Commit graph

5192 commits

Author SHA1 Message Date
Simon McVittie
9cf2d308ce dbus_server_listen: Don't leak first_connect_error
If an implementation fails to listen, and a subsequent implementation
succeeds, then we would have leaked this. Detected by running
tests/loopback.c under valgrind.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107194
(cherry picked from commit b14a4517a8)
2018-08-02 17:13:02 +01:00
Simon McVittie
4937a36c31 sysdeps: Reassure gcc 8 that we are not overflowing struct sockaddr_un
Using strncpy (buffer, str, strlen (str)) is a "code smell" that
might indicate a serious bug (it effectively turns strncpy into
strcpy), and gcc 8 now warns about it. In fact we avoided the bug
here, but it wasn't at all obvious.

We already checked that path_len is less than or equal to
_DBUS_MAX_SUN_PATH_LENGTH, which is 99, chosen to be strictly less
than the POSIX minimum sizeof(sun_path) >= 100, so we couldn't
actually be overflowing the available buffer.

The new static assertion in this commit matches a comment above the
definition of _DBUS_MAX_SUN_PATH_LENGTH: we define
_DBUS_MAX_SUN_PATH_LENGTH to 99, because POSIX says struct
sockaddr_un's sun_path member is at least 100 bytes (including space
for a \0 terminator). dbus will now fail to compile on
platforms that are non-POSIX-compliant in this way, except for Windows.

We zeroed the struct sockaddr_un before writing into it, so stopping
one byte short of the end of sun_path ensures that we get \0
termination.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107350
Reviewed-by: Thiago Macieira <thiago@kde.org>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
(cherry picked from commit f429631365)
2018-08-02 17:13:02 +01:00
Simon McVittie
ab8ef4ae31 build: Disable new gcc 8 warning -Wcast-function-type
The foreach(list, (DBusForeachFunction) free, NULL) idiom seems too
entrenched to remove it from stable branches.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107349
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Thiago Macieira <thiago@kde.org>
2018-08-02 17:12:26 +01:00
Simon McVittie
7469b878d5 Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-06-04 17:56:44 +01:00
Simon McVittie
42772170a9 test: Skip TCP tests if getaddrinfo doesn't work
For example, this can be the case in bubblewrap or Debian pbuilder after
unsharing the network namespace:

    bwrap \
    --bind / / \
    --dev-bind /dev /dev \
    --bind /dev/shm /dev/shm \
    --bind /dev/pts /dev/pts \
    --unshare-net \
    ${builddir}/test/test-loopback --tap
    ...
    ok 1 /connect/tcp # SKIP Name resolution does not work here:
    getaddrinfo("127.0.0.1", "0", {flags=ADDRCONFIG, family=INET,
    socktype=STREAM, protocol=TCP}): Name or service not known

On some systems this can be circumvented by using nss_wrapper from
<https://cwrap.org/nss_wrapper.html>:

    cat > hosts <<EOF
    127.0.0.1 localhost
    EOF
    bwrap \
    ... \
    env \
    LD_PRELOAD=libnss_wrapper.so \
    NSS_WRAPPER_HOSTS=$(pwd)/hosts \
    ${builddir}/test/test-loopback --tap
    ...
    # listening at tcp:host=127.0.0.1,port=39219,family=ipv4,guid=...

but for systems where that does't work, we should be prepared to skip
the affected tests.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=106812
(cherry picked from commit f1faafd59b)
2018-06-04 17:56:31 +01:00
Simon McVittie
44027e9ec6 server-oom test: Don't assume localhost is resolvable
Pathological autobuilder environments might not list localhost in
/etc/hosts.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=106812
(cherry picked from commit 4cfc7de30d)
2018-06-04 17:56:04 +01:00
Simon McVittie
d0837e911d test: Test the same things with unix: that we do with tcp:
Minimal autobuilder environments don't always have working TCP,
so we may need to skip TCP tests. Make sure we test the equivalent
code paths via Unix sockets in those environments.

