1# $FreeBSD$ 2 3. $(atf_get_srcdir)/conf.sh 4 5atf_test_case kill cleanup 6kill_head() 7{ 8 atf_set "descr" "geli kill will wipe a provider's metadata" 9 atf_set "require.user" "root" 10} 11kill_body() 12{ 13 geli_test_setup 14 15 sectors=100 16 md=$(attach_md -t malloc -s `expr $sectors + 1`) 17 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 20 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} 24 25 # Kill attached provider. 26 atf_check geli kill ${md} 27 sleep 1 28 # Provider should be automatically detached. 29 if [ -c /dev/${md}.eli ]; then 30 atf_fail "Provider did not detach when killed" 31 fi 32 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} 36 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} 40 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} 44 45 # Should be possible to attach with keyfile1. 46 atf_check geli attach -p -k keyfile1 ${md} 47 atf_check geli detach ${md} 48 49 # Should be possible to attach with keyfile2. 50 atf_check geli attach -p -k keyfile2 ${md} 51 atf_check geli detach ${md} 52 53 # Kill detached provider. 54 atf_check geli kill ${md} 55 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} 59 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} 63} 64kill_cleanup() 65{ 66 geli_test_cleanup 67} 68 69atf_test_case kill_readonly cleanup 70kill_readonly_head() 71{ 72 atf_set "descr" "geli kill will not destroy the keys of a readonly provider" 73 atf_set "require.user" "root" 74} 75kill_readonly_body() 76{ 77 geli_test_setup 78 79 sectors=100 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 82 83 atf_check geli init -B none -P -K keyfile ${md} 84 # Attach read-only 85 atf_check geli attach -r -p -k keyfile ${md} 86 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} 92} 93kill_readonly_cleanup() 94{ 95 geli_test_cleanup 96} 97 98atf_init_test_cases() 99{ 100 atf_add_test_case kill 101 atf_add_test_case kill_readonly 102} 103