打算要给252加上自动解压缩的功能,主要因为我们年级一个同学是玩0day之类的。所以FXP过来的电影都是分卷压缩的,对用户来说不方便。他也跟我提了好多次了,这次也算是给他个答复吧

这些电影的分卷压缩都会有个sfv文件用作校验,sfv和md5的性质一样,不过更简单。它记录了一个目录下所有正常文件的sfv值。

要做自动解压缩,首先需要通过sfv校验来确认用户已经完成上传。然后再调用解压缩程序

所以第一个要完成的就是给proftpd 加上sfv校验,偷懒参考了张微波的BLOG

  1. 1。先下载一个sfv的插件
  2. 到http://www.bunker-werk.net/proftpd/下载http://www.bunker-werk.net/ftpsfv/ftpsfv-0.1.5.tar.bz2。
  3.  
  4. 2。编译安装
  5.  
  6.     tar jvxf ftpsfv-0.1.5.tar.bz2
  7.     cd ftpsfv
  8.     ./configure
  9.     make
  10.     make install
  11.  
  12. #默认安装在/usr/local/ftpsfv 你可以通过--prefix来指定安装地址
  13.  
  14. 3。ftpsfv设置
  15. vi /usr/local/ftpsfv/etc/ftpexecd.conf
  16.  
  17.     User = root
  18.     Group = root
  19.     #启用ftpexec服务的用户和用户组,你也可以指定为nobody,但前提是你是对sfv.fifo文件有写的权限
  20.     fifoFile = /var/log/sfv.fifo
  21.     logFile = syslog
  22.     # 如果设置为"none",则不写入log日志
  23.     # 设置为"syslog", 写入log日志
  24.     Exec = /usr/local/ftpsfv/bin/ftpsfvcheck.pl
  25.     #默认设置就行
  26.  
  27. vi /usr/local/ftpsfv/bin/ftpsfvcheck.pl
  28.  
  29. 根据你的需要设置,比如
  30.  
  31.     my $user = "root"
  32.     my $group = "root"
  33.     #设置成跟conf文件一样就行,
  34.     my $sitename = "ftpSFV";
  35.     #设置成你要显示的ftp站名就行
  36.     my @exclude_dirs = ("");
  37.     #这是设置哪些目录可以不用检验sfv文件。默认都检测
  38.  
  39. 4。proftpd设置
  40.  
  41. vi /usr/local/proftpd/etc/proftpd.conf
  42.  
  43. 加入如下设置
  44.  
  45.     Logformat sfv "%m %f
  46.     ExtendedLog /var/log/sfv.fifo WRITE sfv
  47.  
  48. 保存退出
  49.  
  50. 5。启用ftpsfv
  51.  
  52. 启动ftpxsfv
  53. /etc/rc.d/init.d/ftpexecd start
  54.  
  55. 然后重启一下proftpd
  56. /etc/rc.d/init.d/proftpd restart
  57.  
  58. 好了,上传一个sfv文件试验一下,应该能看到信息。
  59.  
  60. 总体感觉这个sfv插件还不是很稳定,我试验了几下,有时成功,有时没反应,不知什么原因。还请大家指教

