summaryrefslogtreecommitdiff
path: root/tests/generic/087
blob: 160b32defca0c4585139d74c4a8b20736ca4ab54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2015 Red Hat, Inc.
#
# FSQA Test No. 087
#
# Check if setting the file access and modification times to the current time
# (t) and to a specific timestamp (T) is allowed when expected.
#
# From utime(2): Changing timestamps is permitted when: either the process has
# appropriate privileges, or the effective user ID equals the user ID of the
# file, or [the process is trying to set the timestamps to the current time]
# and the process has write permission for the file.
#
# Note that the last of these tests will always wrongly succeed over NFSv2.
# For NFSv3+, that test will wrongly succeed until kernel commit
# "Disable NFSv2 timestamp workaround for NFSv3+".
#
. ./common/preamble
_begin_fstest perms auto quick

# Override the default cleanup function.
_cleanup()
{
    cd /
}

# Import common functions.
. ./common/filter

# real QA test starts here
_supported_fs generic
_require_test
_require_chown

QA_FS_PERMS=$here/src/fs_perms

cd $TEST_DIR
cp $here/src/testx ./testx.file

# The owner:
$QA_FS_PERMS 600 99 99 99 99 t 1
$QA_FS_PERMS 600 99 99 99 99 T 1

# Other processes with and without write permission:
$QA_FS_PERMS 600 99 99 100 99 t 0
$QA_FS_PERMS 600 99 99 100 99 T 0
$QA_FS_PERMS 660 99 99 100 99 t 1
$QA_FS_PERMS 660 99 99 100 99 T 0

rm -f ./testx.file

status=0
exit