DBusList *included_files; /**< Included files stack */
- DBusHashTable *service_sid_table; /**< Map service names to SELinux contexts */
+ DBusHashTable *service_context_table; /**< Map service names to SELinux contexts */
unsigned int fork : 1; /**< TRUE to fork into daemon mode */
}
static dbus_bool_t
+merge_service_context_hash (DBusHashTable *dest,
+ DBusHashTable *from)
+{
+ DBusHashIter iter;
+
+ _dbus_hash_iter_init (from, &iter);
+ while (_dbus_hash_iter_next (&iter))
+ {
+ const char *service = _dbus_hash_iter_get_string_key (&iter);
+ const char *context = _dbus_hash_iter_get_value (&iter);
+ char *service_copy;
+ char *context_copy;
+
+ service_copy = _dbus_strdup (service);
+ if (service_copy == NULL)
+ return FALSE;
+ context_copy = _dbus_strdup (context);
+ if (context_copy == NULL)
+ return FALSE;
+
+ if (!_dbus_hash_table_insert_string (dest, service_copy, context_copy))
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static dbus_bool_t
merge_included (BusConfigParser *parser,
BusConfigParser *included,
DBusError *error)
{
DBusList *link;
- DBusHashTable *table;
if (!bus_policy_merge (parser->policy,
included->policy))
return FALSE;
}
- table = bus_selinux_id_table_union (parser->service_sid_table,
- included->service_sid_table);
- if (table == NULL)
+ if (!merge_service_context_hash (parser->service_context_table,
+ included->service_context_table))
{
BUS_SET_OOM (error);
return FALSE;
}
-
- _dbus_hash_table_unref (parser->service_sid_table);
- parser->service_sid_table = table;
if (included->user != NULL)
{
if (((parser->policy = bus_policy_new ()) == NULL) ||
!_dbus_string_copy (basedir, 0, &parser->basedir, 0) ||
- ((parser->service_sid_table = bus_selinux_id_table_new ()) == NULL))
+ ((parser->service_context_table = _dbus_hash_table_new (DBUS_HASH_STRING,
+ dbus_free,
+ dbus_free)) == NULL))
{
if (parser->policy)
bus_policy_unref (parser->policy);
if (parser->policy)
bus_policy_unref (parser->policy);
- if (parser->service_sid_table)
- _dbus_hash_table_unref (parser->service_sid_table);
+ if (parser->service_context_table)
+ _dbus_hash_table_unref (parser->service_context_table);
dbus_free (parser);
}
{
const char *own;
const char *context;
+ char *own_copy;
+ char *context_copy;
if (!locate_attributes (parser, "associate",
attribute_names,
return FALSE;
}
- if (!bus_selinux_id_table_insert (parser->service_sid_table,
- own, context))
+ own_copy = _dbus_strdup (own);
+ if (own_copy == NULL)
+ return FALSE;
+ context_copy = _dbus_strdup (context);
+ if (context_copy == NULL)
+ return FALSE;
+
+ if (!_dbus_hash_table_insert_string (parser->service_context_table,
+ own_copy, context_copy))
{
BUS_SET_OOM (error);
return FALSE;
}
DBusHashTable*
-bus_config_parser_steal_service_sid_table (BusConfigParser *parser)
+bus_config_parser_steal_service_context_table (BusConfigParser *parser)
{
DBusHashTable *table;
- _dbus_assert (parser->service_sid_table != NULL); /* can only steal once */
+ _dbus_assert (parser->service_context_table != NULL); /* can only steal once */
- table = parser->service_sid_table;
+ table = parser->service_context_table;
- parser->service_sid_table = NULL;
+ parser->service_context_table = NULL;
return table;
}