summaryrefslogtreecommitdiffstats
path: root/bus
diff options
context:
space:
mode:
Diffstat (limited to 'bus')
-rw-r--r--bus/config-parser.c23
-rw-r--r--bus/selinux.c10
-rw-r--r--bus/selinux.h2
-rw-r--r--bus/session.conf.in3
-rw-r--r--bus/system.conf.in2
5 files changed, 40 insertions, 0 deletions
diff --git a/bus/config-parser.c b/bus/config-parser.c
index dfc313e3..ba1a434d 100644
--- a/bus/config-parser.c
+++ b/bus/config-parser.c
@@ -74,6 +74,7 @@ typedef struct
struct
{
unsigned int ignore_missing : 1;
+ unsigned int if_selinux_enabled : 1;
unsigned int selinux_root_relative : 1;
} include;
@@ -718,6 +719,7 @@ start_busconfig_child (BusConfigParser *parser,
else if (strcmp (element_name, "include") == 0)
{
Element *e;
+ const char *if_selinux_enabled;
const char *ignore_missing;
const char *selinux_root_relative;
@@ -728,6 +730,7 @@ start_busconfig_child (BusConfigParser *parser,
}
e->d.include.ignore_missing = FALSE;
+ e->d.include.if_selinux_enabled = FALSE;
e->d.include.selinux_root_relative = FALSE;
if (!locate_attributes (parser, "include",
@@ -735,6 +738,7 @@ start_busconfig_child (BusConfigParser *parser,
attribute_values,
error,
"ignore_missing", &ignore_missing,
+ "if_selinux_enabled", &if_selinux_enabled,
"selinux_root_relative", &selinux_root_relative,
NULL))
return FALSE;
@@ -752,6 +756,21 @@ start_busconfig_child (BusConfigParser *parser,
return FALSE;
}
}
+
+ if (if_selinux_enabled != NULL)
+ {
+ if (strcmp (if_selinux_enabled, "yes") == 0)
+ e->d.include.if_selinux_enabled = TRUE;
+ else if (strcmp (if_selinux_enabled, "no") == 0)
+ e->d.include.if_selinux_enabled = FALSE;
+ else
+ {
+ dbus_set_error (error, DBUS_ERROR_FAILED,
+ "if_selinux_enabled attribute must have value"
+ " \"yes\" or \"no\"");
+ return FALSE;
+ }
+ }
if (selinux_root_relative != NULL)
{
@@ -2055,6 +2074,10 @@ bus_config_parser_content (BusConfigParser *parser,
e->had_content = TRUE;
+ if (e->d.include.if_selinux_enabled
+ && !bus_selinux_enabled ())
+ break;
+
if (!_dbus_string_init (&full_path))
goto nomem;
diff --git a/bus/selinux.c b/bus/selinux.c
index b5fb6371..0946caf9 100644
--- a/bus/selinux.c
+++ b/bus/selinux.c
@@ -191,6 +191,16 @@ avc_free_lock (void *lock)
#endif /* HAVE_SELINUX */
/**
+ * Return whether or not SELinux is enabled; must be
+ * called after bus_selinux_init.
+ */
+dbus_bool_t
+bus_selinux_enabled (void)
+{
+ return selinux_enabled;
+}
+
+/**
* Initialize the user space access vector cache (AVC) for D-BUS and set up
* logging callbacks.
*/
diff --git a/bus/selinux.h b/bus/selinux.h
index 20803833..886f9c71 100644
--- a/bus/selinux.h
+++ b/bus/selinux.h
@@ -30,6 +30,8 @@
dbus_bool_t bus_selinux_init (void);
void bus_selinux_shutdown (void);
+dbus_bool_t bus_selinux_enabled (void);
+
void bus_selinux_id_ref (BusSELinuxID *sid);
void bus_selinux_id_unref (BusSELinuxID *sid);
diff --git a/bus/session.conf.in b/bus/session.conf.in
index 34d2492c..a537d9dc 100644
--- a/bus/session.conf.in
+++ b/bus/session.conf.in
@@ -26,4 +26,7 @@
<!-- This is included last so local configuration can override what's
in this standard file -->
<include ignore_missing="yes">session-local.conf</include>
+
+ <include if_selinux_enabled="yes" selinux_root_relative="yes">contexts/dbus_contexts</include>
+
</busconfig>
diff --git a/bus/system.conf.in b/bus/system.conf.in
index a45faaef..7b008978 100644
--- a/bus/system.conf.in
+++ b/bus/system.conf.in
@@ -57,4 +57,6 @@
in this standard file -->
<include ignore_missing="yes">system-local.conf</include>
+ <include if_selinux_enabled="yes" selinux_root_relative="yes">contexts/dbus_contexts</include>
+
</busconfig>