summaryrefslogtreecommitdiffstats
path: root/bus/bus.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2004-11-07 17:05:19 +0000
committerColin Walters <walters@verbum.org>2004-11-07 17:05:19 +0000
commitcdac3e058b922431f387351fd8ebf60a764485d1 (patch)
treea92b8fa08c2657b6339d9590be5309ff627d1512 /bus/bus.c
parenta14c43cf3ab7a2636146410e52be5e421fc0aaf9 (diff)
2004-11-07 Colin Walters <walters@verbum.org>
* bus/bus.c (load_config): Break into three separate functions: process_config_first_time_only, process_config_every_time, and process_config_postinit. (process_config_every_time): Move call of bus_registry_set_service_context_table into process_config_postinit. (process_config_postinit): New function, does any processing that needs to happen late in initialization (and also on reload). (bus_context_new): Instead of calling load_config, open config parser here and call process_config_first_time_only and process_config_every_time directly. Later, after we have forked but before changing UID, invoke bus_selinux_full_init, and then call process_config_postinit. (bus_context_reload_config): As in bus_context_new, load parse file inside here, and call process_config_every_time and process_config_postinit. * bus/services.h, bus/services.c (bus_registry_set_service_context_table): Rename from bus_registry_set_sid_table. Take string hash from config parser, and convert them here into SIDs. * bus/config-parser.c (struct BusConfigParser): Have config parser only store a mapping of service->context string. (merge_service_context_hash): New function. (merge_included): Merge context string hashes instead of using bus_selinux_id_table_union. (bus_config_parser_new): Don't use bus_selinux_id_table_new; simply create a new string hash. (bus_config_parser_unref): Unref it. (start_selinux_child): Simply insert strings into hash, don't call bus_selinux_id_table_copy_over. * bus/selinux.h, bus/selinux.c (bus_selinux_id_table_union) (bus_selinux_id_table_copy_over): Delete.
Diffstat (limited to 'bus/bus.c')
-rw-r--r--bus/bus.c117
1 files changed, 72 insertions, 45 deletions
diff --git a/bus/bus.c b/bus/bus.c
index b34e635c..65e396c3 100644
--- a/bus/bus.c
+++ b/bus/bus.c
@@ -401,7 +401,6 @@ process_config_every_time (BusContext *context,
{
DBusString full_address;
DBusList *link;
- DBusHashTable *service_sid_table;
dbus_bool_t retval;
@@ -479,11 +478,6 @@ process_config_every_time (BusContext *context,
goto failed;
}
- service_sid_table = bus_config_parser_steal_service_sid_table (parser);
- bus_registry_set_service_sid_table (context->registry,
- service_sid_table);
- _dbus_hash_table_unref (service_sid_table);
-
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
retval = TRUE;
@@ -493,46 +487,22 @@ process_config_every_time (BusContext *context,
}
static dbus_bool_t
-load_config (BusContext *context,
- dbus_bool_t is_reload,
- DBusError *error)
+process_config_postinit (BusContext *context,
+ BusConfigParser *parser,
+ DBusError *error)
{
- BusConfigParser *parser;
- DBusString config_file;
- dbus_bool_t retval;
-
- _DBUS_ASSERT_ERROR_IS_CLEAR (error);
+ DBusHashTable *service_context_table;
- retval = FALSE;
- parser = NULL;
-
- _dbus_string_init_const (&config_file, context->config_file);
- parser = bus_config_load (&config_file, TRUE, NULL, error);
- if (parser == NULL)
- {
- _DBUS_ASSERT_ERROR_IS_SET (error);
- goto failed;
- }
-
- if (!is_reload && !process_config_first_time_only (context, parser, error))
+ service_context_table = bus_config_parser_steal_service_context_table (parser);
+ if (!bus_registry_set_service_context_table (context->registry,
+ service_context_table))
{
- _DBUS_ASSERT_ERROR_IS_SET (error);
- goto failed;
- }
-
- if (!process_config_every_time (context, parser, is_reload, error))
- {
- _DBUS_ASSERT_ERROR_IS_SET (error);
- goto failed;
+ BUS_SET_OOM (error);
+ return FALSE;
}
- _DBUS_ASSERT_ERROR_IS_CLEAR (error);
- retval = TRUE;
-
- failed:
- if (parser)
- bus_config_parser_unref (parser);
- return retval;
+ _dbus_hash_table_unref (service_context_table);
+ return TRUE;
}
BusContext*
@@ -543,9 +513,13 @@ bus_context_new (const DBusString *config_file,
DBusError *error)
{
BusContext *context;
+ BusConfigParser *parser;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
+ context = NULL;
+ parser = NULL;
+
if (!dbus_server_allocate_data_slot (&server_data_slot))
{
BUS_SET_OOM (error);
@@ -579,8 +553,20 @@ bus_context_new (const DBusString *config_file,
BUS_SET_OOM (error);
goto failed;
}
+
+ parser = bus_config_load (config_file, TRUE, NULL, error);
+ if (parser == NULL)
+ {
+ _DBUS_ASSERT_ERROR_IS_SET (error);
+ goto failed;
+ }
- if (!load_config (context, FALSE, error))
+ if (!process_config_first_time_only (context, parser, error))
+ {
+ _DBUS_ASSERT_ERROR_IS_SET (error);
+ goto failed;
+ }
+ if (!process_config_every_time (context, parser, FALSE, error))
{
_DBUS_ASSERT_ERROR_IS_SET (error);
goto failed;
@@ -723,6 +709,19 @@ bus_context_new (const DBusString *config_file,
_dbus_string_free (&pid);
}
+
+ if (!bus_selinux_full_init ())
+ {
+ _dbus_warn ("SELinux initialization failed\n");
+ }
+
+ if (!process_config_postinit (context, parser, error))
+ {
+ _DBUS_ASSERT_ERROR_IS_SET (error);
+ goto failed;
+ }
+ if (parser != NULL)
+ bus_config_parser_unref (parser);
/* Here we change our credentials if required,
* as soon as we've set up our sockets and pidfile
@@ -756,6 +755,8 @@ bus_context_new (const DBusString *config_file,
return context;
failed:
+ if (parser != NULL)
+ bus_config_parser_unref (parser);
if (context != NULL)
bus_context_unref (context);
@@ -769,9 +770,35 @@ dbus_bool_t
bus_context_reload_config (BusContext *context,
DBusError *error)
{
- return load_config (context,
- TRUE, /* yes, we are re-loading */
- error);
+ BusConfigParser *parser;
+ DBusString config_file;
+ dbus_bool_t ret;
+
+ ret = FALSE;
+ _dbus_string_init_const (&config_file, context->config_file);
+ parser = bus_config_load (&config_file, TRUE, NULL, error);
+ if (parser == NULL)
+ {
+ _DBUS_ASSERT_ERROR_IS_SET (error);
+ goto failed;
+ }
+
+ if (!process_config_every_time (context, parser, TRUE, error))
+ {
+ _DBUS_ASSERT_ERROR_IS_SET (error);
+ goto failed;
+ }
+ if (!process_config_postinit (context, parser, error))
+ {
+ _DBUS_ASSERT_ERROR_IS_SET (error);
+ goto failed;
+ }
+ ret = TRUE;
+
+ failed:
+ if (parser != NULL)
+ bus_config_parser_unref (parser);
+ return ret;
}
static void