dissect-image: simplify check for passphrase presence

m->encrypted is set when fstype=="crypto_LUKS", but this is not obvious when
reading decrypt_partition(). Just check if passphrase is set before using
it.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2017-11-27 12:16:09 +00:00
parent bbd1590085
commit bdd73ac5c2
1 changed files with 3 additions and 3 deletions

View File

@ -861,6 +861,9 @@ static int decrypt_partition(
if (!streq(m->fstype, "crypto_LUKS"))
return 0;
if (!passphrase)
return -ENOKEY;
r = make_dm_name_and_node(m->node, "-decrypted", &name, &node);
if (r < 0)
return r;
@ -1006,9 +1009,6 @@ int dissected_image_decrypt(
}
#if HAVE_LIBCRYPTSETUP
if (m->encrypted && !passphrase)
return -ENOKEY;
d = new0(DecryptedImage, 1);
if (!d)
return -ENOMEM;