LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-15-2014, 10:03 PM   #1
majestik33
LQ Newbie
 
Registered: Aug 2014
Posts: 10

Rep: Reputation: Disabled
Determining the effective file permissions


I would like to ask what are the rules that Linux OS's are using on ext4 file systems when there are conflicts between directory permission and file permissions.

Example:
drwxrwx--- user1 group2 FOLDER
-rw-r--r-- user1 group1 FILE

What permissions a user in a group2 on a file FILE would have?...And what is the general rule for determining file permissions in this situations?

Thanks.
 
Old 08-15-2014, 10:17 PM   #2
notKlaatu
Senior Member
 
Registered: Sep 2010
Location: Lawrence, New Zealand
Distribution: Slackware
Posts: 1,077

Rep: Reputation: 732Reputation: 732Reputation: 732Reputation: 732Reputation: 732Reputation: 732Reputation: 732
There is no conflict.

Group1 owns FILE but group1 will not be able to enter the FOLDER in order to access it

UNLESS

a user is in both GROUP1 and GROUP2

In which case that user will be able to enter the FOLDER via GROUP2 permission access, and read the file either as a member of GROUP1 or OTHER.

Or, obviously, if the user in question is user1.
 
Old 08-15-2014, 10:51 PM   #3
majestik33
LQ Newbie
 
Registered: Aug 2014
Posts: 10

Original Poster
Rep: Reputation: Disabled
User (which is not the same as user1 and dont belongs to group1) will have read, write, execute permissions on the folder and all its content due to its membership in group2, but only read permissons on file FILE because he belongs to world class users. Isnt this a typical folder/file permission conflict?

I tried to change file FILE as user in this set up on Fedora 18 and it did let me modify its content, but the next time I run the command ls -l, what I got was -rw-r--r-- user group1 FILE.
 
Old 08-15-2014, 11:57 PM   #4
notKlaatu
Senior Member
 
Registered: Sep 2010
Location: Lawrence, New Zealand
Distribution: Slackware
Posts: 1,077

Rep: Reputation: 732Reputation: 732Reputation: 732Reputation: 732Reputation: 732Reputation: 732Reputation: 732
You should not be able to modify that file as 'user' with those permissions. Are you sure that 'user' does not belong to group1 ? have you checked with the 'groups' command?

If i have a folder owned by klaatu:users and enter that folder as 'gort', it's OK because gort is in the 'users' group.

However, if I have a file 'foo' in that folder, and foo is owned by klaatu:staff, then as 'gort', I can read the file with cat or a similar command, but if I do something like 'echo bar > foo' then I will get Permission Denied.

I don't think I would call it a "conflict". Maybe looking at a folder's permissions more as a gatekeeper, through which you cannot pass if you do not have the correct permissions. But just because you do have permissions to go inside and look at stuff, it doesn't mean you can change them or use them.

If you really need to understand it, maybe create two users and create two groups. Log in as the first user and create the test environment:

Code:
whoami
> klaatu

groups
users staff blah blah

mkdir /test

chown klaatu:users /test

chmod 770 /test

cd /test

echo "bar" > foo

groups
users staff blah blah

chown klaatu:staff foo

chmod 644 foo

su - gort

whoami
> gort

groups
users blah blah

cd /test

cat foo 
> bar

echo "baz" >> foo 
> -su: /test/foo: Permission denied
 
1 members found this post helpful.
Old 08-16-2014, 12:02 AM   #5
descendant_command
Senior Member
 
Registered: Mar 2012
Posts: 1,876

Rep: Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643
@majestik33 you didn't modify the file - you overwrote it - which you have the permission to do from the 'write' permission on the dir.
 
Old 08-16-2014, 12:48 AM   #6
majestik33
LQ Newbie
 
Registered: Aug 2014
Posts: 10

Original Poster
Rep: Reputation: Disabled
Thats the most probable explenation. Thank you guys, it was very helpful
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
permissions: can you force ACL to be effective OVER unix perms? guruguy Linux - Server 5 02-04-2014 05:58 PM
What is effective user ID and effective group Id Anoop Madhusoodhanan P Linux - Kernel 1 01-11-2010 03:29 PM
Determining a file/directory permissions dudepigeon Linux - General 2 09-21-2009 01:23 PM
ACL effective permissions problem on file copies le_forban Linux - Newbie 4 07-09-2008 07:57 PM
determining file types supersucker Linux - Newbie 2 05-03-2005 12:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:28 PM.

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
Open Source Consulting | Domain Registration