1 2. $(atf_get_srcdir)/conf.sh 3 4atf_test_case kill cleanup 5kill_head() 6{ 7 atf_set "descr" "geli kill will wipe a provider's metadata" 8 atf_set "require.user" "root" 9} 10kill_body() 11{ 12 geli_test_setup 13 14 sectors=100 15 attach_md md -t malloc -s `expr $sectors + 1` 16 17 atf_check dd if=/dev/random of=keyfile1 bs=512 count=16 status=none 18 atf_check dd if=/dev/random of=keyfile2 bs=512 count=16 status=none 19 20 atf_check geli init -B none -P -K keyfile1 ${md} 21 atf_check geli attach -p -k keyfile1 ${md} 22 atf_check -s exit:0 -o ignore geli setkey -n 1 -P -K keyfile2 ${md} 23 24 # Kill attached provider. 25 atf_check geli kill ${md} 26 sleep 1 27 # Provider should be automatically detached. 28 if [ -c /dev/${md}.eli ]; then 29 atf_fail "Provider did not detach when killed" 30 fi 31 32 # We cannot use keyfile1 anymore. 33 atf_check -s not-exit:0 -e match:"Cannot read metadata" \ 34 geli attach -p -k keyfile1 ${md} 35 36 # We cannot use keyfile2 anymore. 37 atf_check -s not-exit:0 -e match:"Cannot read metadata" \ 38 geli attach -p -k keyfile2 ${md} 39 40 atf_check geli init -B none -P -K keyfile1 ${md} 41 atf_check -s exit:0 -o ignore \ 42 geli setkey -n 1 -p -k keyfile1 -P -K keyfile2 ${md} 43 44 # Should be possible to attach with keyfile1. 45 atf_check geli attach -p -k keyfile1 ${md} 46 atf_check geli detach ${md} 47 48 # Should be possible to attach with keyfile2. 49 atf_check geli attach -p -k keyfile2 ${md} 50 atf_check geli detach ${md} 51 52 # Kill detached provider. 53 atf_check geli kill ${md} 54 55 # We cannot use keyfile1 anymore. 56 atf_check -s not-exit:0 -e match:"Cannot read metadata" \ 57 geli attach -p -k keyfile1 ${md} 58 59 # We cannot use keyfile2 anymore. 60 atf_check -s not-exit:0 -e match:"Cannot read metadata" \ 61 geli attach -p -k keyfile2 ${md} 62} 63kill_cleanup() 64{ 65 geli_test_cleanup 66} 67 68atf_test_case kill_readonly cleanup 69kill_readonly_head() 70{ 71 atf_set "descr" "geli kill will not destroy the keys of a readonly provider" 72 atf_set "require.user" "root" 73} 74kill_readonly_body() 75{ 76 geli_test_setup 77 78 sectors=100 79 attach_md md -t malloc -s `expr $sectors + 1` 80 atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none 81 82 atf_check geli init -B none -P -K keyfile ${md} 83 # Attach read-only 84 atf_check geli attach -r -p -k keyfile ${md} 85 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} 91} 92kill_readonly_cleanup() 93{ 94 geli_test_cleanup 95} 96 97atf_init_test_cases() 98{ 99 atf_add_test_case kill 100 atf_add_test_case kill_readonly 101} 102