summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-sysdeps-unix.c
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2007-07-24 11:44:35 +0000
committerRichard Hughes <richard@hughsie.com>2007-07-24 11:44:35 +0000
commit227c67220ba50ef38fabc8587bf729d21534977f (patch)
treea2ef11d242dd04f1c64a7e0bb19c59d7a9d6dd54 /dbus/dbus-sysdeps-unix.c
parent837f60ae77d04adfb3e593dc43da738736641df1 (diff)
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.
Diffstat (limited to 'dbus/dbus-sysdeps-unix.c')
-rw-r--r--dbus/dbus-sysdeps-unix.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c
index 7443b365..2ea83df2 100644
--- a/dbus/dbus-sysdeps-unix.c
+++ b/dbus/dbus-sysdeps-unix.c
@@ -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