summaryrefslogtreecommitdiffstats
path: root/bus/config-parser.c
diff options
context:
space:
mode:
authorJohn (J5) Palmieri <johnp@redhat.com>2006-11-01 23:30:46 +0000
committerJohn (J5) Palmieri <johnp@redhat.com>2006-11-01 23:30:46 +0000
commit5640f7a57b6c8b2e1847e99db412db3c41c9eb98 (patch)
tree206f2e037572003d5a20d285592e1e7267cb7509 /bus/config-parser.c
parentd3440ebe9de8ac9f817ae992244463c197c20f84 (diff)
* configure.in: expose DBUS_DATADIR
* bus/config-parser.c: add the standard_session_servicedirs element to the parser (bus_config_parser_content): process the standard_session_servicedirs element by getting the standard directories from sysdeps and merging them into the service directory list (test_default_session_servicedirs): make sure we get what we expect * bus/session.conf.in: replace the servicedir tag with the standard_session_servicedirs tag * dbus/dbus-list.h: remove the typedef of DBusList and place it in dbus-sysdeps.h to avoid circular header dependencies * dbus/dbus-sysdeps.h: add the typedef of DBusList * dbus/dbus-sysdeps-unix.c (split_paths_and_append): utility function which takes a string of directories delimited by colons, parses them out, appends a suffix and puts them in a list ignoring empty elements (_dbus_get_standard_session_servicedirs): returns the standard directories for a session bus to look for service activation files on Unix which includes the XDG_DATA_HOME, XDG_DATA_DIRS and DBUS_DATADIR directories * test/data/valid-config-files/many-rules.conf: add the standard_session_servicedirs tag to the valid config file tests
Diffstat (limited to 'bus/config-parser.c')
-rw-r--r--bus/config-parser.c120
1 files changed, 119 insertions, 1 deletions
diff --git a/bus/config-parser.c b/bus/config-parser.c
index b126eb0c..70bc441d 100644
--- a/bus/config-parser.c
+++ b/bus/config-parser.c
@@ -47,7 +47,8 @@ typedef enum
ELEMENT_INCLUDEDIR,
ELEMENT_TYPE,
ELEMENT_SELINUX,
- ELEMENT_ASSOCIATE
+ ELEMENT_ASSOCIATE,
+ ELEMENT_STANDARD_SESSION_SERVICEDIRS
} ElementType;
typedef enum
@@ -161,6 +162,8 @@ element_type_to_name (ElementType type)
return "fork";
case ELEMENT_PIDFILE:
return "pidfile";
+ case ELEMENT_STANDARD_SESSION_SERVICEDIRS:
+ return "standard_session_servicedirs";
case ELEMENT_SERVICEDIR:
return "servicedir";
case ELEMENT_INCLUDEDIR:
@@ -800,6 +803,19 @@ start_busconfig_child (BusConfigParser *parser,
return TRUE;
}
+ else if (strcmp (element_name, "standard_session_servicedirs") == 0)
+ {
+ if (!check_no_attributes (parser, "standard_session_servicedirs", attribute_names, attribute_values, error))
+ return FALSE;
+
+ if (push_element (parser, ELEMENT_STANDARD_SESSION_SERVICEDIRS) == NULL)
+ {
+ BUS_SET_OOM (error);
+ return FALSE;
+ }
+
+ return TRUE;
+ }
else if (strcmp (element_name, "servicedir") == 0)
{
if (!check_no_attributes (parser, "servicedir", attribute_names, attribute_values, error))
@@ -1927,6 +1943,7 @@ bus_config_parser_end_element (BusConfigParser *parser,
case ELEMENT_FORK:
case ELEMENT_SELINUX:
case ELEMENT_ASSOCIATE:
+ case ELEMENT_STANDARD_SESSION_SERVICEDIRS:
break;
}
@@ -2335,6 +2352,19 @@ bus_config_parser_content (BusConfigParser *parser,
}
}
break;
+ case ELEMENT_STANDARD_SESSION_SERVICEDIRS:
+ {
+ DBusList *link;
+ DBusList *dirs;
+ dirs = NULL;
+
+ if (!_dbus_get_standard_session_servicedirs (&dirs))
+ goto nomem;
+
+ while ((link = _dbus_list_pop_first_link (&dirs)))
+ service_dirs_append_link_unique_or_free (&parser->service_dirs, link);
+ }
+ break;
case ELEMENT_SERVICEDIR:
{
@@ -3032,6 +3062,91 @@ process_test_equiv_subdir (const DBusString *test_base_dir,
return retval;
}
+
+static const char *test_service_dir_matches[] =
+ {
+ "/testusr/testlocal/testshare/dbus-1/services",
+ "/testusr/testshare/dbus-1/services",
+ DBUS_DATADIR"/dbus-1/services",
+ "/testhome/foo/.testlocal/testshare/dbus-1/services",
+ NULL
+ };
+
+static dbus_bool_t
+test_default_session_servicedirs (void)
+{
+ DBusList *dirs;
+ DBusList *link;
+ int i;
+
+ dirs = NULL;
+
+ printf ("Testing retriving the default session service directories\n");
+ if (!_dbus_get_standard_session_servicedirs (&dirs))
+ _dbus_assert_not_reached ("couldn't get stardard dirs");
+
+ /* make sure our defaults end with share/dbus-1/service */
+ while ((link = _dbus_list_pop_first_link (&dirs)))
+ {
+ DBusString path;
+
+ printf (" default service dir: %s\n", (char *)link->data);
+ _dbus_string_init_const (&path, (char *)link->data);
+ if (!_dbus_string_ends_with_c_str (&path, "share/dbus-1/services"))
+ {
+ printf ("error with default session service directories\n");
+ return FALSE;
+ }
+
+ dbus_free (link->data);
+ _dbus_list_free_link (link);
+ }
+
+ if (!_dbus_setenv ("XDG_DATA_HOME", "/testhome/foo/.testlocal/testshare"))
+ _dbus_assert_not_reached ("couldn't setenv XDG_DATA_HOME");
+
+ if (!_dbus_setenv ("XDG_DATA_DIRS", ":/testusr/testlocal/testshare: :/testusr/testshare:"))
+ _dbus_assert_not_reached ("couldn't setenv XDG_DATA_DIRS");
+
+ if (!_dbus_get_standard_session_servicedirs (&dirs))
+ _dbus_assert_not_reached ("couldn't get stardard dirs");
+
+ /* make sure we read and parse the env variable correctly */
+ i = 0;
+ while ((link = _dbus_list_pop_first_link (&dirs)))
+ {
+ printf (" test service dir: %s\n", (char *)link->data);
+ if (test_service_dir_matches[i] == NULL)
+ {
+ printf ("more directories parsed than in match set\n");
+ return FALSE;
+ }
+
+ if (strcmp (test_service_dir_matches[i],
+ (char *)link->data) != 0)
+ {
+ printf ("%s directory does not match %s in the match set\n",
+ (char *)link->data,
+ test_service_dir_matches[i]);
+ return FALSE;
+ }
+
+ ++i;
+
+ dbus_free (link->data);
+ _dbus_list_free_link (link);
+ }
+
+ if (test_service_dir_matches[i] != NULL)
+ {
+ printf ("extra data %s in the match set was not matched\n",
+ test_service_dir_matches[i]);
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
dbus_bool_t
bus_config_parser_test (const DBusString *test_data_dir)
@@ -3043,6 +3158,9 @@ bus_config_parser_test (const DBusString *test_data_dir)
return TRUE;
}
+ if (!test_default_session_servicedirs())
+ return FALSE;
+
if (!process_test_valid_subdir (test_data_dir, "valid-config-files", VALID))
return FALSE;