Commit graph

1971 commits

Author SHA1 Message Date
Lennart Poettering
ba7daa606c unix-fd: add basic marshalling code for unix fds
This is actually pretty boring since we store our fds as indexes that
are stored as uint32_t's.
2009-05-20 01:36:44 +02:00
Lennart Poettering
faac66e3ea unix-fd: introduce basic protocol definitions
We introduce a new type code for the unix fds. The data stored in unix
fd fields will be an integer index into the array of fds that are
attached to a specific message. We also introduce a new header field
that stores how many fds belong to the message. And finally we introduce
a new error for messages where the payload and the meta data (i.e. unix
fds read for it) don't match up.
2009-05-20 01:36:37 +02:00
Lennart Poettering
4c4db7f9da sysdeps-unix: add basic IO primitives for unix fd passing
This introduces three new functions:

_dbus_read_socket_with_unix_fds
_dbus_write_socket_with_unix_fds
_dbus_read_socket_with_unix_fds_two

These work exactly like their counterpart sans 'with_unix_fds' except
that they also send/recieve file descriptors along with the actual
payload data.
2009-05-20 01:36:27 +02:00
Lennart Poettering
64c63db21e sysdeps-unix: introduce _dbus_socket_can_pass_unix_fd()
This function can be used to check if a socket can be used to pass file
descriptors. On platforms that don't support this at all this is
hardcoded to return FALSE.
2009-05-20 01:36:26 +02:00
Lennart Poettering
18f7259a43 sysdeps-unix: introduce _dbus_dup()
This is a simple wrapper around dup()-like functionality.

Also handles CLOEXEC and makes sure we don't interfere with the standard
I/O file descriptors 0, 1 and 2.
2009-05-20 01:36:19 +02:00
Lennart Poettering
03d50fbd77 sysdeps-unix: if MSG_NOSIGNAL is available don't touch SIGPIPE by default
If we can use MSG_NOSIGNAL we don't have to play games with SIGPIPE
2009-05-15 20:30:15 +02:00
Lennart Poettering
ff0a8993d4 sysdeps-unix: Use MSG_NOSIGNAL when available
On Linux send()/sendmsg() know the special flag MSG_NOSIGNAL which if
set makes sure that no SIGPIPE signal is raised when we write to a
socket that has been disconnected.

By using this flag we don't have to play games with SIGPIPE which is
pretty ugly stuff since it touches the global process context.
2009-05-15 20:30:15 +02:00
Lennart Poettering
6d2eacba89 memory: remove semicolons from macros
Due to some unknown reasons the dbus_new() macros had a semicolon at the
end which makes it impossible to use them in some situations.
2009-05-15 20:30:15 +02:00
Lennart Poettering
3801b6de78 build-system: get rid of config.h inclusion checks
These header files include config.h explicitly anyway. These checks are
hence pointless.

Of course one could argue that including config.h from header files
sucks, but D-Bus generally seems not to have a problem with that, so
let's unify this.
2009-05-15 20:30:15 +02:00
Thiago Macieira
f322112b84 Merge branch 'dbus-1.2' 2009-05-13 15:52:26 +02:00
Thiago Macieira
e21d06cba4 Merge branch 'dbus-1.2'
Conflicts:
	dbus/dbus-sysdeps-util-unix.c
2009-05-13 15:52:18 +02:00
Marc Mutz
6eddb6e122 configure.in: fail abstract socket test gracefully when cross-compiling
* configure.in: only run AC_CACHE_CHECK if enable_abstract_sockets=auto
 * configure.in: warn that, when cross-compiling, we're unable to detect
                 abstract sockets availability automatically

