]> git.ipfire.org Git - thirdparty/dbus.git/log
thirdparty/dbus.git
6 years agotest-privserver: Don't leak the DBusServer
Simon McVittie [Tue, 11 Dec 2018 10:04:18 +0000 (10:04 +0000)] 
test-privserver: Don't leak the DBusServer

This results in (harmless) leak reports when running under the
AddressSanitizer, which could make real leaks harder to find.

Signed-off-by: Simon McVittie <smcv@collabora.com>
6 years agoAdd build system variable DBUS_NAME_TEST_EXEC to cover differences in executable...
Ralf Habacker [Tue, 20 Nov 2018 15:33:57 +0000 (16:33 +0100)] 
Add build system variable DBUS_NAME_TEST_EXEC to cover differences in executable paths

Autotools creates executable applications in the respective
subdirectory of the build directory, while cmake creates
them in <build-root>/bin.

This leads to different paths in the file created
from org.freedesktop.DBus.TestSuite.PrivServer.service.in,
which are fixed by the new variable.

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>
6 years agoRefer to correct bus in test-ids error message
Ralf Habacker [Fri, 7 Dec 2018 18:06:35 +0000 (19:06 +0100)] 
Refer to correct bus in test-ids error message

The test tries to connect to the session bus, not system bus.

Reviewed-by: Simon McVittie <smcv@collabora.com>
6 years agorun-session: Fix warning 'array subscript 3 is above array bounds of 'char *[3]'...
Ralf Habacker [Fri, 7 Dec 2018 18:02:14 +0000 (19:02 +0100)] 
run-session: Fix warning 'array subscript 3 is above array bounds of 'char *[3]' on Windows

After the merge request !22 was created, this bug was fixed in !23,
the associated branch was used for local tests, but the fix was not
transferred to !22. After merging !22 into the master branch and
rebasing !23 to the master, this fix was lost.

Reviewed-by: Simon McVittie <smcv@collabora.com>
6 years agoMerge branch 'skip-server-oom-test' into 'master'
Simon McVittie [Thu, 6 Dec 2018 16:42:09 +0000 (16:42 +0000)] 
Merge branch 'skip-server-oom-test' into 'master'

Skip server oom wildcard test on Windows to avoid firewall exception request

See merge request dbus/dbus!64

Reviewed-by: smcv
6 years agoSkip server oom wildcard test on Windows to avoid firewall exception request
Ralf Habacker [Thu, 6 Dec 2018 16:08:29 +0000 (17:08 +0100)] 
Skip server oom wildcard test on Windows to avoid firewall exception request

After starting the test on Windows 10, whether the local user is an
administrator or not, a dialog box appears with a warning that some
features of the app have been blocked by the firewall and prompts for
credentials for an administrator account while the test continues to
run and pass.

If this request is aborted, the dialog disappears; no restrictions are
visible for the test case. When the test is restarted, the dialog is also
no longer displayed.

In the firewall configuration you can then see that test-server-oom.exe
has been added (but not enabled) for public networks, although no
confirmation has been received from an administrator account.

6 years agoMerge branch 'fix-cmake-wine-support' into 'master'
Simon McVittie [Thu, 6 Dec 2018 12:24:37 +0000 (12:24 +0000)] 
Merge branch 'fix-cmake-wine-support' into 'master'

Fix cmake wine support

See merge request dbus/dbus!60

Reviewed-by: smcv
6 years agoAdd new cmake configure option DBUS_USE_WINE
Ralf Habacker [Wed, 5 Dec 2018 07:30:17 +0000 (08:30 +0100)] 
Add new cmake configure option DBUS_USE_WINE

If this variable is set, ctest uses wine to run cross compiled
test applications. Otherwise, they are assumed to run on a native
Windows operating system.

The new cmake variables Z_DRIVE_IF_WINE and TEST_WRAPPER have been
added to support this function.

7 years agoMerge branch 'fix-cmake-tests' into 'master'
Simon McVittie [Wed, 5 Dec 2018 16:06:05 +0000 (16:06 +0000)] 
Merge branch 'fix-cmake-tests' into 'master'

Fix cmake tests

See merge request dbus/dbus!59

Reviewed-by: smcv
7 years agoUpdate NEWS
Simon McVittie [Wed, 5 Dec 2018 15:02:42 +0000 (15:02 +0000)] 
Update NEWS

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agoAdds uac manifest to all executable test files to prevent the Windows 740 error when...
Ralf Habacker [Wed, 5 Dec 2018 06:56:22 +0000 (07:56 +0100)] 
Adds uac manifest to all executable test files to prevent the Windows 740 error when running

The case occurred during test-pending-call-dispatch. To avoid further
applications being affected in the future, the manifest is added to
all test applications.