One notable exception is test/fdpass.c, which uses TCP as a transport
that is known not to be able to carry Unix fds; this needs to continue
to use TCP.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=106812
(cherry picked from commit cb7dd5bfcc)
2018-06-04 17:56:04 +01:00
Simon McVittie
102129f86a server-oom test: Parse the address instead of going directly to TCP
This expands test coverage, and lets us reuse the test for other
address schemes.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=106812
(cherry picked from commit b19c9e2f26)
2018-06-04 17:55:58 +01:00
Simon McVittie
8ec0b5ae2d sysdeps-unix: Handle errors from getaddrinfo correctly
getaddrinfo and getnameinfo have their own error-handling convention
in which the library call returns either 0 or an EAI_* error code
unrelated to errno. If the error code is not EAI_SYSTEM, then
the value of errno is undefined (in particular it might be carried
over from a previous system call or library call). Introduce a
new helper function _dbus_error_from_gai() to handle this.

The equivalent code paths in Windows appear to be OK: the Windows
implementation of getaddrinfo() is documented to return a Winsock
error code, which we seem to be handling correctly.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=106395
(cherry picked from commit 60cedd0cfd)
2018-06-04 17:55:21 +01:00
Simon McVittie
6c3e82af25 Start 1.12.10 development
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-04-30 18:38:55 +01:00
Simon McVittie
f8902fa1c8 1.12.8 2018-04-30 13:54:22 +01:00
Simon McVittie
08e48ca660 build: Uninstall JavaScript and CSS from htmldir
Otherwise, distcheck fails when mallard-ducktype is available.

Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 9391d769ae)
2018-04-27 18:18:24 +01:00
Simon McVittie
89526d300c Preallocate release name 2018-04-25 16:58:53 +01:00
Simon McVittie
9f76c4cbee NEWS: Mention non-local TCP too
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 2390a325a0)
2018-04-25 16:49:51 +01:00
Simon McVittie
e1e191f4a6 Update NEWS
(cherry picked from commit ee0e42ae2d)
2018-04-25 16:49:51 +01:00
Simon McVittie
1a03a37005 dbus-daemon(1): Mention and deprecate shared session buses
This might (?) have made sense behind a firewall in 2003; but now it's
2018, the typical threat model that we are defending against has
changed from "vandals want to feel proud of their l33t skills"
to "organised crime wants your money", and a "trusted" local LAN
probably contains an obsolete phone, tablet, games console or
Internet-of-Things-enabled toaster with remote root exploits.
This make network topologies that used to be acceptable look
increasingly irresponsible.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=106004
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
(cherry picked from commit d0a16b59a8)
2018-04-25 16:49:44 +01:00
Simon McVittie
a3a37f8bc2 dbus-daemon(1): Recommend requiring EXTERNAL on non-Windows OSs
This is the default, and blocks TCP-based attacks by making the
attacker fail to authenticate (while also preventing inadvisable
TCP-based configurations from working).

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=106004
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
(cherry picked from commit aef4475939)
2018-04-25 16:48:17 +01:00
Simon McVittie
682ab5e564 dbus-daemon(1): Put some scary warnings on <allow_anonymous/>
I'm far from convinced that this option should even *exist*, but it
should definitely be documented as a very bad thing.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=106004
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
(cherry picked from commit 5d36804867)
2018-04-25 16:48:17 +01:00
Simon McVittie
c1c9ecaa8a dbus-daemon(1): Recommend against remote TCP for debugging
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=106004
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
[smcv: Add a TODO comment as suggested]
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit cf47380641)
2018-04-25 16:48:12 +01:00
Simon McVittie
9bd0256f32 dbus-daemon(1): Say that non-local TCP is insecure
With some fairly reasonable threat models (active or passive local
attacker able to eavesdrop on the network link, confidential
information being transferred via D-Bus), secure authentication is
insufficient to make this transport secure: it does not protect
confidentiality or integrity either.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=106004
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
(cherry picked from commit 2513f84db6)
2018-04-25 16:48:01 +01:00
Simon McVittie
6ea8268c55 Update NEWS for 1.12.x branch
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-04-23 18:00:25 +01:00
Simon McVittie
dbeeaf3ad8 doxygen_to_devhelp: Produce Devhelp index format v2
The old version-1 format is deprecated and now produces warnings.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=106186
Reviewed-by: Philip Withnall <withnall@endlessm.com>
[smcv: Add the .devhelp2 file to .gitignore as suggested]
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit fa92263920)
2018-04-23 17:46:01 +01:00
Simon McVittie
6adba11fdf doxygen_to_devhelp: Make the API reference the front page
The tutorial is not necessarily a great entry point for the libdbus
documentation: it's infrequently updated, and we should probably have
the "If you use this low-level API directly, you're signing up for some
pain" message from the API reference show up in devhelp more immediately.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=106186
Reviewed-by: Philip Withnall <withnall@endlessm.com>
[smcv: Add longer commit message with rationale]
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit c84ac8b1ef)
2018-04-23 17:45:58 +01:00
Simon McVittie
5c3af3b9d1 doc: Install highlight.pack.js if present
Newer versions of yelp-build use this instead of a jQuery syntax
highlighter.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=106171
Reviewed-by: Philip Withnall <withnall@endlessm.com>
[smcv: Also add it to .gitignore as suggested]
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 49ad5b110f)
2018-04-23 17:45:55 +01:00
Simon McVittie
f8f707ef8d doc: Only install ancillary files from yelp-build if they exist
Newer versions of yelp-build don't install jquery.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=106171
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
(cherry picked from commit bab857fb6f)
2018-04-23 17:45:50 +01:00
Simon McVittie
a723baa2bc 1.12.6
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-03-01 18:05:09 +00:00
Simon McVittie
59173203df Clarify NEWS entry with implications of fd.o#105165
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-02-23 10:32:43 +00:00
Simon McVittie
41528cb007 Update NEWS for #105165
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit c62a20624e)
2018-02-20 18:43:29 +00:00
Simon McVittie
180b27035f 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
(cherry picked from commit 49ca421997)
2018-02-20 18:42:53 +00:00
Simon McVittie
650e204b97 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
(cherry picked from commit a146724f2f)
2018-02-20 18:42:48 +00:00
David King
b4a4323c68 bus: raise fd limits before dropping privs
Startup ordering was changed in #92832 to ensure that SELinux audit
messages could be sent. As a side effect, the raising of file descriptor
limits was moved to after the dropping of root privileges, resulting in
the limit change always failing.

