[BACK]Return to t_perm.sh CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / tests / sbin / sysctl

Annotation of src/tests/sbin/sysctl/t_perm.sh, Revision 1.1

1.1     ! jruoho      1: #! /usr/bin/atf-sh
        !             2: #
        !             3: # $NetBSD$
        !             4: #
        !             5: # Copyright (c) 2011 The NetBSD Foundation, Inc.
        !             6: # All rights reserved.
        !             7: #
        !             8: # This code is derived from software contributed to The NetBSD Foundation
        !             9: # by Jukka Ruohonen.
        !            10: #
        !            11: # Redistribution and use in source and binary forms, with or without
        !            12: # modification, are permitted provided that the following conditions
        !            13: # are met:
        !            14: # 1. Redistributions of source code must retain the above copyright
        !            15: #    notice, this list of conditions and the following disclaimer.
        !            16: # 2. Redistributions in binary form must reproduce the above copyright
        !            17: #    notice, this list of conditions and the following disclaimer in the
        !            18: #    documentation and/or other materials provided with the distribution.
        !            19: #
        !            20: # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
        !            21: # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
        !            22: # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
        !            23: # PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
        !            24: # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
        !            25: # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
        !            26: # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
        !            27: # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
        !            28: # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
        !            29: # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
        !            30: # POSSIBILITY OF SUCH DAMAGE.
        !            31: #
        !            32: clean() {
        !            33:
        !            34:        if [ -f /tmp/d_sysctl.out ]; then
        !            35:                rm /tmp/d_sysctl.out
        !            36:        fi
        !            37: }
        !            38:
        !            39: sysctl_write() {
        !            40:
        !            41:
        !            42:        deadbeef="3735928559"
        !            43:        file="/tmp/d_sysctl.out"
        !            44:
        !            45:        sysctl "$1" | cut -d= -f1 > $file
        !            46:
        !            47:        if [ ! -f $file ]; then
        !            48:                atf_fail "sysctl -a failed"
        !            49:        fi
        !            50:
        !            51:        # This should probably include a functional verification
        !            52:        # that $deadbeef was not actually written to the node...
        !            53:        #
        !            54:        while read line; do
        !            55:
        !            56:                node="$(echo $line)"
        !            57:
        !            58:                case "$node" in
        !            59:
        !            60:                "$1."*)
        !            61:                        atf_check -s not-exit:0 -e ignore \
        !            62:                                -x sysctl -w "$node=$deadbeef"
        !            63:                        ;;
        !            64:                esac
        !            65:
        !            66:        done < $file
        !            67: }
        !            68:
        !            69: # ddb.
        !            70: #
        !            71: atf_test_case sysctl_ddb cleanup
        !            72: sysctl_ddb_head() {
        !            73:        atf_set "require.user" "unprivileged"
        !            74:        atf_set "descr" "Test writing to 'ddb' sysctl node as an user"
        !            75: }
        !            76:
        !            77: sysctl_ddb_body() {
        !            78:        sysctl_write "ddb"
        !            79: }
        !            80:
        !            81: sysctl_ddb_cleanup() {
        !            82:        clean
        !            83: }
        !            84:
        !            85: # hw.
        !            86: #
        !            87: atf_test_case sysctl_hw cleanup
        !            88: sysctl_hw_head() {
        !            89:        atf_set "require.user" "unprivileged"
        !            90:        atf_set "descr" "Test writing to 'hw' sysctl node as an user"
        !            91: }
        !            92:
        !            93: sysctl_hw_body() {
        !            94:        sysctl_write "hw"
        !            95: }
        !            96:
        !            97: sysctl_hw_cleanup() {
        !            98:        clean
        !            99: }
        !           100:
        !           101: # kern.
        !           102: #
        !           103: atf_test_case sysctl_kern #cleanup
        !           104: sysctl_kern_head() {
        !           105:        atf_set "require.user" "unprivileged"
        !           106:        atf_set "descr" "Test writing to 'kern' sysctl node as an user"
        !           107: }
        !           108:
        !           109: sysctl_kern_body() {
        !           110:        atf_expect_fail "PR kern/44946"
        !           111:        sysctl_write "kern"
        !           112: }
        !           113:
        !           114: sysctl_kern_cleanup() {
        !           115:        clean
        !           116: }
        !           117:
        !           118: # machdep.
        !           119: #
        !           120: atf_test_case sysctl_machdep cleanup
        !           121: sysctl_machdep_head() {
        !           122:        atf_set "require.user" "unprivileged"
        !           123:        atf_set "descr" "Test writing to 'machdep' sysctl node as an user"
        !           124: }
        !           125:
        !           126: sysctl_machdep_body() {
        !           127:        sysctl_write "machdep"
        !           128: }
        !           129:
        !           130: sysctl_machdep_cleanup() {
        !           131:        clean
        !           132: }
        !           133:
        !           134: # net.
        !           135: #
        !           136: atf_test_case sysctl_net cleanup
        !           137: sysctl_net_head() {
        !           138:        atf_set "require.user" "unprivileged"
        !           139:        atf_set "descr" "Test writing to 'net' sysctl node as an user"
        !           140: }
        !           141:
        !           142: sysctl_net_body() {
        !           143:        sysctl_write "net"
        !           144: }
        !           145:
        !           146: sysctl_net_cleanup() {
        !           147:        clean
        !           148: }
        !           149:
        !           150: # security.
        !           151: #
        !           152: atf_test_case sysctl_security cleanup
        !           153: sysctl_security_head() {
        !           154:        atf_set "require.user" "unprivileged"
        !           155:        atf_set "descr" "Test writing to 'security' sysctl node as an user"
        !           156: }
        !           157:
        !           158: sysctl_security_body() {
        !           159:        sysctl_write "security"
        !           160: }
        !           161:
        !           162: sysctl_security_cleanup() {
        !           163:        clean
        !           164: }
        !           165:
        !           166: # vfs.
        !           167: #
        !           168: atf_test_case sysctl_vfs cleanup
        !           169: sysctl_vfs_head() {
        !           170:        atf_set "require.user" "unprivileged"
        !           171:        atf_set "descr" "Test writing to 'vfs' sysctl node as an user"
        !           172: }
        !           173:
        !           174: sysctl_vfs_body() {
        !           175:        sysctl_write "vfs"
        !           176: }
        !           177:
        !           178: sysctl_vfs_cleanup() {
        !           179:        clean
        !           180: }
        !           181:
        !           182: # vm.
        !           183: #
        !           184: atf_test_case sysctl_vm cleanup
        !           185: sysctl_vm_head() {
        !           186:        atf_set "require.user" "unprivileged"
        !           187:        atf_set "descr" "Test writing to 'vm' sysctl node as an user"
        !           188: }
        !           189:
        !           190: sysctl_vm_body() {
        !           191:        sysctl_write "vm"
        !           192: }
        !           193:
        !           194: sysctl_vm_cleanup() {
        !           195:        clean
        !           196: }
        !           197:
        !           198: atf_init_test_cases() {
        !           199:        atf_add_test_case sysctl_ddb
        !           200:        atf_add_test_case sysctl_hw
        !           201:        atf_add_test_case sysctl_kern
        !           202:        atf_add_test_case sysctl_machdep
        !           203:        atf_add_test_case sysctl_net
        !           204:        atf_add_test_case sysctl_security
        !           205:        atf_add_test_case sysctl_vfs
        !           206:        atf_add_test_case sysctl_vm
        !           207: }

CVSweb <webmaster@jp.NetBSD.org>