platform/upstream/dbus.git
9 years agotest_processid: only assert that it works if we expect it to work
Simon McVittie [Mon, 15 Sep 2014 17:38:49 +0000 (18:38 +0100)]
test_processid: only assert that it works if we expect it to work

Otherwise, this would fail on, for instance, QNX.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69702
Reviewed-by: Patrick Welche <prlw1@cam.ac.uk>
Reviewed-by: Alban Crequy <alban.crequy@collabora.co.uk>
Tested-by: Patrick Welche <prlw1@cam.ac.uk>
9 years agowhitespace/comment fixes
Patrick Welche [Thu, 30 Oct 2014 12:39:26 +0000 (12:39 +0000)]
whitespace/comment fixes

[originally part of the previous commit -smcv]

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69702
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Alban Crequy <alban.crequy@collabora.co.uk>
9 years agoImplement NetBSD credentials-passing with LOCAL_PEEREID
Patrick Welche [Tue, 29 Jul 2014 13:08:20 +0000 (14:08 +0100)]
Implement NetBSD credentials-passing with LOCAL_PEEREID

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69702
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Alban Crequy <alban.crequy@collabora.co.uk>
Tested-by: Patrick Welche <prlw1@cam.ac.uk>
9 years agodbus-daemon test: don't assert we pass uid/pid on unknown Unix platforms
Simon McVittie [Mon, 15 Sep 2014 17:04:36 +0000 (18:04 +0100)]
dbus-daemon test: don't assert we pass uid/pid on unknown Unix platforms

We know that Linux, FreeBSD and OpenBSD are "first class citizens"
for credentials-passing, with NetBSD not far behind: people have
turned up on the bug tracking system and told us that tests passed.
On other Unixes, we can't really assert that it works, until someone
who runs them tells us that it worked for them.

Additions to these lists are welcome.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69702
Reviewed-by: Patrick Welche <prlw1@cam.ac.uk>
Reviewed-by: Alban Crequy <alban.crequy@collabora.co.uk>
Tested-by: Patrick Welche <prlw1@cam.ac.uk>
9 years agoNEWS
Simon McVittie [Wed, 29 Oct 2014 14:21:19 +0000 (14:21 +0000)]
NEWS

9 years agodbus-spawn: do not forget the exec() errno when the grandchild exits
Simon McVittie [Thu, 11 Sep 2014 09:59:32 +0000 (10:59 +0100)]
dbus-spawn: do not forget the exec() errno when the grandchild exits

As is already noted in a comment in
_dbus_babysitter_set_child_exit_error(), if the grandchild fails
to exec() the desired process, we get both CHILD_EXEC_FAILED (with
an errno) and CHILD_EXITED (with a status), and we want to report
the former, since it is more informative. However, clearing
sitter->errnum meant we lose the errno value.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=24821
Reviewed-by: Ross Lagerwall
9 years agodbus-tutorial: replace the entire GLib section with "use GDBus"
Simon McVittie [Wed, 10 Sep 2014 12:53:39 +0000 (13:53 +0100)]
dbus-tutorial: replace the entire GLib section with "use GDBus"

Also provide links to relevant GLib and Qt documentation.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=25140

9 years agoStop asserting that we're not using the dummy lock implementation
Simon McVittie [Wed, 8 May 2013 15:58:08 +0000 (16:58 +0100)]
Stop asserting that we're not using the dummy lock implementation

That implementation no longer exists, so neither 0xABCDEF nor 0xABCDEF2
has any special meaning any more.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54972
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Alban Crequy <alban.crequy@collabora.co.uk>
9 years agoUse a better NoReply message for disconnection with reply pending
Simon McVittie [Wed, 29 Oct 2014 14:10:48 +0000 (14:10 +0000)]
Use a better NoReply message for disconnection with reply pending

As an implementation detail, dbus-daemon handles this situation by
artificially triggering a timeout (even if its configured timeout for
method calls is in fact infinite). However, using the same debug message
for both is misleading, and can lead people who are debugging a service
crash to blame dbus-daemon instead, wasting their time.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=76112

9 years agodbus-sysdeps-unix: document the assumption that makes our use of credentials secure
Simon McVittie [Thu, 11 Sep 2014 12:08:21 +0000 (13:08 +0100)]
dbus-sysdeps-unix: document the assumption that makes our use of credentials secure

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83499
Reviewed-by: Alban Crequy <alban.crequy@collabora.co.uk>
9 years agoConsistently save and restore errno
Simon McVittie [Mon, 8 Sep 2014 19:18:22 +0000 (20:18 +0100)]
Consistently save and restore errno

Some functions in dbus-transport-socket.c make a (wrapped)
socket syscall, then call other APIs, then test the result and
errno of the socket syscall.

This would break horribly if those "other APIs" overwrote errno with
their own value (... and this is part of why errno is an awful API).

