Re: [gentoo-user] A non-root user can delete files belonging to root. What's going on?

2015-02-14 Thread Neil Bothwick
On Sat, 14 Feb 2015 08:39:27 +0200, Alan McKinnon wrote:

 Don't feel too bad, it's one of my favourite geeky Unix trivia factoid
 questions. In 10 years, no-one yet has given the correct answer
 immediately!

You need to ask better people :P
 
 It's also very rare to have a file owned by root in a user directory,
 and even rarer for the user to spot the oddity. Most folks just don;t
 need to know that level of detail

I most often see it when editing a user config file as root. The file
keeps the original ownership but the ~ backu file is created and owned by
root.


-- 
Neil Bothwick

-Come, come, why they couldn't hit an elephant from this dist-


pgpINhFZ7MOFx.pgp
Description: OpenPGP digital signature


Re: [gentoo-user] A non-root user can delete files belonging to root. What's going on?

2015-02-13 Thread Rich Freeman
On Fri, Feb 13, 2015 at 9:36 AM, Yuri K. Shatroff yks-...@yandex.ru wrote:

 The owner of a directory is able to delete any files in it. It would really
 be weird otherwise.


I think, to be more precise, anybody with write and execute access to
a directory (whether the owner or not) can remove files from a
directory, unless the directory's sticky bit is set.  If the sticky
bit is set then only the owner of the directory can remove files not
owned by themselves (ie, for /tmp).  I believe having write access to
the file itself is also sufficient to delete it.

-- 
Rich



Re: [gentoo-user] A non-root user can delete files belonging to root. What's going on?

2015-02-13 Thread Yuri K. Shatroff

13.02.2015 17:31, Alan Mackenzie пишет:

Hi, Gentoo.

I'm clearing out dross from my home directory, as me (not as root) and
I've just deleted this file:

 -rw-r--r--  1 rootroot   0 Apr 11  2011 grep

, simply by typing $ rm grep.  I was prompted with:

 rm: remove write-protected regular empty file ■grep■?

, to which I responded 'y'.  The file is now gone.

So, as a non root user, I've managed to delete a file belonging to root,
to which I have no write access.  This is crazy!  I'm not happy about
this.  What's going on?


The owner of a directory is able to delete any files in it. It would 
really be weird otherwise.


--
Regards,
Yuri K. Shatroff



Re: [gentoo-user] A non-root user can delete files belonging to root. What's going on?

2015-02-13 Thread Alan McKinnon
On 13/02/2015 16:31, Alan Mackenzie wrote:
 Hi, Gentoo.
 
 I'm clearing out dross from my home directory, as me (not as root) and
 I've just deleted this file:
 
 -rw-r--r--  1 rootroot   0 Apr 11  2011 grep
 
 , simply by typing $ rm grep.  I was prompted with:
 
 rm: remove write-protected regular empty file ■grep■?
 
 , to which I responded 'y'.  The file is now gone.
 
 So, as a non root user, I've managed to delete a file belonging to root,
 to which I have no write access.  This is crazy!  I'm not happy about
 this.  What's going on?
 


Nothing is going on, the system is working as designed and is doing it
correctly. It's not the permissions of a file that apply to deletion,
it's the permissions of the directory it's in. Because that's all a
delete is - remove one linee from the directory index and the file goes
away.

It's also the exact opposite of creating the file, how does that work?
Well you can't have write permissions yet on a file that has not been
created, the permissions must be the directory. Same with delete.

Trust me, there is no arguing with this - Unix has always worked this
way and likely always will.

-- 
Alan McKinnon
alan.mckin...@gmail.com




Re: [gentoo-user] A non-root user can delete files belonging to root. What's going on?

2015-02-13 Thread Alan McKinnon
On 14/02/2015 00:05, Alan Mackenzie wrote:
 Trust me, there is no arguing with this - Unix has always worked this
  way and likely always will.
 :-)  I ask myself, how come I've got this far without learning this
 pretty basic fact?
 
 Thanks for the explanation.
 

:-)

Don't feel too bad, it's one of my favourite geeky Unix trivia factoid
questions. In 10 years, no-one yet has given the correct answer immediately!


It's also very rare to have a file owned by root in a user directory,
and even rarer for the user to spot the oddity. Most folks just don;t
need to know that level of detail




-- 
Alan McKinnon
alan.mckin...@gmail.com