Commit graph

100 commits

Author SHA1 Message Date
Ralf Habacker
b0286eed76 Wrap path verbose output with '' to be able to see trailing spaces.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92721
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-11-02 13:19:22 +01:00
Simon McVittie
f5e5894a47 Assume that DBUS_DATADIR is absolute on Windows
Both build systems arrange for this to be the case,
and we already assume that it's absolute on Unix.
On Windows, it's probably going to be /mingw/share or
something; it gets relocated via _dbus_replace_install_prefix()
at runtime.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83539
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-10-05 16:29:54 +01:00
Simon McVittie
9b8f844e10 Replace build-time prefix with installation prefix when including config files
This was already done for the contents of .service files, but not
config files.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92028
Tested-by: Ralf Habacker <ralf.habacker@freenet.de>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-10-05 16:29:44 +01:00
Simon McVittie
f830e14d30 Use DBusString for all relocation and install-root code
This means we handle OOM correctly, and makes it obvious
that we are not overflowing buffers. This change does not
affect the actual content of the strings.

Instead of redefining DBUS_DATADIR to be a function call
(which hides the fact that DBUS_DATADIR is used),
this patch makes each use explicit: DBUS_DATADIR
is always the #define from configure or cmake, before
replacing the prefix.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83539
Tested-by: Ralf Habacker <ralf.habacker@freenet.de>
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
2015-10-05 16:29:29 +01:00
Ralf Habacker
26a3c0dc5b include_dir: skip processing on error (CID 54744)
We already skipped processing for DBUS_ERROR_FILE_NOT_FOUND;
but if the error was something else, we would pass the NULL
pointer dir to _dbus_directory_get_next_file(), which dereferences it.
Reported by Coverity: CID 54744: Dereference after null check (FORWARD_NULL)

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90021
[smcv: re-worded commit message]
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-04-16 13:15:19 +01:00
Dimitri John Ledkov
57971f69ef Make include_dir non-existing directory, to not be an error.
Empty include directories were already not treated as failures.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89280
Signed-off-by: Dimitri John Ledkov <dimitri.j.ledkov@intel.com>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-02-25 15:59:24 +00:00
Tyler Hicks
06033cb20f Add apparmor element support to bus config parsing
The <apparmor> element can contain a single mode attribute that has one
of three values:

 "enabled"
 "disabled"
 "required"

"enabled" means that kernel support is autodetected and, if available,
AppArmor mediation occurs in dbus-daemon. If kernel support is not
detected, mediation is disabled. "disabled" means that mediation does
not occur. "required" means that kernel support must be detected for
dbus-daemon to start.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=75113
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2015-02-18 17:04:00 +00:00
Simon McVittie
02e1ddf91e Revert "config: change default auth_timeout to 5 seconds"
This reverts commit 54d26df52b.

It appears this change may cause intermittent slow or failed boot,
more commonly on slower/older machines, in at least Mageia and
possibly also Debian. This would indicate that while the system
is under load, system services are not completing authentication
within 5 seconds.

This change was not the main part of fixing CVE-2014-3639, but does
help to mitigate that attack. As such, increasing this timeout makes
the denial of service attack described by CVE-2014-3639 somewhat
more effective: a local user connecting to the system bus repeatedly
from many parallel processes can cause other users' attempts to
connect to take longer.

