Commit graph

5336 commits

Author SHA1 Message Date
Simon McVittie
005bded7a8 loopback test: Display credentials received
Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103737
Reviewed-by: Philip Withnall <withnall@endlessm.com>
2018-03-02 14:51:54 +00:00
Simon McVittie
948ce614ac DBusCredentials: Add _dbus_clear_credentials()
Not to be confused with _dbus_credentials_clear(), which does something
different (this is a little unfortunate, but the fact that they take
different types should clarify which is which).

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103737
2018-03-02 14:51:51 +00:00
Simon McVittie
2812966f63 credentials: Add test coverage for stringification
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103737
2018-03-02 14:51:48 +00:00
Simon McVittie
de59791882 _dbus_credentials_to_string_append: Remove useless join = FALSE
It can't actually matter in practice, because we never know the
Unix uid and Unix groups but not pid, and we never have a Windows SID
and also a Linux security label; but resetting join to FALSE can only
ever result in us outputting something like "foo=123bar=456" instead
of the intended form with a space in the middle.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103737
2018-03-02 14:51:44 +00:00
Simon McVittie
5efe081fd4 credentials: Add test coverage for groups
Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103737
Reviewed-by: Philip Withnall <withnall@endlessm.com>
2018-03-02 14:51:32 +00:00
Simon McVittie
b6648ca655 sysdeps: Get complete group vector from Linux SO_PEERGROUPS if possible
Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103737
Reviewed-by: Philip Withnall <withnall@endlessm.com>
2018-03-02 14:51:09 +00:00
Simon McVittie
5a07eda31e DBusTransport, DBusConnection: Add internal getter for the credentials
We have a lot of dbus_connection_get_foo() and
_dbus_transport_get_foo() that are actually rather redundant.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103737
2018-03-02 14:51:05 +00:00
Simon McVittie
03c0db9ff5 bus: Also tell systemd before we shut down
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104641
2018-03-02 14:49:15 +00:00
Simon McVittie
c937a39e4b bus: Also tell systemd when we're reloading
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104641
2018-03-02 14:49:11 +00:00
Simon McVittie
18a0a8892b bus: Notify systemd when we are ready
Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104641
Reviewed-by: Philip Withnall <withnall@endlessm.com>
2018-03-02 14:48:49 +00:00
Simon McVittie
be46707673 bus: Don't pass systemd environment variables to activated services
Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104641
Reviewed-by: Philip Withnall <withnall@endlessm.com>
2018-03-02 14:48:24 +00:00
Simon McVittie
454ffd0d0e Start developing 1.13.4
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-03-02 14:47:36 +00:00
Simon McVittie
0b4cbb8fb6 1.13.2
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-03-01 18:15:59 +00:00
Simon McVittie
2154504764 Avoid -Wunused-function for iterate_both_main_loops() without containers
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-03-01 18:15:59 +00:00
Simon McVittie
eebe2476c3 Clarify NEWS entry for #105165
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-02-23 10:33:06 +00:00
Simon McVittie
c62a20624e Update NEWS for #105165
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-02-20 18:40:36 +00:00
Simon McVittie
49ca421997 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
2018-02-20 18:37:30 +00:00
Simon McVittie
a146724f2f 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
2018-02-20 18:34:17 +00:00
David King
6e42964f5f 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>
2018-02-20 17:40:01 +00:00
Simon McVittie
62d59c1a85 Update NEWS for fd.o #101899
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-02-20 17:36:22 +00:00
Simon McVittie
1d1ba5059c test/containers: Test the new header field
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101899
2018-02-16 15:28:06 +00:00
Simon McVittie
624e924284 containers: Add a method to ask to be sent the connection instance header
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101899
2018-02-16 15:27:51 +00:00
Simon McVittie
953bc072a3 DBusMessage: Add a header field for the container instance
In the bus daemon, don't pass through the container instance path:
if there's any value here at all, we want to be able to guarantee that
we sent it (in a later commit).

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101899
2018-02-16 15:27:37 +00:00
Simon McVittie
c6b91129fa bus_transaction_send: Take sender and destination connections
We'll need this if we want to stamp optional header fields on the
message according to the preferences of the recipient(s).

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101899
2018-02-16 15:27:05 +00:00
Simon McVittie
02170d6fa6 Start towards 1.13.2
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-02-08 23:37:01 +00:00
Simon McVittie
ee84f84a3f 1.13.0
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-02-08 14:32:31 +00:00
Simon McVittie
93433970e9 Add NEWS for #104925
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-02-08 14:21:17 +00:00
Philip Withnall
ad72d6bc5f 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>
2018-02-08 14:12:53 +00:00
Simon McVittie
705db4455d Add NEWS for #102839
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-02-08 14:11:26 +00:00
Simon McVittie
0b1e292860 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
2018-02-06 22:36:30 +00:00
Simon McVittie
f127c8e110 test_try_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>
2018-02-06 18:49:02 +00:00
Simon McVittie
57a0cf1d14 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>
2018-02-06 18:48:47 +00:00
Manish Narang
d3e03eb50e 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>
2018-02-06 18:48:35 +00:00
Manish Narang
30f8a38b3c 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>
2018-02-06 18:48:28 +00:00
Simon McVittie
cd97bcd628 Start developing spec v0.33
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-02-01 18:42:06 +00:00
Simon McVittie
4370bee354 Release spec v0.32
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-01-30 15:30:52 +00:00
Simon McVittie
38dea203a5 NEWS: Mention systemd < 237 here too
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-01-29 12:01:09 +00:00
Simon McVittie
8fd3073691 tmpfiles: Add a note that one line is not needed with newer systemd
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-01-29 11:59:40 +00:00
Simon McVittie
acb775a92b travis-ci: Get autoconf-archive from Debian 9 'stretch'
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-01-29 11:55:17 +00:00
Simon McVittie
cb6b6b2bc3 _dbus_credentials_add_from_user: Check return of add_unix_uid
Coverity CID 253543.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104588
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
2018-01-16 14:21:14 +00:00
Simon McVittie
b5c4651b20 Fix unterminated Automake conditional
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-01-15 20:09:35 +00:00
Simon McVittie
6e804baba4 dbus-spawn-unix: Rename from dbus-spawn
This file is the Unix counterpart of dbus-spawn-win.c, so it's less
confusing for it to have an indicative name.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104588
2018-01-15 18:34:56 +00:00
Simon McVittie
d1738d079e dbus-spawn.c: Eliminate trailing whitespace
Otherwise the pre-commit hook won't let me rename it.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104588
2018-01-15 18:34:54 +00:00
Simon McVittie
a0ac652117 Clarify which files are Unix-specific
dbus-spawn.c and dbus-userdb* don't have obviously-Unix-specific names,
but are Unix-specific anyway.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104588
2018-01-15 18:34:28 +00:00
Simon McVittie
2c9d7a6657 NEWS for #104588
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-01-15 14:53:30 +00:00
Simon McVittie
dd451777e3 test: Add a test-case for EXTERNAL auth rejecting usernames
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104588
2018-01-15 14:05:34 +00:00
Simon McVittie
8a4928af76 test: Add a test for authenticating with an empty authorization identity
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104588
2018-01-15 14:05:21 +00:00
Simon McVittie
064c478e14 DBusAuthScript: Make USERNAME_HEX differ from USERID_HEX
Previously, USERID_HEX and USERNAME_HEX were both replaced by the hex
encoding of the numeric uid, something like 31303030 for "1000".
Now USERNAME_HEX is something like 736d6376 for "smcv". This is only
supported on Unix, but no authentication mechanisms use usernames on
Windows anyway.

This would require changing the tests that make use of USERNAME_HEX
if we had any, but we currently don't.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104588
2018-01-15 14:05:15 +00:00
Simon McVittie
356333e4dc _dbus_credentials_add_from_user: Only accept numeric uid for EXTERNAL
In the well-known system dbus-daemon, it's desirable to avoid looking
up non-numeric authorization identities in the user database, because
that could deadlock with NSS modules that directly or indirectly
require the system bus. Add a flag for whether the username will be
looked up in the userdb, and don't set that flag for EXTERNAL auth
(which is what we use on the system bus, and on the session bus
if not configured otherwise).

DBUS_COOKIE_SHA1 authentication is documented in terms of the
username (although in fact libdbus sends a numeric uid there too,
and GDBus only accepts a numeric uid) so continue to use the userdb
for that mechanism. DBUS_COOKIE_SHA1 needs to use the userdb on Unix
anyway, otherwise it won't find the user's home directory.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104588
2018-01-15 14:05:03 +00:00
Simon McVittie
a2932ccc01 _dbus_credentials_add_from_user: Add proper error reporting
While I'm changing its signature anyway, I might as well fix a
long-standing FIXME.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=104588
2018-01-15 14:04:30 +00:00