Systemd/src
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
..
ac-power
activate various: remove assignments of unread variables 2020-09-22 17:58:11 +02:00
analyze analyze: show ungrouped syscalls separately (#17343) 2020-10-14 10:31:59 +02:00
ask-password
backlight various: remove assignments of unread variables 2020-09-22 17:58:11 +02:00
basic fileio: beef up READ_FULL_FILE_CONNECT_SOCKET to allow setting sender socket name 2020-11-03 09:48:04 +01:00
binfmt
boot headers: use custom LicenseRef- spdx tag for various "public domain" files 2020-10-29 11:41:27 +01:00
busctl sd-bus: add custom return code when $XDG_RUNTIME_DIR is not set 2020-10-14 18:28:30 +02:00
cgls
cgroups-agent
cgtop cgtop: Display cpu time in microseonds with --raw 2020-10-21 14:29:48 +02:00
core fileio: beef up READ_FULL_FILE_CONNECT_SOCKET to allow setting sender socket name 2020-11-03 09:48:04 +01:00
coredump tree-wide: assorted coccinelle fixes 2020-10-09 15:02:23 +02:00
cryptsetup Revert "units: add initrd-cryptsetup.target" 2020-10-27 13:36:22 +01:00
debug-generator
delta Merge pull request #16635 from keszybz/do-not-for-each-word 2020-09-09 17:43:38 +02:00
detect-virt
dissect dissect-image: process /usr/ GPT partition type 2020-09-19 21:19:51 +02:00
environment-d-generator
escape tree-wide: correct cases where return log_{error,warning} is used without value 2020-09-08 17:40:46 +02:00
firstboot Add a helper function that does make_salt+crypt_r 2020-09-15 09:30:56 +02:00
fsck tree-wide: assorted coccinelle fixes 2020-10-09 15:02:23 +02:00
fstab-generator fstab-generator: add 'nofail' when NFS 'bg' option is used 2020-09-15 16:24:01 +02:00
fuzz udev: add fuzzer for udev_rule_parse_value 2020-10-29 20:19:29 +08:00
getty-generator getty-generator: use extract_first_word() 2020-09-09 09:34:54 +02:00
gpt-auto-generator dissect: wrap verity settings in new VeritySettings structure 2020-09-17 20:36:23 +09:00
hibernate-resume
home Merge pull request #17472 from keszybz/spdx-license-headers 2020-10-29 19:05:05 +01:00
hostname tree-wide: assorted coccinelle fixes 2020-10-09 15:02:23 +02:00
hwdb
id128
import tree-wide: assorted coccinelle fixes 2020-10-09 15:02:23 +02:00
initctl tree-wide: don't needlessly negate error number passed to bus_error_message() 2020-09-14 21:42:22 +02:00
journal Merge pull request #17472 from keszybz/spdx-license-headers 2020-10-29 19:05:05 +01:00
journal-remote fileio: beef up READ_FULL_FILE_CONNECT_SOCKET to allow setting sender socket name 2020-11-03 09:48:04 +01:00
kernel-install Merge pull request #16777 from DaanDeMeyer/kernel-install-followup 2020-08-25 09:30:44 +02:00
libsystemd Merge pull request #17444 from BtbN/fix_ib_dhcp4 2020-10-29 19:27:29 +01:00
libsystemd-network Merge pull request #17444 from BtbN/fix_ib_dhcp4 2020-10-29 19:27:29 +01:00
libudev tree-wide: define iterator inside of the macro 2020-09-08 12:14:05 +02:00
locale tree-wide: don't needlessly negate error number passed to bus_error_message() 2020-09-14 21:42:22 +02:00
login tree-wide: cast result of get_process_comm() to (void) where we ignore it 2020-10-27 14:06:49 +01:00
machine tree-wide: assorted coccinelle fixes 2020-10-09 15:02:23 +02:00
machine-id-setup core: keep machine-id transient until first boot completes 2020-10-19 16:28:22 +02:00
modules-load
mount tree-wide: assorted coccinelle fixes 2020-10-09 15:02:23 +02:00
network fileio: beef up READ_FULL_FILE_CONNECT_SOCKET to allow setting sender socket name 2020-11-03 09:48:04 +01:00
notify
nspawn fileio: beef up READ_FULL_FILE_CONNECT_SOCKET to allow setting sender socket name 2020-11-03 09:48:04 +01:00
nss-myhostname
nss-mymachines
nss-resolve nss-resolve: port over to new varlink interface 2020-08-26 16:48:16 +02:00
nss-systemd tree-wide: assorted coccinelle fixes 2020-10-09 15:02:23 +02:00
oom oomd: make start up swap check more robust 2020-10-22 17:04:26 -07:00
partition fileio: beef up READ_FULL_FILE_CONNECT_SOCKET to allow setting sender socket name 2020-11-03 09:48:04 +01:00
path sd-path: include 'search' in search pathnames 2020-09-23 10:08:44 +02:00
portable sd-bus: add custom return code when $XDG_RUNTIME_DIR is not set 2020-10-14 18:28:30 +02:00
pstore
quotacheck
random-seed
rc-local-generator meson: RC_LOCAL_SCRIPT_PATH_START to RC_LOCAL_PATH 2020-09-15 17:44:26 +02:00
remount-fs
reply-password
resolve Merge pull request #17472 from keszybz/spdx-license-headers 2020-10-29 19:05:05 +01:00
rfkill
run tree-wide: drop if braces around single line expressions as well 2020-10-09 15:11:55 +02:00
run-generator
shared fileio: beef up READ_FULL_FILE_CONNECT_SOCKET to allow setting sender socket name 2020-11-03 09:48:04 +01:00
shutdown shutdown: also fsync() DM devices before going down 2020-09-23 18:33:48 +02:00
sleep sleep: reword some debug messages 2020-09-08 17:40:46 +02:00
socket-proxy socket-proxy: port to new sd_event_source_set_exit_on_failure() API 2020-10-07 09:40:05 +02:00
stdio-bridge
sulogin-shell
sysctl tree-wide: define iterator inside of the macro 2020-09-08 12:14:05 +02:00
system-update-generator
systemctl tree-wide: cast result of get_process_comm() to (void) where we ignore it 2020-10-27 14:06:49 +01:00
systemd dhcp4: fix DHCP on InfiniBand interfaces 2020-10-28 14:44:43 +01:00
sysusers tmpfiles,sysusers: disable --image= support in standalone versions 2020-10-09 18:03:04 +02:00
sysv-generator tree-wide: define iterator inside of the macro 2020-09-08 12:14:05 +02:00
test fileio: beef up READ_FULL_FILE_CONNECT_SOCKET to allow setting sender socket name 2020-11-03 09:48:04 +01:00
time-wait-sync time-wait-sync: drop gpl snail mail boilerplate 2020-10-29 10:47:28 +01:00
timedate Replace gendered pronouns with gender neutral ones. (#16844) 2020-08-27 11:52:48 +09:00
timesync timesyncd: don't attempt to call IP_TOS sockopt on IPv6 sockets 2020-09-11 10:16:39 +02:00
tmpfiles tmpfiles: Handle filesystems without ACL support in more cases. 2020-10-26 10:20:10 +01:00
tty-ask-password-agent tree-wide: define iterator inside of the macro 2020-09-08 12:14:05 +02:00
udev Merge pull request #17399 from afq984/udev-escaped-string 2020-10-30 09:52:45 +09:00
update-done update-done: Do not fail with read-only /etc or /var 2020-10-20 13:46:36 +09:00
update-utmp tree-wide: correct cases where return log_{error,warning} is used without value 2020-09-08 17:40:46 +02:00
user-sessions
userdb shared: merge {user,group}-record-nss.{c,h} 2020-09-01 16:48:40 +02:00
vconsole
veritysetup fileio: beef up READ_FULL_FILE_CONNECT_SOCKET to allow setting sender socket name 2020-11-03 09:48:04 +01:00
version
volatile-root mount-util: rework umount_verbose() to take log level and flags arg 2020-09-23 18:57:36 +02:00
xdg-autostart-generator xdg-autostart-generator: use Type=exec 2020-10-22 11:05:17 +02:00