1 # $NetBSD: t_perm.sh,v 1.6 2012/03/18 09:46:50 jruoho Exp $
3 # Copyright (c) 2011 The NetBSD Foundation, Inc.
6 # This code is derived from software contributed to The NetBSD Foundation
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions
12 # 1. Redistributions of source code must retain the above copyright
13 # notice, this list of conditions and the following disclaimer.
14 # 2. Redistributions in binary form must reproduce the above copyright
15 # notice, this list of conditions and the following disclaimer in the
16 # documentation and/or other materials provided with the distribution.
18 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 # POSSIBILITY OF SUCH DAMAGE.
30 file="/tmp/d_sysctl.out"
43 sysctl
$1 | cut
-d= -f1 > $file
45 if [ ! -f $file ]; then
46 atf_fail
"sysctl failed"
56 atf_check
-s not-exit
:0 -e ignore \
57 -x sysctl
-w $node=$deadbeef
63 # A functional verification that $deadbeef
64 # was not actually written to the node.
66 if [ ! -z $
(sysctl
$1 |
grep $deadbeef) ]; then
67 atf_fail
"value was written"
73 atf_test_case sysctl_ddb cleanup
75 atf_set
"require.user" "unprivileged"
76 atf_set
"descr" "Test writing to 'ddb' sysctl node as an user"
83 sysctl_ddb_cleanup
() {
89 atf_test_case sysctl_hw cleanup
91 atf_set
"require.user" "unprivileged"
92 atf_set
"descr" "Test writing to 'hw' sysctl node as an user"
105 atf_test_case sysctl_kern cleanup
107 atf_set
"require.user" "unprivileged"
108 atf_set
"descr" "Test writing to 'kern' " \
109 "sysctl node as an user (PR kern/44946)"
116 sysctl_kern_cleanup
() {
122 atf_test_case sysctl_machdep cleanup
123 sysctl_machdep_head
() {
124 atf_set
"require.user" "unprivileged"
125 atf_set
"descr" "Test writing to 'machdep' sysctl node as an user"
128 sysctl_machdep_body
() {
129 sysctl_write
"machdep"
132 sysctl_machdep_cleanup
() {
138 atf_test_case sysctl_net cleanup
140 atf_set
"require.user" "unprivileged"
141 atf_set
"descr" "Test writing to 'net' sysctl node as an user"
148 sysctl_net_cleanup
() {
154 atf_test_case sysctl_security cleanup
155 sysctl_security_head
() {
156 atf_set
"require.user" "unprivileged"
157 atf_set
"descr" "Test writing to 'security' sysctl node as an user"
160 sysctl_security_body
() {
161 sysctl_write
"security"
164 sysctl_security_cleanup
() {
170 atf_test_case sysctl_vfs cleanup
172 atf_set
"require.user" "unprivileged"
173 atf_set
"descr" "Test writing to 'vfs' sysctl node as an user"
180 sysctl_vfs_cleanup
() {
186 atf_test_case sysctl_vm cleanup
188 atf_set
"require.user" "unprivileged"
189 atf_set
"descr" "Test writing to 'vm' sysctl node as an user"
196 sysctl_vm_cleanup
() {
200 atf_init_test_cases
() {
201 atf_add_test_case sysctl_ddb
202 atf_add_test_case sysctl_hw
203 atf_add_test_case sysctl_kern
204 atf_add_test_case sysctl_machdep
205 atf_add_test_case sysctl_net
206 atf_add_test_case sysctl_security
207 atf_add_test_case sysctl_vfs
208 atf_add_test_case sysctl_vm