mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-03-27 11:40:41 +01:00
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
This commit is contained in:
parent
407c111672
commit
f04e52a2e5
4 changed files with 48 additions and 23 deletions
2
README
2
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
54
configure.in
54
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=
|
||||
|
||||
## 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
|
||||
else
|
||||
have_x11=yes
|
||||
enable_x11=yes
|
||||
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
|
||||
|
||||
enable_x11_autolaunch=no
|
||||
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" = xno; then
|
||||
have_x11=no
|
||||
else
|
||||
DBUS_X_LIBS=
|
||||
DBUS_X_CFLAGS=
|
||||
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
|
||||
|
||||
AC_SUBST(DBUS_X_CFLAGS)
|
||||
AC_SUBST(DBUS_X_LIBS)
|
||||
if test "x$enable_x11_autolaunch,$have_x11" = xyes,no; then
|
||||
AC_MSG_ERROR([X11 auto-launch requires X headers/libraries])
|
||||
else
|
||||
# move from "auto" to "yes" or "no" if necessary
|
||||
enable_x11_autolaunch="$have_x11"
|
||||
fi
|
||||
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue