Systemd/src/journal
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
..
.gitignore gitignore: libsystemd-journal.pc is no more (#3863) 2016-08-02 16:04:39 +02:00
Makefile journal: add preliminary incomplete implementation 2011-10-07 22:02:05 +02:00
audit-type.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
audit-type.h tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
cat.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
catalog.c tree-wide: make ++/-- usage consistent WRT spacing 2016-02-22 20:32:04 -08:00
catalog.h tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
compress.c compress: fix gcc warnings about void* used in arithmetic 2016-04-02 18:58:21 -04:00
compress.h tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
fsprg.c journal: assert gcry_mpi_scan succeeded 2016-04-08 21:08:54 -04:00
fsprg.h tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
journal-authenticate.c Merge pull request #2589 from keszybz/resolve-tool-2 2016-02-13 11:15:41 +01:00
journal-authenticate.h tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
journal-def.h tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
journal-file.c journal: fix HMAC calculation when appending a data object 2016-09-23 14:59:51 +02:00
journal-file.h journal: set STATE_ARCHIVED as part of offlining (#2740) 2016-04-27 08:29:43 +02:00
journal-internal.h sd-journal: add API for opening journal files or directories by fd 2016-04-25 15:24:46 +02:00
journal-qrcode.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
journal-qrcode.h tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
journal-send.c sd-journal: suppress empty lines 2016-07-19 17:51:20 +02:00
journal-vacuum.c tree-wide: make ++/-- usage consistent WRT spacing 2016-02-22 20:32:04 -08:00
journal-vacuum.h tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
journal-verify.c journal-verify: get rid of strerror 2016-09-13 20:10:56 -04:00
journal-verify.h tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
journalctl.c Updated formatting for printing the key for FSS (#4165) 2016-09-16 10:14:55 -04:00
journald-audit.c tree-wide: make ++/-- usage consistent WRT spacing 2016-02-22 20:32:04 -08:00
journald-audit.h tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
journald-console.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
journald-console.h tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
journald-gperf.gperf core: rename StartLimitInterval= to StartLimitIntervalSec= 2016-04-29 16:27:48 +02:00
journald-kmsg.c tree-wide: make ++/-- usage consistent WRT spacing 2016-02-22 20:32:04 -08:00
journald-kmsg.h tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
journald-native.c tree-wide: introduce new SOCKADDR_UN_LEN() macro, and use it everywhere 2016-05-05 22:24:36 +02:00
journald-native.h tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
journald-rate-limit.c journald, ratelimit: fix inaccurate message suppression in journal_rate_limit_test() (#4291) 2016-10-06 11:44:51 +02:00
journald-rate-limit.h tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
journald-server.c core: add "invocation ID" concept to service manager 2016-10-07 20:14:38 +02:00
journald-server.h core: add "invocation ID" concept to service manager 2016-10-07 20:14:38 +02:00
journald-stream.c journal: add stdout_stream_scan() comment (#4102) 2016-09-28 07:35:48 +02:00
journald-stream.h tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
journald-syslog.c journald: stack allocation cannot fail 2016-05-05 22:26:09 +02:00
journald-syslog.h tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
journald-wall.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
journald-wall.h tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
journald.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
journald.conf core: rename StartLimitInterval= to StartLimitIntervalSec= 2016-04-29 16:27:48 +02:00
lookup3.c buildsys,journal: allow -fsanitize=address without VALGRIND defined 2016-08-06 02:14:51 +00:00
lookup3.h tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
mmap-cache.c tree-wide: some work-arounds for gcc false positives regarding uninitialized variables 2016-06-21 14:15:23 +02:00
mmap-cache.h tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
sd-journal.c sd-journal: fix sd_journal_open_directory with SD_JOURNAL_OS_ROOT 2016-08-12 00:38:03 -04:00
test-audit-type.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
test-catalog.c fileio: simplify mkostemp_safe() (#4090) 2016-09-13 08:20:38 +02:00
test-compress-benchmark.c test-compress-benchmark: fix argument parsing on 32bit 2016-04-02 18:58:21 -04:00
test-compress.c fileio: simplify mkostemp_safe() (#4090) 2016-09-13 08:20:38 +02:00
test-journal-enum.c tree-wide: make ++/-- usage consistent WRT spacing 2016-02-22 20:32:04 -08:00
test-journal-flush.c sd-journal: add API for opening journal files or directories by fd 2016-04-25 15:24:46 +02:00
test-journal-init.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
test-journal-interleaving.c tests: get rid of strerror 2016-09-13 20:10:57 -04:00
test-journal-match.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
test-journal-send.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
test-journal-stream.c sd-journal: add API for opening journal files or directories by fd 2016-04-25 15:24:46 +02:00
test-journal-syslog.c tree-wide: remove Emacs lines from all files 2016-02-10 13:41:57 +01:00
test-journal-verify.c sd-journal: add API for opening journal files or directories by fd 2016-04-25 15:24:46 +02:00
test-journal.c sd-journal: add API for opening journal files or directories by fd 2016-04-25 15:24:46 +02:00
test-mmap-cache.c fileio: simplify mkostemp_safe() (#4090) 2016-09-13 08:20:38 +02:00