3 . $(atf_get_srcdir)/conf.sh
5 atf_test_case kill cleanup
8 atf_set "descr" "geli kill will wipe a provider's metadata"
9 atf_set "require.user" "root"
16 md=$(attach_md -t malloc -s `expr $sectors + 1`)
18 atf_check dd if=/dev/random of=keyfile1 bs=512 count=16 status=none
19 atf_check dd if=/dev/random of=keyfile2 bs=512 count=16 status=none
21 atf_check geli init -B none -P -K keyfile1 ${md}
22 atf_check geli attach -p -k keyfile1 ${md}
23 atf_check -s exit:0 -o ignore geli setkey -n 1 -P -K keyfile2 ${md}
25 # Kill attached provider.
26 atf_check geli kill ${md}
28 # Provider should be automatically detached.
29 if [ -c /dev/${md}.eli ]; then
30 atf_fail "Provider did not detach when killed"
33 # We cannot use keyfile1 anymore.
34 atf_check -s not-exit:0 -e match:"Cannot read metadata" \
35 geli attach -p -k keyfile1 ${md}
37 # We cannot use keyfile2 anymore.
38 atf_check -s not-exit:0 -e match:"Cannot read metadata" \
39 geli attach -p -k keyfile2 ${md}
41 atf_check geli init -B none -P -K keyfile1 ${md}
42 atf_check -s exit:0 -o ignore \
43 geli setkey -n 1 -p -k keyfile1 -P -K keyfile2 ${md}
45 # Should be possible to attach with keyfile1.
46 atf_check geli attach -p -k keyfile1 ${md}
47 atf_check geli detach ${md}
49 # Should be possible to attach with keyfile2.
50 atf_check geli attach -p -k keyfile2 ${md}
51 atf_check geli detach ${md}
53 # Kill detached provider.
54 atf_check geli kill ${md}
56 # We cannot use keyfile1 anymore.
57 atf_check -s not-exit:0 -e match:"Cannot read metadata" \
58 geli attach -p -k keyfile1 ${md}
60 # We cannot use keyfile2 anymore.
61 atf_check -s not-exit:0 -e match:"Cannot read metadata" \
62 geli attach -p -k keyfile2 ${md}
69 atf_test_case kill_readonly cleanup
72 atf_set "descr" "geli kill will not destroy the keys of a readonly provider"
73 atf_set "require.user" "root"
80 md=$(attach_md -t malloc -s `expr $sectors + 1`)
81 atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none
83 atf_check geli init -B none -P -K keyfile ${md}
85 atf_check geli attach -r -p -k keyfile ${md}
87 atf_check geli kill ${md}
88 # The provider will be detached
89 atf_check [ ! -c /dev/${md}.eli ]
90 # But its keys should not be destroyed
91 atf_check geli attach -p -k keyfile ${md}
93 kill_readonly_cleanup()
100 atf_add_test_case kill
101 atf_add_test_case kill_readonly