Windows Error 740 is defined as 'The Requested Operation Requires Elevation'

7 years agoDrop cmake variable DBUS_WIN_FIXME
Ralf Habacker [Wed, 5 Dec 2018 13:59:17 +0000 (14:59 +0100)] 
Drop cmake variable DBUS_WIN_FIXME

7 years agoAvoid memory leaks on running check_shell_service_success_auto_start on Windows
Ralf Habacker [Mon, 26 Nov 2018 11:09:48 +0000 (12:09 +0100)] 
Avoid memory leaks on running check_shell_service_success_auto_start on Windows

7 years agoCI: Install yelp-tools, for yelp-build, in recent distros
Simon McVittie [Wed, 5 Dec 2018 13:17:17 +0000 (13:17 +0000)] 
CI: Install yelp-tools, for yelp-build, in recent distros

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agoCI: Make adduser properly non-interactive
Simon McVittie [Wed, 5 Dec 2018 13:52:12 +0000 (13:52 +0000)] 
CI: Make adduser properly non-interactive

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agoCI: Don't install weak dependencies (Recommends)
Simon McVittie [Wed, 5 Dec 2018 13:16:10 +0000 (13:16 +0000)] 
CI: Don't install weak dependencies (Recommends)

In particular this avoids installing the TeX toolchain.

However, this also means we don't install dbus, which broke some tests
in minimal containers where dbus wasn't already installed, because the
messagebus user wouldn't have been created. Make sure that user exists,
using the same adduser call as the Debian dbus package.

CMake really wants to find a C++ compiler (even though we only use C++
when compiling for Windows), so explicitly install the default
version of the GNU C++ compiler, g++.

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agoMerge branch 'sysdeps-test-wait' into 'master'
Ralf Habacker [Wed, 5 Dec 2018 14:32:53 +0000 (14:32 +0000)] 
Merge branch 'sysdeps-test-wait' into 'master'

sysdeps test: Wait for spawned process to exit

Closes #238
See merge request dbus/dbus!61
Reviewed-by: rhabacker
7 years agosysdeps test: Wait for spawned process to exit
Simon McVittie [Wed, 5 Dec 2018 12:58:22 +0000 (12:58 +0000)] 
sysdeps test: Wait for spawned process to exit

On Windows, the "out" parameter for the process handle isn't set
unless we specify G_SPAWN_FLAGS_DO_NOT_REAP_CHILD. That means we
can't terminate it, and the child process is leaked. When running the
test individually, the leaked process is harmless apart from its
resource cost, but when running under CTest, it holds a file descriptor
open (or something) which causes CTest to not exit.

If we *do* specify G_SPAWN_FLAGS_DO_NOT_REAP_CHILD, we become
responsible for "reaping" the child process by waiting for its exit
status, which is an OS-specific action.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Resolves: https://gitlab.freedesktop.org/dbus/dbus/issues/238

7 years agoMerge branch 'syslog-test-newlines' into 'master'
Ralf Habacker [Wed, 5 Dec 2018 14:28:36 +0000 (14:28 +0000)] 
Merge branch 'syslog-test-newlines' into 'master'

syslog test: Don't assert that we see plain LF newlines

Closes #243

See merge request dbus/dbus!62

7 years agosyslog test: Don't assert that we see plain LF newlines
Simon McVittie [Wed, 5 Dec 2018 13:40:46 +0000 (13:40 +0000)] 
syslog test: Don't assert that we see plain LF newlines

In at least some build configurations that target Windows, we see CRLF
newlines in the stderr of the subprocess. Leave the newlines unspecified
and let "*" match them.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Resolves: https://gitlab.freedesktop.org/dbus/dbus/issues/243

7 years agoMerge branch 'unprivileged-container' into 'master'
Simon McVittie [Wed, 5 Dec 2018 14:09:19 +0000 (14:09 +0000)] 
Merge branch 'unprivileged-container' into 'master'

dbus-daemon test: Don't test fd limits if in an unprivileged container

See merge request dbus/dbus!58

Reviewed-by: pwithnall
7 years agoMerge branch 'unpythonize' into 'master'
Simon McVittie [Wed, 5 Dec 2018 14:09:00 +0000 (14:09 +0000)] 
Merge branch 'unpythonize' into 'master'

Translate Python-based tests to C

See merge request dbus/dbus!37

Reviewed-by: pwithnall
7 years agoMerge branch 'hash-assertion' into 'master'
Simon McVittie [Wed, 5 Dec 2018 14:07:55 +0000 (14:07 +0000)] 
Merge branch 'hash-assertion' into 'master'

DBusHash: Recalculate bucket used if the table is rebuilt

