Commit graph

106 commits

Author SHA1 Message Date
Marc-André Lureau
9016b48cf9 cmake: drop DBUS_VERBOSE_C_S
Apparently, not used anywhere.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-13 20:36:13 +01:00
Marc-André Lureau
a5c8dda5cf cmake: drop unused HAVE_VASPRINTF/HAVE_VSNPRINTF checks
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-13 20:36:13 +01:00
Marc-André Lureau
95df73b463 cmake/autotools: remove HAVE_DIRFD/HAVE_DDFD
dirfd() is assumed to be present on Linux, dd_fd is never used.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-13 20:36:13 +01:00
Marc-André Lureau
f0a4d92490 cmake: drop needless headers checks
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-07-13 20:36:13 +01:00
Marc-André Lureau
e4d6b74b25 build-sys: drop DBUS_CMAKE
TEST_LISTEN is defined by the cmake/autotools (or meson) build systems.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-06-17 15:19:38 +04:00
Alex Richardson
dafb5ddc09 cmake: Check for setresuid and getresuid
This was not being checked, so the codepaths using the define were
never included.
2022-05-25 22:01:51 +00:00
Marc-André Lureau
5705d14cf0 cmake: drop -DDBUS_CONSOLE_AUTH_DIR=
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-05-19 22:19:25 +02:00
Alex Richardson
b932c343c4 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.
2022-05-16 18:39:26 +00:00
Simon McVittie
ee694ade61 sysdeps: Use close_range() if available
The version with no flags set, which is a slight generalization of
closefrom(), is available on recent Linux and FreeBSD.

The version with CLOSE_RANGE_CLOEXEC is Linux-specific.

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
Ralf Habacker
d74fee2727 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 <ralf.habacker@freenet.de>
2022-03-02 14:35:54 +01:00
Simon McVittie
daf362ee61 build: Opt out from using mingw-w64's replacement printf(), etc.
The Windows code in dbus is careful to use Windows-specific equivalents
of the Standard C features that are not implemented by msvcrt.dll, so
we don't need to substitute a Standard C printf implementation.

This avoids compiler warnings/errors when gcc expects us to be using
Microsoft printf syntax (`ms_printf` attribute), but newer versions of
mingw-w64 expect us to be using GNU or Standard C printf syntax
(`gnu_printf` attribute) as a result of `__USE_MINGW_ANSI_STDIO` being
enabled by default if not otherwise specified.

Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/380
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-02-27 17:05:56 +00:00
Simon McVittie
9d60676ae0 Disable the Containers interface
We've had a request for a 1.14.x stable-branch, but the Containers
interface is only partially implemented, not yet described in the
D-Bus Specification, and not ready to be part of our API guarantees.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-12-10 16:48:51 +00:00
Ralf Habacker
85e6d21a0f Add HAVE_DECL_xxx checks to cmake build system
The first two definitions are required to fix cmake build error when
compiling with -Werror=undef on Windows.

The last one completes having HAVE_DECL_xxx definitions.
2021-11-18 12:52:22 +00:00
Ralf Habacker
6b41f053c5 Move _GNU_SOURCE to config.h.cmake 2021-11-18 12:52:22 +00:00
Ralf Habacker
541dbab907 Move DBUS_BUILT_R_DYNAMIC to config.h.cmake 2021-11-18 12:52:22 +00:00
Ralf Habacker
0590b44a8f Add configure checks for vsnprintf and vasprintf to cmake build system 2021-11-18 12:52:22 +00:00
Ralf Habacker
5b1870a5bd cmake: make support for traditional activation optional
Traditional activation is enabled/disabled with the cmake configure
parameter -DENABLE_TRADITIONAL_ACTIVATION, which is enabled by default.

This was added to the Autotools build system as part of dbus/dbus!107
but until now was not possible to disable when building with CMake.
2020-09-23 17:21:40 +02:00
Ralf Habacker
97bdefd4e2 cmake: Add support for systemd integration on Linux operating systems
Previously, only the Autotools build system could do this. This commit
includes most of the same features as in the Autotools build, although
not the user-session semantics, which will be added separately.

Systemd support is controlled by the cmake variable ENABLE_SYSTEMD, which can
have the values OFF, ON and AUTO, the latter enabling support by default if
the required libraries are available.

