]> git.ipfire.org Git - thirdparty/systemd.git/commit
core: Add support for renaming credentials with ImportCredential=
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 30 Jul 2024 14:16:26 +0000 (16:16 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 31 Jul 2024 13:52:27 +0000 (15:52 +0200)
commit831f208783aeac443e6f2fc2efc3119535a032ef
tree8ba1bf30dcd20d9e4d0a56ecd084fa4d3ddcc39c
parent3de13e6148731ae9c36885afd78b1421e6f16305
core: Add support for renaming credentials with ImportCredential=

This allows for "per-instance" credentials for units. The use case
is best explained with an example. Currently all our getty units
have the following stanzas in their unit file:

"""
ImportCredential=agetty.*
ImportCredential=login.*
"""

This means that setting agetty.autologin=root as a system credential
will make every instance of our all our getty units autologin as the
root user. This prevents us from doing autologin on /dev/hvc0 while
still requiring manual login on all other ttys.

To solve the issue, we introduce support for renaming credentials with
ImportCredential=. This will allow us to add the following to e.g.
serial-getty@.service:

"""
ImportCredential=tty.serial.%I.agetty.*:agetty.
ImportCredential=tty.serial.%I.login.*:login.
"""

which for serial-getty@hvc0.service will make the service manager read
all credentials of the form "tty.serial.hvc0.agetty.xxx" and pass them
to the service in the form "agetty.xxx" (same goes for login). We can
apply the same to each of the getty units to allow setting agetty and
login credentials for individual ttys instead of globally.
12 files changed:
man/org.freedesktop.systemd1.xml
man/systemd.exec.xml
src/core/dbus-execute.c
src/core/exec-credential.c
src/core/exec-credential.h
src/core/execute-serialize.c
src/core/execute.c
src/core/execute.h
src/core/load-fragment-gperf.gperf.in
src/core/load-fragment.c
src/shared/bus-unit-util.c
test/units/TEST-54-CREDS.sh