summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2011-02-25 11:31:29 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2011-02-25 12:01:33 +0000
commitbe5e2b23c93b3d93d8d02f3870618c29f3737239 (patch)
tree519a4a7a75df5b129e4025b37a7b478c9f9edb2f
parent20d2f1702fc602d70fc2ed7a016289679106098e (diff)
parentf04e52a2e5402a2bd17a5e923402df8e79dfd940 (diff)
Merge branch 'require-display-for-autolaunch-19997' into dbus-1.4
Reviewed-by: Colin Walters <walters@verbum.org>
-rw-r--r--README2
-rw-r--r--cmake/CMakeLists.txt2
-rw-r--r--configure.ac52
-rw-r--r--dbus/dbus-sysdeps-unix.c23
4 files changed, 58 insertions, 21 deletions
diff --git a/README b/README
index be4aede2..6c0c39d0 100644
--- a/README
+++ b/README
@@ -105,7 +105,7 @@ to the cmake program are these (use -D<key>=<value> on command line)
CMAKE_BUILD_TYPE set dbus build mode - one of Debug|Release|RelWithDebInfo|MinSizeRel
DBUS_BUILD_TESTS enable unit test code default=ON
- DBUS_BUILD_X11 Build X11-dependent code default=ON
+ DBUS_BUILD_X11 Build with X11 autolaunch support default=ON
HAVE_CONSOLE_OWNER_FILE enable console owner file (solaris only) ) default=ON
DBUS_DISABLE_ASSERTS Disable assertion checking default=OFF
DBUS_DISABLE_CHECKS Disable public API sanity checking default=OFF
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index ae053355..13cdb741 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -345,7 +345,7 @@ OPTION(DBUS_HAVE_ATOMIC_INT "Some atomic integer implementation present" ${at
OPTION(DBUS_USE_ATOMIC_INT_486 "Use atomic integer implementation for 486" ${atomic_int_486})
if(X11_FOUND)
- OPTION(DBUS_BUILD_X11 "Build X11-dependent code " ON)
+ OPTION(DBUS_BUILD_X11 "Build with X11 autolaunch support " ON)
endif(X11_FOUND)
# test binary names
diff --git a/configure.ac b/configure.ac
index 42ec552b..3a5bc45d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1062,34 +1062,48 @@ AC_SUBST(DBUS_TEST_CFLAGS)
AC_SUBST(DBUS_TEST_LIBS)
### X11 detection
-if test x$dbus_win = xyes ; then
- enable_x11=no
-else
-AC_PATH_XTRA
+DBUS_X_LIBS=
+DBUS_X_CFLAGS=
+
+AC_ARG_ENABLE([x11-autolaunch],
+ AS_HELP_STRING([--enable-x11-autolaunch], [build with X11 auto-launch support]),
+ [], [enable_x11_autolaunch=auto])
+
+if test "x$dbus_win" = xyes; then
+ if test "x$enable_x11_autolaunch" = xyes; then
+ AC_MSG_ERROR([X11 auto-launch is not supported on Windows])
+ fi
-## for now enable_x11 just tracks have_x11,
-## there's no --enable-x11
-if test x$no_x = xyes ; then
- have_x11=no
- enable_x11=no
+ enable_x11_autolaunch=no
+fi
+
+if test "x$enable_x11_autolaunch" = xno; then
+ have_x11=no
else
- have_x11=yes
- enable_x11=yes
+ AC_PATH_XTRA
+
+ if test "x$no_x" = xyes; then
+ have_x11=no
+ else
+ have_x11=yes
+ DBUS_X_LIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
+ DBUS_X_CFLAGS="$X_CFLAGS"
+ fi
fi
-if test x$enable_x11 = xyes ; then
- AC_DEFINE(DBUS_BUILD_X11,1,[Build X11-dependent code])
- DBUS_X_LIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
- DBUS_X_CFLAGS="$X_CFLAGS"
+if test "x$enable_x11_autolaunch,$have_x11" = xyes,no; then
+ AC_MSG_ERROR([X11 auto-launch requires X headers/libraries])
else
- DBUS_X_LIBS=
- DBUS_X_CFLAGS=
+ # move from "auto" to "yes" or "no" if necessary
+ enable_x11_autolaunch="$have_x11"
fi
-AC_SUBST(DBUS_X_CFLAGS)
-AC_SUBST(DBUS_X_LIBS)
+if test "x$enable_x11_autolaunch" = xyes ; then
+ AC_DEFINE([DBUS_BUILD_X11], [1], [Define to enable X11 auto-launch])
fi
+AC_SUBST([DBUS_X_CFLAGS])
+AC_SUBST([DBUS_X_LIBS])
#### gcc warning flags
diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c
index 9076600a..e9ea2535 100644
--- a/dbus/dbus-sysdeps-unix.c
+++ b/dbus/dbus-sysdeps-unix.c
@@ -3257,6 +3257,11 @@ _dbus_get_autolaunch_address (const char *scope,
DBusString *address,
DBusError *error)
{
+#ifdef DBUS_BUILD_X11
+ /* Perform X11-based autolaunch. (We also support launchd-based autolaunch,
+ * but that's done elsewhere, and if it worked, this function wouldn't
+ * be called.) */
+ const char *display;
static char *argv[6];
int i;
DBusString uuid;
@@ -3265,6 +3270,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 a $DISPLAY for X11");
+ return FALSE;
+ }
+
if (!_dbus_string_init (&uuid))
{
_DBUS_SET_OOM (error);
@@ -3300,6 +3317,12 @@ _dbus_get_autolaunch_address (const char *scope,
out:
_dbus_string_free (&uuid);
return retval;
+#else
+ dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED,
+ "Using X11 for dbus-daemon autolaunch was disabled at compile time, "
+ "set your DBUS_SESSION_BUS_ADDRESS instead");
+ return FALSE;
+#endif
}
/**