Commit graph

4701 commits

Author SHA1 Message Date
Simon McVittie
8db5ca900f Be more const-correct
As a general design principle, strings that we aren't going to modify
should usually be const. When compiling with -Wwrite-strings, quoted
string constants are of type "const char *", causing compiler warnings
when they are assigned to char * variables.

Unfortunately, we need to add casts in a few places:

* _dbus_list_append(), _dbus_test_oom_handling() and similar generic
  "user-data" APIs take a void *, not a const void *, so we have
  to cast
* For historical reasons the execve() family of functions take a
  (char * const *), i.e. a constant pointer to an array of mutable
  strings, so again we have to cast
* _dbus_spawn_async_with_babysitter similarly takes a char **,
  although we can make it a little more const-correct by making it
  take (char * const *) like execve() does

This also incorporates a subsequent patch by Thomas Zimmermann to
put various string constants in static storage, which is a little
more efficient.

Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Thomas Zimmermann <tdz@users.sourceforge.net>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97357
2016-10-13 17:20:28 +01:00
Simon McVittie
cc7df2fbf9 Remove now-misleading comment
Signed-off-by: Simon McVittie <smcv@debian.org>
2016-10-10 20:50:28 +01:00
Simon McVittie
06cd2ade51 Enable the same warnings when targeting Windows as for Unix
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2016-10-10 18:16:16 +01:00
Simon McVittie
f678f23be2 Enable some more compiler warnings
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=98192
2016-10-10 18:15:32 +01:00
Thomas Zimmermann
d0be2333d5 Fix warnings from compiler option '-Wshadow'
Signed-off-by: Thomas Zimmermann <tdz@users.sourceforge.net>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=98192
2016-10-10 18:04:09 +01:00
Simon McVittie
6292e7c278 Rename distro-style CI build from "release" to "production"
This avoids confusion with the meaning of "release" used by
AX_IS_RELEASE. AX_IS_RELEASE is about facts about the source tree,
namely the distinction between releases (tags) and random snapshots.
The build variants in .travis.yml are about facts about the build
being done, namely the distinction between production and
debug/developer builds.

Production builds are sometimes referred to as "release builds",
for example in typical CMake and MSVC build environments, but a
different term seems better here.

Signed-off-by: Simon McVittie <smcv@debian.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97357
2016-10-10 15:13:01 +01:00
Thomas Zimmermann
5350b54de7 Fix warnings from compiler option '-Wsuggest-attribute=noreturn'
This patch fixes warnings from '-Wsuggest-attribute=noreturn'. We cannot
enable it unconditionally as it would break libtool.

Signed-off-by: Thomas Zimmermann <tdz@users.sourceforge.net>
2016-10-10 15:11:24 +01:00
Thomas Zimmermann
275605f5ee Partially fix warnings from compiler option '-Wredundant-decls'
Signed-off-by: Thomas Zimmermann <tdz@users.sourceforge.net>
[smcv: omit the part involving environ, which was more involved]
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97357
2016-10-10 15:11:03 +01:00
Thomas Zimmermann
4d1c15789f Partially fix warnings from compiler option '-Wformat-nonliteral'
Signed-off-by: Thomas Zimmermann <tdz@users.sourceforge.net>
[smcv: split out from a larger commit]
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97357
2016-10-10 15:10:32 +01:00
Thomas Zimmermann
3c7c840f80 Remove configure option '--disable-compiler-optimisations'
This path removes the obsolete configure option
'--disable-compiler-optimisations'. Users can control compiler flags
by setting CFLAGS, CXXFLAGS, etc in the build environment.

Signed-off-by: Thomas Zimmermann <tdz@users.sourceforge.net>
Reviewed-by: Simon McVittie <smcv@debian.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97357
2016-10-10 15:09:59 +01:00
Thomas Zimmermann
36930b224b Remove unused functions from Windows builds
Several internal functions are not used on Windows. This patch
hides them behind DBUS_WIN.

