diff options
| author | Richard Hughes <richard@hughsie.com> | 2007-07-24 11:44:35 +0000 | 
|---|---|---|
| committer | Richard Hughes <richard@hughsie.com> | 2007-07-24 11:44:35 +0000 | 
| commit | 227c67220ba50ef38fabc8587bf729d21534977f (patch) | |
| tree | a2ef11d242dd04f1c64a7e0bb19c59d7a9d6dd54 | |
| parent | 837f60ae77d04adfb3e593dc43da738736641df1 (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.
| -rw-r--r-- | ChangeLog | 11 | ||||
| -rw-r--r-- | dbus/dbus-sysdeps-unix.c | 67 | ||||
| -rw-r--r-- | dbus/dbus-sysdeps-win.c | 2 | 
3 files changed, 79 insertions, 1 deletions
@@ -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. 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   | 
