Is there a way (with acl's) to protect the contents of a folder? Users should create files inside a folder but not overwrite/edit/delete them. Is this possible?
One might use
inotifywait to watch the directory and make changes, such as changing ownership of each new file copied into the directory. In a Debian-based distribution, install the software as follows:
apt-get install inotify-tools.
Create a script, perhaps
/usr/local/sbin/inbox.sh, as follows.
#!/usr/bin/env bash inotifywait -m -e create "/path/to/directory" | while read path event file; do if [ "$event" = "CREATE" ]; then chown root:root "$path$file" fi done
Give the script permission to execute (
chmod 0700 /usr/local/sbin/inbox.sh). Then run it at boot time from, say,
/etc/rc.local or whichever RC file is appropriate:
According to the manual,
-m monitors indefinitely, and
-e watches for a specific event. Within the
while loop, it could be possible to receive an event such as
CREATE,ISDIR, which indicates the creation of a directory, of course. Directories are not the target of the question; thus the
if statement contains a command to respond only to new files, which are represented with the event,
path variable from
inotifywait has a trailing slash character, so
$file can be concatenated without specifying a slash between the two.