You are not logged in.

#1 2022-11-02 18:13:01

Felix001
Member
Registered: 2022-11-02
Posts: 2

[SOLVED] Enforce permissions for new and copied files

Hi,

Im trying to setup a shared local folder that is used by several users who are all members of a secondary group.
Problem is that I cant find a reliable way to enforce the file permissions inside said folder for both new and copied files.

In case of new files, all it takes is to set the setgid bid on the folder and force the default permissions using ACLs.
However this does not affect any copied files.

Every time a user copies a preexisting file or folder into the target path, it requires a manual chown and chmod run to fix the permissions.

Is there a way to automatically enforce a specific group and permissions even for copied files?

Thanks

Last edited by Felix001 (2022-11-15 03:10:45)

Offline

#2 2022-11-02 21:22:21

seth
Member
Registered: 2012-09-03
Posts: 33,685

Re: [SOLVED] Enforce permissions for new and copied files

You can monitor the folder w/ https://man.archlinux.org/man/community … ywait.1.en and sanitize the file properties on changes.
Alternatively mount a non POSIX capable FS (vfat) into the folder w/ the desired uid/gid/umask

Offline

#3 2022-11-03 17:10:07

twelveeighty
Member
From: Alberta, Canada
Registered: 2011-09-04
Posts: 958

Re: [SOLVED] Enforce permissions for new and copied files

Long-term, that might not be what you want the end-result "experience" to be for that shared drive. You might want to look into NFS idmap for a more durable long-term solution.

Offline

#4 2022-11-15 03:10:25

Felix001
Member
Registered: 2022-11-02
Posts: 2

Re: [SOLVED] Enforce permissions for new and copied files

seth wrote:

You can monitor the folder w/ https://man.archlinux.org/man/community … ywait.1.en and sanitize the file properties on changes.
Alternatively mount a non POSIX capable FS (vfat) into the folder w/ the desired uid/gid/umask


Thanks for the reply, this worked pretty well (and the inotify feature is pretty cool)

For anyone looking for a solution, this is what I use for now:

inotifywait -q -m -r -e moved_to,create /mypath/files |
while read -r directory events filename; do
    TARGET=$directory$filename
    #echo "file: $directory$filename event: $events"
    if [[ -f "$TARGET" ]]
    then
        chmod 660 "$TARGET"
        #echo "changed file"
    elif [[ -d "$TARGET" ]]
    then
        chmod 770 "$TARGET"
        #echo "changed dir"
    fi
done

Offline

#5 2022-11-15 03:44:14

progandy
Member
Registered: 2012-05-17
Posts: 5,048

Re: [SOLVED] Enforce permissions for new and copied files

If the overhead of a fuse layer is acceptable you can look into bindfs (in the AUR):
https://bindfs.org/docs/bindfs.1.html


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

Board footer

Powered by FluxBB