generic/087,126: Test the permission to set file times
[xfstests-dev.git] / tests / generic / 087
1 #! /bin/bash
2 # FSQA Test No. 087
3 #
4 # Check if setting the file access and modification times to the current time
5 # (t) and to a specific timestamp (T) is allowed when expected.
6 #
7 # From utime(2): Changing timestamps is permitted when: either the process has
8 # appropriate privileges, or the effective user ID equals the user ID of the
9 # file, or [the process is trying to set the timestamps to the current time]
10 # and the process has write permission for the file.
11 #
12 # Note that the last of these tests will always wrongly succeed over NFSv2.
13 # For NFSv3+, that test will wrongly succeed until kernel commit
14 # "Disable NFSv2 timestamp workaround for NFSv3+".
15 #
16 #-----------------------------------------------------------------------
17 # Copyright (c) 2015 Red Hat, Inc.
18 # Author: Andreas Gruenbacher <agruenba@redhat.com>
19 #
20 # This program is free software; you can redistribute it and/or
21 # modify it under the terms of the GNU General Public License as
22 # published by the Free Software Foundation.
23 #
24 # This program is distributed in the hope that it would be useful,
25 # but WITHOUT ANY WARRANTY; without even the implied warranty of
26 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27 # GNU General Public License for more details.
28 #
29 # You should have received a copy of the GNU General Public License
30 # along with this program; if not, write the Free Software Foundation,
31 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
32 #
33 #-----------------------------------------------------------------------
34 #
35
36 seq=`basename $0`
37 seqres=$RESULT_DIR/$seq
38 echo "QA output created by $seq"
39
40 here=`pwd`
41 tmp=/tmp/$$
42 status=1        # failure is the default!
43 trap "_cleanup; exit \$status" 0 1 2 3 15
44
45 _cleanup()
46 {
47     cd /
48 }
49
50 # get standard environment, filters and checks
51 . ./common/rc
52 . ./common/filter
53
54 # real QA test starts here
55 _supported_fs generic
56 _supported_os Linux
57 _require_test
58
59 QA_FS_PERMS=$here/src/fs_perms
60
61 cd $TEST_DIR
62 cp $here/src/testx ./testx.file
63
64 # The owner:
65 $QA_FS_PERMS 600 99 99 99 99 t 1
66 $QA_FS_PERMS 600 99 99 99 99 T 1
67
68 # Other processes with and without write permission:
69 $QA_FS_PERMS 600 99 99 100 99 t 0
70 $QA_FS_PERMS 600 99 99 100 99 T 0
71 $QA_FS_PERMS 660 99 99 100 99 t 1
72 $QA_FS_PERMS 660 99 99 100 99 T 0
73
74 rm -f ./testx.file
75
76 status=0
77 exit