Signed-off-by: Thiago Macieira <thiago@kde.org>
2009-05-13 15:50:52 +02:00
Marc Mutz
f719d45432 configure.in: not all gccs support -Wno-pointer-sign
Signed-off-by: Thiago Macieira <thiago@kde.org>
2009-05-13 15:50:51 +02:00
Colin Walters
f76d17437e Release 1.2.14 2009-05-06 12:51:19 -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
Federico Mena Quintero
73ec6964d7 bfo20738 - Return a useful error message from dbus_signature_validate()
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-05-06 12:51:18 -04:00
Federico Mena Quintero
0f19140b52 bfo20738 - Translate DBusValidity into error message
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-05-06 12:51:18 -04:00
William Lachance
0cf4583b5a Bug 19567 - Make marshaling code usable without DBusConnection
Some projects want to reuse the DBus message format, without
actually going through a DBusConnection.  This set of changes
makes a few functions from DBusMessage public, and adds a new
function to determine the number of bytes needed to demarshal
a message.

Signed-off-by: Colin Walters <walters@verbum.org>
2009-05-06 12:51:18 -04:00
Colin Walters
86df8ad592 Followup Bug 19502 - Don't attempt to init va_list, not portable 2009-05-06 12:51:18 -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
Eamon Walsh
da75989b39 dbus-launch: use InputOnly X window
Working on SELinux policy for X, and came across this issue in dbus-launch:

Windows created for use as property/selection placeholders should be of
class InputOnly, since no drawing is ever done to them.

Signed-off-by: Eamon Walsh <ewalsh@tycho.nsa.gov>
Signed-off-by: Thiago Macieira <thiago@kde.org>
2009-05-06 12:51:17 -04:00
Johan Gyllenspetz
5b4ee5fb40 Bug 20494 - Fix signed confusion for dbus_message_get_reply_serial return
We were incorrectly converting the serial to a signed integer
and comparing it to -1.

Signed-off-by: Colin Walters <walters@verbum.org>
2009-05-06 12:51:17 -04:00
Colin Walters
15f5183016 Bug 20137 - Fix alignment usage when demarshaling basics
We can't safely type-pun from e.g. char * to DBusBasicValue *, because
the latter has higher alignment requirements.  Instead, create an
explicit pointer for each case.

Also, we mark each one volatile to sidestep strict aliasing issues, for
the future when we turn on strict aliasing support.

Original patch and review from Jay Estabrook <jay.estabrook@hp.com>.
2009-05-06 12:51:17 -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
Colin Walters
b5a1f3c54a Bug 17803 - Fix both test case and validation logic
The previous commit had errors in both the test case and
the validation logic.  The test case was missing a trailing
comma before the previous one, so we weren't testing the
signature we thought we were.

