Commit graph

6257 commits

Author SHA1 Message Date
Simon McVittie
faa3b2ef4a sysdeps: Only use closefrom() if known to be async-signal-safe
closefrom() is known to be async-signal-safe on FreeBSD, NetBSD and
OpenBSD, and safe to call after fork() on Solaris, but not necessarily
on DragonflyBSD.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-04-21 11:02:14 +01:00
rim
54c62040b2 Use closefrom() to not loop over all possible file descriptors
Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/278
2022-04-21 11:02:14 +01:00
Simon McVittie
a6154cb8ef CI: Add a manual CI job for Ubuntu 22.04 'jammy'
This has a very recent version of glibc, and in particular is new enough
to have close_range().

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-04-21 11:02:13 +01:00
Simon McVittie
48f32958b7 Merge branch 'dont-crash-watch' into 'master'
bus/dir-watch: Do not crash with > 128 dirs

See merge request dbus/dbus!302
2022-04-20 11:29:31 +00:00
Jan Tojnar
b551b3e973 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
2022-04-20 11:24:40 +02:00
Simon McVittie
14b5119f9e Merge branch 'int64_modifier' into 'master'
build: Define DBUS_INT64_MODIFIER, analogous to G_GINT64_MODIFIER

See merge request dbus/dbus!289
2022-04-19 18:47:41 +00:00
Simon McVittie
6130ac4267 build: Define DBUS_INT64_MODIFIER, analogous to G_GINT64_MODIFIER
Using PRId64, etc. to print dbus_int64_t or dbus_uint64_t is not 100%
portable. On platforms where both long and long long are 64-bit (such as
Linux and macOS), we will prefer to define dbus_int64_t as long.
If the operating system has chosen to define int64_t as long long,
which is apparently the case on macOS, then the compiler can warn that
we are passing a long argument to PRId64, which is "lld" and therefore
expects a long long argument (even though that ends up with the same
bit-pattern being used).

We can't necessarily just use int64_t and uint64_t directly, even if all
our supported platforms have them available now, because swapping
dbus_int64_t between long and long long might change C++ name mangling,
causing ABI breaks in third-party libraries if they define C++ functions
that take a dbus_int64_t argument.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-04-19 18:27:47 +00:00
Simon McVittie
8972fcb029 Merge branch 'cmake-config-file-unix' into 'master'
cmake: Correct DBUS_{SYSTEM,SESSION}_CONFIG_FILE on UNIX systems

See merge request dbus/dbus!297
2022-04-19 12:06:58 +00:00
Alex Richardson
f4876e7cb5 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.
2022-04-19 11:52:22 +00:00
Simon McVittie
9506ff7219 Merge branch 'fix-no-x11-build' into 'master'
Fix no-X11 build after d847b5f6ae

Closes #392

See merge request dbus/dbus!298
2022-04-19 11:51:34 +00:00
Alex Richardson
6c1c7e539f Fix no-X11 build after d847b5f6ae
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
2022-04-16 16:04:57 +00:00
Ralf Habacker
e47891864b Merge branch 'ci-auto-detect-distro' into 'master'
Add automatic detection of distribution and suite to CI scripts

See merge request dbus/dbus!292
2022-04-06 12:49:44 +00:00
Ralf Habacker
a3b20acdd4 Add automatic detection of suite to CI scripts
The detection is based on the variable VERSION_CODENAME from
/etc/os-release, which is supported by systemd. For further details see
https://www.freedesktop.org/software/systemd/man/os-release.html.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-04-04 12:37:50 +02:00
Ralf Habacker
82f1aaeea0 Add automatic detection of distribution to CI scripts
The detection is based on the variable ID from /etc/os-release,
which is supported by systemd. For further details see
https://www.freedesktop.org/software/systemd/man/os-release.html.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-04-04 09:24:31 +02:00
Simon McVittie
7060b64287 Merge branch 'unix-ci-sooner' into 'master'
CI: Don't wait for Windows Docker image before doing Unix builds

See merge request dbus/dbus!288
2022-04-01 16:00:59 +00:00
Simon McVittie
73b87a92f8 CI: Don't wait for Windows Docker image before doing Unix builds
The default in Gitlab-CI is that each job waits for all jobs in
previous stages to complete, but we can override this default by
explicitly saying that there are no prerequisites.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-04-01 15:44:59 +00:00
Simon McVittie
f52b4b1d2d Merge branch 'fix-macosx-launchd-build' into 'master'
Fix building on Mac OSX when using launchd