Signed-off-by: Thomas Zimmermann <tdz@users.sourceforge.net>
Reviewed-by: Simon McVittie <smcv@debian.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97357
2016-10-10 15:09:38 +01:00
Thomas Zimmermann
ddbc44adb2 Include string.h for strcmp()
Signed-off-by: Thomas Zimmermann <tdz@users.sourceforge.net>
Reviewed-by: Simon McVittie <smcv@debian.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97357
2016-10-10 15:09:36 +01:00
Thomas Zimmermann
07f87930ca Protect debug-only variables behind DBUS_ENABLE_VERBOSE_MODE
Signed-off-by: Thomas Zimmermann <tdz@users.sourceforge.net>
Reviewed-by: Simon McVittie <smcv@debian.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97357
2016-10-10 15:09:33 +01:00
Thomas Zimmermann
9b16f35398 Cast -1 to DWORD for comparing to variable
Signed-off-by: Thomas Zimmermann <tdz@users.sourceforge.net>
[smcv: add space after cast, that is our coding style]
Reviewed-by: Simon McVittie <smcv@debian.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97357
2016-10-10 15:09:31 +01:00
Thomas Zimmermann
45d68fe384 Fix function declarations
This patch adds 'void' to function declarations without parameters.

Signed-off-by: Thomas Zimmermann <tdz@users.sourceforge.net>
[smcv: fix coding style while we're touching these lines anyway]
Reviewed-by: Simon McVittie <smcv@debian.org>
2016-10-10 15:09:28 +01:00
Thomas Zimmermann
85b520ab8f Add configure option '--enable-debug' to control debugging and profiling
The command-line option '--enable-debug' controls the debugging and
profiling flags of the build. Debugging is disabled by default and only
enabled on developer builds. Profiling is always disabled. Both options
can be overridden from the command line (e.g., for profiling of release
builds).

Signed-off-by: Thomas Zimmermann <tdz@users.sourceforge.net>
[smcv: remove trailing whitespace from new lines]
Reviewed-by: Simon McVittie <smcv@debian.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97357
2016-10-10 15:09:25 +01:00
Simon McVittie
866ff0e926 Start towards 1.11.8
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2016-10-10 15:09:09 +01:00
Simon McVittie
655b3e613c Release 1.11.6 and spec 0.29
Signed-off-by: Simon McVittie <smcv@debian.org>
2016-10-10 10:19:54 +01:00
Simon McVittie
12720d6e28 Ignore ActivationFailure if not using systemd activation
This isn't security-related, just defensive programming: if
dbus-daemon wasn't run with --systemd-activation, then there is no
reason why systemd would legitimately send us this signal, and if it
does we should just ignore it.

Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Colin Walters <walters@verbum.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=98157
2016-10-10 10:05:30 +01:00
Simon McVittie
3da9ad2a9f bus_driver_handle_message: reject ActivationFailure if unprivileged
Specifically, this will allow ActivationFailure messages from our
own uid or from root, but reject them otherwise, even if the bus
configuration for who can own org.freedesktop.systemd1 is entirely
wrong due to something like CVE-2014-8148.

Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Colin Walters <walters@verbum.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=98157
2016-10-10 10:05:26 +01:00
Simon McVittie
91ec6a0561 dbus_activation_systemd_failure: do not use non-literal format string
In principle this could lead to arbitrary memory overwrite via
a format string attack in the message received from systemd,
resulting in arbitrary code execution.

This is not believed to be an exploitable security vulnerability on the
system bus in practice: it can only be exploited by the owner of the
org.freedesktop.systemd1 bus name, which is restricted to uid 0, so
if systemd is attacker-controlled then the system is already doomed.
Similarly, if a systemd system unit mentioned in the activation failure
message has an attacker-controlled name, then the attacker likely already
has sufficient access to execute arbitrary code as root in any case.

However, prior to dbus 1.8.16 and 1.9.10, due to a missing check for
systemd's identity, unprivileged processes could forge activation
failure messages which would have gone through this code path.
We thought at the time that this was a denial of service vulnerability
(CVE-2015-0245); this bug means that it was in fact potentially an
arbitrary code execution vulnerability.

Bug found using -Wsuggest-attribute=format and -Wformat-security.

Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Colin Walters <walters@verbum.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=98157
2016-10-10 10:05:02 +01:00
Simon McVittie
c5099bf89d update NEWS 2016-10-05 19:34:55 +01:00
Philip Withnall
12a893b2eb bus: Add LSM label to connection loginfo string
If it is set (i.e. if an LSM is in use) this will make it appear in
various places in log output.

With SELinux, for example, this appends something like:
   label="system_u:object_r:unlabeled_t:s0"

This commit partially rearranges the code which sets the loginfo string,
so that it consistently puts a space between fields, and not one at the
end.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68212
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2016-10-05 19:32:48 +01:00
Philip Withnall
203a1e5094 bus: Add sender name to bus activation log messages
This clarifies
   Activating via systemd: service name='com.example.Example'
   unit='example.service'
to
   Activating via systemd: service name='com.example.Example'
   unit='example.service' requested by ':1.23' (uid 1000 pid 123
   comm "whatever-activat")

Similarly for the non-systemd code paths.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68212
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2016-10-05 19:32:45 +01:00
Ralf Habacker
487a26f72d Fix double printing function name in _dbus_verbose() messages.
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=98089
2016-10-05 15:14:05 +02:00
Simon McVittie
d36d1b9d10 Update NEWS 2016-10-05 10:09:11 +01:00
Philip Withnall
371e7109f8 doc: Install introspection and busconfig DTDs
Install them to $(datadir)/xml/dbus-1, which seems to be the standard
location for installed DTDs. This means that developers can use them to
validate their introspection XML, and sysadmins can use them to validate
their bus configuration files.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89011
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2016-10-05 10:08:10 +01:00
Simon McVittie
561e39e2c8 Merge branch 'dbus-1.10' 2016-10-04 11:23:49 +01:00
Simon McVittie
9cb71ebd07 NEWS 2016-10-04 11:23:30 +01:00
Marc Mutz
178872ea6f DBusMessage: Fix UB (misaligned access) in call to _dbus_header_set_field_basic()
The const void* 'value' pointer that is passed the address of a
uint32_t here eventually ends up in _dbus_marshal_write_basic(), which
casts it to a DBusBasicValue, a union type that has an alignment of
eight on 64-bit platforms and is therefore more-aligned than the
uint32.

The read of a value of a more-aligned type through a pointer to a less
-aligned type is undefined behaviour.

Fix by storing the uint32 in a DBusBasicValue and passing that instead.

Found by UBSan:

  dbus/dbus/dbus-marshal-basic.c:832:14: runtime error: member access within misaligned address 0x7fdb8dac3a04 for type 'const union DBusBasicValue', which requires 8 byte alignment
  0x7fdb8dac3a04: note: pointer points here
    4a 87 b5 71 01 00 00 00  40 7d 01 00 00 61 00 00  10 3b ac 8d db 7f 00 00  2c 2a 3e 94 db 7f 00 00
                ^
    #0 0x7fdb9444a2c3 in _dbus_marshal_write_basic dbus/dbus/dbus-marshal-basic.c:832
    #1 0x7fdb943d22fb in _dbus_type_writer_write_basic_no_typecode dbus/dbus/dbus-marshal-recursive.c:1605
    #2 0x7fdb943d64e9 in _dbus_type_writer_write_basic dbus/dbus/dbus-marshal-recursive.c:2327
    #3 0x7fdb943c52a6 in write_basic_field dbus/dbus/dbus-marshal-header.c:318
    #4 0x7fdb943c919e in _dbus_header_set_field_basic dbus/dbus/dbus-marshal-header.c:1321
    #5 0x7fdb943e1349 in dbus_message_set_reply_serial dbus/dbus/dbus-message.c:1173

Signed-off-by: Marc Mutz <marc@kdab.net>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=98035
2016-10-04 11:22:25 +01:00
Simon McVittie
06d7304f45 Merge branch 'dbus-1.10' 2016-10-03 11:43:55 +01:00
Simon McVittie
558f1e04b4 NEWS for 1.10.x 2016-10-03 11:43:06 +01:00
Simon McVittie
0cfe2cfb4e autogen.sh: fail cleanly if autoconf fails
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
(cherry picked from commit 0bbfca6def)
2016-10-03 11:42:42 +01:00
Simon McVittie
8824f29712 NEWS for 1.11.x 2016-10-03 11:42:19 +01:00
Philip Withnall
f354940111 spec: Allow <annotation> in <arg> elements in introspection XML
This is widely used in practice (especially by GLib — just look at files
in /usr/share/dbus-1/interfaces/), and there is no reason not to allow
it. Update the specification, introspection DTD and XSL file to allow
and represent it.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=86162
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2016-10-03 11:33:47 +01:00
Philip Withnall
699fbe8df6 doc: Add missing space in introspect.xsl
This adds a space in the output between ‘annotation’ and the key of the
annotation. A Saturday afternoon cosmetic fix.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=86162
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2016-10-03 11:33:34 +01:00
Philip Withnall
bfebafc256 spec: Recommend against using ‘/’ for object paths
As discussed in http://0pointer.de/blog/projects/versioning-dbus.html
and in https://dbus.freedesktop.org/doc/dbus-api-design.html,
un-versioned object paths make it hard to work out which interface a
signal was emitted from.

Clarify this in the specification to try and avoid people making this
mistake.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=37095
Reviewed-by: Simon McVittie <smcv@debian.org>
2016-10-01 16:32:51 +01:00
Simon McVittie
693f75a88b Remove unmatched parenthesis
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97009
2016-09-30 19:36:51 +01:00
Simon McVittie
f1cd229f83 Remove trailing newlines from _dbus_warn, _dbus_warn_check_failed
They used to be needed, but are not needed any more, and we were
never completely consistent about including them in any case.

Signed-off-by: Simon McVittie <smcv@debian.org>
2016-09-30 19:36:51 +01:00
Simon McVittie
b8abdc52af internals: remove newline, pid from assertion failures
_dbus_warn() now calls _dbus_logv() which always logs the pid and
prints a newline anyway.

Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97009
2016-09-30 19:36:50 +01:00
Simon McVittie
7c837b1045 dbus-launch: redirect dbus-daemon output to syslog
Otherwise, it won't go anywhere at all.

Signed-off-by: Simon McVittie <smcv@debian.org>
2016-09-30 19:36:50 +01:00
Simon McVittie
814560d56a Only redirect child processes to systemd Journal if using syslog
In particular this means the test suite won't spam the Journal
any more.

Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97009
2016-09-30 19:36:50 +01:00
Simon McVittie
1c807207bb dbus-daemon: add --syslog, --nosyslog, --syslog-only
Like --fork and --nofork, these override what the configuration says.

Use --syslog-only to force the systemd services to log to the Journal
(via syslog, which means we see the severity metadata) instead of
testing sd_booted() in the configuration implementation.

Signed-off-by: Simon McVittie <smcv@debian.org>
2016-09-30 19:36:50 +01:00
Simon McVittie
2c472b8398 syslog test: extend assertions to cover new functionality
Signed-off-by: Simon McVittie <smcv@debian.org>
2016-09-30 19:36:50 +01:00
Simon McVittie
ce121d2006 _dbus_warn, _dbus_warn_check_failed: unify with _dbus_logv
This means that dbus-daemon will log something like

    dbus-daemon[123]: Unable to add reload watch to main loop

to syslog and/or stderr according to its configuration, while other
libdbus users will print something like this to stderr:

    dbus[4567]: arguments to dbus_foo() were incorrect, assertion
    "connection != NULL" failed at file dbus-foo.c line 123.
    This is normally a bug in some application using the D-Bus library.

This slightly changes the meaning of the argument to _dbus_warn()
and _dbus_warn_check_failed. Previously, a trailing newline was
expected, and a missing newline would have resulted in incorrect
output. Now, a newline is supplied automatically by the
library (like g_warning()), and messages that end with a newline will
result in an unnecessary extra newline in output.

This extra newline is harmless, so I'm not going to change all the
callers immediately.

Signed-off-by: Simon McVittie <smcv@debian.org>
2016-09-30 19:36:50 +01:00
Simon McVittie
04bfdb3dbf bus_context_log: remove special handling of !context->syslog
_dbus_log() and _dbus_logv() are always the right functions to call now.

Signed-off-by: Simon McVittie <smcv@debian.org>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97009
2016-09-30 19:36:50 +01:00
Simon McVittie
92bd5ef290 _dbus_logv: configurably log to syslog and/or stderr
This changes the behaviour of _dbus_logv() if _dbus_init_system_log() was
not called. Previously, _dbus_logv() would always log to syslog;
additionally, it would log to stderr, unless the process is dbus-daemon
and it was started by systemd. Now, it will log to stderr only,
unless _dbus_init_system_log() was called first.

This is the desired behaviour because when we hook up
_dbus_warn_check_failed() to _dbus_logv() in the next commit, we don't
want typical users of libdbus to start logging their check failures to
syslog - we only want the dbus-daemon to do that.

In practice this is not usually a behaviour change, because there was
only one situation in which we called _dbus_logv() without first calling
_dbus_init_system_log(), namely an error while parsing configuration
files. Initialize the system log "just in time" in that situation
to preserve existing behaviour.

Signed-off-by: Simon McVittie <smcv@debian.org>
2016-09-30 19:36:50 +01:00
Simon McVittie
b5c229d3f8 Update autoconf-archive, and use snapshot.debian.org
This way the link won't expire in future.

Signed-off-by: Simon McVittie <smcv@debian.org>
2016-09-30 19:35:59 +01:00
Ralf Habacker
1e43857b31 Fix building with CMake for a Unix platform where functions like recv() are in a separate -lsocket, like QNX.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=94096
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2016-08-18 14:59:41 +02:00
Ralf Habacker
5bb70dd554 Fix building with CMake for a Unix platform that does not have -lrt, such as Android.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=94096
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2016-08-18 14:59:22 +02:00