From eb6b55240da36ce83a391a0b231fbc7f63c73b81 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Mon, 21 Dec 2020 13:11:57 +0100 Subject: [PATCH] bus-creds: Handle ESRCH from get_process_comm FreeBSD's linprocfs does not have a comm file, so get_process_comm returns ESRCH. Handle this gracefully instead of throwing in the towel. --- src/libsystemd/sd-bus/bus-creds.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libsystemd/sd-bus/bus-creds.c b/src/libsystemd/sd-bus/bus-creds.c index d38fe8c..1b3f54a 100644 --- a/src/libsystemd/sd-bus/bus-creds.c +++ b/src/libsystemd/sd-bus/bus-creds.c @@ -850,7 +850,10 @@ int bus_creds_add_more(sd_bus_creds *c, uint64_t mask, pid_t pid, pid_t tid) { if (missing & SD_BUS_CREDS_COMM) { r = get_process_comm(pid, &c->comm); if (r < 0) { - if (!IN_SET(r, -EPERM, -EACCES)) + /* get_process_comm will fail with ESRCH on + * FreeBSD as linprocfs does not have a comm + * file, so we must also handle that here. */ + if (!IN_SET(r, -ESRCH, -EPERM, -EACCES)) return r; } else c->mask |= SD_BUS_CREDS_COMM; -- 2.45.2