From: Alan Jenkins Date: Tue, 3 Oct 2017 11:26:02 +0000 (+0100) Subject: logind: use pid_is_valid() where appropriate X-Git-Tag: v235~22^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F6975%2Fhead;p=thirdparty%2Fsystemd.git logind: use pid_is_valid() where appropriate These two sites _do_ match the definition of pid_is_valid(); they don't provide any special handling for the invalid PID value 0. (They're used by dbus methods, so the PID value 0 is handled with reference to the dbus client creds, outside of these functions). --- diff --git a/src/login/logind-core.c b/src/login/logind-core.c index 997c421e9a8..ba538559f9e 100644 --- a/src/login/logind-core.c +++ b/src/login/logind-core.c @@ -287,7 +287,7 @@ int manager_get_session_by_pid(Manager *m, pid_t pid, Session **session) { assert(m); - if (pid < 1) + if (!pid_is_valid(pid)) return -EINVAL; r = cg_pid_get_unit(pid, &unit); @@ -311,7 +311,7 @@ int manager_get_user_by_pid(Manager *m, pid_t pid, User **user) { assert(m); assert(user); - if (pid < 1) + if (!pid_is_valid(pid)) return -EINVAL; r = cg_pid_get_slice(pid, &unit);