See merge request dbus/dbus!287
2022-04-01 13:56:24 +00:00
Ralf Habacker
30426b26e6 Fix building on Mac OSX when using launchd
Provided by Dawid Wróbel at
https://invent.kde.org/packaging/craft-blueprints-kde\
/-/blob/master/libs/dbus/0002-fix-macos-build.diff
2022-03-31 08:58:46 +02:00
Ralf Habacker
dca1548d1d Merge branch 'wip/find-arch-include-dir' into 'master'
cmake: Look for dbus-arch-deps.h next to DBus1Config.cmake

Closes #314

See merge request dbus/dbus!191
2022-03-30 08:16:59 +00:00
Simon McVittie
104df89947 cmake: Look for dbus-arch-deps.h next to DBus1Config.cmake
<dbus/dbus-arch-deps.h> 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 <smcv@collabora.com>
2022-03-30 07:36:38 +00:00
Simon McVittie
6238a9818d Merge branch 'generalize-autolaunch' into 'master'
dbus-launch: Generalize support for discovering an existing bus

Closes #385

See merge request dbus/dbus!273
2022-03-29 19:12:02 +00:00
Simon McVittie
363919696a dbus-launch: If no X11, look for existing bus before failing
What we are aiming for here is that `dbus-launch --autolaunch` will
exit with an error if it would have been unable to advertise the bus
in a way that will be picked up by other instances of itself, so that
we don't get a proliferation of autolaunched dbus-launch instances,
each with its own dbus-daemon, and none of them talking to the others.

However, we don't need to do that *immediately*: we can try to look for
an existing instance first. If we find one, then we can assume that
it's suitable for use, even if X11 autolaunching was disabled at
compile-time or if connecting to the X server failed at runtime. We
only need to bail out if we get to the point where we are ready to start
forking child processes.

This lets systemd users run `dbus-launch --autolaunch` to find a
systemd-managed dbus-daemon, even if X11 autolaunching is disabled.
When combined with the previous commit, it also lets macOS users run
`dbus-launch --autolaunch` to find a launchd-managed dbus-daemon.

Resolves: dbus/dbus#385
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-03-29 14:38:43 +00:00
Simon McVittie
d847b5f6ae dbus-launch: Generalize support for discovering an existing bus
Previously we were looking for an existing bus via
_dbus_lookup_user_bus(), meaning a user bus $XDG_RUNTIME_DIR/bus
(in practice this is managed by systemd --user, although in principle
there's nothing to stop other session frameworks from providing the
same thing).

_dbus_lookup_session_address() looks for an externally-managed
dbus-daemon in a more general way: on macOS it uses launchd, and on other
Unix it's a thin wrapper around _dbus_lookup_user_bus(). Let's try that,
so that macOS users can get their existing dbus-daemon from launchd.

This partially resolves dbus/dbus#385, although initially only for macOS
users who have (unusually) enabled X11 autolaunching support.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-03-29 14:38:43 +00:00
Ralf Habacker
7cb63366aa Merge branch 'ci-opensuse-support' into 'master'
On CI add support for building package based on openSUSE distribution

Closes #383

See merge request dbus/dbus!192
2022-03-29 14:24:04 +00:00
Ralf Habacker
93073e9565 CI: Switch active cmake related jobs to opensuse as default
Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-03-29 12:47:59 +00:00
Ralf Habacker
acdf5a7a18 On CI add build support for openSUSE distributions
The mingw related jobs are running the whole test suite which
is an extension to the available jobs.

The environment variable ci_suite is not used on openSUSE
distributions, as it is determined from the installed image.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-03-29 12:47:59 +00:00
Ralf Habacker
dd8638e131 cmake: temporary disable fatal warnings related to new opensuse builds
This is necessary for these CI builds to be successful.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-03-29 12:47:59 +00:00
Ralf Habacker
8d86453b82 Merge branch 'compile-with-clang' into 'master'
cmake: Only add warning flags if the compiler supports them

Closes #387

See merge request dbus/dbus!276
2022-03-29 12:36:47 +00:00
Alex Richardson
d35554c111 cmake: Only add warning flags if the compiler supports them
I am compiling for FreeBSD where the compiler is Clang and doesn't accept
all the GCC warning flags. This breaks the -Werror build:
```
error: unknown warning option '-Wduplicated-branches' [-Werror,-Wunknown-warning-option]
error: unknown warning option '-Wduplicated-cond' [-Werror,-Wunknown-warning-option]
error: unknown warning option '-Wjump-misses-init' [-Werror,-Wunknown-warning-option]
error: unknown warning option '-Wlogical-op'; did you mean '-Wlong-long'? [-Werror,-Wunknown-warning-option]
error: unknown warning option '-Wrestrict' [-Werror,-Wunknown-warning-option]
error: unknown warning option '-Wunused-but-set-variable'; did you mean '-Wunused-const-variable'? [-Werror,-Wunknown-warning-option]
```

