]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dissect-tool: accept encryption password via $PASSWORD
authorLennart Poettering <lennart@poettering.net>
Mon, 17 Nov 2025 15:42:58 +0000 (16:42 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 17 Nov 2025 15:42:58 +0000 (16:42 +0100)
docs/ENVIRONMENT.md
src/dissect/dissect.c

index 5732c217aaa0f70eb57252fb0ac50cc62a4f52b6..f2a7d25edbe2665d77a0dad6160c7f4a4441c9e3 100644 (file)
@@ -578,8 +578,8 @@ disk images with `--image=` or similar:
   environment variable to the build directory and you are set. This variable
   is only supported when systemd is compiled in developer mode.
 
-Various tools that read passwords from the TTY, such as `systemd-cryptenroll`
-and `homectl`:
+Various tools that read passwords from the TTY, such as `systemd-cryptenroll`,
+`systemd-dissect` and `homectl`:
 
 * `$PASSWORD` — takes a string: the literal password to use. If this
   environment variable is set it is used as password instead of prompting the
index 1a8fa52fce8a118a0903e3ee513f9560aafa9e35..d244822c133de376776a77ff9909ef532e32f2b6 100644 (file)
@@ -2152,8 +2152,15 @@ static int run(int argc, char *argv[]) {
                                         return log_error_errno(r, "Failed to guess verity root hash: %m");
 
                                 if (arg_action != ACTION_DISSECT) {
+                                        _cleanup_(erase_and_freep) char *envpw = NULL;
+
+                                        r = getenv_steal_erase("PASSWORD", &envpw);
+                                        if (r < 0)
+                                                return log_error_errno(r, "Failed to acquire password from environment: %m");
+
                                         r = dissected_image_decrypt_interactively(
-                                                        m, NULL,
+                                                        m,
+                                                        envpw,
                                                         &arg_verity_settings,
                                                         arg_image_policy,
                                                         arg_flags);