LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 05-02-2020, 01:18 PM   #1
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,141

Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
Trouble with write access and groups.


Code:
$ groups
jason adm sudo kvm libvirt lxd windowsbackup
Code:
ls -al
total 8
drwxrwxr-x 2 root  windowsbackup 4096 May  2 11:14 .
drwxr-xr-x 5 jason jason         4096 May  2 10:49 ..
Code:
$ touch indeed
touch: cannot touch 'indeed': Permission denied
Code:
$ newgrp windowsbackup
$ touch indeed
ls -l
total 0
-rw-rw-r-- 1 jason windowsbackup 0 May  2 11:12 indeed
I am so confused. I figured this should be simple. I'm clearly a member of the group. The permissions on the directory are 775. I can't write to the directory. I've logged out and in several times. I can however write just fine after using
Code:
newgrp windowsbackup
I've done nothing involving special acls or anything.
I've hit this before but I've never tested with the newgrp command. So if it doesn't ask me for a password on the newgrp command, then I'm a member of the group... but I can't write anything? As wrong as it is I've bypassed by just tossing 777 and leaving it. But it bugs the hell out of me. I've posted this issue elsewhere and get nowhere. Google just says chmod 775 and chgrp the folder.

Last edited by jmgibson1981; 05-02-2020 at 01:56 PM.
 
Old 05-02-2020, 01:53 PM   #2
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by jmgibson1981 View Post
$ touch indeed
touch: cannot touch 'indeed': Permission denied
Ar this moment you're in group "jason", which doesn't have write access to the . directory.

Quote:
$ newgrp windowsbackup
$ touch indeed
But now you have changed your group to windowsbackup, so now the touch works.

That you're allowed to use the "newgrp" command without a password is because you are in both groups already. But now the default group for your session is that one, not jason anymore:
Quote:
newgrp changes the current real group ID to the named group, or to the default group listed in /etc/passwd if no group name is given. newgrp also tries to add the group to the user groupset.
But a file (or directory) can be given only a single group ID and that is the "real group ID" of the session, which starts as the one, listed in /etc/passwd
To revert to that default afterwards, you can just issue the command "newgrp" without any parameters.
 
Old 05-02-2020, 02:30 PM   #3
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,141

Original Poster
Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
Ok. I'll have to rework my script. Logic tells me if you have a group membership, you should be able to do what it allows by default. But doesn't work for directories I guess?

Last edited by jmgibson1981; 05-02-2020 at 02:33 PM.
 
Old 05-02-2020, 03:27 PM   #4
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by jmgibson1981 View Post
Ok. I'll have to rework my script. Logic tells me if you have a group membership, you should be able to do what it allows by default. But doesn't work for directories I guess?
It should work for existing files, so you can "touch" a file IN that directory when it has the right group, but for creating NEW files (and subdirs) it can only use a single group (the "real session group ID") to create that file with. And that real group ID of the touch command does not have write permission to that dir as the groups are different.
You, the user, have multiple groups YOU belong too, but a process (like touch), just like a file or directory, can have only a single group ID, which normally is your primary one (the one you logged in with). Thus a process does NOT inherit all of your groups.

Last edited by ehartman; 05-02-2020 at 03:29 PM.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
groups within groups and sshd_config allow_groups td3201 Linux - Server 6 07-25-2009 09:43 AM
System Groups from Users and Groups measekite Linux - General 3 05-05-2009 09:22 PM
Permissions: giving specific groups write access to a directory kinetik Linux - General 3 07-06-2006 08:30 AM
winbind: wbinfo -g only lists global groups from PDC and not local groups saradiya Linux - Networking 0 12-01-2003 02:58 AM
Groups members of other groups bentz Linux - Security 6 06-22-2003 11:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:46 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