Notably, if running under DBUS_VERBOSE, _dbus_verbose() is basically
fprintf(), which sets errno; and our Unix fd-passing support
makes calls of the form _dbus_verbose ("Read/wrote %i unix fds\n", n)
between the syscall and the result processing.

Maybe one day we'll convert all of dbus' syscall wrappers to either
raise a DBusError, or use the "negative errno" convention that systemd
borrowed from the Linux kernel, and in particular, we would need to
do that if we ever ported it to a platform where socket error reporting
was not basically errno. However, in practice everyone uses something
derived from BSD sockets, so "this sets errno, you know what errno is"
is a good enough internal API if we make sure to use it correctly.

Nothing calls _dbus_get_is_errno_nonzero(), so I just removed it instead
of converting it to the new calling convention.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83625

9 years agoNEWS
Simon McVittie [Wed, 29 Oct 2014 13:59:24 +0000 (13:59 +0000)]
NEWS

9 years agoImplement getter, setter for ALLOW_INTERACTIVE_AUTHORIZATION flag
Simon McVittie [Thu, 25 Sep 2014 12:29:50 +0000 (13:29 +0100)]
Implement getter, setter for ALLOW_INTERACTIVE_AUTHORIZATION flag

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83449
Reviewed-by: Lennart Poettering
9 years agobuild: include dbus-sysdeps-unix.h for _dbus_fd_set_close_on_exec
Patrick Welche [Tue, 28 Oct 2014 15:31:58 +0000 (15:31 +0000)]
build: include dbus-sysdeps-unix.h for _dbus_fd_set_close_on_exec

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=85563
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agodbus-spec, dbus-protocol: add ALLOW_INTERACTIVE_AUTHORIZATION flag
Simon McVittie [Thu, 25 Sep 2014 12:19:24 +0000 (13:19 +0100)]
dbus-spec, dbus-protocol: add ALLOW_INTERACTIVE_AUTHORIZATION flag

Heavily based on a patch from Lennart Poettering.

This is useful for authentication frameworks such as polkit, but this
flag is supposed to be generic, and not be bound to any implementation
of such a framework.

The dbus specification already clarifies that unknown flags must be
ignored, the reference implementation and the other implementations we
checked indeed ignore any new flags, hence we should be fine with
compatibility here.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83449

9 years agoInclude test-dbus and test-bus in cmake 'make check' target.
Ralf Habacker [Tue, 14 Jan 2014 17:59:18 +0000 (18:59 +0100)]
Include test-dbus and test-bus in cmake 'make check' target.

Because test-dbus and test-bus lives in subdirectory dbus/bus, we need
to define make 'check' in top level source directory.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=73689
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agotest-bus, test-dbus: close any inherited fds from caller
Simon McVittie [Fri, 24 Oct 2014 12:41:13 +0000 (13:41 +0100)]
test-bus, test-dbus: close any inherited fds from caller

It is probably a bug for them to pass us any fds without close-on-exec;
but apparently CMake has this bug, and so does at least some NetBSD GUI
environment. Cope.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=73689
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83899
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
9 years agocmake: only copy session.conf and system.conf into test data dir
Simon McVittie [Fri, 24 Oct 2014 12:42:57 +0000 (13:42 +0100)]
cmake: only copy session.conf and system.conf into test data dir

Historically, CMake used the glob *.conf.in whereas Autotools listed
the files explicitly. This used to be equivalent, but broke down
when we added example-*.conf.in which are just snippets rather than
complete configuration files (they're intended to go in session.d
or system.d, or otherwise get included by the main config file).

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=73689
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
9 years agoAdd configure checks for accept4, dirfd, inotify_init1 and unix_fd_passing to cmake...
Ralf Habacker [Fri, 17 Oct 2014 13:42:06 +0000 (15:42 +0200)]
Add configure checks for accept4, dirfd, inotify_init1 and unix_fd_passing to cmake build system.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=73689
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agoAdd configure check for pipe2 to cmake build system.
Ralf Habacker [Tue, 14 Oct 2014 14:18:54 +0000 (16:18 +0200)]
Add configure check for pipe2 to cmake build system.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=73689
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agoNEWS
Simon McVittie [Tue, 14 Oct 2014 13:12:14 +0000 (14:12 +0100)]
NEWS

9 years agodbus-test-tool: add black-hole mode
Alban Crequy [Wed, 2 Jul 2014 13:18:26 +0000 (14:18 +0100)]
dbus-test-tool: add black-hole mode

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=34140
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agodbus-test-tool spam: add --messages-per-conn=N
Alban Crequy [Wed, 2 Jul 2014 15:36:44 +0000 (16:36 +0100)]
dbus-test-tool spam: add --messages-per-conn=N

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=34140
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agoAdd dbus-test-tool, currently with "echo" and "spam" modes
Alban Crequy [Mon, 26 Sep 2011 10:02:59 +0000 (11:02 +0100)]
Add dbus-test-tool, currently with "echo" and "spam" modes

