summaryrefslogtreecommitdiff
path: root/bus/bus.c
diff options
context:
space:
mode:
authorJohn Johansen <john.johansen@canonical.com>2014-02-12 12:37:41 -0600
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2015-02-18 17:04:02 +0000
commit2a881a9e75526986b3df1c999a78bd8326d77082 (patch)
tree0378b7defe3ba5dda613055808f324f1c0acf950 /bus/bus.c
parent06033cb20fb6b33fc26c2ef3f5bec1bf75596e34 (diff)
downloaddbus-2a881a9e75526986b3df1c999a78bd8326d77082.tar.gz
Initialize AppArmor mediation
When starting dbus-daemon, autodetect AppArmor kernel support and use the results from parsing the busconfig to determine if mediation should be enabled. In the busconfig, "enabled" means that kernel support is autodetected and, if available, AppArmor mediation occurs in dbus-daemon. In "enabled" mode, if kernel support is not detected, mediation is disabled. "disabled" means that mediation does not occur. "required" means that kernel support must be detected for dbus-daemon to start. Additionally, when libaudit support is built into dbus-daemon, the AppArmor initialization routines set up the audit connection. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=75113 Signed-off-by: John Johansen <john.johansen@canonical.com> [tyhicks: Honor enforcement modes and detect AppArmor dbus rule support] [tyhicks: fix unreachable return when AppArmor support is built] [tyhicks: make bus_apparmor_full_init() able to raise a DBusError] Signed-off-by: Tyler Hicks <tyhicks@canonical.com> [smcv: _bus_apparmor_aa_supports_dbus: document necessary kernel API guarantee] [smcv: bus_apparmor_pre_init: distinguish between OOM and AppArmor not enabled] [smcv: document why we open() and not just stat()] Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Reviewed-by: Tyler Hicks <tyhicks@canonical.com>
Diffstat (limited to 'bus/bus.c')
-rw-r--r--bus/bus.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/bus/bus.c b/bus/bus.c
index 091fbe28..2c2c5649 100644
--- a/bus/bus.c
+++ b/bus/bus.c
@@ -34,6 +34,7 @@
#include "config-parser.h"
#include "signals.h"
#include "selinux.h"
+#include "apparmor.h"
#include "dir-watch.h"
#include <dbus/dbus-list.h>
#include <dbus/dbus-hash.h>
@@ -933,6 +934,20 @@ bus_context_new (const DBusString *config_file,
bus_context_log (context, DBUS_SYSTEM_LOG_FATAL, "SELinux enabled but D-Bus initialization failed; check system log\n");
}
+ if (!bus_apparmor_full_init (error))
+ {
+ _DBUS_ASSERT_ERROR_IS_SET (error);
+ goto failed;
+ }
+
+ if (bus_apparmor_enabled ())
+ {
+ /* Only print AppArmor mediation message when syslog support is enabled */
+ if (context->syslog)
+ bus_context_log (context, DBUS_SYSTEM_LOG_INFO,
+ "AppArmor D-Bus mediation is enabled\n");
+ }
+
if (!process_config_postinit (context, parser, error))
{
_DBUS_ASSERT_ERROR_IS_SET (error);
@@ -960,6 +975,9 @@ bus_context_new (const DBusString *config_file,
/* FIXME - why not just put this in full_init() below? */
bus_selinux_audit_init ();
#endif
+#ifdef HAVE_APPARMOR
+ bus_apparmor_audit_init ();
+#endif
}
dbus_server_free_data_slot (&server_data_slot);