Fix the file_as_id routine so it works for test 050.
[xfstests-dev.git] / 123
1 #! /bin/sh
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 #
11 # creator
12 owner=ajones@sgi.com
13
14 seq=`basename $0`
15 echo "QA output created by $seq"
16
17 here=`pwd`
18 tmp=/tmp/$$
19 status=0        # success is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
24     cd $testdir
25     rm data_coherency.txt
26     cd /
27     _cleanup_testdir
28 }
29
30 _user_do()
31 {
32     echo $1 | su - $qa_user | sed -e "s#.*Permission denied.*#Permission denied#g"
33 }
34
35 # get standard environment, filters and checks
36 . ./common.rc
37 . ./common.filter
38
39 # real QA test starts here
40 _supported_fs xfs udf nfs
41 _supported_os Linux IRIX
42
43 _require_user
44
45 _setup_testdir
46
47 echo foo > $testdir/data_coherency.txt
48 # check basic appending to a file
49 echo bar >> $testdir/data_coherency.txt
50
51
52 # try append
53 _user_do "echo goo 2>&1 >> $testdir/data_coherency.txt" 
54
55 # try overwrite 
56 _user_do "echo goo 2>&1 > $testdir/data_coherency.txt" 
57
58 # try delete
59 _user_do "rm $testdir/data_coherency.txt 2>&1" 
60
61 # try move
62 _user_do "mv $testdir/data_coherency.txt $testdir/data_coherency2.txt 2>&1" 
63
64 cat $testdir/data_coherency.txt
65
66
67 exit