[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:02:05AM +0200, Wouter Verhelst wrote:
> > $ 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:

which is not quite true:

gast:sandbox> ls -la 
drwxrwxrwx    2 ecki     ecki           28 May 13 03:30 .
drwxrwxr-x  217 ecki     ecki        45056 May 13 03:28 ..
-r--r--r--    1 ecki     ecki            0 May 13 03:28 bla
-rw-r--r--    1 gast     ecki            0 May 13 03:29 fasel
-rw-rw-rw-    1 ecki     gast            0 May 13 03:30 bar
gast:sandbox> id
uid=1010(gast) gid=1010(gast) groups=1010(gast)
gast:sandbox> touch bla
touch: cannot touch `bla': Permission denied
gast:sandbox> touch fasel
gast:sandbox> touch bar
gast:sandbox> ls -la
drwxrwxrwx    2 ecki     ecki           28 May 13 03:30 .
drwxrwxr-x  217 ecki     ecki        45056 May 13 03:28 ..
-r--r--r--    1 ecki     ecki            0 May 13 03:28 bla
-rw-r--r--    1 gast     ecki            0 May 13 03:32 fasel
-rw-rw-rw-    1 ecki     gast            0 May 13 03:32 bar


as you can see "gast" can only touch fasel and bar, but not bla. bla is
neighter owned nor writeable by gast, even tough the dir is world-writeable.

> This is because those timestamps are saved in the directory inode

this is because the timestamp and the permission is saved in the file-inode,
and the dir entry has no info about that.

This is btw a "feature" of the kernel, not core-utils.

Greetings
Bernd



Reply to: