diff --git a/ChangeLog b/ChangeLog index 16d9baf3..f7c92825 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 2011-01-29 Milan Broz * Fix mapping removal if device disappeared but node still exists. + * Fix luksAddKey return code if master key is used. 2011-01-25 Milan Broz * Add loop-AES handling (loopaesOpen and loopaesClose commands). diff --git a/src/cryptsetup.c b/src/cryptsetup.c index 25583f21..adcbf16e 100644 --- a/src/cryptsetup.c +++ b/src/cryptsetup.c @@ -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) { diff --git a/tests/compat-test b/tests/compat-test index c0737658..12e7f19a 100755 --- a/tests/compat-test +++ b/tests/compat-test @@ -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