0

I have a directory that has rwxrwxr-x and -s- permission settings, if I create files in this folder from user A these files gets permission rw-rw-r--, and with user B it gets rw-r--r--. I'm really confused about how exactly files are getting their permission set when they are first created...

To be more focused on what i need to do - the directory has group G which contains both users A and B and I want them both to be able to work on all the files in that same directory, so if both of them would have created files with rw-rw-r-- they could work on these files (delete them and recreate them or just edit them) without interference.

3
  • So is the mode drwxrwsr-x? Commented Mar 23, 2020 at 21:01
  • @ctrl-alt-delor yes Commented Mar 23, 2020 at 21:02
  • 1
    Set-group-id just sets the group. The mode is controlled by the umask. There was a question a, few days ago, about file-access-control-lists FACLs, that may be relevant. unix.stackexchange.com/q/570795/4778 and unix.stackexchange.com/q/573349/4778 Commented Mar 23, 2020 at 21:03

1 Answer 1

1

The permissions of a new file are set from (1) the permissions set in the open() call modified by (2) the umask of the creating process, so that bits set in the umask are zeroed. That is, a permission bit is set only if allowed by both of those, it's just that the bits in umask are inverted.

In your case the users probably have different umasks, namely A seems to have an umask of 0002 (clearing just the write bit from others), while B seems to have an umask of 0022 (clearing the write bit from the group and other users). The umasks are likely set in their shell startup files or via pam_umask.

If you have ACLs set on the directory, and default ACLs in particular, then the situation is slightly different. In that case, the umask is ignored, and instead the default ACLs are copied to ACLs on the file, except that only permission bits set in the system call stay set.

You're probably looking for the answers in this question:

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.