Rename crypttab opt silent to password-echo

Use the option name 'password-echo' instead of the generic term
'silent'.

Make the option take an argument for better control over echoing
behavior.

Related discussion in https://github.com/systemd/systemd/pull/19619
This commit is contained in:
Sebastian Blunt
2021-06-07 10:35:28 +02:00
committed by Lennart Poettering
parent 3745355764
commit 2cbca51a71
4 changed files with 36 additions and 16 deletions
+17 -6
View File
@@ -58,7 +58,7 @@ static char *arg_header = NULL;
static unsigned arg_tries = 3;
static bool arg_readonly = false;
static bool arg_verify = false;
static bool arg_silent = false;
static AskPasswordFlags arg_ask_password_flags = 0;
static bool arg_discards = false;
static bool arg_same_cpu_crypt = false;
static bool arg_submit_from_crypt_cpus = false;
@@ -235,9 +235,20 @@ static int parse_one_option(const char *option) {
arg_readonly = true;
else if (streq(option, "verify"))
arg_verify = true;
else if (streq(option, "silent"))
arg_silent = true;
else if (STR_IN_SET(option, "allow-discards", "discard"))
else if ((val = startswith(option, "password-echo="))) {
if (streq(val, "masked"))
arg_ask_password_flags &= ~(ASK_PASSWORD_ECHO|ASK_PASSWORD_SILENT);
else {
r = parse_boolean(val);
if (r < 0) {
log_warning_errno(r, "Invalid password-echo= option \"%s\", ignoring.", val);
return 0;
}
SET_FLAG(arg_ask_password_flags, ASK_PASSWORD_ECHO, r);
SET_FLAG(arg_ask_password_flags, ASK_PASSWORD_SILENT, !r);
}
} else if (STR_IN_SET(option, "allow-discards", "discard"))
arg_discards = true;
else if (streq(option, "same-cpu-crypt"))
arg_same_cpu_crypt = true;
@@ -543,7 +554,7 @@ static int get_password(
_cleanup_strv_free_erase_ char **passwords = NULL;
char **p, *id;
int r = 0;
AskPasswordFlags flags = ASK_PASSWORD_PUSH_CACHE | (arg_silent*ASK_PASSWORD_SILENT);
AskPasswordFlags flags = arg_ask_password_flags | ASK_PASSWORD_PUSH_CACHE;
assert(vol);
assert(src);
@@ -811,7 +822,7 @@ static int attach_luks_or_plain_or_bitlk_by_fido2(
arg_headless,
required,
&decrypted_key, &decrypted_key_size,
arg_silent);
arg_ask_password_flags);
if (r >= 0)
break;
if (r != -EAGAIN) /* EAGAIN means: token not found */