Commit graph

5658 commits

Author SHA1 Message Date
Simon McVittie
85d07a97e6 bus_container_instance_new: Don't leak empty DBusString object
We already stole its data, but that allocated a new buffer, which we
still need to free.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-19 11:35:22 +00:00
Simon McVittie
5accf42aab bus_driver_handle_become_monitor: Don't leak zero-length array of rules
Only privileged users can trigger this leak, so it is not a denial of
service attack.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-19 11:35:22 +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
dab4a12e0e CI: Do one build with mingw + CMake by default
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-19 11:27:25 +00:00
Simon McVittie
38e4d72fdc Only use _DBUS_VA_COPY_ASSIGN to implement va_copy() on MSVC
We don't know that _DBUS_VA_COPY_ASSIGN is always the right choice.
However, we do know that it's OK on MSVC versions too old to support
va_copy().

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-19 11:27:25 +00:00
Simon McVittie
6278951f6d Don't check how to copy a va_list if we already have va_copy()
If we already have ISO C va_copy() or its non-standard counterpart
__va_copy(), then there's no need to do an AC_RUN_IFELSE or its
CMake equivalent to detect whether "args2 = args1" or "*args2 = *args1"
works. AC_RUN_IFELSE is problematic during cross-compilation, where the
program cannot be run (you have to know in advance that the test program
will be run and what its result will be), so we want to avoid it whenever
possible.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-19 11:27:25 +00:00
Simon McVittie
c018e0b1b2 Merge branch 'cmake-generate-dbus.devhelp2' into 'master'
Add generating dbus.devhelp2 to cmake build system

See merge request dbus/dbus!39
2018-11-19 11:06:36 +00:00
Simon McVittie
e8a2e1dcea build: Simplify checks for straightforward header files
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-19 11:05:17 +00:00
Simon McVittie
1b0e79cb43 build: Simplify checks for functions with no special dependencies
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-19 11:05:17 +00:00
Ralf Habacker
ca20822d19 Add generating dbus.devhelp2 to cmake build system 2018-11-16 23:01:56 +01:00
Simon McVittie
2908a4da6a embedded tests: Make it easier to run a single test-case
When running tests under "make check" or similar to take advantage
of facilities like AM_TESTS_ENVIRONMENT and AX_VALGRIND_CHECK, it's
more straightforward to set an environment variable than to pass a
command-line option.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://gitlab.freedesktop.org/dbus/dbus/issues/218
2018-11-16 15:16:21 +00:00
Simon McVittie
dd4fb66f67 Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-16 15:04:52 +00:00
Simon McVittie
dde5844c59 Merge branch 'iso-varargs' into 'master'
internals: Assume compiler supports a subset of ISO varargs syntax

See merge request dbus/dbus!36

Reviewed-by: rhabacker
Reviewed-by: pwithnall
2018-11-16 11:41:32 +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
Simon McVittie
a6674bff17 Merge branch 'dbus-va-copy-fixup' into 'master'
Refactor cmake checks for DBUS_VA_COPY and DBUS_VA_COPY_ARRAY

See merge request dbus/dbus!29
2018-11-15 15:40:32 +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
Simon McVittie
0732d3ee1b Merge branch 'avc_open' into 'master'
Stop using avc_init() which is deprecated and use avc_open() instead. Also, use SELINUX_CB_POLICYLOAD instead of AVC_CALLBACK_RESET callback.

See merge request dbus/dbus!31

Reviewed-by: smcv
2018-11-15 15:17:47 +00:00
Laurent Bigonville
a442601cb2 Use SELINUX_CB_POLICYLOAD instead of AVC_CALLBACK_RESET callback
Use SELINUX_CB_POLICYLOAD instead of AVC_CALLBACK_RESET callback as this
only seems necessary on policy reload and not if the enforcing mode is
changing.

See discussion at https://marc.info/?l=selinux&m=152173501930182&w=2

https://gitlab.freedesktop.org/dbus/dbus/issues/134
2018-11-15 15:59:49 +01:00
Laurent Bigonville
67f7bdf8c2 Stop using avc_init() which is deprecated
Stop using avc_init() and use avc_open() instead. With this commit
dbus-daemon will stop using a thread to monitor the avc netlink and will
poll it instead.

https://gitlab.freedesktop.org/dbus/dbus/issues/134
2018-11-15 15:59:49 +01:00
Simon McVittie
3525335f76 Merge branch 'pc-file-trailing-slash-issue' into 'master'
Avoid double slashes in paths created by pkg-config

See merge request dbus/dbus!30
2018-11-15 13:39:31 +00:00
Ralf Habacker
696a6b629d Avoid double slashes in paths created by pkg-config
If in a .pc variable a path is created from another
variable, such as exec_prefix=${prefix}/lib, prefix
must not contain a trailing slash to avoid double
slashes in the generated path.
2018-11-15 13:12:48 +00:00
Simon McVittie
9983744326 Merge branch 'msvc-compile-fix' into 'master'
Msvc compile fix

See merge request dbus/dbus!33