Move the raise_file_descriptor_limit() call to ensure that it is called
before dropping root privileges.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=105165
Bug-RedHat: https://bugzilla.redhat.com/show_bug.cgi?id=1529044
[smcv: Call raise_file_descriptor_limit() even if !context->user]
Reviewed-by: Simon McVittie <smcv@collabora.com>

(cherry picked from commit 6e42964f5f)
2018-02-20 18:42:44 +00:00
Simon McVittie
9a2846e105 Start towards 1.12.6
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-02-08 23:37:33 +00:00
Simon McVittie
636963fd75 1.12.4
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-02-08 14:32:18 +00:00
Simon McVittie
518a3a362f Add NEWS for #104925
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 93433970e9)
2018-02-08 14:21:43 +00:00
Philip Withnall
038bd1a190 doc: Fix bracket escaping in Ducktype API design file
There’s no need to escape closing brackets if the paired opening bracket
is escaped (or doesn’t need escaping).

See
https://github.com/projectmallard/mallard-ducktype/issues/16#issuecomment-362590519.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104925
Reviewed-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit ad72d6bc5f)
2018-02-08 14:13:45 +00:00
Simon McVittie
4e7efdb6eb Add NEWS for #102839
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 705db4455d)
2018-02-08 14:11:59 +00:00
Simon McVittie
7065b51527 Add new test for waiting on pending calls in threads
Based on code contributed by Manish Narang. This is not included in the
automated test suite, because it isn't reliable on heavily-loaded
automatic test infrastructure like Travis-CI.

Reviewed-by: Philip Withnall <withnall@endlessm.com>
[smcv: Add the test to the CMake build system too, as requested]
[smcv: Convert into a manual test]
Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=102839
(cherry picked from commit 0b1e292860)
2018-02-07 07:34:35 +00:00
Simon McVittie
3ccad29fba Add a simplified backport of g_steal_pointer()
This will be used in tests later in the branch.

Sadly we can't use GLIB_VERSION_2_44 unless we are willing to have a
hard dependency on GLib 2.44, which would force us to do all our
Travis-CI builds in Docker containers rather than in ye olde base
system, and that adds 50% to the time taken to do builds.

Reviewed-by: Philip Withnall <withnall@endlessm.com>
[smcv: Rebase onto 1.13.x branch, fix minor conflicts]
Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101354
(cherry picked from commit d5742550ca)
2018-02-07 07:34:35 +00:00
Simon McVittie
97d480c09c cmake: Match AC_DEFINE more precisely, respecting [] quoting
The regular expression previously used here to select the second
comma-delimited argument won't work when we introduce an argument
containing a comma, which I need to do now. We can address this by
recognising Autoconf's quoting mechanism (which uses square
brackets).

