Commit graph

120 commits

Author SHA1 Message Date
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
Lennart Poettering 2be441769f bus: add calls to query attached objects 2013-11-22 01:42:15 +01:00
Lennart Poettering 969987ea93 bus: restore selinux access control to PID 1 for properties 2013-11-21 23:36:51 +01:00
Lennart Poettering ebcf1f97de bus: rework message handlers to always take an error argument
Message handler callbacks can be simplified drastically if the
dispatcher automatically replies to method calls if errors are returned.

Thus: add an sd_bus_error argument to all message handlers. When we
dispatch a message handler and it returns negative or a set sd_bus_error
we send this as message error back to the client. This means errors
returned by handlers by default are given back to clients instead of
rippling all the way up to the event loop, which is desirable to make
things robust.

As a side-effect we can now easily turn the SELinux checks into normal
function calls, since the method call dispatcher will generate the right
error replies automatically now.

Also, make sure we always pass the error structure to all property and
method handlers as last argument to follow the usual style of passing
variables for return values as last argument.
2013-11-21 21:12:36 +01:00
Lennart Poettering 14c24659cd bus: rename SD_BUS_ERROR_MAKE to SD_BUS_ERROR_MAKE_CONST to indicate it only works for const strings 2013-11-21 02:11:06 +01:00
Lennart Poettering df2d202e6e bus: let's simplify things by getting rid of unnecessary bus parameters 2013-11-21 02:07:35 +01:00
Lennart Poettering 28383ba189 bus: add API calls to escape string components of objects paths 2013-11-21 01:03:26 +01:00
Lennart Poettering 86befb4098 bus: make sure an additional ref to a busevent source doesn't cause the event source to be triggered again 2013-11-20 20:58:17 +01:00
Lennart Poettering 718db96199 core: convert PID 1 to libsystemd-bus
This patch converts PID 1 to libsystemd-bus and thus drops the
dependency on libdbus. The only remaining code using libdbus is a test
case that validates our bus marshalling against libdbus' marshalling,
and this dependency can be turned off.

This patch also adds a couple of things to libsystem-bus, that are
necessary to make the port work:

- Synthesizing of "Disconnected" messages when bus connections are
  severed.

- Support for attaching multiple vtables for the same interface on the
  same path.

This patch also fixes the SetDefaultTarget() and GetDefaultTarget() bus
calls which used an inappropriate signature.

As a side effect we will now generate PropertiesChanged messages which
carry property contents, rather than just invalidation information.
2013-11-20 20:52:36 +01:00
Lennart Poettering 911121a7c8 bus: add sd_bus_send_to() API call 2013-11-20 19:37:02 +01:00
Lennart Poettering aea93debfa bus: bump serial number counter when sending already sealed messages 2013-11-20 19:36:14 +01:00
Kay Sievers f21326e604 bus: TIMESTAMP is optional kdbus metadata now, NAMES are always added 2013-11-18 01:30:57 +01:00
Kay Sievers 16be43684f bus: CREDS and NAMES are optional kdbus metadata now 2013-11-17 22:35:58 +01:00
Tom Gundersen 0927756b8d bus: typo
Fix a couple of 'void' that should have been 'sd_bus'.
2013-11-14 22:19:48 +01:00
Lennart Poettering a8a07f892c bus: detect blocking message calls to our own connection and return ELOOP early 2013-11-12 00:12:44 +01:00
Lennart Poettering 76b543756e bus: introduce concept of a default bus for each thread and make use of it everywhere
We want to emphasize bus connections as per-thread communication
primitives, hence introduce a concept of a per-thread default bus, and
make use of it everywhere.
2013-11-12 00:12:43 +01:00
Lennart Poettering c49b30a235 bus: rename sd_bus_send_with_reply_and_block() to sd_bus_call()
The call is one of the most important ones we expose, where we place
major emphasis on. We should make sure to give it a short, memorable
name.
2013-11-12 00:12:43 +01:00
Zbigniew Jędrzejewski-Szmek d9f644e2cd bus: export libsystemd-bus as a public library
Old static libsystemd-bus.la becomes libsystemd-bus-internal.la.
memfd functions are also exported in the same library.

(Best viewed with --color-words -U0).
2013-11-06 14:56:47 -05:00
Lennart Poettering affff0b6f2 bus: add sd_bus_get_current() bus call to determine message that is currently being dispatched 2013-11-05 20:51:49 +01:00
Lennart Poettering 9d6c7c821c bus: make use of assert_return() in all API calls that don't use it yet 2013-11-05 19:14:58 +01:00
Lennart Poettering a7893c6b28 bus: add API call to create bus connection to the system bus of local containers
Also, add support for this to machinectl, so that we can enumerate the
machines that run inside a container. We must go deeper!
2013-10-30 15:37:02 +01:00
Lennart Poettering 0f8bd8debb bus: move ssh support into public API of libsystem-bus 2013-10-30 15:35:49 +01:00
Lennart Poettering abc5fe7250 bus: automatically flush bus queue when we exit the event loop
This way, we do not have to call it manually
2013-10-18 01:43:55 +02:00
Lennart Poettering 40ca29a137 timedated: use libsystemd-bus instead of libdbus for bus communication
Among other things this also adds a few things necessary for the change:

- Considerably more powerful error returning APIs in libsystemd-bus

- Adapter for connecting an sd_bus to an sd_event

- As I reworked the PolicyKit logic to the new library I also made it
  asynchronous, so that PolicyKit requests of one user cannot block out
  another user anymore.

- We always use the macro names for common bus error. That way it is
  harder to mistype them since the compiler will notice
2013-10-16 06:15:02 +02:00
Lennart Poettering 7a37d62501 bus: return 1 on all calls that send messages
This way they are nicer to use from method dispatch callbacks as last
call, since method dispatch callbacks expect > 0 return if the message
got handled.
2013-10-16 06:15:01 +02:00
Lennart Poettering 8efd638179 bus: make sure sd_bus_get_timeout() returns a 0 timeout of there are already read but not dispatched messages 2013-10-16 06:15:01 +02:00
Lennart Poettering 8ce2afd634 bus: make sure that we always keep a ref to the bus when we dispatch callbacks
Otherwise the callback might unref the bus we are processing and destroy
the object while we are processing it.
2013-10-14 19:53:56 +02:00
Lennart Poettering d68888227d bus: use assert_return() for more API calls 2013-10-14 19:40:37 +02:00
Lennart Poettering 71fda00f32 list: make our list macros a bit easier to use by not requring type spec on each invocation
We can determine the list entry type via the typeof() gcc construct, and
so we should to make the macros much shorter to use.
2013-10-14 06:11:19 +02:00
Lennart Poettering 992c052c34 bus: split up overly long sd-bus.c into three files 2013-10-11 20:18:10 +02:00
Lennart Poettering 9db7635521 bus: if a a Set() vtable callback of a writable is left NULL, try to do the right thing automatically 2013-10-11 20:03:19 +02:00