Systemd/src/journal-remote
Lennart Poettering d3dcf4e3b9 fileio: beef up READ_FULL_FILE_CONNECT_SOCKET to allow setting sender socket name
This beefs up the READ_FULL_FILE_CONNECT_SOCKET logic of
read_full_file_full() a bit: when used a sender socket name may be
specified. If specified as NULL behaviour is as before: the client
socket name is picked by the kernel. But if specified as non-NULL the
client can pick a socket name to use when connecting. This is useful to
communicate a minimal amount of metainformation from client to server,
outside of the transport payload.

Specifically, these beefs up the service credential logic to pass an
abstract AF_UNIX socket name as client socket name when connecting via
READ_FULL_FILE_CONNECT_SOCKET, that includes the requesting unit name
and the eventual credential name. This allows servers implementing the
trivial credential socket logic to distinguish clients: via a simple
getpeername() it can be determined which unit is requesting a
credential, and which credential specifically.

Example: with this patch in place, in a unit file "waldo.service" a
configuration line like the following:

    LoadCredential=foo:/run/quux/creds.sock

will result in a connection to the AF_UNIX socket /run/quux/creds.sock,
originating from an abstract namespace AF_UNIX socket:

    @$RANDOM/unit/waldo.service/foo

(The $RANDOM is replaced by some randomized string. This is included in
the socket name order to avoid namespace squatting issues: the abstract
socket namespace is open to unprivileged users after all, and care needs
to be taken not to use guessable names)

The services listening on the /run/quux/creds.sock socket may thus
easily retrieve the name of the unit the credential is requested for
plus the credential name, via a simpler getpeername(), discarding the
random preifx and the /unit/ string.

This logic uses "/" as separator between the fields, since both unit
names and credential names appear in the file system, and thus are
designed to use "/" as outer separators. Given that it's a good safe
choice to use as separators here, too avoid any conflicts.

This is a minimal patch only: the new logic is used only for the unit
file credential logic. For other places where we use
READ_FULL_FILE_CONNECT_SOCKET it is probably a good idea to use this
scheme too, but this should be done carefully in later patches, since
the socket names become API that way, and we should determine the right
amount of info to pass over.
2020-11-03 09:48:04 +01:00
..
browse.html fix(journal-gatewayd): use relative urls (not starting with '/') 2019-06-18 17:06:12 +02:00
journal-gatewayd.c fileio: beef up READ_FULL_FILE_CONNECT_SOCKET to allow setting sender socket name 2020-11-03 09:48:04 +01:00
journal-remote-main.c fileio: beef up READ_FULL_FILE_CONNECT_SOCKET to allow setting sender socket name 2020-11-03 09:48:04 +01:00
journal-remote-parse.c journal-import: extract helpers for handling arrays of iovec and make them available for others 2019-06-27 19:14:23 +02:00
journal-remote-parse.h Drop my copyright headers 2018-06-14 13:03:20 +02:00
journal-remote-write.c journal-remote: use source's boot-id 2019-04-02 10:32:21 +02:00
journal-remote-write.h journal-remote: use source's boot-id 2019-04-02 10:32:21 +02:00
journal-remote.c tree-wide: drop stdio.h when stdio-util.h is included 2019-11-04 00:30:32 +09:00
journal-remote.conf.in journal-remote: add license and reference to man page in conf files 2018-06-26 04:04:45 +09:00
journal-remote.h journal-remote: destroy RemoteServer object by using _cleanup_ attribute 2018-12-08 18:09:40 +09:00
journal-upload-journal.c journal: fix dropping first record during upload to remote journal 2020-05-19 07:58:59 +02:00
journal-upload.c various daemons: emit Stopping... notification before destructing the manager object 2020-07-02 17:12:23 +02:00
journal-upload.conf.in journal-remote: add license and reference to man page in conf files 2018-06-26 04:04:45 +09:00
journal-upload.h tree-wide: use the usual SPDX header for our own files 2020-10-29 10:47:20 +01:00
log-generator.py log-generator: make message size configurable, add short options 2018-05-31 13:04:18 +02:00
meson.build meson: create /var/log/journal/{,remote/} conditionally 2019-07-04 10:16:48 +02:00
microhttpd-util.c tree-wide: use DISABLE_WARNING_FORMAT_NONLITERAL where appropriate 2020-05-25 18:25:05 +02:00
microhttpd-util.h Fix build with µhttpd 0.9.71 2020-07-01 13:10:48 +09:00