See merge request dbus/dbus!44

7 years agoFix test-shutdown bail out on Windows
Ralf Habacker [Wed, 24 Oct 2018 10:03:14 +0000 (12:03 +0200)] 
Fix test-shutdown bail out on Windows

test-shutdown expects a GUID in the bus address by default,
which is not available under Windows, because on this platform
an autolaunch address is provided by dbus-run-session and is
not returned by dbus-daemon.

Bug: https://gitlab.freedesktop.org/dbus/dbus/merge_requests/59
Reviewed-by: Simon McVittie <smcv@collabora.com>
7 years agoStart working on dbus 1.13.10
Simon McVittie [Tue, 4 Dec 2018 17:25:20 +0000 (17:25 +0000)] 
Start working on dbus 1.13.10

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years ago1.13.8 dbus-1.13.8
Simon McVittie [Tue, 4 Dec 2018 12:27:32 +0000 (12:27 +0000)] 
1.13.8

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agoNEWS: Note new weak dependency on xsltproc for CMake
Simon McVittie [Tue, 4 Dec 2018 12:26:03 +0000 (12:26 +0000)] 
NEWS: Note new weak dependency on xsltproc for CMake

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agodbus-daemon test: Don't test fd limits if in an unprivileged container
Simon McVittie [Tue, 4 Dec 2018 12:09:26 +0000 (12:09 +0000)] 
dbus-daemon test: Don't test fd limits if in an unprivileged container

In an unprivileged container, uid 0 doesn't have CAP_SYS_RESOURCE, so
we can't expect the dbus-daemon to be able to escalate its fd limit.

This can be reproduced using bubblewrap:

    sudo bwrap \
        --cap-drop CAP_SYS_RESOURCE \
        --ro-bind / / \
        --dev /dev \
    env \
        DBUS_TEST_DAEMON=.../bus/dbus-daemon \
        DBUS_TEST_DATA=.../test/data \
    .../test/test-dbus-daemon \
        -p /fd-limit \
        --verbose

Bug-Debian: https://bugs.debian.org/908092

7 years agoCI: Exercise maintainer-only documentation build
Simon McVittie [Tue, 4 Dec 2018 11:25:21 +0000 (11:25 +0000)] 
CI: Exercise maintainer-only documentation build

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agoCI: Remove unimplemented --with-glib option
Simon McVittie [Tue, 4 Dec 2018 11:29:12 +0000 (11:29 +0000)] 
CI: Remove unimplemented --with-glib option

dbus has never actually had this option.

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agoCI: List attributes, sizes etc. of installed files, not just names
Simon McVittie [Tue, 4 Dec 2018 11:25:02 +0000 (11:25 +0000)] 
CI: List attributes, sizes etc. of installed files, not just names

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agodoc: Remove obsolete message about man2html
Simon McVittie [Tue, 4 Dec 2018 11:41:11 +0000 (11:41 +0000)] 
doc: Remove obsolete message about man2html

We no longer run man2html.

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agodoc: Don't include ChangeLog in dbus-docs.tar.xz
Simon McVittie [Tue, 4 Dec 2018 11:18:39 +0000 (11:18 +0000)] 
doc: Don't include ChangeLog in dbus-docs.tar.xz

Signed-off-by: Simon McVittie <smcv@collabora.com>
Fixes: e93b421137493710cb6b81420d15928eb13014e3
7 years agodoc: Use tar --xz to create dbus-docs.tar.xz
Simon McVittie [Tue, 4 Dec 2018 11:17:05 +0000 (11:17 +0000)] 
doc: Use tar --xz to create dbus-docs.tar.xz

Signed-off-by: Simon McVittie <smcv@collabora.com>
Fixes: b805744029e6c497b0b92051199a304636e82fcd
7 years agoCI: Start supporting Debian 10 'buster', currently under development
Simon McVittie [Mon, 3 Dec 2018 19:45:46 +0000 (19:45 +0000)] 
CI: Start supporting Debian 10 'buster', currently under development

This gives us a way to build on a more recent host OS if we want to.
For Gitlab-CI it's disabled by default.

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agoCI: Stop building on Ubuntu 14.04 'trusty'
Simon McVittie [Mon, 3 Dec 2018 19:44:47 +0000 (19:44 +0000)] 
CI: Stop building on Ubuntu 14.04 'trusty'

The version of gcc in trusty is too old for AddressSanitizer, which we
want to be able to start using, and Travis-CI finally supports Ubuntu
16.04 'xenial' now. This lets us remove some workarounds, but we need
to update others.

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agoDBusHash: Program a bit more defensively
Simon McVittie [Fri, 17 Aug 2018 18:50:13 +0000 (19:50 +0100)] 
DBusHash: Program a bit more defensively

