问题原文
原帖链接 · RaWkStAr · CC BY-SA 3.0
I'd like to prevent users from deleting files they have uploaded to my sftp server. I know I could set up a solution of my own using inotify/dnotify (or pam hook) and lsof which triggers a script to do something such as chattr +i $filename after a file is uploaded and closed. But I wonder if there is something already available as a feature or a solution already vetted and available of which I'm not aware.
The current setup is that I'm using openssh sftp and users are jailed upon connecting.
已采纳解答
原帖链接 · Navern · CC BY-SA 3.0
Look at lsyncd(http://code.google.com/p/lsyncd/). It will provide inotify=>action part for your solution. It will look like this:
cat /etc/lsyncd.conf
settings {
logfile = "/var/log/lsyncd.log",
statusFile = "/var/run/lsyncd.status",
nodaemon = false,
insist = true,
}
-- config action
my_config = {
delay = 10,
maxProcesses = 1,
onCreate = "chattr +i -R /path/to/dir/*",
}
sync { my_config,
source="/path/to/dir/",
}
-- EOF
you can change onCreate action for better logic, maybe run a script which will find uploaded files and set chattr +i.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
