bootctl: add --random-seed=yes/no

This commit is contained in:
Ludwig Nussel 2024-04-17 11:30:03 +02:00 committed by Yu Watanabe
parent 8422d04e8d
commit 8ce171bf51
6 changed files with 31 additions and 4 deletions

View file

@ -385,6 +385,15 @@
<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

View 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

View 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'

View 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());

View 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;

View 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;