With WITH_SYSTEMD_SYSTEMUNITDIR a custom installation location can be specified.
If it is not specified, the related install path is determined from the installed
systemd package, if present.
2020-06-10 18:13:47 +00:00
Ralf Habacker
08eb885be6 cmake: build and install dbus-cleanup-sockets on non Windows platforms 2020-04-29 17:35:08 +00:00
Simon McVittie
1530582863 Merge branch 'fix-poll-header' into 'master'
sysdeps: use POSIX poll.h instead of sys/poll.h

See merge request dbus/dbus!148
2020-04-01 14:17:52 +00:00
Natanael Copa
3509748dce sysdeps: use POSIX poll.h instead of sys/poll.h
POSIX.1-2001 and POSIX.1-2008 specifies include <poll.h> so use that
rather than the non-standard/legacy include <sys/poll.h>.

This fixes the following warnings when building with musl libc:

    1 | #warning redirecting incorrect #include <sys/poll.h> to <poll.h>
      |  ^~~~~~~

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
2020-03-26 18:17:22 +01:00
Natanael Copa
6d92e8e983 _dbus_generate_random_bytes: use getrandom(2)
Use getrandom(2) and fall back to /dev/urandom if it is missing or if it
fails some any reason.

This solves problem where dbus-uuidgen is called from a chroot which
lacks /dev/urandom.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
2020-03-26 16:56:59 +01:00
Simon McVittie
3197cbe369 Merge branch 'non-posix-getwpnam-r' into 'master'
Remove support for non-POSIX getpwnam_r()

See merge request dbus/dbus!11
2020-03-11 14:15:29 +00:00
Ralf Habacker
ffcaede257 Drop cmake variable DBUS_WIN_FIXME 2018-12-05 15:58:48 +01:00
Simon McVittie
a7bf808cca cmake: Opt-in to modern APIs and thread-safety for Solaris
In the Autotools build system, the AC_USE_SYSTEM_EXTENSIONS macro
defines __EXTENSIONS__ and _POSIX_PTHREAD_SEMANTICS, and we set the
others explicitly when compiling for a Solaris host.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-19 11:27:38 +00:00
Simon McVittie
e57120cb65 build: Drop support for non-POSIX getpwnam_r(), getgrnam_r()
Solaris 2.3 and 2.4 took their getpwnam_r() signature from draft 6
of the POSIX threads standard. Since Solaris 2.5 (1995), defining
_POSIX_PTHREAD_SEMANTICS opts-in to the non-draft version of
getpwnam_r(), and since Solaris 11.4 (2018), the non-draft version is
the default.

We already use AC_USE_SYSTEM_EXTENSIONS, which defines
_POSIX_PTHREAD_SEMANTICS, among other useful macros.

Thanks to Alan Coopersmith for assistance with Solaris history.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-19 11:27:38 +00:00
Simon McVittie
f33038bc1b build: Require va_copy() or __va_copy() on non-MSVC compilers
va_copy() is a C99 feature, and should be widely supported by now.
gcc in strict C89 mode implements an equivalent __va_copy() instead.

MSVC 2013 implements va_copy(), but at the moment we still aim to support
MSVC 2010 and 2012, which don't have it. However, we know that in
Windows ABIs, va_list is a pointer, so we can use
_DBUS_VA_COPY_ASSIGN. We do not support MSVC for Autotools builds, only
CMake, due to its non-Unixish command-line interface.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-19 11:27:25 +00:00
Simon McVittie
f93b63587f internals: Assume compiler supports a subset of ISO varargs syntax
We have considerable anecdotal evidence that every relevant compiler
supports at least the small part of ISO varargs syntax that we need
here, because tools/tool-common.h has contained

    #define VERBOSE(...) do {} while (0)

since dbus 1.9.2 (2014) and nobody has complained yet. With that in
mind, let's simplify.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-15 18:55:57 +00:00
Ralf Habacker
a0503f0c99 Refactor cmake checks for DBUS_VA_COPY and DBUS_VA_COPY_ARRAY
For test case execution, CheckCSourceCompiles is now used instead
of try_compile and the determination of DBUS_VA_AS_ARRAY is
performed with a separate test instead of evaluating the result
of HAVE_VA_COPY and HAVE___VA_COPY.

