Commit graph

5359 commits

Author SHA1 Message Date
Ralf Habacker
39efd6ebdd Add version info to installed executables for cmake build system on Windows
Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
Reviewed-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103387
2018-03-12 19:47:28 +01:00
Ralf Habacker
64a1d59b3d Windows _dbus_connect_tcp_socket_with_nonce: Simplify initialization of variable noncefileStr
This optimization has been detected while comparing the related unix
implemention.

Reviewed-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-12 18:38:19 +01:00
Ralf Habacker
9d1cdce2b4 Remove obsolete call to _dbus_string_free() in unix variant of _dbus_connect_tcp_socket_with_nonce
A DBusString that was initialized with a constant doesn't hold any
allocated memory, so it doesn't need to be freed.

Reviewed-by: Simon McVittie <smcv@collabora.com>
https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-12 18:38:13 +01:00
Ralf Habacker
a0ac4c4022 Windows _dbus_listen_tcp_socket: Set socket options SO_REUSEADDR and TCP_NODELAY
Reviewed-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-12 18:38:03 +01:00
Ralf Habacker
98a5011b81 Windows _dbus_listen_tcp_socket: Use AF_UNSPEC if family is unspecified
Now that we cope with getting WSAEADDRNOTAVAIL when trying to listen on
::1 with IPv6 disabled, and gracefully fall back to only listening on
127.0.0.1, we can use AF_UNSPEC like the corresponding Unix code does.

Reviewed-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-12 18:37:54 +01:00
Ralf Habacker
bbf1cb70a5 Windows _dbus_connect_tcp_socket_with_nonce: Keep error code for 'Unknown address family' in sync with unix
Reviewed-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-12 18:37:43 +01:00
Ralf Habacker
3c5d2eda0d Windows _dbus_connect_tcp_socket_with_nonce: Combine all connect() errors
Previously, we took the errno from the most recent connect() error,
and used a more generic diagnostic message.

Reviewed-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-12 18:37:35 +01:00
Ralf Habacker
cc7efde510 Windows _dbus_listen_tcp_socket: Treat bind() failures as non-fatal
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
Reviewed-by: Simon McVittie <smcv@collabora.com>
2018-03-12 15:01:24 +01:00
Simon McVittie
6c5be2e146 Unix _dbus_connect_tcp_socket_with_nonce: Combine all connect() errors
Previously, we took the errno from the most recent connect() error,
and used a more generic diagnostic message.

Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Signed-off-by: Simon McVittie <smcv@collabora.com>
https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-10 12:14:52 +01:00
Simon McVittie
23fb280143 Unix _dbus_connect_tcp_socket_with_nonce: Always goto out
This will make it easier to do single-exit-path cleanup.

Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Signed-off-by: Simon McVittie <smcv@collabora.com>
https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-10 12:14:45 +01:00
Simon McVittie
ff359872b9 sysdeps-unix: Treat bind() failures as non-fatal
When we use AF_UNSPEC, we are likely to get multiple addresses back
from getaddrinfo(), and perhaps we won't be able to use them all.
Give that failure mode, or any other bind() failure, the same treatment
as EADDRINUSE failures here and all connect() failures in
_dbus_connect_tcp_socket_with_nonce(): if any address succeeds, then
the overall operation succeeds, but if all of them fail, then the
overall operation fails.

I've made _dbus_combine_tcp_errors() generic enough that
_dbus_connect_tcp_socket_with_nonce() could use it too, although that
isn't implemented here.

Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
[smcv: Adjust commit message]
Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-09 12:28:27 +00:00
Simon McVittie
e894c94562 sysdeps-unix: Set more specific IP-related errors when listening
When we have resolved a hostname/port pair to a list of IPv4 or IPv6
addresses, if we are unable to listen on a a specific one of those
addresses, we should report which one.

When IPv6 is disabled for the loopback interface, this changes the
diagnostic from:

Failed to bind socket "localhost:1234": Cannot assign requested address

to the more informative

Failed to bind socket "::1" port 1234: Cannot assign requested address

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-09 12:27:31 +00:00
Simon McVittie
abb4d1a87b _dbus_append_address_from_socket: Factor out inet_sockaddr_to_string
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-09 12:27:04 +00:00
Simon McVittie
83549e28ec Windows: Target Windows Vista or higher
This will give us the RFC-2553 inet_ntop() interface.
Windows Vista extended security support ended in 2017, but we don't
actually need anything from versions newer than Vista yet.

Loosely based on part of a patch by Ralf Habacker.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-09 12:26:08 +00:00
Simon McVittie
dc15de1f7b _dbus_get_low_level_socket_errno: Add
Some libdbus functions have as their API "this function sets errno",
but that just leads to strangeness on Windows, where socket (Winsock)
functions don't actually set errno themselves, leading to those
functions having to copy the Winsock error into errno to fake the
Unix-like behaviour. With hindsight, that was probably a bad idea.

This function should be portable enough to be used with functions that
are essentially the same on Unix and Windows, like inet_ntop().

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-09 12:25:46 +00:00
Simon McVittie
a97b6b597b _dbus_append_address_from_socket: Correct misleading error message
If what actually failed was reading the address from the socket,
we might as well say so.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-09 12:25:36 +00:00
Simon McVittie
1d85b229b3 _dbus_append_address_from_socket: Make control flow clearer
In the current implementation, we can reach the "err" label either
because we ran out of memory, or because we got a socket error from
getsockname() or inet_ntop(), and we blindly assume that running out
of memory will set ENOMEM.

However, that isn't actually true: when we are simulating OOM in
dbus_malloc(), the fake OOM doesn't set ENOMEM. Handle the OOM
condition explicitly instead.

In the AF_UNIX case, the break statement is no longer reached at all,
so leave a comment there. In the AF_INET and AF_INET6 cases, if
inet_ntop() fails, explicitly goto err instead of using break
(this has the same practical effect) to make it clearer that we are
going to the "socket error" code path.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61922
2018-03-09 12:25:05 +00:00
Laurent Bigonville
8a4e07925c Add _dbus_clear_loop and _dbus_clear_watch
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92831
[smcv: Fix variable names]
Reviewed-by: Simon McVittie <smcv@collabora.com>
2018-03-06 12:38:29 +00:00
Simon McVittie
dd9f24794b Update NEWS for fd.o #103737, #104641
Signed-off-by: Simon McVittie <smcv@collabora.com>
2018-03-02 15:17:38 +00:00
Simon McVittie
52594df070 bus driver: Use DBusCredentials to fill credentials structure
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:52:20 +00:00
Simon McVittie
fbc2a447c4 sysdeps: Document what _dbus_credentials_new_from_current_process has
It only has the most important credentials, not the full set.

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:52:18 +00:00
Simon McVittie
395269e0bc bus: Get loginfo string bits from DBusCredentials
This saves a couple of _dbus_strdup/dbus_free pairs.

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:52:17 +00:00
Simon McVittie
aaf690e805 bus: Try to get groups directly from credentials, not userdb
If we avoid consulting the userdb, then it's one less chance to
deadlock.

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:52:06 +00:00
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