Commit graph

3709 commits

Author SHA1 Message Date
Lennart Poettering
2cf320fc82 selinux: when dropping capabilities only include AUDIT caps if we have them
When we drop capabilities we shouldn't assume we can keep
CAP_AUDIT_WRITE unconditionally, since it will not be available when
running in containers.

This patch only adds CAP_AUDIT_WRITE to the list of caps we keep if we
actually have it in the first place.

This makes audit/selinux enabled D-Bus work in a Linux container.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=49062
Acked-by: Thiago Macieira <thiago@kde.org>
Acked-by: Colin Walters <walters@verbum.org>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-09-13 14:24:19 +01:00
Simon McVittie
efd8209d05 NEWS 2013-09-13 14:16:50 +01:00
Justin Lee
8d2536e023 Remove obscure "low-latency" parts in the introduction of spec
According to Wikipedia
http://en.wikipedia.org/wiki/Latency_%28engineering%29#Packet-switched_networks
latency means "the time from the source sending a packet to the destination
receiving it". Therefore, latency is unrelated to whether the operation is
asynchronous or synchronous. And also unrelated to whether it's one-way or
round-trip. Latency exists for asynchronous and one-way transfer, because for
current DBus implementations we need at least one context switch to transfer
each message from the sender process to the receiver process. Emphasizing
D-Bus is low-latency could encourage user to abuse/misuse the system.

Mail disscusion:
http://lists.freedesktop.org/archives/dbus/2013-May/015665.html

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=65141
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-09-13 14:15:35 +01:00
Simon McVittie
c627c4119f More NEWS 2013-09-13 14:06:02 +01:00
Simon McVittie
ca99f0142b Merge branch 'dbus-1.6'
Conflicts:
	NEWS
	configure.ac
2013-09-13 14:04:45 +01:00
Simon McVittie
1c95955cbc NEWS 2013-09-13 14:02:33 +01:00
Chengwei Yang
dd71688e5d Fix dbus-daemon document about servicedir
In dbus-daemon implementation, the servicedir are searched in order in
which they appear in the config file.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66994
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-09-13 13:55:41 +01:00
Chengwei Yang
0cea59aad5 Remove DBUS_COMPILATION from test source code
DBUS_COMPILATION definition was moved to test/Makefile.am static_cppflags,
so remove it from test source code.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68852
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-09-13 13:44:09 +01:00
Chengwei Yang
200a11ebbe Check EINVAL for accept4()
It was reported that accept4() will return -1 with errrno is EINVAL on
arm platform, so check EINVAL for accept4() and retry accept().

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69026
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-09-13 13:40:08 +01:00
Pino Toscano
c1288c5366 Allow EPROTOTYPE for SOCK_CLOEXEC but unsupported by socket/socketpair
If SOCK_CLOEXEC is defined (usually because accept4 is implemented),
check for EPROTOTYPE (the POSIX errno for invalid socket types) in
addition to EINVAL as errno indicating whether socket and socketpair
do not support SOCK_CLOEXEC (and other SOCK_* flags).

[adapted by Chengwei Yang to give _dbus_connect_exec() the same treatment]
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69073
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-09-13 13:36:32 +01:00
Chengwei Yang
7a53684d42 Check EINVAL for socketpair and retry without SOCK_CLOEXEC
As the same as _dbus_open_socket() and _dbus_full_duplex_pipe(),
socketpair() may fail with EINVAL if call with SOCK_CLOEXEC.

Check for the failure and retry without SOCK_CLOEXEC, in addition, only
call _dbus_fd_set_close_on_exec() if the socketpair failure happened.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69073
[trivial coding style fixes -smcv]
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-09-13 13:33:21 +01:00
Chengwei Yang
37df7c316b Use the argument of dbus_connection_set_route_peer_messages()
The function dbus_connection_set_route_peer_messages() take a bool
argument, however, in the implementation, it always hard-code to TRUE
rather than take its bool argument.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69165
[amended commit message -smcv]
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-09-13 12:35:00 +01:00
Chengwei Yang
f658047ec8 Fix pass wrong type of argument to function
The last argument of function _dbus_transport_new_for_socket() is
declared as const DBusString *. However, it is passed as a bool value.
Although the value of FALSE equals NULL in fact, this is an incorrect
use of function.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69165
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-09-13 12:29:36 +01:00
Sviatoslav Chagaev
a548141b17 Fix file descriptor leak in _dbus_command_for_pid
Fix a file descriptor not being closed when an error codepath is taken.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69182
Reviewed-by: Chengwei Yang <chengwei.yang@intel.com>
[more specific commit message -smcv]
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-09-13 12:25:37 +01:00
Simon McVittie
0fbb337146 1.6.15 2013-09-05 17:26:18 +01:00
Simon McVittie
7b3f2143fd 1.6.14 2013-09-05 16:37:08 +01:00
Simon McVittie
fc600b6a8f _dbus_babysitter_unref: avoid infinite loop if waitpid() returns EINTR
If waitpid() failed with EINTR, we'd go back for another go, but
because ret is nonzero, we'd skip the waitpid() and just keep looping.

