From: Simon McVittie Date: Sat, 29 Jun 2019 16:36:36 +0000 (+0100) Subject: bus: Make audit initialization idempotent X-Git-Tag: dbus-1.13.14~27^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1b1c5ddd35405182ef95044effe64109ed2242b2;p=thirdparty%2Fdbus.git 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 --- diff --git a/bus/audit.c b/bus/audit.c index 91f2c5cf6..9bfe456a1 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 */ }