This is installed by default, but easy to filter out for embedded systems
or whatever.

Based on earlier work by Simon McVittie and Will Thompson

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=34140
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agodbus_shutdown: document its effect on shared connections
Simon McVittie [Wed, 10 Sep 2014 15:20:52 +0000 (16:20 +0100)]
dbus_shutdown: document its effect on shared connections

In practice, the sort of applications that call dbus_shutdown()
(e.g. regression tests) will want to either use private connections,
or turn off exit-on-disconnect on the shared connection, or both.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=16924

9 years agoDo not claim that '*' resolves to INADDR_ANY on all OSs
Simon McVittie [Thu, 11 Sep 2014 14:05:25 +0000 (15:05 +0100)]
Do not claim that '*' resolves to INADDR_ANY on all OSs

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=72296

9 years agoNEWS
Simon McVittie [Mon, 13 Oct 2014 12:58:06 +0000 (13:58 +0100)]
NEWS

9 years agospec: introduce new value "const" for EmitsChangedSignal annotation
Lennart Poettering [Sun, 22 Dec 2013 01:35:13 +0000 (02:35 +0100)]
spec: introduce new value "const" for EmitsChangedSignal annotation

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=72958
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agoNEWS
Simon McVittie [Mon, 13 Oct 2014 12:52:12 +0000 (13:52 +0100)]
NEWS

9 years agoLet pkg-config expand directory variables recursively
Руслан Ижбулатов [Sat, 8 Mar 2014 07:34:35 +0000 (07:34 +0000)]
Let pkg-config expand directory variables recursively

In particular this makes them more MinGW-friendly: pkg-config on Windows
has specific code to rewrite the ${prefix} when installed in a
different prefix.

[add @datarootdir@, expand commit message -smcv]

Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=75858

9 years agoNEWS, bump spec version to (unreleased) 0.25
Simon McVittie [Mon, 6 Oct 2014 11:27:36 +0000 (12:27 +0100)]
NEWS, bump spec version to (unreleased) 0.25

9 years agospec: translate arbitrary limits into something more comprehensible
Simon McVittie [Wed, 24 Sep 2014 16:44:31 +0000 (17:44 +0100)]
spec: translate arbitrary limits into something more comprehensible

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=84188
Reviewed-by: Lennart Poettering
9 years agospec: in the table of types, classify them
Simon McVittie [Wed, 24 Sep 2014 16:44:03 +0000 (17:44 +0100)]
spec: in the table of types, classify them

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=84188
Reviewed-by: Lennart Poettering
9 years agoStart 1.9.2, update NEWS
Simon McVittie [Mon, 6 Oct 2014 11:17:07 +0000 (12:17 +0100)]
Start 1.9.2, update NEWS

9 years agoGetAllMatchRules: provide an example how it could be used
Alban Crequy [Thu, 2 Oct 2014 13:21:24 +0000 (14:21 +0100)]
GetAllMatchRules: provide an example how it could be used

[use dist_examples_SCRIPTS instead of EXTRA_DIST -smcv]

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=84598
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years ago1.9.0
Simon McVittie [Wed, 1 Oct 2014 18:35:08 +0000 (19:35 +0100)]
1.9.0

9 years agoconfig: add examples to show how to enable/disable the Stats interface
Alban Crequy [Fri, 26 Sep 2014 10:26:32 +0000 (11:26 +0100)]
config: add examples to show how to enable/disable the Stats interface

[install examples to ${docdir}/examples -smcv]

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=80759
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agoEnable Stats interface by default; disallow non-root use on system bus
Simon McVittie [Fri, 5 Sep 2014 14:15:14 +0000 (15:15 +0100)]
Enable Stats interface by default; disallow non-root use on system bus

[fix typo in interface name -alban]

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=80759
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agodbus-launch: Fix typo in manpage
Sebastian Rasmussen [Thu, 25 Sep 2014 07:29:00 +0000 (09:29 +0200)]
dbus-launch: Fix typo in manpage

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=84313
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agoUse ISO C strchr() instead of BSD index()
Simon McVittie [Thu, 25 Sep 2014 10:46:39 +0000 (11:46 +0100)]
Use ISO C strchr() instead of BSD index()

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=24307

9 years agomatch_rule_to_string: add test
Alban Crequy [Wed, 24 Sep 2014 15:29:21 +0000 (16:29 +0100)]
match_rule_to_string: add test

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=24307
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agomatch_rule_to_string: fix escaping
Alban Crequy [Wed, 24 Sep 2014 15:28:56 +0000 (16:28 +0100)]
match_rule_to_string: fix escaping

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=24307
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agomatch_rule_to_string: returns NULL if no memory instead of looping
Alban Crequy [Wed, 24 Sep 2014 13:15:44 +0000 (14:15 +0100)]
match_rule_to_string: returns NULL if no memory instead of looping

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=24307
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agoStats: GetAllMatchRules: add tests
Alban Crequy [Tue, 23 Sep 2014 17:51:47 +0000 (18:51 +0100)]
Stats: GetAllMatchRules: add tests

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=24307
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agoImplement GetAllMatchRules on the Stats interface
Alban Crequy [Mon, 30 Jun 2014 12:44:58 +0000 (13:44 +0100)]
Implement GetAllMatchRules on the Stats interface

