From 70e17df9df7562ff4de613ffcf8a3f9f0aa08178 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 18 Feb 2015 11:47:33 +0000 Subject: [PATCH 13/31] fix: document why we open() and not just stat() --- bus/apparmor.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bus/apparmor.c b/bus/apparmor.c index 1f09b6c..645bb84 100644 --- a/bus/apparmor.c +++ b/bus/apparmor.c @@ -112,6 +112,13 @@ _bus_apparmor_detect_aa_dbus_support (dbus_bool_t *is_supported) !_dbus_string_append (&aa_dbus, "/features/dbus/mask")) goto out; + /* We need to open() the flag file, not just stat() it, because AppArmor + * does not mediate stat() in the apparmorfs. If you have a + * dbus-daemon inside an LXC container, with insufficiently broad + * AppArmor privileges to do its own AppArmor mediation, the desired + * result is that it behaves as if AppArmor was not present; but a stat() + * here would succeed, and result in it trying and failing to do full + * mediation. https://bugs.launchpad.net/ubuntu/+source/dbus/+bug/1238267 */ mask_file = open (_dbus_string_get_const_data (&aa_dbus), O_RDONLY | O_CLOEXEC); if (mask_file != -1) -- 2.1.4