Commit graph

4626 commits

Author SHA1 Message Date
Simon McVittie
73b03e0bfb name-test, tools: add missing COVERAGE_CFLAGS
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2016-08-15 15:17:31 +01:00
Simon McVittie
2ec7c67b16 Document use of AX_CODE_COVERAGE
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2016-08-15 14:31:44 +01:00
Thomas Zimmermann
be04ba8354 Use AX_CODE_COVERAGE for test-coverage statistics
DBus uses custom rules in its Makefiles to implement test-coverage
statistics.

This patch implements test-coverage statistics with the autoconf macro
AX_CODE_COVERAGE. The script automatically tests for tools (e.g., gcov,
lcov), sets build variables and creates Makefile rules.

Run 'configure' with '--enable-code-coverage' to enable support for
test-coverage statistics. Run 'make check-code-coverage' to run the
tests and generate the statistics.

Signed-off-by: Thomas Zimmermann <tdz@users.sourceforge.net>
[smcv: do not alter compiler.m4; move AM_CXXFLAGS to the one place we
compile C++]
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88922
2016-08-15 14:30:51 +01:00
Simon McVittie
1a30d452a4 Merge branch 'dbus-1.10' 2016-08-12 18:24:10 +01:00
Simon McVittie
c56cc26164 Add a regression test for dbus-launch in X11
[Modified for the dbus-1.10 branch: DBUS_USE_TEST_BINARY is needed.]

Signed-off-by: Simon McVittie <smcv@debian.org>
2016-08-12 18:21:36 +01:00
Simon McVittie
6ce19c8625 test-dbus-daemon-fork: exercise closed stdin, stdout, stderr
Signed-off-by: Simon McVittie <smcv@debian.org>
2016-08-12 18:21:36 +01:00
Simon McVittie
1679f58a14 test: expand dbus-launch-eval test to cover stdin being closed
Signed-off-by: Simon McVittie <smcv@debian.org>
2016-08-12 18:21:36 +01:00
Simon McVittie
a7caca9f47 Add a simple test for dbus-daemon --fork
[Modified for the dbus-1.10 branch: DBUS_USE_TEST_BINARY is needed.]

Signed-off-by: Simon McVittie <smcv@debian.org>
2016-08-12 18:21:32 +01:00
Simon McVittie
042391e88a test: add a regression test for eval "$(dbus-launch --sh-syntax)"
[Modified for the dbus-1.10 branch: DBUS_USE_TEST_BINARY is needed.]

Signed-off-by: Simon McVittie <smcv@debian.org>
2016-08-12 18:21:01 +01:00
Simon McVittie
67f2fed1fd test-dbus-launch-x11: extend to cover --exit-with-x11
Signed-off-by: Simon McVittie <smcv@debian.org>
2016-08-12 18:13:47 +01:00
Simon McVittie
01ffa21501 Add a regression test for dbus-launch in X11
Signed-off-by: Simon McVittie <smcv@debian.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97008
2016-08-12 18:13:21 +01:00
Simon McVittie
53fe3b44af test-dbus-daemon-fork: exercise closed stdin, stdout, stderr
Signed-off-by: Simon McVittie <smcv@debian.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97008
2016-08-12 18:13:13 +01:00
Simon McVittie
4710c60bbf Add a simple test for dbus-daemon --fork
Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Colin Walters
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97008
2016-08-12 18:12:46 +01:00
Simon McVittie
0e0a032aa2 test: add a regression test for eval "$(dbus-launch --sh-syntax)"
Signed-off-by: Simon McVittie <smcv@debian.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97008
2016-08-12 18:12:41 +01:00
Simon McVittie
b7d280f623 _dbus_change_to_daemon_user (audit code path): set DBusError correctly
The other error cases here all set the error instead of just warning.

Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97009
2016-08-12 17:34:29 +01:00
Simon McVittie
76ae52735e Remove trailing newlines from _dbus_assert_not_reached
This was never necessary: _dbus_assert_not_reached() always added one.

Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97009
2016-08-12 17:11:48 +01:00
Simon McVittie
f518165b84 dbus-daemon, dbus-launch: cope with callers having closed standard fds
In Debian bug <https://bugs.debian.org/829348>, lightdm appears to
have been starting dbus-launch with at least one of the three
standard fds 0, 1, 2 (stdin, stdout, stderr) closed. This resulted
in the dbus-daemon's epoll_create1() returning a fd less than 3.
Later, _dbus_become_daemon() replaces fds 0-2 with /dev/null. As a
result, a subsequent call to _dbus_loop_add_watch() for the reload
pipe resulted in calling epoll_ctl on the non-epoll fd pointing to
/dev/null, which fails with EINVAL, resulting in the dbus-daemon
exiting unsuccessfully.

