dbus/bus config-parser.c,1.44,1.45 session.conf.in,1.10,1.11
John Palmieri
johnp at kemper.freedesktop.org
Wed Nov 1 15:30:48 PST 2006
Update of /cvs/dbus/dbus/bus
In directory kemper:/tmp/cvs-serv4609/bus
Modified Files:
config-parser.c session.conf.in
Log Message:
* 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
Index: config-parser.c
===================================================================
RCS file: /cvs/dbus/dbus/bus/config-parser.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- config-parser.c 27 Oct 2006 18:30:22 -0000 1.44
+++ config-parser.c 1 Nov 2006 23:30:46 -0000 1.45
@@ -47,7 +47,8 @@
ELEMENT_INCLUDEDIR,
ELEMENT_TYPE,
ELEMENT_SELINUX,
- ELEMENT_ASSOCIATE
+ ELEMENT_ASSOCIATE,
+ ELEMENT_STANDARD_SESSION_SERVICEDIRS
} ElementType;
typedef enum
@@ -161,6 +162,8 @@
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 @@
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 @@
case ELEMENT_FORK:
case ELEMENT_SELINUX:
case ELEMENT_ASSOCIATE:
+ case ELEMENT_STANDARD_SESSION_SERVICEDIRS:
break;
}
@@ -2335,6 +2352,19 @@
}
}
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 @@
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 @@
return TRUE;
}
+ if (!test_default_session_servicedirs())
+ return FALSE;
+
if (!process_test_valid_subdir (test_data_dir, "valid-config-files", VALID))
return FALSE;
Index: session.conf.in
===================================================================
RCS file: /cvs/dbus/dbus/bus/session.conf.in,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- session.conf.in 3 Aug 2006 20:34:36 -0000 1.10
+++ session.conf.in 1 Nov 2006 23:30:46 -0000 1.11
@@ -10,7 +10,7 @@
<listen>unix:tmpdir=@DBUS_SESSION_SOCKET_DIR@</listen>
- <servicedir>@EXPANDED_DATADIR@/dbus-1/services</servicedir>
+ <standard_session_servicedirs />
<policy context="default">
<!-- Allow everything to be sent -->
More information about the dbus-commit
mailing list