chiark / gitweb /
logind: use pid_is_valid() where appropriate
authorAlan Jenkins <alan.christopher.jenkins@gmail.com>
Tue, 3 Oct 2017 11:26:02 +0000 (12:26 +0100)
committerSven Eden <yamakuzure@gmx.net>
Fri, 8 Dec 2017 06:27:39 +0000 (07:27 +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 714503228bfb534f7dd63ca70dfdb7dce9440f28..95e2363dd0589ae182fe44d0c1c060ea79c8cb61 100644 (file)
@@ -291,7 +291,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;
 
 #if 0 /// elogind does not support systemd units, but its own session system
@@ -330,7 +330,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;
 
 #if 0 /// elogind does not support systemd units, but its own session system