Fix luksAddKey return code if master key is used.

git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@421 36d66b0a-2a48-0410-832c-cd162a569da5
This commit is contained in:
Milan Broz
2011-01-31 23:10:32 +00:00
parent 0a905364fa
commit e0dab9e99f
3 changed files with 11 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
2011-01-29 Milan Broz <mbroz@redhat.com>
* Fix mapping removal if device disappeared but node still exists.
* Fix luksAddKey return code if master key is used.
2011-01-25 Milan Broz <mbroz@redhat.com>
* Add loop-AES handling (loopaesOpen and loopaesClose commands).

View File

@@ -643,9 +643,10 @@ static int action_luksAddKey(int arg)
crypt_set_iterarion_time(cd, opt_iteration_time);
if (opt_master_key_file) {
if (_read_mk(opt_master_key_file, &key, keysize) < 0)
r = _read_mk(opt_master_key_file, &key, keysize);
if (r < 0)
goto out;
//FIXME: process keyfile arg
r = crypt_keyslot_add_by_volume_key(cd, opt_key_slot,
key, keysize, NULL, 0);
} else if (opt_key_file || opt_new_key_file) {

View File

@@ -197,7 +197,13 @@ $CRYPTSETUP -q luksFormat --master-key-file /dev/urandom -s 128 --uuid $TEST_UUI
$CRYPTSETUP luksOpen -d $KEY1 $LOOPDEV $DEV_NAME || fail
$CRYPTSETUP -q luksClose $DEV_NAME || fail
prepare "[17] AddKey passphrase and keyfile" wipe
prepare "[17] AddKey volume key, passphrase and keyfile" wipe
# masterkey
echo "key0" | $CRYPTSETUP -q luksFormat $LOOPDEV --master-key-file /dev/zero --key-slot 3 || fail
$CRYPTSETUP luksDump $LOOPDEV | grep -q "Key Slot 3: ENABLED" || fail
echo "key1" | $CRYPTSETUP luksAddKey $LOOPDEV --master-key-file /dev/zero --key-slot 4 || fail
$CRYPTSETUP luksDump $LOOPDEV | grep -q "Key Slot 4: ENABLED" || fail
echo "key2" | $CRYPTSETUP luksAddKey $LOOPDEV --master-key-file /dev/null --key-slot 5 2>/dev/null && fail
# [0]key0 [1]key1 [2]$KEY1/1 [3]$KEY1 [4]$KEY2
$CRYPTSETUP -q luksFormat $LOOPDEV $KEY1 --key-slot 3 || fail
$CRYPTSETUP luksDump $LOOPDEV | grep -q "Key Slot 3: ENABLED" || fail