Default permissions for files within directory when using rsync

1

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

/path/to/directory/deletemeplease

deletemeplease will have permissions drwxr-sr-x

Any files created within /path/to/directory/ have permissions rw-r--r--

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?

EDIT

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

nullReference

Posted 2017-10-22T16:17:46.383

Reputation: 153

Please be specific then: what exact permissions do you expect/need for a new file? directory? – Kamil Maciorowski – 2017-10-22T17:09:29.127

@KamilMaciorowski question has been updated. If further information is required, please let me know and I can elaborate further. – nullReference – 2017-10-22T17:16:24.803

If the problem is related tto rsync, stating the rsync options would be useful. – xenoid – 2017-10-22T19:38:06.877

@xenoid questions updated to include rsync command options – nullReference – 2017-10-22T23:33:41.297

No answers