Usage:

$ dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus \
      org.freedesktop.DBus.Debug.Stats.GetAllMatchRules
method return sender=org.freedesktop.DBus -> dest=:1.13 reply_serial=2
   array [
      dict entry(
         string ":1.4"
         array [
         ]
      )
      dict entry(
         string ":1.9"
         array [
            string "type='signal',interface='org.freedesktop.DBus',member='NameOwnerChanged'"
         ]
      )
      dict entry(
         string ":1.11"
         array [
            string "eavesdrop='true'"
         ]
      )
   ]

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=24307
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agoDescribe quoting for match rules
Simon McVittie [Wed, 24 Sep 2014 16:43:35 +0000 (17:43 +0100)]
Describe quoting for match rules

I wish I could say "I can't believe this was never documented", but
it wouldn't be true.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=24307
Reviewed-by: Alban Crequy
9 years agoFix test suite fails on test-dbus with --enable-tests (but no assertions).
Ralf Habacker [Wed, 24 Sep 2014 21:23:31 +0000 (23:23 +0200)]
Fix test suite fails on test-dbus with --enable-tests (but no assertions).

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83968
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agoExpand documentation of NO_REPLY_EXPECTED
Simon McVittie [Tue, 23 Sep 2014 16:43:30 +0000 (17:43 +0100)]
Expand documentation of NO_REPLY_EXPECTED

The message type is more important than whether NO_REPLY_EXPECTED is
set, when deciding whether a reply is expected. This documents
existing practice in at least libdbus, GDBus and dbus-daemon.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=75749
Reviewed-by: Thiago Macieira
9 years agoinotify: make sure we set the close-on-exec flag
Simon McVittie [Tue, 23 Sep 2014 18:25:31 +0000 (19:25 +0100)]
inotify: make sure we set the close-on-exec flag

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=73689
Reviewed-by: Ralf Habacker
[add <dbus/dbus-sysdeps-unix.h> which is now required for
_dbus_fd_set_close_on_exec -smcv]

9 years agoBuild test-bus-system with cmake on non win32 platforms.
Ralf Habacker [Wed, 17 Sep 2014 08:09:33 +0000 (10:09 +0200)]
Build test-bus-system with cmake on non win32 platforms.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83583
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agoNew test for fd-passing
Simon McVittie [Wed, 17 Sep 2014 16:19:53 +0000 (17:19 +0100)]
New test for fd-passing

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83622
Reviewed-by: Alban Crequy <alban.crequy@collabora.co.uk>
[add dbus-sysdeps-unix.h as required for close-on-exec in master -smcv]

9 years agoMerge branch 'dbus-1.8'
Simon McVittie [Tue, 16 Sep 2014 16:50:14 +0000 (17:50 +0100)]
Merge branch 'dbus-1.8'

Conflicts:
NEWS
configure.ac

9 years ago1.8.9
Simon McVittie [Tue, 16 Sep 2014 16:47:46 +0000 (17:47 +0100)]
1.8.9

9 years agoNEWS for 1.9
Simon McVittie [Mon, 15 Sep 2014 16:44:55 +0000 (17:44 +0100)]
NEWS for 1.9

9 years agodbus-monitor: more details on file descriptors
Alban Crequy [Fri, 27 Jun 2014 15:25:23 +0000 (16:25 +0100)]
dbus-monitor: more details on file descriptors

Print more details when receiving a file descriptor.

Before:
   unix fd 5

After:
   file descriptor
         inode: 1030
         type: char
   file descriptor
         inode: 295664
         type: socket
         address family: unknown (16)
   file descriptor
         inode: 295665
         type: socket
         address family: inet
         name 127.0.0.1 port 47723
         peer 127.0.0.1 port 22
   file descriptor
         inode: 295666
         type: socket
         address family: unix
         name @/tmp/d67s774Sws0pEra
   file descriptor
         inode: 295667
         type: socket
         address family: unix
         name @
         peer @

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=80603
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agodbus-monitor: do not leak file descriptors from fd-passing
Alban Crequy [Fri, 27 Jun 2014 15:33:39 +0000 (16:33 +0100)]
dbus-monitor: do not leak file descriptors from fd-passing

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=80603
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agoPrepare 1.8.8 (embargoed until tomorrow)
Simon McVittie [Mon, 15 Sep 2014 11:43:04 +0000 (12:43 +0100)]
Prepare 1.8.8 (embargoed until tomorrow)

