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.
11 #-----------------------------------------------------------------------
21 status=1 # FAILure is the default!
22 trap "_cleanup; exit \$status" 0 1 2 3 15
24 # get standard environment, filters and checks
31 [ -n "$testdir" ] && rm -f $file
37 sed -e "s#$testdir#TESTDIR#g"
42 sed -e "s#$tmp##" -e "s#$file#file#"
45 # real QA test starts here
49 [ -x $runas ] || _notrun "$runas executable not found"
56 echo "QA output created by $seq"
58 file=$testdir/$seq.file
60 user=`grep ':all=:all=' /etc/capability | tail -1 | $AWK_PROG -F: '{print $1}'`
61 uid=`grep $user /etc/passwd | $AWK_PROG -F: '{print $3}'`
63 cat >$tmp.append <<EOF
67 chmod ugo+x $tmp.append
74 chcap CAP_CHOWN+p $file
77 ls -P $file | _testfilter
79 echo "append to file as root"
83 ls -P $file | _testfilter
90 echo "append to file as user without caps"
91 # in particular user doesn't have FSETID or SETFCAP
92 $runas -u $uid $tmp.append
100 ls -P $file | _testfilter
102 # try again when it doesn't have the EA
103 echo "append to file as user without caps a 2nd time"
104 $runas -u $uid $tmp.append
107 ls -P $file | _testfilter
114 echo "only let root write to file"
118 echo "as non-root try to append to file"
119 $runas -u $uid $tmp.append 2>&1 | _filefilter
121 echo "restore perms on file"
124 echo "set a root EA on file"
125 attr -R -s test -V testval $file | _filefilter
127 echo "list EA on file"
128 attr -R -l $file | _filefilter
130 echo "as non-root try to append to file"
131 $runas -u $uid $tmp.append 2>&1 | _filefilter
133 echo "list EA on file"
134 attr -R -l $file | _filefilter
138 echo "as non-root call writemod"
139 $runas -u $uid src/writemod $file 2>&1 | _filefilter