why can I write to a file I don't have permission to??

Bill Medland billmedland at mercuryspeed.com
Fri Apr 15 15:33:55 UTC 2005


On April 14, 2005 07:55 pm, David.Knight at clubcorp.com wrote:
> On April 14, 2005 02:56 pm, David.Knight at clubcorp.com wrote:
> > RedHat List,
> >         I was working on a script the other day and ran into
> > an anomaly with the file permission's on files. I have
> > checked this on several ES servers and all produce the same
> > results.

As Tobias pointed out, you can get the behaviour you want 
(almost) by setting the sticky bit on the directory; man chmod.

Note that the man page is slightly wrong unclear.  With the 
sticky bit on the directory the file may be deleted by either 
the file's owner or the directory's owner.  In your case it 
won't help because the user is the directory owner and so can 
remove the file.  Compare that to /tmp where root is the 
directory owner and the directory has the sticky bit set, so the 
non-root user won't be able to delete root's files (or anyone 
else's)

References:
- W. Richard Stevens' "Advanced Programming in the Unix 
Environment" (generally accepted as quite authoritative), 
sections 4.5 and 4.10
- Single Unix Specification V3 - General Concepts - Directory 
Protection

-- 
Bill Medland
mailto:billmedland at mercuryspeed.com
http://webhome.idirect.com/~kbmed




More information about the redhat-list mailing list