大网数据广告活动
服务器运维问答

Deny deletion after SFTP upload

· 52CE 我爱测

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…

问题原文

原帖链接 · 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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2015-08-18)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。