Commit graph

411 commits

Author SHA1 Message Date
Colin Walters
3dac125d61 Fix compilation in --disable-selinux case
_dbus_change_to_daemon_user moved into selinux.c for the --with-selinux
(and audit) case because that's where all of the relevant libcap headers
were being used.  However in the --disable-selinux case this didn't
compile and wasn't very clean.

If we don't have libaudit, use the legacy direct setgid/setuid bits
we had before in dbus-sysdeps-util-unix.c.
2010-02-02 15:04:58 -05:00
Colin Walters
90fe96b187 Fix inotify shutdown
We were incorrectly passing NULL for a DBusList when the usage expected
is a pointer to a NULL DBusList pointer.  Also during dbus_shutdown
we need to actually close the inotify fd, and remove our watch.

Move the shutdown handler out of bus.c and into inotify where we
can do all of this cleanly.
2010-02-02 15:04:45 -05:00
Colin Walters
8a9880ffd2 Clean up inotify watch handling
Substantially based on a patch by Matthias Clasen <mclasen@redhat.com>
kqueue implementation by Joe Marcus Clarke <marcus@freebsd.org>

Previously, when we detected a configuration change (which included
the set of config directories to monitor for changes), we would
simply drop all watches, then readd them.

The problem with this is that it introduced a race condition where
we might not be watching one of the config directories for changes.

Rather than dropping and readding, change the OS-dependent monitoring
API to simply take a new set of directories to monitor.  Implicit
in this is that the OS-specific layer needs to keep track of the
previously monitored set.
2010-02-01 16:22:56 -05:00
Colin Walters
0705eb5c86 Update messagebus.in init script to start earlier
Patch from Fedora.
2010-01-28 17:31:36 -05:00
Colin Walters
b93476ce07 Don't drop pending activations when reloading configuration
The reload handling for activation simply dropped all knowledge
of pending activations, which was clearly wrong.  Refactor things
so that reload only reloads directories, server address etc.

Based on a patch originally from Matthias Clasen <mclasen@redhat.com>
2010-01-28 17:01:24 -05:00
Colin Walters
0a3905d7f3 Switch to libcap-ng, avoid linking libdbus against libcap[-ng]
(Commit message written by Colin Walters <walters@verbum.org>)

A current Fedora goal is to convert projects to libcap-ng which
more easily allows dropping Linux capabilities.  For software
which also links to libdbus, it's problematic to link against
libcap as well.

Though really, libdbus should have never linked against libcap
in the first place, which is another thing this patch changes
by moving the libcap-using bits out of dbus/ and into bus/.

https://bugzilla.redhat.com/show_bug.cgi?id=518541
2010-01-28 17:01:24 -05:00
Colin Walters
b7e77c6b03 Ignore exit code zero from activated services
A variety of system components have migrated from legacy init into DBus
service activation.  Many of these system components "daemonize", which
involves forking.  The DBus activation system treated an exit as an
activation failure, assuming that the child process which grabbed the
DBus name didn't run first.

While we're in here, also differentiate in this code path between the
servicehelper (system) versus direct activation (session) paths.  In
the session activation path our error message mentioned a helper
process which was confusing, since none was involved.

Based on a patch and debugging research from Ray Strode <rstrode@redhat.com>
2010-01-28 17:01:24 -05:00
Matthias Clasen
8343c971cd Bug 25697 - Fix memory leak in policy reload
Signed-off-by: Colin Walters <walters@verbum.org>
2009-12-18 14:29:40 -05:00
Colin Watson
be89ffacc9 Fix link order: system libraries should come after libdbus-convenience
libdbus-convenience may use system libraries, but not the other way
round. Most platforms don't care, but on some platforms this means that
system libraries need to be listed after libdbus-convenience.la on the
link line.
2009-09-18 21:12:39 +02:00
Matthias Clasen
943b9d3944 Bug 22516 - Ensure inotify fd is set close on exec
This prevents it leaking into spawned child processes.

Signed-off-by: Colin Walters <walters@verbum.org>
(cherry picked from commit f4e15893e5)
2009-07-14 15:40:17 -04:00
Tobias Mueller
dc33f4f774 Bug 21161 - Update the FSF address
No comment.

