chiark / gitweb /
sd-bus: handle ppid=0 more gracefully (which happens for pid=1)
authorLennart Poettering <lennart@poettering.net>
Wed, 22 Apr 2015 11:27:29 +0000 (13:27 +0200)
committerSven Eden <yamakuzure@gmx.net>
Tue, 14 Mar 2017 07:09:37 +0000 (08:09 +0100)
src/libelogind/sd-bus/bus-creds.c

index ab48aaf..9d519c4 100644 (file)
@@ -734,11 +734,14 @@ int bus_creds_add_more(sd_bus_creds *c, uint64_t mask, pid_t pid, pid_t tid) {
                                         if (p) {
                                                 p += strspn(p, WHITESPACE);
 
-                                                r = parse_pid(p, &c->ppid);
-                                                if (r < 0)
-                                                        return r;
+                                                /* Explicitly check for PPID 0 (which is the case for PID 1) */
+                                                if (!streq(p, "0")) {
+                                                        r = parse_pid(p, &c->ppid);
+                                                        if (r < 0)
+                                                                return r;
 
-                                                c->mask |= SD_BUS_CREDS_PPID;
+                                                        c->mask |= SD_BUS_CREDS_PPID;
+                                                }
                                                 continue;
                                         }
                                 }