linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: Bug in the file attributes ?
@ 2001-03-29 19:25 Jesse Pollard
  0 siblings, 0 replies; 9+ messages in thread
From: Jesse Pollard @ 2001-03-29 19:25 UTC (permalink / raw)
  To: xordoquy, linux-kernel

---------  Received message begins Here  ---------

> 
> 
> Hi,
> 
> I just made a manipulation that disturbs me. So I'm asking whether it's a
> bug or a features.
> 
> user> su
> root> echo "test" > test
> root> ls -l
> -rw-r--r--   1 root     root            5 Mar 29 19:14 test
> root> exit
> user> rm test
> rm: remove write-protected file `test'? y
> user> ls test
> ls: test: No such file or directory
> 
> This is in the user home directory.
> Since the file is read only for the user, it should not be able to remove
> it. Moreover, the user can't write to test.
> So I think this is a bug.

Nope - rm only updates the directory, which the user owns; not the file.
The prompt is just being nice.

-------------------------------------------------------------------------
Jesse I Pollard, II
Email: pollard@navo.hpc.mil

Any opinions expressed are solely my own.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Bug in the file attributes ?
  2001-03-29 18:51 ` Justin Carlson
@ 2001-03-30  2:34   ` Tim Wright
  0 siblings, 0 replies; 9+ messages in thread
From: Tim Wright @ 2001-03-30  2:34 UTC (permalink / raw)
  To: Justin Carlson; +Cc: Xavier Ordoquy, linux-kernel

On Thu, Mar 29, 2001 at 10:51:18AM -0800, Justin Carlson wrote:
> You don't need write perms on a file to remove it, you need write perms on the
> directory.  If you've got write permissions on the directory, you can remove
> any file in the directory, regardless of the permissions.
> 
> -Justin

Except when the "sticky" bit is set. This is useful for shared temporary
directories. Files can be created by anyone, but they can only be unlinked
by the owner or by the superuser. Take a look at the permissions of /var/tmp.

Tim

-- 
Tim Wright - timw@splhi.com or timw@aracnet.com or twright@us.ibm.com
IBM Linux Technology Center, Beaverton, Oregon
Interested in Linux scalability ? Look at http://lse.sourceforge.net/
"Nobody ever said I was charming, they said "Rimmer, you're a git!"" RD VI

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Bug in the file attributes ?
  2001-03-29 18:44 ` Andreas Dilger
  2001-03-29 20:56   ` Xavier Ordoquy
@ 2001-03-29 22:57   ` Brian Beattie
  1 sibling, 0 replies; 9+ messages in thread
From: Brian Beattie @ 2001-03-29 22:57 UTC (permalink / raw)
  To: Andreas Dilger; +Cc: Xavier Ordoquy, linux-kernel

On Thu, 29 Mar 2001, Andreas Dilger wrote:

> Xavier Ordoquy writes:
> > I just made a manipulation that disturbs me. So I'm asking whether it's a
> > bug or a features.
> > 
> > user> su
> > root> echo "test" > test
> > root> ls -l
> > -rw-r--r--   1 root     root            5 Mar 29 19:14 test
> > root> exit
> > user> rm test
> > rm: remove write-protected file `test'? y
> > user> ls test
> > ls: test: No such file or directory
> > 
> > This is in the user home directory.
> > Since the file is read only for the user, it should not be able to remove
> > it. Moreover, the user can't write to test.
> 
> This is definitely not a bug.  Deleting a file (under *nix) does not
> "modify" the file at all, it is modifying the directory where the file
> resides.

To be correct and pedantic, in a traditional Unix type filesystem, one
does not remove a file...one dereferences it, i.e. "unlink", as part of
this process garbage collection is performed which checks the reference
count. If the inode's reference count is zero, the inode and data blocks
are returned to their respective free lists.  All the rm command does, is
to remove the directory entry and decrement the reference count :).  This
is why Unix has a rm (remove link) as opposed to a del (delete file)
command.

Brian...just being pedantic :-^

Brian Beattie
bbeattie@sequent.com
503.578.5899  Des2-3C-5


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Bug in the file attributes ?
  2001-03-29 18:44 ` Andreas Dilger
