Commit graph

145 commits

Author SHA1 Message Date
Lennart Poettering ee104e11e3 user-util: move UID/GID related macros from macro.h to user-util.h 2015-10-27 13:25:57 +01:00
Lennart Poettering 430f0182b7 src/basic: rename audit.[ch] → audit-util.[ch] and capability.[ch] → capability-util.[ch]
The files are named too generically, so that they might conflict with
the upstream project headers. Hence, let's add a "-util" suffix, to
clarify that this are just our utility headers and not any official
upstream headers.
2015-10-27 13:25:57 +01:00
Lennart Poettering 6bedfcbb29 util-lib: split string parsing related calls from util.[ch] into parse-util.[ch] 2015-10-27 13:25:55 +01:00
Lennart Poettering 3ffd4af220 util-lib: split out fd-related operations into fd-util.[ch]
There are more than enough to deserve their own .c file, hence move them
over.
2015-10-25 13:19:18 +01:00
Lennart Poettering 07630cea1f util-lib: split our string related calls from util.[ch] into its own file string-util.[ch]
There are more than enough calls doing string manipulations to deserve
its own files, hence do something about it.

This patch also sorts the #include blocks of all files that needed to be
updated, according to the sorting suggestions from CODING_STYLE. Since
pretty much every file needs our string manipulation functions this
effectively means that most files have sorted #include blocks now.

Also touches a few unrelated include files.
2015-10-24 23:05:02 +02:00
Lennart Poettering 50e0d56cf3 sd-bus: fix error handling of pthread API calls
pthread APIs (unlike the rest of libc) return their errors as positive
error codes directly from the functions, rather than using errno. Let's
make sure we always handle things that way.
2015-10-17 16:48:21 +02:00
David Herrmann 057171efc1 Revert "sd-bus: do not connect to dbus-1 socket when kdbus is available"
This reverts commit d4d00020d6. The idea of
the commit is broken and needs to be reworked. We really cannot reduce
the bus-addresses to a single address. We always will have systemd with
native clients and legacy clients at the same time, so we also need both
addresses at the same time.
2015-08-27 16:32:22 +02:00
David Herrmann 19bee5c367 sd-bus: rename bloom-tag to arg0-has
We use dashes in our bloom-tags. Make sure the newly introduced arg0has
tag uses the same style.

Note that the external dbus-tags don't use dashes, though. They are
defined in the spec and we need to keep compatibility there.
2015-08-27 16:29:01 +02:00
Lennart Poettering eccd47c5be sd-bus: introduce new match type "arg0has=" for matching arrays of strings
Previously, sd-bus inofficially already supported bus matches that
tested a string against an array of strings ("as"). This was done via an
enhanced way to interpret "arg0=" matches. This is problematic however,
since clients have no way to determine if their respective
implementation understood strv matches or not, thus allowing invalid
matches to be installed without a way to detect that.

This patch changes the logic to only allow such matches with a new
"arg0has=" syntax. This has the benefit that non-conforming
implementations will return a parse error and a client application may
thus efficiently detect support for the match type.

Matches of this type are useful for "udev"-like systems that "tag" objects
with a number of strings, and clients need to be able to match against
any of these "tags".

The name "has" takes inspiration from Python's ".has_key()" construct.
2015-08-25 19:28:30 +02:00
Kay Sievers d4d00020d6 sd-bus: do not connect to dbus-1 socket when kdbus is available
We should not fall back to dbus-1 and connect to the proxy when kdbus
returns an error that indicates that kdbus is running but just does not
accept new connections because of quota limits or something similar.

Using is_kdbus_available() in libsystemd/ requires it to move from
shared/ to libsystemd/.

Based on a patch from David Herrmann:
  https://github.com/systemd/systemd/pull/886
2015-08-11 20:49:36 +02:00
Lennart Poettering 3f624df6cf sd-bus: ignore BLOOM_FILTER kdbus items
The kernel nowadays sends these along, and that's OK, hence don't even
debug log about it, but completely ignore it.
2015-08-06 15:48:33 +03:00
Thomas Hindoe Paaboel Andersen 7d6884b65e tree-wide: fix indentation 2015-08-06 00:44:19 +02:00
David Herrmann 95cdf5e3a9 sd-bus: don't treat KDBUS_ITEM_TIMESTAMP as unknown item
In bus_kernel_translate_message(), we print a DEBUG message on unknown
items. But right now, we also print this message for KDBUS_ITEM_TIMESTAMP
despite parsing it properly. Fix this!
2015-07-24 12:53:23 +02:00
David Herrmann 0c9cc10dcc sd-bus: don't leak kdbus notifications
When we get notifications from the kernel, we always turn them into
synthetic dbus1 messages. This means, we do *not* consume the kdbus
message, and as such have to free the offset.

Right now, the translation-helpers told the caller that they consumed the
message, which is wrong. Fix this by explicitly releasing all kernel
messages that are translated.
2015-07-02 12:24:05 +02:00
Simon McVittie 11c9f1e48a Stop talking about the "XDG" version of basename()
XDG refers to X Desktop Group, a former name for freedesktop.org.
This group is responsible for specifications like basedirs,
.desktop files and icon naming, but as far as I know, it has never
tried to redefine basename().

