LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 08-20-2012, 08:42 PM   #1
LanFan.BlueSailor
LQ Newbie
 
Registered: Jul 2007
Posts: 6

Rep: Reputation: 0
user removed from one group can still get that group's permission


This is my first post in this forum. Sorry if I posted it in the wrong place.

I use openLDAP for user management. A group foo is used to share some files among the users belong to group foo. The ownership of shared folder is root:foo, and the permission is set to 770. This will make sure that users not in group foo will be denied to access that folder.
For some reasons, the member of group foo varies occasionally. If a new user is added to group foo, a simple re-logon will gives the user correct id and groups, and get the access to the shared folder. Everything works fine.
The issue comes if the user is removed from group foo. After the remove and re-logon, the id and groups say the user is no longer the member of group foo (it should be the case). And this user should no long access that shared folder. However, this user can still cd to that shared folder without a permission denied error message.
So, why user removed from one group can still get that group's permission, even after re-logon.

I tried restart my ldap service to refresh the user info, but no help. Only a reboot of the box will make the user get the right permission. So I think it's could be a user credential cache. But I do not know how to flush it without a reboot.

What should I do to get the right permission? Any help will be appreciated. thx

PS: Seems to be less related, but the shared folder is also a samba share. But the samba share got the right permission after a restart of smb service.
 
Old 08-20-2012, 08:58 PM   #2
LanFan.BlueSailor
LQ Newbie
 
Registered: Jul 2007
Posts: 6

Original Poster
Rep: Reputation: 0
some code details are here.

Code:
drwxrwx--- 2 root pan_res 6 Aug 20 15:47 pan_res
pan_res is the shared folder for all members in group pan_res

Code:
[lanfan@beetle /smb]$ id
uid=1087(lanfan) gid=1001(pan) groups=1001(pan) context=user_u:system_r:unconfined_t
[lanfan@beetle /smb]$ groups
pan
user lanfan is just removed from group pan_res. And id and groups say it's no longer a member of that group

Code:
[lanfan@beetle /smb]$ cd pan_res/
[lanfan@beetle pan_res]$ ls
But I can still cd to that folder without an error.

Code:
[lijs@beetle /smb]$ id
uid=61317(lijs) gid=1001(pan) groups=1001(pan) context=user_u:system_r:unconfined_t
[lijs@beetle /smb]$ groups
pan
[lijs@beetle /smb]$ cd pan_res
pan_res: Permission denied.
For other users not in that group, it received a Permission denied error as expected.
 
Old 08-21-2012, 06:05 AM   #3
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by LanFan.BlueSailor View Post
some code details are here.

Code:
drwxrwx--- 2 root pan_res 6 Aug 20 15:47 pan_res
pan_res is the shared folder for all members in group pan_res

Code:
[lanfan@beetle /smb]$ id
uid=1087(lanfan) gid=1001(pan) groups=1001(pan) context=user_u:system_r:unconfined_t
[lanfan@beetle /smb]$ groups
pan
user lanfan is just removed from group pan_res. And id and groups say it's no longer a member of that group

Code:
[lanfan@beetle /smb]$ cd pan_res/
[lanfan@beetle pan_res]$ ls
But I can still cd to that folder without an error.

Code:
[lijs@beetle /smb]$ id
uid=61317(lijs) gid=1001(pan) groups=1001(pan) context=user_u:system_r:unconfined_t
[lijs@beetle /smb]$ groups
pan
[lijs@beetle /smb]$ cd pan_res
pan_res: Permission denied.
For other users not in that group, it received a Permission denied error as expected.
After you remove lanfan from the pan_res group did you log out and then log in?
Because id program don't show id/group for the current process, it's read /etc/passwd, /etc/group, whatever to get information.
So, while id output may be correct current process STILL may have more privileges that id shows.

By the way, what shared in this folder?
Not always, but often enough need in shared folder indicate that actually some version control needed instead.
 
Old 08-21-2012, 11:38 AM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,774

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by Valery Reznic View Post
Because id program don't show id/group for the current process, it's read /etc/passwd, /etc/group, whatever to get information.
That is demonstrably not true:
Code:
[builder] ~ $ id
uid=505(builder) gid=505(builder) groups=468(mock),505(builder) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[builder] ~ $ newgrp mock
[builder] ~ $ id
uid=505(builder) gid=468(mock) groups=468(mock),505(builder) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
And, after editing /etc/group to remove "builder" from the "mock" group:
Code:
[builder] ~ $ grep mock /etc/group
mock:x:468:rnichols
[builder] ~ $ id
uid=505(builder) gid=468(mock) groups=468(mock),505(builder) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
The id program does read /etc/passwd and /etc/group, but only to map numeric IDs to names.
 
