]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tpm2-clear: make it clear that we default to true for systemd.tpm2_allow_clear
authorMike Yuan <me@yhndnzj.com>
Wed, 5 Mar 2025 15:13:55 +0000 (16:13 +0100)
committerMike Yuan <me@yhndnzj.com>
Wed, 5 Mar 2025 16:04:00 +0000 (17:04 +0100)
src/tpm2-setup/tpm2-clear.c

index 0dcee96a07ad21098b19590730a36196f79ec820..5c4fc2a5dee3b25f0fe2632495b047f2c4e27c30 100644 (file)
@@ -94,14 +94,15 @@ static int request_tpm2_clear(void) {
 
         if (clear < 0) {
                 bool b;
-                r = proc_cmdline_get_bool("systemd.tpm2_allow_clear", /* flags= */ 0, &b);
+                r = proc_cmdline_get_bool("systemd.tpm2_allow_clear", PROC_CMDLINE_TRUE_WHEN_MISSING, &b);
                 if (r < 0)
                         return log_error_errno(r, "Failed to parse systemd.tpm2_allow_clear kernel command line argument: %m");
-                if (r > 0)
-                        clear = b;
+                clear = b;
         }
 
-        if (clear == 0) {
+        assert(clear >= 0);
+
+        if (!clear) {
                 log_info("Clearing TPM2 disabled, exiting early.");
                 return 0;
         }