3 atf_test_case kill cleanup
6 atf_set "descr" "geli kill will wipe a provider's metadata"
7 atf_set "require.user" "root"
11 . $(atf_get_srcdir)/conf.sh
14 md=$(attach_md -t malloc -s `expr $sectors + 1`)
16 atf_check dd if=/dev/random of=keyfile1 bs=512 count=16 status=none
17 atf_check dd if=/dev/random of=keyfile2 bs=512 count=16 status=none
19 atf_check geli init -B none -P -K keyfile1 ${md}
20 atf_check geli attach -p -k keyfile1 ${md}
21 atf_check -s exit:0 -o ignore geli setkey -n 1 -P -K keyfile2 ${md}
23 # Kill attached provider.
24 atf_check geli kill ${md}
26 # Provider should be automatically detached.
27 if [ -c /dev/${md}.eli ]; then
28 atf_fail "Provider did not detach when killed"
31 # We cannot use keyfile1 anymore.
32 atf_check -s not-exit:0 -e match:"Cannot read metadata" \
33 geli attach -p -k keyfile1 ${md}
35 # We cannot use keyfile2 anymore.
36 atf_check -s not-exit:0 -e match:"Cannot read metadata" \
37 geli attach -p -k keyfile2 ${md}
39 atf_check geli init -B none -P -K keyfile1 ${md}
40 atf_check -s exit:0 -o ignore \
41 geli setkey -n 1 -p -k keyfile1 -P -K keyfile2 ${md}
43 # Should be possible to attach with keyfile1.
44 atf_check geli attach -p -k keyfile1 ${md}
45 atf_check geli detach ${md}
47 # Should be possible to attach with keyfile2.
48 atf_check geli attach -p -k keyfile2 ${md}
49 atf_check geli detach ${md}
51 # Kill detached provider.
52 atf_check geli kill ${md}
54 # We cannot use keyfile1 anymore.
55 atf_check -s not-exit:0 -e match:"Cannot read metadata" \
56 geli attach -p -k keyfile1 ${md}
58 # We cannot use keyfile2 anymore.
59 atf_check -s not-exit:0 -e match:"Cannot read metadata" \
60 geli attach -p -k keyfile2 ${md}
64 . $(atf_get_srcdir)/conf.sh
68 atf_test_case kill_readonly cleanup
71 atf_set "descr" "geli kill will not destroy the keys of a readonly provider"
72 atf_set "require.user" "root"
76 . $(atf_get_srcdir)/conf.sh
79 md=$(attach_md -t malloc -s `expr $sectors + 1`)
80 atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none
82 atf_check geli init -B none -P -K keyfile ${md}
84 atf_check geli attach -r -p -k keyfile ${md}
86 atf_check geli kill ${md}
87 # The provider will be detached
88 atf_check [ ! -c /dev/${md}.eli ]
89 # But its keys should not be destroyed
90 atf_check geli attach -p -k keyfile ${md}
92 kill_readonly_cleanup()
94 . $(atf_get_srcdir)/conf.sh
100 atf_add_test_case kill
101 atf_add_test_case kill_readonly