Don't attempt Unix X11 autolaunching if DISPLAY isn't set
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Thu, 24 Feb 2011 18:17:07 +0000 (18:17 +0000)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Thu, 24 Feb 2011 18:43:34 +0000 (18:43 +0000)
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

index 9076600..ff902ff 100644 (file)
@@ -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);