In particular, the assertions that bucket >= table->buckets and
bucket <= &table->buckets[table->n_buckets - 1] catch the bug fixed
by the previous commit, by ensuring that bucket is somewhere inside
the new array of buckets.

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agoDBusHash: Recalculate bucket used if the table is rebuilt
Simon McVittie [Fri, 17 Aug 2018 18:49:36 +0000 (19:49 +0100)] 
DBusHash: Recalculate bucket used if the table is rebuilt

Hash buckets are simply entries in an array owned by the hash table,
so every time the hash table's array of buckets is reallocated, we must
invalidate all pointers to buckets and recalculate them to point into
the new array of buckets. This was not always done. Luckily, we appear
to have avoided causing any actual memory corruption like this.

The only place where we reallocate the array of buckets is in
rebuild_table(), which is only called by add_allocated_entry(), which
is only called by add_entry(), which is only called by
find_generic_function() when create_if_not_found is true.
find_generic_function(), in turn, is only called by the
table->find_function() implementations.

The table->find_function() implementations have an optional "out"
parameter which returns a pointer to the hash bucket in which the returned
entry would be found. It is set in find_generic_function() for existing
entries, or in add_allocated_entry() if a new entry is created; after
that it is returned through callers unchanged until the caller of
table->find_function() is reached. The only callers that make use of the
"out" parameter in practice are _dbus_hash_iter_lookup(), to populate
a DBusHashIter, and the _dbus_hash_table_remove_TYPE() family, to pass
it to remove_entry().

We can ignore the _dbus_hash_table_remove_TYPE() family for two
reasons: they call the find function with create_if_not_found set to
FALSE, which never reallocates the hash table, and they do not store
the pointer to the bucket in the long-term. So we only need to consider
_dbus_hash_iter_lookup().

It is documented to be unsafe to add hash entries while a DBusHashIter
is open, and only adding a hash entry can trigger rebuild_table();
so we can assume that if _dbus_hash_iter_lookup() returns a valid
bucket, it remains valid forever.

The remaining case that must be considered is whether reallocation
can occur after setting the "out" parameter for the bucket, but before
returning it to _dbus_hash_iter_lookup(). We can see that it can: we
call rebuild_table() after recalculating the correct bucket. If we do,
and it actually causes a rebuild, then we must recalculate the bucket
accordingly.

Looking at the worst-case impact of this bug, if it is going to cause
any problem, it would only be when _dbus_hash_iter_lookup() is called
with create_if_not_found set true. This makes three uses of the bucket:
it stores it in the DBusHashTableIter, it calculates the next bucket
by finding the offset of the bucket in table->buckets and advancing
by one pointer, and it makes an assertion that should be tautologous,
enforcing that the next bucket corresponds to what it should.

When running under the AddressSanitizer, which makes allocations in
widely spaced regions of memory, on a 32-bit platform, we could (and
indeed do) find that the tautologous assertion fails. The current
bucket returned from the "out" parameter is a pointer into the old
value of table->buckets. If it's far enough before or after the new
table->buckets in the address space, then the offset in next_bucket
could overflow a 32-bit integer, resulting in the assertion no longer
being true.

The next commit will add extra assertions, which reproduce the bug
even without AddressSanitizer.

In production code without assertions, the impact is that
the ->bucket and ->next_bucket members of the DBusHashIter can be
invalid. They are used in _dbus_hash_iter_next() and
_dbus_hash_iter_remove_entry(). However, the only callers of
_dbus_hash_iter_lookup() outside test code are in bus/containers.c,
and neither calls either of those functions, so we dodge that bullet.

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agoTranslate Python-based tests to C
Simon McVittie [Fri, 16 Nov 2018 18:53:11 +0000 (18:53 +0000)] 
Translate Python-based tests to C

This simplifies bootstrapping: now you don't have to build dbus,
build dbus-python (with GLib), and use dbus-python to test dbus.

It also avoids test failures when using facilities like
AddressSanitizer. When libdbus is built with AddressSanitizer, but the
system copies of Python and dbus-python were not, dbus-python will exit
the Python interpreter on load, because libasan wasn't already
initialized. The simplest way to avoid this is to not use Python:
the scripts are not *that* hard to translate into C.

Both of these tests happen to be conditionally compiled for Unix only.
test_activation_forking() relies on code in TestSuiteForkingEchoService
that calls fork(), which can only work on Unix; meanwhile,
test_system_signals() tests the system bus configuration, which is
only relevant to Unix because we don't support using dbus-daemon as
a privilege boundary on Windows (and in any case D-Bus is not a Windows
OS feature, so the system bus cannot be used to communicate with OS
services like it can on most Linux systems).

