Automatically force all files in a directory to have the same UID/GID?
This is a simple question, and it may have a simple answer or maybe no answer at all...
Is there a simple way to setup a directory so that any file moved, copied or created in it will always have the same UID?
The idea here would be that say a home user's folder is configured so that anything placed there always has the correct UID.
So even if root copied a folder from anywhere on the system to that user's home folder, the copy's UID/GID would automatically be set to that of the given user.
The application for this is a custom built NAS server. I only care about share-level security; I basically allow or disallow users to access shares via SMB and use the force user directive in smb.conf to force the uid for access to given folders as desired. This means that I can have several user accounts login that all have full read-write access to the same share without complicated "I created that file but now you can't modify it" issues.
The problem arises if I want to move or copy a large folder manually. If I have, say, a 10GB work folder that needs to move from one share to another, I'll execute an mv on the server, rather than copying it at a workstation. This is because the server can then just move the folder, rather than copying the file back and forth over the network. If I forget to chown the folder after moving it, though, this creates a problem.
I currently have a script set to run every few hours via cron that scans all the NAS folders using the find command, looking for files that don't match the correct UID/GID and executing chown per file. But short of doing this, which seems a bit disk-intensive given the task at hand, is there a more efficient way to do this?