@ 2001-03-29 20:56   ` Xavier Ordoquy
  2001-03-29 19:04     ` John Jasen
  2001-03-29 22:57   ` Brian Beattie
  1 sibling, 1 reply; 9+ messages in thread
From: Xavier Ordoquy @ 2001-03-29 20:56 UTC (permalink / raw)
  To: linux-kernel


OK, thanks for the answer.
I've spoken to a few people before and they hadn't heard about it.
Since once upon the time on a solaris system I've had a root file that I 
couldn't remove even if I hold the rights of the directory.
This is why I figured out this was a bug.
Anyway, thanks for that.

---
 Xavier Ordoquy, Aurora-linux
 If NT is the answer, you didn't understand the question.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Bug in the file attributes ?
@ 2001-03-29 20:20 Xavier Ordoquy
  2001-03-29 18:44 ` Andreas Dilger
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Xavier Ordoquy @ 2001-03-29 20:20 UTC (permalink / raw)
  To: linux-kernel


Hi,

I just made a manipulation that disturbs me. So I'm asking whether it's a
bug or a features.

user> su
root> echo "test" > test
root> ls -l
-rw-r--r--   1 root     root            5 Mar 29 19:14 test
root> exit
user> rm test
rm: remove write-protected file `test'? y
user> ls test
ls: test: No such file or directory

This is in the user home directory.
Since the file is read only for the user, it should not be able to remove
it. Moreover, the user can't write to test.
So I think this is a bug.

---
 Xavier Ordoquy, Aurora-linux
 If NT is the answer, you didn't understand the question.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Bug in the file attributes ?
  2001-03-29 20:56   ` Xavier Ordoquy
@ 2001-03-29 19:04     ` John Jasen
  0 siblings, 0 replies; 9+ messages in thread
From: John Jasen @ 2001-03-29 19:04 UTC (permalink / raw)
  To: Xavier Ordoquy; +Cc: linux-kernel

On Thu, 29 Mar 2001, Xavier Ordoquy wrote:

> OK, thanks for the answer.
> I've spoken to a few people before and they hadn't heard about it.
> Since once upon the time on a solaris system I've had a root file that I
> couldn't remove even if I hold the rights of the directory.
> This is why I figured out this was a bug.
> Anyway, thanks for that.

I think, I could very easily be mistaken, tho', that being able to do this
is part of posix compliance.

--
-- John E. Jasen (jjasen1@umbc.edu)
-- In theory, theory and practise are the same. In practise, they aren't.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Bug in the file attributes ?
  2001-03-29 20:20 Xavier Ordoquy
  2001-03-29 18:44 ` Andreas Dilger
  2001-03-29 18:45 ` Stephen Clouse
@ 2001-03-29 18:51 ` Justin Carlson
  2001-03-30  2:34   ` Tim Wright
  2 siblings, 1 reply; 9+ messages in thread
From: Justin Carlson @ 2001-03-29 18:51 UTC (permalink / raw)
  To: Xavier Ordoquy, linux-kernel

On Thu, 29 Mar 2001, Xavier Ordoquy wrote:
> Hi,
> 
> I just made a manipulation that disturbs me. So I'm asking whether it's a
> bug or a features.
> 
> user> su
> root> echo "test" > test
> root> ls -l
> -rw-r--r--   1 root     root            5 Mar 29 19:14 test
> root> exit
> user> rm test
> rm: remove write-protected file `test'? y
> user> ls test
> ls: test: No such file or directory
> 
> This is in the user home directory.
> Since the file is read only for the user, it should not be able to remove
> it. Moreover, the user can't write to test.
> So I think this is a bug.

