Commit graph

553 commits

Author SHA1 Message Date
Daniel Mack 5a884f93fd libsystemd-bus: match on any connection ID unless specified 2013-12-20 23:12:42 +01:00
Daniel Mack 73842d62d7 libsystemd-bus: follow changes in kdbus
In particular, the match interface has seen a major overhaul.
2013-12-20 20:57:20 +01:00
Lennart Poettering ff0031069f sd-event: return 1 in sd_event_run() when we hit EINTR
That way we can distuingish timeouts from EINTR
2013-12-19 22:18:39 +01:00
Lennart Poettering 37224a5ff5 bus: fix exit-on-idle for driverd 2013-12-19 22:18:39 +01:00
Lennart Poettering ff2ea19264 bus: reenable id change subscriptions 2013-12-19 22:18:39 +01:00
Kay Sievers 8da4de0376 bus: do not add empty strings, size should be 0 2013-12-19 06:56:53 +01:00
Lennart Poettering 53461b74df driverd: implement AddMatch/RemoveMatch logic 2013-12-19 04:40:56 +01:00
Kay Sievers ec76ec1fde bus: catch up with kdbus changes 2013-12-18 21:16:35 +01:00
Lennart Poettering 8e959fbf38 bus: reduce calls to KDBUS_CMD_MEMFD_SIZE_SET ioctl
Instead of calling it for each buffer append, increase allocation
exponentially and set the real value only at the end, when sealing off
the memfd.

This should drastically reduce the number of times we invoke the
ioctl().
2013-12-18 19:04:14 +01:00
Lennart Poettering 5e2f14e62b busctl: output a single sorted list of names, including activatable and activated 2013-12-18 02:54:16 +01:00
Lennart Poettering 71ebe743a0 bus: beef up driverd
Add validity checks for all parameters passed in.

Implement ReleaseName and StartServiceByName().

Fix access control in vtable.
2013-12-18 02:54:16 +01:00
Lennart Poettering 45fd5e4d08 bus: when releasing, taking, listing bus names check if they are valid
Given that the kernel does not validate bus names we have to when using
them.
2013-12-18 02:54:16 +01:00
Daniel Mack ceceaf09f9 bus: sync with kdbus
Two new things here:

a) struct kdbus_notify_name_change now carries two struct
   kdbus_notify_id_change

