From: Zbigniew Jędrzejewski-Szmek Date: Wed, 13 Apr 2016 03:52:41 +0000 (-0400) Subject: logind: make KillOnlyUsers override KillUserProcesses X-Git-Tag: v230~158^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=921f831d3e2e27a0da16d93ad3dc468263a63320;p=thirdparty%2Fsystemd.git logind: make KillOnlyUsers override KillUserProcesses Instead of KillOnlyUsers being a filter for KillUserProcesses, it can now be used to specify users to kill, independently of the KillUserProcesses setting. Having the settings orthogonal seems to make more sense. It also makes KillOnlyUsers symmetrical to KillExcludeUsers. --- diff --git a/man/logind.conf.xml b/man/logind.conf.xml index 6e587c3561e..3217ece21af 100644 --- a/man/logind.conf.xml +++ b/man/logind.conf.xml @@ -124,7 +124,9 @@ corresponding to the session and all processes inside that scope will be terminated. If false, the scope is "abandonded", see systemd.scope5, - and processes are not killed. Defaults to yes. + and processes are not killed. Defaults to yes, + but see the options KillOnlyUsers= and + KillExcludeUsers= below. In addition to session processes, user process may run under the user manager unit user@.service. Depending on the linger @@ -147,17 +149,16 @@ KillOnlyUsers= KillExcludeUsers= - These settings take space-separated lists of usernames that - determine to which users the KillUserProcesses= setting - applies. A user name may be added to KillExcludeUsers= to - exclude the processes in the session scopes of that user from being killed even if - KillUserProcesses=yes is set. If - KillExcludeUsers= is not set, the root user - is excluded by default. KillExcludeUsers= may be set to an - empty value to override this default. If a user is not excluded, - KillOnlyUsers= is checked next. A list of user names may be - specified in KillOnlyUsers=, to only include those - users. Otherwise, all users are included. + These settings take space-separated lists of usernames that override + the KillUserProcesses= setting. A user name may be added to + KillExcludeUsers= to exclude the processes in the session scopes of + that user from being killed even if KillUserProcesses=yes is set. If + KillExcludeUsers= is not set, the root user is + excluded by default. KillExcludeUsers= may be set to an empty value + to override this default. If a user is not excluded, KillOnlyUsers= + is checked next. If this setting is specified, only the session scopes of those users + will be killed. Otherwise, users are subject to the + KillUserProcesses=yes setting. diff --git a/src/login/logind-core.c b/src/login/logind-core.c index 73075274e0a..cbf8d757fee 100644 --- a/src/login/logind-core.c +++ b/src/login/logind-core.c @@ -364,19 +364,16 @@ bool manager_shall_kill(Manager *m, const char *user) { assert(m); assert(user); - if (!m->kill_user_processes) - return false; - if (!m->kill_exclude_users && streq(user, "root")) return false; if (strv_contains(m->kill_exclude_users, user)) return false; - if (strv_isempty(m->kill_only_users)) - return true; + if (!strv_isempty(m->kill_only_users)) + return strv_contains(m->kill_only_users, user); - return strv_contains(m->kill_only_users, user); + return m->kill_user_processes; } static int vt_is_busy(unsigned int vtnr) {