LinuxQuestions.org
Visit Jeremy's Blog.
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 08-13-2019, 12:16 PM   #1
permaroot
Member
 
Registered: Aug 2019
Location: Arden, NC
Distribution: Manjaro, Centos7, Arch
Posts: 98

Rep: Reputation: 34
Can't get files to inherit execute permission from parent directory


Hey all,

I am trying to set up a directory called Mediashare on my desktop. My hope is to share this directory to any devices on my LAN.

I am trying to make it so that any new files created in the directory inherit the directory permissions.

I have tried using setfacl, using the GUID sticky bit to inherit the group permissions, and even messing with umask.

For some reason the files will not inherit execute permissions. Is this done purposefully for some security reason or am I missing something?

Any help is appreciated.
 
Old 08-13-2019, 02:45 PM   #2
ehartman
Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 836

Rep: Reputation: 416Reputation: 416Reputation: 416Reputation: 416Reputation: 416
Quote:
Originally Posted by permaroot View Post
For some reason the files will not inherit execute permissions. Is this done purposefully for some security reason or am I missing something?
As there is NO way to inherit permissions from the directory the files are in: this is expected. A later addition makes it possible for directories to let its GROUP be inherited, but not the permissions:
Quote:
When used on a directory, instead, the setgid bit alters the standard behavior so that the group of the files created inside said directory, will not be that of the user who created them, but that of the parent directory itself.
Note that nothing is said about the permissions, so if you want other users in that group to be able to modify those files, you still have to use an umask to make them WRITABLE for the group.
This usage of the setgid bit is only applicable for directories als setgid already had another meaning for normal files (especially executable ones).
 
2 members found this post helpful.
Old 08-13-2019, 03:39 PM   #3
permaroot
Member
 
Registered: Aug 2019
Location: Arden, NC
Distribution: Manjaro, Centos7, Arch
Posts: 98

Original Poster
Rep: Reputation: 34
Quote:
Originally Posted by ehartman View Post
As there is NO way to inherit permissions from the directory the files are in: this is expected. A later addition makes it possible for directories to let its GROUP be inherited, but not the permissions:


Note that nothing is said about the permissions, so if you want other users in that group to be able to modify those files, you still have to use an umask to make them WRITABLE for the group.
This usage of the setgid bit is only applicable for directories als setgid already had another meaning for normal files (especially executable ones).
Ok that makes sense. And it seems that umask will never assign execute permissions to files, correct? This always must be done manually with chmod?

Thanks again for the help.
 
Old 08-14-2019, 02:10 AM   #4
ehartman
Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 836

Rep: Reputation: 416Reputation: 416Reputation: 416Reputation: 416Reputation: 416
Quote:
Originally Posted by permaroot View Post
And it seems that umask will never assign execute permissions to files, correct? This always must be done manually with chmod?
umask cannot assign permissions, that's for the creating process. So an executable, created by "ld" (the linker) will be created with x-bits set, but a script, created with an editor, will not. With, i.e. a umask of 002 only the "write permission for others" will be masked OUT, so directories will keep their x-bits, as do files that have been created that way, but normally files will be -rw-rw-r-- with that umask and have to be explicitly chmod'ed (if they should be executable, that is: are scripts).
BTW: this is different for FAT and NTFS filesystems as those do not support x-bits, so the "is executable" is faked at the mount with the umask (cq fmask/dmask) mount options.
I mostly use a "fmask=0133" option (which will mask out all x-bits too for files) for user-mounted USB sticks etc, as they will be "noexec" anyway, so why confuse the issue with seemingly executable files.
 
1 members found this post helpful.
Old 08-14-2019, 10:36 AM   #5
permaroot
Member
 
Registered: Aug 2019
Location: Arden, NC
Distribution: Manjaro, Centos7, Arch
Posts: 98