Unix programs are not normally expected to behave correctly when
launched with the standard fds not already open; but at the same time,
X11 autolaunching means that dbus-launch (and hence the dbus-daemon)
can get started from an arbitrarily precarious situation.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97008
Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Thiago Macieira <thiago@kde.org>
(cherry picked from commit c8f73a2a3a)
2016-08-12 10:58:38 +01:00
Simon McVittie
ed33129fe4 _dbus_ensure_standard_fds: new function to ensure std* fds are open
This function opens stdin, stdout, stderr pointing to /dev/null
if they aren't already open. Optionally, it can also replace
whatever is available on those fds with /dev/null.

To allow for use in contexts where only async-signal-safe functions
should be used, such as between fork() and a following exec(),
this function does not use conventional libdbus error handling
(which would require malloc). Instead, it sets errno and returns
an explanatory string.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97008
Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Thiago Macieira <thiago@kde.org>
(cherry picked from commit 69123a6bd2)
2016-08-12 10:58:38 +01:00
Simon McVittie
6d8a198de9 various tests: produce better diagnostics on error
Same root cause as <https://bugs.freedesktop.org/show_bug.cgi?id=96653>:
we didn't check whether the message was in fact an error reply.

Signed-off-by: Simon McVittie <smcv@debian.org>
2016-08-12 10:25:06 +01:00
Simon McVittie
e9d37affcd More NEWS for 1.11 2016-08-12 10:17:46 +01:00
Simon McVittie
53ddb81c8c Merge branch 'dbus-1.10' 2016-08-12 10:14:46 +01:00
Simon McVittie
32c940d183 NEWS for 1.10 2016-08-12 10:12:28 +01:00
Simon McVittie
7ebe1de218 Mark WaitingForOK state as unused
It should probably be used (see #97298) but the fact that it isn't
is breaking compatibility with gcc 6, so apply a quick workaround
while we look into what's wrong here.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97282
(cherry picked from commit 21d6118081)
2016-08-12 10:11:31 +01:00
Simon McVittie
4729b7a5f4 update-activation-environment: produce better diagnostics on error
If dbus-daemon or systemd replied to our method call with an error,
we would report it as "invalid arguments" instead of the true error
name and message.

Same root cause as <https://bugs.freedesktop.org/show_bug.cgi?id=96653>.

Signed-off-by: Simon McVittie <smcv@debian.org>
2016-08-12 09:50:00 +01:00
Simon McVittie
9d89710c1f config-parser: remove unnecessary newline from _dbus_log()
_dbus_log() already adds a newline.

Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97009
2016-08-11 16:41:16 +01:00
Simon McVittie
d97d561a46 _dbus_system_log: rename to _dbus_log
This is a step towards making it write to either stderr or syslog
or both, as configured globally.

Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97009
2016-08-11 16:41:16 +01:00
Simon McVittie
8ef699dd20 _dbus_init_system_log: record a syslog tag (executable name)
Instead of hard-coding "dbus", report what the executable really is.

Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97009
2016-08-11 16:41:16 +01:00
Simon McVittie
a227177918 sysdeps: move _dbus_system_log() into the shared library
This is in preparation for optionally making _dbus_warn() use it.
dbus-daemon closes its stderr under some circumstances, including
when launched by dbus-launch, which makes failures in that
situation rather hard to debug.

_dbus_system_log() is the same on Unix and Windows, so move it
to dbus-sysdeps.c. _dbus_system_logv() remains platform-specific.

Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97009
[smcv: move the #include for syslog.h, too]
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2016-08-11 16:41:16 +01:00
Simon McVittie
e3d76634c3 test-bus: don't write to the syslog
We want to emulate the behaviour of the system bus, but we don't
really want to spam the system log with lots of test messages.

Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97009
2016-08-11 16:41:16 +01:00
Thomas Zimmermann
30a7cb3901 Fix misleading indentation to avoid respective compiler warning
Signed-off-by: Thomas Zimmermann <tdz@users.sourceforge.net>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97282
2016-08-11 16:41:14 +01:00
Thomas Zimmermann
67306f865b Protect 'i' in _handle_inotify_watch by DBUS_ENABLE_VERBOSE_MODE
Signed-off-by: Thomas Zimmermann <tdz@users.sourceforge.net>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97282
2016-08-11 16:41:10 +01:00
Thomas Zimmermann
a48a49b9c9 Initialize 'klass' in _dbus_type_reader_recurse to NULL
Initializing 'klass' in _dbus_type_reader_recurse avoids a
compile-time warning about the variable being uninitialized.

Signed-off-by: Thomas Zimmermann <tdz@users.sourceforge.net>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97282
2016-08-11 16:41:05 +01:00
Thomas Zimmermann
5b50a18ca9 Protect 'orig_len' in recover_unused_bytes by DBUS_ENABLE_VERBOSE_MODE
Signed-off-by: Thomas Zimmermann <tdz@users.sourceforge.net>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97282
2016-08-11 16:41:02 +01:00
Thomas Zimmermann
6ac1dfb343 dbus-launch: Protect concat2 by DBUS_ENABLE_EMBEDDED_TESTS
Signed-off-by: Thomas Zimmermann <tdz@users.sourceforge.net>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97282
2016-08-11 16:40:58 +01:00
Simon McVittie
21d6118081 Mark WaitingForOK state as unused
It should probably be used (see #97298) but the fact that it isn't
is breaking compatibility with gcc 6, so apply a quick workaround
while we look into what's wrong here.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97282
2016-08-11 16:08:39 +01:00
Simon McVittie
8c24df0ba0 Merge branch 'dbus-1.10' 2016-07-29 19:15:21 +01:00
Simon McVittie
9e79a8ff8c NEWS for 1.10 branch 2016-07-29 19:14:18 +01:00
Ioan-Adrian Ratiu
1bfde22292 configure.ac: explicitely check stdint.h
Otherwise HAVE_STDINT_H will not be defined or the var will not be
picked up from cache so builds could fail with errors like:
| ../../dbus-1.10.8/dbus/dbus-internals.h:239:8: error: ‘uintptr_t’ undeclared (first use in this function)

Signed-off-by: Ioan-Adrian Ratiu <adrian.ratiu@ni.com>
[smcv: fix Autoconf underquoting]
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2016-07-29 19:12:59 +01:00
Simon McVittie
2fd7b418c1 Merge branch 'dbus-1.10' 2016-07-25 12:11:39 +01:00
Simon McVittie
33878930d9 Update NEWS for 1.11 2016-07-25 12:11:00 +01:00
Simon McVittie
bed2688452 Update NEWS for merge of dbus-1.10-ci branch 2016-07-25 11:53:13 +01:00
Simon McVittie
8dab754686 Merge branch 'dbus-1.10-ci' into dbus-1.10 2016-07-25 11:43:54 +01:00
Simon McVittie
e4724af4ee _read_subprocess_line_argv: use _dbus_ensure_standard_fds
This also gives us an opportunity to improve the error reporting.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97008
Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Thiago Macieira <thiago@kde.org>
2016-07-25 11:27:13 +01:00
Simon McVittie
fef477f150 dbus-launch: use _dbus_ensure_standard_fds when closing stderr
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97008
Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Thiago Macieira <thiago@kde.org>
2016-07-25 11:27:03 +01:00
Simon McVittie
f0819f926f dbus-launch: use _dbus_ensure_standard_fds() in the babysitter
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97008
Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Thiago Macieira <thiago@kde.org>
2016-07-25 11:26:52 +01:00
Simon McVittie
57593b18fc _dbus_become_daemon: use _dbus_ensure_standard_fds, and report errors
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97008
Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Thiago Macieira <thiago@kde.org>
2016-07-25 11:26:43 +01:00
Simon McVittie
c8f73a2a3a dbus-daemon, dbus-launch: cope with callers having closed standard fds
In Debian bug <https://bugs.debian.org/829348>, lightdm appears to
have been starting dbus-launch with at least one of the three
standard fds 0, 1, 2 (stdin, stdout, stderr) closed. This resulted
in the dbus-daemon's epoll_create1() returning a fd less than 3.
Later, _dbus_become_daemon() replaces fds 0-2 with /dev/null. As a
result, a subsequent call to _dbus_loop_add_watch() for the reload
pipe resulted in calling epoll_ctl on the non-epoll fd pointing to
/dev/null, which fails with EINVAL, resulting in the dbus-daemon
exiting unsuccessfully.

Unix programs are not normally expected to behave correctly when
launched with the standard fds not already open; but at the same time,
X11 autolaunching means that dbus-launch (and hence the dbus-daemon)
can get started from an arbitrarily precarious situation.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97008
Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Thiago Macieira <thiago@kde.org>
2016-07-25 11:26:36 +01:00
Simon McVittie
69123a6bd2 _dbus_ensure_standard_fds: new function to ensure std* fds are open
This function opens stdin, stdout, stderr pointing to /dev/null
if they aren't already open. Optionally, it can also replace
whatever is available on those fds with /dev/null.

To allow for use in contexts where only async-signal-safe functions
should be used, such as between fork() and a following exec(),
this function does not use conventional libdbus error handling
(which would require malloc). Instead, it sets errno and returns
an explanatory string.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97008
Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Thiago Macieira <thiago@kde.org>
2016-07-25 11:26:01 +01:00
Ralf Habacker
e3a14eb4fd dbus: do not include unused afxres.h on windows.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=96181
Reviewed-by: simon.mcvittie@collabora.co.uk
2016-07-23 17:16:53 +02:00
Simon McVittie
b04d9324fb dbus-launch: add --exit-with-x11 option
This is more suitable for distributions' Xsession scripts: it verifies
that X is already available, and so never results in an attempt to poll
stdin.

We read the machine UUID because it is needed to set the X atoms.
x11_init() assumes that the machine UUID (global variable) has been
set, either via read_machine_uuid_if_needed() or save_machine_uuid().
This is pretty tangled, but to make The Right Thing happen
automatically, we'd need to redo dbus-launch in terms of DBusError.

Reviewed-by: Will Thompson
Reviewed-by: Thiago Macieira
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39197
Signed-off-by: Simon McVittie <smcv@debian.org>
2016-07-20 13:32:36 +01:00