sd-bus: make credential acquisition more graceful
authorLennart Poettering <lennart@poettering.net>
Mon, 14 Dec 2020 12:16:39 +0000 (13:16 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 2 Feb 2021 13:52:52 +0000 (14:52 +0100)
commita1b1ef65a4371e8aec4b0df1326e4cb5de005e80
treea6c40c88842445be4bbf49a85d9a0e5fc6b58020
parenta62421591e3edb47fa2a85499e4d721eeff73c42
sd-bus: make credential acquisition more graceful

So far when asked for augmented bus credentials and the process was
already gone we'd fail fatally. Let's make this graceful instead, and
never allow augmenting fail due to PID having vanished — unless the
augmenting is the explicit and only purpose of the requested operation.

This should be safe as clients have to explicitly query the acquired
creds anyway and handle if they couldn't be acquired. Moreover we
already handle permission problems gracefully, thus clients must be
ready to deal with missing creds.

This is useful to make selinux authorization work for short-lived client
proceses. PReviously we'd augment creds to have more info to log about
(the selinux decision would not be based on augmented data however,
because that'd be unsafe), and would fail if we couldn't get it. Now,
we'll try to acquire the data, but if we cannot acquire it, we'll still
do the selinux check, except that logging will be more limited.

(cherry picked from commit f8ecc2c00df7bd810557f3056ec12f6a0730812d)
src/libsystemd/sd-bus/bus-control.c
src/libsystemd/sd-bus/bus-convenience.c