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)
7 # Test out fix for pv#901019
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
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.
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.
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.
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.
31 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
32 # Mountain View, CA 94043, or:
36 # For further information regarding this notice, see:
38 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
39 #-----------------------------------------------------------------------
49 status=1 # FAILure is the default!
50 trap "_cleanup; exit \$status" 0 1 2 3 15
52 # get standard environment, filters and checks
59 [ -n "$testdir" ] && rm -f $file
65 sed -e "s#$testdir#TESTDIR#g"
70 sed -e "s#$tmp##" -e "s#$file#file#"
73 # real QA test starts here
77 [ -x $runas ] || _notrun "$runas executable not found"
84 echo "QA output created by $seq"
86 file=$testdir/$seq.file
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}'`
91 cat >$tmp.append <<EOF
95 chmod ugo+x $tmp.append
102 chcap CAP_CHOWN+p $file
105 ls -P $file | _testfilter
107 echo "append to file as root"
111 ls -P $file | _testfilter
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
128 ls -P $file | _testfilter
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
135 ls -P $file | _testfilter
142 echo "only let root write to file"
146 echo "as non-root try to append to file"
147 $runas -u $uid $tmp.append 2>&1 | _filefilter
149 echo "restore perms on file"
152 echo "set a root EA on file"
153 attr -R -s test -V testval $file | _filefilter
155 echo "list EA on file"
156 attr -R -l $file | _filefilter
158 echo "as non-root try to append to file"
159 $runas -u $uid $tmp.append 2>&1 | _filefilter
161 echo "list EA on file"
162 attr -R -l $file | _filefilter
166 echo "as non-root call writemod"
167 $runas -u $uid src/writemod $file 2>&1 | _filefilter