]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bootctl: move conditions into corresponding functions
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 26 Oct 2025 07:57:07 +0000 (16:57 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 2 Nov 2025 07:07:46 +0000 (16:07 +0900)
src/bootctl/bootctl-install.c
src/bootctl/bootctl-random-seed.c

index f31c55d36a5db876903dcb69b0d67b604cc13306..a0a2ba49081e468aa6ea6cb11c03e6611caeb47d 100644 (file)
@@ -626,6 +626,9 @@ static int efi_timestamp(EFI_TIME *ret) {
 #endif
 
 static int install_secure_boot_auto_enroll(const char *esp, X509 *certificate, EVP_PKEY *private_key) {
+        if (!arg_secure_boot_auto_enroll)
+                return 0;
+
 #if HAVE_OPENSSL
         int r;
 
@@ -1101,17 +1104,13 @@ int verb_install(int argc, char *argv[], void *userdata) {
                         if (r < 0)
                                 return r;
 
-                        if (arg_install_random_seed) {
-                                r = install_random_seed(arg_esp_path);
-                                if (r < 0)
-                                        return r;
-                        }
+                        r = install_random_seed(arg_esp_path);
+                        if (r < 0)
+                                return r;
 
-                        if (arg_secure_boot_auto_enroll) {
-                                r = install_secure_boot_auto_enroll(arg_esp_path, certificate, private_key);
-                                if (r < 0)
-                                        return r;
-                        }
+                        r = install_secure_boot_auto_enroll(arg_esp_path, certificate, private_key);
+                        if (r < 0)
+                                return r;
                 }
 
                 r = install_loader_specification(arg_dollar_boot_path());
index c4811aace33d8dd732c9d1f0b7ceaaeb8349359c..8abb6c19697153c798784c2fd2ef6510586f701f 100644 (file)
@@ -122,6 +122,9 @@ int install_random_seed(const char *esp) {
 
         assert_cc(RANDOM_EFI_SEED_SIZE == SHA256_DIGEST_SIZE);
 
+        if (!arg_install_random_seed)
+                return 0;
+
         esp_fd = open(esp, O_DIRECTORY|O_RDONLY|O_CLOEXEC);
         if (esp_fd < 0)
                 return log_error_errno(errno, "Failed to open ESP directory '%s': %m", esp);