Path: blob/main/tests/sys/geom/class/eli/kill_test.sh
39635 views
1. $(atf_get_srcdir)/conf.sh23atf_test_case kill cleanup4kill_head()5{6atf_set "descr" "geli kill will wipe a provider's metadata"7atf_set "require.user" "root"8}9kill_body()10{11geli_test_setup1213sectors=10014attach_md md -t malloc -s `expr $sectors + 1`1516atf_check dd if=/dev/random of=keyfile1 bs=512 count=16 status=none17atf_check dd if=/dev/random of=keyfile2 bs=512 count=16 status=none1819atf_check geli init -B none -P -K keyfile1 ${md}20atf_check geli attach -p -k keyfile1 ${md}21atf_check -s exit:0 -o ignore geli setkey -n 1 -P -K keyfile2 ${md}2223# Kill attached provider.24atf_check geli kill ${md}25sleep 126# Provider should be automatically detached.27if [ -c /dev/${md}.eli ]; then28atf_fail "Provider did not detach when killed"29fi3031# We cannot use keyfile1 anymore.32atf_check -s not-exit:0 -e match:"Cannot read metadata" \33geli attach -p -k keyfile1 ${md}3435# We cannot use keyfile2 anymore.36atf_check -s not-exit:0 -e match:"Cannot read metadata" \37geli attach -p -k keyfile2 ${md}3839atf_check geli init -B none -P -K keyfile1 ${md}40atf_check -s exit:0 -o ignore \41geli setkey -n 1 -p -k keyfile1 -P -K keyfile2 ${md}4243# Should be possible to attach with keyfile1.44atf_check geli attach -p -k keyfile1 ${md}45atf_check geli detach ${md}4647# Should be possible to attach with keyfile2.48atf_check geli attach -p -k keyfile2 ${md}49atf_check geli detach ${md}5051# Kill detached provider.52atf_check geli kill ${md}5354# We cannot use keyfile1 anymore.55atf_check -s not-exit:0 -e match:"Cannot read metadata" \56geli attach -p -k keyfile1 ${md}5758# We cannot use keyfile2 anymore.59atf_check -s not-exit:0 -e match:"Cannot read metadata" \60geli attach -p -k keyfile2 ${md}61}62kill_cleanup()63{64geli_test_cleanup65}6667atf_test_case kill_readonly cleanup68kill_readonly_head()69{70atf_set "descr" "geli kill will not destroy the keys of a readonly provider"71atf_set "require.user" "root"72}73kill_readonly_body()74{75geli_test_setup7677sectors=10078attach_md md -t malloc -s `expr $sectors + 1`79atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none8081atf_check geli init -B none -P -K keyfile ${md}82# Attach read-only83atf_check geli attach -r -p -k keyfile ${md}8485atf_check geli kill ${md}86# The provider will be detached87atf_check [ ! -c /dev/${md}.eli ]88# But its keys should not be destroyed89atf_check geli attach -p -k keyfile ${md}90}91kill_readonly_cleanup()92{93geli_test_cleanup94}9596atf_init_test_cases()97{98atf_add_test_case kill99atf_add_test_case kill_readonly100}101102103