baudolino Posted November 5, 2002 Report Share Posted November 5, 2002 [baudolino]$ ls -l total 4 -rw-r--r-- 1 root root 8 Nov 4 19:48 cannotDELETEme [baudolino]$ whoami baudolino [baudolino]$ groups baudolino graal [baudolino]$ rm cannotDELETEme rm: remove write-protected regular file `cannotDELETEme'? y [baudolino]$ ls -l total 0 [baudolino]$ Since I am not root and I do not belong to group root, my permissions regarding the file cannotDELETEme are r---. How come am I allowed to delete the file? Quote Link to comment Share on other sites More sharing options...
beesea Posted November 5, 2002 Report Share Posted November 5, 2002 type su and then enter in the root password. then you'll be able to delete the file Quote Link to comment Share on other sites More sharing options...
baudolino Posted November 5, 2002 Author Report Share Posted November 5, 2002 As you can see from the attached code, I can delete the file without using su. What I want is an explanation why, although I don't have the correct permissions, I can still delete the file. Quote Link to comment Share on other sites More sharing options...
beesea Posted November 6, 2002 Report Share Posted November 6, 2002 sorry bout that, misread what you wrote Quote Link to comment Share on other sites More sharing options...
Cannonfodder Posted November 6, 2002 Report Share Posted November 6, 2002 One possibility may be your /etc/fstab file. Do you have mount permissions setup in there for your user id? I'm stretching here so don't laugh at me :P Quote Link to comment Share on other sites More sharing options...
theYinYeti Posted November 6, 2002 Report Share Posted November 6, 2002 Let's talk about permissions, files, and directories. If you have the 'r' right for a file, then you can view its content. If you have the 'w' right for a file, then you can modify its content. If you have the 'x' right for a file, then you can execute the file. If you have the 'r' right for a directory, then you can view its content (view what files are there). If you have the 'w' right for a directory, then you can modify its content (add or remove files). If you have the 'x' right for a directory, then you can enter the directory, and try to go further in it (nested directories and files). You can remove any file you don't own in a directory you have the right to write in, eg a file created by root in your home directory. Yves. Quote Link to comment Share on other sites More sharing options...
static Posted November 6, 2002 Report Share Posted November 6, 2002 Hey Yves - I am pretty certain that when I, as root, create something in /home/static, static can't delete it. (Maybe I'm wrong, but I seem to remember..) This could be a problem with userid's. If baudolino has the same uid as root this will happen. PS Newbies take note: The original post is very neat and easy to follow. Excellent structure - makes it easier for us to help ;O) Quote Link to comment Share on other sites More sharing options...
chalex20 Posted November 6, 2002 Report Share Posted November 6, 2002 Hey Yves - I am pretty certain that when I, as root, create something in /home/static, static can't delete it. (Maybe I'm wrong, but I seem to remember..) This could be a problem with userid's. If baudolino has the same uid as root this will happen. PS Newbies take note: The original post is very neat and easy to follow. Excellent structure - makes it easier for us to help ;O) I've performed such test on my own machine. [alex@linux alex]$ ls -l somefile -rw-r--r-- 1 root root 0 Nov 6 17:10 somefile [alex@linux alex]$ rm somefile rm: remove write-protected regular empty file `somefile'? y [alex@linux alex]$ ls -l somefile ls: somefile: No such file or directory [alex@linux alex]$ id uid=501(alex) You're surely wrong :-) . The file was created by root and nevertheless a regular user succeeded to delete it. Pure issue of directory permissions. Quote Link to comment Share on other sites More sharing options...
baudolino Posted November 7, 2002 Author Report Share Posted November 7, 2002 Thanks! I understand now why I was able to delete the file. It looks like permissions are not as straightforward as I thought. Here is another example: [baudolino]$ pwd /home/baudolino/testarea [baudolino]$ id uid=501(baudolino) gid=501(baudolino) groups=501(baudolino),500(graal) [baudolino]$ ls ls: .: Permission denied [baudolino]$ su Password: [root]# ls -la total 12 d-w-r-xr-- 2 baudolino baudolino 4096 Nov 6 23:05 ./ drwxr-xr-x 4 baudolino baudolino 4096 Nov 6 23:08 ../ -rw-r--r-- 1 baudolino baudolino 8 Nov 6 22:16 a [root]# exit exit [baudolino]$ rm a rm: cannot lstat `a': Permission denied [baudolino]$ touch b touch: creating `b': Permission denied [baudolino]$ cat >> a bash: a: Permission denied [baudolino]$ As you can see, I have w permission to both the testarea directory and the a file. I can not write to or modify the file a. I can not create another file in the testarea directory. From my experiments, it looks like I need either -wx or rwx in the testarea directory to remove, modify the a file. I need the same permissions to create a new file in testarea. I wonder about the meaning of r, w, and x for a link, a pipe, a character device or a block device. I will do some experiments tonight on this, but let me know if you already know it! Thanks again! Quote Link to comment Share on other sites More sharing options...
static Posted November 7, 2002 Report Share Posted November 7, 2002 You're surely wrong :-) . The file was created by root and nevertheless a regular user succeeded to delete it. Pure issue of directory permissions. Well Sorrrryy! I did mention I could have been wrong... ;) You learn something everyday. Quote Link to comment Share on other sites More sharing options...
Counterspy Posted November 8, 2002 Report Share Posted November 8, 2002 You might want to look at the Permissions section at http://www.mandrakeuser.org. Counterspy Quote Link to comment Share on other sites More sharing options...
baudolino Posted November 8, 2002 Author Report Share Posted November 8, 2002 I looked in there, but I could not find anything regarding the meaning of the permissions for links, pipes, character devices, block devices or sockets. If you know a specific web link about this topic, please post the exact address. In the meanwhile, if somebody is interested, here is what I found out about permissions for links and pipes. Here is one (long and successful) experiment: [baudolino]$ id uid=501(baudolino) gid=501(baudolino) groups=501(baudolino),500(graal) [baudolino]$ ls -li total 4 224926 -rwxr--r-- 1 baudolino baudolino 4 Nov 7 23:56 a [baudolino]$ cat a abc [baudolino]$ cat >>a <<"EOF" > def > EOF [baudolino]$ cat a abc def [baudolino]$ ln -s a b [baudolino]$ ln a c [baudolino]$ ls -li total 8 224926 -rwxr--r-- 2 baudolino baudolino 8 Nov 7 23:57 a 224931 lrwxrwxrwx 1 baudolino baudolino 1 Nov 7 23:57 b -> a 224926 -rwxr--r-- 2 baudolino baudolino 8 Nov 7 23:57 c [baudolino]$ cat b abc def [baudolino]$ cat c abc def [baudolino]$ chmod u=r c [baudolino]$ ls -li total 8 224926 -r--r--r-- 2 baudolino baudolino 8 Nov 7 23:57 a 224931 lrwxrwxrwx 1 baudolino baudolino 1 Nov 7 23:57 b -> a 224926 -r--r--r-- 2 baudolino baudolino 8 Nov 7 23:57 c [baudolino]$ cat b abc def [baudolino]$ cat c abc def [baudolino]$ cat >>b <<"EOF" > xxx > EOF bash: b: Permission denied [baudolino]$ cat >>c <<"EOF" > yyy > EOF bash: c: Permission denied [baudolino]$ cat b abc def [baudolino]$ cat c abc def [baudolino]$ chmod u=w b [baudolino]$ ls -li total 8 224926 --w-r--r-- 2 baudolino baudolino 8 Nov 7 23:57 a 224931 lrwxrwxrwx 1 baudolino baudolino 1 Nov 7 23:57 b -> a 224926 --w-r--r-- 2 baudolino baudolino 8 Nov 7 23:57 c [baudolino]$ cat >>b <<"EOF" > 123 > EOF [baudolino]$ cat b cat: b: Permission denied [baudolino]$ cat >>c <<"EOF" > 456 > EOF [baudolino]$ cat c cat: c: Permission denied [baudolino]$ chmod u=rwx b [baudolino]$ ls -li total 8 224926 -rwxr--r-- 2 baudolino baudolino 16 Nov 8 00:01 a 224931 lrwxrwxrwx 1 baudolino baudolino 1 Nov 7 23:57 b -> a 224926 -rwxr--r-- 2 baudolino baudolino 16 Nov 8 00:01 c [baudolino]$ cat b abc def 123 456 [baudolino]$ 1. No mater what I tried, the permissionsof the soft link (B) are always lrwxrwxrwx. Changing the permission of a soft link changes the permission of the target (a). 2. The hard links (a and c) have always the same permissions. 3. The permissions of the soft link (B) are given not by its own permissions (which seem always to be lrwxrwxrwx), but on the permissions of the target(a). Does anybody know how to change the permissions of a soft link (b, in the example above) without changing the permissions of the target (a, in the example above)? The example below shows that it possible, but I don't know how. [baudolino]$ ls -l /dev/modem lr-xr-xr-x 1 root root 5 Nov 7 17:17 /dev/modem ->tts/4 [baudolino]$ ls -l /dev/tts/4 crw-rw---- 1 baudolino tty 4, 68 Nov 7 23:10 /dev/tts/4 [baudolino]$ Regarding the permissions of pipes, the r right means that you can put new stuff in the pipe or you can completely change the content of the pipe and the w right means that you can take out all the stuff from the pipe. What I don't know is what is the meaning of the x right for a pipe (if there is a meaning). Sorry for the long post, but I thought somebody might find it interesting, just like I did. Quote Link to comment Share on other sites More sharing options...
theYinYeti Posted November 13, 2002 Report Share Posted November 13, 2002 :-) Ah Ah You beat me :lol: I can't explain those questions. There must be some explanation though. (For soft links, I wondered the same myself). Good luck, and tell us what you discover. Bye, Yves. Quote Link to comment Share on other sites More sharing options...
Counterspy Posted November 13, 2002 Report Share Posted November 13, 2002 Since you seem to have run out of suggestions here, try posting this question in the newsgroup alt.os.linux.mandrake. There is a much larger group of problem solvers there. Counterspy Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.