Commit graph

39 commits

Author SHA1 Message Date
Lennart Poettering a1e58e8ee1 tree-wide: use coccinelle to patch a lot of code to use mfree()
This replaces this:

        free(p);
        p = NULL;

by this:

        p = mfree(p);

Change generated using coccinelle. Semantic patch is added to the
sources.
2015-09-09 08:19:27 +02:00
Lennart Poettering d7e46e01ac audit: audit calls should return ENODATA when process are not in an audit session
ENODATA is how we usually indicate such "missing info" cases, so we
should do this here, too.
2015-09-04 09:07:31 +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
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
Zbigniew Jędrzejewski-Szmek 236f83afa9 bus-creds: always set SD_BUS_CREDS_PID when we set pid in the mask
Also reorder the code a bit to be easier to parse.
2015-06-09 09:13:35 -04:00
Torstein Husebø 45afd51974 treewide: fix typos 2015-05-26 19:55:51 +02:00
Lennart Poettering 329ac4bc54 sd-bus,sd-login: add api for querying the slice within the the user systemd instance of a process
units are organized in slice trees, not only for the system instance,
but also for user systemd instances, expose this properly.
2015-04-30 11:58:06 +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 4761e880ae sd-bus: add controlling tty field to sd_creds object
This is useful to print wall messages from logind with the right client
tty. (to be added in a later patch)
2015-04-23 19:43:40 +02:00
Lennart Poettering 3a69881704 sd-bus: handle ppid=0 more gracefully (which happens for pid=1) 2015-04-22 13:27:53 +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
Lennart Poettering 0f51442056 sd-bus: when augmenting creds, remember which ones were augmented
Also, when we do permissions checks using creds, verify that we don't do
so based on augmented creds, as extra safety check.
2015-04-21 00:58:56 +02:00
Lennart Poettering 822d9b6e4c sd-bus: augmenting cgroups-based creds when we have the cgroup path already is free 2015-04-21 00:58:56 +02:00
Lennart Poettering f887fa73ee sd-bus: when augmenting creds, don't override any creds in any case
Let's better be safe than sorry.
2015-04-21 00:58:56 +02:00
Lennart Poettering da634f97eb sd-bus: when copying creds objects, make sure we copy even the implicit well known names 2015-04-21 00:58:56 +02:00
Ronny Chevalier 0b452006de shared: add process-util.[ch] 2015-04-10 23:54:49 +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
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
Lennart Poettering 1c0216696a sd-bus: fix typo 2015-01-23 03:00:15 +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
Lennart Poettering 3280236156 sd-bus: get rid of PID starttime concept
As kdbus no longer exports this, remove all traces from sd-bus too
2014-12-09 18:16:54 +01:00
Lennart Poettering fb6d9b77a7 sd-bus: set creds info for "org.freedesktop.DBus.Local" generated messages, too 2014-11-27 22:05:23 +01:00
Lennart Poettering ac653862e0 sd-bus: fake valid well-known-names metadata for faked bus messages 2014-11-27 22:02:12 +01:00
Lennart Poettering 50c4521675 sd-bus: optimize how we generate the well-known-names lists in messages from kdbus 2014-11-27 22:02:12 +01:00
Lennart Poettering e12d81ae80 sd-bus: given that the kernel now passes the auxgroups list as 32bit array to us, no need to convert to uid_t manually
This way, we can save one allocation and avoid copying the array
unnecesarily.
2014-11-26 14:59:12 +01:00
Lennart Poettering a6ede528c4 sd-bus: properly copy selinux label and description field when duplicating creds object 2014-11-25 14:28:34 +01:00
Lennart Poettering 0258159049 sd-bus: add supplementary groups list to creds object 2014-11-25 14:28:34 +01:00
Lennart Poettering 705a415f68 sd-bus: update to current kernel version, by splitting off the extended KDBUS_ITEM_PIDS structure from KDBUS_ITEM_CREDS
Also:

- adds support for euid, suid, fsuid, egid, sgid, fsgid fields.

- makes augmentation of creds with data from /proc explicitly
  controllable to give apps better control over this, given that this is
  racy.

- enables augmentation for kdbus connections (previously we only did it
  for dbus1). This is useful since with recent kdbus versions it is
  possible for clients to control the metadata they want to send.

- changes sd_bus_query_sender_privilege() to take the euid of the client
  into consideration, if known

- when we don't have permissions to read augmentation data from /proc,
  don't fail, just don't add the data in
2014-11-25 14:28:34 +01:00
Lennart Poettering 455971c149 sd-bus: rename "connection name" to "description" for the sd-bus API too
kdbus recently renamed this concept, and so should we in what we expose
in userspace.
2014-11-04 16:13:49 +01:00
Zbigniew Jędrzejewski-Szmek de0671ee7f Remove unnecessary casts in printfs
No functional change expected :)
2014-05-15 15:29:58 +02:00
Lennart Poettering a6278b8830 bus: replace sd_bus_label_{escape,unescape}() by new sd_bus_path_{encode,decode}()
The new calls work similarly, but enforce a that a common, fixed bus
path prefix is used.

This follows discussions with Simon McVittie on IRC that it should be a
good idea to make sure that people don't use the escaping applied here
too wildly as anything other than the last label of a bus path.
2014-03-11 19:03:50 +01:00
Lennart Poettering 151b9b9662 api: in constructor function calls, always put the returned object pointer first (or second)
Previously the returned object of constructor functions where sometimes
returned as last, sometimes as first and sometimes as second parameter.
Let's clean this up a bit. Here are the new rules:

1. The object the new object is derived from is put first, if there is any

2. The object we are creating will be returned in the next arguments

3. This is followed by any additional arguments

Rationale:

For functions that operate on an object we always put that object first.
Constructors should probably not be too different in this regard. Also,
if the additional parameters might want to use varargs which suggests to
put them last.

Note that this new scheme only applies to constructor functions, not to
all other functions. We do give a lot of freedom for those.

Note that this commit only changes the order of the new functions we
added, for old ones we accept the wrong order and leave it like that.
2014-02-20 00:03:10 +01:00
Lennart Poettering 9f5650aecb util: generalize code that checks whether PIDs are alive or unwaited for 2014-02-18 02:51:47 +01:00
Lennart Poettering 2578d51ebd bus: unescape connection name when reading it from credentials 2014-01-22 18:51:49 +01:00
Lennart Poettering cccb0b2cdb bus: include connection name in credentials structure 2014-01-22 16:40:40 +01:00
Tom Gundersen 607553f930 libsystemd: split up into subdirs
We still only produce on .so, but let's keep the sources separate to make things a bit
less messy.
2014-01-21 14:41:35 +01:00
Renamed from src/libsystemd/bus-creds.c (Browse further)