This is not 100% right (it doesn't understand nested square brackets),
but it's good enough in practice.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Acked-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101354
(cherry picked from commit 83b439f7b4)
2018-02-07 07:34:35 +00:00
Simon McVittie
d4d6cdab99 tests: Add the ability to multiply up test timeouts
Tests that brute-force OOM code paths can be rather slow.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=100317
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 5c91d85f3e)
2018-02-06 19:14:27 +00:00
Simon McVittie
bd31f268e2 test_connect_to_bus: Allow skipping the use of a DBusLoop
DBusLoop isn't thread-safe, so we can't use it to test multi-threaded
situations.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=102839
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
(cherry picked from commit f127c8e110)
[smcv: Adjust for older codebase]
2018-02-06 19:14:27 +00:00
Simon McVittie
3c73f2e8f3 DBusPendingCall: Improve doc-comments around completed flag
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=102839
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
(cherry picked from commit 57a0cf1d14)
2018-02-06 19:14:27 +00:00
Manish Narang
a6e5364d84 DBusPendingCall: Only update ->completed under the connection lock
If one thread is blocking on a pending call, and another thread is
dispatching the connection, then we need them to agree on the value
of the completed flag by protecting all accesses with a lock. Reads
for this member seem to have the connection lock already, so it's
sufficient to make sure that the only write also happens under the
connection lock.

We already set the completed flag before calling the callback, so it
seems OK to stretch it to meaning that some thread has merely *taken
responsibility for* calling the callback.

The completed flag shares a bitfield with timeout_added, but that
flag is protected by the connection lock already.

Based on suggestions from Simon McVittie on
<https://bugs.freedesktop.org/show_bug.cgi?id=102839>.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=102839
[smcv: Revert indentation changes; add commit message]
Reviewed-by: Simon McVittie <smcv@collabora.com>

(cherry picked from commit d3e03eb50e)
2018-02-06 19:14:27 +00:00
Manish Narang
1572ca928b DBusConnection: Pass a pending call around more often
If a pending call is provided, _dbus_connection_do_iteration_unlocked
checks whether it has completed or has a reply ready as soon as it
acquires the I/O path. If that's the case, then the iteration
terminates without trying to carry out I/O, so that the pending call
can be dispatched immediately, without blocking until a timeout is
reached. This change is believed to be necessary, but not sufficient,
to resolve #102839.

Based on part of a patch from Michael Searle on
<https://bugs.freedesktop.org/show_bug.cgi?id=102839>.
Commit message added by Simon McVittie.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=102839
Reviewed-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 30f8a38b3c)
2018-02-06 19:14:27 +00:00
Simon McVittie
47ab11cb42 NEWS: Mention systemd < 237 here too
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 38dea203a5)
2018-01-29 12:01:15 +00:00
Simon McVittie
5663d36454 tmpfiles: Add a note that one line is not needed with newer systemd
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 8fd3073691)
2018-01-29 11:59:51 +00:00
Simon McVittie
25a1926cf8 travis-ci: Get autoconf-archive from Debian 9 'stretch'
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit acb775a92b)
2018-01-29 11:59:50 +00:00
Simon McVittie
7f4d9b0b00 Update NEWS for #104577
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-01-11 12:39:39 +00:00
Chris Lesiak
49c6c61966 Modify systemd tmpfiles.d snippet to create /var/lib/dbus/
This snippet was already attempting to create /var/lib/dbus/machine-id,
but would fail on volatile or stateless systems where /var/lib/dbus/
did not already exist. systemd-tmpfiles automatically creates parent
directories for tmpfiles of type 'd', 'D', etc., but not for files
or symlinks (https://github.com/systemd/systemd/issues/7853).

Signed-off-by: Chris Lesiak <chris.lesiak@licor.com>
[smcv: Extended commit message to clarify why we need this]
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104577
Reviewed-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit aeebf801f1)
2018-01-11 12:36:47 +00:00
Simon McVittie
402b79206c Update NEWS for #104265
Signed-off-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit 67d04ad1aa)
2017-12-14 15:52:53 +00:00