With this change we use check_{c,cxx}_compiler_flag to check if the flag
is supported before adding it. In the future this will allow adding
clang-specific warning flags to the list of warnings as well since they
will be ignored for GCC.
2022-03-29 12:21:46 +00:00
Simon McVittie
0a22950288 Merge branch 'bug834725' into 'master'
sysdeps-unix: check fd before calling _dbus_fd_set_close_on_exec()

See merge request dbus/dbus!285
2022-03-29 12:19:58 +00:00
Mike Gilbert
769a0462be 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 <floppym@gentoo.org>
2022-03-29 11:52:32 +00:00
Ralf Habacker
b56cad123c Merge branch 'cross-compile-session-socket' into 'master'
cmake: Fix DBUS_SESSION_SOCKET_DIR when cross-compiling

See merge request dbus/dbus!279
2022-03-29 11:49:56 +00:00
Alex Richardson
e827309976 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/<random characters>/T/ instead of the expected /tmp.
2022-03-29 11:40:15 +00:00
Ralf Habacker
302f85d45d Merge branch 'fix-fetching-mingw-packages' into 'master'
tools/ci-install.sh: on debian|ubuntu reduce the need for mingw package name changes

Closes #388

See merge request dbus/dbus!286
2022-03-29 11:39:45 +00:00
Ralf Habacker
c6b35bc0f4 .gitignore: Ignore downloaded and installed mingw packages used on debian|ubuntu
Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-03-29 10:30:51 +02:00
Ralf Habacker
c4d69fe95e tools/ci-install.sh: clean up the previously used installation prefix and the downloaded mingw packages
This is necessary to have a clean initial state when running the script
locally.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-03-29 10:29:18 +02:00
Ralf Habacker
99c1de5180 tools/ci-install.sh: Use partially qualified versions with mingw package names
Fixes dbus/dbus#388

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-03-29 10:29:18 +02:00
Ralf Habacker
a7fb199f22 tools/ci-install.sh: on debian|ubuntu reduce the need for mingw package name changes
Instead of having to specify an exact version that needs to be adjusted
with each repository update, it is now possible to specify package names
without version or partially qualified versions, which reduces the
frequency of necessary adjustments.

This is achieved by searching for the package names in a previously
downloaded list of available packages.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
2022-03-29 10:29:18 +02:00
Ralf Habacker
2fb2491ad0 Merge branch 'cmake-fix-export-dynamic' into 'master'
cmake: Only pass -Wl,--export-dynamic when linking

See merge request dbus/dbus!278
2022-03-24 22:13:55 +00:00
Alex Richardson
c7f6d07252 cmake: Use -Wl,-export_dynamic when building for macOS
The macOS linker does not accept --export-dynamic, so use this
alternate spelling.
2022-03-24 22:00:06 +00:00
Alex Richardson
1a8fd7a382 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.
2022-03-24 22:00:06 +00:00
Ralf Habacker
8757c7d8d8 Merge branch 'cmake-unnecessary-include-dir' into 'master'
cmake: Drop an unnecessary include directory

See merge request dbus/dbus!282
2022-03-24 14:36:15 +00:00
Alex Richardson
be5da7305e 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.
2022-03-24 14:26:42 +00:00
Ralf Habacker
453905de32 Merge branch 'detect-backtrace-freebsd' into 'master'
cmake: Detect backtrace() support on platforms such as FreeBSD

See merge request dbus/dbus!281
2022-03-24 13:56:13 +00:00
Alex Richardson
3f5bdf0c2d 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).
2022-03-24 13:41:19 +00:00
Ralf Habacker
1312fd5f81 Merge branch 'fix-freebsd-environ' into 'master'
Revert "Fix gcc compile error: redundant redeclaration of ‘environ’ [-Werror=redundant-decls]"

See merge request dbus/dbus!277
2022-03-24 13:40:44 +00:00
Alex Richardson
d4dbde9fc5 Revert "Fix gcc compile error: redundant redeclaration of ‘environ’ [-Werror=redundant-decls]"
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 e8b34b419e.
2022-03-19 14:50:31 +00:00
Ralf Habacker
25c0aff7e8 Merge branch 'issue-templates' into 'master'
Add bug and feature template for issue tracker

See merge request dbus/dbus!270
2022-03-18 07:47:10 +00:00
Ralf Habacker
46e8904e2b Add feature template 2022-03-18 08:36:35 +01:00
Ralf Habacker
ae0bc8462f Add bug template 2022-03-18 08:36:35 +01:00