前面玩得都很顺利,但是修改proftpd配置后。测试了下,怎么都没有发生校验。于是翻来覆去搞了几回,最后无奈的看了一遍源码包中的INSTALL,sigh~~~~~问题瞬间解决

  1. ftpsfv (an sfv checker for proftpd)
  2.  
  3.  Version: 0.1.3
  4.  
  5.  Copyright (C) 2003 by Thomas Lachmann <TL@bunker-werk.net>
  6.  
  7.    This program is free software; you can redistribute it and/or modify
  8.    it under the terms of the GNU General Public License as published by
  9.    the Free Software Foundation; either version 2 of the License, or
  10.    (at your option) any later version.
  11.  
  12.    This program is distributed in the hope that it will be useful,
  13.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.    GNU General Public License for more details.
  16.  
  17.    You should have received a copy of the GNU General Public License
  18.    along with this program; if not, write to the Free Software
  19.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  
  21.  DESCRIPTION
  22.  ===========
  23.  
  24.  ftpsfv monitors a fifo that is filled by the proftpd daemon and starts a
  25.  script to verify the uploaded sfv files.
  26.  If the verify result is ok, an adjustable directory is created.
  27.  Also missing and bad files are reported via filenames.
  28.  Now reduces the load on the system, because it checks files only once.
  29.  Also a ignore directory option is available.
  30.  
  31.  Requirements:
  32.  ============
  33.     - ftpexecd (a daemon which  monitors a proftpd log fifo and
  34.         executes an external program/script after a file is uploaded),
  35.         provided by ftpsfv
  36.     - a script called ftpsfvcheck.pl
  37.         provided by ftpsfv
  38.     - ftpsfv a sfv file checker
  39.         provided by ftpsfv
  40.  
  41.  INSTALL NOTES
  42.  =============
  43.  
  44.  install steps:
  45.     - run "./configure"
  46.         NOTE:
  47.         the default install path for ftpsfv is '/usr/local/ftpsfv',
  48.         if you want to change this, run "./configure --prefix=dir_to_install"
  49.     - run "make"
  50.     - run "make install"
  51.     - edit /usr/local/ftpsfv/etc/ftpexecd.conf
  52.         The following directives are used in ftpexecd.conf
  53.  
  54.             User = root
  55.             # this defines the user the daemon runs as, it's advisable NOT to use root for security reasons
  56.             # if changed, make sure this user has the permissions to access the files on the ftp
  57.             
  58.             Group = root
  59.             # this defines the group the daemon runs as, it's advisable NOT to use root for security reasons
  60.             # if changed, make sure this group has the permissions to access the files on the ftp
  61.  
  62.             fifoFile = /var/log/sfv.fifo
  63.             # points to the named pipe/fifo of the logfile defined in proftpd
  64.  
  65.             logFile = syslog
  66.             # points to a file where to log all messages from ftpexecd
  67.             # if value == "none", no logging is done
  68.             # if vaiue == "syslog", all logging is done via syslog
  69.  
  70.             Exec = /usr/local/ftpsfv/bin/ftpsfvcheck.pl
  71.             # point to a program/script which is run after each file upload
  72.             # it's called with one argument: filename
  73.  
  74.             remarks begin with a #
  75.             all file references have to be ABSOLUTE paths
  76.  
  77.     - you may change the user/group uses by ftpexecd, since all other
  78.       scripts called from ftpexecd will executed under this user/group
  79.       Using nobody/nobody is a better choice when using RedHat for example.
  80.       NOTE: this user/group MUST HAVE READ PERMISSION to the files beeing checked
  81.             and WRTITE PERMISSION to the direcotory where the files are
  82.             THIS IS IMPORTANT ELSE ftpsfv WILL NOT WORK!
  83.  
  84.     - create a fifo in your proftpd log file directory, e.g. "mkfifo /path/to/proftpd/logs/sfv.fifo"
  85.     - add the line "Logformat sfv "%m %f" to the server config
  86.     - add the line "ExtendedLog /path/to/sfv_fifo WRITE sfv" to the server config / virtual host config
  87.  
  88.     - edit /usr/local/ftpsfv/bin/ftpsfvcheck.pl to change different options regarding ftpsfv
  89.       see ftpsfvcheck.pl for the options
  90.     - start ftpexecd with /etc/init.d/ftpexecd start
  91.     - restart proftpd
  92.  
  93.     - it is important to run ftpexecd _BEFORE_ proftpd, else proftpd will hang until ftpexecd is started
  94.       if chkconfig is available ftpexecd will be registered as systems ervice, which is
  95.       started at boot
  96.  
  97.  
  98.     Test if the sfv checker works...
  99.     
  100.     If it doesn't work, check your log you defined in ftpexecd.conf, ftpexecd will log all errors to it.
  101.     If you want more debugging output, stop ftpexecd with /etc/init.d/ftpexecd stop and run it
  102.     from the installed dir with the argument -n (e.g. /usr/local/ftpsfv/sbin/ftpexecd -n), with this
  103.     option ftpexecd will not run as a daemon and output debug informations to stderr.

注意到上面第86行,ExtendLog需要加到VitualHost配置段下面才能起作用。而我原来只是把这个配置加到GLobal配置段。抓狂……一个这么小的问题浪费了我这么多时间


SFV校验搞定之后,下面就找个时间写个小程序来解压缩就好了:)