]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: use pid_is_valid() where appropriate 6975/head
authorAlan Jenkins <alan.christopher.jenkins@gmail.com>
Tue, 3 Oct 2017 11:26:02 +0000 (12:26 +0100)
committerAlan Jenkins <alan.christopher.jenkins@gmail.com>
Wed, 4 Oct 2017 14:40:20 +0000 (15:40 +0100)
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).

src/login/logind-core.c

index 997c421e9a8647c01084a20457ee6099ba2656be..ba538559f9e1c9d39dd9b2ef7e8483b93a6b3c16 100644 (file)
@@ -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);