From f3b18ff5ef01ebd9fc5b32445f95aeece93122a1 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Sun, 20 Feb 2011 05:16:16 -0500 Subject: [PATCH] Give XDG_DATA_HOME priority over XDG_DATA_DIRS for servicedirs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to the XDG Base Directory Specification, “the base directory defined by $XDG_DATA_HOME is considered more important than any of the base directories defined by $XDG_DATA_DIRS.” This makes it easier to override a system service file as a normal user. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=34496 Signed-off-by: Anders Kaseorg --- dbus/dbus-sysdeps-unix.c | 49 ++++++++++++++++++++++++--------------------- 1 files changed, 26 insertions(+), 23 deletions(-) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index fdea634..9076600 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -3502,29 +3502,6 @@ _dbus_get_standard_session_servicedirs (DBusList **dirs) xdg_data_home = _dbus_getenv ("XDG_DATA_HOME"); 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 (xdg_data_home != NULL) { if (!_dbus_string_append (&servicedir_path, xdg_data_home)) @@ -3546,6 +3523,32 @@ _dbus_get_standard_session_servicedirs (DBusList **dirs) goto oom; } + if (!_dbus_string_append (&servicedir_path, ":")) + goto oom; + + 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_SESSION_SERVICEDIR, dirs)) -- 1.7.4.1