The tests are performed for all supported compilers. Since older
MSVC compilers (< 2013) do not support va_copy(), the macro
_DBUS_VA_ASSIGN(a1,a2) with the implementation { a1 = a2; } is used
as a fallback.
2018-11-15 15:18:22 +00:00
Ralf Habacker
b0c0652005 Add Windows implementation of dbus-run-session tool
Bug: https://gitlab.freedesktop.org/dbus/dbus/issues/135
Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
Reviewed-by: Simon McVittie <smcv@collabora.com>
2018-10-25 18:24:04 +00:00
Ralf Habacker
f7e9b8a737 Revert "Refactor cmake checks for DBUS_VA_COPY and DBUS_VA_COPY_ARRAY"
This reverts commit bd6ece893a,
which was added without a final review.
2018-10-25 20:13:17 +02:00
Ralf Habacker
fd00c5fdef Add cmake support for HAVE_GNUC_VARARGS and HAVE_ISO_VARARGS
Reviewed-by: Simon McVittie <smcv@collabora.com>
Bug: https://gitlab.freedesktop.org/dbus/dbus/merge_requests/18
2018-10-24 10:03:30 +02:00
Ralf Habacker
72b0aebb6e Add cmake check for HAVE_DDFD
Reviewed-by: Simon McVittie <smcv@collabora.com>
Bug: https://gitlab.freedesktop.org/dbus/dbus/merge_requests/18
2018-10-24 10:03:30 +02:00
Ralf Habacker
ba8a5e509c Add cmake check for HAVE_DIRFD
Reviewed-by: Simon McVittie <smcv@collabora.com>
Bug: https://gitlab.freedesktop.org/dbus/dbus/merge_requests/18
2018-10-24 10:03:30 +02:00
Ralf Habacker
6c95c7e395 Add cmake check for DBUS_USE_SYNC
Reviewed-by: Simon McVittie <smcv@collabora.com>
Bug: https://gitlab.freedesktop.org/dbus/dbus/merge_requests/18
2018-10-24 10:03:30 +02:00
Ralf Habacker
bd6ece893a Refactor cmake checks for DBUS_VA_COPY and DBUS_VA_COPY_ARRAY
For test case execution, CheckCSourceCompiles is now used instead
of try_compile and the determination of DBUS_VA_AS_ARRAY is
performed with a separate test instead of evaluating the result
of HAVE_VA_COPY and HAVE___VA_COPY.

The tests are performed for all supported compilers. Since older
MSVC compilers (< 2013) do not support va_copy(), the macro
_DBUS_VA_ASSIGN(a1,a2) with the implementation { a1 = a2; } is used
as a fallback.

Reviewed-by: Simon McVittie <smcv@collabora.com>
Bug: https://gitlab.freedesktop.org/dbus/dbus/merge_requests/18
2018-10-24 10:03:30 +02:00
Ralf Habacker
2934dedd1c Add cmake support for DBUS_HAVE_LINUX_EPOLL
Reviewed-by: Simon McVittie <smcv@collabora.com>
Bug: https://gitlab.freedesktop.org/dbus/dbus/merge_requests/18
2018-10-24 10:03:29 +02:00
Ralf Habacker
ae728666d5 Move DBUS_USE_OUTPUT_DEBUG_STRING to config.h.cmake
Bug: https://gitlab.freedesktop.org/dbus/dbus/issues/117
Reviewed-by: Simon McVittie <smcv@collabora.com>
2018-10-20 13:53:45 +02:00
Ralf Habacker
c0bfd55938 Move DBUS_ENABLE_EMBEDDED_TESTS and BUS_ENABLE_MODULAR_TESTS to config.h.cmake
Bug: https://gitlab.freedesktop.org/dbus/dbus/issues/117
Reviewed-by: Simon McVittie <smcv@collabora.com>
2018-10-20 13:53:01 +02:00
Ralf Habacker
6978c1192c Keep macro values in config.h.cmake synchronized with Autotools
Autotools sets the value of HAVE_xxx macros in config.h to 1 if
the corresponding value exists. This has not been used consistently
in config.h.cmake so far.

