From 08bae4afe81e6e4a2c737400184a06a57f7b436a Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 20 Jun 2017 13:08:06 +0100 Subject: [PATCH 05/49] build: Introduce ${runstatedir} and use it for the pid file By default ${runstatedir} is the same as ${localstatedir}/run, but many Linux distributions configure it to be /run. The pid file is not part of the API between dbus and other software, so we do not need to keep it strictly compatible. We do not use /run for the system bus socket, because that is part of the API between D-Bus clients and servers, and has always been "officially" /var/run/dbus/system_bus_socket. In practice, in distributions that have adopted /run, /var/run is always a bind-mount or symbolic link to /run, so we could consider changing the "official" name of the D-Bus system bus socket later; for now, distributions wishing to do so could configure with --with-system-socket=/run/dbus/system_bus_socket. Similarly, we do not replace /var/run/console with /run/console, because that path is part of the API between dbus-daemon and the (obsolete) PAM modules that used /var/run/console. Signed-off-by: Simon McVittie --- cmake/CMakeLists.txt | 5 +++-- cmake/config.h.cmake | 1 + configure.ac | 17 +++++++++++++++-- dbus/Makefile.am | 1 + 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index f2bc0e9f..9f41ca74 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -70,6 +70,7 @@ set(DBUS_MACHINE_UUID_FILE ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/dbus/machin set(DBUS_BINDIR ${CMAKE_INSTALL_FULL_BINDIR}) set(DBUS_DAEMONDIR ${CMAKE_INSTALL_FULL_BINDIR}) set(DBUS_LOCALSTATEDIR ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}) +set(DBUS_RUNSTATEDIR ${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/run) # On Windows this is relative to where we put the bus setup, in # ${datadir}/dbus-1. For simplicity, we only do this if @@ -432,7 +433,7 @@ if(UNIX) endif() # Not used on Windows, where there is no system bus -set (DBUS_SYSTEM_PID_FILE ${DBUS_LOCALSTATEDIR}/run/dbus/pid) +set (DBUS_SYSTEM_PID_FILE ${DBUS_RUNSTATEDIR}/dbus/pid) if (WIN32) set (DBUS_CONSOLE_AUTH_DIR "") @@ -448,7 +449,7 @@ endif (WIN32) # and also to connect to. If this ever changes, it'll need to be split into # two variables, one for the listening address and one for the connecting # address. -set (DBUS_SYSTEM_BUS_DEFAULT_ADDRESS "unix:path=${DBUS_LOCALSTATEDIR}/run/dbus/system_bus_socket" CACHE STRING "system bus default address") +set (DBUS_SYSTEM_BUS_DEFAULT_ADDRESS "unix:path=${DBUS_RUNSTATEDIR}/dbus/system_bus_socket" CACHE STRING "system bus default address") if (WIN32) set (DBUS_SESSION_BUS_LISTEN_ADDRESS "autolaunch:" CACHE STRING "session bus default listening address") diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 8305a68a..361d0b0d 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -25,6 +25,7 @@ #cmakedefine DBUS_SESSION_BUS_CONNECT_ADDRESS "@DBUS_SESSION_BUS_CONNECT_ADDRESS@" #cmakedefine DBUS_MACHINE_UUID_FILE "@DBUS_MACHINE_UUID_FILE@" #cmakedefine DBUS_DAEMONDIR "@DBUS_DAEMONDIR@" +#cmakedefine DBUS_RUNSTATEDIR "@DBUS_RUNSTATEDIR@" #cmakedefine DBUS_ENABLE_STATS diff --git a/configure.ac b/configure.ac index 1561c941..903adcd5 100644 --- a/configure.ac +++ b/configure.ac @@ -1486,6 +1486,11 @@ AM_CONDITIONAL(DBUS_CAN_UPLOAD_DOCS, [test x$enable_doxygen_docs = xyes && test x$enable_xml_docs = xyes && test x$enable_ducktype_docs = xyes]) +# Autoconf 2.70 will support this, and many distros patch this option in, +# but Autoconf 2.70 hasn't actually been released yet. +AS_IF([test -z "${runstatedir}"], [runstatedir='${localstatedir}/run']) +AC_SUBST([runstatedir]) + #### Have to go $localstatedir->$prefix/var->/usr/local/var #### find the actual value for $prefix that we'll end up with @@ -1498,6 +1503,7 @@ AS_AC_EXPAND(EXPANDED_BINDIR, "$bindir") AS_AC_EXPAND(EXPANDED_LIBDIR, "$libdir") AS_AC_EXPAND(EXPANDED_LIBEXECDIR, "$libexecdir") AS_AC_EXPAND(EXPANDED_DATADIR, "$datadir") +AS_AC_EXPAND(EXPANDED_RUNSTATEDIR, "$runstatedir") #### Check our operating system operating_system=unknown @@ -1556,6 +1562,8 @@ AC_SUBST([systemduserunitdir], [$with_systemduserunitdir]) if ! test -z "$with_system_socket"; then DBUS_SYSTEM_SOCKET=$with_system_socket else + # We don't use runstatedir for this (yet?), because /var/run has been the + # interoperable system bus socket for 10+ years. DBUS_SYSTEM_SOCKET=${EXPANDED_LOCALSTATEDIR}/run/dbus/system_bus_socket fi @@ -1581,9 +1589,9 @@ AC_DEFINE_UNQUOTED(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS, "$DBUS_SYSTEM_BUS_DEFAULT_AD if ! test -z "$with_system_pid_file"; then DBUS_SYSTEM_PID_FILE=$with_system_pid_file elif test x$with_init_scripts = xredhat ; then - DBUS_SYSTEM_PID_FILE=${EXPANDED_LOCALSTATEDIR}/run/messagebus.pid + DBUS_SYSTEM_PID_FILE="${EXPANDED_RUNSTATEDIR}/messagebus.pid" else - DBUS_SYSTEM_PID_FILE=${EXPANDED_LOCALSTATEDIR}/run/dbus/pid + DBUS_SYSTEM_PID_FILE="${EXPANDED_RUNSTATEDIR}/dbus/pid" fi AC_SUBST(DBUS_SYSTEM_PID_FILE) @@ -1592,6 +1600,10 @@ AC_SUBST(DBUS_SYSTEM_PID_FILE) if ! test -z "$with_console_auth_dir"; then DBUS_CONSOLE_AUTH_DIR=$with_console_auth_dir else + # We don't use runstatedir for this (yet?), because /var/run is the + # path that was traditionally used by pam_console and pam_foreground. + # TODO: pam_console and pam_foreground were superseded by ConsoleKit, + # which was superseded by systemd-logind, so maybe we should remove this DBUS_CONSOLE_AUTH_DIR=/var/run/console/ fi @@ -1918,6 +1930,7 @@ echo " bindir: ${EXPANDED_BINDIR} sysconfdir: ${EXPANDED_SYSCONFDIR} localstatedir: ${EXPANDED_LOCALSTATEDIR} + runstatedir: ${EXPANDED_RUNSTATEDIR} datadir: ${EXPANDED_DATADIR} source code location: ${srcdir} compiler: ${CC} diff --git a/dbus/Makefile.am b/dbus/Makefile.am index e4aa2eea..67ce8cce 100644 --- a/dbus/Makefile.am +++ b/dbus/Makefile.am @@ -12,6 +12,7 @@ AM_CPPFLAGS = \ -DDBUS_MACHINE_UUID_FILE=\""$(localstatedir)/lib/dbus/machine-id"\" \ -DDBUS_SYSTEM_CONFIG_FILE=\""$(dbusdatadir)/system.conf"\" \ -DDBUS_SESSION_CONFIG_FILE=\""$(dbusdatadir)/session.conf"\" \ + -DDBUS_RUNSTATEDIR=\""$(runstatedir)"\" \ $(NULL) AM_CFLAGS = \ -- 2.11.0