9 years agoFix installation of empty directories for cmake build system.
Ralf Habacker [Fri, 8 Aug 2014 20:02:08 +0000 (22:02 +0200)]
Fix installation of empty directories for cmake build system.

The differences has been found out by comparing with the cross compiled
mingw..-dbus packages.

[exclude system bus support bits on Windows -smcv]

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83583
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agoMake various system-bus-related things Unix-only
Simon McVittie [Thu, 11 Sep 2014 16:37:49 +0000 (17:37 +0100)]
Make various system-bus-related things Unix-only

There is no system bus on Windows, and there won't be until/unless
it can be secure.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83583
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
9 years agoSplit _dbus_fd_set_close_on_exec into Unix and Windows versions
Simon McVittie [Thu, 11 Sep 2014 11:04:04 +0000 (12:04 +0100)]
Split _dbus_fd_set_close_on_exec into Unix and Windows versions

On Unix, the thing that can be made close-on-exec is a file descriptor,
which is an int.

On Windows, the thing that can be made close-on-exec is a HANDLE,
which is pointer-sized (but not necessarily a pointer!). In practice,
on Windows we only called _dbus_fd_set_close_on_exec() on socket
pseudo-file-descriptors (SOCKET, which is an unsigned int);
every SOCKET can validly be cast to HANDLE, but not every HANDLE
is a SOCKET.

Before this commit we used an intptr_t as a sort of fake
union { int; HANDLE; }, which just obscures what's going on.

In practice, everything that called _dbus_fd_set_close_on_exec()
is really platform-specific anyway, so let's just have two separate
functions and call this solved.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39610

9 years ago_dbus_read_socket_with_unix_fds: do not accept extra fds in cmsg padding
Simon McVittie [Tue, 9 Sep 2014 11:44:22 +0000 (12:44 +0100)]
_dbus_read_socket_with_unix_fds: do not accept extra fds in cmsg padding

This addresses CVE-2014-3635.

