LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-15-2009, 05:50 PM   #1
melcataclysm
LQ Newbie
 
Registered: Apr 2008
Posts: 3

Rep: Reputation: 0
why can I remove files owned by another user in a directory of mine?


Hi all.
In my system I have two users, "user1" and "user2", that belong to a group "grp"

I also have a directory "dir" with these permissions:
dir drwxrwxr-x user1 grp

If in this directory user1 create a file "test" owned only by him:
test rw-rw-r-- user1 user1
why user2 can delete this file (after a prompt)?


Thank you!

Alessandro
 
Old 10-15-2009, 06:22 PM   #2
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 271Reputation: 271Reputation: 271
Did you check if user2 is part of group "user1"? Because it looks like group "user1" also has write permission (which included delete).
 
Old 10-15-2009, 06:46 PM   #3
mstng_67
LQ Newbie
 
Registered: Sep 2009
Posts: 9

Rep: Reputation: 0
Quote:
that belong to a group "grp"
Alessandro,

Herein lies your problem. Both users belong to the same group; and that group has the exact same permissions as the file's owner (user1) in your case. Both user1 and grp have rw permissions..meaning that any user in "grp" will be able to modify/delete the file. To solve the problem either:

a) restrict the group permissions on the directory or the individual file (perhaps to read-only.)

b) remove user2 from "grp"; and, therefore, user2's permission to delete the file.

Best,

Micheal

Last edited by mstng_67; 10-15-2009 at 06:47 PM.
 
Old 10-15-2009, 06:52 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Dir group write perms = ability to delete a file
http://en.wikipedia.org/wiki/File_system_permissions
http://www.zzee.com/solutions/linux-...k_9_1077830297

Both users are in group grp, according to OP.
 
Old 10-18-2009, 06:41 AM   #5
melcataclysm
LQ Newbie
 
Registered: Apr 2008
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by mstng_67 View Post
Alessandro,

Herein lies your problem. Both users belong to the same group; and that group has the exact same permissions as the file's owner (user1) in your case. Both user1 and grp have rw permissions..meaning that any user in "grp" will be able to modify/delete the file. To solve the problem either:

a) restrict the group permissions on the directory or the individual file (perhaps to read-only.)

b) remove user2 from "grp"; and, therefore, user2's permission to delete the file.

Best,

Micheal
mmmh...
but my file is owned only by user user1 and group user1.
For what I understand you are meaning that even if the file is owned by user1 and user1 group, user2 can delete it because user1 and user2 are in the same group grp? (I hope to be understable)
Remember that the file has these permissions:

test rw-rw-r-- user1 user1
 
Old 10-18-2009, 07:06 AM   #6
GazL
Senior Member
 
Registered: May 2008
Posts: 4,084
Blog Entries: 1

Rep: Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530Reputation: 1530
File creation/deletion is controlled by directory permissions. Unless you use a sticky bit, file ownership doesn't matter.

If you want to restrict file deletion to the owner only you need to set the sticky bit on the directory. I'd also suggest sgid in your case to force files into the correct group,

Code:
chown root:grp dir
chmod 3775 dir
I make the directory ownership root, to put all members of grp on an even footing, though you can use any other user for this. All access to the dir will be controlled by grp.

Give that a try, see if it meets your needs.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
User Home Directory now owned bt Root AndeAnderson Linux - Newbie 4 10-09-2009 04:52 PM
is there a way to list all files owned by a user? KingPanda Debian 3 10-29-2008 09:16 PM
Tiger checks Ubuntu get fail message root directory owned by user argh2xxx Linux - Security 2 10-20-2008 10:33 AM
Can you make any files and folders created within a directory owned by another user?? helptonewbie Linux - Newbie 13 12-14-2007 05:21 PM
user access to files owned by root jonfa Linux - General 2 07-09-2007 12:58 PM


All times are GMT -5. The time now is 10:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration