From 0bc0e1461a6177078ed0feb0d1a3ad449c9944b4 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 19 Feb 2015 12:08:59 +0000 Subject: [PATCH 2/2] audit: use DBUS_SYSTEM_LOG_WARNING if we cannot open the audit fd --- bus/audit.c | 14 ++++++++++---- bus/audit.h | 4 +++- bus/bus.c | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/bus/audit.c b/bus/audit.c index 97f7d1c..1aa1e18 100644 --- a/bus/audit.c +++ b/bus/audit.c @@ -49,20 +49,26 @@ static int audit_fd = -1; * Open the libaudit fd if appropriate. */ void -bus_audit_init(void) +bus_audit_init (BusContext *context) { #ifdef HAVE_LIBAUDIT audit_fd = audit_open (); if (audit_fd < 0) { + int e = errno; + /* If kernel doesn't support audit, bail out */ - if (errno == EINVAL || errno == EPROTONOSUPPORT || errno == EAFNOSUPPORT) + if (e == EINVAL || e == EPROTONOSUPPORT || e == EAFNOSUPPORT) return; + /* If user bus, bail out */ - if (errno == EPERM && getuid() != 0) + if (e == EPERM && getuid () != 0) return; - _dbus_warn ("Failed opening connection to the audit subsystem"); + + bus_context_log (context, DBUS_SYSTEM_LOG_WARNING, + "Failed to open connection to the audit subsystem: %s", + _dbus_strerror (e)); } #endif /* HAVE_LIBAUDIT */ } diff --git a/bus/audit.h b/bus/audit.h index 367d7e7..e17016f 100644 --- a/bus/audit.h +++ b/bus/audit.h @@ -24,7 +24,9 @@ #include -void bus_audit_init (void); +#include "bus.h" + +void bus_audit_init (BusContext *context); int bus_audit_get_fd (void); void bus_audit_shutdown (void); diff --git a/bus/bus.c b/bus/bus.c index 31e4e5e..f0a1767 100644 --- a/bus/bus.c +++ b/bus/bus.c @@ -972,7 +972,7 @@ bus_context_new (const DBusString *config_file, goto failed; } - bus_audit_init (); + bus_audit_init (context); } dbus_server_free_data_slot (&server_data_slot); -- 2.1.4