I think these references were meant to say XPG (X/Open Portability
Guide), a precursor of POSIX. POSIX is better-known and less easily
confused with XDG, and is how the basename(3) man page describes
the libgen.h version of basename().

The other version of basename() is glibc-specific and is described
in basename(3) as "the GNU version"; specifically mention that
version, to disambiguate.
2015-06-17 11:23:46 +01:00
Lennart Poettering aa0d0ed6b8 sd-bus: remove ucred parameter from bus_message_from_header() since we don't use it anymore 2015-06-10 15:52:52 +02:00
David Herrmann ed47f6397d bus: don't force send-masks on kdbus buses
Right now we always pass KDBUS_ITEM_ATTACH_FLAGS_RECV to
KDBUS_CMD_BUS_MAKE, effectively forcing every bus connection to do the
same during KDBUS_CMD_HELLO. This used to be a workaround to make sure all
metadata is always present. However, we refrained from that approach and
intend to make all metadata collection solely rely on /proc access
restrictions. Therefore, there is no need to force the send-flags mask on
newly created buses.
2015-06-05 15:23:03 +02:00
Kay Sievers 6517217d49 kdbus: remove attach_flags_mask module parameter setting 2015-06-03 22:24:16 +02:00
Torstein Husebø ff9b60f38b treewide: Correct typos and spell plural of bus consistent 2015-05-11 15:51:30 +02:00
Lennart Poettering 524d896ac1 sd-bus: when we get ENOTTY on the HELLO ioctl assume incompatible API version
As perparation for future incompatible kdbus kernel API changes.
2015-04-30 01:24:48 +02:00
Lennart Poettering cfeaa44a09 sd-bus: properly handle creds that are known but undefined for a process
A number of fields do not apply to all processes, including: there a
processes without a controlling tty, without parent process, without
service, user services or session. To distuingish these cases from the
case where we simply don't have the data, always return ENXIO for them,
while returning ENODATA for the case where we really lack the
information.

Also update the credentials dumping code to show this properly. Fields
that are known but do not apply are now shown as "n/a".

Note that this also changes some of the calls in process-util.c and
cgroup-util.c to return ENXIO for these cases.
2015-04-29 21:45:58 +02:00
Lennart Poettering 1386e47db5 sd-bus: expose ppid field
kdbus has been passing us the ppid file for a while, actually make use
of it.
2015-04-21 20:58:09 +02:00
Ronny Chevalier 6482f6269c shared: add formats-util.h 2015-04-10 23:54:48 +02:00
David Herrmann 15411c0cb1 tree-wide: there is no ENOTSUP on linux
Replace ENOTSUP by EOPNOTSUPP as this is what linux actually uses.
2015-03-13 14:10:39 +01:00
Daniel Mack 606303a93e sd-bus: sync kdbus.h (ABI break)
After some reconsideration, we decided to move the binary protocol
back to 64-bit wide UIDs and GIDs. After all, it should be possible
to redefine [gu]id_t to uint64_t and things should continue to
work. As we want to avoid such data types in kdbus.h, let's move
back to 64-bit values and be safe.

In sd-bus, we have to do a translation between uint64_t and gid_t
now for supplementary gids.

Some inline comments have also been updated in kdbus upstream.
2015-03-02 11:36:35 +01:00
Daniel Mack 6ad4a4fc43 sd-bus: sync kdbus.h
Follow two small changes in the kdbus API:

 * Flags are now returned in cmd->return_flags by KDBUS_CMD_NAME_ACQUIRE

 * struct kdbus_item_list has been dropped. The information stored in
   this struct was redundant since awhile already, as all commands
   report their returned slice size anyway.
2015-02-24 12:10:13 +01:00
Thomas Hindoe Paaboel Andersen 2eec67acbb remove unused includes
This patch removes includes that are not used. The removals were found with
include-what-you-use which checks if any of the symbols from a header is
in use.
2015-02-23 23:53:42 +01:00
David Herrmann 83e30358f2 bus: sync with kdbus
Pull in new kdbus changes, namely:
 - EOVERFLOW is replaces by KDBUS_RECV_RETURN_DROPPED_MSGS
 - ENOMSG is merged with EAGAIN for consistency
2015-02-17 18:16:07 +01:00
Lennart Poettering b267a6d204 sd-bus: make sure we always serialize the reply cookie as 64bit on dbus2, and 32bit on dbus1 2015-02-16 16:31:29 +01:00
Lennart Poettering 2ac7c17f9d Revert "Revert "sd-bus: change serialization of kdbus messages to qualify in their entirety as gvariant objects""
This reverts commit 954871d8ba.
2015-02-16 15:03:44 +01:00
Daniel Mack 403193f54b sd-bus: sync kdbus.h (ABI break)
Another slice logic rework in kdbus made KDBUS_ITEM_PAYLOAD_OFF items
relative to the message header again. Catch up with that in sd-bus.
2015-02-13 14:55:51 +01:00
Lennart Poettering eef46c372f tree-wide: whenever we include libgen.h, immediately undefine basename()
Also, document in adjacent comments and in CODING_STYLE why we do that.
2015-02-11 18:50:38 +01:00
David Herrmann b2086f601b bus: sync with kdbus (ABI break) 2015-02-05 16:52:42 +01:00
Kay Sievers 954871d8ba Revert "sd-bus: change serialization of kdbus messages to qualify in their entirety as gvariant objects"
This breaks booting with kdbus.