This is also a partial solution to
<https://gitlab.freedesktop.org/dbus/dbus/issues/135>, by reducing the
size of name-test/.

For this to work, we need to build the test-service helper executable
even if embedded tests are disabled.

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agotest-service: Write diagnostics to stderr
Simon McVittie [Fri, 16 Nov 2018 19:22:42 +0000 (19:22 +0000)] 
test-service: Write diagnostics to stderr

When run by a TAP test, stdout is reserved for machine-readable
TAP output.

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agoUpdate NEWS
Simon McVittie [Mon, 3 Dec 2018 16:31:07 +0000 (16:31 +0000)] 
Update NEWS

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agoactivation: Don't leak if delivering activation message is forbidden
Simon McVittie [Fri, 17 Aug 2018 14:42:17 +0000 (15:42 +0100)] 
activation: Don't leak if delivering activation message is forbidden

This is technically a denial of service because the dbus-daemon will
run out of memory eventually, but it's a very slow and noisy one,
because all the rejected messages are also very likely to have
been logged to the system log.

Detected by AddressSanitizer.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Resolves: https://gitlab.freedesktop.org/dbus/dbus/issues/234
Reviewed-by: pwithnall
7 years agoUpdate NEWS
Simon McVittie [Mon, 3 Dec 2018 15:42:43 +0000 (15:42 +0000)] 
Update NEWS

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agoMerge branch 'max-conns-per-user' into 'master'
Simon McVittie [Mon, 3 Dec 2018 15:30:57 +0000 (15:30 +0000)] 
Merge branch 'max-conns-per-user' into 'master'

test/dbus-daemon: Mark max-connections-per-user as unimplemented on Windows

See merge request dbus/dbus!54

Reviewed-by: pwithnall
Reviewed-by: rhabacker
7 years agoMerge branch '221-spec-fix' into 'master'
Simon McVittie [Mon, 3 Dec 2018 15:29:40 +0000 (15:29 +0000)] 
Merge branch '221-spec-fix' into 'master'

spec: Fix a typo in an ObjectManager example

Closes #221

See merge request dbus/dbus!56

Reviewed-by: smcv
7 years agospec: Fix a typo in an ObjectManager example
Philip Withnall [Mon, 3 Dec 2018 11:39:11 +0000 (11:39 +0000)] 
spec: Fix a typo in an ObjectManager example

As spotted by Peter Bigot.

Closes #221

Signed-off-by: Philip Withnall <withnall@endlessm.com>
7 years agoEnable check_get_connection_unix_process_id test on Windows with CMake
Ralf Habacker [Thu, 29 Nov 2018 22:50:03 +0000 (23:50 +0100)] 
Enable check_get_connection_unix_process_id test on Windows with CMake

This check is now possible because with merge request
 https://gitlab.freedesktop.org/dbus/dbus/merge_requests/55
the prerequisites are valid.

It was already run if built with Autotools, because DBUS_WIN_FIXME
was only defined in the CMake build system.

[smcv: Add more context regarding Autotools vs. CMake]
Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agoMerge branch 'windows-pid' into 'master'
Simon McVittie [Thu, 29 Nov 2018 19:51:48 +0000 (19:51 +0000)] 
Merge branch 'windows-pid' into 'master'

bus test: Accept GetConnectionUnixProcessID() success on Windows

See merge request dbus/dbus!55

Reviewed-by: pwithnall
7 years agobus test: Accept GetConnectionUnixProcessID() success on Windows
Simon McVittie [Thu, 29 Nov 2018 19:24:40 +0000 (19:24 +0000)] 
bus test: Accept GetConnectionUnixProcessID() success on Windows

Despite its name, which is a historical quirk, this is now a
generic cross-platform process ID on anything with the concept of
numbered processes. It appears it has actually worked on Windows
since dbus 1.7.x.

Bug: https://gitlab.freedesktop.org/dbus/dbus/issues/239
Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agodbus-daemon(1): Document max_connections_per_user as Unix-only
Simon McVittie [Thu, 29 Nov 2018 18:17:46 +0000 (18:17 +0000)] 
dbus-daemon(1): Document max_connections_per_user as Unix-only

The limit is accepted on Windows, but not enforced.

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agotest/dbus-daemon: Mark max-connections-per-user as unimplemented on Windows
Simon McVittie [Thu, 29 Nov 2018 14:24:00 +0000 (14:24 +0000)] 
test/dbus-daemon: Mark max-connections-per-user as unimplemented on Windows

The implementation of the max-connections-per-user limit works in terms
of Unix uids, so it doesn't apply on Windows.