Bug: https://gitlab.freedesktop.org/dbus/dbus/issues/117
Reviewed-by: Simon McVittie <smcv@collabora.com>
2018-10-20 13:52:46 +02:00
Simon McVittie
aced59e202 cmake: Define HAVE_PRCTL, HAVE_RAISE according to existing checks
Otherwise test-segfault will not be able to disable core dumps, making
it extremely slow and noisy to run the tests under cmake.
I added the missing checks in commit be55374f, but didn't add the
corresponding symbols to config.h.cmake.

Fixes: be55374f "cmake: check for the necessary symbols for test-segfault.c"
Closes: https://gitlab.freedesktop.org/dbus/dbus/issues/227
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-10-15 13:51:38 +01:00
Simon McVittie
83549e28ec Windows: Target Windows Vista or higher
This will give us the RFC-2553 inet_ntop() interface.
Windows Vista extended security support ended in 2017, but we don't
actually need anything from versions newer than Vista yet.

Loosely based on part of a patch by Ralf Habacker.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-09 12:26:08 +00:00
Simon McVittie
49ca421997 Add a unit test for the dbus-daemon resetting its fd limit
Reviewed-by: David King <dking@redhat.com>
[smcv: Fix typo in cmake macro name]
Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=105165
2018-02-20 18:37:30 +00:00
Simon McVittie
a146724f2f cmake: Check for getrlimit, setrlimit
This gives us feature parity with the Autotools build system for this
particular area, and in particular means a system dbus-daemon built
with cmake can expand its fd limit.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=105165
2018-02-20 18:34:17 +00:00
Simon McVittie
88b3c31928 driver: Add a stub implementation of the Containers1 interface
For now, this is considered to be a privileged operation, because the
resource-limiting isn't wired up yet. It only contains the bare minimum
of API.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101354
2017-12-11 15:50:02 +00:00
Simon McVittie
6a6521746b unix: Condition Linux-specific abstract sockets on __linux__
This is nicer for cross-compiling, because AC_RUN_IFELSE can't work
there. In practice abstract sockets are supported on Linux since
2.2 (so, all relevant versions), and on no other platform; so it
seems futile to keep this complexity.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=34905
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
2017-09-29 14:04:57 +01:00
Simon McVittie
633a208ce7 build: Remove unused substitution DBUS_PATH_OR_ABSTRACT
This was presumably once used in constructs like
"unix:" DBUS_PATH_OR_ABSTRACT "=/var/run/dbus/foo", but git grep says
there are no remaining uses, so it can go.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=34905
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
2017-09-29 14:04:38 +01:00
Simon McVittie
1477ca5035 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 and mount a tmpfs in that
location. All other factors being equal, it is preferable to use /run
where available because it is guaranteed to be local, whereas traversing
/var might involve automounting a networked filesystem (even though
/var/run itself is very likely to be a tmpfs).

/run or /var/run is currently only used in a few places in dbus, but
I plan to make more use of it during the development of
<https://bugs.freedesktop.org/show_bug.cgi?id=100344>.

The pid file is not part of the API between dbus and other software
(other than distribution init scripts for dbus itself), so we do not
need to keep it strictly compatible; so it is OK to move it.

We do not yet 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.
<https://bugs.freedesktop.org/show_bug.cgi?id=101628> tracks the
possibility of changing that.

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 pam_console and pam_foreground that used /var/run/console.
<https://bugs.freedesktop.org/show_bug.cgi?id=101629> tracks the possible
future removal of that code path.

In the CMake build system, the equivalent of ${runstatedir} remains
hard-coded to the equivalent of ${localstatedir}/run for simplicity. For
the sort of system-wide installations that would consider redefining
${runstatedir} to /run, the Autotools build system is strongly
recommended: in particular this is what Linux distributions are expected
to use.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101569
2017-06-30 10:51:14 +01:00
Simon McVittie
36fcd43005 Pass in DBUS_TEST_EXEC via environment, not hard-coded into binaries
This avoids "capturing" the build directory in the built binaries
when built with embedded tests, which is good for reproducible builds.
See <https://reproducible-builds.org/> for more information.

Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=100692
2017-04-18 17:20:30 +01:00