This reverts commit b381de4197.
2015-01-30 13:53:45 +01:00
Lennart Poettering b381de4197 sd-bus: change serialization of kdbus messages to qualify in their entirety as gvariant objects
Previously, we only minimally altered the dbus1 framing for kdbus, and
while the header and its fields where compliant Gvariant objects, and so
was the body, the entire message together was not.

As result of discussions with Ryan Lortie this is now changed, so that
the messages in there entirely are fully compliant GVariants. This
follows the framing description described here:

https://wiki.gnome.org/Projects/GLib/GDBus/Version2

Note that this change changes the framing of *all* messages sent via
kdbus, this means you have to reboot your kdbus system, after compiling
and installing this new version.
2015-01-26 21:52:07 +01:00
Lennart Poettering 72e6110485 sd-bus: reuse the KDBUS_CMD_FREE wrapper wherever appropriate 2015-01-26 21:52:07 +01:00
David Herrmann 314808cea4 bus: drop systemd.kdbus_attach_flags_mask= cmdline
There is no reason to provide our own attach_flags_mask. We can simply
rely on kdbus.attach_flags_mask= which is read by the kernel *and* kmod.
If it's set, we assume the user wants to override our setting, so we
simply skip setting it.
2015-01-18 23:56:19 +01:00
Daniel Mack a9c8343e83 sd-bus: sync kdbus.h (API break)
Just a simple variable rename, and a dropped flag that sd-bus didn't make
use of.
2015-01-12 18:15:45 +01:00
David Herrmann 7ce9812173 bus: append bloom-filter to all signals
Make sure to append bloom-filters to all signal-messages, not only
broadcasts.
2015-01-09 00:53:30 +01:00
Lennart Poettering d29ae2914e sd-bus: unify how we set the sender of synthetic messages 2015-01-07 20:25:30 +01:00
Lennart Poettering 76877fb9cc sd-bus: make use of the newly added timestamps on kdbus kernel messages 2015-01-07 19:53:39 +01:00
Daniel Mack d7d052b23f sd-bus: sync kdbus.h
Catch up with latest changes in kdbus.ko:

 * Signals can be sent as unicast now, hence they need to be marked as
   such with the KDBUS_MSG_SIGNAL in the message flags.

 * Follow ioctl number change for KDBUS_CMD_FREE
2015-01-05 13:44:40 +01:00
David Herrmann 7d9fcc2bf6 bus: fix capabilities on big-endian
The kernel provides capabilities as a u32 array, sd-bus uses an u8 array.
This works fine on little-endian as both are encoded the same way.
However, this fails on big-endian if we do not perform sufficient
byte-swapping on each u32 entry.

This patch makes sd-bus use u32, too. We avoid changing any kernel
provided data so we can keep pointing into kdbus pool buffers which
contain u32 arrays.
2014-12-30 09:09:41 +01:00
David Herrmann 34a5d5e526 bus: drop creds->capability_size
The number of available caps can be read from
/proc/sys/kernel/cap_last_cap during runtime. Our helper cap_last_cap()
does that, so there's no reason to remember the size of any capability
cache. We can just pre-allocate arrays with a suitable size for all
available caps and reject any higher caps.

The kernel capability API uses u32 as base so make sure we do the same.
Note that this is specified by POSIX, so it's unlikely to change.
2014-12-30 08:42:53 +01:00
David Herrmann 315a73d97f bus: fix typo
Drop spurious 'we'.
2014-12-29 12:55:28 +01:00
Lennart Poettering 3c70e3bb02 core: rearrange code so that libsystemd/sd-bus/ does not include header files from core
Stuff in src/shared or src/libsystemd should *never* include code from
src/core or any of the tools, so don't do that here either. It's not OK!
2014-12-23 19:15:27 +01:00
Daniel Mack 856d6e0988 sd-bus: ignore KDBUS_ITEM_TIMESTAMP in kernel messages
Kernel notifications carry a timestamp now, so make sure
bus_kernel_translate_message() doesn't complain when it stumbles across
them.
2014-12-22 19:59:53 +01:00
David Herrmann 19ee32dc4d bus: send attach flags on BUS_MAKE
Make sure to set send-attach-flags on BUS_MAKE. These control which
information is revealed about the bus-owner.
2014-12-12 14:02:57 +01:00
David Herrmann 18ee085c15 bus: fix assert() on HELLO error-path
Make sure we don't call into any bus_kernel_*() functions before
b->is_kernel is set to true. Hard-code the CMD_FREE just like the other
helpers do.
2014-12-12 14:02:05 +01:00
David Herrmann d31f486b83 bus: sync with kdbus.git
Changes:
 * bloom parameters are returned in an offset via HELLO
 * FREE now takes items just like any other ioctl
2014-12-11 17:26:03 +01:00