This is not a problem in practice, because it only makes sense to limit
connections per user if you have multiple users, and we don't support
the well-known system bus on Windows.

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agoMerge branch 'dbus-daemon-inherited-fds' into 'master'
Simon McVittie [Wed, 21 Nov 2018 16:14:34 +0000 (16:14 +0000)] 
Merge branch 'dbus-daemon-inherited-fds' into 'master'

Don't let dbus-daemon and its subprocesses inherit unnecessary fds

See merge request dbus/dbus!50

Reviewed-by: rhabacker
Reviewed-by: pwithnall
7 years agoMerge branch 'simplify-configure-checks' into 'master'
Simon McVittie [Wed, 21 Nov 2018 16:14:11 +0000 (16:14 +0000)] 
Merge branch 'simplify-configure-checks' into 'master'

Simplify configure checks

See merge request dbus/dbus!10

7 years agoDon't let dbus-daemon and its subprocesses inherit unnecessary fds
Simon McVittie [Tue, 20 Nov 2018 18:06:34 +0000 (18:06 +0000)] 
Don't let dbus-daemon and its subprocesses inherit unnecessary fds

This should avoid test failures under CMake in which the
dbus-daemon inherits an unwanted fd from CMake's test framework, causing
the close-on-exec check before executing activated services to fail.

The dbus-daemon now marks all fds that it inherits, except for its
stdin, stdout and stderr, to be closed on exec. For completeness, the
dbus-daemons run by dbus-run-session and dbus-launch also now inherit
stdin, stdout, stderr and the pipes used to communicate with their
callers, but nothing else.

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agodbus-spawn-unix: If a fd is not close-on-exec, look it up in /proc/self/fd
Simon McVittie [Tue, 20 Nov 2018 17:32:02 +0000 (17:32 +0000)] 
dbus-spawn-unix: If a fd is not close-on-exec, look it up in /proc/self/fd

In operating systems where /proc/self/fd works like it does on Linux
(Linux itself, and FreeBSD with Linux /proc emulation) this will give
us a clue about the fd that was leaked or opened incorrectly.

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agoFindDocBookXSL.cmake: Add
Simon McVittie [Tue, 20 Nov 2018 18:27:47 +0000 (18:27 +0000)] 
FindDocBookXSL.cmake: Add

Taken from
<https://github.com/KDE/kdoctools/blob/master/cmake/FindDocBookXSL.cmake>

Signed-off-by: Simon McVittie <smcv@collabora.com>
Resolves: https://gitlab.freedesktop.org/dbus/dbus/issues/237

7 years agoMerge branch '233-fix-broken-meinproc4' into 'master'
Simon McVittie [Tue, 20 Nov 2018 17:13:31 +0000 (17:13 +0000)] 
Merge branch '233-fix-broken-meinproc4' into 'master'

Fix broken meinproc4-based Docbook processing by using xsltproc instead

Closes #233

See merge request dbus/dbus!48

Reviewed-by: smcv
7 years agoAdd xsltproc usage to README.cmake
Ralf Habacker [Tue, 20 Nov 2018 13:19:59 +0000 (14:19 +0100)] 
Add xsltproc usage to README.cmake

7 years agoFix incorrect links in index html page used by cmake
Ralf Habacker [Tue, 20 Nov 2018 14:09:36 +0000 (15:09 +0100)] 
Fix incorrect links in index html page used by cmake

7 years agoFix broken meinproc4 based docbook generating by already used xsltproc
Ralf Habacker [Tue, 20 Nov 2018 13:06:17 +0000 (14:06 +0100)] 
Fix broken meinproc4 based docbook generating by already used xsltproc

Using xsltproc helps to reduce manual editing of xml doc and avoids
cyclic dependency (kdelibs depends on dbus and dbus depends on kdelibs).
It is available on all platforms (in the opposite to xmlto) and supports
freedesktop CI out of the box.

This commit adds docbook-xml and docbook-xsl as new dependency for cmake
and removes obsolate xmlto support, which depends on xsltproc.

7 years agoMerge branch 'error-matches-bool' into 'master'
Simon McVittie [Tue, 20 Nov 2018 13:53:56 +0000 (13:53 +0000)] 
Merge branch 'error-matches-bool' into 'master'

Add _DBUS_ASSERT_ERROR_XOR_BOOL, and a test for assertions

See merge request dbus/dbus!49

Reviewed-by: pwithnall
7 years agoMerge branch 'desktop-file-leak-refactor' into 'master'
Simon McVittie [Tue, 20 Nov 2018 13:39:14 +0000 (13:39 +0000)] 
Merge branch 'desktop-file-leak-refactor' into 'master'

BusDesktopFile: Refactor logic to free the parser contents

