[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: can touch(1) readonly files

On Tue, May 13, 2003 at 03:10:58AM +0800, Dan Jacobson wrote:
> Gentlemen, what's the deal where one can change the dates on read-only files?
> $ chmod -w f; touch -d 'next year' f; ls -l f
> -r--r--r-- 1 jidanni jidanni 666 2004-05-13 03:02 f

You can only do that if you have write permissions to the directory the
file is in; if not:

wouter@rock:/usr$ touch -d 'next year' doc; ls -ld doc .
touch: setting times of `doc': Operation not permitted
drwxr-xr-x   16 root     root          472 Apr 28 03:21 .
drwxr-xr-x    2 root     root         7568 May 13 02:42 doc

This is because those timestamps are saved in the directory inode
instead of in the file inode, so closing down permissions on the file
won't prevent anyone from tampering with timestamps.

wouter at grep dot be
"An expert can usually spot the difference between a fake charge and a
full one, but there are plenty of dead experts." 
  -- National Geographic Channel, in a documentary about large African beasts.

Attachment: pgpK_oFN3vkp5.pgp
Description: PGP signature

Reply to: