mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-01-06 07:10:14 +01:00
build: Don't use build-time TMPDIR, TEMP, TMP as socket directory
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>
This commit is contained in:
parent
f7952eb8e8
commit
d7afc131bf
2 changed files with 4 additions and 26 deletions
|
|
@ -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
|
||||
|
|
|
|||
10
meson.build
10
meson.build
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue