dont specify shell for su, irix doesnt like it
[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
31 _filter_user_do()
32 {
33         perl -ne "
34 s,.*Permission\sdenied.*,Permission denied,;
35 s,.*no\saccess\sto\stty.*,,;
36 s,.*no\sjob\scontrol\sin\sthis\sshell.*,,;
37 s,^\s*$,,;
38         print;"
39 }
40
41
42
43
44 _user_do()
45 {
46     echo "/bin/sh '$1'" | su - $qa_user | _filter_user_do 
47 }
48
49 # get standard environment, filters and checks
50 . ./common.rc
51 . ./common.filter
52
53 # real QA test starts here
54 _supported_fs xfs udf nfs
55 _supported_os Linux IRIX
56
57 _require_user
58
59 _setup_testdir
60
61 echo foo > $testdir/data_coherency.txt
62 # check basic appending to a file
63 echo bar >> $testdir/data_coherency.txt
64
65 # try append
66 _user_do "echo goo 2>&1 >> $testdir/data_coherency.txt" 
67
68 # try overwrite 
69 _user_do "echo goo 2>&1 > $testdir/data_coherency.txt" 
70
71 # try delete
72 _user_do "rm $testdir/data_coherency.txt 2>&1" 
73
74 # try move
75 _user_do "mv $testdir/data_coherency.txt $testdir/data_coherency2.txt 2>&1" 
76
77 cat $testdir/data_coherency.txt
78
79
80 exit