Commit graph

4328 commits

Author SHA1 Message Date
Simon McVittie
d9ee040d0b dbus-monitor: disable automatic handling of o.fd.Peer messages
A normal DBusConnection will automatically reply to o.fd.Peer
messages such as Ping. We don't want this: if we are using
traditional eavesdropping with an older dbus-daemon, we'll
confuse everyone else by replying to messages that weren't
intended for us. If we are using the new Monitoring
interface (since 1.9.12), the same still applies, but in
addition, the dbus-daemon will disconnect us for not being
a well-behaved monitor.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90952
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
2015-07-21 16:50:48 +01:00
Ralf Habacker
d10ac7c57e bus_registry_new: Assert in case of not valid context parameter to avoid potiental crashes (CID 54764).
Because the context parameter is dereferenced several times in related code without a null check,
we need to make sure to have a valid context.

Reported by Coverity: CID 54764: Dereference after null check (FORWARD_NULL)

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90021
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-07-13 14:33:32 +02:00
Simon McVittie
907c0b36e9 Merge branch 'dbus-1.8'
Conflicts:
	NEWS
2015-06-17 20:41:24 +01:00
Simon McVittie
1b892db6dd NEWS 2015-06-17 20:40:51 +01:00
Jacek Bukarewicz
b863c22f6a Fix memleak in GetConnectionCredentials handler
Reply message was not unreferenced when GetConnectionCredentials
handler was successful.

Signed-off-by: Jacek Bukarewicz <j.bukarewicz@samsung.com>
[smcv: changed bus_message_unref() to dbus_message_unref()]
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=91008
2015-06-17 19:00:02 +01:00
Simon McVittie
54357a9692 tests: use the new bus setup for make installcheck
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89280
Reviewed-by: Dimitri John Ledkov <dimitri.j.ledkov@intel.com>
2015-06-17 16:06:53 +01:00
Simon McVittie
54f94fce08 dbus-daemon.1: document the new locations
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89280
Reviewed-by: Dimitri John Ledkov <dimitri.j.ledkov@intel.com>
2015-06-17 16:06:39 +01:00
Simon McVittie
3b0a05b57c NEWS 2015-05-27 11:49:44 +01:00
Dimitri John Ledkov
70950325c7 Adjust cmake build to match autoconf installation locations.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89280
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-27 11:49:41 +01:00
Dimitri John Ledkov
b2c61ca6ea Move session & system bus configuration to datadir, by default.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89280
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-27 11:49:34 +01:00
Simon McVittie
4cbe3019c7 Start towards 1.9.18 2015-05-27 10:42:46 +01:00
Simon McVittie
2381b81d05 more NEWS, also more release name 2015-05-14 15:04:36 +01:00
Simon McVittie
6986e22be1 1.9.16 2015-05-14 14:50:24 +01:00
Simon McVittie
b57223d701 Merge branch 'dbus-1.8'
Conflicts:
	NEWS
2015-05-14 14:45:04 +01:00
Simon McVittie
db31c8995e add a missing change, fix some bug numbers 2015-05-14 14:43:53 +01:00
Simon McVittie
1c4f87ca28 Merge branch 'dbus-1.8'
Conflicts:
	NEWS
	cmake/CMakeLists.txt
	configure.ac
2015-05-14 14:41:06 +01:00
Simon McVittie
bcdead0fd4 Fail to generate random bytes instead of falling back to rand()
This is more robust against broken setups where we run out
of memory or cannot read /dev/urandom.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90414
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
[smcv: document @error]
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-14 14:30:30 +01:00
Simon McVittie
f385324d8b Make UUID generation failable
Previously, this would always succeed, but might use
weak random numbers in rare failure cases. I don't think
these UUIDs are security-sensitive, but if they're generated
by a PRNG as weak as rand() (<= 32 bits of entropy), we
certainly can't claim that they're universally unique.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90414
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
[smcv: document @error]
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-14 14:30:30 +01:00
Simon McVittie
49646211f3 _dbus_server_init_base: raise a DBusError
This can currently only fail from OOM, but I'm about to make
it possible to fail from insufficient entropy.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90414
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
[smcv: document @error]
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-14 14:30:30 +01:00
Simon McVittie
f180a83972 _dbus_server_new_for_socket: raise a DBusError
This can currently only fail due to OOM, but I'm about to
make it possible to fail for other reasons.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90414
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
[smcv: correct failure to set error in one case; document @error]
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-14 14:30:30 +01:00
Simon McVittie
084977cfe2 Security hardening: force EXTERNAL auth in session.conf on Unix
DBUS_COOKIE_SHA1 is dependent on unguessable strings, i.e.
indirectly dependent on high-quality pseudo-random numbers
whereas EXTERNAL authentication (credentials-passing)
is mediated by the kernel and cannot be faked.

