简介:
FTP上传文件权限继承有很多的方法能解决!最常用的是ACL,这里我通过Inotify的实现
 
Inotify下载地址: https://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz
 
编译安装
1、[root@localhost down]# wget --no-check-certificate https://github.com/downloads/rvoicilas/inotify-tools/inotify-tools-3.14.tar.gz  \\  --no-check-certificate参数是支持https
 
2、[root@localhost down]# tar -zxf inotify-tools-3.14.tar.gz
 
3、[root@localhost inotify-tools-3.14]# ./configure
 
4、[root@localhost inotify-tools-3.14]# make ;make install
 
检查
1、查看是否支持内核
[root@localhost inotify-tools-3.14]# ll /proc/sys/fs/inotify
total 0
-rw-r--r-- 1 root root 0 Jul    9 19:43 max_queued_events
-rw-r--r-- 1 root root 0 Jul    9 19:43 max_user_instances
-rw-r--r-- 1 root root 0 Jul    9 19:43 max_user_watches
2、检查软件是安装成功
[root@localhost inotify-tools-3.14]# ls /usr/local/bin/inotifywait        
/usr/local/bin/inotifywait
 
使用
1、我的FTP目录是/var/www  使用如下命令监测运行下
/usr/local/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format    '%T %w%f' -e modify,delete,create,attrib /var/www
2、OK,现在我们在/var/www创建一个testfile文件。
[root@localhost www]# touch testfile
3、哈哈成功显示出来信息
[root@localhost inotify-tools-3.14]# /usr/local/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format    '%T %w%f' -e modify,delete,create,attrib /var/www
09/07/11 20:01 /var/www/testfile
4、利用这个输出,写个SHELL自动继承
#!/bin/bash
#inofp.sh
src=/var/www
/usr/local/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format    '%T %w%f' \
-e modify,delete,create,attrib \
${src} \
| while read    file
                do
                                chmod -R 777 $file 2>/dev/null
                done
5、执行这个shell 
sh inofp.sh &>/dev/null &
6、去/var/www/新建个文件夹和文件试试 
[root@localhost www]# touch file
[root@localhost www]# mkdir directory
7、我脚本里面设的权限是777 看看成功否
[root@localhost www]# ll
total 4
drwxrwxrwx 2 root root 4096 Jul    9 21:22 directory
-rwxrwxrwx 1 root root        0 Jul    9 21:25 file
8、OK成功全部777