Reviewed-by: smcv
Reviewed-by: pwithnall
2018-11-15 13:09:54 +00:00
Ralf Habacker
59332d06d7 Windows MSVC compile fix
Do not use unistd.h with MSVC because this header file does not
exist for this compiler.

Fixup of commit b0c0652005
2018-11-08 14:20:55 +01:00
Simon McVittie
59013d4c43 Merge branch '222-comm-whitespace' into 'master'
Fix whitespace and error behaviour for _dbus_command_from_pid()

Closes #222

See merge request dbus/dbus!28

Reviewed-by: pwithnall
2018-11-01 12:07:22 +00:00
Simon McVittie
e8cdb9171e tests: Assert that _dbus_command_for_pid() has correct error behaviour
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-10-31 16:56:36 +00:00
Simon McVittie
47fc3ed2a9 sysdeps: Return an error for _dbus_command_for_pid on Windows
If a function returns boolean for success/error, and returns a
DBusError, then it should set the DBusError if and only if it
returns FALSE.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-10-31 16:56:36 +00:00
Simon McVittie
d70040d8d2 tests: Assert that dbus#222 has been fixed 2018-10-31 16:56:36 +00:00
Simon McVittie
f7bf69443d sysdeps: Remove trailing NUL from command lines from /proc
Resolves: https://gitlab.freedesktop.org/dbus/dbus/issues/222
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-10-31 16:56:36 +00:00
Simon McVittie
93c1d08300 tests: Add a unit test for _dbus_command_for_pid()
In particular this demonstrates that dbus#222 has been solved.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-10-31 16:56:36 +00:00
Simon McVittie
6eb1c2cd53 test_get_helper_executable: Add function
This is basically the same as get_test_exec() in dbus-spawn-test.c,
but GLib-flavoured.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-10-31 16:56:36 +00:00
Simon McVittie
2a2c6e6790 test_incomplete: Add function
This is a wrapper for g_test_incomplete(), which works around bugs in
that function prior to GLib 2.57.3. I originally wrote it for librsvg.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-10-31 16:56:36 +00:00
Simon McVittie
d30188a135 tests: Build test-sleep-forever even if embedded tests are disabled
It will be used as a long-running subprocess to test
_dbus_command_for_pid().

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-10-31 16:56:36 +00:00
Simon McVittie
168bbe146c tests: Build installable helpers whenever any tests are enabled
We might need these to run tests at build-time, so we should build them
whenever either modular or embedded tests are enabled, even if
installed-tests aren't.

We haven't noticed this bug until now because $(installable_helpers)
only contained test-apparmor-activation, which isn't normally needed at
build-time because the AppArmor test can only work when run as root.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-10-31 16:56:36 +00:00
Ralf Habacker
06b8055690 Merge branch '135-dbus-run-session-windows' into 'master'
Add windows implementation of dbus-run-session helper tool for cmake

See merge request dbus/dbus!22
2018-10-25 19:50:06 +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
Simon McVittie
e87a3ba560 Merge branch 'cmake-ddlh' into 'master'
cmake: Install dbus-daemon-launch-helper even if tests are disabled

See merge request dbus/dbus!9
Reviewed-by: rhabacker
2018-10-25 16:56:04 +00:00
Simon McVittie
84aa8c9934 cmake: Install d-d-launch-helper to ${CMAKE_INSTALL_LIBEXECDIR}
Instead of hard-coding the lib subdirectory of the installation prefix,
use the ${CMAKE_INSTALL_LIBEXECDIR} provided by the GNUInstallDirs
module, which defaults to the libexec subdirectory of the installation
prefix. This is consistent with the Autotools build system, which
installs to ${exec_prefix}/libexec unless modified with --libexecdir.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-10-25 16:04:04 +00:00
Simon McVittie
ef1f53eed8 cmake: Use non-deprecated install mechanism for d-d-launch-helper
As suggested by Ralf Habacker on !9.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-10-25 16:04:04 +00:00
Simon McVittie
6ce7f5dd58 cmake: Install dbus-daemon-launch-helper even if tests are disabled
This is a long-standing bug, spotted while moving test code into
the test directory.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-10-25 16:04:04 +00:00
Simon McVittie
0d9e031361 Merge branch 'cleanup-cmake-source-dir-definitions' into 'master'
Cleanup of the cmake definitions of source directories

See merge request dbus/dbus!27

Reviewed-by: smcv
2018-10-25 13:51:38 +00:00
Ralf Habacker
f2f4f4795c Cleanup of the cmake definitions of source directories
Since the cmake build system is located below the cmake/
subdirectory, references to the source files used such as
../../bus or ${CMAKE_SOURCE_DIR}/../dbus etc. are required.
To standardize and simplify this, a cmake variable is now
defined in each of the listed directories, which contains
the corresponding path.
2018-10-25 13:23:20 +00:00
Ralf Habacker
f679669505 Merge branch '117-checks-from-configure-ac' into 'master'
Take cmake checks from configure.ac

See merge request dbus/dbus!18
2018-10-24 17:01:52 +00:00
Ralf Habacker
7bba42587b Remove todo(s) for cmake build system
Bug: https://gitlab.freedesktop.org/dbus/dbus/merge_requests/18
2018-10-24 10:03:30 +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