Commit graph

5066 commits

Author SHA1 Message Date
Simon McVittie
bbbc602318 config-parser: Fail on impossible send_broadcast/send_destination pair
If we add a rule like

    <allow send_destination="com.example" send_broadcast="true"/>

then it cannot possibly match anything, because to be a broadcast, the
message would have to have no destination. The only value of
send_destination that can be combined with send_broadcast="true" is
the wildcard "*", but by this point in the function we already
replaced "*" with NULL.

Adapted from an earlier implementation of send_broadcast by
Alban Crequy.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Bug: https://bugs.freedesktop.org/92853
Reviewed-by: Philip Withnall <withnall@endlessm.com>
2017-09-25 13:37:56 +01:00
Simon McVittie
8f9022e8dc NEWS for fd.o #102686
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-09-25 13:31:54 +01:00
Simon McVittie
4ebc424000 unix: Reduce log level for DBUS_SYSTEM_LOG_INFO to LOG_INFO
This is a better match for the way we use it in practice.

Signed-off-by: Simon McVittie <smcv@debian.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=102686
Reviewed-by: Philip Withnall <withnall@endlessm.com>
2017-09-25 13:29:18 +01:00
Simon McVittie
d82378fd31 Merge branch 'dbus-1.10' 2017-08-15 12:23:15 -04:00
Simon McVittie
4a2e702468 NEWS for #102145 2017-08-15 12:22:27 -04:00
Alan Coopersmith
85c55e0c63 Fix -Werror=declaration-after-statement build failure on Solaris
dbus-sysdeps-unix.c: In function ‘_dbus_read_credentials_socket’:
dbus-sysdeps-unix.c:2061:9: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
         adt_session_data_t *adth = NULL;
         ^

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=102145
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: Simon McVittie <smcv@collabora.com>
2017-08-15 12:21:00 -04:00
Simon McVittie
81966a5252 Update NEWS for fd.o #95264
Signed-off-by: Simon McVittie <smcv@debian.org>
2017-08-15 11:55:38 -04:00
Lennart Poettering
a8dc1ebdae sysdeps: increase listen() backlog of AF_UNIX sockets to SOMAXCONN
Previously, the listen() backlog was set to an arbitrary 30. This means
that if dbus-daemon is overloaded only 30 more connections may be queued
by the kernel, before connect() fails with EAGAIN. (Note that EAGAIN !=
EINPROGRESS -- the latter is what is returned if a connection is queued
and being processed for asynchronous sockets; EAGAIN in this case is
really an error, that cannot be recovered from).

Most software simply sets SOMAXCONN as backlog for AF_UNIX sockets, to
allow queuing of as many connections as the kernel allows. SOMAXCONN is
128 on Linux, which is not particularly high, but at least higher than
30.

This patch changes dbus-daemon to do the same.

I noticed this when flooding dbus-daemon with a lot of connections,
where it pretty quickly ceased to respond, much earlier than it really
should.

Note that the backlog has nothing to do with the number of concurrent
connections allowed, it simply controls how many queued, but not
accept()ed connections there may be on the listening socket.

(cherry picked from commit 12bd6e893c)
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=95264
Bug-Debian: https://bugs.debian.org/872144
Reviewed-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Thiago Macieira <thiago@kde.org>
2017-08-15 11:53:16 -04:00
Simon McVittie
52aeb92f9a tests: Use dbus_clear_connection etc. in a couple of tests
This is just enough to demonstrate that they work - I'm deliberately
not doing a mass change throughout all tests, and we should definitely
not rush to introduce these into production code, because it would
hinder cherry-picking and merging fixes between branches. However,
new code on master can use them freely.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101895
2017-07-30 08:49:22 +01:00
Simon McVittie
e13f29cae7 Implement dbus_clear_connection(), etc.
These are inspired by GLib's g_clear_pointer() and g_clear_object(),
which in turn is descended from CPython's Py_CLEAR_OBJECT. They should
make our code a lot less repetitive.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101895
2017-07-30 08:48:43 +01:00
Simon McVittie
e9974f76a9 build: Clean up DBUS_COOKIE_SHA1 keyrings
We use this directory as the temporary home directory.

Fixes: 3f377c5113
Signed-off-by: Simon McVittie <smcv@debian.org>
2017-07-28 19:38:09 +01:00
Simon McVittie
ddcb812b1f NEWS for #101960 2017-07-28 18:50:08 +01:00
Simon McVittie
3f377c5113 userdb: Respect $HOME for the home directory of our own uid
This lets cooperating processes with the same value of $HOME
interoperate for DBUS_COOKIE_SHA1 by reading and writing $HOME, even
if their $HOME differs from the uid's "official" home directory
according to getpwuid(). Out of paranoia, we only do this if the uid
and the euid are equal, since if they were unequal the correct thing
to do would be ambiguous.

In particular, Debian autobuilders run as a user whose "official"
home directory in /etc/passwd is "/nonexistent", as a mechanism to
detect non-deterministic build processes that rely on the contents of
the home directory. Until now, this meant we couldn't run dbus'
build-time tests, because every test that used DBUS_COOKIE_SHA1 would
fail in this environment.

