Commit graph

5164 commits

Author SHA1 Message Date
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
Benedikt Heine
6f0cbee93d Resolve bindir variable in dbus-1.pc file correctly
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104265
Reviewed-by: Simon McVittie <smcv@collabora.com>
(cherry picked from commit d5c2e5539f)
2017-12-14 14:58:47 +00:00
Simon McVittie
fc2ab95515 Merge remote-tracking branch 'github/dbus-1.12' into dbus-1.12 2017-11-28 12:30:32 +00:00
Simon McVittie
9a8428831b _dbus_server_new_for_socket: Iterate over arrays as intended
Commit 0c03b505 was meant to clear all the fds indexed by j in
[0, n_fds), which socket_disconnect() can't be allowed to close
(because on failure the caller remains responsible for closing them);
but instead it closed the one we failed to add to the main loop
(fd i), repeatedly.

Similarly, it was meant to invalidate all the watches indexed by j
in [i, n_fds) (the one we failed to add to the main loop and the ones
we didn't try to add to the main loop yet), which socket_disconnect()
can't be allowed to see (because it would fail to remove them from
the main loop and hit an assertion failure); but instead it invalidated
fd i, repeatedly.

These happen to be the same thing if you only have one fd, resulting
in the test-case passing on an IPv4-only system, but failing on a
system with both IPv4 and IPv6.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89104
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
(cherry picked from commit c9aa00ce73)
2017-11-27 19:48:36 +00:00
Simon McVittie
f634f16984 NEWS for 1.12.x
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-11-24 19:14:34 +00:00
Simon McVittie
3e245e15d6 Add a targeted test for OOM during _dbus_server_new_for_tcp_socket()
This also covers _dbus_server_new_for_socket(), which is one of the
worse places in terms of complexity of the error-unwinding path
(3 labels).

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89104
(cherry picked from commit ac6c4d384d)
2017-11-24 13:48:15 +00:00
Simon McVittie
c393aefb34 _dbus_listen_tcp_socket: Don't rely on dbus_realloc setting errno
dbus_realloc() doesn't guarantee to set errno (if it did, the
only reasonable thing it could set it to would be ENOMEM). In
particular, faking OOM conditions doesn't set it. This can cause an
assertion failure when OOM tests assert that the only error that can
validly occur is DBUS_ERROR_NO_MEMORY.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89104
(cherry picked from commit 9ded6907e6)
2017-11-24 13:42:27 +00:00
Simon McVittie
d166252a8d _dbus_server_new_for_socket: Properly disconnect during error unwinding
_dbus_server_finalize_base() asserts that the socket has been
disconnected, but in some OOM code paths we would call it without
officially disconnecting. Do so.

This means we need to be a bit more careful about what is
socket_disconnect()'s responsibility to clean up, what is
_dbus_server_new_for_socket()'s responsibility, and what is the caller's
responsibility.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89104
(cherry picked from commit 0c03b505a9)
2017-11-24 13:16:30 +00:00
Simon McVittie
58c9a56dbb _dbus_server_new_for_socket: Invalidate watches during error unwinding
We assert that every watch is invalidated before it is freed, but
in some OOM code paths this didn't happen.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89104
(cherry picked from commit 1ce34beef8)
2017-11-24 13:16:17 +00:00
Simon McVittie
a1121674a7 Update NEWS for 1.12.x
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-11-14 12:25:58 +00:00
Thomas Zajic
64a5ba63be Add a missing space in logging output
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103729
(cherry picked from commit c9ce0a7059)
2017-11-14 12:24:40 +00:00
Simon McVittie
7f92c3cfcf Start 1.12.4
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-11-13 17:11:27 +00:00
Simon McVittie
0f0968336b 1.12.2
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-11-13 13:35:55 +00:00
Simon McVittie
06c105545f Update NEWS for 1.12.x
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-11-10 16:24:59 +00:00
Simon McVittie
1a29dc8544 bus_connections_setup_connection: If we can't set it up, log why
While reviewing fd.o#101354, Philip Withnall pointed out that if we
rejected a connection in the new code there, we didn't log why. It
turns out we didn't log that in the more normal code path either.
Redo the error handling so that failure to set up a connection
is logged.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103592
(cherry picked from commit 56847ae818)
2017-11-10 16:22:20 +00:00
Simon McVittie
35238ed567 Update NEWS for 1.12.x
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-11-10 16:20:02 +00:00
Simon McVittie
b672a683be travis-ci: Enable/disable more features in various builds
In the debug build, enable features that are off by default. In the
reduced build, explicitly disable features, some of which are
on by default. In the legacy build, check that we can compile the
default feature-set without inotify, dnotify, systemd, etc.

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 3c031ef5aa)
2017-11-10 16:10:15 +00:00
Simon McVittie
a208e02421 _dbus_accept_with_noncefile: Don't leak nonce
This was always leaked, both on success and on error.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103597
(cherry picked from commit 37d5af203c)
2017-11-07 11:43:37 +00:00
Simon McVittie
d000891624 do_noncefile_create: Avoid freeing uninitialized memory on error
We could free all of these without having ever successfully
initialized them.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103597
(cherry picked from commit 6d08f5c04e)
2017-11-07 11:43:34 +00:00
Simon McVittie
208af9a447 do_check_nonce: Don't free uninitialized memory on OOM
If _dbus_string_init() fails, it doesn't guarantee that the string
is initialized to anything in particular. Worse, if
_dbus_string_init (&buffer) fails, p would never have been initialized
at all, due to the use of the short-circuiting || operator.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103597
(cherry picked from commit 0ea0e4b0fd)
2017-11-07 11:43:31 +00:00
Simon McVittie
b5d1585b0f Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-10-31 13:07:03 +00:00
Tony Theodore
47d2e5a345 build: Avoid using echo -e
`echo -e` is a GNU extension, and in particular not available on
Darwin.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103493
[smcv: Added commit message]
Reviewed-by: Simon McVittie <smcv@collabora.com>

(cherry picked from commit 216ae1adfc)
2017-10-31 13:06:55 +00:00
Simon McVittie
d6eb0039c1 Update NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-10-31 11:40:56 +00:00
ilovezfs
c416bb37dd build: Use $(MKDIR_P) syntax suitable for install-sh
This fixes the build when a GNU-compatible `mkdir -p` is not available.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103521
[smcv: Add commit message]
Reviewed-by: Simon McVittie <smcv@collabora.com>

(cherry picked from commit c7d8b723eb)
2017-10-31 11:40:52 +00:00
Simon McVittie
b299a226b3 Bump version for 1.12.x branch
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-10-30 14:49:59 +00:00
Simon McVittie
98294ab81a Prepare 1.12.0
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-10-30 12:37:23 +00:00
Simon McVittie
93efaf7873 Disable deprecation warnings for stable branch
We're not going to replace deprecated functions here, similar to commit
88e0ccb2 in the dbus-1.10 branch.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-10-30 12:31:03 +00:00
Simon McVittie
d5746922de NEWS for #103420
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-10-23 16:10:39 +01:00
Simon McVittie
1e8c52c647 build: Remove various unused files from build system
These were in git but not distributed in source tarballs, and in fact
not hooked up to the Autotools build system at all.
test/data/valid-introspection-files was mentioned in the CMake build
system (copied from the source directory to the build directory), but
according to `git grep` is not used for anything.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103420
2017-10-23 16:08:32 +01:00