mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-14 12:20:00 +01:00
Fix return code and retry count for bad passphrase and non-tty input.
It there is an input on stdin (pipe), we cannot retry for password, a retry applies only for the real terminal. Also the retry lost EPERM (wrong passphrase) return code in this case, replacing it with tty read error. Fixes #321.
This commit is contained in:
@@ -1122,7 +1122,7 @@ static int action_open_luks(void)
|
||||
if (r >= 0 || opt_token_only)
|
||||
goto out;
|
||||
|
||||
tries = (opt_key_file && !tools_is_stdin(opt_key_file)) ? 1 : opt_tries;
|
||||
tries = (tools_is_stdin(opt_key_file) && isatty(STDIN_FILENO)) ? opt_tries : 1;
|
||||
do {
|
||||
r = tools_get_key(NULL, &password, &passwordLen,
|
||||
opt_keyfile_offset, opt_keyfile_size, opt_key_file,
|
||||
@@ -1590,7 +1590,7 @@ static int action_luksResume(void)
|
||||
if ((r = crypt_load(cd, luksType(opt_type), NULL)))
|
||||
goto out;
|
||||
|
||||
tries = (opt_key_file && !tools_is_stdin(opt_key_file)) ? 1 : opt_tries;
|
||||
tries = (tools_is_stdin(opt_key_file) && isatty(STDIN_FILENO)) ? opt_tries : 1;
|
||||
do {
|
||||
r = tools_get_key(NULL, &password, &passwordLen,
|
||||
opt_keyfile_offset, opt_keyfile_size, opt_key_file,
|
||||
|
||||
Reference in New Issue
Block a user