From b952663cd1b7c6d9d68d8e9229337645e54f0328 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 3 Dec 2023 20:19:08 +0100 Subject: [PATCH] gpt-auto-generator: Pass cryptsetup credentials to cryptsetup cryptsetup reads a bunch of credentials now but we don't pass import those in any service units yet. Let's pass through all cryptsetup prefixed credentials to the systemd-cryptsetup@root instance. --- man/systemd-cryptsetup.xml | 54 +++++++++++++++++++++++++++++++++++++- src/shared/generator.c | 1 + 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/man/systemd-cryptsetup.xml b/man/systemd-cryptsetup.xml index 1d3a3135f3..8191fdda4e 100644 --- a/man/systemd-cryptsetup.xml +++ b/man/systemd-cryptsetup.xml @@ -3,7 +3,7 @@ - + systemd-cryptsetup @@ -104,6 +104,58 @@ If no suitable key may be acquired via any of the mechanisms describes above, volume activation fails. + + System Credentials + + systemd-cryptsetup supports the service credentials logic as implemented by + ImportCredential=/LoadCredential=/SetCredential= + (see systemd.exec1 for + details). The following credentials are used by systemd-crypsetup@root.service + (generated by systemd-gpt-auto-generator) when passed in: + + + + cryptsetup.passphrase + + This credential specifies the passphrase of the LUKS volume. + + + + + + cryptsetup.fido2-pin + + This credential specifies the FIDO2 token pin. + + + + + + cryptsetup.tpm2-pin + + This credential specifies the TPM pin. + + + + + + cryptsetup.luks2-pin + + This credential specifies the LUKS2 token pin. + + + + + + cryptsetup.pkcs11-pin + + This credential specifies the PKCS11 token pin. + + + + + + See Also diff --git a/src/shared/generator.c b/src/shared/generator.c index 5626587269..fe58021f00 100644 --- a/src/shared/generator.c +++ b/src/shared/generator.c @@ -790,6 +790,7 @@ int generator_write_cryptsetup_service_section( "TimeoutSec=infinity\n" /* The binary handles timeouts on its own */ "KeyringMode=shared\n" /* Make sure we can share cached keys among instances */ "OOMScoreAdjust=500\n" /* Unlocking can allocate a lot of memory if Argon2 is used */ + "ImportCredential=cryptsetup.*\n" "ExecStart=" SYSTEMD_CRYPTSETUP_PATH " attach '%s' '%s' '%s' '%s'\n" "ExecStop=" SYSTEMD_CRYPTSETUP_PATH " detach '%s'\n", name_escaped, what_escaped, strempty(key_file_escaped), strempty(options_escaped), -- 2.25.1