In the tests, set HOME as well as DBUS_TEST_HOMEDIR. We keep
DBUS_TEST_HOMEDIR too, because Windows doesn't use HOME, only HOMEDRIVE
and HOMEPATH.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101960
Bug-Debian: https://bugs.debian.org/630152
Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
2017-07-28 16:12:24 +01:00
Simon McVittie
94f6c651f8 NEWS for #101848 2017-07-28 11:46:02 +01:00
Simon McVittie
901711e4bf test: Exercise min_fds, max_fds
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-07-28 11:39:22 +01:00
Simon McVittie
b22bdc39fd policy: Add max_fds, min_fds qualifiers for send, receive rules
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101848
Reviewed-by: Thiago Macieira <thiago@kde.org>
[smcv: Revert an incorrect comment change]
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-07-28 11:36:51 +01:00
Simon McVittie
f876edd342 NEWS for #92853 2017-07-28 11:27:24 +01:00
Simon McVittie
7fbc4adcba Add a regression test for applying bus policy to broadcasts/unicasts
This test-case is actually in the test for monitoring the bus,
because it's easier to see what's going on there - the error reply
to a rejected broadcast is not visible unless you are monitoring.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: Thiago Macieira <thiago@kde.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92853
2017-07-28 11:24:20 +01:00
Simon McVittie
7424c3499f Add send_broadcast as an attribute of <allow> and <deny> elements
<allow send_broadcast="true" ...> only matches broadcasts,
which are signals with a NULL destination. There was previously
no way for the policy language to express "NULL destination",
only "any destination".

<allow send_broadcast="false" ...> only matches non-broadcasts,
which are non-signals or signals with a non-NULL destination.
There was previously no way for the policy language to express
"any non-NULL destination", only "any destination".

