diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2011-02-24 18:57:05 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2011-02-24 18:58:18 +0000 |
commit | f04e52a2e5402a2bd17a5e923402df8e79dfd940 (patch) | |
tree | 1f9bd8d359331d785bf89aa228fd81f213105153 | |
parent | 407c11167273ca388de6f0e770272067bff89ffb (diff) |
Allow X11 autolaunch to be disabled even if the headers/libraries are there
In an embedded system where the D-Bus session is a core part of the
environment, like Maemo, accidentally auto-launching a second session bus
(for instance for a concurrent ssh session) is a bad idea - it can lead
to a "split brain" situation where half the applications in the GUI are
using a different bus. In these controlled environments, it'd be useful
to prevent autolaunch from ever happening.
(As a side benefit, the changes to configure.in also mean that packagers
can explicitly --enable-x11-autolaunch, to make sure that failure to find
X will make compilation fail cleanly.)
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=19997
Bug-NB: NB#219964
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | cmake/CMakeLists.txt | 2 | ||||
-rw-r--r-- | configure.in | 52 | ||||
-rw-r--r-- | dbus/dbus-sysdeps-unix.c | 13 |
4 files changed, 47 insertions, 22 deletions
@@ -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.in b/configure.in index b043018f..3e40931b 100644 --- a/configure.in +++ b/configure.in @@ -1051,34 +1051,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 ff902ff1..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; @@ -3273,7 +3278,7 @@ _dbus_get_autolaunch_address (const char *scope, if (display == NULL || display[0] == '\0') { dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, - "Unable to autolaunch a dbus-daemon without DISPLAY set"); + "Unable to autolaunch a dbus-daemon without a $DISPLAY for X11"); return FALSE; } @@ -3312,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 } /** |