CentOS – How to Have Files Extracted from Archive Inherit Permission from Parent Folder

aclcentospermissionsumask

I'm using a Centos 8 Linux with multiple user belonging to the same group accessing a number ff folder/subfolder and files in the same FS (xfs). I want all files and folders have write permission for the group setting umask to 0002 allow new file created from user to have the right permission, but I have tar and other compressed files being extracted by users the extracted files maintain the permission they had in origin and are not changing resulting with some files being with permission only for the owner and not the group I'm trying to find a way to set the permission automatically without need of user to run a chmod to allow write for group I tried assign g+s on themain folder but I can only get the new folder inherit the group permission not the single files. I tried enabling ACL but again I don't get files to inherit parent folder permission. This how it look my main folder

drwxrwsr-x+ 4 owner group 4.0K Mar 6 10:26 test

And the content after extracting a tgz file in it

drwxrwsr-x+ 8 owner group 202 Mar 6 09:56 folder1 
drwxrwsr-x+ 8 owner group 202 Mar 6 10:12 folder2

but then when i reach the first folder with files, files permission are just for owner

ll test/folder1
-rwx------. 1 owner group 195K Jun 6 2018 file1
-rwx------. 1 owner group 225K Aug 4 2018 file2
-rwx------. 1 owner group 211K Aug 20 2018 file3
-rwx------. 1 owner group 100K Sep 9 2018 file4
-rwx------. 1 owner group 200K Oct 24 2018 file5
-rwx------. 1 owner group 199K Nov 9 2018 file6

even after executing

setfacl -R -m d:o:rwx test

files are not changing their permission

Is there a way to force all files created or extracted from a compressed archive to inherit the permission from the main folder?

Best Answer

I'm still looking for a better solution, but for now I created a a script that pipe tar output to chmod command

#!/bin/bash -
set -o pipefail
tar xvf "$@" | xargs -rd '\n' chmod 770 --

I don't like it so much because instruct 100 and more user to use a different command will be tricky but if won't find better solution I'll keep this. just for info from man page tar seems to have an option which should ignore the file permission

--no-same-permissions

but seems working only if umask permission are more restrictive than the one on the extracted files, wonder if it's a bug

Related Question