I am attempting to configure the file permissions that are set on directories and files when they are created by a specific user/group, but seem to be having a bit of an issue.
I have tried setting the following:
chmod 2770 /path/to/directory chmod g+rwxs /path/to/directory
However when I create a new directory within this directory for example
deletemeplease will have permissions
Any files created within
/path/to/directory/ have permissions
I have also tried setting ACLs for the directory such as below:
setfacl -dm u::rwx,g::rwx,o::r /path/to/directory
When setting ACL, permissions of created files and directories become
rw-rw-r-- which is getting closer, but the execute bit is still not being set.
Is there a step I'm missing here?
The linked answer is only explaining the difference between umask and chmod. My issue is that after setting permissions they are not taking place.
When a new directory or file is created I am expecting the permissions to be set to
rwxrwxr--. Howevever when a new directory is created the directory has permissions
rwxr-sr--. When a new file is created the permissions are
rw-rw-r--. Then if a new directory is created and contains files, the files within the newly created directory have permissions
rw-r--r-- which is very strange.
I just discovered that when creating files and directories within the terminal, that permissions are being applied as expected (minus the execute bit for files). The strange behaviour described above is happening when directories/files are being created via rsync from a script that's being executed. The script is being executed via www-data user, which is the directory user and group for the directory which has the acls applied, so should they not be applied when rsync runs?
The script which is running rsync is using executing the following command:
rsync -rltgoDzvO /path/for/files/to/sync /path/to/directory