summaryrefslogtreecommitdiff
path: root/bus/config-parser.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2004-10-18 04:04:12 +0000
committerColin Walters <walters@verbum.org>2004-10-18 04:04:12 +0000
commit736fa825e15c8d72eac85080e6cdf028c2f8df43 (patch)
tree6775c8bd1b8170ff3312ec055d369fb7d66997ba /bus/config-parser.c
parentca293924a0320277919c881d36bccdae5b8a32e7 (diff)
downloaddbus-736fa825e15c8d72eac85080e6cdf028c2f8df43.tar.gz
2004-10-18 Colin Walters <walters@verbum.org>
* bus/selinux.h: Add bus_selinux_enabled. * bus/selinux.c (bus_selinux_enabled): Implement it. * bus/config-parser.c (struct include): Add if_selinux_enabled member. (start_busconfig_child): Parse if_selinux_enabled attribute for include. (bus_config_parser_content): Handle it. * bus/session.conf.in, bus/system.conf.in: Add inclusion of context mapping to default config files; conditional on SELinux being enabled. * doc/busconfig.dtd: Add to if_selinux_enabled to default DTD. * test/data/invalid-config-files/badselinux-1.conf, test/data/invalid-config-files/badselinux-2.conf: Test files for bad syntax.
Diffstat (limited to 'bus/config-parser.c')
-rw-r--r--bus/config-parser.c23
1 files changed, 23 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;