On Windows, EXTERNAL authentication is not available,
so we continue to use the hard-coded default (all
authentication mechanisms are tried).

Users of tcp: or nonce-tcp: on Unix will have to comment
this out, but they would have had to use a special
configuration anyway (to set the listening address),
and the tcp: and nonce-tcp: transports are inherently
insecure unless special steps are taken to have them
restricted to a VPN or SSH tunnelling.

Users of obscure Unix platforms (those that trigger
the warning "Socket credentials not supported on this Unix OS"
when compiling dbus-sysdeps-unix.c) might also have to
comment this out, or preferably provide a tested patch
to enable credentials-passing on that OS.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90414
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-05-14 14:30:30 +01:00
Simon McVittie
31489e1c4f start towards 1.8.20 2015-05-14 14:30:08 +01:00
Simon McVittie
1788e8f93d 1.8.18 2015-05-14 13:28:38 +01:00
Ralf Habacker
954371eea2 dbus_daemon_publish_session_bus_address: Fix -Wsign-compare issue.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90089
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-14 12:32:09 +01:00
Simon McVittie
4df63ce80b NEWS 2015-05-13 18:52:23 +01:00
Simon McVittie
b9a5ea27f9 Avoid reading beyond the length of a variable
Appending &some as DBUS_TYPE_INT64, DBUS_TYPE_UINT64 or DBUS_TYPE_DOUBLE,
where "some" is an int, reads beyond the bounds of that variable.
Use a zero-filled DBusBasicValue instead.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=30350
2015-05-13 18:44:44 +01:00
Simon McVittie
c8b2d74503 Fix whitespace as per Havoc's review (in 2010)
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=30350
2015-05-13 18:44:44 +01:00
Christian Dywan
8e83c6e4d5 Implement dbus_message_iter_get_element_count
According unit tests are added to _dbus_message_test.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=30350
Reviewed-by: Havoc Pennington <hp@pobox.com>
2015-05-13 18:44:42 +01:00
Simon McVittie
ae56222048 DBusSocket: put the #ifdef case before the !defined case
This avoids the confusing #ifndef...#else anti-pattern.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-05-12 18:37:07 +01:00
Ralf Habacker
36e9dace74 Convert mostly DBUS_SOCKET_... and DBUS_POLLABLE_.. macros for more type safety.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-12 18:36:24 +01:00
Simon McVittie
f5e1c1391f Turn DBusSocket into a type-safe struct, preventing inappropriate conversion
Fix the remaining platform-specific code to look at the struct's
appropriate platform-specific member.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
2015-05-12 18:35:56 +01:00
Simon McVittie
54395bd5ad Remove _dbus_socket_is_invalid, no longer used
It didn't have many users anyway, and I've replaced them with the
DBUS_SOCKET_IS_VALID macro.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-05-12 18:35:49 +01:00
Simon McVittie
68d8c66680 Convert miscellaneous socket APIs to DBusSocket
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-05-12 18:35:38 +01:00
Simon McVittie
bbbd79b6ea generic socket transport code: work in terms of DBusSocket
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-05-12 18:35:24 +01:00
Simon McVittie
21ca7f7cc3 Split _dbus_set_fd_nonblocking vs. _dbus_set_socket_nonblocking
The former is Unix-specific, the latter is also portable to Windows.
On Unix, they're really the same thing.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-05-12 18:35:13 +01:00
Simon McVittie
378e01c0d0 main: reload_pipe is (despite its name) a socket pair
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-05-12 18:34:56 +01:00
Simon McVittie
520802f8c2 DBusMainLoop, DBusSocketSet: work in terms of DBusPollable
This requires generic support for keying hash tables by DBusPollable:
there are already implementations for int and uintptr_t keys, but not
for "int or uintptr_t depending on platform", which is what
DBusPollable now means.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
2015-05-12 18:34:32 +01:00
Simon McVittie
6ac3d6f70a Mostly remove the remnants of an older socket abstraction layer
This is only used on Windows, and wasn't even a particularly abstract
abstraction.

I've removed DBUS_SOCKET_IS_INVALID in favour of DBUS_SOCKET_IS_VALID
because I prefer to avoid double-negatives.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-05-12 18:34:24 +01:00
Simon McVittie
cc652d9f0c dbus-sysdeps: add more infrastructure around DBusSocket
This is all trivial right now, but will become significant when we
change DBusSocket into a type-safe struct.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-05-12 18:34:19 +01:00
Simon McVittie
064884f977 bus_unix_fds_passing_test: the results of _dbus_socketpair are sockets
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-05-12 18:33:50 +01:00
Ralf Habacker
ede75686ff Use typedef DBusSocket for sockets fd's to avoid conversion warnings.
[smcv: remove unneeded and invalid dbus-sysdeps.h from public header;
make prototype of _dbus_socketpair() consistent; undo conversion
of getaddrinfo result from int to SOCKET; don't call
_dbus_return_val_if_fail() from internal function]

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89444
2015-05-12 18:33:43 +01:00
Simon McVittie
d9ab893182 Security hardening: force EXTERNAL auth in session.conf on Unix
DBUS_COOKIE_SHA1 is dependent on unguessable strings, i.e.
indirectly dependent on high-quality pseudo-random numbers
whereas EXTERNAL authentication (credentials-passing)
is mediated by the kernel and cannot be faked.

