Systemd/src/libsystemd
Lennart Poettering 4b58153dd2 core: add "invocation ID" concept to service manager
This adds a new invocation ID concept to the service manager. The invocation ID
identifies each runtime cycle of a unit uniquely. A new randomized 128bit ID is
generated each time a unit moves from and inactive to an activating or active
state.

The primary usecase for this concept is to connect the runtime data PID 1
maintains about a service with the offline data the journal stores about it.
Previously we'd use the unit name plus start/stop times, which however is
highly racy since the journal will generally process log data after the service
already ended.

The "invocation ID" kinda matches the "boot ID" concept of the Linux kernel,
except that it applies to an individual unit instead of the whole system.

The invocation ID is passed to the activated processes as environment variable.
It is additionally stored as extended attribute on the cgroup of the unit. The
latter is used by journald to automatically retrieve it for each log logged
message and attach it to the log entry. The environment variable is very easily
accessible, even for unprivileged services. OTOH the extended attribute is only
accessible to privileged processes (this is because cgroupfs only supports the
"trusted." xattr namespace, not "user."). The environment variable may be
altered by services, the extended attribute may not be, hence is the better
choice for the journal.

Note that reading the invocation ID off the extended attribute from journald is
racy, similar to the way reading the unit name for a logging process is.

This patch adds APIs to read the invocation ID to sd-id128:
sd_id128_get_invocation() may be used in a similar fashion to
sd_id128_get_boot().

PID1's own logging is updated to always include the invocation ID when it logs
information about a unit.

A new bus call GetUnitByInvocationID() is added that allows retrieving a bus
path to a unit by its invocation ID. The bus path is built using the invocation
ID, thus providing a path for referring to a unit that is valid only for the
current runtime cycleof it.

Outlook for the future: should the kernel eventually allow passing of cgroup
information along AF_UNIX/SOCK_DGRAM messages via a unique cgroup id, then we
can alter the invocation ID to be generated as hash from that rather than
entirely randomly. This way we can derive the invocation race-freely from the
messages.
2016-10-07 20:14:38 +02:00
..
sd-bus core: add "invocation ID" concept to service manager 2016-10-07 20:14:38 +02:00
sd-daemon tree-wide: htonl() is weird, let's use htobe32() instead (#3538) 2016-06-15 01:26:01 +02:00
sd-device sd-device/networkd: unify code to get a socket for issuing netdev ioctls on 2016-10-06 19:04:01 +02:00
sd-event sd-event: expose the event loop iteration counter via sd_event_get_iteration() (#3631) 2016-06-30 21:25:07 +02:00
sd-hwdb sd-hwdb: order properties by origin 2016-09-21 15:18:28 +02:00
sd-id128 core: add "invocation ID" concept to service manager 2016-10-07 20:14:38 +02:00
sd-login Various fixes for typos found by lintian (#3705) 2016-07-12 12:52:11 +02:00
sd-netlink networkd: add support to configure virtual CAN device (#4139) 2016-09-14 18:15:16 +02:00
sd-network tree-wide: remove unused variables 2016-02-23 20:40:51 +01:00
sd-path sd-path: use XDG_CONFIG_HOME instead of hardcoding ~/.config for user-dirs 2016-03-15 04:09:44 +00:00
sd-resolve sd-resolve: use close_many() (#3643) 2016-07-02 08:17:26 -07:00
sd-utf8 tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
.gitignore libsystemd: remove list of symbols to export only in the future 2015-06-17 16:21:13 +02:00
Makefile libsystemd-bus: rename to libsystemd 2014-01-13 18:54:19 +01:00
libsystemd.pc.in build-sys: update .pc.in files 2014-01-25 18:55:58 -05:00
libsystemd.sym core: add "invocation ID" concept to service manager 2016-10-07 20:14:38 +02:00