0

First I set the setgid bit, so that files/folder under directory will be created with the same group as directory.

chmod g+s <directory> 

Then I tried to change the folder's permission structure, so that the group has rwx access to it by:

setfacl -R -m g::rwx /<directory> 

Problem

Now, root came by and creates a new folder (with files) under this directory which leads to:

drwxr-xr-x+ 3 root homecontrol 4096 May 11 20:20 '<folder>' 

So homecontrol was set properly as group, but the write permission is missing.

4
  • I guess you just misunderstand the (stupid) output of ls... What is the output of `getfacl '/<directory>/<folder>'? Commented May 13, 2023 at 22:12
  • You are absolutely right! getfacl on the directory displays proper permissions like: # owner: root # group: homecontrol group::rwx So my problem is, that the owner is still root, which shall be homecontrol. Is there a way i can set the default owner to homecontrol? Commented May 14, 2023 at 14:59
  • You didn't mention this problem in your question even though the ls output made it quite clear that the owner is root... Commented May 14, 2023 at 15:08
  • I didn't know that i have a "owner" problem here, i thought it would be the missing write permission. Commented May 14, 2023 at 15:37

2 Answers 2

0

You need to add the default keyword:

shadur@proteus:~/test$ mkdir testdir shadur@proteus:~/test$ setfacl -m default:g::rwx testdir/ shadur@proteus:~/test$ touch testdir/test2 shadur@proteus:~/test$ ls -lsa testdir/ total 8 4 drwxr-xr-x+ 2 shadur shadur 4096 May 13 14:59 . 4 drwxr-xr-x 3 shadur shadur 4096 May 13 14:57 .. 0 -rw-rw-r-- 1 shadur shadur 0 May 13 14:59 test2 
1
  • Sorry, i forgot to add -d to the command above. But newertheless, even with "default", there is no write permission for group after creating a new file afterwards. Commented May 13, 2023 at 16:58
0

You cannot enforce the owner of a new file; you can only change it after the file has been created. This can be done with

  • a cron job / Systemd timer (very simple)
  • inotify (i.e. incrond or inotifywait) if you need short response times or have directories with huge amounts of files

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.