Commit graph

150 commits

Author SHA1 Message Date
Michael Scherer 2047a15a17 Fix format string mismatch introduced in ab9001a1
src/libsystemd-bus/sd-bus.c: In function 'sd_bus_open_user':
src/libsystemd-bus/sd-bus.c:1104:25: warning: format '%s' expects argument of type 'char *', but argument 3 has type 'long unsigned int' [-Wformat=]
                         asprintf(&b->address, UNIX_USER_BUS_FMT, (unsigned long) getuid());
2014-01-05 11:17:03 -05:00
Zbigniew Jędrzejewski-Szmek cd6d5e1c76 man: document a batch of bus functions 2014-01-04 00:15:01 -05:00
Zbigniew Jędrzejewski-Szmek ab9001a1e3 Move bus path definitions to def.h 2014-01-02 19:45:47 -05:00
Lennart Poettering 90911bb63e bus: always show messages we send 2013-12-26 17:16:56 +01:00
Lennart Poettering 758bf0c755 bus: don't process Peer interface messages in the proxy 2013-12-26 03:08:52 +01:00
Lennart Poettering 693eb9a2d4 bus: rename message "serial" to "cookie"
Even if the lower-leveld dbus1 protocol calls it "serial", let's expose
the word "cookie" for this instead, as this is what kdbus uses and since
it doesn't imply monotonicity the same way "serial" does.
2013-12-25 18:04:04 +01:00
Lennart Poettering 2e3db52da9 bus: also write debug logs about messages we send 2013-12-25 03:09:09 +01:00
Lennart Poettering 4cdf07519a bus: be a bit more verbose when debug mode is on 2013-12-25 02:41:09 +01:00
Lennart Poettering 751bc6ac79 bus: properly shift cgroup data returned from kdbus by the container's root before parsing 2013-12-24 19:31:44 +01:00
Lennart Poettering 8a0e0ed9dd bus: fake client side creds in the proxy to the caller's creds 2013-12-24 15:27:59 +01:00
Lennart Poettering dc74ce9b4a bus: write debug message when we get a method call we cannot handle 2013-12-23 17:18:30 +01:00
Lennart Poettering a7639e37af bus-proxyd: synthesize NameAcquire/NameLost signals for socket clients 2013-12-23 04:20:55 +01:00
Lennart Poettering 14f862a508 bus: also take write queue into consideration in sd_bus_try_close() 2013-12-22 21:11:03 +01:00
Lennart Poettering bd746b8b0c bus: in sd_bus_try_close() consider local read queue too 2013-12-21 03:46:26 +01:00
Lennart Poettering ae095f8605 bus: wrap KDBUS_CMD_BYEBYE with a high-level call sd_bus_try_close() 2013-12-20 23:26:11 +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
Lennart Poettering e1c433c621 bus: remarshal messages when necessary before sending 2013-12-17 15:45:31 +01:00
Lennart Poettering 821e0756c6 bus: use GREEDY_REALLOC() when allocating message queues 2013-12-16 20:34:46 +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 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 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 3df7a7e610 bus: always pass valid timeout to kdbus 2013-12-12 20:00:45 +01:00
Lennart Poettering 0f437184b6 bus: enforce endianess and marshalling for messages we send 2013-12-12 20:00:45 +01:00
Lennart Poettering f8e11cda53 bus: properly return an error when we detect a method call timeout 2013-12-12 05:40:05 +01:00
Lennart Poettering 9e5548644f bus: connect directly via kdbus in sd_bus_open_system_container()
kdbus fortunately exposes the container's busses in the host fs, hence
we can access it directly instead of doing the namespacing dance.
2013-12-12 00:07:49 +01:00
Lennart Poettering b6741478e7 journal: add ability to browse journals of running OS containers
This adds the new library call sd_journal_open_container() and a new
"-M" switch to journalctl. Particular care is taken that journalctl's
"-b" switch resolves to the current boot ID of the container, not the
host.
2013-12-11 22:04:03 +01:00
Lennart Poettering a82cafb97b bus: don't generate assert warnings when we detach a detached bus from an event 2013-12-10 23:06:50 +00:00
Lennart Poettering 5b1bc83f81 bus: when we _unref() a NULL pointer, don't use assert_return()
We support unreffing NULL pointers just fine and we shouldn't pay the
_unlikely_() price for it, not get a debug message if we do, hence let's
not use assert_return() here.
2013-12-10 20:38:04 +00:00
Lennart Poettering adacb9575a bus: introduce "trusted" bus concept and encode access control in object vtables
Introduces a new concept of "trusted" vs. "untrusted" busses. For the
latter libsystemd-bus will automatically do per-method access control,
for the former all access is automatically granted. Per-method access
control is encoded in the vtables: by default all methods are only
accessible to privileged clients. If the SD_BUS_VTABLE_UNPRIVILEGED flag
is set for a method it is accessible to unprivileged clients too. By
default whether a client is privileged is determined via checking for
its CAP_SYS_ADMIN capability, but this can be altered via the
SD_BUS_VTABLE_CAPABILITY() macro that can be ORed into the flags field
of the method.

Writable properties are also subject to SD_BUS_VTABLE_UNPRIVILEGED and
SD_BUS_VTABLE_CAPABILITY() for controlling write access to them. Note
however that read access is unrestricted, as PropertiesChanged messages
might send out the values anyway as an unrestricted broadcast.

