comparison usr/src/test/zfs-tests/tests/functional/acl/nontrivial/zfs_acl_chmod_rwx_003_pos.ksh @ 13899:0bcf78798346

3311 Want a test framework for arbitrary OS unit tests 3312 Add a testrunner package for OS unit tests 3313 Add a testrunner package to convert ZFS tests from STF Reviewed by: Matt Ahrens <matthew.ahrens@delphix.com> Reviewed by: Will Guyette <will.guyette@delphix.com> Reviewed by: Dan Kimmel <dan.kimmel@delphix.com> Reviewed by: Adam Leventhal <ahl@delphix.com> Reviewed by: Henrik Mattson <henrik.mattson@delphix.com> Reviewed by: Sonu Pillai <sonu.pillai@delphix.com> Reviewed by: Christopher Siden <chris.siden@delphix.com> Reviewed by: George Wilson <george.wilson@delphix.com> Reviewed by: Richard Lowe <richlowe@richlowe.net> Approved by: Richard Lowe <richlowe@richlowe.net>
author John Wren Kennedy <john.kennedy@delphix.com>
date Wed, 05 Dec 2012 22:04:50 -0500
parents
children
comparison
equal deleted inserted replaced
13898:7f822b09519b 13899:0bcf78798346
1 #!/bin/ksh -p
2 #
3 # CDDL HEADER START
4 #
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
8 #
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
13 #
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 #
20 # CDDL HEADER END
21 #
22
23 #
24 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
26 #
27
28 . $STF_SUITE/tests/functional/acl/acl_common.kshlib
29
30 #
31 # DESCRIPTION:
32 # Verify that the read_data/write_data/execute permission for
33 # owner/group/everyone are correct.
34 #
35 # STRATEGY:
36 # 1. Loop root and non-root user.
37 # 2. Separated verify type@:access:allow|deny to file and directory
38 # 3. To super user, read and write deny was override.
39 # 4. According to ACE list and override rule, expect that
40 # read/write/execute file or directory succeed or fail.
41 #
42
43 verify_runnable "both"
44
45 # owner@ group_users other_users
46 set -A users \
47 "root" "$ZFS_ACL_ADMIN" "$ZFS_ACL_OTHER1" \
48 "$ZFS_ACL_STAFF1" "$ZFS_ACL_STAFF2" "$ZFS_ACL_OTHER1"
49
50 # In order to test execute permission, read_data was need firstly.
51 set -A a_access "read_data" "write_data" "read_data/execute"
52 set -A a_flag "owner@" "group@" "everyone@"
53
54 log_assert "Verify that the read_data/write_data/execute permission for" \
55 "owner/group/everyone are correct."
56 log_onexit cleanup
57
58 function logname #node acl_spec user
59 {
60 typeset node=$1
61 typeset acl_spec=$2
62 typeset user=$3
63
64 # To super user, read and write deny permission was override.
65 if [[ $acl_spec == *:allow ]] || \
66 [[ $user == root && -d $node ]] || \
67 [[ $user == root && $acl_spec != *"execute"* ]]
68 then
69 print "log_must"
70 elif [[ $acl_spec == *:deny ]]; then
71 print "log_mustnot"
72 fi
73 }
74
75 function check_chmod_results #node acl_spec g_usr o_usr
76 {
77 typeset node=$1
78 typeset acl_spec=$2
79 typeset g_usr=$3
80 typeset o_usr=$4
81 typeset log
82
83 if [[ $acl_spec == "owner@:"* || $acl_spec == "everyone@:"* ]]; then
84 log=$(logname $node $acl_spec $ZFS_ACL_CUR_USER)
85 $log rwx_node $ZFS_ACL_CUR_USER $node $acl_spec
86 fi
87 if [[ $acl_spec == "group@:"* || $acl_spec == "everyone@:"* ]]; then
88 log=$(logname $node $acl_spec $g_usr)
89 $log rwx_node $g_usr $node $acl_spec
90 fi
91 if [[ $acl_spec == "everyone@"* ]]; then
92 log=$(logname $node $acl_spec $o_usr)
93 $log rwx_node $o_usr $node $acl_spec
94 fi
95 }
96
97 function test_chmod_basic_access #node group_user other_user
98 {
99 typeset node=$1
100 typeset g_usr=$2
101 typeset o_usr=$3
102 typeset flag access acl_spec
103
104 for flag in ${a_flag[@]}; do
105 for access in ${a_access[@]}; do
106 for tp in allow deny; do
107 acl_spec="$flag:$access:$tp"
108 log_must usr_exec $CHMOD A+$acl_spec $node
109 check_chmod_results \
110 $node $acl_spec $g_usr $o_usr
111 log_must usr_exec $CHMOD A0- $node
112 done
113 done
114 done
115 }
116
117 typeset -i i=0
118 while (( i < ${#users[@]} )); do
119 log_must set_cur_usr ${users[i]}
120
121 log_must usr_exec $TOUCH $testfile
122 test_chmod_basic_access $testfile ${users[((i+1))]} ${users[((i+2))]}
123 log_must usr_exec $MKDIR $testdir
124 test_chmod_basic_access $testdir ${users[((i+1))]} ${users[((i+2))]}
125
126 log_must usr_exec $RM -rf $testfile $testdir
127
128 (( i += 3 ))
129 done
130
131 log_pass "Verify that the read_data/write_data/execute permission for" \
132 "owner/group/everyone passed."