Signed-off-by: Colin Walters <walters@verbum.org>
(cherry picked from commit 5baf2f856a)
2009-07-14 15:39:47 -04:00
Scott James Remnant
21b0ff273a Unrestrict session bus timeout.
* bus/session.conf.in: Remove the reply_timeout stanza, previously
  intended to increase the reply timeout, this now reduces it.

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
(cherry picked from commit bd2063e17e)
2009-07-14 15:38:33 -04:00
Scott James Remnant
f68efe1e80 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>
(cherry picked from commit 8f1d2a2fa8)
2009-07-14 15:38:25 -04:00
Scott James Remnant
ce326587c3 Expire list timeout may be negative for no expiry.
* bus/expirelist.c (do_expiration_with_current_time): Don't check for
  expiry if expire_after is negative, will just disable the expiry timer
  after the call.

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
(cherry picked from commit d672d03206)
2009-07-14 15:38:18 -04:00
Scott James Remnant
e296855e41 Explicitly check for zero time fields.
* bus/expirelist.c (do_expiration_with_current_time): If the item added
  time fields are both zero, always expire.

Signed-off-by: Scott James Remnant <scott@ubuntu.com>
(cherry picked from commit d33cfec625)
2009-07-14 15:38:11 -04:00
Eamon Walsh
b38c433bf7 libselinux behavior in permissive mode wrt invalid domains
Stephen Smalley wrote:
> On Tue, 2009-04-21 at 16:32 -0400, Joshua Brindle wrote:
>
>> Stephen Smalley wrote:
>>
>>> On Thu, 2009-04-16 at 20:47 -0400, Eamon Walsh wrote:
>>>
>>>> Stephen Smalley wrote:
>>>>
>> <snip>
>>
>>
>>> No, I don't want to change the behavior upon context_to_sid calls in
>>> general, as we otherwise lose all context validity checking in
>>> permissive mode.
>>>
>>> I think I'd rather change compute_sid behavior to preclude the situation
>>> from arising in the first place, possibly altering the behavior in
>>> permissive mode upon an invalid context to fall back on the ssid
>>> (process) or the tsid (object).  But I'm not entirely convinced any
>>> change is required here.
>>>
>>>
>> I just want to follow up to make sure we are all on the same page here. Was the
>> suggestion to change avc_has_perm in libselinux or context_to_sid in the kernel
>> or leave the code as is and fix the callers of avc_has_perm to correctly handle
>> error codes?
>>
>> I prefer the last approach because of Eamon's explanation, EINVAL is already
>> passed in errno to specify the context was invalid (and if object managers
>> aren't handling that correctly now there is a good chance they aren't handling
>> the ENOMEM case either).
>>
>
> I'd be inclined to change compute_sid (not context_to_sid) in the kernel
> to prevent invalid contexts from being formed even in permissive mode
> (scenario is a type transition where role is not authorized for the new
> type).  That was originally to allow the system to boot in permissive
> mode.  But an alternative would be to just stay in the caller's context
> (ssid) in that situation.
>
> Changing the callers of avc_has_perm() to handle EINVAL and/or ENOMEM
> may make sense, but that logic should not depend on enforcing vs.
> permissive mode.
>
>

FWIW, the following patch to D-Bus should help:

bfo21072 - Log SELinux denials better by checking errno for the cause

    Note that this does not fully address the bug report since
    EINVAL can still be returned in permissive mode.  However the log
    messages will now reflect the proper cause of the denial.

Signed-off-by: Eamon Walsh <ewalsh@tycho.nsa.gov>
Signed-off-by: Colin Walters <walters@verbum.org>
2009-05-06 12:51:19 -04:00
Kjartan Maraas
eb3b99e7c6 Bug 19502 - Sparse warning cleanups
This patch makes various things that should be static static,
corrects some "return FALSE" where it should be NULL, etc.

Signed-off-by: Colin Walters <walters@verbum.org>
2009-05-06 12:51:18 -04:00
Colin Walters
a709566edd Always append closing quote in log command
Patch suggested by Tomas Hoger <thoger@redhat.com>
2009-05-06 12:51:17 -04:00
James Carter
1f3bcd241e Initialize AVC earlier so we can look up service security contexts
* bus/bus.c: Initialize AVC earlier:
	http://lists.freedesktop.org/archives/dbus/2008-October/010493.html

