xfstests: fix some warnings
[xfstests-dev.git] / 123
1 #! /bin/bash
2 # FSQA Test No. 123
3 #
4 # Make sure user cannot overwrite, append, delete or move a file created by 
5 # root. Modified CXFSQA test 940960 and 940558.
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2006 Silicon Graphics, Inc.  All Rights Reserved.
9 #
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
13 #
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22 #
23 #-----------------------------------------------------------------------
24 #
25 # creator
26 owner=ajones@sgi.com
27
28 seq=`basename $0`
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=0        # success is the default!
34
35 trap "_cleanup; exit \$status" 0 1 2 3 15
36
37 _cleanup()
38 {
39     cd $testdir
40     rm -rf $my_test_subdir
41     cd /
42     _cleanup_testdir
43 }
44
45
46 _filter_user_do()
47 {
48         perl -ne "
49 s,.*Permission\sdenied.*,Permission denied,;
50 s,.*no\saccess\sto\stty.*,,;
51 s,.*no\sjob\scontrol\sin\sthis\sshell.*,,;
52 s,^\s*$,,;
53         print;"
54 }
55
56
57
58
59 _user_do()
60 {
61     if [ "$HOSTOS" == "IRIX" ]
62         then
63         echo $1 | /bin/bash "su $qa_user 2>&1" | _filter_user_do
64     else
65         echo $1 | su $qa_user 2>&1 | _filter_user_do
66     fi
67 }
68
69 # get standard environment, filters and checks
70 . ./common.rc
71 . ./common.filter
72
73 # real QA test starts here
74 _supported_fs generic
75 _supported_os Linux IRIX
76
77 _require_user
78
79 _setup_testdir
80 my_test_subdir=$testdir/123subdir
81
82 # create subdir with required permissions
83 mkdir -m 755 $my_test_subdir
84
85 echo foo > $my_test_subdir/data_coherency.txt
86 # check basic appending to a file
87 echo bar >> $my_test_subdir/data_coherency.txt
88
89 # try append
90 _user_do "echo goo >> $my_test_subdir/data_coherency.txt" 
91
92 # try overwrite 
93 _user_do "echo goo > $my_test_subdir/data_coherency.txt" 
94
95 # try delete
96 _user_do "rm $my_test_subdir/data_coherency.txt" 
97
98 # try move
99 _user_do "mv $my_test_subdir/data_coherency.txt $my_test_subdir/data_coherency2.txt" 
100
101 cat $my_test_subdir/data_coherency.txt
102
103
104 exit