summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2009-07-14 11:43:54 -0400
committerColin Walters <walters@verbum.org>2009-07-14 15:42:38 -0400
commit3028841a74fbac7886be5c16843a75f19383c9b3 (patch)
tree02c718727faeb91a9689afa8d16ed2bc90b6710a
parent5abb8aeb5e315df997cbaccfbc8865ef2b70bcf1 (diff)
Cope with dbus-launch not being in DBUS_BINDIR
This is a temporary hack for systems which use DBUS_BINDIR=/bin, but then move dbus-launch back into /usr/bin. Longer term, we should explicitly support this in upstream code, or even better figure out how to move dbus-launch into /bin (e.g. dynamically load libX11 if available), or have a --with-x11-tools configure option. (cherry picked from commit 70c5285eb4b757fdd4e552e002c5d54072492152)
-rw-r--r--dbus/dbus-sysdeps-unix.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c
index 573e7a2b..1268768b 100644
--- a/dbus/dbus-sysdeps-unix.c
+++ b/dbus/dbus-sysdeps-unix.c
@@ -2878,7 +2878,8 @@ _dbus_get_tmpdir(void)
* without writing any data to stdout. Verify the @p result length
* before and after this function call to cover this case.
*
- * @param progname initial path to exec
+ * @param progname initial path to exec (may or may not be absolute)
+ * @param path_fallback if %TRUE, search PATH for executable
* @param argv NULL-terminated list of arguments
* @param result a DBusString where the output can be append
* @param error a DBusError to store the error in case of failure
@@ -2886,6 +2887,7 @@ _dbus_get_tmpdir(void)
*/
static dbus_bool_t
_read_subprocess_line_argv (const char *progpath,
+ dbus_bool_t path_fallback,
char * const *argv,
DBusString *result,
DBusError *error)
@@ -2897,19 +2899,13 @@ _read_subprocess_line_argv (const char *progpath,
int status;
int orig_len;
int i;
- DBusString uuid;
+
dbus_bool_t retval;
sigset_t new_set, old_set;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
retval = FALSE;
- if (!_dbus_string_init (&uuid))
- {
- _DBUS_SET_OOM (error);
- return FALSE;
- }
-
/* We need to block any existing handlers for SIGCHLD temporarily; they
* will cause waitpid() below to fail.
* https://bugs.freedesktop.org/show_bug.cgi?id=21347
@@ -2989,11 +2985,22 @@ _read_subprocess_line_argv (const char *progpath,
for (i = 3; i < maxfds; i++)
close (i);
- sigprocmask(SIG_SETMASK, &old_set, NULL);
+ sigprocmask (SIG_SETMASK, &old_set, NULL);
/* If it looks fully-qualified, try execv first */
if (progpath[0] == '/')
- execv (progpath, argv);
+ {
+ execv (progpath, argv);
+ /* Ok, that failed. Now if path_fallback is given, let's
+ * try unqualified. This is mostly a hack to work
+ * around systems which ship dbus-launch in /usr/bin
+ * but everything else in /bin (because dbus-launch
+ * depends on X11).
+ */
+ if (path_fallback)
+ /* We must have a slash, because we checked above */
+ execvp (strrchr (progpath, '/')+1, argv);
+ }
else
execvp (progpath, argv);
@@ -3120,7 +3127,8 @@ _dbus_get_autolaunch_address (DBusString *address,
_dbus_assert (i == _DBUS_N_ELEMENTS (argv));
- retval = _read_subprocess_line_argv (DBUS_BINDIR "/dbus-launch",
+ retval = _read_subprocess_line_argv (DBUS_BINDIR "/dbus-launch",
+ TRUE,
argv, address, error);
out: