2011-04-22 Milan Broz <mbroz@redhat.com>
* Also support --skip option for loopaesOpen.
+ * Fix return code when passphrase is read from pipe.
2011-04-18 Milan Broz <mbroz@redhat.com>
* Respect maximum keyfile size paramater.
{
char *passphrase_read = NULL;
size_t passphrase_size_read;
- int r = -EINVAL, tries = cd->tries;
+ int r = -EINVAL, eperm = 0, tries = cd->tries;
*vk = NULL;
do {
r = LUKS_open_key_with_hdr(cd->device, keyslot, passphrase_read,
passphrase_size_read, &cd->hdr, vk, cd);
+ if (r == -EPERM)
+ eperm = 1;
crypt_safe_free(passphrase_read);
passphrase_read = NULL;
} while (r == -EPERM && (--tries > 0));
if (r < 0) {
crypt_free_volume_key(*vk);
*vk = NULL;
+
+ /* Report wrong passphrase if at least one try failed */
+ if (eperm && r == -EPIPE)
+ r = -EPERM;
}
crypt_safe_free(passphrase_read);
return -EINVAL;
}
+ if (read_stdin)
+ log_dbg("STDIN descriptor passphrase entry requested.");
+ else
+ log_dbg("File descriptor passphrase entry requested.");
+
/* If not requsted otherwise, we limit input to prevent memory exhaustion */
if (keyfile_size_max == 0) {
keyfile_size_max = DEFAULT_KEYFILE_SIZE_MAXKB * 1024;
}
/* Fail if piped input dies reading nothing */
- if(!i && !regular_file)
+ if(!i && !regular_file) {
+ log_dbg("Nothing read on input.");
+ r = -EPIPE;
goto out_err;
+ }
/* Fail if we exceeded internal default (no specified size) */
if (unlimited_read && i == keyfile_size_max) {