Fix the display of a variable.
[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
21 trap "_cleanup; exit \$status" 0 1 2 3 15
22
23 _cleanup()
24 {
25     cd $testdir
26     rm -rf $my_test_subdir
27     cd /
28     _cleanup_testdir
29 }
30
31
32 _filter_user_do()
33 {
34         perl -ne "
35 s,.*Permission\sdenied.*,Permission denied,;
36 s,.*no\saccess\sto\stty.*,,;
37 s,.*no\sjob\scontrol\sin\sthis\sshell.*,,;
38 s,^\s*$,,;
39         print;"
40 }
41
42
43
44
45 _user_do()
46 {
47     if [ "$HOSTOS" == "IRIX" ]
48         then
49         echo $1 | /bin/sh "su $qa_user 2>&1" | _filter_user_do
50     else
51         echo $1 | su $qa_user 2>&1 | _filter_user_do
52     fi
53 }
54
55 # get standard environment, filters and checks
56 . ./common.rc
57 . ./common.filter
58
59 # real QA test starts here
60 _supported_fs xfs udf nfs
61 _supported_os Linux IRIX
62
63 _require_user
64
65 _setup_testdir
66 my_test_subdir=$testdir/123subdir
67
68 # create subdir with required permissions
69 mkdir -m 755 $my_test_subdir
70
71 echo foo > $my_test_subdir/data_coherency.txt
72 # check basic appending to a file
73 echo bar >> $my_test_subdir/data_coherency.txt
74
75 # try append
76 _user_do "echo goo >> $my_test_subdir/data_coherency.txt" 
77
78 # try overwrite 
79 _user_do "echo goo > $my_test_subdir/data_coherency.txt" 
80
81 # try delete
82 _user_do "rm $my_test_subdir/data_coherency.txt" 
83
84 # try move
85 _user_do "mv $my_test_subdir/data_coherency.txt $my_test_subdir/data_coherency2.txt" 
86
87 cat $my_test_subdir/data_coherency.txt
88
89
90 exit