tools/llvm: Do not build with symbols
[minix3.git] / tests / sbin / sysctl / t_perm.sh
blob6acfd1935b8daa469bc79fbf7504847d3fce177b
1 # $NetBSD: t_perm.sh,v 1.6 2012/03/18 09:46:50 jruoho Exp $
3 # Copyright (c) 2011 The NetBSD Foundation, Inc.
4 # All rights reserved.
6 # This code is derived from software contributed to The NetBSD Foundation
7 # by Jukka Ruohonen.
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions
11 # are met:
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"
32 clean() {
34 if [ -f $file ]; then
35 rm $file
39 sysctl_write() {
41 deadbeef="3735928559"
43 sysctl $1 | cut -d= -f1 > $file
45 if [ ! -f $file ]; then
46 atf_fail "sysctl failed"
49 while read line; do
51 node=$(echo $line)
53 case $node in
55 "$1."*)
56 atf_check -s not-exit:0 -e ignore \
57 -x sysctl -w $node=$deadbeef
59 esac
61 done < $file
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"
71 # ddb.
73 atf_test_case sysctl_ddb cleanup
74 sysctl_ddb_head() {
75 atf_set "require.user" "unprivileged"
76 atf_set "descr" "Test writing to 'ddb' sysctl node as an user"
79 sysctl_ddb_body() {
80 sysctl_write "ddb"
83 sysctl_ddb_cleanup() {
84 clean
87 # hw.
89 atf_test_case sysctl_hw cleanup
90 sysctl_hw_head() {
91 atf_set "require.user" "unprivileged"
92 atf_set "descr" "Test writing to 'hw' sysctl node as an user"
95 sysctl_hw_body() {
96 sysctl_write "hw"
99 sysctl_hw_cleanup() {
100 clean
103 # kern.
105 atf_test_case sysctl_kern cleanup
106 sysctl_kern_head() {
107 atf_set "require.user" "unprivileged"
108 atf_set "descr" "Test writing to 'kern' " \
109 "sysctl node as an user (PR kern/44946)"
112 sysctl_kern_body() {
113 sysctl_write "kern"
116 sysctl_kern_cleanup() {
117 clean
120 # machdep.
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() {
133 clean
136 # net.
138 atf_test_case sysctl_net cleanup
139 sysctl_net_head() {
140 atf_set "require.user" "unprivileged"
141 atf_set "descr" "Test writing to 'net' sysctl node as an user"
144 sysctl_net_body() {
145 sysctl_write "net"
148 sysctl_net_cleanup() {
149 clean
152 # security.
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() {
165 clean
168 # vfs.
170 atf_test_case sysctl_vfs cleanup
171 sysctl_vfs_head() {
172 atf_set "require.user" "unprivileged"
173 atf_set "descr" "Test writing to 'vfs' sysctl node as an user"
176 sysctl_vfs_body() {
177 sysctl_write "vfs"
180 sysctl_vfs_cleanup() {
181 clean
184 # vm.
186 atf_test_case sysctl_vm cleanup
187 sysctl_vm_head() {
188 atf_set "require.user" "unprivileged"
189 atf_set "descr" "Test writing to 'vm' sysctl node as an user"
192 sysctl_vm_body() {
193 sysctl_write "vm"
196 sysctl_vm_cleanup() {
197 clean
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