Switch to dbench3 for benchmark runs, with xattr support enabled.
[xfstests-dev.git] / 093
1 #! /bin/sh
2 # FS QA Test No. 093
3 #
4 # Test out for IRIX the removal of file capabilities when
5 # writing to the file (when it doesn't have CAP_FSETID & CAP_SETFCAP)
6 # i.e. not root.
7 # Test out fix for pv#901019
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
11
12 # This program is free software; you can redistribute it and/or modify it
13 # under the terms of version 2 of the GNU General Public License as
14 # published by the Free Software Foundation.
15
16 # This program is distributed in the hope that it would be useful, but
17 # WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
20 # Further, this software is distributed without any warranty that it is
21 # free of the rightful claim of any third person regarding infringement
22 # or the like.  Any license provided herein, whether implied or
23 # otherwise, applies only to this software file.  Patent licenses, if
24 # any, provided herein do not apply to combinations of this program with
25 # other software, or any other product whatsoever.
26
27 # You should have received a copy of the GNU General Public License along
28 # with this program; if not, write the Free Software Foundation, Inc., 59
29 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
30
31 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
32 # Mountain View, CA  94043, or:
33
34 # http://www.sgi.com 
35
36 # For further information regarding this notice, see: 
37
38 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
39 #-----------------------------------------------------------------------
40 #
41 # creator
42 owner=tes@sgi.com
43
44 seq=`basename $0`
45
46 here=`pwd`
47 tmp=/tmp/$$
48 runas=$here/src/runas
49 status=1        # FAILure is the default!
50 trap "_cleanup; exit \$status" 0 1 2 3 15
51
52 # get standard environment, filters and checks
53 . ./common.rc
54 . ./common.filter
55 . ./common.attr
56
57 _cleanup()
58 {
59     [ -n "$testdir" ] && rm -f $file
60     _cleanup_testdir
61 }
62
63 _testfilter()
64 {
65     sed -e "s#$testdir#TESTDIR#g"
66 }
67
68 _filefilter()
69 {
70     sed -e "s#$tmp##" -e "s#$file#file#"
71 }
72
73 # real QA test starts here
74 _supported_fs xfs udf
75 _supported_os IRIX
76
77 [ -x $runas ] || _notrun "$runas executable not found"
78
79 rm -f $seq.full
80
81 _setup_testdir
82 _need_to_be_root
83
84 echo "QA output created by $seq"
85 echo ""
86 file=$testdir/$seq.file
87
88 user=`grep ':all=:all=' /etc/capability | tail -1 | $AWK_PROG -F: '{print $1}'`
89 uid=`grep $user /etc/passwd | $AWK_PROG -F: '{print $3}'`
90
91 cat >$tmp.append <<EOF
92 #!/bin/sh
93 echo data >>$file
94 EOF
95 chmod ugo+x $tmp.append
96
97 echo "touch file"
98 touch $file
99 chmod ugo+w $file 
100
101 echo "chcap on file"
102 chcap CAP_CHOWN+p $file
103
104 echo "ls -P on file"
105 ls -P $file | _testfilter
106
107 echo "append to file as root"
108 $tmp.append
109
110 echo "ls -P on file"
111 ls -P $file | _testfilter
112
113 echo "cat file"
114 echo "----"
115 cat $file
116 echo "----"
117
118 echo "append to file as user without caps"
119 # in particular user doesn't have FSETID or SETFCAP
120 $runas -u $uid $tmp.append
121
122 echo "cat file"
123 echo "----"
124 cat $file
125 echo "----"
126
127 echo "ls -P on file"
128 ls -P $file | _testfilter
129
130 # try again when it doesn't have the EA
131 echo "append to file as user without caps a 2nd time"
132 $runas -u $uid $tmp.append
133
134 echo "ls -P on file"
135 ls -P $file | _testfilter
136
137 echo "cat file"
138 echo "----"
139 cat $file
140 echo "----"
141
142 echo "only let root write to file"
143 chmod 700 $file
144 chown root $file 
145
146 echo "as non-root try to append to file"
147 $runas -u $uid $tmp.append 2>&1 | _filefilter
148
149 echo "restore perms on file"
150 chmod 777 $file
151
152 echo "set a root EA on file"
153 attr -R -s test -V testval $file | _filefilter
154
155 echo "list EA on file"
156 attr -R -l $file | _filefilter
157
158 echo "as non-root try to append to file"
159 $runas -u $uid $tmp.append 2>&1 | _filefilter
160
161 echo "list EA on file"
162 attr -R -l $file | _filefilter
163
164 chown $uid $file
165 chmod ugo+w $testdir
166 echo "as non-root call writemod"
167 $runas -u $uid src/writemod $file 2>&1 | _filefilter
168
169 echo "cat file"
170 echo "----"
171 cat $file
172 echo "----"
173
174 # success, all done
175 status=0
176 exit