b) a new KDBUS_CMD_BYEBYE ioctl that has no user yet in systemd
2013-12-18 00:20:55 +01:00
Thomas Hindoe Paaboel Andersen 2b49a47041 bus-util: return errors when encountered
Introduced in:
9f6eb1cd58
313333b403
2013-12-17 21:56:49 +01:00
Shawn Landden ec202eae8e __thread --> thread_local for C11 compat
Also make thread_local available w/o including <threads.h>.
(as the latter hasn't been implemented, but this part is trivial)
2013-12-17 21:45:43 +01:00
Lukasz Skalski 5232c42ec4 libsystemd-bus: true/false instead of yes/no in msg dump
Due to this patch, message dump (for message which includes boolean
type) is more consistent with dbus-send (which display true/false
instead of yes/no for boolean). It's only simple 'cosmetics change'.

** For dbus-send **

dbus-send --system --dest=org.freedesktop.DBus --type=method_call --print-reply / org.freedesktop.DBus.NameHasOwner string:org.freedesktop.login1

method return sender=org.freedesktop.DBus -> dest=:1.97 reply_serial=2
   boolean true

** For libsystemd-bus (without this patch) **

‣ Type=method_call  Endian=l  Flags=0  Version=2 Serial=8
  Destination=org.freedesktop.DBus  Path=/org/freedesktop/DBus  Interface=org.freedesktop.DBus  Member=NameHasOwner
  MESSAGE "s" {
  	STRING "org.freedesktop.login1";
  };

‣ Type=method_return  Endian=l  Flags=1  Version=2 Serial=51  ReplySerial=8
  Sender=:1.59  Destination=:1.67
  UniqueName=:1.59  WellKnownNames={org.freedesktop.DBus}
  MESSAGE "b" {
  	BOOLEAN yes;
  };

For me true/false seems to be better readable than yes/no for BOOLEAN.
2013-12-17 21:45:43 +01:00
Lennart Poettering f83f897489 busctl: on kdbus the bus driver is a service like any other, hence don't skip it 2013-12-17 15:45:31 +01:00
Lennart Poettering e1c433c621 bus: remarshal messages when necessary before sending 2013-12-17 15:45:31 +01:00
Daniel Mack 816a3f9ec5 bus: sync with kdbus
kdbus_cmd_{ep,ns,bus}_make are now consolidated, and bloom_size has
become an item of the dynamically sized list.
2013-12-17 13:45:02 +01:00
Daniel Mack 613ec4b836 bus: sync up with kdbus 2013-12-17 12:25:20 +01:00
Zbigniew Jędrzejewski-Szmek 0b6c04bb45 bus: use gperf to map error string to errno 2013-12-16 23:21:50 -05:00
Kay Sievers 6241164b73 bus: update kdbus.h 2013-12-17 02:50:19 +01:00
Lennart Poettering 5d6cf65f09 bus: when connecting to a container's system bus, double fork after joining the container's namespace
setns(CLONE_NEWPID) only applies to child processes, hence let's fork
once after joining the container's namespace.
2013-12-17 01:57:27 +01:00
Lennart Poettering a4475f577b bus: when entering an existing namespace to connect to a container's system bus also switch over PID namespace
This is necessary to ensure that kdbus can collect creds of the
destination namespace when connecting.
2013-12-17 01:05:37 +01:00
Lennart Poettering 821e0756c6 bus: use GREEDY_REALLOC() when allocating message queues 2013-12-16 20:34:46 +01:00
Lennart Poettering 306f07be2f bus: let's use GREEDY_REALLOC() when allocating space for containers 2013-12-16 20:34:46 +01:00
Kay Sievers e0d4864438 kdbus.h: add alignment requirements 2013-12-16 17:47:28 +01:00
Lennart Poettering aec6d91fb7 bus: increase the bus socket buffer to 8 MB similar, to the log socket buffers 2013-12-16 17:05:51 +01:00
Colin Walters 8e050193e1 Fix segv introduced by 2fd069b18e
n->path is pointing to the value now, we set s = NULL above.
2013-12-15 20:23:23 -05:00
Zbigniew Jędrzejewski-Szmek 2fd069b18e Fix a few resource leaks in error paths
https://bugzilla.redhat.com/show_bug.cgi?id=1043304
2013-12-15 17:49:28 -05:00
Lennart Poettering 9bfa2c029d bus: _printf_ attributes should be on prototypes not function definitions for non-static functions 2013-12-15 23:43:47 +01:00
Kay Sievers b6c631f378 bus: update kdbus monitoring interface 2013-12-15 16:56:28 +01:00
Zbigniew Jędrzejewski-Szmek 5958d08962 bus: return negative errno on error
https://bugs.freedesktop.org/show_bug.cgi?id=72688
2013-12-14 22:45:14 -05:00
Thomas Hindoe Paaboel Andersen 9091e686f4 Add more _printf_'s for format-nonliterals
Clang is a bit more strict wrt format-nonliterals:
http://clang.llvm.org/docs/LanguageExtensions.html#format-string-checking

Adding these extra printf attributes also makes gcc able to find more
problems. E.g. this patch uncovers a format issue in udev-builtin-path_id.c

Some parts looked intetional about breaking the format-nonliteral check.
I added some supression for warnings there.
2013-12-14 13:32:22 +01:00
Lennart Poettering 8d35dae708 event: some snake-oil to speed up impossible error checks 2013-12-14 05:10:25 +01:00
Lennart Poettering 9a800b5622 event: instead of reset the revents field when we get new revents data from epoll, OR it in 2013-12-14 05:10:25 +01:00
Lennart Poettering 15b38f936e event: dynamically adjust size of events array instead of pre-allocating it possibly too large or too small 2013-12-14 05:10:25 +01:00
Lennart Poettering bc9fd78c7b bus: when connecting to a container's kdbus instance, enter namespace first
Previously we'd open the connection in the originating namespace, which
meant most peers of the bus would not be able to make sense of the
PID/UID/... identity of us since we didn't exist in the namespace they
run in. However they require this identity for privilege decisions,
hence disallowing access to anything from the host.

Instead, when connecting to a container, create a temporary subprocess,
make it join the container's namespace and then connect from there to
the kdbus instance. This is similar to how we do it for socket
conections already.

THis also unifies the namespacing code used by machinectl and the bus
APIs.
2013-12-14 05:10:25 +01:00
Lennart Poettering 9d3e3aa58d event: make gcc shut up 2013-12-13 17:39:52 +01:00
Lukasz Skalski 043ccd8383 libsystemd-bus: the same error codes for sd_bus_release_name() (for kdbus and dbus1)
Due to this patch, sd_bus_release_name() function
returns the same code errors for kdbus and dbus1
if we try release non-existing name or foreign
name.
2013-12-13 15:50:41 +01:00
Lennart Poettering 9f97c93671 update TODO 2013-12-13 15:30:12 +01:00
Lennart Poettering 6d6f4904aa bus: when a connection terminated use ECONNRESET as error 2013-12-13 15:30:12 +01:00
Lennart Poettering 1e05d493b7 bus: rework how we attach fds to event loops
When trying a couple of addresses one after the other, make sure to
reattach the fds to the event loop.
2013-12-13 15:30:12 +01:00
Lennart Poettering 30caf8f3af event: add ability to change fd of an active event source 2013-12-13 15:30:12 +01:00
Lennart Poettering 8f726607ec event: allow to query userdata and watchdog state 2013-12-13 15:30:12 +01:00
Lennart Poettering 12179984a3 event: when unreffing an event source from its own handler, detach fd from epoll
The pattern of unreffing an IO event source and then closing its fd is
frequently seen in even source callbacks. Previously this likely
resultet in us removing the fd from the epoll after it was closed which
is problematic, since while we were dispatching we always kept an extra
reference to event source objects because we might still need it later.
2013-12-13 04:06:43 +01:00
Lennart Poettering 6203e07a83 event: rework sd-event exit logic
With this change a failing event source handler will not cause the
entire event loop to fail. Instead, we just disable the specific event
source, log a message at debug level and go on.

This also introduces a new concept of "exit code" which can be stored in
the event loop and is returned by sd_event_loop(). We also rename "quit"
to "exit" everywhere else.

Altogether this should make things more robus and keep errors local
while still providing a way to return event loop errors in a clear way.
2013-12-13 04:06:43 +01:00
Lennart Poettering 6e41a3e53d bus: fix make check 2013-12-13 04:06:43 +01:00
Lennart Poettering 33cb6e7934 bus: properly parse NameOwnerChanged messages when caller explicitly wants to match against names coming/going 2013-12-13 04:06:43 +01:00
Lennart Poettering 11846aa746 bus: make sure exit-on-idle logic works on kdbus systems that do not generate NameLost 2013-12-13 04:06:43 +01:00