1 # $NetBSD: t_perm.sh,v 1.7 2016/06/17 03:55:35 pgoyette 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"
42 deadbeef_signed="-559038737"
44 sysctl $1 | cut -d= -f1 > $file
46 if [ ! -f $file ]; then
47 atf_fail "sysctl failed"
57 atf_check -s not-exit:0 -e ignore \
58 -x sysctl -w $node=$deadbeef
64 # A functional verification that $deadbeef
65 # was not actually written to the node.
67 if [ ! -z $(sysctl $1 | grep -e $deadbeef -e $deadbeef_signed) ]; then
68 atf_fail "value was written"
74 atf_test_case sysctl_ddb cleanup
76 atf_set "require.user" "unprivileged"
77 atf_set "descr" "Test writing to 'ddb' sysctl node as an user"
84 sysctl_ddb_cleanup() {
90 atf_test_case sysctl_hw cleanup
92 atf_set "require.user" "unprivileged"
93 atf_set "descr" "Test writing to 'hw' sysctl node as an user"
100 sysctl_hw_cleanup() {
106 atf_test_case sysctl_kern cleanup
108 atf_set "require.user" "unprivileged"
109 atf_set "descr" "Test writing to 'kern' " \
110 "sysctl node as an user (PR kern/44946)"
117 sysctl_kern_cleanup() {
123 atf_test_case sysctl_machdep cleanup
124 sysctl_machdep_head() {
125 atf_set "require.user" "unprivileged"
126 atf_set "descr" "Test writing to 'machdep' sysctl node as an user"
129 sysctl_machdep_body() {
130 sysctl_write "machdep"
133 sysctl_machdep_cleanup() {
139 atf_test_case sysctl_net cleanup
141 atf_set "require.user" "unprivileged"
142 atf_set "descr" "Test writing to 'net' sysctl node as an user"
149 sysctl_net_cleanup() {
155 atf_test_case sysctl_security cleanup
156 sysctl_security_head() {
157 atf_set "require.user" "unprivileged"
158 atf_set "descr" "Test writing to 'security' sysctl node as an user"
161 sysctl_security_body() {
162 sysctl_write "security"
165 sysctl_security_cleanup() {
171 atf_test_case sysctl_vfs cleanup
173 atf_set "require.user" "unprivileged"
174 atf_set "descr" "Test writing to 'vfs' sysctl node as an user"
181 sysctl_vfs_cleanup() {
187 atf_test_case sysctl_vm cleanup
189 atf_set "require.user" "unprivileged"
190 atf_set "descr" "Test writing to 'vm' sysctl node as an user"
197 sysctl_vm_cleanup() {
201 atf_init_test_cases() {
202 atf_add_test_case sysctl_ddb
203 atf_add_test_case sysctl_hw
204 atf_add_test_case sysctl_kern
205 atf_add_test_case sysctl_machdep
206 atf_add_test_case sysctl_net
207 atf_add_test_case sysctl_security
208 atf_add_test_case sysctl_vfs
209 atf_add_test_case sysctl_vm