If your machine boots reliably with the shorter timeout, and
resilience against local denial of service attacks is important
to you, putting this in /etc/dbus-1/system-local.conf
or a file matching /etc/dbus-1/system.d/*.conf can restore
the lower limit:

    <busconfig>
      <limit name="auth_timeout">5000</limit>
    </busconfig>

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=86431
2014-11-22 10:49:21 +00:00
Alban Crequy
bbf11cd5f9 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>
2014-09-15 12:29:30 +01:00
Alban Crequy
54d26df52b 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>
2014-09-15 12:28:10 +01:00
Alban Crequy
5bc7f9519e 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>
2014-09-15 12:27:20 +01:00
Matt Hoosier
fc3bf2f304 Don't forget allow_anonymous when merging configs
The algorithm to collapse a subsidiary config file's data into the
master data structure forgot to examine this flag.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=73475
Reviewed-by: Chengwei Yang <chengwei.yang@intel.com>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2014-01-14 11:04:18 +00:00
Simon McVittie
412538b3b9 Export dbus_setenv() as a utility function
It's sufficiently portable that GLib has an equivalent, and I really
don't want to have to either open-code it in dbus-run-session or
link dbus-run-session statically. We have enough statically-linked
rubbish already.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39196
Reviewed-by: Colin Walters <walters@verbum.org>
2013-08-23 11:40:50 +01:00
Chengwei Yang
db2757f812 tests to embedded tests: replaced in dbus-daemon
Signed-off-by: Chengwei Yang <chengwei.yang@intel.com>
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66291
2013-06-28 12:13:28 +01:00
Matt Fischer
977293549d Set default maximum number of Unix fds according to OS
QNX has an arbitrary limit to the number of file descriptors
which may be passed in a message, which is smaller than the
current default.  This patch therefore changes the default from
a hardcoded constant to a macro, which is determined at configure
time by looking at the host operating system.

[This reduces the limit from 4096 (session)/1024 (system) to 128 fds
per message on QNX, and 1024 fds per message on other operating systems.
I think the reduced session bus limit on other OSs is a reasonable change
too, given that the default hard/soft ulimits in Linux are only 4096/1024
fds per process. -smcv]

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61176
Reviewed-by: Simon McVittie <simon.mcvittie.collabora.co.uk>
2013-04-11 13:34:55 +01:00
Krzysztof Konopko
161b7d7007 Merge <servicehelper> from included config file
<servicehelper> is not supported in the included config file, i. e. it's
not merged in merge_included().  There's clearly no reason it shouldn't
be supported in the included config file along with <user>, <type>
and others.  It's quite reasonable for a client willing to override the
default servicehelper, e. g. in system-local.conf.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=51560
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2013-02-12 10:49:29 +00:00
Alban Crequy
f1cfc138ef test: enforce own_prefix policy rules
After parsing [allow|deny] rules with own_prefix, check they are enforced
correctly.

https://bugs.freedesktop.org/show_bug.cgi?id=46886
2012-03-22 11:51:23 +00:00
Alban Crequy
5670dc6cf7 config parser: add own_prefix
https://bugs.freedesktop.org/show_bug.cgi?id=46882
2012-03-04 14:36:56 +00:00
Simon McVittie
fccb5a0fe1 Explicitly don't search XDG_DATA_DIRS for system services, and document it
In practice, it never works, because the activation helper doesn't
respect environment variables for security reasons.
If you want to vary the search path, alter system.conf instead, to
replace or augment <standard_system_servicedirs/> with your preferred
search path.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=21620
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2012-02-08 16:11:35 +00:00
Simon McVittie
222b7d9f97 config-parser: don't try to get CommonProgramFiles from the environment on Unix
It's unused on Unix, and gcc warns.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39231
Reviewed-by: Will Thompson <will.thompson@collabora.co.uk>
2011-08-05 12:27:04 +01:00
Lennart Poettering
d837d937c5 activation: add /lib/dbus-1/system-services to the search path for services
In order to allow D-Bus usage during early boot (where /usr is not
accessible) also search for bus activation files in
/lib/dbus-1/system-services/. This is only a first step in the right
direction, before we really can boot without /usr we'd need to move all
current activation files (or possibly replace
/usr/dbus-1/system-services to a symlink to
/lib/dbus-1/system-services).
2011-07-28 21:22:07 +02:00
Simon McVittie
75cecfc374 Break up the monster conditional in config-parser so gcov can cope
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=10887
Reviewed-by: Colin Walters <walters@verbum.org>
2011-04-07 11:25:54 +01:00
Andre Heinecke
e0fc90bdf2 Do not use the name ELEMENT_TYPE
On Windows Systems ELEMENT_TYPE is already defined
in Winioctl.h this header is included indirectly
in dbus-sysdeps.h. By avoiding the use of the Name
ELEMENT_TYPE it is ensured that config-parser-common.h
can be included together with dbus-sysdeps.h

Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
2011-03-07 13:50:38 +00:00
Simon McVittie
7848abe6c2 config-parser regression test: don't require that fd.o #34496 exists
Reviewed-by: Will Thompson <will.thompson@collabora.co.uk>
2011-02-24 18:40:11 +00:00
Simon McVittie
7480dfdb2a If a file included via <includedir/> is invalid, syslog and skip it
This is more graceful than failing entirely (our previous behaviour),
but more visible than ignoring it completely (the previous behaviour
patched in by Debian and derivatives).

Based on a patch from Daniel Silverstone back in 2004, which was meant
to be temporary; I think it makes sense to change this permanently,
since files in *.d are typically supplied by other packages, whose bugs
shouldn't be able to bring down dbus-daemon.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=19186
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=230231
Reviewed-by: Colin Walters <walters@verbum.org>
2011-01-31 19:16:00 +00:00
Ralf Habacker
02d973686a Use absolute session service dir path in bus-test on windows. 2010-12-29 14:43:24 +01:00
Marcus Brinkmann
dbecdeabb2 Consistently include <config.h> in all C source files and never in header files. 2010-03-19 20:11:48 +01:00
Ralf Habacker
73b926275f uses tcp based test connections for now 2009-12-01 11:17:40 +01:00
Thiago Macieira
37019e9d27 Merge branch 'fd-passing'
Conflicts:
	dbus/dbus-connection.c
	dbus/dbus-message-util.c
	dbus/dbus-sysdeps-unix.c
2009-07-16 16:05:16 +02:00
Tobias Mueller
5baf2f856a Bug 21161 - Update the FSF address
No comment.

Signed-off-by: Colin Walters <walters@verbum.org>
2009-07-10 19:32:38 -04:00
Scott James Remnant
8f1d2a2fa8 Change default reply timeout.
* bus/config-parser.c (bus_config_parser_new): change the default reply
  timeout to "never"

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
2009-05-28 11:47:36 +02:00
Lennart Poettering
64ad844967 bus: make use of new unix fd limits
Create configuration settings and enforce message unix fd limits the
same way we do for allocated message memory.
2009-05-20 02:10:17 +02:00
Thiago Macieira
63196f69c4 Merge branch 'dbus-1.2'
Conflicts:
	bus/bus.c
	bus/config-parser-common.c
	bus/config-parser-common.h
	bus/config-parser.c
	bus/connection.c
	bus/dbus-daemon.1.in
	dbus/dbus-marshal-validate-util.c
	dbus/dbus-marshal-validate.c
	dbus/dbus-sysdeps-util-unix.c
	test/name-test/tmp-session-like-system.conf
2009-04-28 15:16:36 +02:00
Matt McCutchen
6663d1dd35 Bug 18446: Keep umask for session bus
Signed-off-by: Colin Walters <walters@verbum.org>
2009-01-06 18:20:13 -05:00
Colin Walters
427ff01f9d Add optional logging on allow rules
This lets us have a backwards compatibility allow rule but still easily
see when that rule is being used.
2008-12-16 12:20:43 -05:00
Colin Walters
6053d2208e Add optional logging on allow rules
This lets us have a backwards compatibility allow rule but still easily
see when that rule is being used.
2008-12-16 11:57:27 -05:00
Colin Walters
69ed32cbcc Add syslog of security denials and configuration file reloads
We need to start logging denials so that they become more easily trackable
and debuggable.
2008-12-12 15:18:12 -05:00
Colin Walters
bb2a464067 Add syslog of security denials and configuration file reloads
We need to start logging denials so that they become more easily trackable
and debuggable.
2008-12-12 14:00:16 -05:00
Dennis Kaarsemaker
07a4ad4b04 Bug 15393 - support allow_anonymous config variable
* bus/bus.c: Set allow_anonymous if specified from
	parser.
	* bus/config-parser.c: Parse it.
	* bus/config-parser-common.h: Declare it.

Signed-off-by: Colin Walters <walters@verbum.org>
2008-11-12 08:51:00 -05:00
Matt McCutchen
0314e701c8 Bug 18446: Keep umask for session bus
Signed-off-by: Colin Walters <walters@verbum.org>
2008-11-10 08:55:27 -05:00
John (J5) Palmieri
f72bb380a6 remove dead code
2008-01-15  John (J5) Palmieri  <johnp@redhat.com>

	* patch by Kimmo Hämäläinen <kimmo dot hamalainen at nokia dot com>

	* bus/config-parser.c (locate_attributes): remove dead code which
	always evaluated to TRUE

	* dbus/dbus-shell.c (_dbus_shell_quote): remove unused code
2008-01-15 13:32:47 -05:00
Havoc Pennington
79d3004e26 2007-07-24 Havoc Pennington <hp@redhat.com>
* configure.in: add AM_PROG_CC_C_O to allow per-target CPPFLAGS

	* bus/dispatch.c (bus_dispatch_test_conf): Fix up setting
	TEST_LAUNCH_HELPER_CONFIG to include the full path, and enable
	test shell_fail_service_auto_start when use_launcher==TRUE

	* bus/activation-helper-bin.c (convert_error_to_exit_code): pass
	through the INVALID_ARGS error so the test suite works

	* bus/activation.c (handle_activation_exit_error): return
	DBUS_ERROR_NO_MEMORY if we get BUS_SPAWN_EXIT_CODE_NO_MEMORY

	* dbus/dbus-spawn.c (_dbus_babysitter_get_child_exit_status):
	return only the exit code of the child, not the entire thingy from
	waitpid(), and make the return value indicate whether the child
	exited normally (with a status code)

	* bus/bus.c (process_config_first_time_only): _dbus_strdup works
	on NULL so no need to check
	(process_config_every_time): move servicehelper init here, so we
	reload it on HUP or config file change

	* bus/Makefile.am (install-data-hook): remove comment because
	Emacs make mode seems to be grumpy about it
2007-07-24 22:11:00 +00:00
Richard Hughes
0cb8dd64a9 2007-07-24 Richard Hughes <richard@hughsie.com>
* bus/Makefile.am:
* bus/config-parser.c: (bus_config_parser_unref),
(start_busconfig_child), (bus_config_parser_end_element),
(servicehelper_path), (bus_config_parser_content),
(bus_config_parser_finished),
(bus_config_parser_get_servicehelper),
(test_default_session_servicedirs),
(test_default_system_servicedirs), (bus_config_parser_test):
* bus/config-parser.h:
Make the config-parser code use the common config code.
Also add the session and systemdirs stuff, and make the config parser
aware of the servicehelper field.
2007-07-24 11:58:08 +00:00
Havoc Pennington
d012387afe 2007-07-13 Havoc Pennington <hp@redhat.com>
* Add indent-tabs-mode: nil to all file headers.
2007-07-14 02:44:01 +00:00
Havoc Pennington
ebb99420e5 add a comment about the match rules limit 2007-06-19 17:23:55 +00:00
Havoc Pennington
7be5fd95cd 2007-06-09 Havoc Pennington <hp@redhat.com>
* bus/policy.c (bus_policy_create_client_policy): gracefully
	continue if the connection has no unix user - just don't apply
	any unix user dependent rules.

	* bus/config-parser.c: remove dbus-userdb.h usage

	* bus/bus.c: remove dbus-userdb.h usage

	* dbus/dbus-transport.c (_dbus_transport_get_is_authenticated):
	support Windows user function; also, fix the logic for checking
	auth as root in the default auth code (broken in the previous
	commit)

	* dbus/dbus-connection.c
	(dbus_connection_set_windows_user_function): new function
	(dbus_connection_get_windows_user): new function
2007-06-09 23:41:33 +00:00
Ralf Habacker
5bd59d4a6c * bus/config-parser.c (test_service_dir_matches): fixed ordering for unix.
* bus/config-parser.c (test_default_session_servicedirs): made allocation  of _progs platform independent.
2007-05-24 08:07:28 +00:00
Ralf Habacker
e02f8b1c00 * bus\config-parser.c (test_default_session_servicedirs):win32 fix. 2007-05-17 11:47:48 +00:00
Ralf Habacker
cd57ebe33b * bus/config-parser.c, bus/policy.c, bus/policy.h, bus/dbus-daemon.1.in,bus/session.conf.in: added eavesdrop support for replies - patch by olli.salli at collabora.co.uk approved by Havoc Pennington. 2007-03-15 13:27:01 +00:00
Havoc Pennington
9362aac398 2007-03-11 Havoc Pennington <hp@redhat.com>
* tools/dbus-launch.c (do_close_stderr): fix C89 problem and
	formatting problem

	* Mostly fix the DBusPipe mess.
	- put line break after function return types
	- put space before parens
	- do not pass structs around by value
	- don't use dbus_strerror after calling supposedly cross-platform
	api
	- don't name pipe variables "fd"
	- abstract special fd numbers like -1 and 1
2007-03-12 22:52:40 +00:00