Reviewed-by: Philip Withnall <withnall@endlessm.com>
[smcv: improved documentation as per Philip's review]
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Thiago Macieira <thiago@kde.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92853
2017-07-28 11:24:20 +01:00
Simon McVittie
2d3f751716 dbus-daemon(1): Document how send_* and receive_* work in general
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Thiago Macieira <thiago@kde.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92853
2017-07-28 11:24:20 +01:00
Simon McVittie
13a155c514 dbus-daemon(1): Be more truthful about the default policy
We don't allow sending unrequested replies, but the documentation
implied that we did.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Thiago Macieira <thiago@kde.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92853
2017-07-28 11:24:20 +01:00
Simon McVittie
ff09f3ba70 dbus-daemon(1): Clarify how user, group rules work
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Thiago Macieira <thiago@kde.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92853
2017-07-28 11:24:20 +01:00
Simon McVittie
c1348e23fe dbus-daemon(1): Actually document "own" rules
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Thiago Macieira <thiago@kde.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92853
2017-07-28 11:24:20 +01:00
Simon McVittie
bc9c63f8f1 dbus-daemon(1): Document the wildcard attribute value "*" more clearly
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Thiago Macieira <thiago@kde.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92853
2017-07-28 11:24:20 +01:00
Simon McVittie
636cccdef7 Add a test-case for combining receive_type and send_destination
Until the previous commit, this would have worked. Now it correctly fails
with "send and receive attributes cannot be combined".

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Thiago Macieira <thiago@kde.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92853
2017-07-28 11:24:20 +01:00
Simon McVittie
9f81acc004 config-parser: Clarify how <allow>, <deny> attributes work
The giant conditionals used to check policy attributes are increasingly
unwieldy, so let's try something else. Bundle together the send_
attributes, the receive_ attributes, the eavesdrop attribute
(which can go on either send or receive rules) and the other attributes
into equivalence classes, and write the conditionals in terms of those
equivalence classes.

In particular, this correctly forbids
    <allow receive_type="..." send_destination="..."/>
which was previously allowed but nonsensical (the send part took
precedence and the receive part was ignored).

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: Thiago Macieira <thiago@kde.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92853
2017-07-28 11:24:20 +01:00
Simon McVittie
ebc8fe8da2 Merge branch 'dbus-1.10' 2017-07-28 11:22:50 +01:00
Simon McVittie
3cf2d6a1ca NEWS for #101858 2017-07-28 11:21:07 +01:00
Simon McVittie
8d8b5eb8a4 config-loader-expat: Tell Expat not to defend against hash collisions
By default, Expat uses cryptographic-quality random numbers as a salt for
its hash algorithm, and since 2.2.1 it gets them from the getrandom
syscall on Linux. That syscall refuses to return any entropy until the
kernel's CSPRNG (random pool) has been initialized. Unfortunately, this
can take as long as 40 seconds on embedded devices with few entropy
sources, which is too long: if the system dbus-daemon blocks for that
length of time, important D-Bus clients like systemd and systemd-logind
time out and fail to connect to it.

We're parsing small configuration files here, and we trust them
completely, so we don't need to defend against hash collisions: nobody
is going to be crafting them to cause pathological performance.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101858
Tested-by: Christopher Hewitt <hewitt@ieee.org>
[smcv: Adjust build-system changes for 1.11.x]
Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
2017-07-28 11:17:04 +01:00
Simon McVittie
1252dc1d1f config-loader-expat: Tell Expat not to defend against hash collisions
By default, Expat uses cryptographic-quality random numbers as a salt for
its hash algorithm, and since 2.2.1 it gets them from the getrandom
syscall on Linux. That syscall refuses to return any entropy until the
kernel's CSPRNG (random pool) has been initialized. Unfortunately, this
can take as long as 40 seconds on embedded devices with few entropy
sources, which is too long: if the system dbus-daemon blocks for that
length of time, important D-Bus clients like systemd and systemd-logind
time out and fail to connect to it.

We're parsing small configuration files here, and we trust them
completely, so we don't need to defend against hash collisions: nobody
is going to be crafting them to cause pathological performance.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101858
Signed-off-by: Simon McVittie <smcv@debian.org>
Tested-by: Christopher Hewitt <hewitt@ieee.org>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
2017-07-28 11:15:51 +01:00
Simon McVittie
b825751505 Start 1.10.24
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-07-27 21:55:32 +01:00
Simon McVittie
962bfdd992 Belatedly bump the libtool versioning
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-07-27 21:24:13 +01:00
Simon McVittie
1d94d3383d Start towards 1.11.18
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-07-27 21:24:04 +01:00
Simon McVittie
9f63efe8f3 1.11.16 2017-07-27 13:57:27 +01:00
Simon McVittie
2f8f4d619b 1.10.22 2017-07-27 13:57:19 +01:00
Simon McVittie
14abb849c5 NEWS
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-07-20 20:36:10 +01:00
Michal Koutný
446b0d9ac7 DBusMainLoop: ensure all required timeouts are restarted
This is a followup of 529600397b. We can't
shortcut the timeouts iteration in order not to miss any timeouts that
might require timestamp restart.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=95619
Reviewed-by: Simon McVittie <smcv@collabora.com>
2017-07-20 20:35:04 +01:00
Simon McVittie
15369dc956 Merge branch 'dbus-1.10' 2017-07-07 13:16:49 +01:00
Simon McVittie
7dc322e633 NEWS for fd.o#101716
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-07-07 13:16:09 +01:00
Simon McVittie
ace54f1358 test/name-test: Be compatible with Python 3
configure.ac will detect PYTHON=python3 if there is no python
executable in the PATH.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101716
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-07-07 13:14:38 +01:00
Simon McVittie
2e8c59d9cc Merge branch 'dbus-1.10' 2017-07-07 10:59:35 +01:00
Simon McVittie
1b0565aca3 NEWS for #101698
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-07-07 10:55:39 +01:00
Simon McVittie
f2f239fc83 tests: Make tests fail if they try to connect to the real session bus
It is too easy for a developer working in an environment that has a
session bus to write tests that pass locally, but fail in minimal
environments. This is also risky because the tests might do
destructive things on the developer's real session bus. We can avoid
connecting to the session bus by consistently removing its address
from the environment, and replacing it with something that will
always fail.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101698
2017-07-07 10:54:14 +01:00
Simon McVittie
8e48532d24 test/dbus-daemon: Unset DBUS_SESSION_BUS_ADDRESS
When we intend to exercise the default behaviour in the absence of
DBUS_SESSION_BUS_ADDRESS (but with an XDG_RUNTIME_DIR present), it would
help if we unset DBUS_SESSION_BUS_ADDRESS. Otherwise we'll just connect
to the real session bus, if there is one.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101698
2017-07-07 10:54:01 +01:00
Simon McVittie
4be6af8563 Update NEWS for fd.o#101700
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-07-06 18:45:34 +01:00
Simon McVittie
68304a47c0 Update NEWS for 1.10 branch
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-07-06 18:43:23 +01:00
Simon McVittie
b2fbffb027 name-test: Backport dbus-run-session wrapper from git master
test-pending-call-disconnected relies on being run under a session bus.
On master, the TESTS in this directory all get that treatment, but
in dbus-1.10 they do not. This caused test-pending-call-disconnected
to fail in minimal environments like travis-ci where there is no
developer-initiated session bus.

Backport part of commit ec6b220 "name-test: run most C tests directly,
not via run-test.sh" to wrap it in dbus-run-session. This is better
than putting it in run-test.sh because this way, its TAP output is
parsed directly by Automake.

It also has the side benefit of exercising dbus-run-session in the
automated 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=101698
2017-07-06 18:34:48 +01:00
Simon McVittie
10b82c3870 system.conf: Allow unprivileged users to get dbus-daemon properties
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101700
2017-07-06 18:31:51 +01:00
Simon McVittie
d999063ade Update NEWS for the various things that ended up in #101568
Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-07-05 17:30:27 +01:00
Simon McVittie
be66708744 test-variant: Add a regression test for DBusVariant
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101568
2017-07-05 16:22:54 +01:00