From 227c67220ba50ef38fabc8587bf729d21534977f Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Tue, 24 Jul 2007 11:44:35 +0000 Subject: 2007-07-24 Richard Hughes * 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. --- dbus/dbus-sysdeps-unix.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++ dbus/dbus-sysdeps-win.c | 2 +- 2 files changed, 68 insertions(+), 1 deletion(-) (limited to 'dbus') 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 diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 14edd9eb..3c6c31be 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -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 -- cgit