Commit graph

60 commits

Author SHA1 Message Date
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 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
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
Lennart Poettering 1fee9de509 bus: add api to control auto start message flag 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
Lennart Poettering 938bcbab12 bus: add APIs for adding iovecs to messages as string or arrays 2013-11-11 16:26:12 +01:00
Lennart Poettering 63be1989c7 bus: add APIs to easily query string and strv properties 2013-11-07 19:28:54 +01:00
Lennart Poettering 0095c45415 api: replace manual C++ guards by macros 2013-11-07 16:53:26 +01: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 7b05894275 bus: add new bus API call sd_bus_message_at_end()
This may be used to determine whether we are at the end of a container
ot the entire message.
2013-11-05 19:36:05 +01:00
Marc-Antoine Perennou 4686d1b6ee bus: add sd_bus_message_read_strv()
It will be useful to have that in the public API.
2013-11-05 18:12:18 +01:00
Lennart Poettering 9b07511d65 bus: add sd_bus_message_skip() to skip over multiple fields 2013-11-05 02:26:48 +01:00
Lennart Poettering e5609878d8 timedatectl: assorted simplifications 2013-10-31 03:02:49 +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 29f8d1f21a bus: add a macro to simplify reading of UUIDs 2013-10-29 19:34:59 +01:00
Lennart Poettering c430fee6ff bus: add new sd_bus_message_verify_type() and sd_bus_message_copy() API calls 2013-10-29 19:34:59 +01:00
Lennart Poettering aacf3b483b api: unify some common bits used by public systemd APIs 2013-10-16 17:01:26 +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 4be391639f bus: properly implement logic for generating InterfacesAdded/InterfacesRemoved signals of ObjectManager 2013-10-11 23:23:46 +02:00
Lennart Poettering 55736ed0c7 bus: add sd_bus_message_append_strv() to easily add a NULL terminated string array to a message 2013-10-11 23:02:47 +02:00
Lennart Poettering 77a874a3fb bus: don't rely on gccisms/c11 in public header files.
One day sd-bus.h should become a public header file. We generally try to
be conservative in language features we use in public headers (much
unlike in private code), hence don't make use of anonymous unions in
structs for the vtable definitions.
2013-10-11 20:32:16 +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
Lennart Poettering 90d184b234 bus: decorate API calls with gcc attributes where appropriate 2013-10-11 05:21:08 +02:00
Lennart Poettering 29ddb38fea libsystemd-bus: add lightweight object vtable implementation for exposing objects on the bus
This adds a lightweight scheme how to define interfaces in static fixed
arrays which then can be easily registered on a bus connection. This
makes it much easier to write bus services.

This automatically handles implementation of the Properties,
ObjectManager, and Introspection bus interfaces.
2013-10-09 02:40:07 +02:00
Lennart Poettering 9444b1f20e logind: add infrastructure to keep track of machines, and move to slices
- This changes all logind cgroup objects to use slice objects rather
  than fixed croup locations.

- logind can now collect minimal information about running
  VMs/containers. As fixed cgroup locations can no longer be used we
  need an entity that keeps track of machine cgroups in whatever slice
  they might be located. Since logind already keeps track of users,
  sessions and seats this is a trivial addition.

- nspawn will now register with logind and pass various bits of metadata
  along. A new option "--slice=" has been added to place the container
  in a specific slice.

- loginctl gained commands to list, introspect and terminate machines.

- user.slice and machine.slice will now be pulled in by logind.service,
  since only logind.service requires this slice.
2013-06-20 03:49:59 +02:00
Lennart Poettering 264ad849a4 bus: add APIs for negotiating what is attached to messages 2013-05-17 04:26:27 +02:00
Lennart Poettering eb01ba5de1 bus: synthesize timeout message errors instead of returning error codes 2013-05-16 21:14:56 +02:00
Lennart Poettering 453a0c2946 bus: add support for adding memfds into message payload 2013-05-15 19:45:45 +02:00
Lennart Poettering f8e013f8bf bus: add sd_bus_message_append_string_space() for zero-copy string appending 2013-05-10 03:38:11 +02:00
Lennart Poettering b3af9646f8 bus: add API for appending/reading fixed arrays 2013-05-09 20:01:21 +02:00
Lennart Poettering 8973790ee6 cryptsetup: warn if /etc/crypttab is world-readable 2013-04-30 08:36:01 -03:00
Zbigniew Jędrzejewski-Szmek e4d2bfdd73 Add printf attributes in exported headers
gcc (and other compilers) sometimes generate spurious warnings, and
thus users of public headers must be able to disable warnings.

Printf format attributes can be disabled by setting
    #define _sd_printf_attr_
before including the header file.

Also, add similar logic for sentinel attribute:
    #define _sd_sentinel_attr_
before including the header file disables the attribute.
2013-04-25 21:50:48 -04:00
Lennart Poettering 7066618570 bus: add cal to determine machine id of an owner of a service 2013-04-23 16:00:32 -03:00
Lennart Poettering 102ea8e4f2 bus: parse capability kdbus meta data of messages 2013-04-23 00:14:30 -03:00
Lennart Poettering 120f919e70 bus: parse audit metadata from kdbus messages 2013-04-22 23:38:38 -03:00
Lennart Poettering bc7f3beb30 bus: parse owner uid from cgroup path, too 2013-04-22 23:27:38 -03:00
Lennart Poettering d8d3d8a781 bus: parse unit/user unit/session from cgroup path 2013-04-16 04:54:46 +02:00
Lennart Poettering 4a875b6133 kdbus: parse cgroup meta data, too 2013-04-15 01:51:37 +02:00
Lennart Poettering 77930f1120 kdbus: also parse cmdline message attribute 2013-04-14 03:20:23 +02:00
Lennart Poettering 69aec65cf8 kdbus: parse even more kernel meta data fields 2013-04-13 21:53:11 +02:00
Lennart Poettering acb5a3cb20 bus: parse and expose kdbus message timestamps 2013-04-12 01:57:53 +02:00
Lennart Poettering 8323bc1f90 bus: also parse PID starttime out of kdbus message 2013-04-12 01:49:52 +02:00
Lennart Poettering e9a967f9a0 bus: make kdbus work so that we can exchange real messages
We have ignition, we have tremendous fire!
2013-04-12 01:19:32 +02:00