Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've run into a perplexing problem where user permissions are not being respected on a Linux computer. Other users are able to move and delete files they don't own. Is there a way to restrict this? Why is this happening? Here's an example.

# Become user jen
[root@localhost test]# su jen

# Display files in the current directory
[jen@localhost test]$ ls -al
total 24
drwxrwxrwx.  3 root root  4096 Apr 10 09:49 .
dr-xr-xr-x. 19 root root  4096 Apr  9 18:19 ..
drwx------.  2 root root 16384 Apr  9 16:15 lost+found

[jen@localhost test]$ touch jen_file
[jen@localhost test]$ ls -l
total 16
-rw-rw-r--. 1 jen jen     0 Apr 10 09:50 jen_file
drwx------. 2 root root 16384 Apr  9 16:15 lost+found

# Exit user jen and become user mike
[jen@localhost test]$ exit
[root@localhost test]# su mike

# Try to modify jen's file as mike. Permission denied, like normal.
[mike@localhost test]$ echo "test" > jen_file
bash: jen_file: Permission denied

# User mike can move jen's file! This should not happen.
[mike@localhost test]$ mv jen_file mike_file
[mike@localhost test]$ ls -l
total 16
-rw-rw-r--. 1 jen jen     0 Apr 10 09:50 mike_file
drwx------. 2 root root 16384 Apr  9 16:15 lost+found

# User mike can delete jen's file. This definately should not happen!
[mike@localhost test]$ rm -f mike_file
[mike@localhost test]$ ls -l
total 16
drwx------. 2 root root 16384 Apr  9 16:15 lost+found

Not sure if it's relevant, but here is the fstab line for the mounted partition (where this test is being run):

# Device name           Mount point   Type   Attributes                     Dump   Check
/dev/mapper/vg00-test   /test         ext4   defaults,acl,user_xattr,nodev  0      3
share|improve this question
1  
You can 'fix' this with chmod o-rwx /home/jen (which is currently set to d rwx rwx rwx . 3 root root 4096 Apr 10 09:49 . (The rights relevant for Mike and everybody else are bolded). The real question here is how a directory in /home got that way, and how the rights are on the other home directories. –  Hennes Apr 10 '13 at 14:14
    
@Hennes: This would prevent jen from accessing the file as well, unless she is in the root group, as now she can't even cd into this directory. –  Sven Apr 10 '13 at 14:16
    
@Hennes: Also, no one mentions /home, this is all happening on /test. –  Sven Apr 10 '13 at 14:18
    
Good point on both of them. As to the first: I guess I am used to su - username which would also change the dir to ~jen. It took me a while to realise the dash was not present. –  Hennes Apr 10 '13 at 14:19
    
Maybe it's worth to check the ACL permissions?: # getfacl /home/jen –  b13n1u Apr 10 '13 at 14:24

2 Answers 2

up vote 5 down vote accepted

Actually, this is working as expected. The 'mv' consists of a read operation, which mike is allowed to do by the o+r, a write, which mike is allowed to do by o+rwx on the directory, and a delete, which mike is allowed to do by o+rwx on the directory. To get the behavior you're looking for, chmod the directory to mode 1777.

share|improve this answer
2  
To add a bit of explanation: mode 1777 set the sticky bit, which restrict file system operations on a file to the owner of the file`. –  Sven Apr 10 '13 at 14:23

You are misunderstanding the permission concept.

Move and delete are operations on the directory, not on the file. And mike has read/write permission for the directory.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.