2

I have two users : bob and sally, who resepctively own two files : bob100 and sally100:

> ls -altrh /path/to/dir : 

-rw-r--r--. 1 bob   test    0 Jan  7 12:59 bob100
-rw-r--r--. 1 sally test    0 Jan  7 13:06 sally100
drwxrwxrwx. 8 root  root 4.1K Jan  7 13:06 .

However, BOB can delete files in SALLY's account:

> runuser -l bob -c 'rm -f /path/to/dir/sally100'

Why is it that bob is allowed to delete a file which clearly only sally has write permissions on?

8

Because group/others have write permissions on a parent directory. File deletion is actually unlinking it from the directory. The directory is being modified, not the file.

0

If you want to afford some protection to files in a shared directory, set the sticky bit on the directory (i.e. chmod +t mydir). When the sticky bit is set for a directory, only 'root' or the owner of a file may unlink (delete) it. Usually, this bit is on for /tmp and /var/tmp.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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