diff options
author | Simon McVittie <smcv@collabora.com> | 2019-06-29 17:36:36 +0100 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2019-07-03 11:11:23 +0100 |
commit | 1b1c5ddd35405182ef95044effe64109ed2242b2 (patch) | |
tree | dd09de37039fe48ce9e94cdbbde6e7fbf676ea7b /bus | |
parent | e148aa47d365ef28c524d666e060f3c8b7a9891f (diff) | |
download | dbus-1b1c5ddd35405182ef95044effe64109ed2242b2.tar.gz |
bus: Make audit initialization idempotent
The audit module is initialized every time a new BusContext is created,
which is only once in the real dbus-daemon, but can happen several times
in some unit tests.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'bus')
-rw-r--r-- | bus/audit.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/bus/audit.c b/bus/audit.c index 91f2c5cf..9bfe456a 100644 --- a/bus/audit.c +++ b/bus/audit.c @@ -54,6 +54,9 @@ bus_audit_init (BusContext *context) #ifdef HAVE_LIBAUDIT int i; + if (audit_fd >= 0) + return; + capng_get_caps_process (); /* Work around a bug in libcap-ng < 0.7.7: it leaks a fd, which isn't @@ -105,7 +108,11 @@ void bus_audit_shutdown (void) { #ifdef HAVE_LIBAUDIT - audit_close (audit_fd); + if (audit_fd >= 0) + { + audit_close (audit_fd); + audit_fd = -1; + } #endif /* HAVE_LIBAUDIT */ } |