On Windows, EXTERNAL authentication is not available,
so we continue to use the hard-coded default (all
authentication mechanisms are tried).

Users of tcp: or nonce-tcp: on Unix will have to comment
this out, but they would have had to use a special
configuration anyway (to set the listening address),
and the tcp: and nonce-tcp: transports are inherently
insecure unless special steps are taken to have them
restricted to a VPN or SSH tunnelling.

Users of obscure Unix platforms (those that trigger
the warning "Socket credentials not supported on this Unix OS"
when compiling dbus-sysdeps-unix.c) might also have to
comment this out, or preferably provide a tested patch
to enable credentials-passing on that OS.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90414
2015-05-12 11:54:50 +01:00
Ralf Habacker
77e1b3110a reader_init: Initialize all fields of struct DBusTypeReader (CID 54754, 54772, 54773).
This patch is based on the fix for 'Field reader.array_len_offset is
uninitialized'

Reported by Coverity: CID 54754, 54772, 54773: Uninitialized scalar
variable (UNINIT)

[smcv: also re-order how the class is set when we recurse, so that
the sub-reader's class doesn't end up NULL]

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90021
2015-05-08 15:54:42 +01:00
Simon McVittie
720e3ccb62 Merge branch 'dbus-1.8' 2015-05-08 15:37:58 +01:00
Simon McVittie
480f0182fa Revert "reader_init: Initialize all fields of struct DBusTypeReader (CID 54754, 54772, 54773)."
This reverts commit 21a7873f20.

This appears to cause a segfault, presumably resulting from something
assuming that reader_init() would not reinitialize all fields:

 #0  0x00007ffff7b74777 in _dbus_type_reader_get_current_type (reader=reader@entry=0x7fffffffda50) at .../dbus/dbus-marshal-recursive.c:791
 #1  0x00007ffff7b719d0 in _dbus_header_cache_check (header=<optimized out>)
    at .../dbus/dbus-marshal-header.c:209
 #2  0x00007ffff7b719d0 in _dbus_header_cache_check (header=header@entry=0x624658, field=field@entry=6) at .../dbus/dbus-marshal-header.c:250
 #3  0x00007ffff7b72884 in _dbus_header_get_field_basic (header=header@entry=0x624658, field=field@entry=6, type=type@entry=115, value=value@entry=0x7fffffffdbd8) at .../dbus/dbus-marshal-header.c:1365
 #4  0x00007ffff7b7d8c2 in dbus_message_get_destination (message=message@entry=0x624650) at .../dbus/dbus-message.c:3457
 #5  0x00007ffff7b67be6 in _dbus_connection_send_preallocated_unlocked_no_update (connection=connection@entry=0x6236d0, preallocated=0x0,
    preallocated@entry=0x6234c0, message=message@entry=0x624650, client_serial=client_serial@entry=0x7fffffffdcbc)
    at .../dbus/dbus-connection.c:2017
2015-05-08 15:36:19 +01:00
Ralf Habacker
84b2682eef auth_set_unix_credentials: Fix calling _dbus_credentials_add_pid without checking return value (CID 54708).
Reported by Coverity: CID 54708: Unchecked return value (CHECKED_RETURN)

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90021
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-06 12:14:47 +02:00
Ralf Habacker
8b5788b2c2 auth_set_unix_credentials: Fix calling _dbus_credentials_add_unix_uid without checking return value (CID 54722).
Reported by Coverity: CID 54722: Unchecked return value (CHECKED_RETURN)

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90021
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-06 12:14:44 +02:00
Ralf Habacker
5948bd13ed Merge remote-tracking branch 'origin/dbus-1.8' 2015-05-06 12:14:31 +02:00
Ralf Habacker
21a7873f20 reader_init: Initialize all fields of struct DBusTypeReader (CID 54754, 54772, 54773).
This patch is based on the fix for 'Field reader.array_len_offset is uninitialized'

Reported by Coverity: CID 54754, 54772, 54773: Uninitialized scalar variable (UNINIT)

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90021
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-06 12:11:04 +02:00
Ralf Habacker
2e96b07e94 do_check_nonce: Fix of calling _dbus_string_append_len without checking return value (CID 54720).
Reported by Coverity: CID: Unchecked return value (CHECKED_RETURN)

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90021
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-05-06 12:10:59 +02:00