]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cryptenroll: add an "unlock_password" field to ExecContext
authorLennart Poettering <lennart@amutable.com>
Wed, 24 Jun 2026 09:23:19 +0000 (11:23 +0200)
committerLennart Poettering <lennart@amutable.com>
Sat, 27 Jun 2026 15:28:39 +0000 (17:28 +0200)
This is preparation for the Varlinkification, as then we want to pass
the password in via IPC instead of prompting the user.

Note that this only adds the field, and applies it, but never actually
sets it. That's for the varlinkification later.

src/cryptenroll/cryptenroll-password.c
src/cryptenroll/cryptenroll.c
src/cryptenroll/cryptenroll.h

index 6e78d6ab2fe6254799736847143f7b8eeff52a1a..0d3da9f2e7435d29508e5590f03251798a234612 100644 (file)
@@ -26,6 +26,20 @@ int load_volume_key_password(
         assert_se(cd);
         assert_se(ret_vk);
 
+        if (c->unlock_password) {
+                r = sym_crypt_volume_key_get(
+                                cd,
+                                CRYPT_ANY_SLOT,
+                                ret_vk->iov_base,
+                                &ret_vk->iov_len,
+                                c->unlock_password,
+                                strlen(c->unlock_password));
+                if (r < 0)
+                        return log_error_errno(r, "Provided unlock password did not work: %m");
+
+                return r;
+        }
+
         r = getenv_steal_erase("PASSWORD", &envpw);
         if (r < 0)
                 return log_error_errno(r, "Failed to acquire password from environment: %m");
index 0099c3c4a5cabf1129bfa1d204fb6c5cf7567f65..c9f17c761fcbd48fa6d13a1802650c9d2e23a8f9 100644 (file)
@@ -121,6 +121,7 @@ void enroll_context_done(EnrollContext *c) {
         c->unlock_keyfile = mfree(c->unlock_keyfile);
         c->unlock_fido2_device = mfree(c->unlock_fido2_device);
         c->unlock_tpm2_device = mfree(c->unlock_tpm2_device);
+        c->unlock_password = erase_and_free(c->unlock_password);
         c->passphrase = erase_and_free(c->passphrase);
         c->fido2_device = mfree(c->fido2_device);
         c->fido2_salt_file = mfree(c->fido2_salt_file);
index 3e598487042e6276d2e21dfa4bb35c189a39a95f..b675023ee381d555c312a759ca7b2437168fd20b 100644 (file)
@@ -48,6 +48,7 @@ typedef struct EnrollContext {
         char *unlock_keyfile;
         char *unlock_fido2_device;
         char *unlock_tpm2_device;
+        char *unlock_password;          /* used by Varlink; NULL on CLI path */
 
         /* New password to enroll (mechanism == password). When NULL the helpers fall back to
          * $NEWPASSWORD / askpw. */