mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-11 19:00:02 +01:00
Add back "Passphrase for (dev):" prompt.
This commit is contained in:
@@ -2650,8 +2650,12 @@ const char *crypt_get_uuid(struct crypt_device *cd)
|
||||
|
||||
const char *crypt_get_device_name(struct crypt_device *cd)
|
||||
{
|
||||
const char *path = device_block_path(cd->device);
|
||||
const char *path;
|
||||
|
||||
if (!cd)
|
||||
return NULL;
|
||||
|
||||
path = device_block_path(cd->device);
|
||||
if (!path)
|
||||
path = device_path(cd->device);
|
||||
|
||||
|
||||
@@ -181,8 +181,7 @@ static int action_open_plain(void)
|
||||
opt_keyfile_offset, activate_flags);
|
||||
} else {
|
||||
key_size_max = (opt_key_file && !params.hash) ? key_size : (size_t)opt_keyfile_size;
|
||||
r = tools_get_key(_("Enter passphrase: "),
|
||||
&password, &passwordLen,
|
||||
r = tools_get_key(NULL, &password, &passwordLen,
|
||||
opt_keyfile_offset, key_size_max,
|
||||
opt_key_file, opt_timeout,
|
||||
_verify_passphrase(0), 0, cd);
|
||||
@@ -245,8 +244,7 @@ static int tcrypt_load(struct crypt_device *cd, struct crypt_params_tcrypt *para
|
||||
|
||||
do {
|
||||
/* TCRYPT header is encrypted, get passphrase now */
|
||||
r = tools_get_key(_("Enter passphrase: "),
|
||||
CONST_CAST(char**)¶ms->passphrase,
|
||||
r = tools_get_key(NULL, CONST_CAST(char**)¶ms->passphrase,
|
||||
¶ms->passphrase_size, 0, 0, opt_keyfile_stdin, opt_timeout,
|
||||
_verify_passphrase(0), 0, cd);
|
||||
if (r < 0)
|
||||
@@ -778,7 +776,7 @@ static int action_luksFormat(void)
|
||||
else if (opt_urandom)
|
||||
crypt_set_rng_type(cd, CRYPT_RNG_URANDOM);
|
||||
|
||||
r = tools_get_key(_("Enter passphrase: "), &password, &passwordLen,
|
||||
r = tools_get_key(NULL, &password, &passwordLen,
|
||||
opt_keyfile_offset, opt_keyfile_size, opt_key_file,
|
||||
opt_timeout, _verify_passphrase(1), 1, cd);
|
||||
if (r < 0)
|
||||
@@ -1218,7 +1216,7 @@ static int luksDump_with_volume_key(struct crypt_device *cd)
|
||||
if (!vk)
|
||||
return -ENOMEM;
|
||||
|
||||
r = tools_get_key(_("Enter passphrase: "), &password, &passwordLen,
|
||||
r = tools_get_key(NULL, &password, &passwordLen,
|
||||
opt_keyfile_offset, opt_keyfile_size, opt_key_file,
|
||||
opt_timeout, 0, 0, cd);
|
||||
if (r < 0)
|
||||
|
||||
@@ -256,6 +256,7 @@ int tools_get_key(const char *prompt,
|
||||
int timeout, int verify, int pwquality,
|
||||
struct crypt_device *cd)
|
||||
{
|
||||
char tmp[1024];
|
||||
int r = -EINVAL, block;
|
||||
|
||||
block = tools_signals_blocked();
|
||||
@@ -267,10 +268,12 @@ int tools_get_key(const char *prompt,
|
||||
if (keyfile_offset) {
|
||||
log_err(_("Cannot use offset with terminal input.\n"));
|
||||
} else {
|
||||
//FIXME:if (!prompt) "Enter passphrase for %s: "
|
||||
if (!prompt)
|
||||
prompt = "Enter passphrase:";
|
||||
r = crypt_get_key_tty(prompt, key, key_size, timeout, verify, cd);
|
||||
if (!prompt && !crypt_get_device_name(cd))
|
||||
snprintf(tmp, sizeof(tmp), _("Enter passphrase: "));
|
||||
else if (!prompt)
|
||||
snprintf(tmp, sizeof(tmp), _("Enter passphrase for %s: "),
|
||||
crypt_get_device_name(cd));
|
||||
r = crypt_get_key_tty(prompt ?: tmp, key, key_size, timeout, verify, cd);
|
||||
}
|
||||
} else {
|
||||
log_dbg("STDIN descriptor passphrase entry requested.");
|
||||
|
||||
Reference in New Issue
Block a user