Commit b5d36dc2 authored by Simon McVittie's avatar Simon McVittie

Split DBUS_SESSION_BUS_DEFAULT_ADDRESS into listen, connect addresses and set better defaults

On Unix, the connect address should basically always be "autolaunch:"
but the listen address has to be something you can listen on.

On Windows, you can listen on "autolaunch:" or
"autolaunch:scope=*install-path", for instance, and the dbus-daemon is
involved in the auto-launching process.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=38201Reviewed-by: default avatarDavid Zeuthen <davidz@redhat.com>
[default address changed to autolaunch: for interop with GDBus -smcv]
Signed-off-by: default avatarSimon McVittie <simon.mcvittie@collabora.co.uk>
parent 05b0b9e6
......@@ -129,8 +129,11 @@ DBUS_HAVE_ATOMIC_INT:BOOL=OFF
// install required system libraries
DBUS_INSTALL_SYSTEM_LIBS:BOOL=OFF
// session bus default address
DBUS_SESSION_BUS_DEFAULT_ADDRESS:STRING=nonce-tcp:
// session bus default listening address
DBUS_SESSION_BUS_LISTEN_ADDRESS:STRING=autolaunch:
// session bus fallback address for clients
DBUS_SESSION_BUS_CONNECT_ADDRESS:STRING=autolaunch:
// system bus default address (only useful on Unix)
DBUS_SYSTEM_BUS_DEFAULT_ADDRESS:STRING=unix:path=/var/run/dbus/system_bus_socket
......
......@@ -12,7 +12,7 @@
the behavior of child processes. -->
<keep_umask/>
<listen>@DBUS_SESSION_BUS_DEFAULT_ADDRESS@</listen>
<listen>@DBUS_SESSION_BUS_LISTEN_ADDRESS@</listen>
<standard_session_servicedirs />
......
......@@ -442,14 +442,16 @@ set (DBUS_USER )
set (DBUS_SYSTEM_BUS_DEFAULT_ADDRESS "unix:path=${EXPANDED_LOCALSTATEDIR}/run/dbus/system_bus_socket" CACHE STRING "system bus default address")
if (WIN32)
set (DBUS_SESSION_BUS_DEFAULT_ADDRESS "nonce-tcp:" CACHE STRING "session bus default address")
set (DBUS_SESSION_BUS_LISTEN_ADDRESS "autolaunch:" CACHE STRING "session bus default listening address")
set (DBUS_SESSION_BUS_CONNECT_ADDRESS "autolaunch:" CACHE STRING "session bus fallback address for clients")
set (DBUS_SYSTEM_CONFIG_FILE "etc/dbus-1/system.conf")
set (DBUS_SESSION_CONFIG_FILE "etc/dbus-1/session.conf")
# bus-test expects a non empty string
set (DBUS_USER "Administrator")
else (WIN32)
set (DBUS_SESSION_BUS_DEFAULT_ADDRESS "unix:path=${DBUS_SESSION_SOCKET_DIR}" CACHE STRING "session bus default address")
set (DBUS_SESSION_BUS_LISTEN_ADDRESS "unix:tmpdir=${DBUS_SESSION_SOCKET_DIR}" CACHE STRING "session bus default listening address")
set (DBUS_SESSION_BUS_CONNECT_ADDRESS "autolaunch:" CACHE STRING "session bus fallback address for clients")
set (sysconfdir "")
set (configdir ${sysconfdir}/dbus-1 )
set (DBUS_SYSTEM_CONFIG_FILE ${configdir}/system.conf)
......@@ -569,7 +571,8 @@ message(" Using XML parser: ${XML_LIB} "
message(" Daemon executable name: ${DBUS_DAEMON_NAME}")
if (WIN32)
message(" System bus address: ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS} ")
message(" Session bus address: ${DBUS_SESSION_BUS_DEFAULT_ADDRESS} ")
message(" Session bus listens on: ${DBUS_SESSION_BUS_LISTEN_ADDRESS} ")
message(" Session clients connect to: ${DBUS_SESSION_BUS_CONNECT_ADDRESS} ")
else (WIN32)
#message(" Init scripts style: ${with_init_scripts} ")
#message(" Abstract socket names: ${have_abstract_sockets} ")
......
......@@ -15,8 +15,8 @@
#cmakedefine DBUS_SESSION_CONFIG_FILE "@DBUS_SESSION_CONFIG_FILE@"
#cmakedefine DBUS_DAEMON_NAME "@DBUS_DAEMON_NAME@"
#cmakedefine DBUS_SYSTEM_BUS_DEFAULT_ADDRESS "@DBUS_SYSTEM_BUS_DEFAULT_ADDRESS@"
#cmakedefine DBUS_SESSION_BUS_CONNECT_ADDRESS "@DBUS_SESSION_BUS_CONNECT_ADDRESS@"
#cmakedefine DBUS_MACHINE_UUID_FILE "@DBUS_MACHINE_UUID_FILE@"
#cmakedefine DBUS_SESSION_BUS_DEFAULT_ADDRESS "@DBUS_SESSION_BUS_DEFAULT_ADDRESS@"
#cmakedefine DBUS_DAEMONDIR "@DBUS_DAEMONDIR@"
#cmakedefine PACKAGE "@PACKAGE@"
/* Version number of package */
......
......@@ -2,7 +2,7 @@
@echo off
:: session bus address
set DBUS_SESSION_BUS_ADDRESS=@DBUS_SESSION_BUS_DEFAULT_ADDRESS@
set DBUS_SESSION_BUS_ADDRESS=@DBUS_SESSION_BUS_CONNECT_ADDRESS@
:: system bus address
set DBUS_SYSTEM_BUS_DEFAULT_ADDRESS=@DBUS_SYSTEM_BUS_DEFAULT_ADDRESS@
\ No newline at end of file
set DBUS_SYSTEM_BUS_DEFAULT_ADDRESS=@DBUS_SYSTEM_BUS_DEFAULT_ADDRESS@
......@@ -169,7 +169,6 @@ AC_ARG_WITH(console-owner-file, AS_HELP_STRING([--with-console-owner-file=[filen
AC_ARG_WITH(launchd-agent-dir, AS_HELP_STRING([--with-launchd-agent-dir=[dirname]],[directory to put the launchd agent (default: /Library/LaunchAgents)]))
AC_ARG_WITH(dbus_user, AS_HELP_STRING([--with-dbus-user=<user>],[User for running the DBUS daemon (messagebus)]))
AC_ARG_WITH(dbus_daemondir, AS_HELP_STRING([--with-dbus-daemondir=[dirname]],[Directory for installing the DBUS daemon]))
AC_ARG_WITH(dbus_session_bus_default_address, AS_HELP_STRING([--with-dbus-session-bus-default-address=[nonce-tcp:/autolaunch:/tcp:host:port]],[Transport Type to be used (default: nonce-tcp:)]),with_dbus_session_bus_default_address=$withval,with_dbus_session_bus_default_address=nonce-tcp:)
AC_ARG_ENABLE([embedded-tests],
AS_HELP_STRING([--enable-embedded-tests],
......@@ -1675,14 +1674,64 @@ fi
AC_DEFINE_UNQUOTED(DBUS_SESSION_SOCKET_DIR, "$DBUS_SESSION_SOCKET_DIR", [Where per-session bus puts its sockets])
AC_SUBST(DBUS_SESSION_SOCKET_DIR)
if test x$dbus_win = xyes; then
DBUS_SESSION_BUS_DEFAULT_ADDRESS="$with_dbus_session_bus_default_address"
# This must be a listening address. It doesn't necessarily need to be an
# address you can connect to - it can be something vague like
# "nonce-tcp:".
#
# The default varies by platform.
AC_ARG_WITH([dbus_session_bus_listen_address],
AS_HELP_STRING([--with-dbus-session-bus-listen-address=[ADDRESS]],
[default address for a session bus to listen on (see configure.ac)]),
[with_dbus_session_bus_listen_address=$withval],
[with_dbus_session_bus_listen_address=])
if test "x$with_dbus_session_bus_listen_address" != "x"; then
# the user specified something, trust them
DBUS_SESSION_BUS_LISTEN_ADDRESS="$with_dbus_session_bus_listen_address"
elif test x$dbus_win = xyes; then
# On Windows, you can (and should) listen on autolaunch addresses,
# because autolaunching is different.
# See https://bugs.freedesktop.org/show_bug.cgi?id=38201
DBUS_SESSION_BUS_LISTEN_ADDRESS="autolaunch:"
elif test x$have_launchd = xyes; then
DBUS_SESSION_BUS_DEFAULT_ADDRESS="launchd:env=DBUS_LAUNCHD_SESSION_BUS_SOCKET"
# Mac OS X default is to use launchd
DBUS_SESSION_BUS_LISTEN_ADDRESS="launchd:env=DBUS_LAUNCHD_SESSION_BUS_SOCKET"
else
# The default on all other Unix platforms (notably Linux)
# is to create a randomly named socket in /tmp or similar
DBUS_SESSION_BUS_LISTEN_ADDRESS="unix:tmpdir=$DBUS_SESSION_SOCKET_DIR"
fi
AC_SUBST([DBUS_SESSION_BUS_LISTEN_ADDRESS])
# This must be an address you can connect to. It doesn't necessarily
# need to be an address you can listen on - it can be "autolaunch:",
# even on Unix.
#
# The default varies by platform.
AC_ARG_WITH([dbus_session_bus_connect_address],
AS_HELP_STRING([--with-dbus-session-bus-connect-address=[ADDRESS]],
[fallback address for a session bus client to connect to (see configure.ac)]),
[with_dbus_session_bus_connect_address=$withval],
[with_dbus_session_bus_connect_address=])
if test "x$with_dbus_session_bus_connect_address" != "x"; then
# the user specified something, trust them
DBUS_SESSION_BUS_CONNECT_ADDRESS="$with_dbus_session_bus_connect_address"
elif test x$dbus_win = xyes; then
# Windows autolaunching is a bit different; leaving it in its own
# branch of the conditional because the default might conceivably
# change (see #38201)
DBUS_SESSION_BUS_CONNECT_ADDRESS="autolaunch:"
else
DBUS_SESSION_BUS_DEFAULT_ADDRESS="unix:tmpdir=$DBUS_SESSION_SOCKET_DIR"
# The default on all other Unix platforms (notably Linux)
# is to use auto-launching - this works a bit differently on Mac OS X
# but comes out basically the same in the end
DBUS_SESSION_BUS_CONNECT_ADDRESS="autolaunch:"
fi
AC_SUBST(DBUS_SESSION_BUS_DEFAULT_ADDRESS)
AC_SUBST([DBUS_SESSION_BUS_CONNECT_ADDRESS])
AC_DEFINE_UNQUOTED([DBUS_SESSION_BUS_CONNECT_ADDRESS],
["$DBUS_SESSION_BUS_CONNECT_ADDRESS"],
[Fallback address for session bus clients])
# darwin needs this to initialize the environment
AC_CHECK_HEADERS(crt_externs.h)
......@@ -1798,7 +1847,8 @@ echo "
System bus socket: ${DBUS_SYSTEM_SOCKET}
System bus address: ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS}
System bus PID file: ${DBUS_SYSTEM_PID_FILE}
Session bus address: ${DBUS_SESSION_BUS_DEFAULT_ADDRESS}
Session bus listens on: ${DBUS_SESSION_BUS_LISTEN_ADDRESS}
Session clients connect to: ${DBUS_SESSION_BUS_CONNECT_ADDRESS}
Console auth dir: ${DBUS_CONSOLE_AUTH_DIR}
Console owner file: ${have_console_owner_file}
Console owner file path: ${DBUS_CONSOLE_OWNER_FILE}
......
......@@ -192,12 +192,12 @@ init_session_address (void)
if (!retval)
return FALSE;
/* The DBUS_SESSION_BUS_DEFAULT_ADDRESS should have really been named
* DBUS_SESSION_BUS_FALLBACK_ADDRESS.
*/
/* We have a hard-coded (but compile-time-configurable) fallback address for
* the session bus. */
if (bus_connection_addresses[DBUS_BUS_SESSION] == NULL)
bus_connection_addresses[DBUS_BUS_SESSION] =
_dbus_strdup (DBUS_SESSION_BUS_DEFAULT_ADDRESS);
_dbus_strdup (DBUS_SESSION_BUS_CONNECT_ADDRESS);
if (bus_connection_addresses[DBUS_BUS_SESSION] == NULL)
return FALSE;
......
......@@ -35,10 +35,6 @@
DBUS_BEGIN_DECLS
#ifndef DBUS_SESSION_BUS_DEFAULT_ADDRESS
#define DBUS_SESSION_BUS_DEFAULT_ADDRESS "autolaunch:"
#endif
void _dbus_warn (const char *format,
...) _DBUS_GNUC_PRINTF (1, 2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment