summaryrefslogtreecommitdiff
path: root/src/login/logind-dbus.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-02-06 18:32:14 +0100
committerLennart Poettering <lennart@poettering.net>2014-02-07 15:14:36 +0100
commit5f41d1f10fd97e93517b6a762b1bec247f4d1171 (patch)
treea599559b6177bd9fccd01c56f74fad9b81a61851 /src/login/logind-dbus.c
parenta911bb9ab27ac0eb3bbf4e8b4109e5da9b88eee3 (diff)
logind: rework session shutdown logic
Simplify the shutdown logic a bit: - Keep the session FIFO around in the PAM module, even after the session shutdown hook has been finished. This allows logind to track precisely when the PAM handler goes away. - In the ReleaseSession() call start a timer, that will stop terminate the session when elapsed. - Never fiddle with the KillMode of scopes to configure whether user processes should be killed or not. Instead, simply leave the scope units around when we terminate a session whose processes should not be killed. - When killing is enabled, stop the session scope on FIFO EOF or after the ReleaseSession() timeout. When killing is disabled, simply tell PID 1 to abandon the scope. Because the scopes stay around and hence all processes are always member of a scope, the system shutdown logic should be more robust, as the scopes can be shutdown as part of the usual shutdown logic.
Diffstat (limited to 'src/login/logind-dbus.c')
-rw-r--r--src/login/logind-dbus.c51
1 files changed, 35 insertions, 16 deletions
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 4745961773..40885557c1 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -748,15 +748,7 @@ static int method_release_session(sd_bus *bus, sd_bus_message *message, void *us
if (!session)
return sd_bus_error_setf(error, BUS_ERROR_NO_SUCH_SESSION, "No session '%s' known", name);
- /* We use the FIFO to detect stray sessions where the process
- invoking PAM dies abnormally. We need to make sure that
- that process is not killed if at the clean end of the
- session it closes the FIFO. Hence, with this call
- explicitly turn off the FIFO logic, so that the PAM code
- can finish clean up on its own */
- session_remove_fifo(session);
- session_save(session);
- user_save(session->user);
+ session_release(session);
return sd_bus_reply_method_return(message, NULL);
}
@@ -2185,7 +2177,6 @@ int manager_start_scope(
const char *slice,
const char *description,
const char *after,
- const char *kill_mode,
sd_bus_error *error,
char **job) {
@@ -2232,12 +2223,6 @@ int manager_start_scope(
return r;
}
- if (!isempty(kill_mode)) {
- r = sd_bus_message_append(m, "(sv)", "KillMode", "s", kill_mode);
- if (r < 0)
- return r;
- }
-
/* cgroup empty notification is not available in containers
* currently. To make this less problematic, let's shorten the
* stop timeout for sessions, so that we don't wait
@@ -2372,6 +2357,40 @@ int manager_stop_unit(Manager *manager, const char *unit, sd_bus_error *error, c
return 1;
}
+int manager_abandon_scope(Manager *manager, const char *scope, sd_bus_error *error) {
+ _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
+ _cleanup_free_ char *path = NULL;
+ int r;
+
+ assert(manager);
+ assert(scope);
+
+ path = unit_dbus_path_from_name(scope);
+ if (!path)
+ return -ENOMEM;
+
+ r = sd_bus_call_method(
+ manager->bus,
+ "org.freedesktop.systemd1",
+ path,
+ "org.freedesktop.systemd1.Scope",
+ "Abandon",
+ error,
+ NULL,
+ NULL);
+ if (r < 0) {
+ if (sd_bus_error_has_name(error, BUS_ERROR_NO_SUCH_UNIT) ||
+ sd_bus_error_has_name(error, BUS_ERROR_LOAD_FAILED)) {
+ sd_bus_error_free(error);
+ return 0;
+ }
+
+ return r;
+ }
+
+ return 1;
+}
+
int manager_kill_unit(Manager *manager, const char *unit, KillWho who, int signo, sd_bus_error *error) {
assert(manager);
assert(unit);