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 #-----------------------------------------------------------------------
29 seqres=$RESULT_DIR/$seq
33 status=1 # FAILure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
36 # get standard environment, filters and checks
43 [ -n "$TEST_DIR" ] && rm -f $file
48 sed -e "s#$TEST_DIR#TESTDIR#g"
53 sed -e "s#$tmp##" -e "s#$file#file#"
56 # real QA test starts here
66 echo "QA output created by $seq"
68 file=$TEST_DIR/$seq.file
70 user=`grep ':all=:all=' /etc/capability | tail -1 | $AWK_PROG -F: '{print $1}'`
71 uid=`_cat_passwd | grep $user | $AWK_PROG -F: '{print $3}'`
73 cat >$tmp.append <<EOF
77 chmod ugo+x $tmp.append
84 chcap CAP_CHOWN+p $file
87 ls -P $file | _testfilter
89 echo "append to file as root"
93 ls -P $file | _testfilter
100 echo "append to file as user without caps"
101 # in particular user doesn't have FSETID or SETFCAP
102 _runas -u $uid $tmp.append
110 ls -P $file | _testfilter
112 # try again when it doesn't have the EA
113 echo "append to file as user without caps a 2nd time"
114 _runas -u $uid $tmp.append
117 ls -P $file | _testfilter
124 echo "only let root write to file"
128 echo "as non-root try to append to file"
129 _runas -u $uid $tmp.append 2>&1 | _filefilter
131 echo "restore perms on file"
134 echo "set a root EA on file"
135 ${ATTR_PROG} -R -s test -V testval $file | _filefilter
137 echo "list EA on file"
138 ${ATTR_PROG} -R -l $file | _filefilter
140 echo "as non-root try to append to file"
141 _runas -u $uid $tmp.append 2>&1 | _filefilter
143 echo "list EA on file"
144 ${ATTR_PROG} -R -l $file | _filefilter
147 chmod ugo+w $TEST_DIR
148 echo "as non-root call writemod"
149 _runas -u $uid src/writemod $file 2>&1 | _filefilter