]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/pjdfstest/tests/utimensat/07.t
Update tcsh to 6.21.00.
[FreeBSD/FreeBSD.git] / contrib / pjdfstest / tests / utimensat / 07.t
1 #! /bin/sh
2 # vim: filetype=sh noexpandtab ts=8 sw=8
3 # $FreeBSD$
4
5 desc="utimensat will work if the caller is the owner or root"
6
7 dir=`dirname $0`
8 . ${dir}/../misc.sh
9
10 require "utimensat"
11
12 echo "1..17"
13
14 n0=`namegen`
15 n1=`namegen`
16 DATE1=1900000000 #Sun Mar 17 11:46:40 MDT 2030
17 DATE2=1950000000 #Fri Oct 17 04:40:00 MDT 2031
18 UID_NOBODY=`id -u nobody`
19 GID_NOBODY=`id -g nobody`
20 UID_ROOT=`id -u root`
21 GID_ROOT=`id -g root`
22
23 expect 0 mkdir ${n1} 0755
24 cdir=`pwd`
25 cd ${n1}
26
27 create_file regular ${n0} 0644 $UID_ROOT $GID_ROOT
28 # First check that nobody can't update the timestamps
29 expect EPERM -u $UID_NOBODY open . O_RDONLY : utimensat 0 ${n0} 0 UTIME_OMIT $DATE2 0 0
30 expect EPERM -u $UID_NOBODY open . O_RDONLY : utimensat 0 ${n0} $DATE1 0 0 UTIME_OMIT 0
31 expect EPERM -u $UID_NOBODY open . O_RDONLY : utimensat 0 ${n0} $DATE1 0 $DATE2 0 0
32
33 # Now check that a nonowner with write permission can't update the timestamps
34 expect 0 chmod ${n0} 0666
35 expect EPERM -u $UID_NOBODY open . O_RDONLY : utimensat 0 ${n0} 0 UTIME_OMIT $DATE2 0 0
36 expect EPERM -u $UID_NOBODY open . O_RDONLY : utimensat 0 ${n0} $DATE1 0 0 UTIME_OMIT 0
37 expect EPERM -u $UID_NOBODY open . O_RDONLY : utimensat 0 ${n0} $DATE1 0 $DATE2 0 0
38
39 # Now check that the owner can update the timestamps
40 expect 0 chown ${n0} $UID_NOBODY $GID_NOBODY
41 expect 0 chmod ${n0} 0444
42 expect 0 -u $UID_NOBODY open . O_RDONLY : utimensat 0 ${n0} $DATE1 0 $DATE2 0
43
44 # Now check that the superuser can update the timestamps
45 expect 0 -u $UID_ROOT open . O_RDONLY : utimensat 0 ${n0} $DATE1 0 $DATE2 0 0
46
47
48 expect 0 unlink ${n0}
49
50 cd ${cdir}
51 expect 0 rmdir ${n1}