The validation logic was wrong because if the type was not valid,
we'd drop through the entire if clause, and thus skip returning
an error code, and accept the signature.
2009-05-06 12:51:16 -04: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
Marc Mutz
b2f943e9c0 configure.in: fix help string alignment
* AC_ARG_ENABLE(libaudit: use AS_HELP_STRING for aligned help messages

Signed-off-by: Thiago Macieira <thiago@kde.org>
(cherry picked from commit 660073925b)
2009-04-28 14:42:20 +02:00
Eamon Walsh
705b34f0a6 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-04-22 11:18:39 -04:00
Federico Mena Quintero
27f8a31fe6 bfo20738 - Return a useful error message from dbus_signature_validate()
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-04-21 14:09:54 -04:00
Federico Mena Quintero
099b5e59ea bfo20738 - Translate DBusValidity into error message
Signed-off-by: Federico Mena Quintero <federico@novell.com>
2009-04-21 14:09:54 -04:00
William Lachance
16a947eedb Bug 19567 - Make marshaling code usable without DBusConnection
Some projects want to reuse the DBus message format, without
actually going through a DBusConnection.  This set of changes
makes a few functions from DBusMessage public, and adds a new
function to determine the number of bytes needed to demarshal
a message.

Signed-off-by: Colin Walters <walters@verbum.org>
2009-04-21 13:51:46 -04:00
Colin Walters
ce09b82ec2 Followup Bug 19502 - Don't attempt to init va_list, not portable 2009-04-21 13:11:54 -04:00
Kjartan Maraas
3c89788fa4 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-04-21 13:10:10 -04:00
Thiago Macieira
83d7da43c4 Merge branch 'dbus-1.2' 2009-04-21 13:00:50 +02:00
Marc Mutz
11f4aaa77f configure.in: fix help string alignment
* AC_ARG_ENABLE(libaudit: use AS_HELP_STRING for aligned help messages

Signed-off-by: Thiago Macieira <thiago@kde.org>
(cherry picked from commit 660073925b)
2009-04-21 13:00:41 +02:00
Marc Mutz
660073925b configure.in: fix help string alignment
* AC_ARG_ENABLE(libaudit: use AS_HELP_STRING for aligned help messages

Signed-off-by: Thiago Macieira <thiago@kde.org>
2009-04-20 18:22:58 +02:00
Colin Walters
e8f8c1c5a2 Bug 17803 - Fix both test case and validation logic
The previous commit had errors in both the test case and
the validation logic.  The test case was missing a trailing
comma before the previous one, so we weren't testing the
signature we thought we were.

The validation logic was wrong because if the type was not valid,
we'd drop through the entire if clause, and thus skip returning
an error code, and accept the signature.
2009-04-17 13:25:39 -04:00
Eamon Walsh
8f5c3e3c25 dbus-launch: use InputOnly X window
Working on SELinux policy for X, and came across this issue in dbus-launch:

Windows created for use as property/selection placeholders should be of
class InputOnly, since no drawing is ever done to them.

Signed-off-by: Eamon Walsh <ewalsh@tycho.nsa.gov>
Signed-off-by: Thiago Macieira <thiago@kde.org>
2009-03-20 09:08:37 +01:00
Johan Gyllenspetz
387ccafb4d Bug 20494 - Fix signed confusion for dbus_message_get_reply_serial return
We were incorrectly converting the serial to a signed integer
and comparing it to -1.

Signed-off-by: Colin Walters <walters@verbum.org>
2009-03-17 17:26:03 -04:00
Colin Walters
7de15965c2 Bug 20137 - Fix alignment usage when demarshaling basics
We can't safely type-pun from e.g. char * to DBusBasicValue *, because
the latter has higher alignment requirements.  Instead, create an
explicit pointer for each case.

Also, we mark each one volatile to sidestep strict aliasing issues, for
the future when we turn on strict aliasing support.

Original patch and review from Jay Estabrook <jay.estabrook@hp.com>.
2009-03-17 16:42:43 -04:00
Colin Walters
3f3a531902 Always append closing quote in log command
Patch suggested by Tomas Hoger <thoger@redhat.com>
2009-03-12 10:31:54 -04:00
Xan Lopez
5a3907f28f Fix typo in docs. 2009-02-02 15:15:23 -05:00
Xan Lopez
16e9289ca2 Fix typo in docs. 2009-02-02 15:14:45 -05:00
Colin Walters
c30270f182 Bump for unstable cycle 2009-01-06 19:36:11 -05:00
Colin Walters
1757a749c3 Release 1.2.12. 2009-01-06 19:35:55 -05:00
Colin Walters
be47457346 Add Scott to HACKING 2009-01-06 18:41:03 -05:00
Colin Walters
2895b793eb Bug 17060: Explicitly hard fail if expat is not available
* configure.in: Tweak libxml/expat detection and handling.
2009-01-06 18:27:27 -05:00
Lionel Landwerlin
1334ecb435 Bug 17969: Don't test for abstract sockets if explicitly disabled
Signed-off-by: Colin Walters <walters@verbum.org>
2009-01-06 18:26:39 -05:00
Jon Gosting
d437d9202e Bug 18064 - more efficient validation for fixed-size type arrays
* dbus/dbus-marshal-validate.c: If an array is fixed size,
	skip validation

Signed-off-by: Colin Walters <walters@verbum.org>
2009-01-06 18:26:04 -05: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