]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bootctl: add --random-seed=yes/no
authorLudwig Nussel <ludwig.nussel@suse.de>
Wed, 17 Apr 2024 09:30:03 +0000 (11:30 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 20 Jun 2024 05:26:13 +0000 (14:26 +0900)
man/bootctl.xml
shell-completion/bash/bootctl
shell-completion/zsh/_bootctl
src/boot/bootctl-install.c
src/boot/bootctl.c
src/boot/bootctl.h

index d5ded286cc6482112fd037ff345de86187a92b22..f6218519c47e4cd596a5d768869fc28745401506 100644 (file)
         <xi:include href="version-info.xml" xpointer="v220"/></listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term><option>--random-seed=yes|no</option></term>
+        <listitem><para>By default the <command>install</command> command initializes a random seed file in
+        the ESP. When creating an image it may be desirable to disable that in order to avoid having the
+        same seed in all instances.</para>
+
+        <xi:include href="version-info.xml" xpointer="v257"/></listitem>
+      </varlistentry>
+
       <varlistentry>
         <term><option>--graceful</option></term>
         <listitem><para>Ignore failure when the EFI System Partition cannot be found, when EFI variables
index 45fcd502dee9f532c22b13929a6da25ac6d32c7f..775cc450553be1bcb627ec2e1a7cf0e5bb5c3077 100644 (file)
@@ -33,7 +33,7 @@ _bootctl() {
     local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
     local -A OPTS=(
         [STANDALONE]='-h --help -p --print-esp-path -x --print-boot-path --version --no-variables --no-pager --graceful --dry-run'
-        [ARG]='--esp-path --boot-path --make-machine-id-directory --root --image --install-source'
+        [ARG]='--esp-path --boot-path --make-machine-id-directory --root --image --install-source --random-seed'
     )
 
     if __contains_word "$prev" ${OPTS[ARG]}; then
@@ -56,6 +56,9 @@ _bootctl() {
             --install-source)
                 comps="image host auto"
                 ;;
+            --random-seed)
+                comps="yes no"
+                ;;
         esac
         COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
         return 0
index f021978f5f8c62400155bfeb0223f99889fb4045..40826833728d4d0042229da5203eee18e88d3212 100644 (file)
@@ -83,4 +83,5 @@ _arguments \
     '--root=[Operate under the specified directory]:PATH' \
     '--image=[Operate on the specified image]:PATH' \
     '--install-source[Where to pick files when using --root=/--image=]:options:(image host auto)' \
+    '--random-seed[Whether to create random-seed file during install]:options:(yes no)' \
     '*::bootctl command:_bootctl_commands'
index dc46d30c5bba5c92bb1577338bc339d4415d749f..6f55b98d74b8a45cbcd219e58e9464b2b2b0ea1b 100644 (file)
@@ -847,9 +847,11 @@ int verb_install(int argc, char *argv[], void *userdata) {
                         if (r < 0)
                                 return r;
 
-                        r = install_random_seed(arg_esp_path);
-                        if (r < 0)
-                                return r;
+                        if (arg_install_random_seed) {
+                                r = install_random_seed(arg_esp_path);
+                                if (r < 0)
+                                        return r;
+                        }
                 }
 
                 r = install_loader_specification(arg_dollar_boot_path());
index 10d72df01175e2cf92b2cc962b14915cd833b008..e609028731f11f4f635ab62723ade307ce9c32f0 100644 (file)
@@ -39,6 +39,7 @@ bool arg_print_esp_path = false;
 bool arg_print_dollar_boot_path = false;
 unsigned arg_print_root_device = 0;
 bool arg_touch_variables = true;
+bool arg_install_random_seed = true;
 PagerFlags arg_pager_flags = 0;
 bool arg_graceful = false;
 bool arg_quiet = false;
@@ -186,6 +187,8 @@ static int help(int argc, char *argv[], void *userdata) {
                "  -RR                  Print path to the whole disk block device node\n"
                "                       backing the root FS (returns e.g. /dev/nvme0n1)\n"
                "     --no-variables    Don't touch EFI variables\n"
+               "     --random-seed=yes|no\n"
+               "                       Whether to create random-seed file during install\n"
                "     --no-pager        Do not pipe output into a pager\n"
                "     --graceful        Don't fail when the ESP cannot be found or EFI\n"
                "                       variables cannot be written\n"
@@ -222,6 +225,7 @@ static int parse_argv(int argc, char *argv[]) {
                 ARG_INSTALL_SOURCE,
                 ARG_VERSION,
                 ARG_NO_VARIABLES,
+                ARG_RANDOM_SEED,
                 ARG_NO_PAGER,
                 ARG_GRACEFUL,
                 ARG_MAKE_ENTRY_DIRECTORY,
@@ -247,6 +251,7 @@ static int parse_argv(int argc, char *argv[]) {
                 { "print-boot-path",             no_argument,       NULL, 'x'                             },
                 { "print-root-device",           no_argument,       NULL, 'R'                             },
                 { "no-variables",                no_argument,       NULL, ARG_NO_VARIABLES                },
+                { "random-seed",                 required_argument, NULL, ARG_RANDOM_SEED                 },
                 { "no-pager",                    no_argument,       NULL, ARG_NO_PAGER                    },
                 { "graceful",                    no_argument,       NULL, ARG_GRACEFUL                    },
                 { "quiet",                       no_argument,       NULL, 'q'                             },
@@ -334,6 +339,12 @@ static int parse_argv(int argc, char *argv[]) {
                         arg_touch_variables = false;
                         break;
 
+                case ARG_RANDOM_SEED:
+                        r = parse_boolean_argument("--random-seed=", optarg, &arg_install_random_seed);
+                        if (r < 0)
+                                return r;
+                        break;
+
                 case ARG_NO_PAGER:
                         arg_pager_flags |= PAGER_DISABLE;
                         break;
index 93f302ce3072a05064fa368c3c612e75c70a2823..19eb93c2b1d3228eaeb8c864eb0b9f7b62d0fe82 100644 (file)
@@ -20,6 +20,7 @@ extern bool arg_print_esp_path;
 extern bool arg_print_dollar_boot_path;
 extern unsigned arg_print_root_device;
 extern bool arg_touch_variables;
+extern bool arg_install_random_seed;
 extern PagerFlags arg_pager_flags;
 extern bool arg_graceful;
 extern bool arg_quiet;