2007-07-24 Richard Hughes <richard@hughsie.com>
authorRichard Hughes <richard@hughsie.com>
Tue, 24 Jul 2007 11:44:35 +0000 (11:44 +0000)
committerRichard Hughes <richard@hughsie.com>
Tue, 24 Jul 2007 11:44:35 +0000 (11:44 +0000)
* dbus/dbus-sysdeps-unix.c:
(_dbus_get_standard_system_servicedirs):
* dbus/dbus-sysdeps-win.c:
Provide a way to get the standard system servicedirs, just like we do
for the session service dirs. These should be seporate, as there may
be a security issue starting up some session stuff as root.
The use-case for the same binary starting up per-system _and_
per-session is also not valid.

ChangeLog
dbus/dbus-sysdeps-unix.c
dbus/dbus-sysdeps-win.c

index e89c9b0..85f5797 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2007-07-24  Richard Hughes  <richard@hughsie.com>
 
+       * dbus/dbus-sysdeps-unix.c:
+       (_dbus_get_standard_system_servicedirs):
+       * dbus/dbus-sysdeps-win.c:
+       Provide a way to get the standard system servicedirs, just like we do
+       for the session service dirs. These should be seporate, as there may
+       be a security issue starting up some session stuff as root.
+       The use-case for the same binary starting up per-system _and_
+       per-session is also not valid.
+
+2007-07-24  Richard Hughes  <richard@hughsie.com>
+
        * bus/dbus-daemon.1.in:
        Add standard_system_servicedirs and servicehelper into the man file
        and explain what each does.
index 7443b36..2ea83df 100644 (file)
@@ -2832,6 +2832,7 @@ _dbus_read_local_machine_uuid (DBusGUID   *machine_id,
 }
 
 #define DBUS_UNIX_STANDARD_SESSION_SERVICEDIR "/dbus-1/services"
+#define DBUS_UNIX_STANDARD_SYSTEM_SERVICEDIR "/dbus-1/system-services"
 
 
 /**
@@ -2921,6 +2922,72 @@ _dbus_get_standard_session_servicedirs (DBusList **dirs)
   return FALSE;
 }
 
+
+/**
+ * Returns the standard directories for a system bus to look for service 
+ * activation files 
+ *
+ * On UNIX this should be the standard xdg freedesktop.org data directories:
+ *
+ * XDG_DATA_DIRS=${XDG_DATA_DIRS-/usr/local/share:/usr/share}
+ *
+ * and
+ *
+ * DBUS_DATADIR
+ *
+ * On Windows there is no system bus and this function can return nothing.
+ *
+ * @param dirs the directory list we are returning
+ * @returns #FALSE on OOM 
+ */
+
+dbus_bool_t 
+_dbus_get_standard_system_servicedirs (DBusList **dirs)
+{
+  const char *xdg_data_dirs;
+  DBusString servicedir_path;
+
+  if (!_dbus_string_init (&servicedir_path))
+    return FALSE;
+
+  xdg_data_dirs = _dbus_getenv ("XDG_DATA_DIRS");
+
+  if (xdg_data_dirs != NULL)
+    {
+      if (!_dbus_string_append (&servicedir_path, xdg_data_dirs))
+        goto oom;
+
+      if (!_dbus_string_append (&servicedir_path, ":"))
+        goto oom;
+    }
+  else
+    {
+      if (!_dbus_string_append (&servicedir_path, "/usr/local/share:/usr/share:"))
+        goto oom;
+    }
+
+  /* 
+   * add configured datadir to defaults
+   * this may be the same as an xdg dir
+   * however the config parser should take 
+   * care of duplicates 
+   */
+  if (!_dbus_string_append (&servicedir_path, DBUS_DATADIR":"))
+        goto oom;
+
+  if (!_dbus_split_paths_and_append (&servicedir_path, 
+                                     DBUS_UNIX_STANDARD_SYSTEM_SERVICEDIR, 
+                                     dirs))
+    goto oom;
+
+  _dbus_string_free (&servicedir_path);  
+  return TRUE;
+
+ oom:
+  _dbus_string_free (&servicedir_path);
+  return FALSE;
+}
+
 /**
  * Append the absolute path of the system.conf file
  * (there is no system bus on Windows so this can just
index 14edd9e..3c6c31b 100644 (file)
@@ -3054,7 +3054,7 @@ _dbus_make_file_world_readable(const DBusString *filename,
 
 
 #define DBUS_STANDARD_SESSION_SERVICEDIR "/dbus-1/services"
-
+#define DBUS_STANDARD_SYSTEM_SERVICEDIR "/dbus-1/system-services"
 
 /**
  * Returns the standard directories for a session bus to look for service