Signed-off-by: Colin Walters <walters@verbum.org>
2009-01-06 18:22:39 -05:00
Tor Lillqvist
1000270072 [win32] Protect usage of SIGHUP with #ifdef
Signed-off-by: Colin Walters <walters@verbum.org>
2009-01-06 18:21:25 -05: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
Peter Breitenlohner
eebad8668d Avoid possible use of uninitialized variable
Signed-off-by: Colin Walters <walters@verbum.org>
2009-01-06 17:43:32 -05:00
Colin Walters
4e4f0de8cc Various compiler warning fixes 2009-01-06 17:38:32 -05:00
Colin Walters
788e592b32 Add requested_reply to send denials, and connection loginfo to "would deny"
The requested_reply field is necessary in send denials too because
it's used in the policy language.  The connection loginfo lack in
"would deny" was just an oversight.
2008-12-18 15:39:18 -05:00
Colin Walters
9a1657e8e1 Add uid, pid, and command to security logs
Extend the current security logs with even more relevant
information than just the message content.  This requires
some utility code to look up and cache (as a string)
the data such as the uid/pid/command when a connection is
authenticated.
2008-12-18 15:39:04 -05:00
Colin Walters
c224ba1861 Merge commit '3d6abf64d0abb2718e082e120f14f8f923a4af59' into dbus-1.2 2008-12-16 12:29:04 -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
8cbe86da90 Add message type to security syslog entries
It's part of the security check, we should have it in the log.
2008-12-12 17:07:01 -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
3d6abf64d0 Clean up and clarify default system policy
The former was too reliant on old bugs and was generally unclear.
This one makes explicit exactly what is allowed and not.
2008-12-12 14:50:21 -05:00
Colin Walters
df09db0d42 Another manpage update explicitly mentioning bare send_interface
We need to fix all of the bare send_interface rules; see:
https://bugs.freedesktop.org/show_bug.cgi?id=18961
2008-12-09 10:19:16 -05:00
Colin Walters
120604d272 Add at_console docs to manpage, as well as brief <policy> foreward
We need some sort of general advice here.
2008-12-09 10:19:01 -05:00
Colin Walters
d899734475 Bug 18229: Allow signals
Our previous fix went too far towards lockdown; many things rely
on signals to work, and there's no really good reason to restrict
which signals can be emitted on the bus because we can't tie
them to a particular sender.
2008-12-09 10:17:36 -05:00
Tomas Hoger
8fad15265f Bug 18229 - Change system.conf to correctly deny non-reply sends by default
The previous rule <allow send_requested_reply="true"/> was actually
applied to all messages, even if they weren't a reply.  This meant
that in fact the default DBus policy was effectively allow, rather
than deny as claimed.

This fix ensures that the above rule only applies to actual reply
messages.
Signed-off-by: Colin Walters <walters@verbum.org>
2008-12-05 11:39:43 -05:00
Colin Walters
121c6b13a3 Bug 16294: Don't lose inotify watch when config fails to parse
* bus/dir-watch-inotify.c: Always drop the watch in
	handle_inotify_watch; this ensures we always readd it
	correctly in bus_drop_all_directory_watches.
2008-07-28 12:02:56 -04:00
Ray Strode
3bc6840b04 Fix leaks in bus_activation_get_environment error paths
Commit 91306ef938 introduced
two memory leaks on OOM error paths.  In one case the
environment string array wasn't getting freed, and in the
other case it was getting freed with dbus_free instead of
dbus_free_string_array.
2008-07-15 04:01:49 -04:00
Ray Strode
01e50bcd5d Update man page to make the point of the <type> element more clear
There have been a number of patches in the past try to key system
versus session bus policy off of the message bus type, when the
policy should be distinguished from more fine-grained options in the
individulal policy files.  Hopefully, this man page update will make
that more clear.
2008-07-12 13:38:04 -04:00
Ray Strode
37853b6dd0 Add new UpdateActivationEnvironment bus message
It adjusts the environment of activated bus clients.
This is important for session managers that get started
after the session bus daemon and want to influence the
environment of desktop services that are started by the
bus.
2008-07-12 13:38:00 -04:00
Ray Strode
91306ef938 Store what environment to activate with on activation object
We now keep the environment in a hash table member of the
activation object and provide a method
bus_activation_set_environment_variable to modify the
hash table.  This hash table is seeded initially with the
environment of the bus daemon itself.
2008-07-12 13:21:23 -04:00
Colin Walters
ab1eb1fd5a Bug 15740: Solaris/ADT auditing support (simon zheng)
* bus/driver.c: Add GetAdtAuditSessionData method
	which returns audit data for a connection.
	* configure.in: Detect ADT auditing support
	* dbus/dbus-auth.c: Read ADT auditing creds.
	* dbus/dbus-connection.c: Implement
	dbus_connection_get_adt_audit_session_data.
	* dbus/dbus-connection.h: Export it.
	* dbus/dbus-credentials.c: Add support for
	gathering adt_audit_data and retrieving it
	via _dbus_credentials_get_adt_audit_data.
	* dbus/dbus-credentials.h: Add
	DBUS_CREDENTIAL_ADT_AUDIT_DATA_ID.
	* dbus/dbus-protocol.h: New error
	DBUS_ERROR_ADT_AUDIT_DATA_UNKNOWN.
	* dbus/dbus-sysdeps.c: Support for reading
	audit credentials via ADT API.
	* dbus/dbus-transport.c: New function
	_dbus_transport_get_adt_audit_session_data
	to retrieve credentials.
	* dbus/dbus-transport.h: Export it.
