Our SFTP share is set in: /home/COMMUNITY
Each workgroup has its own directory, for example: /home/COMMUNITY/Halloween
This directory has multiple directories under it. There is one group that contains all users: COMMUNITY. All directories have with sticky bit set as group owner COMMUNITY, this works well and all directories and files created in this structure have automatically this group.
Individual directory rights for SFTP users are controlled by the directory group. In case of /Halloween it is the group HALLOWEEN. Users login with SFTP start in /home/COMMUNITY. This works well when only one user per directory was working on a community project. However our community service group is growing and have more users per group HALLOWEEN for example and here things go wrong. A directory of file created by a user gets automatically his/her ownership as is default. But for our system to work well the ownership of the underlying directories and files must be root.
Maybe flawed but our current thought is to fix this with a shell script that first test if a directory/file has root as owner and if not it will be changed to root. We need to do this recursively under the COMMUNITY directory. We want to keep this very fast and not force to change files that have root already as owner. People sharing documents may create issues but when we run the script frequently we hope it fixes our current problems that users cannot save documents created by other users.
Articles: "Bash Script To Repair Directory and File Ownership", "SFTP jail & Keeping file ownership the same / File owner per folder" and "Sticky Bit Tips" are close to what we want but it not 100% the same and we can not figure it out how to make it work.
Your help is greatly appreciated by all our volonteers who use this system and are now getting frustrated that it does not work quite right anymore.