From 545cdf34023530be61effc2b6139558cfdcc5160 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Tue, 1 Jul 2014 14:04:59 +0100 Subject: [PATCH 3/4] Add interface element support to the bus config parsing https://bugs.freedesktop.org/show_bug.cgi?id=80759 --- bus/bus.c | 9 +++++++++ bus/config-parser-common.c | 6 ++++++ bus/config-parser-common.h | 1 + bus/config-parser.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ bus/config-parser.h | 1 + bus/session.conf.in | 5 +++++ bus/system.conf.in | 5 +++++ 7 files changed, 73 insertions(+) diff --git a/bus/bus.c b/bus/bus.c index a514e31..89d87de 100644 --- a/bus/bus.c +++ b/bus/bus.c @@ -63,6 +63,7 @@ struct BusContext BusPolicy *policy; BusMatchmaker *matchmaker; BusLimits limits; + DBusList *interfaces; unsigned int fork : 1; unsigned int syslog : 1; unsigned int keep_umask : 1; @@ -518,6 +519,14 @@ process_config_every_time (BusContext *context, return FALSE; } + if (context->interfaces) + { + _dbus_list_foreach (&context->interfaces, + (DBusForeachFunction) dbus_free, NULL); + _dbus_list_clear (&context->interfaces); + } + context->interfaces = bus_config_parser_steal_interfaces (parser); + /* get our limits and timeout lengths */ bus_config_parser_get_limits (parser, &context->limits); diff --git a/bus/config-parser-common.c b/bus/config-parser-common.c index c522ff4..caa490a 100644 --- a/bus/config-parser-common.c +++ b/bus/config-parser-common.c @@ -99,6 +99,10 @@ bus_config_parser_element_name_to_type (const char *name) { return ELEMENT_INCLUDE; } + else if (strcmp (name, "interface") == 0) + { + return ELEMENT_INTERFACE; + } else if (strcmp (name, "policy") == 0) { return ELEMENT_POLICY; @@ -141,6 +145,8 @@ bus_config_parser_element_type_to_name (ElementType type) return "busconfig"; case ELEMENT_INCLUDE: return "include"; + case ELEMENT_INTERFACE: + return "interface"; case ELEMENT_USER: return "user"; case ELEMENT_LISTEN: diff --git a/bus/config-parser-common.h b/bus/config-parser-common.h index 186bf4c..ff5bcb9 100644 --- a/bus/config-parser-common.h +++ b/bus/config-parser-common.h @@ -41,6 +41,7 @@ typedef enum ELEMENT_SERVICEDIR, ELEMENT_SERVICEHELPER, ELEMENT_INCLUDEDIR, + ELEMENT_INTERFACE, /* this is really , but winioctl.h defines ELEMENT_TYPE */ ELEMENT_CONFIGTYPE, ELEMENT_SELINUX, diff --git a/bus/config-parser.c b/bus/config-parser.c index a6a8e1c..8fc18e5 100644 --- a/bus/config-parser.c +++ b/bus/config-parser.c @@ -105,6 +105,8 @@ struct BusConfigParser BusPolicy *policy; /**< Security policy */ + DBusList *interfaces; /**< List of additional interfaces to enable */ + BusLimits limits; /**< Limits */ char *pidfile; /**< PID file */ @@ -903,6 +905,19 @@ start_busconfig_child (BusConfigParser *parser, return TRUE; } + else if (element_type == ELEMENT_INTERFACE) + { + if (!check_no_attributes (parser, "interface", attribute_names, attribute_values, error)) + return FALSE; + + if (push_element (parser, ELEMENT_INTERFACE) == NULL) + { + BUS_SET_OOM (error); + return FALSE; + } + + return TRUE; + } else if (element_type == ELEMENT_INCLUDE) { Element *e; @@ -2034,6 +2049,7 @@ bus_config_parser_end_element (BusConfigParser *parser, case ELEMENT_SERVICEDIR: case ELEMENT_SERVICEHELPER: case ELEMENT_INCLUDEDIR: + case ELEMENT_INTERFACE: case ELEMENT_LIMIT: if (!e->had_content) { @@ -2386,6 +2402,24 @@ bus_config_parser_content (BusConfigParser *parser, } break; + case ELEMENT_INTERFACE: + { + char *s; + + e->had_content = TRUE; + + if (!_dbus_string_copy_data (content, &s)) + goto nomem; + + if (!_dbus_list_append (&parser->interfaces, + s)) + { + dbus_free (s); + goto nomem; + } + } + break; + case ELEMENT_INCLUDE: { DBusString full_path, selinux_policy_root; @@ -2656,6 +2690,18 @@ bus_config_parser_get_addresses (BusConfigParser *parser) return &parser->listen_on; } +DBusList* +bus_config_parser_steal_interfaces (BusConfigParser *parser) +{ + DBusList *interfaces; + + interfaces = parser->interfaces; + + parser->interfaces = NULL; + + return interfaces; +} + DBusList** bus_config_parser_get_mechanisms (BusConfigParser *parser) { diff --git a/bus/config-parser.h b/bus/config-parser.h index ba5bf74..5252993 100644 --- a/bus/config-parser.h +++ b/bus/config-parser.h @@ -71,6 +71,7 @@ const char* bus_config_parser_get_servicehelper (BusConfigParser *parser); DBusList** bus_config_parser_get_service_dirs (BusConfigParser *parser); DBusList** bus_config_parser_get_conf_dirs (BusConfigParser *parser); BusPolicy* bus_config_parser_steal_policy (BusConfigParser *parser); +DBusList* bus_config_parser_steal_interfaces (BusConfigParser *parser); void bus_config_parser_get_limits (BusConfigParser *parser, BusLimits *limits); diff --git a/bus/session.conf.in b/bus/session.conf.in index 74d9d1f..15784e1 100644 --- a/bus/session.conf.in +++ b/bus/session.conf.in @@ -35,6 +35,11 @@ contexts/dbus_contexts + + + + + -- 1.8.5.3