Also avoid an unnecessary "goto" in favour of a proper loop, to make it
more clearly correct.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68945
Reviewed-by: Colin Walters <walters@verbum.org>
2013-09-05 16:31:13 +01:00
Chengwei Yang
fbeac8820a dbus-launch: unconditionally use SIGHUP and free memory on OOM
In a previous patch, it check SIGHUP for windows, however, in fact there
is dbus-launch-win.c supposed to be used on windows. So just use SIGHUP
unconditionally.

Also free memory on OOM, although this doesn't make much sense since
this is a oneshort program, rather than a daemon.

Signed-off-by: Chengwei Yang <chengwei.yang@intel.com>
[fixed whitespace -smcv]
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66068
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-09-05 14:01:46 +01:00
Simon McVittie
3357f484e0 NEWS 2013-09-05 13:57:53 +01:00
Simon McVittie
50674ed689 Use GNU make features to reduce repetition
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=48277
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Chengwei Yang <chengwei.yang@intel.com>
2013-09-05 13:56:36 +01:00
Simon McVittie
dd81768ecb Document that GNU make is required
In theory the Autotools build system supports any "make" implementation,
but there are no regular contributors who test with BSD make, so the
inevitable result is that only GNU make actually works (fd.o #48277).

Apparently there's only one GNUism at the moment, which is fixable,
but that means repeating ourselves a bit more. If we instead document
that GNU make is required, we can simplify the Makefiles over time
by using extensions like $(patsubst), leading to a less error-prone
build system.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=48277
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Chengwei Yang <chengwei.yang@intel.com>
2013-09-05 13:55:46 +01:00
Simon McVittie
f8e180476f Merge branch 'dbus-1.6'
Conflicts:
	NEWS
	tools/run-with-tmp-session-bus.sh
2013-09-05 13:12:36 +01:00
Simon McVittie
7d8895e4f4 NEWS 2013-09-05 13:11:45 +01:00
Simon McVittie
ad5b3128ba NEWS for 1.6 2013-09-05 13:11:31 +01:00
Ivan Romanov
50b64a0c79 Use iface instead of interface in function parameters
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66493
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
(cherry picked from commit 0928169cf8)
2013-09-05 13:08:22 +01:00
Simon McVittie
42e12d342e run-with-tmp-session-bus.sh: create a unique temporary file per process
This makes the regression tests OK to run in parallel.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68852
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
(cherry picked from commit 9d80d46a79)
2013-09-05 13:05:21 +01:00
Simon McVittie
3b4a09c04e NEWS for 1.6 2013-09-05 13:03:06 +01:00
Simon McVittie
87df259d8c Add CPPFLAGS to "shared if possible" test binaries
In principle we ought to define DBUS_STATIC_BUILD in anything that's
using libdbus-internal.la (to avoid linking failures on
statically-linked mingw builds), and DBUS_TEST_USE_INTERNAL in any
test that's using the non-dbus-glib code paths of test-utils.[ch]
(to avoid the GLib requirement, although in practice, everything
"shared if possible" requires GLib at the moment anyway).

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68852
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2013-09-05 12:35:29 +01:00
Simon McVittie
9d80d46a79 run-with-tmp-session-bus.sh: create a unique temporary file per process
This makes the regression tests OK to run in parallel.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68852
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2013-09-05 12:35:11 +01:00
Simon McVittie
30e7a81302 Tests: allow dbus-glib to be replaced with use of libdbus-internal
We only use dbus-glib for its main loop; within dbus, DBusLoop is
available as an alternative, although it isn't thread-safe and
isn't public API.

For tests that otherwise only use libdbus public API, it's desirable to
be able to avoid DBusLoop, so we can run them against an installed
libdbus as an integration test. However, if we don't have dbus-glib,
we're going to have to use an in-tree main loop, which might as well
be DBusLoop.

The major disadvantage of using dbus-glib is that it isn't safe to
link both dbus-1 and dbus-internal at the same time. This is awkward
for a future test case that wants to use _dbus_getsid() in dbus-daemon.c,
but only on Windows (fd.o #54445). If we use the same API wrapper around
both dbus-glib and DBusLoop, we can compile that test against dbus-glib
or against DBusLoop, depending on the platform.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68852
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2013-09-03 12:00:51 +01:00
Simon McVittie
f17fd1cc4e Define DBUS_COMPILATION externally for all tests that use internal stuff
It might as well go in the AM_CPPFLAGS rather than in the source code.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68852
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2013-09-03 12:00:44 +01:00
Simon McVittie
ce334cb0d6 corrupt test: close connection before releasing GSocket
GSocket takes responsibility for closing the fd, and there doesn't
seem to be any way to tell it not to. When this test is adapted to run
under DBusLoop as an alternative to dbus-glib, that becomes a problem,
because DBusLoop/DBusSocketSetEpoll do not tolerate that. Work around it.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68852
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2013-09-03 12:00:37 +01:00
Simon McVittie
cae26e9fac _dbus_become_daemon: don't pretend it worked
This function is meaningless (and possibly unimplementable) on Windows.
We shouldn't call it; if we do, it should raise an error.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68852
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2013-09-03 12:00:31 +01:00
Simon McVittie
732021af1b Allow dbus-daemon --nofork on Windows
On Windows, the dbus-daemon is not able to fork (daemonize). If someone
explicitly requests forking, it should fail, but if someone
explicitly requests *not* forking, there seems no harm in allowing it.

A few of the regression tests specifically require a dbus-daemon that
will not fork, so allowing this option on Windows means those tests
don't need an extra OS condition.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68852
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2013-09-03 12:00:09 +01:00
Simon McVittie
21a60c993b Fix declaration of _dbus_win_startup_winsock
This regressed in commit b7a91bfd.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68610
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2013-09-03 11:59:46 +01:00
Simon McVittie
b119fc4a14 Fix unused function when SELinux is not enabled
It must be one of the "only smcv tests this" configurations...
2013-08-30 17:41:33 +01:00
Simon McVittie
3e35c91fd8 Move some sysdeps stuff only used by the dbus-daemon outside libdbus
This means we don't need to worry about whether it's thread-safe,
and makes libdbus a little smaller.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68610
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2013-08-30 17:32:45 +01:00
Simon McVittie
765c9ebc59 _dbus_check_setuid: comment on thread-safety
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68610
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2013-08-30 17:32:44 +01:00
Simon McVittie
b7a91bfd46 _dbus_win_startup_winsock: be thread-safe
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68610
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2013-08-30 17:32:42 +01:00
Simon McVittie
53966707ae Comment some suspicious uses of static variables
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68610
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2013-08-30 17:32:40 +01:00
Simon McVittie
e63961b750 _dbus_get_autolaunch_address: don't make argv static
This function could be accessed from any thread, which would mean it
scribbles on argv twice.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68610
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2013-08-30 17:32:39 +01:00
Simon McVittie
cc28d8d910 _dbus_file_path_extract_elements_from_tail: don't misuse static variable
If we _dbus_verbose() from more than one thread at the same time,
we don't want to get into trouble with static variables (and I don't
think micro-optimizing this function is really worth it anyway).

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68610
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2013-08-30 17:32:15 +01:00
Simon McVittie
31edd76313 Revert "Add a statically-initialized implementation of _dbus_lock() on glibc systems"
This reverts commit 83aaa9f359.

This wasn't right: because it looked for a symbol from pthread.h,
modules could end up disagreeing about whether threading was enabled or
not.
2013-08-30 17:31:16 +01:00
Simon McVittie
d98a587f76 _dbus_get_tmpdir: be thread-safe
Sharing a static variable between threads is not safe in general,
and this function is used in the shared libdbus (for nonce files),
so it can't rely on being single-threaded.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68610
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2013-08-29 12:30:02 +01:00
Simon McVittie
ced50f8be1 libdbus-1.la: have proper dependencies on Windows
Assigning to libdbus_1_la_DEPENDENCIES defeats Automake's normal
dependency logic, which makes libdbus-1.la depend on all the
static libraries that will go into it (it still had a corrct dependency
on the other objects, which go through a separate variable).
This meant libdbus-init-win wasn't necessarily built first.

Use EXTRA_libdbus_1_la_DEPENDENCIES to avoid that problem.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68505
Acked-by: Ralf Habacker <ralf.habacker@freenet.de>
2013-08-29 11:35:52 +01:00
Ralf Habacker
b1579df4ce Generate autotools provided PACKAGE_.. and VERSION defines by a cmake macro.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=67072
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-08-28 14:50:57 +02:00
Ralf Habacker
5366a920f4 Fixed mingw gcc 4.8.1 complains about double defined macros.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=67072
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-08-28 10:53:54 +02:00
Ralf Habacker
e1bc016458 Fixed gcc 4.8.1 -Wformat warnings on windows.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=67072
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-08-28 10:43:28 +02:00
Chengwei Yang
28f15d8b21 Fix debug output about dbus server ref count
dbus_server_disconnect() invokes dbus_server_unref() at the end of
function, the latter will print a trace about server ref count decrease
1. However, it doesn't invoke dbus_server_ref(), so there isn't a trace
about server ref count increase in debug output.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68303
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-08-23 12:00:25 +01:00
Chengwei Yang
d61daf50ce Fix comment about atomic operations
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68303
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-08-23 11:59:23 +01:00