[comp.bugs.sys5] touch: got to be owner if use date string

Dan_Jacobson@ATT.COM (02/12/91)

spotted on Amdahl UTS 5.2.6....

$ ls -l lcircle10.300pk
-rw-rw-rw-   1 dvorak   dvorak      4340 Feb 12 07:51 lcircle10.300pk
$ id
uid=47941(danj1) gid=47941(danj1) fsid=8(45262)
$ touch lcircle10.300pk
#that worked, why not this?  works when I'm owner...
$ touch 1231235999 lcircle10.300pk
touch: cannot change times on lcircle10.300pk
-- 
Dan_Jacobson@ATT.COM  Naperville IL USA  +1 708-979-6364

jfh@greenber.austin.ibm.com (John F Haugh II) (02/13/91)

In article <DANJ1.91Feb12091029@cbnewse.ATT.COM> Dan_Jacobson@ATT.COM writes:
>spotted on Amdahl UTS 5.2.6....
>
>$ ls -l lcircle10.300pk
>-rw-rw-rw-   1 dvorak   dvorak      4340 Feb 12 07:51 lcircle10.300pk
>$ id
>uid=47941(danj1) gid=47941(danj1) fsid=8(45262)
>$ touch lcircle10.300pk
>#that worked, why not this?  works when I'm owner...
>$ touch 1231235999 lcircle10.300pk
>touch: cannot change times on lcircle10.300pk

Not sure which part should be the bug.

In the olden days, touch without an argument read and wrote the
first byte of the file.  That was sufficient to change the file
modification time.

Nowadays, touch takes a date and uses the utime(2) system call
to change the last read or written dates.  This calls requires
the user to be the file owner or root.

The initial question I raised concerns whether the "old style"
behavior should still work.  I think the answer is "why not."
-- 
John F. Haugh II      |      I've Been Moved     |    MaBellNet: (512) 838-4340
SneakerNet: 809/1D064 |          AGAIN !         |      VNET: LCCB386 at AUSVMQ
BangNet: ..!cs.utexas.edu!ibmchs!auschs!snowball.austin.ibm.com!jfh (e-i-e-i-o)

jeq@i88.isc.com (Jonathan E. Quist) (02/13/91)

In article <DANJ1.91Feb12091029@cbnewse.ATT.COM> Dan_Jacobson@ATT.COM writes:
>spotted on Amdahl UTS 5.2.6....
>
>$ ls -l lcircle10.300pk
>-rw-rw-rw-   1 dvorak   dvorak      4340 Feb 12 07:51 lcircle10.300pk
>$ id
>uid=47941(danj1) gid=47941(danj1) fsid=8(45262)
>$ touch lcircle10.300pk
>#that worked, why not this?  works when I'm owner...
>$ touch 1231235999 lcircle10.300pk
>touch: cannot change times on lcircle10.300pk

touch() calls utime(file,0) to set the current time.
to set a particular time, it calls utime(file,&utimbuf),
with the contents of utimbuf set to the desired time.
The first requires only write permission; the second
requires ownership.  (ref. utime(2))

--
Jonathan E. Quist				INTERACTIVE Systems Corporation
jeq@i88.isc.com     					Naperville, IL
DoD #094/ '71 CL450-K4 "Gleep"

Dan_Jacobson@ATT.COM (02/14/91)

>>>>> On 12 Feb 91 21:30:24 GMT, jeq@i88.isc.com (Jonathan E. Quist) said:

J> touch() calls utime(file,0) to set the current time.
J> to set a particular time, it calls utime(file,&utimbuf),
J> with the contents of utimbuf set to the desired time.
J> The first requires only write permission; the second
J> requires ownership.  (ref. utime(2))

OK, fine, than the touch man page should say

BUGS
	The optional timestring doesn't work if you don't own the file,
	even though you can write to it.  In that case consider
	copying the file, touching it to the preferred date, moving it
	to the original file name, if possible, then chown(1) and
	chgrp(1)ing the file to the original owner.

[I haven't considered any of the options letters.]

[Also thanks to Sam Ho]
-- 
Dan_Jacobson@ATT.COM  Naperville IL USA  +1 708-979-6364