From 73240b300ed15ff81936ff84425636cc84e6c7dd Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 10 Dec 2021 13:08:38 +0000 Subject: [PATCH 01/29] bus: Correct check for inotify_init() failure fd 0 is a valid fd - although if we are using stdin as our inotify fd, something is weird somewhere. Signed-off-by: Simon McVittie (cherry picked from commit 7e61e0b53b2555cdd6256b446a2422a6bf969114) Backported-from: dbus!235 --- bus/dir-watch-inotify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bus/dir-watch-inotify.c b/bus/dir-watch-inotify.c index 940f09a0..6cc02968 100644 --- a/bus/dir-watch-inotify.c +++ b/bus/dir-watch-inotify.c @@ -234,7 +234,7 @@ _init_inotify (BusContext *context) #else inotify_fd = inotify_init (); #endif - if (inotify_fd <= 0) + if (inotify_fd < 0) { _dbus_warn ("Cannot initialize inotify"); goto out; From 052a2bead8d77e3e477cedc2355c25cde7e4b1b8 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 10 Dec 2021 13:09:15 +0000 Subject: [PATCH 02/29] bus: Show the errno if inotify cannot be initialized Signed-off-by: Simon McVittie (cherry picked from commit 25e22b2540d04aa66341def929081b477a28a4cd) Backported-from: dbus!235 --- bus/dir-watch-inotify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bus/dir-watch-inotify.c b/bus/dir-watch-inotify.c index 6cc02968..b52a24c0 100644 --- a/bus/dir-watch-inotify.c +++ b/bus/dir-watch-inotify.c @@ -236,7 +236,7 @@ _init_inotify (BusContext *context) #endif if (inotify_fd < 0) { - _dbus_warn ("Cannot initialize inotify"); + _dbus_warn ("Cannot initialize inotify: %s", _dbus_strerror (errno)); goto out; } From 29631357acfd278fde1abdd70a4af3e72dde27dc Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Wed, 2 Mar 2022 11:00:06 +0100 Subject: [PATCH 03/29] cmake: setup variable WORDS_BIGENDIAN correctly Since version 3.0 cmake provides the macro test_big_endian for that purpose. fixes #375 Signed-off-by: Ralf Habacker (cherry picked from commit d74fee2727617778aafe42dc6ea7519876efe9a8) Backported-from: dbus!266 --- CMakeLists.txt | 4 ++++ cmake/config.h.cmake | 3 +++ 2 files changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e1fc413..a29bddcf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,10 @@ include(MacrosAutotools) autoinit(configure.ac) autoversion(dbus) +# replacement for AC_C_BIGENDIAN +include (TestBigEndian) +test_big_endian(WORDS_BIGENDIAN) + if(EXISTS ${CMAKE_SOURCE_DIR}/config.h.in) autoheaderchecks(${CMAKE_SOURCE_DIR}/config.h.in ${CMAKE_SOURCE_DIR}/cmake/ConfigureChecks.cmake ${CMAKE_SOURCE_DIR}/cmake/config.h.cmake) else() diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 4215a903..06bb34fd 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -21,6 +21,9 @@ * should be placed in this file */ +/* AC_C_BIGENDIAN */ +#cmakedefine WORDS_BIGENDIAN + /* Opt-in to modern APIs and thread-safety for Solaris. In the Autotools * build system we do the equivalent of this by appending to CFLAGS * in configure.ac */ From b745747f52d938a1ecfb80e87ee53b2b7a5654d5 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Thu, 3 Mar 2022 09:48:51 +0100 Subject: [PATCH 04/29] cmake: Set DBUS_*_CONFIG_FILE to be in datadir on Unix The files were installed to the datadir (usually /usr/share) since commit 70950325, but the macros used to implement dbus-daemon --system and dbus-daemon --session still looked for them in the sysconfdir (usually /etc). Fixes: 70950325 "Adjust cmake build to match autoconf installation locations" (cherry picked from commit 6c21072a1e7832783b77dfde8d95ddf1e5927b98) Backported-from: dbus!267 --- CMakeLists.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a29bddcf..210e5311 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -610,10 +610,8 @@ if(WIN32) else(WIN32) 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) - set(DBUS_SESSION_CONFIG_FILE ${configdir}/session.conf) + set(DBUS_SYSTEM_CONFIG_FILE ${DBUS_DATADIR}/system.conf) + set(DBUS_SESSION_CONFIG_FILE ${DBUS_DATADIR}/session.conf) set(DBUS_USER "messagebus") set(DBUS_TEST_USER "nobody") # For best security, assume that all non-Windows platforms can do From 83325d29adf03582960d1640eecdfa8576501385 Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Sat, 19 Mar 2022 14:48:04 +0000 Subject: [PATCH 05/29] =?UTF-8?q?Revert=20"Fix=20gcc=20compile=20error:=20?= =?UTF-8?q?redundant=20redeclaration=20of=20=E2=80=98environ=E2=80=99=20[-?= =?UTF-8?q?Werror=3Dredundant-decls]"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Breaks the build on FreeBSD which doens't have an environ declaration. The CMake check_symbol_exists call sets `HAVE_DECL_ENVIRON` to an empty variable (which means if(DEFINED) suceeds). This normalization should not be necessary as it will be handled correctly by `#cmakedefine01`. If not, all the other HAVE_* defines would also be wrong. This reverts commit e8b34b419e44e0b95622f45c0f17487e241b1961. (cherry picked from commit d4dbde9fc5bb217fe279b162195961552837fcca) Backported-from: dbus!277 --- CMakeLists.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 210e5311..66590792 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -625,11 +625,6 @@ set(DBUS_DAEMON_NAME "dbus-daemon" CACHE STRING "The name of the dbus daemon exe #include(ConfigureChecks.cmake) -# only defined but expected as boolean -if(DEFINED HAVE_DECL_ENVIRON) - set(HAVE_DECL_ENVIRON 1) -endif() - # compiler definitions add_definitions(-DHAVE_CONFIG_H) add_definitions(${DBUS_BUS_CFLAGS}) From 42b8ac2ba05116fd00ceeab1100c5c59e9b189ab Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Sun, 20 Mar 2022 23:25:29 +0000 Subject: [PATCH 06/29] cmake: Detect backtrace() support on platforms such as FreeBSD On FreeBSD use of backtrace requires linking libexecinfo. The current check_symbol_exists() will fail due to that missing library. Fortunately, CMake ships with a FindBacktrace module (at least since 3.0) that can be used to correctly handle platforms such as FreeBSD (and OpenBSD according to the FindBacktrace source). (cherry picked from commit 3f5bdf0c2df3fb2b15f7dde246bf035bfae4d37a) Backported-from: dbus!281 --- cmake/ConfigureChecks.cmake | 4 +++- dbus/CMakeLists.txt | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index 7e21e084..45136cc3 100644 --- a/cmake/ConfigureChecks.cmake +++ b/cmake/ConfigureChecks.cmake @@ -42,7 +42,9 @@ check_include_file(ws2tcpip.h HAVE_WS2TCPIP_H)# dbus-sysdeps-win.c check_include_file(unistd.h HAVE_UNISTD_H) # dbus-sysdeps-util-win.c check_include_file(sys/inotify.h DBUS_BUS_ENABLE_INOTIFY) -check_symbol_exists(backtrace "execinfo.h" HAVE_BACKTRACE) # dbus-sysdeps.c, dbus-sysdeps-win.c +find_package(Backtrace) # dbus-sysdeps.c, dbus-sysdeps-win.c +set(HAVE_BACKTRACE ${Backtrace_FOUND}) + check_symbol_exists(getgrouplist "grp.h" HAVE_GETGROUPLIST) # dbus-sysdeps.c check_symbol_exists(getpeerucred "ucred.h" HAVE_GETPEERUCRED) # dbus-sysdeps.c, dbus-sysdeps-win.c check_symbol_exists(nanosleep "time.h" HAVE_NANOSLEEP) # dbus-sysdeps.c diff --git a/dbus/CMakeLists.txt b/dbus/CMakeLists.txt index e9203ca6..9e3f0a14 100644 --- a/dbus/CMakeLists.txt +++ b/dbus/CMakeLists.txt @@ -292,6 +292,10 @@ else(WIN32) if(LIBSOCKET) target_link_libraries(dbus-1 ${LIBSOCKET}) endif() + if (HAVE_BACKTRACE) + target_link_libraries(dbus-1 ${Backtrace_LIBRARY}) + target_include_directories(dbus-1 PRIVATE ${Backtrace_INCLUDE_DIR}) + endif() endif() target_include_directories(dbus-1 INTERFACE $;$) From 8c05bdc5866a979a51f94255d9eb90867ec81da8 Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Wed, 23 Mar 2022 22:06:33 +0000 Subject: [PATCH 07/29] cmake: Drop an unnecessary include directory There should be no need to include the directory above the DBus sources, if that is actually required users can always pass -I flags to CMake. I noticed this because CLion started indexing all my cloned projects when I opened DBus due to this include path. (cherry picked from commit be5da7305e779f73c6832647cd69235bb348865f) Backported-from: dbus!282 --- bus/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/bus/CMakeLists.txt b/bus/CMakeLists.txt index 26f07dd2..dafee593 100644 --- a/bus/CMakeLists.txt +++ b/bus/CMakeLists.txt @@ -85,7 +85,6 @@ endif() include_directories( ${CMAKE_BINARY_DIR} - ${CMAKE_SOURCE_DIR}/.. ${EXPAT_INCLUDE_DIR} ) From 41d2026fbd55554a538249a986edf772e3865615 Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Sat, 19 Mar 2022 17:56:54 +0000 Subject: [PATCH 08/29] cmake: Only pass -Wl,--export-dynamic when linking Otherwise we get the following warnings when building .o files with Clang: clang-13: warning: -Wl,--export-dynamic: 'linker' input unused [-Wunused-command-line-argument] This is required to allow the -Werror build to pass on FreeBSD. (cherry picked from commit 1a8fd7a3820d193d1132bc4c84317348799181ff) Backported-from: dbus!278 --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 66590792..2eb4b52c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -377,8 +377,8 @@ endif() if(UNIX AND NOT DBUS_DISABLE_ASSERT) # required for backtrace - string(APPEND CMAKE_C_FLAGS_DEBUG " -Wl,--export-dynamic") - string(APPEND CMAKE_CXX_FLAGS_DEBUG " -Wl,--export-dynamic") + string(APPEND CMAKE_SHARED_LINKER_FLAGS " -Wl,--export-dynamic") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,--export-dynamic") set(DBUS_BUILT_R_DYNAMIC 1) endif() From ce73955aad33998c666b9705d6005fb49792a93b Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Sat, 19 Mar 2022 19:23:32 +0000 Subject: [PATCH 09/29] cmake: Use -Wl,-export_dynamic when building for macOS The macOS linker does not accept --export-dynamic, so use this alternate spelling. (cherry picked from commit c7f6d072522702a505de71b3faa2ff160bde848e) Backported-from: dbus!278 --- CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2eb4b52c..ae9700db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -377,8 +377,13 @@ endif() if(UNIX AND NOT DBUS_DISABLE_ASSERT) # required for backtrace - string(APPEND CMAKE_SHARED_LINKER_FLAGS " -Wl,--export-dynamic") - string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,--export-dynamic") + if (APPLE) + string(APPEND CMAKE_SHARED_LINKER_FLAGS " -Wl,-export_dynamic") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,-export_dynamic") + else() + string(APPEND CMAKE_SHARED_LINKER_FLAGS " -Wl,--export-dynamic") + string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,--export-dynamic") + endif() set(DBUS_BUILT_R_DYNAMIC 1) endif() From 0d3ca74340b9468c0d9b979b4f6dd20fc903e92a Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Sat, 19 Mar 2022 14:56:12 +0000 Subject: [PATCH 10/29] cmake: Fix DBUS_SESSION_SOCKET_DIR when cross-compiling Inferring it from the environment is not correct, since the host system could have a different temporary directory defined. Instead of guessing based on the host, require the user to pass an explicit directory when cross-compiling. This is helpful for me since I am cross-compiling for FreeBSD from macOS and on my host TMPDIR is set to /var/folders//T/ instead of the expected /tmp. (cherry picked from commit e827309976cab94c806fda20013915f1db2d4f5a) Backported-from: dbus!279 --- CMakeLists.txt | 8 +++++++- README.cmake | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ae9700db..cc4926e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -575,8 +575,14 @@ if(MSVC_IDE) endif() #### Find socket directories +set(DBUS_SESSION_SOCKET_DIR "" CACHE STRING "Default directory for session socket") if(UNIX) - if(NOT $ENV{TMPDIR} STREQUAL "") + 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}) diff --git a/README.cmake b/README.cmake index a1cfc96a..281b730d 100644 --- a/README.cmake +++ b/README.cmake @@ -179,6 +179,9 @@ DBUS_SESSION_BUS_LISTEN_ADDRESS:STRING=autolaunch: // session bus fallback address for clients DBUS_SESSION_BUS_CONNECT_ADDRESS:STRING=autolaunch: +//Default directory for session socket +DBUS_SESSION_SOCKET_DIR:STRING=/tmp + // system bus default address (only useful on Unix) DBUS_SYSTEM_BUS_DEFAULT_ADDRESS:STRING=unix:path=/var/run/dbus/system_bus_socket From d5f9a6e075d3ce13bb5fd8f64bd4317220503cb0 Mon Sep 17 00:00:00 2001 From: Mike Gilbert Date: Sun, 27 Mar 2022 15:09:48 -0400 Subject: [PATCH 11/29] sysdeps-unix: check fd before calling _dbus_fd_set_close_on_exec() If /proc/self/oom_score_adj does not exist, fd will invalid (-1). Attempting to set the CLOEXEC flag will obviously fail, and we lose the original errno value from open(). Bug: https://bugs.gentoo.org/834725 Signed-off-by: Mike Gilbert (cherry picked from commit 769a0462befb9829594a76e675526aba8579317e) Backported-from: dbus!285 --- dbus/dbus-sysdeps-util-unix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index 314ce64b..8f079cbf 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -1633,7 +1633,8 @@ _dbus_reset_oom_score_adj (const char **error_str_p) if (fd < 0) { fd = open ("/proc/self/oom_score_adj", O_RDWR); - _dbus_fd_set_close_on_exec (fd); + if (fd >= 0) + _dbus_fd_set_close_on_exec (fd); } if (fd >= 0) From e2dd13d9061d8c8a212b9f2f0e6503cc7cf60a51 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 6 Nov 2020 14:42:19 +0000 Subject: [PATCH 12/29] cmake: Look for dbus-arch-deps.h next to DBus1Config.cmake is architecture-dependent, and compilers have not traditionally supported an installation path for architecture-specific headers (Debian-based systems have /usr/include/${multiarch_tuple}, but that isn't portable beyond Debian). When dbus was built using Autotools, dependent projects that use CMake need to look for this header in the right place. Unfortunately, it seems that at least recent versions of CMake will ignore the HINTS we get from pkg-config if they are told to search in a non-standard prefix via ${DBus1_ROOT}. Look for dbus-arch-deps.h in a directory derived from the filename of the CMake config file, before trying the normal search algorithm. The CMake config file is in ${libdir}, and so is the architecture-specific header, so this should work reasonably reliably. According to the CMake documentation, if we search for the same thing multiple times, the first successful result will be used; and searching with NO_DEFAULT_PATH is the official way to prepend things to the search order. Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/314 Signed-off-by: Simon McVittie (cherry picked from commit 104df89947913e97bf4253d7dea53626063f6406) Backported-from: dbus!191 --- cmake/DBus1Config.pkgconfig.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/DBus1Config.pkgconfig.in b/cmake/DBus1Config.pkgconfig.in index 93c593e1..0f021850 100644 --- a/cmake/DBus1Config.pkgconfig.in +++ b/cmake/DBus1Config.pkgconfig.in @@ -9,6 +9,7 @@ # to a target with target_link_libraries get_filename_component(DBus1_PKGCONFIG_DIR "${CMAKE_CURRENT_LIST_DIR}/../../pkgconfig" ABSOLUTE) +get_filename_component(DBus1_NEARBY_ARCH_INCLUDE_DIR "${CMAKE_CURRENT_LIST_DIR}/../../dbus-1.0/include" ABSOLUTE) find_package(PkgConfig) if(DEFINED ENV{PKG_CONFIG_DIR}) set(_dbus_pkgconfig_dir "$ENV{PKG_CONFIG_DIR}") @@ -50,6 +51,9 @@ set(DBus1_DEFINITIONS ${PC_DBUS1_CFLAGS_OTHER}) find_path(DBus1_INCLUDE_DIR dbus/dbus.h HINTS ${PC_DBUS1_INCLUDEDIR} ${PC_DBUS1_INCLUDE_DIRS} PATH_SUFFIXES dbus-1.0) +find_path(DBus1_ARCH_INCLUDE_DIR dbus/dbus-arch-deps.h + PATHS ${DBus1_NEARBY_ARCH_INCLUDE_DIR} + NO_DEFAULT_PATH) find_path(DBus1_ARCH_INCLUDE_DIR dbus/dbus-arch-deps.h HINTS ${PC_DBUS1_INCLUDE_DIRS} PATH_SUFFIXES dbus-1.0) From 1c081156090629b9fbb2b60a2845084a0dcc7e3b Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Sat, 16 Apr 2022 16:04:22 +0000 Subject: [PATCH 13/29] Fix no-X11 build after d847b5f6ae994c408c166ed51752ed9f550df600 Since that commit the error variable is used in all cases not only the DBUS_BUILD_X11 #ifdef branches. Fixes: https://gitlab.freedesktop.org/dbus/dbus/-/issues/392 (cherry picked from commit 6c1c7e539f17099e6f2b624cdae160fd8138a8fb) Backported-from: dbus!298 --- tools/dbus-launch.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index f1a5b970..74e39691 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -846,9 +846,7 @@ main (int argc, char **argv) dbus_bool_t user_bus_supported = FALSE; DBusString user_bus; const char *error_str; -#ifdef DBUS_BUILD_X11 DBusError error = DBUS_ERROR_INIT; -#endif exit_with_session = FALSE; config_file = NULL; From 3533087ea4525940e87dca27b7dbb55a11cb306d Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Fri, 1 Apr 2022 11:09:45 +0000 Subject: [PATCH 14/29] cmake: Correct DBUS_{SYSTEM,SESSION}_CONFIG_FILE on UNIX systems We always install to a dbus-1 subdir, but the path encoded in the binary was missing the dbus-1/ subdirectory, so we end up getting errors when trying to load it. (cherry picked from commit f4876e7cb5815f5d329f9517d96a1df88688cf9f) Backported-from: dbus!297 --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cc4926e3..98904504 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -621,8 +621,8 @@ if(WIN32) else(WIN32) 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(DBUS_SYSTEM_CONFIG_FILE ${DBUS_DATADIR}/system.conf) - set(DBUS_SESSION_CONFIG_FILE ${DBUS_DATADIR}/session.conf) + set(DBUS_SYSTEM_CONFIG_FILE ${DBUS_DATADIR}/dbus-1/system.conf) + set(DBUS_SESSION_CONFIG_FILE ${DBUS_DATADIR}/dbus-1/session.conf) set(DBUS_USER "messagebus") set(DBUS_TEST_USER "nobody") # For best security, assume that all non-Windows platforms can do From 9e8fe0718c1abf93e92fcf98c3fe962fc524bfa8 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Wed, 20 Apr 2022 11:07:25 +0200 Subject: [PATCH 15/29] bus/dir-watch: Do not crash with > 128 dirs Without this running, dbus-daemon with long XDG_DATA_DIRS will crash on out-of-bounds write: $ XDG_DATA_DIRS=$(seq -f "/foo/%g" -s ':' 129) dbus-daemon --session *** stack smashing detected ***: terminated (cherry picked from commit b551b3e9737958216a1a9d359150a4110a9d0549) Backported-from: dbus!302 --- bus/dir-watch-inotify.c | 7 ++++++- bus/dir-watch-kqueue.c | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/bus/dir-watch-inotify.c b/bus/dir-watch-inotify.c index b52a24c0..9beadb0e 100644 --- a/bus/dir-watch-inotify.c +++ b/bus/dir-watch-inotify.c @@ -108,12 +108,17 @@ _set_watched_dirs_internal (DBusList **directories) i = 0; link = _dbus_list_get_first_link (directories); - while (link != NULL) + while (link != NULL && i < MAX_DIRS_TO_WATCH) { new_dirs[i++] = (char *)link->data; link = _dbus_list_get_next_link (directories, link); } + if (link != NULL) + { + _dbus_warn ("Too many directories to watch them all, only watching first %d.", MAX_DIRS_TO_WATCH); + } + /* Look for directories in both the old and new sets, if * we find one, move its data into the new set. */ diff --git a/bus/dir-watch-kqueue.c b/bus/dir-watch-kqueue.c index 183db241..15519fcb 100644 --- a/bus/dir-watch-kqueue.c +++ b/bus/dir-watch-kqueue.c @@ -218,12 +218,17 @@ bus_set_watched_dirs (BusContext *context, DBusList **directories) i = 0; link = _dbus_list_get_first_link (directories); - while (link != NULL) + while (link != NULL && i < MAX_DIRS_TO_WATCH) { new_dirs[i++] = (char *)link->data; link = _dbus_list_get_next_link (directories, link); } + if (link != NULL) + { + _dbus_warn ("Too many directories to watch them all, only watching first %d.", MAX_DIRS_TO_WATCH); + } + /* Look for directories in both the old and new sets, if * we find one, move its data into the new set. */ From 9cf3b0810fcec8acd324d1b7a278ac9dc4aed08d Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Sun, 15 May 2022 11:28:51 +0100 Subject: [PATCH 16/29] cmake: Fix definition of DBUS_USE_SYNC dbus-sysdeps-unix.c checks for DBUS_USE_SYNC using 0/1 checks not defined checks, so we should be using #cmakedefine01. This fixes lots of -Wundef warnings when compiling for FreeBSD and ensures that we actually use atomics instead of the pthread fallback there. (cherry picked from commit b932c343c4965023b0fd0a16be76840755ff6434) Backported-from: dbus!306 --- cmake/ConfigureChecks.cmake | 2 +- cmake/config.h.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index 45136cc3..baa8ac21 100644 --- a/cmake/ConfigureChecks.cmake +++ b/cmake/ConfigureChecks.cmake @@ -137,7 +137,7 @@ CHECK_C_SOURCE_COMPILES(" int main() { int a = 4; int b = __sync_sub_and_fetch(&a, 4); - exit(b); + return b; } " DBUS_USE_SYNC) diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 06bb34fd..ed8ef66c 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -246,7 +246,7 @@ #cmakedefine DBUS_HAVE_LINUX_EPOLL 1 /* Use the gcc __sync extension */ -#cmakedefine DBUS_USE_SYNC 1 +#cmakedefine01 DBUS_USE_SYNC #cmakedefine HAVE_VASPRINTF 1 #cmakedefine HAVE_VSNPRINTF 1 From 6625f220c41df3103db90f93c405e004ee5fd402 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sun, 22 May 2022 21:45:27 +0200 Subject: [PATCH 17/29] build: Do not dist built XML catalog It will have whatever paths the person who built the dist tarball hardcoded. (cherry picked from commit dcd19cc0d970df073643caee4bd3b97fe93b68ac) Backported-from: dbus!317 --- doc/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/Makefile.am b/doc/Makefile.am index 605f8666..471ac2b5 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -30,7 +30,7 @@ xmlcatalogdir = $(dtddir) catalog.xml: catalog.xml.in $(SED) "s|@DBUS_DTD_DIR@|$(dtddir)|" $< >$@ -dist_xmlcatalog_DATA = \ +xmlcatalog_DATA = \ catalog.xml dist_doc_DATA = system-activation.txt @@ -211,6 +211,7 @@ endif CLEANFILES = \ $(man1_MANS) \ $(MAN_XML_FILES) \ + $(xmlcatalog_DATA) \ $(XMLTO_HTML) \ $(YELP_HTML) \ $(YELP_STATIC_HTML) \ From 6d7ec5fc6d62f9749e1d2634625f85104f64b41b Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Wed, 25 May 2022 22:05:03 +0000 Subject: [PATCH 18/29] configure: Avoid exit() when checking for __sync_sub_and_fetch() Use of exit() requires a stdlib.h include. This check was failing for me since the compiler defaulted to -Werror=implicit-function-declaration, so __sync_sub_and_fetch() support was not dectected. (cherry picked from commit 56e52a4212cb78e55d1bdee9c1f2a85a205c1ee9) Backported-from: dbus!320 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index e33df00b..61f22dc2 100644 --- a/configure.ac +++ b/configure.ac @@ -613,7 +613,7 @@ AS_IF([test -n "$dbus_va_copy_func"], AC_CACHE_CHECK([whether $CC knows __sync_sub_and_fetch()], dbus_cv_sync_sub_and_fetch, [AC_LINK_IFELSE([ - AC_LANG_PROGRAM([[]], [[int a = 4; int b = __sync_sub_and_fetch(&a, 4); exit(b); ]])], + AC_LANG_PROGRAM([[]], [[int a = 4; int b = __sync_sub_and_fetch(&a, 4); return b; ]])], [dbus_cv_sync_sub_and_fetch=yes], [dbus_cv_sync_sub_and_fetch=no]) ]) From 434ac5fdb3001aa251a16047d7ca6109b1c66141 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 18 May 2022 13:59:17 +0100 Subject: [PATCH 19/29] COPYING: The project is called dbus, not D-Bus We are trying to be consistent about saying this codebase is dbus (a piece of software), which is the reference implementation of D-Bus (a protocol). Signed-off-by: Simon McVittie (cherry picked from commit 789d97ad53044f94351a958e785c2923643b346a) --- COPYING | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/COPYING b/COPYING index 8260b100..1483f37e 100644 --- a/COPYING +++ b/COPYING @@ -1,4 +1,4 @@ -D-Bus is licensed to you under your choice of the Academic Free +dbus is licensed to you under your choice of the Academic Free License version 2.1, or the GNU General Public License version 2 (or, at your option any later version). From aacd468108a75bc8f43238c80379c4cea322278b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 1 Apr 2022 18:58:34 +0100 Subject: [PATCH 20/29] activation-helper: Never crash if unable to write oom_score_adj _dbus_warn() normally only logs a warning, but can be made fatal by environment variables. In particular, we do that during unit testing, which can result in a build-time test failure if dbus is built in a sandbox environment that prevents write access. _dbus_log() does only the logging part of _dbus_warn(), which seems more appropriate here. Signed-off-by: Simon McVittie (cherry picked from commit ad72e3b9e352f6cb1d568bb01f0d79c2a63fc276) Backported-from: dbus!291 --- bus/activation-helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bus/activation-helper.c b/bus/activation-helper.c index 8a4fd732..df0472ce 100644 --- a/bus/activation-helper.c +++ b/bus/activation-helper.c @@ -348,7 +348,7 @@ exec_for_correct_user (char *exec, char *user, DBusError *error) /* Resetting the OOM score adjustment is best-effort, so we don't * treat a failure to do so as fatal. */ if (!_dbus_reset_oom_score_adj (&error_str)) - _dbus_warn ("%s: %s", error_str, strerror (errno)); + _dbus_log (DBUS_SYSTEM_LOG_WARNING, "%s: %s", error_str, strerror (errno)); if (!switch_user (user, error)) return FALSE; From a54da99a062d3286d373aedb1ab013b2c48c6117 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 1 Apr 2022 18:56:26 +0100 Subject: [PATCH 21/29] sysdeps: Only open oom_score_adj read/write if we need to write it If we're running in a sandbox, we might not have write access to oom_score_adj. In the common case where we don't have any special protection from the OOM-killer, we can detect that with only read access, and skip the part where we open it for writing. (We would also not have write access to oom_score_adj if we're running with elevated Linux capabilities while not root, but that should never actually happen for dbus-daemon-launch-helper, which is setuid root for production use or has no capabilities during unit-testing.) Signed-off-by: Simon McVittie (cherry picked from commit a8006841ce73e0d2131c55d414e3e45a1827b6d6) Backported-from: dbus!291 --- dbus/dbus-sysdeps-util-unix.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index 8f079cbf..ca130cff 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -1627,12 +1627,12 @@ _dbus_reset_oom_score_adj (const char **error_str_p) const char *error_str = NULL; #ifdef O_CLOEXEC - fd = open ("/proc/self/oom_score_adj", O_RDWR | O_CLOEXEC); + fd = open ("/proc/self/oom_score_adj", O_RDONLY | O_CLOEXEC); #endif if (fd < 0) { - fd = open ("/proc/self/oom_score_adj", O_RDWR); + fd = open ("/proc/self/oom_score_adj", O_RDONLY); if (fd >= 0) _dbus_fd_set_close_on_exec (fd); } @@ -1680,6 +1680,26 @@ _dbus_reset_oom_score_adj (const char **error_str_p) goto out; } + close (fd); +#ifdef O_CLOEXEC + fd = open ("/proc/self/oom_score_adj", O_WRONLY | O_CLOEXEC); + + if (fd < 0) +#endif + { + fd = open ("/proc/self/oom_score_adj", O_WRONLY); + if (fd >= 0) + _dbus_fd_set_close_on_exec (fd); + } + + if (fd < 0) + { + ret = FALSE; + error_str = "open(/proc/self/oom_score_adj) for writing"; + saved_errno = errno; + goto out; + } + if (pwrite (fd, "0", sizeof (char), 0) < 0) { ret = FALSE; @@ -1700,7 +1720,7 @@ _dbus_reset_oom_score_adj (const char **error_str_p) else { ret = FALSE; - error_str = "open(/proc/self/oom_score_adj)"; + error_str = "open(/proc/self/oom_score_adj) for reading"; saved_errno = errno; goto out; } From c8dd76206b323da2847f628bf5b7c5a41d4b287f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 18 Jul 2022 11:14:08 +0100 Subject: [PATCH 22/29] test: Skip tests that involve switching uid if unable to do so In a Linux user namespace, it is possible that we are uid 0 but are unable to switch to some other uid like DBUS_USER or DBUS_TEST_USER, because the other uid is not "mapped" in the user namespace, resulting in setuid() or setresuid() failing with EINVAL "Invalid argument". For example, it's easy for this to happen when running under the bubblewrap tool. Try to drop privileges in a child process, and skip the test if we are unable to do so. Resolves: dbus#407 Signed-off-by: Simon McVittie (cherry picked from commit 8b08dd32644cfdf6d6d054bfbcb836f3fefca723) Backported-from: dbus!330 --- test/test-utils-glib.c | 62 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/test/test-utils-glib.c b/test/test-utils-glib.c index 2aafb03e..231860a1 100644 --- a/test/test-utils-glib.c +++ b/test/test-utils-glib.c @@ -40,6 +40,7 @@ # include # include # include +# include # include #endif @@ -66,6 +67,61 @@ _test_assert_no_error (const DBusError *e, } #ifdef DBUS_UNIX +static gboolean +can_become_user_or_skip (uid_t uid) +{ + gchar *message; + pid_t child_pid; + pid_t pid; + int wstatus; + + /* We can't switch to the uid without affecting the whole process, + * which we don't necessarily want to do, so try it in a child process. */ + child_pid = fork (); + + if (child_pid < 0) + g_error ("fork: %s", g_strerror (errno)); + + if (child_pid == 0) + { + /* Child process: try to become uid, exit 0 on success, exit with + * status = errno on failure */ + + if (setuid (uid) != 0) + { + /* make sure we report failure even if errno is wrong */ + if (errno == 0) + errno = ENODATA; + + _exit (errno); + } + + /* success */ + _exit (0); + } + + /* Parent process: wait for child and report result */ + + pid = waitpid (child_pid, &wstatus, 0); + g_assert_cmpuint (child_pid, ==, pid); + + if (WIFEXITED (wstatus) && WEXITSTATUS (wstatus) == 0) + return TRUE; + + if (WIFEXITED (wstatus)) + message = g_strdup_printf ("unable to become uid %lu: %s", + (unsigned long) uid, + g_strerror (WEXITSTATUS (wstatus))); + else + message = g_strdup_printf ("unable to become uid %lu: unknown wait status %d", + (unsigned long) uid, + wstatus); + + g_test_skip (message); + g_free (message); + return FALSE; +} + static void child_setup (gpointer user_data) { @@ -141,6 +197,9 @@ spawn_dbus_daemon (const gchar *binary, return NULL; } + if (!can_become_user_or_skip (pwd->pw_uid)) + return NULL; + if (user == TEST_USER_ROOT_DROP_TO_MESSAGEBUS) { /* Let the dbus-daemon start as root and drop privileges @@ -163,6 +222,9 @@ spawn_dbus_daemon (const gchar *binary, return NULL; } + if (!can_become_user_or_skip (pwd->pw_uid)) + return NULL; + break; case TEST_USER_ME: From 2d36911fc3d490f4cd443fe86d5f28994d6e63c0 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sat, 23 Jul 2022 11:19:28 +0100 Subject: [PATCH 23/29] Move release checklist to its own file In other projects I've found that having a separate file that only lists the release steps makes them easier to check. Signed-off-by: Simon McVittie (cherry picked from commit 3758e5b1648a26fd2343db3c804d32a29ae75ff8) --- CONTRIBUTING.md | 81 +------------------------------------ maint/release-checklist.md | 82 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 80 deletions(-) create mode 100644 maint/release-checklist.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d141fb8b..a83fceec 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -270,86 +270,7 @@ This section is not directly relevant to infrequent contributors. ### Releasing -To make a release of D-Bus, do the following: - - - check out a fresh copy from Git - - - verify that the libtool versioning/library soname is - changed if it needs to be, or not changed if not - - - update the file NEWS based on the git history - - - verify that the version number of dbus-specification.xml is - changed if it needs to be; if changes have been made, update the - release date in that file - - - update the AUTHORS file with "make update-authors" if necessary - - - the version number should have major.minor.micro, even - if micro is 0, i.e. "1.0.0" and "1.2.0" not "1.0"/"1.2"; the micro - version should be even for releases, and odd for intermediate snapshots - - - "make distcheck" (DO NOT just "make dist" - pass the check!) - - - if make distcheck fails, fix it. - - - once distcheck succeeds, "git commit -a". This is the version - of the tree that corresponds exactly to the released tarball. - - - tag the tree with "git tag -s -m 'Released X.Y.Z' dbus-X.Y.Z" - where X.Y.Z is the version of the release. If you can't sign - then simply created an unsigned annotated tag: - "git tag -a -m 'Released X.Y.Z' dbus-X.Y.Z". - - - bump the version number up in configure.ac (so the micro version is odd), - and commit it. Make sure you do this *after* tagging the previous - release! The idea is that git has a newer version number - than anything released. Similarly, bump the version number of - dbus-specification.xml and set the release date to "(not finalized)". - - - merge the branch you've released to the chronologically-later - branch (usually "master"). You'll probably have to fix a merge - conflict in configure.ac (the version number). - - - push your changes and the tag to the central repository with - git push origin master dbus-X.Y dbus-X.Y.Z - - - scp your tarball to freedesktop.org server and copy it to - dbus.freedesktop.org:/srv/dbus.freedesktop.org/www/releases/dbus/dbus-X.Y.Z.tar.xz. - This should be possible if you're in group "dbus" - - - Update the online documentation with `make -C doc maintainer-upload-docs`. - - - update the wiki page http://www.freedesktop.org/Software/dbus by - adding the new release under the Download heading. Then, cut the - link and changelog for the previous that was there. - - - post to dbus@lists.freedesktop.org announcing the release. - -### Making a ".0" stable release - -We create a branch for each stable release. The branch name should be -dbus-X.Y which is a branch that has releases versioned X.Y.Z; -changes on a stable branch should be limited to significant bug fixes. - -Because we won't make minor changes like keeping up with the latest -deprecations on a stable branch, stable branches should turn off the -gcc warning for deprecated declarations (e.g. see commit 4ebb275ab7). - -Be extra-careful not to merge master (or any branch based on master) into a -stable branch. - -To branch: - - git branch dbus-X.Y - -and upload the branch tag to the server: - - git push origin dbus-X.Y - -To develop in this branch: - - git checkout dbus-X.Y +See maint/release-checklist.md. ### Code reviews diff --git a/maint/release-checklist.md b/maint/release-checklist.md new file mode 100644 index 00000000..5de87933 --- /dev/null +++ b/maint/release-checklist.md @@ -0,0 +1,82 @@ +# dbus release checklist + +To make a release of D-Bus, do the following: + + - check out a fresh copy from Git + + - verify that the libtool versioning/library soname is + changed if it needs to be, or not changed if not + + - update the file NEWS based on the git history + + - verify that the version number of dbus-specification.xml is + changed if it needs to be; if changes have been made, update the + release date in that file + + - update the AUTHORS file with "make update-authors" if necessary + + - the version number should have major.minor.micro, even + if micro is 0, i.e. "1.0.0" and "1.2.0" not "1.0"/"1.2"; the micro + version should be even for releases, and odd for intermediate snapshots + + - "make distcheck" (DO NOT just "make dist" - pass the check!) + + - if make distcheck fails, fix it. + + - once distcheck succeeds, "git commit -a". This is the version + of the tree that corresponds exactly to the released tarball. + + - tag the tree with "git tag -s -m 'Released X.Y.Z' dbus-X.Y.Z" + where X.Y.Z is the version of the release. If you can't sign + then simply created an unsigned annotated tag: + "git tag -a -m 'Released X.Y.Z' dbus-X.Y.Z". + + - bump the version number up in configure.ac (so the micro version is odd), + and commit it. Make sure you do this *after* tagging the previous + release! The idea is that git has a newer version number + than anything released. Similarly, bump the version number of + dbus-specification.xml and set the release date to "(not finalized)". + + - merge the branch you've released to the chronologically-later + branch (usually "master"). You'll probably have to fix a merge + conflict in configure.ac (the version number). + + - push your changes and the tag to the central repository with + git push origin master dbus-X.Y dbus-X.Y.Z + + - scp your tarball to freedesktop.org server and copy it to + dbus.freedesktop.org:/srv/dbus.freedesktop.org/www/releases/dbus/dbus-X.Y.Z.tar.xz. + This should be possible if you're in group "dbus" + + - Update the online documentation with `make -C doc maintainer-upload-docs`. + + - update the wiki page http://www.freedesktop.org/Software/dbus by + adding the new release under the Download heading. Then, cut the + link and changelog for the previous that was there. + + - post to dbus@lists.freedesktop.org announcing the release. + +## Making a ".0" stable release + +We create a branch for each stable release. The branch name should be +dbus-X.Y which is a branch that has releases versioned X.Y.Z; +changes on a stable branch should be limited to significant bug fixes. + +Because we won't make minor changes like keeping up with the latest +deprecations on a stable branch, stable branches should turn off the +gcc warning for deprecated declarations (e.g. see commit 4ebb275ab7). + +Be extra-careful not to merge master (or any branch based on master) into a +stable branch. + +To branch: + + git branch dbus-X.Y + +and upload the branch tag to the server: + + git push origin dbus-X.Y + +To develop in this branch: + + git checkout dbus-X.Y From 6a5e212b39ccdb36bcdba9fe6e2cf67647447722 Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Tue, 9 Aug 2022 10:17:57 +0000 Subject: [PATCH 24/29] dbus-sysdeps-util-unix.c: Avoid including sys/syslimits.h This header is GCC specific header that on my system just contains `#include_next `. FreeBSD also provides this header but it contains a `#warning` that it should not be used. Replace the one use with `#include ` and drop the configure checks. (cherry picked from commit a214ed824d257b5ab3ea81c8286395e65df81423) Backported-from: dbus!280 --- cmake/ConfigureChecks.cmake | 1 - cmake/config.h.cmake | 3 --- configure.ac | 1 - dbus/dbus-sysdeps-util-unix.c | 5 +---- 4 files changed, 1 insertion(+), 9 deletions(-) diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index baa8ac21..fee46e36 100644 --- a/cmake/ConfigureChecks.cmake +++ b/cmake/ConfigureChecks.cmake @@ -34,7 +34,6 @@ check_include_file(sys/stat.h HAVE_SYS_STAT_H) check_include_file(sys/types.h HAVE_SYS_TYPES_H) check_include_file(sys/uio.h HAVE_SYS_UIO_H) check_include_file(sys/prctl.h HAVE_SYS_PRCTL_H) -check_include_file(sys/syslimits.h HAVE_SYS_SYSLIMITS_H) # dbus-sysdeps-unix.c check_include_file(sys/time.h HAVE_SYS_TIME_H)# dbus-sysdeps-win.c check_include_file(sys/wait.h HAVE_SYS_WAIT_H)# dbus-sysdeps-win.c check_include_file(time.h HAVE_TIME_H) # dbus-sysdeps-win.c diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index ed8ef66c..a69f8510 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -151,9 +151,6 @@ #cmakedefine HAVE_SYS_RESOURCE_H 1 #cmakedefine HAVE_SYS_STAT_H 1 -/* Define to 1 if you have sys/syslimits.h */ -#cmakedefine HAVE_SYS_SYSLIMITS_H 1 - /* Define to 1 if you have sys/time.h */ #cmakedefine HAVE_SYS_TIME_H 1 diff --git a/configure.ac b/configure.ac index 61f22dc2..d1055514 100644 --- a/configure.ac +++ b/configure.ac @@ -424,7 +424,6 @@ stdint.h sys/prctl.h sys/random.h sys/resource.h -sys/syslimits.h sys/time.h unistd.h ws2tcpip.h diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index ca130cff..9fe7d55f 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #ifdef HAVE_SYS_RESOURCE_H #include @@ -56,10 +57,6 @@ #include #endif -#ifdef HAVE_SYS_SYSLIMITS_H -#include -#endif - #ifdef HAVE_SYSTEMD #include #endif From 890f0e0fc68fb40a6e461b0940aa9412f1758705 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Thu, 31 Mar 2022 08:57:08 +0200 Subject: [PATCH 25/29] Fix building on Mac OSX when using launchd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Provided by Dawid Wróbel at https://invent.kde.org/packaging/craft-blueprints-kde\ /-/blob/master/libs/dbus/0002-fix-macos-build.diff (cherry picked from commit 30426b26e6aacd6587e97d444ac577db6f0e7e23) Backported-from: dbus!287 --- dbus/dbus-server-launchd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/dbus/dbus-server-launchd.c b/dbus/dbus-server-launchd.c index 21292973..5c2b1d65 100644 --- a/dbus/dbus-server-launchd.c +++ b/dbus/dbus-server-launchd.c @@ -39,6 +39,7 @@ #ifdef DBUS_ENABLE_LAUNCHD #include #include +#include #include "dbus-misc.h" #include "dbus-server-socket.h" From e1d2cd286b31d206fe3ac434fbf7c84f5138de94 Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Sun, 15 May 2022 11:34:48 +0100 Subject: [PATCH 26/29] dir-watch-kqueue: Silence -Wshadow warning This should be the last warning that is preventing us from using -Werror for FreeBSD builds. (cherry picked from commit 2480181af4ef0cae65aab303e103b58d8f6f2066) Backported-from: dbus!307 --- bus/dir-watch-kqueue.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bus/dir-watch-kqueue.c b/bus/dir-watch-kqueue.c index 15519fcb..a4ed7ca5 100644 --- a/bus/dir-watch-kqueue.c +++ b/bus/dir-watch-kqueue.c @@ -51,7 +51,7 @@ static DBusWatch *watch = NULL; static DBusLoop *loop = NULL; static dbus_bool_t -_handle_kqueue_watch (DBusWatch *watch, unsigned int flags, void *data) +_handle_kqueue_watch (DBusWatch *_watch, unsigned int flags, void *data) { struct kevent ev; struct timespec nullts = { 0, 0 }; @@ -73,6 +73,7 @@ _handle_kqueue_watch (DBusWatch *watch, unsigned int flags, void *data) else if (res < 0 && errno == EBADF) { kq = -1; + _dbus_assert (watch == _watch); if (watch != NULL) { _dbus_loop_remove_watch (loop, watch); From a817ff39d256133b12a9ef0bad6f736b2124148a Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Wed, 25 May 2022 22:00:08 +0000 Subject: [PATCH 27/29] cmake: Check for setresuid and getresuid This was not being checked, so the codepaths using the define were never included. (cherry picked from commit dafb5ddc09767e22d1a8848e05b756b03226dd3f) --- cmake/ConfigureChecks.cmake | 2 ++ cmake/config.h.cmake | 2 ++ 2 files changed, 4 insertions(+) diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index fee46e36..e3a91711 100644 --- a/cmake/ConfigureChecks.cmake +++ b/cmake/ConfigureChecks.cmake @@ -75,6 +75,8 @@ check_symbol_exists(vsnprintf "stdio.h" HAVE_VSNPRINTF) check_symbol_exists(MSG_NOSIGNAL "sys/socket.h" HAVE_DECL_MSG_NOSIGNAL) check_symbol_exists(environ "unistd.h" HAVE_DECL_ENVIRON) check_symbol_exists(LOG_PERROR "syslog.h" HAVE_DECL_LOG_PERROR) +check_symbol_exists(setresuid "unistd.h" HAVE_SETRESUID) +check_symbol_exists(getresuid "unistd.h" HAVE_GETRESUID) check_struct_member(cmsgcred cmcred_pid "sys/types.h;sys/socket.h" HAVE_CMSGCRED) # dbus-sysdeps.c diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index a69f8510..fa42023f 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -247,6 +247,8 @@ #cmakedefine HAVE_VASPRINTF 1 #cmakedefine HAVE_VSNPRINTF 1 +#cmakedefine HAVE_SETRESUID 1 +#cmakedefine HAVE_GETRESUID 1 /* whether -export-dynamic was passed to libtool */ #cmakedefine DBUS_BUILT_R_DYNAMIC 1 From a41ee157dde806e3cb018f4d7638e81354848f4c Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Sun, 29 May 2022 12:58:49 +0000 Subject: [PATCH 28/29] cmake: Always try to find pkg-config Commit 97bdefd4e2598e6ea72337acb4230928594bda81 move the include(FindPkgConfig) call into a Linux-specific codepath, so pkg-config was not being detected on FreeBSD. This mean that the check for PKG_CONFIG_FOUND to determine whether to install .pc files later on would always fail and .pc files were not installed on FreeBSD. (cherry picked from commit 82f5c966442a455edf0bae4fbc17e35abdf7db5e) Backported-from: dbus!280 --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 98904504..fc405d2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,9 +144,13 @@ option(DBUS_DISABLE_ASSERT "Disable assertion checking" OFF) option(DBUS_ENABLE_STATS "enable bus daemon usage statistics" OFF) option(ENABLE_TRADITIONAL_ACTIVATION "Enable traditional activation (without using systemd)" ON) +find_package(PkgConfig) + if(DBUS_LINUX) add_auto_option(ENABLE_SYSTEMD "build with systemd at_console support" AUTO) - include(FindPkgConfig) + if (NOT PKG_CONFIG_FOUND) + message(SEND_ERROR "pkg-config not found, this is required on Linux systems") + endif() pkg_check_modules(SYSTEMD libsystemd>=209) if(NOT SYSTEMD_FOUND) pkg_check_modules(SYSTEMD libsystemd-login>=32 libsystemd-daemon>=32 libsystemd-journal>=32) From ccb5247454e18724f37a94e543e6465ada6e3cc0 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 12 Sep 2022 21:45:38 +0100 Subject: [PATCH 29/29] Update NEWS for 1.14.x branch Signed-off-by: Simon McVittie --- NEWS | 53 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index f6f37316..bc9571ff 100644 --- a/NEWS +++ b/NEWS @@ -3,10 +3,55 @@ dbus 1.14.2 (UNRELEASED) Fixes: -• When building with Autotools, don't treat --with-x or --with-x=yes - as a request to disable X11, fixing a regression in 1.13.20. - Instead, require X11 libraries and fail if they cannot be detected. - (dbus!263, Lars Wendler) +• Fix build failure on FreeBSD (dbus!277, Alex Richardson) + +• Fix build failure on macOS with launchd enabled + (dbus!287, Dawid Wróbel) + +• Preserve errno on failure to open /proc/self/oom_score_adj + (dbus!285, Gentoo#834725; Mike Gilbert) + +• On Linux, don't log warnings if oom_score_adj is read-only but does not + need to be changed (dbus!291, Simon McVittie) + +• Slightly improve error-handling for inotify + (dbus!235, Simon McVittie) + +• Don't crash if dbus-daemon is asked to watch more than 128 directories + for changes (dbus!302, Jan Tojnar) + +• Autotools build system fixes: + · Don't treat --with-x or --with-x=yes as a request to disable X11, + fixing a regression in 1.13.20. Instead, require X11 libraries and + fail if they cannot be detected. (dbus!263, Lars Wendler) + · When a CMake project uses an Autotools-built libdbus in a + non-standard prefix, find dbus-arch-deps.h successfully + (dbus#314, Simon McVittie) + · Don't include generated XML catalog in source releases + (dbus!317, Jan Tojnar) + · Improve robustness of detecting gcc __sync atomic builtins + (dbus!320, Alex Richardson) + +• CMake build system fixes: + · Detect endianness correctly, fixing interoperability with other D-Bus + implementations on big-endian systems (dbus#375, Ralf Habacker) + · When building for Unix, install session and system bus setup + in the intended locations + (dbus!267, dbus!297; Ralf Habacker, Alex Richardson) + · Detect setresuid() and getresuid() (dbus!319, Alex Richardson) + · Detect backtrace() on FreeBSD (dbus!281, Alex Richardson) + · Don't include headers from parent directory (dbus!282, Alex Richardson) + · Distinguish between host and target TMPDIR when cross-compiling + (dbus!279, Alex Richardson) + · Fix detection of atomic operations (dbus!306, Alex Richardson) + +Tests and CI enhancements: + +• On Unix, skip tests that switch uid if run in a container that is + unable to do so, instead of failing (dbus#407, Simon McVittie) + +• Use the latest MSYS2 packages for CI + (Ralf Habacker, Simon McVittie) dbus 1.14.0 (2022-02-28) ========================