--- a/ChangeLog 2011-12-21 16:35:08.145307411 +0100 +++ b/ChangeLog 2011-12-21 16:36:49.838516700 +0100 @@ -1,5 +1,6 @@ 2011-12-21 Ondrej Kozina <okozina@redhat.com> * Print informative message in isLuks only in verbose mode. + * Fix luksKillSLot exit code if slot is inactive or invalid. 2011-06-08 Milan Broz <mbroz@redhat.com> * Fix return code for status command when device doesn't exists. --- a/src/cryptsetup.c 2011-12-21 16:35:08.146307395 +0100 +++ b/src/cryptsetup.c 2011-12-21 16:39:50.679097217 +0100 @@ -613,6 +613,7 @@ static int action_luksKillSlot(int arg __attribute__((unused))) case CRYPT_SLOT_INACTIVE: log_err(_("Key %d not active. Can't wipe.\n"), opt_key_slot); case CRYPT_SLOT_INVALID: + r = -EINVAL; goto out; } @@ -1245,7 +1245,7 @@ int main(int argc, const char **argv) if (!strcmp(aname, "luksKillSlot") && action_argc > 1) opt_key_slot = atoi(action_argv[1]); if (opt_key_slot != CRYPT_ANY_SLOT && - (opt_key_slot < 0 || opt_key_slot > crypt_keyslot_max(CRYPT_LUKS1))) + (opt_key_slot < 0 || opt_key_slot >= crypt_keyslot_max(CRYPT_LUKS1))) usage(popt_context, EXIT_FAILURE, _("Key slot is invalid."), poptGetInvocationName(popt_context)); --- a/tests/compat-test 2011-12-21 15:59:53.809001558 +0100 +++ b/tests/compat-test 2011-12-21 16:41:34.850272053 +0100 @@ -126,6 +126,8 @@ echo "key1" | $CRYPTSETUP luksOpen $LOOP # Unsuccessful Key Delete - nothing may change prepare "[7] unsuccessful delete" +$CRYPTSETUP -q luksKillSlot $LOOPDEV 8 2>/dev/null && fail +$CRYPTSETUP -q luksKillSlot $LOOPDEV 7 2>/dev/null && fail echo "invalid" | $CRYPTSETUP luksKillSlot $LOOPDEV 1 2>/dev/null && fail check