Mercurial > illumos > illumos-gate
comparison usr/src/test/zfs-tests/tests/functional/acl/nontrivial/zfs_acl_chmod_inherit_001_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 2009 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 chmod have correct behaviour to directory and file when setting | |
33 # different inherit strategy to them. | |
34 # | |
35 # STRATEGY: | |
36 # 1. Loop super user and non-super user to run the test case. | |
37 # 2. Create basedir and a set of subdirectores and files within it. | |
38 # 3. Separately chmod basedir with different inherite options. | |
39 # 4. Then create nested directories and files like the following. | |
40 # | |
41 # _ odir4 | |
42 # |_ ofile4 | |
43 # _ odir3 _| | |
44 # |_ ofile3 | |
45 # _ odir1 _| | |
46 # |_ ofile2 | |
47 # basefile | | |
48 # chmod --> basedir -| | |
49 # |_ nfile1 | |
50 # |_ ndir1 _ | |
51 # |_ nfile2 | |
52 # |_ ndir2 _ | |
53 # |_ nfile3 | |
54 # |_ ndir3 | |
55 # | |
56 # 5. Verify each directories and files have the correct access control | |
57 # capability. | |
58 # | |
59 | |
60 verify_runnable "both" | |
61 | |
62 function cleanup | |
63 { | |
64 if [[ -f $basefile ]]; then | |
65 log_must $RM -f $basefile | |
66 fi | |
67 if [[ -d $basedir ]]; then | |
68 log_must $RM -rf $basedir | |
69 fi | |
70 } | |
71 | |
72 log_assert "Verify chmod have correct behaviour to directory and file when " \ | |
73 "setting different inherit strategies to them." | |
74 log_onexit cleanup | |
75 | |
76 # Define inherit flag | |
77 set -A object_flag file_inherit dir_inherit file_inherit/dir_inherit | |
78 set -A strategy_flag "" inherit_only no_propagate inherit_only/no_propagate | |
79 | |
80 # Defile the based directory and file | |
81 basedir=$TESTDIR/basedir; basefile=$TESTDIR/basefile | |
82 | |
83 # Define the existed files and directories before chmod | |
84 odir1=$basedir/odir1; odir2=$odir1/odir2; odir3=$odir2/odir3 | |
85 ofile1=$basedir/ofile1; ofile2=$odir1/ofile2; ofile3=$odir2/ofile3 | |
86 | |
87 # Define the files and directories will be created after chmod | |
88 ndir1=$basedir/ndir1; ndir2=$ndir1/ndir2; ndir3=$ndir2/ndir3 | |
89 nfile1=$basedir/nfile1; nfile2=$ndir1/nfile2; nfile3=$ndir2/nfile3 | |
90 | |
91 # Verify all the node have expected correct access control | |
92 allnodes="$basedir $ndir1 $ndir2 $ndir3 $nfile1 $nfile2 $nfile3" | |
93 allnodes="$allnodes $odir1 $odir2 $odir3 $ofile1 $ofile2 $ofile3" | |
94 | |
95 # | |
96 # According to inherited flag, verify subdirectories and files within it has | |
97 # correct inherited access control. | |
98 # | |
99 function verify_inherit #<object> [strategy] | |
100 { | |
101 # Define the nodes which will be affected by inherit. | |
102 typeset inherit_nodes | |
103 typeset obj=$1 | |
104 typeset str=$2 | |
105 | |
106 log_must usr_exec $MKDIR -p $ndir3 | |
107 log_must usr_exec $TOUCH $nfile1 $nfile2 $nfile3 | |
108 | |
109 # Except for inherit_only, the basedir was affected always. | |
110 if [[ $str != *"inherit_only"* ]]; then | |
111 inherit_nodes="$inherit_nodes $basedir" | |
112 fi | |
113 # Get the files which inherited ACE. | |
114 if [[ $obj == *"file_inherit"* ]]; then | |
115 inherit_nodes="$inherit_nodes $nfile1" | |
116 | |
117 if [[ $str != *"no_propagate"* ]]; then | |
118 inherit_nodes="$inherit_nodes $nfile2 $nfile3" | |
119 fi | |
120 fi | |
121 # Get the directores which inherited ACE. | |
122 if [[ $obj == *"dir_inherit"* ]]; then | |
123 inherit_nodes="$inherit_nodes $ndir1" | |
124 | |
125 if [[ $str != *"no_propagate"* ]]; then | |
126 inherit_nodes="$inherit_nodes $ndir2 $ndir3" | |
127 fi | |
128 fi | |
129 | |
130 for node in $allnodes; do | |
131 if [[ " $inherit_nodes " == *" $node "* ]]; then | |
132 log_mustnot chgusr_exec $ZFS_ACL_OTHER1 $LS -vd $node \ | |
133 > /dev/null 2>&1 | |
134 else | |
135 log_must chgusr_exec $ZFS_ACL_OTHER1 $LS -vd $node \ | |
136 > /dev/null 2>&1 | |
137 fi | |
138 done | |
139 } | |
140 | |
141 for user in root $ZFS_ACL_STAFF1; do | |
142 log_must set_cur_usr $user | |
143 | |
144 for obj in "${object_flag[@]}"; do | |
145 for str in "${strategy_flag[@]}"; do | |
146 typeset inh_opt=$obj | |
147 (( ${#str} != 0 )) && inh_opt=$inh_opt/$str | |
148 aclspec="A+user:$ZFS_ACL_OTHER1:read_acl:$inh_opt:deny" | |
149 | |
150 log_must usr_exec $MKDIR $basedir | |
151 log_must usr_exec $TOUCH $basefile | |
152 log_must usr_exec $MKDIR -p $odir3 | |
153 log_must usr_exec $TOUCH $ofile1 $ofile2 $ofile3 | |
154 | |
155 # | |
156 # Inherit flag can only be placed on a directory, | |
157 # otherwise it will fail. | |
158 # | |
159 log_must usr_exec $CHMOD $aclspec $basefile | |
160 | |
161 # | |
162 # Place on a directory should succeed. | |
163 # | |
164 log_must usr_exec $CHMOD $aclspec $basedir | |
165 | |
166 verify_inherit $obj $str | |
167 | |
168 log_must usr_exec $RM -rf $basefile $basedir | |
169 done | |
170 done | |
171 done | |
172 | |
173 log_pass "Verify chmod inherit behaviour passed." |