Old 08-21-2012, 12:11 PM   #5
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by rknichols View Post
That is demonstrably not true:
Code:
[builder] ~ $ id
uid=505(builder) gid=505(builder) groups=468(mock),505(builder) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[builder] ~ $ newgrp mock
[builder] ~ $ id
uid=505(builder) gid=468(mock) groups=468(mock),505(builder) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
And, after editing /etc/group to remove "builder" from the "mock" group:
Code:
[builder] ~ $ grep mock /etc/group
mock:x:468:rnichols
[builder] ~ $ id
uid=505(builder) gid=468(mock) groups=468(mock),505(builder) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
The id program does read /etc/passwd and /etc/group, but only to map numeric IDs to names.
You are absolutely right, thank you for correction.
When I run id under strace before posting I somehow missed that it called getgroups.

My bad.
 
Old 08-21-2012, 07:11 PM   #6
LanFan.BlueSailor
LQ Newbie
 
Registered: Jul 2007
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Valery Reznic View Post
After you remove lanfan from the pan_res group did you log out and then log in?
Yes. I do log out and then log in. And user lanfan still have access to pan_res group.

Quote:
Originally Posted by Valery Reznic View Post
By the way, what shared in this folder?
The folder is empty by now. But lanfan can even create/modify files in the shared folder after removed from pan_res group (and re-logon).
 
Old 08-21-2012, 07:24 PM   #7
LanFan.BlueSailor
LQ Newbie
 
Registered: Jul 2007
Posts: 6

Original Poster
Rep: Reputation: 0
I tested on another box using the /etc/passwd and /etc/group for user management instead of openLDAP.

Everything goes fine: After remove user from that group, the user immediately get the permission denied error message.

So I think it's maybe a openLDAP related issue.

Any more suggestion? Any help will be appreciated. thx
 
Old 08-22-2012, 03:36 AM   #8
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by LanFan.BlueSailor View Post
I tested on another box using the /etc/passwd and /etc/group for user management instead of openLDAP.

Everything goes fine: After remove user from that group, the user immediately get the permission denied error message.

So I think it's maybe a openLDAP related issue.

Any more suggestion? Any help will be appreciated. thx
Could you test it
- on the box with openLDAP, but for directory that is not samba share.
- without openLDAP (i.e /etc/passwd, etc/group) but with directory on samba share
?
 
Old 08-22-2012, 09:25 AM   #9
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,632
Blog Entries: 4

Rep: Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931Reputation: 3931
Do you have an openLDAP replication server that is not in sync? Is information previously obtained from LDAP being cached? How exactly do you connect to LDAP?
 
Old 08-22-2012, 07:55 PM   #10
LanFan.BlueSailor
LQ Newbie
 
Registered: Jul 2007
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by sundialsvcs View Post
Do you have an openLDAP replication server that is not in sync?
No replication. Only one openLDAP server.

Quote:
Originally Posted by sundialsvcs View Post
Is information previously obtained from LDAP being cached?
That what I first thought about. I tried to find where it cached the user credential and cleaned it. But I couldn't find where.

Quote:
Originally Posted by sundialsvcs View Post
How exactly do you connect to LDAP?
Actually, I use a tool called authconfig provided by CentOS to setup the LDAP authentication.
I know little about the configuration details.
 
Old 08-22-2012, 08:34 PM   #11
LanFan.BlueSailor
LQ Newbie
 
Registered: Jul 2007
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Valery Reznic View Post
Could you test it
- on the box with openLDAP, but for directory that is not samba share.
- without openLDAP (i.e /etc/passwd, etc/group) but with directory on samba share
?
Things go even more complicated.

I tested on a new directory which is not a samba share, and received the permission denied message correctly.
I added this new directory to a new samba share, and this time received the permission denied message correctly.

Then I found that the previous shared directory is mounted from an NFS.
So, it's neither an openLDAP issue, nor a samba issue. It seems to be an NFS issue. Maybe I mounted this NFS with too high privileges.

I decide to use another share directory which is not from NFS. That's the easiest solution.
For NFS issue, I'll look into it at other times.

Thread solved. Thx for all your helps
 
Old 08-23-2012, 12:32 AM   #12
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Hmm, after all NFS turns out to be culprit. Interesting.

You said before that this shared directory is empty.
But what supposed to be shared here?
 
  


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
Group permissions: user can't access 770 directory even though a member of group jm34003 Linux - Security 13 05-16-2012 02:03 PM
[SOLVED] Permission User&Group Nibaly Linux - Newbie 12 12-11-2011 01:44 PM
[SOLVED] query on user group permission deep27ak Linux - Newbie 5 11-17-2011 06:17 AM
lp permission assign to user group syedali Linux - Desktop 0 08-06-2011 03:17 AM
smb permission for (sub)user group mweil Linux - Networking 0 07-23-2004 07:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 09:53 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
Open Source Consulting | Domain Registration