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-27-2016, 11:35 AM   #1
hopeless_n00b
LQ Newbie
 
Registered: Aug 2014
Posts: 11

Rep: Reputation: Disabled
[SOLVED] file permissions


Let me be user_A who executes:

> sudo -u user_B rm /home/user_B/foo
> sudo -u user_B touch /home/user_B/foo

All seemingly works well; the file is created as evidenced by

> sudo -u user_B ls -l /home/user_B/foo
-rw------- 1 user_B user_B 0 Oct 27 14:52 /home/user_B/foo

The question is: How can I make it happen (assuming I have root access) that when /home/user_B/foo is created, the user_B group automagically has read and write permissions... i.e., the following would happen

> sudo -u user_B ls -l /home/user_B/foo
-rw-rw---- 1 user_B user_B 0 Oct 27 14:52 /home/user_B/foo

Last edited by hopeless_n00b; 10-27-2016 at 05:57 PM. Reason: hoplessly botched my first attempt at describing the issue
 
Old 10-27-2016, 01:05 PM   #2
Habitual
LQ Addict
 
Registered: Jan 2011
Posts: 7,809
Blog Entries: 11

Rep: Reputation: 2104Reputation: 2104Reputation: 2104Reputation: 2104Reputation: 2104Reputation: 2104Reputation: 2104Reputation: 2104Reputation: 2104Reputation: 2104Reputation: 2104
Maybe tell us what you are willing to do?
 
Old 10-27-2016, 01:14 PM   #3
Turbocapitalist
Senior Member
 
Registered: Apr 2005
Distribution: Ubuntu, Devuan, OpenBSD
Posts: 1,618
Blog Entries: 3

Rep: Reputation: 692Reputation: 692Reputation: 692Reputation: 692Reputation: 692Reputation: 692
I wrote up something similar to this in a blog post, https://www.linuxquestions.org/quest...e-users-37043/

How close does that get you to your goal? The changes there apply only to the directories you choose and then only the users in the designated group would get write access, not all of the users.
 
1 members found this post helpful.
Old 10-27-2016, 02:13 PM   #4
hopeless_n00b
LQ Newbie
 
Registered: Aug 2014
Posts: 11

Original Poster
Rep: Reputation: Disabled
write access still denied

I figured out how to edit my question, and so moved the revision (which was here) to the top so that people reading the post would have a more accurate idea of my issue.

Upon following the link in the third post above, I came to appreciate that when user_A executes

> sudo -u user_B touch /home/user_B/foo

it is the umask of user_A that has an influence on the result: if the umask of user_A is 0000 then

> sudo -u user_B ls -l /home/user_B/foo
-rw-r----- 1 user_B user_B 0 Oct 27 14:52 /home/user_B/foo

I remain mystified as to why write access is denied the user_B group (by the way, I did chmod g+s on directories as advised).

Moreover, User_A does not wish to have umask 0000 . Is there a way around that without Access control lists?

Last edited by hopeless_n00b; 10-27-2016 at 03:26 PM. Reason: making my posts more coherent
 
Old 10-27-2016, 02:16 PM   #5
Turbocapitalist
Senior Member
 
Registered: Apr 2005
Distribution: Ubuntu, Devuan, OpenBSD
Posts: 1,618
Blog Entries: 3

Rep: Reputation: 692Reputation: 692Reputation: 692Reputation: 692Reputation: 692Reputation: 692
Quote:
Originally Posted by hopeless_n00b View Post
The question is: How can I make it happen (assuming I have root access) that when /home/user_B/foo is created, the user_B group automagically has read and write permissions... i.e., the following would happen

> sudo -u user_B ls -l /home/user_B/foo
-rw-rw---- 1 user_B user_B 0 Oct 27 14:52 /home/user_B/foo
The gist is that you set the setGID bit for that directory and that the directory is using a group that user_B is a member of. But depending on your umask, you might have to do other tricks. Try the link in #3 above.
 
Old 10-27-2016, 03:51 PM   #6
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 3,329

Rep: Reputation: 575Reputation: 575Reputation: 575Reputation: 575Reputation: 575Reputation: 575
Quote:
Originally Posted by Habitual View Post
Maybe tell us what you are willing to do?
what he is willing to do?

what you got in mind. yo?
 
Old 10-27-2016, 04:21 PM   #7
hopeless_n00b
LQ Newbie
 
Registered: Aug 2014
Posts: 11

Original Poster
Rep: Reputation: Disabled
Smile reply to BW-userx

I'm trying to do that which is described in the top post
 
Old 10-27-2016, 05:00 PM   #8
hopeless_n00b
LQ Newbie
 
Registered: Aug 2014
Posts: 11

Original Poster
Rep: Reputation: Disabled
O.K., user_A can have whatever umask wanted, but have it temporarily set to 0000 as follows

> ( umask 0000 ; sudo -u user_B touch /home/user_B/foo )

When the above command finishes the umask for user_A is unchanged, and

> sudo -u user_B ls -l /home/user_B/foo
-rw-r--r-- 1 user_B user_B 0 Oct 27 17:53 /home/user_B/foo

So I almost have a solution... But how can I automagicaly get write permission for the user_B group ?

Last edited by hopeless_n00b; 10-27-2016 at 05:02 PM.
 
Old 10-27-2016, 05:55 PM   #9
hopeless_n00b
LQ Newbie
 
Registered: Aug 2014
Posts: 11

Original Poster
Rep: Reputation: Disabled
Smile need to modify sudo line

FINALLY !!!

The following succeeds:

> ( umask 0000 ; sudo -u ff -- sh -c '( umask 0000 ; touch /home/ff/foo )' )

Thanks to Turbocapitalist who got me thinking in the right direction
 
Old 10-27-2016, 10:23 PM   #10
Turbocapitalist
Senior Member
 
Registered: Apr 2005
Distribution: Ubuntu, Devuan, OpenBSD
Posts: 1,618
Blog Entries: 3

Rep: Reputation: 692Reputation: 692Reputation: 692Reputation: 692Reputation: 692Reputation: 692
Quote:
Originally Posted by hopeless_n00b View Post
> ( umask 0000 ; sudo -u ff -- sh -c '( umask 0000 ; touch /home/ff/foo )' )
That'll give write access to everybody, not just those in your group. Setting the umask is only incidental to using the right group name and using the SetGID bit. If you do set it, it might be 0002 or something. It is the group and SetGID bit that do the work 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
File permissions question - Cento & Ubuntu / same file / same permissions but... Robert.Thompson Linux - Newbie 10 03-17-2016 09:49 AM
File Permissions- Once again the Permissions questions?? fusionstate Linux - Newbie 2 01-04-2014 12:47 PM
chmod: changing permissions of `/usr../bin': Read-only file File System Issue cdhar Linux - Newbie 3 12-31-2012 06:17 AM
File permissions v. directory permissions Completely Clueless Linux - Newbie 7 07-09-2009 08:33 AM
file permissions OK, but command permissions? stabu Linux - General 2 10-05-2005 12:00 PM


All times are GMT -5. The time now is 10:44 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration