From 407c11167273ca388de6f0e770272067bff89ffb Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 24 Feb 2011 18:17:07 +0000 Subject: [PATCH] Don't attempt Unix X11 autolaunching if DISPLAY isn't set The known use cases for autolaunching (ssh -Y firefox, run konqueror in legacy DE) all need $DISPLAY too. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=19997 --- dbus/dbus-sysdeps-unix.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 9076600..ff902ff 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -3265,6 +3265,18 @@ _dbus_get_autolaunch_address (const char *scope, _DBUS_ASSERT_ERROR_IS_CLEAR (error); retval = FALSE; + /* fd.o #19997: if $DISPLAY isn't set to something useful, then + * dbus-launch-x11 is just going to fail. Rather than trying to + * run it, we might as well bail out early with a nice error. */ + display = _dbus_getenv ("DISPLAY"); + + if (display == NULL || display[0] == '\0') + { + dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, + "Unable to autolaunch a dbus-daemon without DISPLAY set"); + return FALSE; + } + if (!_dbus_string_init (&uuid)) { _DBUS_SET_OOM (error); -- 2.7.4