See merge request dbus/dbus!43

Reviewed-by: pwithnall
7 years agoMerge branch 'test-random-ints' into 'master'
Simon McVittie [Tue, 20 Nov 2018 13:35:53 +0000 (13:35 +0000)] 
Merge branch 'test-random-ints' into 'master'

marshal-recursive test: improve clarity, avoid undefined behaviour

See merge request dbus/dbus!46

Reviewed-by: pwithnall
7 years agoAdd a test for assertions
Simon McVittie [Tue, 20 Nov 2018 12:48:51 +0000 (12:48 +0000)] 
Add a test for assertions

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years ago_dbus_disable_crash_handling: Factor out from test-segfault
Simon McVittie [Tue, 20 Nov 2018 12:48:40 +0000 (12:48 +0000)] 
_dbus_disable_crash_handling: Factor out from test-segfault

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agoImprove diagnostics for error assertion failures
Simon McVittie [Tue, 20 Nov 2018 12:24:35 +0000 (12:24 +0000)] 
Improve diagnostics for error assertion failures

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agoCleanup of cmake doc-related targets
Ralf Habacker [Tue, 20 Nov 2018 12:56:39 +0000 (13:56 +0100)] 
Cleanup of cmake doc-related targets

There is now a top-level target "doc" that is always built.
Depending on the detected generators it depends on optional
targets like apidoc' and 'devhelp2'.

7 years ago_DBUS_ASSERT_ERROR_XOR_BOOL: Add and use
Simon McVittie [Tue, 20 Nov 2018 12:17:20 +0000 (12:17 +0000)] 
_DBUS_ASSERT_ERROR_XOR_BOOL: Add and use

As suggested by Philip Withnall in dbus!43.

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agoBusDesktopFile: Refactor logic to free the parser contents
Simon McVittie [Fri, 16 Nov 2018 17:30:47 +0000 (17:30 +0000)] 
BusDesktopFile: Refactor logic to free the parser contents

Now that we have _DBUS_STRING_INIT_INVALID, we can initialize
parser.data to a value that is safe for _dbus_string_free(), which
means we can put all the cleanup through a single code path that
definitely frees everything.

(This is just refactoring, not a correctness fix.)

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agoci-build.sh: Show file size in list of files to be able to compare generated file...
Ralf Habacker [Mon, 19 Nov 2018 19:29:33 +0000 (20:29 +0100)] 
ci-build.sh: Show file size in list of files to be able to compare generated file size

7 years agoUpdate NEWS
Simon McVittie [Tue, 20 Nov 2018 11:32:54 +0000 (11:32 +0000)] 
Update NEWS

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agoMerge branch 'va-copy' into 'master'
Simon McVittie [Tue, 20 Nov 2018 11:23:36 +0000 (11:23 +0000)] 
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
7 years agoMerge branch 'containers-test-race' into 'master'
Simon McVittie [Tue, 20 Nov 2018 11:22:48 +0000 (11:22 +0000)] 
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
7 years agoMerge branch 'keyring-undefined-shift' into 'master'
Simon McVittie [Tue, 20 Nov 2018 11:22:20 +0000 (11:22 +0000)] 
Merge branch 'keyring-undefined-shift' into 'master'

keyring: Avoid undefined out-of-range shift

See merge request dbus/dbus!45

7 years agoMerge branch 'desktop-file-leak' into 'master'
Simon McVittie [Tue, 20 Nov 2018 11:21:32 +0000 (11:21 +0000)] 
Merge branch 'desktop-file-leak' into 'master'

bus: Fix memory leaks when parsing .service files

See merge request dbus/dbus!42

Reviewed-by: pwithnall
7 years agoMerge branch 'misc-leaks' into 'master'
Simon McVittie [Tue, 20 Nov 2018 11:21:05 +0000 (11:21 +0000)] 
Merge branch 'misc-leaks' into 'master'

Fix small memory leaks

See merge request dbus/dbus!41

7 years agocontainers test: Wait a few more seconds for the socket to be deleted
Simon McVittie [Mon, 19 Nov 2018 13:53:52 +0000 (13:53 +0000)] 
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>
7 years agotests: Generate random values in unsigned integer space
Simon McVittie [Fri, 31 Aug 2018 18:01:03 +0000 (19:01 +0100)] 
tests: Generate random values in unsigned integer space

When we're doing bitwise operations, addition with wraparound and
large left-shifts, it seems safer to use unsigned integers, where
the effect of overflow is well-defined (it wraps around). Signed
integer overflow is undefined behaviour, so compilers are free to
optimize by assuming that it cannot happen.

