Commit Graph

36 Commits

Author SHA1 Message Date
Lennart Poettering df98a87ba3 bus: introduce concept of "const" properties
This way we have four kinds of properties:

a) those which are constant as long as an object exists
b) those which can change and PropertiesChange messages with contents are generated
c) those which can change and where the PropertesChange merely includes invalidation
d) those which can change but for which no events are generated

Clients (through code generators run on the introspection XML) can thus
aggressively cache a, b, c, with only d excluded.
2013-12-22 03:50:52 +01:00
Lennart Poettering 7fb411f035 bus: when introspecting, turn unprivileged flag into inverse annoation of "privileged"
Internally, it makes sense to have a default of "privileged" for
methods, and a flag to open it up. However, externally in the bus
introspection turn this around since negative options actually suck.
2013-12-21 18:08:39 +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
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
Lennart Poettering f820cf99c1 bus: do not dispatch incoming method calls that are broacasted to vtables 2013-12-10 23:11:10 +00:00
Lennart Poettering 6e8df5f00a bus: introduce new SD_BUS_VTABLE_HIDDEN flag for vtable members
When this flag is set then its member will not be shown in the
introspection data. Also, properties with this flag set will not be
included in GetAll() responses.
2013-12-10 16:52:49 +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 6717d47350 bus: when replying to an incoming message and the vtable contains the expected return signature generate an error if the response message doesn't match it 2013-12-02 15:29:40 +01:00
Lennart Poettering 0fc5ab9057 bus: properly return errors to client if invalid parameters are passed to built-in methods 2013-11-25 22:32:18 +01:00
Lennart Poettering 52c7f2b2d5 bus: deal with duplicate values from enumerators 2013-11-22 01:57:30 +01:00
Lennart Poettering f00c31213a bus: also add error parameter to object find and enumerator callbacks
Just in order to bring things inline with the method and property
callbacks.
2013-11-22 01:42:15 +01:00
Lennart Poettering 86b8d28971 logind,machined,run: properly invoke StartTransientUnit() bus call 2013-11-21 21:12:36 +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 df2d202e6e bus: let's simplify things by getting rid of unnecessary bus parameters 2013-11-21 02:07:35 +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
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 5d66866d96 bus: never report nodes as children that do not have the right prefix 2013-11-05 21:24:33 +01:00
Lennart Poettering c13c7de3bf bus: support implicit serialization of strv string arrays within vtables 2013-11-05 01:13:05 +01:00
Lennart Poettering 38911893c5 bus: fix build 2013-10-30 02:38:52 +01:00
Lennart Poettering d36679f72e bus: it is OK to have signals with multiple parameters 2013-10-30 02:08:57 +01:00
Lennart Poettering bd03703884 bus: don't fail if GetAll() is used to get properties of the built-in interfaces 2013-10-30 02:08:57 +01:00
Lennart Poettering 250a918dc4 strv: introduce new strv_from_stdarg_alloca() macro to generate a string array from stdarg function parameters
This allows us to turn lists of strings passed in easily into string
arrays without having to allocate memory.
2013-10-29 19:53:43 +01:00
Lennart Poettering 28d6633ae1 bus: NULL signatures are OK too 2013-10-22 12:41:54 +01:00
Kay Sievers af8601fa8b bus: allow to specify NULL as an empty string to add 2013-10-21 00:21:27 +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 68313d3dfa bus: properly handle if new objects are installed in the node tree while we are dispatching to one 2013-10-14 21:58:06 +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 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 4be391639f bus: properly implement logic for generating InterfacesAdded/InterfacesRemoved signals of ObjectManager 2013-10-11 23:23:46 +02:00
Lennart Poettering 92db139e34 bus: in GetManagedObjects() only return each object once. 2013-10-11 23:21:22 +02:00
Lennart Poettering 92e189e572 bus: unify code to find parents of an object path with 2013-10-11 23:20:54 +02:00
Lennart Poettering 8e4e652b92 bus: properly generate GetAll reply 2013-10-11 23:19:40 +02:00
Lennart Poettering dfa927250e bus: beef up parameter checking in vtable handling 2013-10-11 21:27:59 +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 992c052c34 bus: split up overly long sd-bus.c into three files 2013-10-11 20:18:10 +02:00