Commit graph

5567 commits

Author SHA1 Message Date
Ralf Habacker
bac2fd3aa4 ci-build.sh: Show file size in list of files to be able to compare generated file size 2018-11-20 12:59:23 +01:00
Simon McVittie
e1ad4e202d Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-20 11:32:54 +00:00
Simon McVittie
867c9bbe2e Merge branch 'va-copy' into 'master'
Don't check how to copy a va_list if we have va_copy; only use _DBUS_VA_COPY_ASSIGN on MSVC

See merge request dbus/dbus!35

Reviewed-by: rhabacker
2018-11-20 11:23:36 +00:00
Simon McVittie
e0f240e9e3 Merge branch 'containers-test-race' into 'master'
containers test: Wait a few more seconds for the socket to be deleted

See merge request dbus/dbus!47

Reviewed-by: pwithnall
2018-11-20 11:22:48 +00:00
Simon McVittie
2b229d0471 Merge branch 'keyring-undefined-shift' into 'master'
keyring: Avoid undefined out-of-range shift

See merge request dbus/dbus!45
2018-11-20 11:22:20 +00:00
Simon McVittie
269e0548e2 Merge branch 'desktop-file-leak' into 'master'
bus: Fix memory leaks when parsing .service files

See merge request dbus/dbus!42

Reviewed-by: pwithnall
2018-11-20 11:21:32 +00:00
Simon McVittie
04d9ee3437 Merge branch 'misc-leaks' into 'master'
Fix small memory leaks

See merge request dbus/dbus!41
2018-11-20 11:21:05 +00:00
Simon McVittie
c2ee90375a containers test: Wait a few more seconds for the socket to be deleted
Previously, we were waiting a few seconds for the dbus-daemon to stop
listening, then trying to connect again and asserting that it failed,
then immediately asserting that the socket had actually been deleted.
However, there is a race here: the dbus-daemon stops listening on the
socket, and then deletes it. If the test client wins the race by
probing to see whether the socket is present after the dbus-daemon
has stopped listening but before the dbus-daemon has deleted it, then
the test will fail.

This intermittently happens on Gitlab-CI, most recently in
<https://gitlab.freedesktop.org/smcv/dbus/-/jobs/45694>.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-19 13:53:52 +00:00
Simon McVittie
70fdc001be keyring: Avoid undefined out-of-range shift
Detected with UndefinedBehaviourSanitizer, which will warn on
about 50% of calls to this function, when s[3] is 128 or more,
because id is signed, so 128 << 24 is undefined signed overflow.

All we want here is a random non-negative signed int (in the range 0
to 2**31-1, with 31 bits varying). The intention seemed to be to
generate a random unsigned int, cast it to signed, and then negate it
if negative, but it seems simpler and more obviously correct to just
make sure the most  significant byte fits in the non-negative range.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-19 12:15:17 +00:00
Simon McVittie
2df063be18 BusDesktopFile: Don't leak content if key=value appears before [Section]
BusDesktopFile has a strange convention in which the various parser
helper functions (parse_section_start(), etc.) free the parser on error.
However, this particular error case happens outside the helper functions
and so will leak.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-19 11:38:11 +00:00
Simon McVittie
24d0be54cc desktop-file test: Don't leak errors
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-11-19 11:38:11 +00:00
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
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