From: Ludwig Nussel Date: Wed, 17 Apr 2024 09:30:03 +0000 (+0200) Subject: bootctl: add --random-seed=yes/no X-Git-Tag: v257-rc1~1090 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ce171bf51bebaf6184f41e5cbcf00e0edbe0762;p=thirdparty%2Fsystemd.git bootctl: add --random-seed=yes/no --- diff --git a/man/bootctl.xml b/man/bootctl.xml index d5ded286cc6..f6218519c47 100644 --- a/man/bootctl.xml +++ b/man/bootctl.xml @@ -385,6 +385,15 @@ + + + By default the install 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. + + + + Ignore failure when the EFI System Partition cannot be found, when EFI variables diff --git a/shell-completion/bash/bootctl b/shell-completion/bash/bootctl index 45fcd502dee..775cc450553 100644 --- a/shell-completion/bash/bootctl +++ b/shell-completion/bash/bootctl @@ -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 diff --git a/shell-completion/zsh/_bootctl b/shell-completion/zsh/_bootctl index f021978f5f8..40826833728 100644 --- a/shell-completion/zsh/_bootctl +++ b/shell-completion/zsh/_bootctl @@ -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' diff --git a/src/boot/bootctl-install.c b/src/boot/bootctl-install.c index dc46d30c5bb..6f55b98d74b 100644 --- a/src/boot/bootctl-install.c +++ b/src/boot/bootctl-install.c @@ -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()); diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c index 10d72df0117..e609028731f 100644 --- a/src/boot/bootctl.c +++ b/src/boot/bootctl.c @@ -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; diff --git a/src/boot/bootctl.h b/src/boot/bootctl.h index 93f302ce307..19eb93c2b1d 100644 --- a/src/boot/bootctl.h +++ b/src/boot/bootctl.h @@ -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;