aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOndrej Kozina <okozina@redhat.com>2023-12-04 11:15:03 +0100
committerMilan Broz <gmazyland@gmail.com>2023-12-13 20:59:14 +0000
commit31027b924002ef90c2713e3bf14f80c77b4b0c7a (patch)
tree9beb3bf7659f998d74d05eb70b3871ba4f76d02e
parent1d0680ce95fe44b9382820f2fbb0eec6d4fe1109 (diff)
downloadcryptsetup-31027b924002ef90c2713e3bf14f80c77b4b0c7a.tar.gz
test: check if device remains usable after failed attempt to double activation.
-rwxr-xr-xtests/compat-test-opal6
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/compat-test-opal b/tests/compat-test-opal
index 70f503a1..3d5c07c6 100755
--- a/tests/compat-test-opal
+++ b/tests/compat-test-opal
@@ -448,6 +448,7 @@ prepare "[6] add key" wipe
echo -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q $FAST_PBKDF_OPT luksFormat --type luks2 --hw-opal $OPAL2_DEV || fail
echo -e "$PWD1\n$PWD2" | $CRYPTSETUP luksAddKey $OPAL2_DEV $FAST_PBKDF_OPT || fail
echo $PWD2 | $CRYPTSETUP luksOpen $OPAL2_DEV $DEV_NAME || fail
+$CRYPTSETUP close $DEV_NAME || fail
# Unsuccessful Key Delete - nothing may change
prepare "[7] unsuccessful delete" new
@@ -461,11 +462,13 @@ $CRYPTSETUP -q luksKillSlot $OPAL2_DEV 1 || fail
echo $PWD2 | $CRYPTSETUP luksOpen $OPAL2_DEV $DEV_NAME 2> /dev/null && fail
[ $? -ne 2 ] && fail "luksOpen should return EPERM exit code"
echo $PWD1 | $CRYPTSETUP luksOpen $OPAL2_DEV $DEV_NAME || fail
+$CRYPTSETUP close $DEV_NAME || fail
# Key Slot 1 and key material section 1 must change, the rest must not
prepare "[9] add key test for key files" new
echo $PWD1 | $CRYPTSETUP luksAddKey $FAST_PBKDF_OPT $OPAL2_DEV $KEY1 || fail
$CRYPTSETUP -d $KEY1 luksOpen $OPAL2_DEV $DEV_NAME || fail
+$CRYPTSETUP close $DEV_NAME || fail
# Key Slot 1 and key material section 1 must change, the rest must not
prepare "[10] delete key test with key1 as remaining key" new
@@ -631,7 +634,8 @@ echo -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --
$CRYPTSETUP remove $DEV_NAME || fail
echo -e "$PWD1\n$OPAL2_ADMIN_PIN" | $CRYPTSETUP -q luksFormat $FAST_PBKDF_OPT --type luks2 --hw-opal $OPAL2_DEV || fail
echo $PWD1 | $CRYPTSETUP luksOpen $OPAL2_DEV $DEV_NAME || fail
-echo $PWD1 | $CRYPTSETUP luksOpen $OPAL2_DEV $DEV_NAME2 2>/dev/null && fail
+echo $PWD1 | $CRYPTSETUP luksOpen -q $OPAL2_DEV $DEV_NAME2 >/dev/null 2>&1 && fail
+dd if=$OPAL2_DEV of=/dev/zero bs=1M skip=16 count=1 iflag=direct >/dev/null 2>&1 || fail "OPAL segment perhaps locked after failed activation over already active device."
$CRYPTSETUP luksClose $DEV_NAME || fail
prepare "[19] luksDump" wipe