3 atf_test_case attach_d cleanup
6 atf_set "descr" "geli attach -d will cause the provider to detach on last close"
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=keyfile bs=512 count=16 status=none
18 atf_check geli init -B none -P -K keyfile ${md}
19 atf_check geli attach -d -p -k keyfile ${md}
21 # Be sure it doesn't detach on read.
22 atf_check dd if=/dev/${md}.eli of=/dev/null status=none
24 if [ ! -c /dev/${md}.eli ]; then
25 atf_fail "Detached on last close of a reader"
28 # It should detach on last close of a writer
31 if [ -c /dev/${md}.eli ]; then
32 atf_fail "Did not detach on last close of a writer"
38 . $(atf_get_srcdir)/conf.sh
42 atf_test_case attach_r cleanup
45 atf_set "descr" "geli attach -r will create a readonly provider"
46 atf_set "require.user" "root"
50 . $(atf_get_srcdir)/conf.sh
53 md=$(attach_md -t malloc -s `expr $sectors + 1`)
54 atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none
56 atf_check geli init -B none -P -K keyfile ${md}
57 atf_check geli attach -r -p -k keyfile ${md}
59 atf_check -o match:"^Flags: .*READ-ONLY" geli list ${md}.eli
61 # Verify that writes are verbotten
62 atf_check -s not-exit:0 -e match:"Read-only" \
63 dd if=/dev/zero of=/dev/${md}.eli count=1
67 . $(atf_get_srcdir)/conf.sh
71 atf_test_case nokey cleanup
74 atf_set "descr" "geli attach fails if called with no key component"
75 atf_set "require.user" "root"
79 . $(atf_get_srcdir)/conf.sh
82 md=$(attach_md -t malloc -s `expr $sectors + 1`)
83 atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none
85 atf_check geli init -B none -P -K keyfile ${md}
86 atf_check -s not-exit:0 -e match:"No key components given" \
87 geli attach -p ${md} 2>/dev/null
91 . $(atf_get_srcdir)/conf.sh
97 atf_add_test_case attach_d
98 atf_add_test_case attach_r
99 atf_add_test_case nokey