Commit graph

137 commits

Author SHA1 Message Date
Tom Gundersen 6bb648a16a libsystemd-bus: rename to libsystemd
Documentation was updated to refer to either 'libsystemd' or 'sd-bus' in place
of libsystemd-bus.
2014-01-13 18:54:19 +01:00
Kay Sievers ec260edc1c bus: fix length calculation when serializing SD_BUS_TYPE_SIGNATURE 2014-01-12 00:30:49 +08:00
Lennart Poettering d9416f8a82 man: document sd_bus_message_get_cookie() 2013-12-25 18:04:04 +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 3798fd4c30 bus: allow peeking signatures recusively inside of containers
Previously we invalidated the peeked signature as soon as the caller
would recurse into a container, making stack based handling difficult.
With this change we will keep the peeked signature around until the user
advances to the next field.
2013-12-24 03:02:49 +01:00
Lennart Poettering 8f19720dd2 bus: fix assert when serializing fixed size struct to gvariant 2013-12-23 23:48: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 3547329642 bus: refuse messages pretending to originate from local interface 2013-12-21 03:52:39 +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 e1c433c621 bus: remarshal messages when necessary before sending 2013-12-17 15:45:31 +01:00
Lennart Poettering 306f07be2f bus: let's use GREEDY_REALLOC() when allocating space for containers 2013-12-16 20:34:46 +01:00
Lennart Poettering e4bb80a076 bus: fix rewind logic 2013-12-12 20:49:32 +01:00
Lennart Poettering 3df7a7e610 bus: always pass valid timeout to kdbus 2013-12-12 20:00:45 +01: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 35460afc48 Revert "libsystemd-bus: use assert_return"
This reverts commit f7e2bd5a80.

Most of these checks are not programming errors, but happen during
normal runtime. For example bus_kernel_pop_memfd() is called all the
time on non-kdbus systems and is supposed to quickly fail if kdbus is
not available. However, assert_return() makes this failure
expensive, and hence has no place here. With the most recent change to
assert_return() it will even log a debug message, which should never
happen here.
2013-12-10 19:31:10 +00:00
Lukasz Skalski f7e2bd5a80 libsystemd-bus: use assert_return 2013-12-09 23:27:19 -05:00
Lennart Poettering 5f7e8903b2 bus: properly handle empty messages 2013-12-10 03:30:51 +01:00
Lennart Poettering 224a1ed4c1 bus: empty gvariant arrays should at least get size 1 2013-12-10 03:04:16 +01:00
Lennart Poettering 041b85cf01 bus: it's OK to send messages with an empty payload but non-empty signature
THis might happen when sending arrays with 0 enttries, hence this is not
an indication for a problem.
2013-12-10 02:57:46 +01:00
Lennart Poettering 8f2e44f820 bus: make gcc shut up 2013-12-10 02:33:13 +01:00
Lennart Poettering d36b703136 bus: fix rewinding in gvariant messages 2013-12-10 01:06:52 +01:00
Lennart Poettering 5763192abf bus: fix signature handling when exiting container 2013-12-10 01:06:29 +01:00
Lennart Poettering 0039a203b1 bus: properly deserialize gvariant fixed size arrays 2013-12-10 01:05:23 +01:00
Lennart Poettering d63850688d bus: handler empty messages correctly when using gvariant marshalling 2013-12-10 01:04:36 +01:00
Lennart Poettering f30976971c bus: suppress creating empty parts in messages 2013-12-10 01:03:41 +01:00
Lennart Poettering 18f5b48f3f bus: rely on explicit eof check instead of checking when mapping payload
This allows us to drop quite a bit of code.
2013-12-09 23:24:17 +01:00
Lennart Poettering 813892259b bus: rearrange bus-message.c function order to keep read and write calls together 2013-12-09 23:16:14 +01:00
Lennart Poettering 6647dc6659 bus: demarshal gvariant 2013-12-09 23:04:49 +01:00
Lennart Poettering ea6ad56836 bus: add missing LE meta data enforcement for gvariant serializer 2013-12-05 03:09:09 +01:00
Lennart Poettering c1b9d93572 bus: add support for serializing to gvariant
(deserialization is still missing, hence this is not hooked up to kdbus)
2013-12-05 02:47:36 +01: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 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 79f8d3d2ce bus: support temporarily const errors that don't need to be freed but require deep copies
This should fix issues with incorrectly copying bus error messages out
of sd_bus_message objects.

Original bug found by: Djalal Harouni
2013-11-30 19:47:46 +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 5461f53f18 bus: when turning a buffer into a sd_bus_message avoid creating zero-length parts 2013-11-29 13:34:55 +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
Lennart Poettering 780896a4f1 bus: rework sd_bus_error APIs
All calls that set a sd_bus_error structure will now return the same
error converted to a negative errno. This may be used as syntactic sugar
to return from a function and setting a bus_error structure in one go.

Also, translate all Linux Exyz (EIO, EINVAL, EUCLEAN, EPIPE, ...)
automatically into counterparts in the (new) "Posix.Error." namespace.

If we fail to allocate memory for the components of a sd_bus_error
automatically reset it to an OOM error which we always can write.
2013-11-22 04:23:22 +01:00
Lennart Poettering 2be441769f bus: add calls to query attached objects 2013-11-22 01:42:15 +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 51b4ea6f48 bus: the :no-sender hack is now unnecessary, since the new library doesn't require this anymore 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
Lennart Poettering 2b5c5383e4 bus: beautify bus_message_dump() output a bit 2013-11-12 00:12:44 +01:00
Lennart Poettering 1fee9de509 bus: add api to control auto start message flag 2013-11-12 00:12:44 +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 f959af205a bus: use ENXIO as error condition when trying to exit a container when we are not in any
So far we used ENXIO whenever the user tried to read something from a
function that didn't carry the right type, and hence use the same error
here to indicate that what the user expected and what was in the message
didn't match up.
2013-11-10 23:54:55 +01:00
Zbigniew Jędrzejewski-Szmek 0a9776c230 systemctl: make sure daemon-reload returns success
Also change sd_bus_message_exit_container to return -ENOENT
when not in a container, to make it easier to distinguish different
errors.
2013-11-09 19:41:00 -05:00
Kay Sievers dbb642afae bus: let magic ":no-sender" pass the validation 2013-11-09 00:58:11 +01:00
Marc-Antoine Perennou 1405bef3f1 bus: mark sd_bus_message_at_end public 2013-11-07 19:02:15 +01:00