xref: /freebsd/contrib/pjdfstest/tests/utimensat/06.t (revision 531c2d7af3cd2e64eec94aa1b19c4b2f16fce515)
1*3416500aSEnji Cooper#! /bin/sh
2*3416500aSEnji Cooper# vim: filetype=sh noexpandtab ts=8 sw=8
3*3416500aSEnji Cooper# $FreeBSD$
4*3416500aSEnji Cooper
5*3416500aSEnji Cooperdesc="utimensat with UTIME_NOW will work if the caller has write permission"
6*3416500aSEnji Cooper
7*3416500aSEnji Cooperdir=`dirname $0`
8*3416500aSEnji Cooper. ${dir}/../misc.sh
9*3416500aSEnji Cooper
10*3416500aSEnji Cooperrequire "utimensat"
11*3416500aSEnji Cooper
12*3416500aSEnji Cooperecho "1..13"
13*3416500aSEnji Cooper
14*3416500aSEnji Coopern0=`namegen`
15*3416500aSEnji Coopern1=`namegen`
16*3416500aSEnji CooperUID_NOBODY=`id -u nobody`
17*3416500aSEnji CooperGID_NOBODY=`id -g nobody`
18*3416500aSEnji CooperUID_ROOT=`id -u root`
19*3416500aSEnji CooperGID_ROOT=`id -g root`
20*3416500aSEnji Cooper
21*3416500aSEnji Cooperexpect 0 mkdir ${n1} 0755
22*3416500aSEnji Coopercdir=`pwd`
23*3416500aSEnji Coopercd ${n1}
24*3416500aSEnji Cooper
25*3416500aSEnji Coopercreate_file regular ${n0} 0644
26*3416500aSEnji Cooper# First check that nobody can't update the timestamps
27*3416500aSEnji Cooperexpect EACCES -u $UID_NOBODY open . O_RDONLY : utimensat 0 ${n0} 0 UTIME_NOW 0 UTIME_NOW 0
28*3416500aSEnji Cooper
29*3416500aSEnji Cooper# Now check that the owner can update the timestamps
30*3416500aSEnji Cooperexpect 0 chown ${n0} $UID_NOBODY $GID_NOBODY
31*3416500aSEnji Cooperexpect 0 chmod ${n0} 0444
32*3416500aSEnji Cooperexpect 0 -u $UID_NOBODY open . O_RDONLY : utimensat 0 ${n0} 0 UTIME_NOW 0 UTIME_NOW 0
33*3416500aSEnji Cooper
34*3416500aSEnji Cooper# Now check that the superuser can update the timestamps
35*3416500aSEnji Cooperexpect 0 -u $UID_ROOT open . O_RDONLY : utimensat 0 ${n0} 0 UTIME_OMIT 0 UTIME_OMIT 0
36*3416500aSEnji Cooper
37*3416500aSEnji Cooper# Now check that anyone with write permission can update the timestamps
38*3416500aSEnji Cooperexpect 0 chown ${n0} $UID_ROOT $GID_ROOT
39*3416500aSEnji Cooperexpect 0 chmod ${n0} 0666
40*3416500aSEnji Cooperexpect 0 -u $UID_NOBODY open . O_RDONLY : utimensat 0 ${n0} 0 UTIME_NOW 0 UTIME_NOW 0
41*3416500aSEnji Cooper
42*3416500aSEnji Cooperexpect 0 unlink ${n0}
43*3416500aSEnji Cooper
44*3416500aSEnji Coopercd ${cdir}
45*3416500aSEnji Cooperexpect 0 rmdir ${n1}
46