1 |
On 13/02/2015 16:31, Alan Mackenzie wrote: |
2 |
> Hi, Gentoo. |
3 |
> |
4 |
> I'm clearing out dross from my home directory, as me (not as root) and |
5 |
> I've just deleted this file: |
6 |
> |
7 |
> -rw-r--r-- 1 root root 0 Apr 11 2011 grep |
8 |
> |
9 |
> , simply by typing $ rm grep. I was prompted with: |
10 |
> |
11 |
> rm: remove write-protected regular empty file ■grep■? |
12 |
> |
13 |
> , to which I responded 'y'. The file is now gone. |
14 |
> |
15 |
> So, as a non root user, I've managed to delete a file belonging to root, |
16 |
> to which I have no write access. This is crazy! I'm not happy about |
17 |
> this. What's going on? |
18 |
> |
19 |
|
20 |
|
21 |
Nothing is going on, the system is working as designed and is doing it |
22 |
correctly. It's not the permissions of a file that apply to deletion, |
23 |
it's the permissions of the directory it's in. Because that's all a |
24 |
delete is - remove one linee from the directory index and the file goes |
25 |
away. |
26 |
|
27 |
It's also the exact opposite of creating the file, how does that work? |
28 |
Well you can't have write permissions yet on a file that has not been |
29 |
created, the permissions must be the directory. Same with delete. |
30 |
|
31 |
Trust me, there is no arguing with this - Unix has always worked this |
32 |
way and likely always will. |
33 |
|
34 |
-- |
35 |
Alan McKinnon |
36 |
alan.mckinnon@×××××.com |