By default the system bus is set to "untrusted" and the user bus is
"trusted" since per-method access control on the latter is unnecessary.

On dbus1 busses we check the UID of the caller rather than the
configured capability since the capability cannot be determined without
race. On kdbus the capability is checked if possible from the attached
meta-data of a message and otherwise queried from the sending peer.

This also decorates the vtables of the various daemons we ship with
these flags.
2013-12-10 16:52:49 +00:00
Lennart Poettering 0461f8cdc1 bus: internalize a lot of protocol definitions
We shouldn export what isn't necessary or useful to clients, so let's
add the protocol definitions we only need internally into a private
header.
2013-12-03 18:14:50 +01:00
Lennart Poettering 95c4fe8271 busctl: add command to dump creds of a peer or pid
(also, rename _SD_BUS_CREDS_MAX to _SD_BUX_CRED_ALL, since "MAX" so far
was used to indicate one higher than the highest valid value, and this
is not correct here.)
2013-12-02 18:40:43 +01:00
Zbigniew Jędrzejewski-Szmek 75be4e6445 bus: remove unused variable 2013-11-30 20:10:18 -05:00
Lennart Poettering 626851be97 bus: do kdbus only if this is enabled on the configure switch
Since we want to retain the ability to break kernel ←→ userspace ABI
after the next release, let's not make use by default of kdbus, so that
people with future kernels will not suddenly break with current systemd
versions.

kdbus support is left in all builds but must now be explicitly requested
at runtime (for example via setting $DBUS_SESSION_BUS). Via a configure
switch the old behaviour can be restored. In fact, we change autogen.sh
to do this, so that git builds (which run autogen.sh) get kdbus by
default, but tarball builds (which ue the configure defaults) do not get
it, and hence this stays out of the distros by default.
2013-11-30 20:18:48 +01:00
Lennart Poettering 3310dfd5bd bus: append unique and well known names to all messages unconditionally 2013-11-30 16:08:11 +01:00
Lennart Poettering 49b832c5b8 bus: include unique and well known names in credentials object 2013-11-30 14:46:14 +01:00
Daniel Mack 1d0e3c9884 libsystemd-bus: catch up with latest kdbus changes
The name list and query functions now work differently in kdbus, as the
result is stored in the connection's pool, rather than being copied back
through the ioctl buffer. That also safes us some logic, as we don't
have to resize the communication buffer in a loop with growing buffer
sizes.

Due to this, KDBUS_CMD_MSG_RELEASE was renamed to KDBUS_CMD_FREE, as it
is now used outside the message logic as well.
2013-11-30 13:31:04 +01:00
Lennart Poettering e3dd987cfc core: allocate a kdbus bus for each systemd instance, if we can 2013-11-30 03:53:42 +01:00
Lennart Poettering 32f464809e bus: whenever we notice the connection is terminated enter CLOSING state 2013-11-30 01:49:40 +01:00
Lennart Poettering a43b9ca304 bus: synthesize local error reply when we cannot deliver a message to kdbus because the destination is unavailable 2013-11-30 01:02:51 +01:00
Lennart Poettering 7adc46fcce bus: don't generate NameAcquired/NameLost messages in the library
The signals appear entirely redundant due to NameOwnerChange, hence
don't do them in the new library, instead leave them for the
compatibility bridge only.

Also, set the serial number for synthesized messages to (uint32_t) -1.
2013-11-30 00:21:06 +01:00
Lennart Poettering 7d22c71732 bus: add the ability for backends to queue to input messages at the same time
We need this so that one incoming kernel message can result in two
high-level bus messages, for the case where we synthesize NameAcquired
and NameOwnerChanged in the same instance.
2013-11-29 22:03:55 +01:00
Daniel Mack 87b522ae19 libsystemd-bus: add sd_bus_translate_attach_flags()
Factor out code from sd_bus_negotiate_attach_creds() to a generic
translate function, so it can be used from other places.
2013-11-29 22:01:34 +01:00
Lennart Poettering 34a2c9e841 bus: when synthesizing messages locally, fill in a sender 2013-11-29 20:14:11 +01:00
Lennart Poettering 777d7a6123 kdbus: synthesize NameOwnerChange signals from kernel messages and support matches against NameOwnerChange 2013-11-29 20:14:11 +01:00
Daniel Mack d21a7bb1a9 libsystemd-bus: catch up with latest kdbus changes
kdbus_cmd_hello now has a new uint64_t flags field for the requested
attachments. Follow that change in libsystemd-bus.
2013-11-29 15:36:40 +01:00
Lennart Poettering 5b12334d35 bus: add new sd_bus_creds object to encapsulate process credentials
This way we can unify handling of credentials that are attached to
messages, or can be queried for bus name owners or connection peers.

This also adds the ability to extend incomplete credential information
with data from /proc,

Also, provide a convenience call that will automatically determine the
most appropriate credential object for an incoming message, by using the
the attached information if possible, the sending name information if
available and otherwise the peer's credentials.
2013-11-28 18:42:18 +01:00
Kay Sievers dd971bd2ce bus: update kdbus.h and always subscribe to KDBUS_HELLO_ATTACH_NAMES 2013-11-28 02:26:03 +01:00
Lennart Poettering c99c09a2dc bus: properly handle if we get disconnected during HELLO phase 2013-11-27 20:28:48 +01:00
Lennart Poettering 0e586eae02 bus: when closing a bus, drop all refs to queued messages, so that the bus can be freed 2013-11-22 16:31:40 +01:00