Fix verbose message about key removal in luksKillSlot,luksErase and luksKremoveKey.

The crypt_keyslot_destroy() does not return keyslot number,
so return value 0 was always used as a keyslot reference.
This commit is contained in:
Milan Broz
2018-10-27 17:36:17 +02:00
parent bb29c5b322
commit 7213d5a76b
3 changed files with 16 additions and 4 deletions

View File

@@ -54,6 +54,9 @@ Changes since version 2.0.4
* Allows passphrase change for unbound keyslots.
* Fixes removed keyslot number in verbose message for luksKillSlot,
luksRemoveKey and erase command.
* Adds blkid scan when attempting to open a plain device and warn the user
about existing device signatures in a ciphertext device.

View File

@@ -1288,7 +1288,7 @@ static int action_luksKillSlot(void)
}
r = crypt_keyslot_destroy(cd, opt_key_slot);
tools_keyslot_msg(r, REMOVED);
tools_keyslot_msg(opt_key_slot, REMOVED);
out:
crypt_free(cd);
return r;
@@ -1341,7 +1341,7 @@ static int action_luksRemoveKey(void)
}
r = crypt_keyslot_destroy(cd, opt_key_slot);
tools_keyslot_msg(r, REMOVED);
tools_keyslot_msg(opt_key_slot, REMOVED);
out:
crypt_safe_free(password);
crypt_free(cd);
@@ -1911,7 +1911,7 @@ static int action_luksErase(void)
r = crypt_keyslot_destroy(cd, i);
if (r < 0)
goto out;
tools_keyslot_msg(r, REMOVED);
tools_keyslot_msg(i, REMOVED);
}
}
out:

View File

@@ -849,7 +849,7 @@ prepare "[37] Interactive add key." new
expect - >/dev/null <<EOF
proc abort {} { send_error "Timeout. "; exit 2 }
set timeout 10
eval spawn $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT -v $LOOPDEV
eval spawn $CRYPTSETUP luksAddKey -S 2 $FAST_PBKDF_OPT -v $LOOPDEV
expect timeout abort "Enter any existing passphrase:"
sleep 0.1
send "$PWD0\n"
@@ -867,6 +867,15 @@ sleep 0.1
send "$PWD1\n"
expect timeout abort "Command successful."
expect timeout abort eof
eval spawn $CRYPTSETUP luksKillSlot -v $LOOPDEV 1
expect timeout abort "Keyslot 1 is not active."
expect timeout abort eof
eval spawn $CRYPTSETUP luksKillSlot -v $LOOPDEV 2
expect timeout abort "Enter any remaining passphrase:"
sleep 0.1
send "$PWD0\n"
expect timeout abort "Key slot 2 removed."
expect timeout abort eof
exit
EOF
[ $? -eq 0 ] || fail "Expect script failed."