If (*n_fds * sizeof (int) % sizeof (size_t)) is nonzero,
then CMSG_SPACE (*n_fds * sizeof (int)) > CMSG_LEN (*n_fds * sizeof (int)
because the SPACE includes padding to a size_t boundary, whereas the LEN
does not. We have to allocate the SPACE. Previously, we told the kernel
that the buffer size we wanted was the SPACE, not the LEN, which meant
it was free to fill the padding with additional fds: on a 64-bit
platform with 32-bit int, that's one extra fd, if *n_fds happens
to be odd.

This meant that a malicious sender could send exactly 1 fd too many,
which would make us fail an assertion if enabled, or overrun a buffer
by 1 fd otherwise.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83622
Reviewed-by: Alban Crequy <alban.crequy@collabora.co.uk>
9 years agoAdd _DBUS_GNUC_UNUSED, and use it in _DBUS_STATIC_ASSERT
Simon McVittie [Tue, 9 Sep 2014 11:49:44 +0000 (12:49 +0100)]
Add _DBUS_GNUC_UNUSED, and use it in _DBUS_STATIC_ASSERT

This means we can use _DBUS_STATIC_ASSERT at non-global scope without
tripping -Wunused-local-typedefs.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83767
Reviewed-by: Alban Crequy <alban.crequy@collabora.co.uk>
(cherry picked from commit 0e3d08d45cb9a9ceb2c077875eeb38306dad37b8)

9 years agobus: enforce pending_fd_timeout
Alban Crequy [Mon, 21 Jul 2014 16:17:11 +0000 (17:17 +0100)]
bus: enforce pending_fd_timeout

This is one of four commits needed to address CVE-2014-3637.

The bus uses _dbus_connection_set_pending_fds_function and
_dbus_connection_get_pending_fds_count to be notified when there are pending
file descriptors. A timeout per connection is armed and disarmed when the file
descriptor list is used and emptied.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=80559
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agoDBusConnection: implements _dbus_connection_set_pending_fds_function
Alban Crequy [Fri, 18 Jul 2014 16:28:32 +0000 (17:28 +0100)]
DBusConnection: implements _dbus_connection_set_pending_fds_function

This is one of four commits needed to address CVE-2014-3637.

This will allow the bus to be notified whenever a file descriptor is added or
removed from a DBusConnection's DBusMessageLoader.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=80559
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agoDBusConnection: implements _dbus_connection_get_pending_fds_count
Alban Crequy [Fri, 18 Jul 2014 15:45:07 +0000 (16:45 +0100)]
DBusConnection: implements _dbus_connection_get_pending_fds_count

This is one of four commits needed to address CVE-2014-3637.

This will allow the bus to know whether there are pending file descriptors in a
DBusConnection's DBusMessageLoader.

https://bugs.freedesktop.org/show_bug.cgi?id=80559
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
[fix compilation on platforms that do not HAVE_UNIX_FD_PASSING -smcv]
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agoconfig: add new limit: pending_fd_timeout
Alban Crequy [Mon, 21 Jul 2014 16:34:08 +0000 (17:34 +0100)]
config: add new limit: pending_fd_timeout

This is one of four commits needed to address CVE-2014-3637.

When a file descriptor is passed to dbus-daemon, the associated D-Bus message
might not be fully sent to dbus-daemon yet. Dbus-daemon keeps the file
descriptor in the DBusMessageLoader of the connection, waiting for the rest of
the message. If the client stops sending the remaining bytes, dbus-daemon will
wait forever and keep that file descriptor.

This patch adds pending_fd_timeout (milliseconds) in the configuration to
disconnect a connection after a timeout when a file descriptor was sent but not
the remaining message.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=80559
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agoStop listening on DBusServer sockets when reaching max_incomplete_connections
Alban Crequy [Fri, 4 Jul 2014 14:05:51 +0000 (15:05 +0100)]
Stop listening on DBusServer sockets when reaching max_incomplete_connections

This addresses the parts of CVE-2014-3639 not already addressed by
reducing the default authentication timeout.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=80851
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=80919
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agoconfig: change default auth_timeout to 5 seconds
Alban Crequy [Tue, 8 Jul 2014 11:00:58 +0000 (12:00 +0100)]
config: change default auth_timeout to 5 seconds

This partially addresses CVE-2014-3639.

This will change the default on the system bus where the limit
  <limit name="auth_timeout">...</limit>
is not specified.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=80919
Reviewed-by: Thiago Macieira <thiago@kde.org>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agoconfig: change DEFAULT_MESSAGE_UNIX_FDS to 16
Simon McVittie [Fri, 12 Sep 2014 14:51:39 +0000 (15:51 +0100)]
config: change DEFAULT_MESSAGE_UNIX_FDS to 16

This addresses CVE-2014-3636.

Based on a patch by Alban Crequy. Now that it's the same on all
platforms, there's little point in it being set by configure/cmake.

This change fixes two distinct denials of service:

fd.o#82820, part A
------------------

Before this patch, the system bus had the following default configuration:
- max_connections_per_user: 256
- DBUS_DEFAULT_MESSAGE_UNIX_FDS: usually 1024 (or 256 on QNX, see fd.o#61176)
  as defined by configure.ac
- max_incoming_unix_fds: DBUS_DEFAULT_MESSAGE_UNIX_FDS*4 = usually 4096
- max_outgoing_unix_fds: DBUS_DEFAULT_MESSAGE_UNIX_FDS*4 = usually 4096
- max_message_unix_fds: DBUS_DEFAULT_MESSAGE_UNIX_FDS = usually 1024

This means that a single user could create 256 connections and transmit
256*4096 = 1048576 file descriptors.

The file descriptors stay attached to the dbus-daemon process while they are
in the message loader, in the outgoing queue or waiting to be dispatched before
D-Bus activation.

dbus-daemon is usually limited to 65536 file descriptors (ulimit -n). If the
limit is reached and dbus-daemon needs to receive a message with a file
descriptor attached, this is signalled by recvfrom with the flag MSG_CTRUNC.
Dbus-daemon cannot recover from that error because the kernel does not have any
API to retrieve a file descriptor which has been discarded with MSG_CTRUNC.
Therefore, it closes the connection of the sender. This is not necessarily the
connection which generated the most file descriptors so it can lead to
denial-of-service attacks.

In order to prevent DoS issues, this patch reduces DEFAULT_MESSAGE_UNIX_FDS to
16:

max_connections_per_user * max_incoming_unix_fds = 256 * 64 = 16384

This is less than the usual "ulimit -n" (65536) with a good margin to
accomodate the other sources of file descriptors (stdin/stdout/stderr,
listening sockets, message loader, etc.).

Distributors on non-Linux may need to configure a smaller limit in
system.conf, if their limit on the number of fds is smaller than
Linux's.

fd.o#82820, part B
------------------

On Linux, it's not possible to send more than 253 fds in a single sendmsg()
call: sendmsg() would return -EINVAL.
  #define SCM_MAX_FD      253

SCM_MAX_FD changed value during Linux history:
- it used to be (OPEN_MAX-1)
- commit c09edd6eb (Jul 2007) changed it to 255
- commit bba14de98 (Nov 2010) changed it to 253

Libdbus always sends all of a message's fds, and the beginning
of the message itself, in a single sendmsg() call. Combining these
two, a malicious sender could split a message across two or more
sendmsg() calls to construct a composite message with 254 or more
fds. When dbus-daemon attempted to relay that message to its
recipient in a single sendmsg() call, it would receive EINVAL,
interpret that as a fatal socket error and disconnect the recipient,
resulting in denial of service.

This is fixed by keeping max_message_unix_fds <= SCM_MAX_FD.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=82820
Reviewed-by: Alban Crequy <alban.crequy@collabora.co.uk>
9 years agosystem bus limit: use max_replies_per_connection=128 by default
Alban Crequy [Thu, 10 Jul 2014 14:08:06 +0000 (15:08 +0100)]
system bus limit: use max_replies_per_connection=128 by default

This addresses CVE-2014-3638.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=81053
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agoReplace some runtime assertions with compile-time assertions
Simon McVittie [Thu, 11 Sep 2014 11:55:52 +0000 (12:55 +0100)]
Replace some runtime assertions with compile-time assertions

This requires a little bit of code re-ordering, because
_DBUS_STATIC_ASSERT can appear anywhere that a variable declaration
would be valid, i.e. not after executable code.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83767
Reviewed-by: Alban Crequy <alban.crequy@collabora.co.uk>
9 years agoAdd _DBUS_GNUC_UNUSED, and use it in _DBUS_STATIC_ASSERT
Simon McVittie [Tue, 9 Sep 2014 11:49:44 +0000 (12:49 +0100)]
Add _DBUS_GNUC_UNUSED, and use it in _DBUS_STATIC_ASSERT

This means we can use _DBUS_STATIC_ASSERT at non-global scope without
tripping -Wunused-local-typedefs.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83767
Reviewed-by: Alban Crequy <alban.crequy@collabora.co.uk>
9 years agoMerge branch 'dbus-1.8'
Simon McVittie [Mon, 15 Sep 2014 10:51:26 +0000 (11:51 +0100)]
Merge branch 'dbus-1.8'

9 years agoNEWS for 1.8
Simon McVittie [Mon, 15 Sep 2014 10:50:57 +0000 (11:50 +0100)]
NEWS for 1.8

9 years agoOn Linux, call prctl to disable core dumps
Simon McVittie [Mon, 15 Sep 2014 10:50:48 +0000 (11:50 +0100)]
On Linux, call prctl to disable core dumps

Whenever I forget to turn off corekeeper, the regression tests
take ages to record all test-segfault's crashes.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83772
Reviewed-by: Alban Crequy <alban.crequy@collabora.co.uk>
9 years agoMerge branch 'dbus-1.8'
Simon McVittie [Fri, 12 Sep 2014 11:36:20 +0000 (12:36 +0100)]
Merge branch 'dbus-1.8'

Conflicts:
NEWS

9 years agoNEWS for 1.8.x
Simon McVittie [Fri, 12 Sep 2014 11:35:31 +0000 (12:35 +0100)]
NEWS for 1.8.x

9 years agoenable build support without systemd compatibility libraries
Umut Tezduyar Lindskog [Tue, 2 Sep 2014 07:02:31 +0000 (09:02 +0200)]
enable build support without systemd compatibility libraries

systemd 209 merged all the libraries to libsystemd. Old
libraries can still be enabled with --enable-compat-libs
switch in systemd but this increases the binary size.

Implement a fallback library check in case compat libraries
dont exist.

[Fixed underquoting; switched priority so we try libsystemd first -smcv]
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agofree_pending_restore_data --> free_restore_pending_data
Chengwei Yang [Tue, 3 Dec 2013 07:52:15 +0000 (15:52 +0800)]
free_pending_restore_data --> free_restore_pending_data

This patch doesn't do any function change, but only the function name,
to align its name with the struct RestorePendingData.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=72254
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agoPort dbus_directory_...() function to use win32 native api instead of opendir()/readd...
Ralf Habacker [Fri, 5 Sep 2014 12:36:52 +0000 (14:36 +0200)]
Port dbus_directory_...() function to use win32 native api instead of opendir()/readdir() and closedir() emulation.

This fixes a license issue introduced by the initial win32 port.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=57272
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agoAdd directory test application 'manual-dir-iter' to cmake and autotools build system.
Ralf Habacker [Mon, 8 Sep 2014 13:15:55 +0000 (13:15 +0000)]
Add directory test application 'manual-dir-iter' to cmake and autotools build system.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=57272
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agoAdd dbus string convenience function _dbus_string_init_from_string().
Ralf Habacker [Fri, 5 Sep 2014 16:02:44 +0000 (18:02 +0200)]
Add dbus string convenience function _dbus_string_init_from_string().

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=57272
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agoImprove debug message to be able to see empty files.
Ralf Habacker [Fri, 5 Sep 2014 05:40:29 +0000 (07:40 +0200)]
Improve debug message to be able to see empty files.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=57272
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agoMerge branch 'dbus-1.8'
Ralf Habacker [Sun, 7 Sep 2014 09:37:32 +0000 (11:37 +0200)]
Merge branch 'dbus-1.8'

9 years agoFix windows doc for running tests.
Ralf Habacker [Tue, 14 Jan 2014 23:45:41 +0000 (00:45 +0100)]
Fix windows doc for running tests.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=41252
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agoNEWS for 1.9
Simon McVittie [Fri, 5 Sep 2014 15:51:02 +0000 (16:51 +0100)]
NEWS for 1.9

9 years agoNEWS for 1.8
Simon McVittie [Fri, 5 Sep 2014 15:48:00 +0000 (16:48 +0100)]
NEWS for 1.8

9 years agoMerge branch 'dbus-1.8'
Simon McVittie [Fri, 5 Sep 2014 12:41:12 +0000 (13:41 +0100)]
Merge branch 'dbus-1.8'

9 years agoStats: fix compilation issue
Alban Crequy [Thu, 24 Jul 2014 07:04:48 +0000 (08:04 +0100)]
Stats: fix compilation issue

Bug-Gentoo: https://bugs.gentoo.org/show_bug.cgi?id=507232
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=81043
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
9 years agodoc/dbus-tutorial: fix tutorial to reference the proper GType for 'ay'
Thomas Haller [Wed, 2 Jul 2014 09:12:26 +0000 (11:12 +0200)]
doc/dbus-tutorial: fix tutorial to reference the proper GType for 'ay'

DBUS_TYPE_G_BYTE_ARRAY does not exist. It should be DBUS_TYPE_G_UCHAR_ARRAY

Signed-off-by: Thomas Haller <thaller@redhat.com>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=80795

10 years agoWin32 cmake msvc16 64 bit native and mingw32/64 4.8.3 cross compile fix.
Ralf Habacker [Fri, 8 Aug 2014 16:57:10 +0000 (18:57 +0200)]
Win32 cmake msvc16 64 bit native and mingw32/64 4.8.3 cross compile fix.

This patch fixes a "missing include directory" compile error on test-print build target.

Bug: http://lists.freedesktop.org/archives/dbus/2014-August/016260.html
Reviewed-by: rony@wu.ac.at
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
10 years agoMerge branch 'dbus-1.8'
Simon McVittie [Wed, 2 Jul 2014 17:33:51 +0000 (18:33 +0100)]
Merge branch 'dbus-1.8'

Conflicts:
NEWS
configure.ac

10 years agostart 1.8.7
Simon McVittie [Wed, 2 Jul 2014 17:24:44 +0000 (18:24 +0100)]
start 1.8.7

10 years agoPrepare 1.8.6 in advance
Simon McVittie [Mon, 30 Jun 2014 13:18:03 +0000 (14:18 +0100)]
Prepare 1.8.6 in advance

10 years agoHandle ETOOMANYREFS when sending recursive fds (SCM_RIGHTS)
Alban Crequy [Tue, 24 Jun 2014 16:57:14 +0000 (17:57 +0100)]
Handle ETOOMANYREFS when sending recursive fds (SCM_RIGHTS)

Since Linux commit 25888e (from 2.6.37-rc4, Nov 2010), sendmsg() on Unix
sockets returns -1 errno=ETOOMANYREFS ("Too many references: cannot splice")
when the passfd mechanism (SCM_RIGHTS) is "abusively" used recursively by
applications. A malicious client could use this to force a victim system
service to be disconnected from the system bus; the victim would likely
respond by exiting. This is a denial of service (fd.o #80163,
CVE-2014-3532).

This patch silently drops the D-Bus message on ETOOMANYREFS and does not close
the connection.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=80163
Reviewed-by: Thiago Macieira <thiago@kde.org>
[altered commit message to explain DoS significance -smcv]
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
10 years agoIf loader contains two messages with fds, don't corrupt the second
Simon McVittie [Wed, 11 Jun 2014 11:24:20 +0000 (12:24 +0100)]
If loader contains two messages with fds, don't corrupt the second

There were two bugs here: we would previously overwrite the unused
fds with the already-used fds instead of the other way round, and
we would copy n bytes where we should have copied n ints.

Additionally, sending crafted messages in a chosen sequence to a victim
system service could cause an invalid file descriptor to be present
when dbus-daemon tries to forward one of those crafted messages to the
victim, causing sendmsg() to fail with EBADF, which resulted in
disconnecting the victim service, which would likely respond to that
by exiting. This is a denial of service (fd.o #80469, CVE-2014-3533).

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=79694
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=80469
Reviewed-by: Alban Crequy <alban.crequy@collabora.co.uk>
10 years agoNEWS
Simon McVittie [Wed, 11 Jun 2014 10:56:00 +0000 (11:56 +0100)]
NEWS

10 years agobus_set_watched_dirs: portability patch for systems which lack O_CLOEXEC
Patrick Welche [Fri, 6 Jun 2014 13:03:39 +0000 (14:03 +0100)]
bus_set_watched_dirs: portability patch for systems which lack O_CLOEXEC

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=77032
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
10 years agoMerge branch 'dbus-1.8'
Simon McVittie [Wed, 11 Jun 2014 10:46:27 +0000 (11:46 +0100)]
Merge branch 'dbus-1.8'

Conflicts:
NEWS
configure.ac

10 years agoNEWS
Simon McVittie [Wed, 11 Jun 2014 10:45:42 +0000 (11:45 +0100)]
NEWS