Original Poster
Rep: Reputation: 34
Quote:
Originally Posted by ehartman View Post
umask cannot assign permissions, that's for the creating process. So an executable, created by "ld" (the linker) will be created with x-bits set, but a script, created with an editor, will not. With, i.e. a umask of 002 only the "write permission for others" will be masked OUT, so directories will keep their x-bits, as do files that have been created that way, but normally files will be -rw-rw-r-- with that umask and have to be explicitly chmod'ed (if they should be executable, that is: are scripts).
BTW: this is different for FAT and NTFS filesystems as those do not support x-bits, so the "is executable" is faked at the mount with the umask (cq fmask/dmask) mount options.
I mostly use a "fmask=0133" option (which will mask out all x-bits too for files) for user-mounted USB sticks etc, as they will be "noexec" anyway, so why confuse the issue with seemingly executable files.
Sorry I mis spoke. I do understand that umask doesnít assign permissions. This makes sense. Found an article on how permissions are set depending on how they are created after reading your reply and itís much clearer to me. Thanks again!
 
Old 08-14-2019, 01:06 PM   #6
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 1,155

Rep: Reputation: 526Reputation: 526Reputation: 526Reputation: 526Reputation: 526Reputation: 526
You can try ACLs If you have a filesystem that supports ACLs.
ACLs are an addition to the standard Unix permission. A default mask should even allow permission inheritance.
The drawback of ACLs is that they are often neglected by the standard Unix tools.
 
1 members found this post helpful.
Old 08-14-2019, 01:15 PM   #7
permaroot
Member
 
Registered: Aug 2019
Location: Arden, NC
Distribution: Manjaro, Centos7, Arch
Posts: 98

Original Poster
Rep: Reputation: 34
Quote:
Originally Posted by MadeInGermany View Post
You can try ACLs If you have a filesystem that supports ACLs.
ACLs are an addition to the standard Unix permission. A default mask should even allow permission inheritance.
The drawback of ACLs is that they are often neglected by the standard Unix tools.
I guess i was confused at first about directories being able to inherit permissions. Its something my teacher mistakenly said was possible but "couldnt get it to work" when showing us in class.

After that was cleared up I was really just wondering why even when creating a file with a umask of 0000 that execute permissions were never set. Reading about POSIX and understanding that programs like touch automatically use 666 as permissions for any file created, really cleared it up for me.

I understand the use of ACLs and Umask but I had no idea that certain programs have default permissions when creating files that the umask then subtracts permissions from. But i thank you for the reply! Reading more about POSIX now!

Last edited by permaroot; 08-14-2019 at 01:16 PM.
 
Old 08-14-2019, 01:43 PM   #8
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.6
Posts: 3,486

Rep: Reputation: 1169Reputation: 1169Reputation: 1169Reputation: 1169Reputation: 1169Reputation: 1169Reputation: 1169Reputation: 1169Reputation: 1169
Quote:
Originally Posted by permaroot View Post
I guess i was confused at first about directories being able to inherit permissions. Its something my teacher mistakenly said was possible but "couldnt get it to work" when showing us in class.

After that was cleared up I was really just wondering why even when creating a file with a umask of 0000 that execute permissions were never set. Reading about POSIX and understanding that programs like touch automatically use 666 as permissions for any file created, really cleared it up for me.

I understand the use of ACLs and Umask but I had no idea that certain programs have default permissions when creating files that the umask then subtracts permissions from. But i thank you for the reply! Reading more about POSIX now!
touch on my system uses the umask of the user and creates 644 files. You should keep reading...
 
1 members found this post helpful.
Old 08-14-2019, 02:27 PM   #9
permaroot
Member
 
Registered: Aug 2019
Location: Arden, NC
Distribution: Manjaro, Centos7, Arch
Posts: 98

Original Poster
Rep: Reputation: 34
Talking

Quote:
Originally Posted by scasey View Post
touch on my system uses the umask of the user and creates 644 files. You should keep reading...
because the umask is 0022 by default! I noted in my last little blurb that the umask is taken from the programs default (which is 666).

I really am starting to understand it, i promise! lol
 
1 members found this post helpful.
  


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
How to Inherit parent directory permissions without using ACL ? sahil0512 Linux - Newbie 1 12-26-2016 01:34 AM
[SOLVED] Can not inherit the permission from parent folder to child. Toushi Linux - General 4 04-28-2011 06:15 AM
[SOLVED] C++ classes - a matter of style? inherit or not inherit? worzel1968 Programming 25 03-21-2011 02:40 PM
inherit permissions of the parent directory in newly created file abhijit_mohanta Linux - Newbie 1 09-10-2009 06:45 PM
Samba - Inherit Permissions from Parent Directory bence8810 Linux - Software 6 08-03-2006 06:33 AM

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

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