]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/pjdfstest/tests/utimensat/06.t
MFV r355071: libbsdxml (expat) 2.2.9.
[FreeBSD/FreeBSD.git] / contrib / pjdfstest / tests / utimensat / 06.t
1 #! /bin/sh
2 # vim: filetype=sh noexpandtab ts=8 sw=8
3 # $FreeBSD$
4
5 desc="utimensat with UTIME_NOW will work if the caller has write permission"
6
7 dir=`dirname $0`
8 . ${dir}/../misc.sh
9
10 require "utimensat"
11
12 echo "1..13"
13
14 n0=`namegen`
15 n1=`namegen`
16 UID_NOBODY=`id -u nobody`
17 GID_NOBODY=`id -g nobody`
18 UID_ROOT=`id -u root`
19 GID_ROOT=`id -g root`
20
21 expect 0 mkdir ${n1} 0755
22 cdir=`pwd`
23 cd ${n1}
24
25 create_file regular ${n0} 0644
26 # First check that nobody can't update the timestamps
27 expect EACCES -u $UID_NOBODY open . O_RDONLY : utimensat 0 ${n0} 0 UTIME_NOW 0 UTIME_NOW 0
28
29 # Now check that the owner can update the timestamps
30 expect 0 chown ${n0} $UID_NOBODY $GID_NOBODY
31 expect 0 chmod ${n0} 0444
32 expect 0 -u $UID_NOBODY open . O_RDONLY : utimensat 0 ${n0} 0 UTIME_NOW 0 UTIME_NOW 0
33
34 # Now check that the superuser can update the timestamps
35 expect 0 -u $UID_ROOT open . O_RDONLY : utimensat 0 ${n0} 0 UTIME_OMIT 0 UTIME_OMIT 0
36
37 # Now check that anyone with write permission can update the timestamps
38 expect 0 chown ${n0} $UID_ROOT $GID_ROOT
39 expect 0 chmod ${n0} 0666
40 expect 0 -u $UID_NOBODY open . O_RDONLY : utimensat 0 ${n0} 0 UTIME_NOW 0 UTIME_NOW 0
41
42 expect 0 unlink ${n0}
43
44 cd ${cdir}
45 expect 0 rmdir ${n1}