Detected by the undefined behaviour sanitizer (UBSan).

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agotests: Remove unnecessary casts
Simon McVittie [Fri, 31 Aug 2018 17:58:06 +0000 (18:58 +0100)] 
tests: Remove unnecessary casts

If we have a variable "Type value;" then casting &value to (Type *) is
not useful, because it has that type already; it can only hide errors.

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agotests: Make it clearer that we avoid overflowing fixed-length buffers
Simon McVittie [Fri, 31 Aug 2018 17:50:37 +0000 (18:50 +0100)] 
tests: Make it clearer that we avoid overflowing fixed-length buffers

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agokeyring: Avoid undefined out-of-range shift
Simon McVittie [Fri, 17 Aug 2018 18:38:07 +0000 (19:38 +0100)] 
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>
7 years agoBusDesktopFile: Don't leak content if key=value appears before [Section]
Simon McVittie [Fri, 16 Nov 2018 17:25:18 +0000 (17:25 +0000)] 
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>
7 years agodesktop-file test: Don't leak errors
Simon McVittie [Fri, 16 Nov 2018 17:19:50 +0000 (17:19 +0000)] 
desktop-file test: Don't leak errors

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agobus_container_instance_new: Don't leak empty DBusString object
Simon McVittie [Fri, 17 Aug 2018 14:37:36 +0000 (15:37 +0100)] 
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>
7 years agobus_driver_handle_become_monitor: Don't leak zero-length array of rules
Simon McVittie [Fri, 17 Aug 2018 14:33:10 +0000 (15:33 +0100)] 
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>
7 years agobuild: Require va_copy() or __va_copy() on non-MSVC compilers
Simon McVittie [Fri, 16 Nov 2018 16:21:48 +0000 (16:21 +0000)] 
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>
7 years agoCI: Do one build with mingw + CMake by default
Simon McVittie [Thu, 15 Nov 2018 18:32:06 +0000 (18:32 +0000)] 
CI: Do one build with mingw + CMake by default

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agoOnly use _DBUS_VA_COPY_ASSIGN to implement va_copy() on MSVC
Simon McVittie [Thu, 15 Nov 2018 17:42:13 +0000 (17:42 +0000)] 
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>
7 years agoDon't check how to copy a va_list if we already have va_copy()
Simon McVittie [Thu, 15 Nov 2018 17:40:33 +0000 (17:40 +0000)] 
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>
7 years agoMerge branch 'cmake-generate-dbus.devhelp2' into 'master'
Simon McVittie [Mon, 19 Nov 2018 11:06:36 +0000 (11:06 +0000)] 
Merge branch 'cmake-generate-dbus.devhelp2' into 'master'

Add generating dbus.devhelp2 to cmake build system

See merge request dbus/dbus!39

7 years agobuild: Simplify checks for straightforward header files
Simon McVittie [Tue, 4 Sep 2018 14:49:11 +0000 (07:49 -0700)] 
build: Simplify checks for straightforward header files

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agobuild: Simplify checks for functions with no special dependencies
Simon McVittie [Tue, 4 Sep 2018 14:42:12 +0000 (07:42 -0700)] 
build: Simplify checks for functions with no special dependencies

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agoAdd generating dbus.devhelp2 to cmake build system
Ralf Habacker [Fri, 16 Nov 2018 22:01:03 +0000 (23:01 +0100)] 
Add generating dbus.devhelp2 to cmake build system

7 years agoembedded tests: Make it easier to run a single test-case
Simon McVittie [Thu, 12 Jul 2018 16:38:04 +0000 (17:38 +0100)] 
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

7 years agoUpdate NEWS
Simon McVittie [Fri, 16 Nov 2018 15:04:52 +0000 (15:04 +0000)] 
Update NEWS

Signed-off-by: Simon McVittie <smcv@collabora.com>
7 years agoMerge branch 'iso-varargs' into 'master'
Simon McVittie [Fri, 16 Nov 2018 11:41:32 +0000 (11:41 +0000)] 
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
7 years agointernals: Assume compiler supports a subset of ISO varargs syntax
Simon McVittie [Thu, 15 Nov 2018 18:55:57 +0000 (18:55 +0000)] 
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>
7 years agoMerge branch 'dbus-va-copy-fixup' into 'master'
Simon McVittie [Thu, 15 Nov 2018 15:40:32 +0000 (15:40 +0000)] 
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

7 years agoRefactor cmake checks for DBUS_VA_COPY and DBUS_VA_COPY_ARRAY
Ralf Habacker [Thu, 25 Oct 2018 18:14:24 +0000 (20:14 +0200)] 
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.

7 years agoMerge branch 'avc_open' into 'master'
Simon McVittie [Thu, 15 Nov 2018 15:17:47 +0000 (15:17 +0000)] 
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