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
13 # modify it under the terms 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,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #-----------------------------------------------------------------------
35 status=1 # FAILure is the default!
36 trap "_cleanup; exit \$status" 0 1 2 3 15
38 # get standard environment, filters and checks
45 [ -n "$testdir" ] && rm -f $file
51 sed -e "s#$testdir#TESTDIR#g"
56 sed -e "s#$tmp##" -e "s#$file#file#"
59 # real QA test starts here
63 [ -x $runas ] || _notrun "$runas executable not found"
70 echo "QA output created by $seq"
72 file=$testdir/$seq.file
74 user=`grep ':all=:all=' /etc/capability | tail -1 | $AWK_PROG -F: '{print $1}'`
75 uid=`grep $user /etc/passwd | $AWK_PROG -F: '{print $3}'`
77 cat >$tmp.append <<EOF
81 chmod ugo+x $tmp.append
88 chcap CAP_CHOWN+p $file
91 ls -P $file | _testfilter
93 echo "append to file as root"
97 ls -P $file | _testfilter
104 echo "append to file as user without caps"
105 # in particular user doesn't have FSETID or SETFCAP
106 $runas -u $uid $tmp.append
114 ls -P $file | _testfilter
116 # try again when it doesn't have the EA
117 echo "append to file as user without caps a 2nd time"
118 $runas -u $uid $tmp.append
121 ls -P $file | _testfilter
128 echo "only let root write to file"
132 echo "as non-root try to append to file"
133 $runas -u $uid $tmp.append 2>&1 | _filefilter
135 echo "restore perms on file"
138 echo "set a root EA on file"
139 attr -R -s test -V testval $file | _filefilter
141 echo "list EA on file"
142 attr -R -l $file | _filefilter
144 echo "as non-root try to append to file"
145 $runas -u $uid $tmp.append 2>&1 | _filefilter
147 echo "list EA on file"
148 attr -R -l $file | _filefilter
152 echo "as non-root call writemod"
153 $runas -u $uid src/writemod $file 2>&1 | _filefilter