~emersion/basu

eb6b55240da36ce83a391a0b231fbc7f63c73b81 — Kenny Levinsen 2 years ago d40b2ab
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.
1 files changed, 4 insertions(+), 1 deletions(-)

M src/libsystemd/sd-bus/bus-creds.c
M src/libsystemd/sd-bus/bus-creds.c => src/libsystemd/sd-bus/bus-creds.c +4 -1
@@ 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;