You don't need write perms on a file to remove it, you need write perms on the
directory.  If you've got write permissions on the directory, you can remove
any file in the directory, regardless of the permissions.

-Justin

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Bug in the file attributes ?
  2001-03-29 20:20 Xavier Ordoquy
  2001-03-29 18:44 ` Andreas Dilger
@ 2001-03-29 18:45 ` Stephen Clouse
  2001-03-29 18:51 ` Justin Carlson
  2 siblings, 0 replies; 9+ messages in thread
From: Stephen Clouse @ 2001-03-29 18:45 UTC (permalink / raw)
  To: Xavier Ordoquy; +Cc: linux-kernel

[-- Attachment #1: msg.pgp --]
[-- Type: text/plain, Size: 724 bytes --]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, Mar 29, 2001 at 08:20:32PM +0000, Xavier Ordoquy wrote:
> This is in the user home directory.
> Since the file is read only for the user, it should not be able to remove
> it. Moreover, the user can't write to test.
> So I think this is a bug.

You have failed to RTFM.  There is no bug here.

http://www.linuxdoc.org/FAQ/Linux-FAQ/x1955.html#AEN2242

- -- 
Stephen Clouse <stephenc@theiqgroup.com>
Senior Programmer, IQ Coordinator Project Lead
The IQ Group, Inc. <http://www.theiqgroup.com/>

-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.8

iQA/AwUBOsOC1gOGqGs0PadnEQJtVwCgm23nRu0O14SwWvxjZDulld8m24YAn2vb
yHGvzJR10oC1dabikTezfX+3
=TlMz
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Bug in the file attributes ?
  2001-03-29 20:20 Xavier Ordoquy
@ 2001-03-29 18:44 ` Andreas Dilger
  2001-03-29 20:56   ` Xavier Ordoquy
  2001-03-29 22:57   ` Brian Beattie
  2001-03-29 18:45 ` Stephen Clouse
  2001-03-29 18:51 ` Justin Carlson
  2 siblings, 2 replies; 9+ messages in thread
From: Andreas Dilger @ 2001-03-29 18:44 UTC (permalink / raw)
  To: Xavier Ordoquy; +Cc: linux-kernel

Xavier Ordoquy writes:
> I just made a manipulation that disturbs me. So I'm asking whether it's a
> bug or a features.
> 
> user> su
> root> echo "test" > test
> root> ls -l
> -rw-r--r--   1 root     root            5 Mar 29 19:14 test
> root> exit
> user> rm test
> rm: remove write-protected file `test'? y
> user> ls test
> ls: test: No such file or directory
> 
> This is in the user home directory.
> Since the file is read only for the user, it should not be able to remove
> it. Moreover, the user can't write to test.

This is definitely not a bug.  Deleting a file (under *nix) does not
"modify" the file at all, it is modifying the directory where the file
resides.  In this case, a user _will_ have permission to write into
their home directory, so they can delete the file, but not modify it.

Why do such a thing?  If you have group/world write permission on a
directory, then people who have write permission to the _directory_
should be able to delete files even if they don't own them.  However,
if you set the "sticky" bit on the directory (chmod +t /dir), then only
the owner of the file can delete it, like in /tmp.

Cheers, Andreas
-- 
Andreas Dilger  \ "If a man ate a pound of pasta and a pound of antipasto,
                 \  would they cancel out, leaving him still hungry?"
http://www-mddsp.enel.ucalgary.ca/People/adilger/               -- Dogbert

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2001-03-30  2:35 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-29 19:25 Bug in the file attributes ? Jesse Pollard
2001-03-29 20:20 Xavier Ordoquy
2001-03-29 18:44 ` Andreas Dilger
2001-03-29 20:56   ` Xavier Ordoquy
2001-03-29 19:04     ` John Jasen
2001-03-29 22:57   ` Brian Beattie
2001-03-29 18:45 ` Stephen Clouse
2001-03-29 18:51 ` Justin Carlson
2001-03-30  2:34   ` Tim Wright

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).