Files
apfstests/tests/generic/087
T
Andreas Gruenbacher 51a36c71b4 generic/087,126: Test the permission to set file times
Check if setting the file access and modification times to the current time
and to a specific timestamp is allowed when expected.

In generic/126, remove a left-over temporary file.

Signed-off-by: Andreas Gruenbacher <andreas.gruenbacher@gmail.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2015-05-26 12:51:57 +10:00

78 lines
2.2 KiB
Bash
Executable File

#! /bin/bash
# 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+".
#
#-----------------------------------------------------------------------
# Copyright (c) 2015 Red Hat, Inc.
# Author: Andreas Gruenbacher <agruenba@redhat.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
#-----------------------------------------------------------------------
#
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_cleanup()
{
cd /
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
# real QA test starts here
_supported_fs generic
_supported_os Linux
_require_test
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