Gentoo Archives: gentoo-user

From: Alan Mackenzie <acm@×××.de>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] A non-root user can delete files belonging to root. What's going on?
Date: Fri, 13 Feb 2015 22:06:07
Message-Id: 20150213220526.GB26599@acm.fritz.box
In Reply to: Re: [gentoo-user] A non-root user can delete files belonging to root. What's going on? by Alan McKinnon
1 Hello, Alan.
2
3 On Fri, Feb 13, 2015 at 08:20:13PM +0200, Alan McKinnon wrote:
4 > On 13/02/2015 16:31, Alan Mackenzie wrote:
5 > > Hi, Gentoo.
6
7 > > I'm clearing out dross from my home directory, as me (not as root) and
8 > > I've just deleted this file:
9
10 > > -rw-r--r-- 1 root root 0 Apr 11 2011 grep
11
12 > > , simply by typing $ rm grep. I was prompted with:
13
14 > > rm: remove write-protected regular empty file ■grep■?
15
16 > > , to which I responded 'y'. The file is now gone.
17
18 > > So, as a non root user, I've managed to delete a file belonging to root,
19 > > to which I have no write access. This is crazy! I'm not happy about
20 > > this. What's going on?
21
22
23
24 > Nothing is going on, the system is working as designed and is doing it
25 > correctly. It's not the permissions of a file that apply to deletion,
26 > it's the permissions of the directory it's in. Because that's all a
27 > delete is - remove one linee from the directory index and the file goes
28 > away.
29
30 Ah. OK. That seems fairly straighforward to grasp.
31
32 > It's also the exact opposite of creating the file, how does that work?
33 > Well you can't have write permissions yet on a file that has not been
34 > created, the permissions must be the directory. Same with delete.
35
36 > Trust me, there is no arguing with this - Unix has always worked this
37 > way and likely always will.
38
39 :-) I ask myself, how come I've got this far without learning this
40 pretty basic fact?
41
42 Thanks for the explanation.
43
44 > --
45 > Alan McKinnon
46 > alan.mckinnon@×××××.com
47
48 --
49 Alan Mackenzie (Nuremberg, Germany).

Replies

Subject Author
Re: [gentoo-user] A non-root user can delete files belonging to root. What's going on? Alan McKinnon <alan.mckinnon@×××××.com>