From 3a698817043ca8f4059c52b7ff30097462b1f7bc Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 22 Apr 2015 13:27:29 +0200 Subject: [PATCH] sd-bus: handle ppid=0 more gracefully (which happens for pid=1) --- src/libsystemd/sd-bus/bus-creds.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/libsystemd/sd-bus/bus-creds.c b/src/libsystemd/sd-bus/bus-creds.c index 6cb47f55cef..a68b0d00edd 100644 --- a/src/libsystemd/sd-bus/bus-creds.c +++ b/src/libsystemd/sd-bus/bus-creds.c @@ -768,11 +768,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; } }