]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
build: Don't use build-time TMPDIR, TEMP, TMP as socket directory
authorSimon McVittie <smcv@collabora.com>
Mon, 28 Apr 2025 13:06:39 +0000 (14:06 +0100)
committerSimon McVittie <smcv@collabora.com>
Fri, 16 May 2025 10:22:11 +0000 (10:22 +0000)
When the ancestor of this code was introduced in 2003 (commit e45e4382),
it was presumably most common to have these variables either unset, or
set to a value that is system-wide and remains valid in the long term,
such as /tmp or /var/tmp.

However, on modern systems they are sometimes set to a value that is
itself temporary, for example /var/folders/${some_long_path}/T on macOS,
or user-specific, for example /tmp/user/$(id -u) on Linux with
libpam-tmpdir. These values are certainly not useful to hard-code into
libdbus and dbus-daemon during installation: they will not be usable
when running dbus-related programs after a reboot or as a different user.

So, instead of assuming TMPDIR, TEMP and TMP remain valid long-term,
we now hard-code /tmp as our default.

As before, system integrators can override this default with
`-Dsession_socket_dir=...` (Meson) or `-DDBUS_SESSION_SOCKET_DIR=...`
(CMake) if a different directory is more appropriate than /tmp.
However, system integrators should note that because AF_UNIX paths have
a relatively short length limit (typically 108 bytes), a short path is
better than a long path in this context.

Resolves: dbus/dbus#551
Signed-off-by: Simon McVittie <smcv@collabora.com>
CMakeLists.txt
meson.build

index 49ae125b3f3c70bb2b6d517bc17c561cef40ad16..82c1493a237f3c23042e7fc0f8e82dec03cdd7a4 100644 (file)
@@ -562,23 +562,9 @@ if(MSVC_IDE)
     file(REMOVE ${PROJECT_BINARY_DIR}/data/dbus-1/services)
 endif()
 
-#### Find socket directories
-set(DBUS_SESSION_SOCKET_DIR "" CACHE STRING "Default directory for session socket")
-if(UNIX)
-    if (CMAKE_CROSSCOMPILING)
-        if (NOT DBUS_SESSION_SOCKET_DIR)
-            message(FATAL_ERROR "cannot autodetect session socket directory "
-                    "when crosscompiling, pass -DDBUS_SESSION_SOCKET_DIR=...")
-        endif()
-    elseif(NOT $ENV{TMPDIR} STREQUAL "")
-        set(DBUS_SESSION_SOCKET_DIR $ENV{TMPDIR})
-    elseif(NOT $ENV{TEMP} STREQUAL "")
-        set(DBUS_SESSION_SOCKET_DIR $ENV{TEMP})
-    elseif(NOT $ENV{TMP} STREQUAL "")
-        set(DBUS_SESSION_SOCKET_DIR $ENV{TMP})
-    else()
-        set(DBUS_SESSION_SOCKET_DIR /tmp)
-    endif()
+set(DBUS_SESSION_SOCKET_DIR "" CACHE STRING "Default directory for session socket on Unix")
+if(UNIX AND NOT DBUS_SESSION_SOCKET_DIR)
+    set(DBUS_SESSION_SOCKET_DIR /tmp)
 endif()
 
  # Not used on Windows, where there is no system bus
index 65bb9d0d8e594d13c2dfee9adb4b3242224c8478..451da911446e492db69353ddf0c64b48d60ea8d6 100644 (file)
@@ -1070,19 +1070,11 @@ endif
 data_config.set('SYSCONFDIR_FROM_PKGDATADIR', sysconfdir_from_pkgdatadir)
 data_config.set('DATADIR_FROM_PKGSYSCONFDIR', datadir_from_pkgsysconfdir)
 
-#### Find socket directories
-values = run_command(python, '-c',
-    'import os; [print(os.getenv(e, "")) for e in ["TMPDIR", "TEMP", "TMP"]]',
-    check: true,
-).stdout()
-values += '/tmp'
-default_socket_dir = values.strip().split('\n')[0]
-
 if platform_unix
     session_socket_dir = get_option('session_socket_dir')
 
     if session_socket_dir == ''
-        session_socket_dir = default_socket_dir
+        session_socket_dir = '/tmp'
     endif
 
     config.set_quoted('DBUS_SESSION_SOCKET_DIR', session_socket_dir)