2008-06-05 17:24:34 -04:00
Kimmo Hämäläinen
7c4b345802 fix expiration of pending replies
* bus/expirelist.c
  (do_expiration_with_current_time): calculate correct min wait time
  and next interval
  (bus_expire_list_add, bus_expire_list_add_link): if the timeout is
  disabled when we add an item to the expire list, enable the timeout
  (do_expiration_with_current_time): only set timeout if there are
  items to expire
2008-04-03 11:12:27 -04:00
John (J5) Palmieri
960fef844b Merge branch 'master' of git+ssh://johnp@git.freedesktop.org/git/dbus/dbus
Conflicts:

	ChangeLog
2008-04-03 11:11:19 -04:00
Frederic Crozat
68f69d3818 Fixes for the inotify configuration file monitor backend.
2008-04-01  Timo Hoenig  <thoenig@suse.de>

Patch from Frederic Crozat <fcrozat@mandriva.com>

* bus/dir-watch-inotify.c (bus_watch_directory): Only monitor
  IN_CLOSE_WRITE, IN_DELETE, IN_MOVE_TO and IN_MOVE_FROM events. This
  way, only atomic changes to configuration file are monitored.
* bus/dir-watch-inotify.c (_handle_inotify_watch): Fix typo in
  _dbus_verbose function call
* bus/dir-watch-inotify.c (bus_drop_all_directory_watches): Use
  _dbus_strerror instead of perror
2008-04-01 18:09:46 +02:00
Havoc Pennington
a37404111b Make BusExpireList an opaque data type
2007-11-08  Havoc Pennington  <hp@redhat.com>

	* bus/connection.c, bus/expirelist.c: Make the BusExpireList
	struct opaque, adding accessors for manipulating the list. In this
	commit there should be no change in functionality or behavior. The
	purpose of this change is to improve encapsulation prior to fixing
	some bugs Kimmo Hämäläinen found where the timeout is not properly
	updated, since we need to e.g. take some action whenever adding
	and removing stuff from the expire list.
2008-03-04 14:21:42 -05:00
John (J5) Palmieri
6db561dce2 CVE-2008-0595 dbus security policy circumvention
* CVE-2008-0595 - security policy of the type <allow send_interface=
  "some.interface.WithMethods"/> work as an implicit allow for
  messages sent without an interface bypassing the default deny rules
  and potentially allowing restricted methods exported on the bus to be
  executed by unauthorized users.  This patch fixes the issue.
* bus/policy.c (bus_client_policy_check_can_send,
  bus_client_policy_check_can_receive): skip messages without an
  interface when evaluating an allow rule, and thus pass it to the
  default deny rules
2008-02-26 13:30:47 -05:00
John (J5) Palmieri
be8750940b fix build against the latest gcc/glibc
* dbus/dbus-sysdeps-unix.c: define _GNU_SOURCE
* bus/selinux.c: include limits.h
* Patch by Matthias Clasen <mclasen at redhat.com>
2008-02-21 13:42:06 -05:00
John (J5) Palmieri
e1821fc35a fix inotify support
2008-01-17  Timo Hoenig  <thoenig@suse.de>
	* fix inotify support
	* bus/dir-watch-inotify.c (_handle_inotify_watch): fix reading of the
	inotify events. Also, use ssize_t not size_t for 'ret'.
	* bus/dir-watch-inotify.c (bus_watch_directory): watch not only for
	IN_MODIFY but also for IN_CREATE and IN_DELETE
	* bus/dir-watch-inotify.c (bus_drop_all_directory_watches): drop the
	inotify watches more elegantly by closing inotify:_fd, set inotify_fd to
	-1 after dropping the watches
2008-01-17 14:57:47 -05:00
John (J5) Palmieri
71c2677086 add lsb headers to init script (FDO Bug #11491)
2008-01-15  John (J5) Palmieri  <johnp@redhat.com>

	* bus/messagebus.in: add lsb headers (FDO Bug #11491)
2008-01-15 16:58:36 -05:00
John (J5) Palmieri
4cc2bfa10e check failed allocation (FDO Bug #12920)
2008-01-15  John (J5) Palmieri  <johnp@redhat.com>

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

	* bus/bus.c (setup_server): check failed allocation (FDO Bug #12920)
2008-01-15 15:49:35 -05:00
John (J5) Palmieri
9db435926f rewrite selinux error handling to not abort due to a NULL read
2008-01-15  John (J5) Palmieri  <johnp@redhat.com>

	* bus/bus.c (bus_context_check_security_policy): rewrite selinux error
	handling to not abort due to a NULL read and to set the error only if
	it is not already set (Based off of FDO Bug #12430)
2008-01-15 14:20:43 -05:00