2 # vim: filetype=sh noexpandtab ts=8 sw=8
5 desc="utimensat will work if the caller is the owner or root"
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`
23 expect 0 mkdir ${n1} 0755
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
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
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
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