summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2015-11-02 14:24:51 +0000
committerRalf Habacker <ralf.habacker@freenet.de>2015-11-02 23:24:11 +0100
commit2f1a715e7f77739cca6afe371a971174d5879c07 (patch)
tree99535a0e5e71c4e1ffdd1dcdae658ad053017998
parent50b07fbb01d3f6fd42cc083f2ed0fb8670d1d37c (diff)
downloaddbus-2f1a715e7f77739cca6afe371a971174d5879c07.tar.gz
test_default_session_servicedirs: use the intended data directory
If D-Bus was configured for /usr/local and built in Z:/build, the previous code would use Z:/build/dbus/.libs/usr/local/share/dbus-1/services whereas the intention was to replace the configured prefix /usr/local with the detected location, more like Z:/build/dbus/.libs/share/dbus-1/services Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92721 Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
-rw-r--r--bus/config-parser.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/bus/config-parser.c b/bus/config-parser.c
index 3a5ecc34..1925d435 100644
--- a/bus/config-parser.c
+++ b/bus/config-parser.c
@@ -3401,28 +3401,36 @@ test_default_session_servicedirs (void)
DBusList *dirs;
DBusList *link;
DBusString progs;
+ DBusString install_root_based;
int i;
dbus_bool_t ret = FALSE;
#ifdef DBUS_WIN
+ const char *tmp;
const char *common_progs;
- char buffer[1024];
#endif
- /* On Unix we don't actually use this variable, but it's easier to handle the
- * deallocation if we always allocate it, whether needed or not */
- if (!_dbus_string_init (&progs))
- _dbus_assert_not_reached ("OOM allocating progs");
+ /* On Unix we don't actually use these, but it's easier to handle the
+ * deallocation if we always allocate them, whether needed or not */
+ if (!_dbus_string_init (&progs) ||
+ !_dbus_string_init (&install_root_based))
+ _dbus_assert_not_reached ("OOM allocating strings");
#ifdef DBUS_WIN
- if (_dbus_get_install_root(buffer, sizeof(buffer)))
- {
- strcat(buffer,DBUS_DATADIR);
- strcat(buffer,"/dbus-1/services");
- test_session_service_dir_matches[0] = buffer;
- }
-#endif
+ if (!_dbus_string_append (&install_root_based, DBUS_DATADIR) ||
+ !_dbus_string_append (&install_root_based, "/dbus-1/services"))
+ goto out;
+
+ tmp = _dbus_replace_install_prefix (
+ _dbus_string_get_const_data (&install_root_based));
+
+ if (tmp == NULL ||
+ !_dbus_string_set_length (&install_root_based, 0) ||
+ !_dbus_string_append (&install_root_based, tmp))
+ goto out;
+
+ test_session_service_dir_matches[0] = _dbus_string_get_const_data (
+ &install_root_based);
-#ifndef DBUS_UNIX
common_progs = _dbus_getenv ("CommonProgramFiles");
if (common_progs)
@@ -3511,6 +3519,7 @@ test_default_session_servicedirs (void)
ret = TRUE;
out:
+ _dbus_string_free (&install_root_based);
_dbus_string_free (&progs);
return ret;
}