代码: |
# This is a basic ProFTPD configuration file (rename it to # 'proftpd.conf' for actual use. It establishes a single server # and a single anonymous login. It assumes that you have a user/group # "nobody" and "ftp" for normal operation and anon. ServerName "ltsnet" ServerType standalone DefaultServer on # Port 21 is the standard FTP port. Port 21 # Umask 022 is a good standard umask to prevent new dirs and files # from being group and world writable. Umask 022 # To prevent DoS attacks, set the maximum number of child processes # to 30. If you need to allow more than 30 concurrent connections # at once, simply increase this value. Note that this ONLY works # in standalone mode, in inetd mode you should use an inetd server # that allows you to limit maximum number of processes per service # (such as xinetd). MaxInstances 30 # Set the user and group under which the server will run. User nobody Group nobody # To cause every FTP user to be "jailed" (chrooted) into their home # directory, uncomment this line. ServerIdent off DisplayLogin welcome.msg DefaultRoot ~ # Normally, we want files to be overwriteable. <Directory /> AllowOverwrite on </Directory> # A basic anonymous configuration, no upload directories. If you do not # want anonymous users, simply delete this entire <Anonymous> section. <Anonymous /home/ftp> User ftp Group ftp # We want clients to be able to login with "anonymous" as well as "ftp" UserAlias anonymous ftp # Limit the maximum number of anonymous logins MaxClients 10 # We want 'welcome.msg' displayed at login, and '.message' displayed # in each newly chdired directory. DisplayLogin welcome.msg DisplayFirstChdir .message # Limit WRITE everywhere in the anonymous chroot <Limit WRITE> DenyAll </Limit> </Anonymous> SQLAuthTypes Backend Plaintext SQLAuthenticate users* groups* SQLConnectInfo proftpd@localhost root 123456 SQLUserInfo ftpuser userid passwd uid gid homedir shell SQLGroupInfo ftpgroup groupname gid members SQLHomedirOnDemand on SQLLog PASS updatecount SQLNamedQuery updatecount UPDATE "count=count+1,accessed=now() WHERE userid='%u'" ftpuser SQLLog STOR,DELE modified SQLNamedQuery modified UPDATE "modified=now() WHERE userid='%u'" ftpuser QuotaEngine on QuotaDirectoryTally on QuotaDisplayUnits Mb QuotaShowQuotas on QuotaLog "/var/log/quota" SQLNamedQuery get-quota-limit SELECT "name, quota_type, per_session, limit_type, bytes_in_avail, bytes_out_avail, bytes_xfer_avail, files_in_avail, files_out_avail, files_xfer_avail FROM ftpquotalimits WHERE name = '%{0}' AND quota_type = '%{1}'" SQLNamedQuery get-quota-tally SELECT "name, quota_type, bytes_in_used, bytes_out_used, bytes_xfer_used, files_in_used, files_out_used, files_xfer_used FROM ftpquotatallies WHERE name = '%{0}' AND quota_type = '%{1}'" SQLNamedQuery update-quota-tally UPDATE "bytes_in_used = bytes_in_used + %{0}, bytes_out_used = bytes_out_used+ %{1}, bytes_xfer_used = bytes_xfer_used + %{2}, files_in_used = files_in_used + %{3}, files_out_used = files_out_used + %{4}, files_xfer_used = files_xfer_used + %{5} WHERE name = '%{6}' AND quota_type = '%{7}'" ftpquotatallies SQLNamedQuery insert-quota-tally INSERT "%{0}, %{1}, %{2}, %{3}, %{4}, %{5}, %{6}, %{7}" ftpquotatallies QuotaLimitTable sql:/get-quota-limit QuotaTallyTable sql:/get-quota-tally/update-quota-tally/insert-quota-tally |
代码: |
# 表的结构 `ftpgroup` # CREATE TABLE `ftpgroup` ( `groupname` varchar(16) NOT NULL default '', `gid` smallint(6) NOT NULL default '5500', `members` varchar(16) NOT NULL default '', KEY `groupname` (`groupname`) ) TYPE=MyISAM COMMENT='ProFTP group table'; # # 导出表中的数据 `ftpgroup` # INSERT INTO `ftpgroup` VALUES ('ftpgroup', 5500, 'ftpuser'); # -------------------------------------------------------- # # 表的结构 `ftpquotalimits` # CREATE TABLE `ftpquotalimits` ( `name` varchar(30) default NULL, `quota_type` enum('user','group','class','all') NOT NULL default 'user', `per_session` enum('false','true') NOT NULL default 'false', `limit_type` enum('soft','hard') NOT NULL default 'soft', `bytes_in_avail` float NOT NULL default '0', `bytes_out_avail` float NOT NULL default '0', `bytes_xfer_avail` float NOT NULL default '0', `files_in_avail` int(10) unsigned NOT NULL default '0', `files_out_avail` int(10) unsigned NOT NULL default '0', `files_xfer_avail` int(10) unsigned NOT NULL default '0' ) TYPE=MyISAM; # # 导出表中的数据 `ftpquotalimits` # INSERT INTO `ftpquotalimits` VALUES ('test', 'user', 'true', 'hard', '9e+06', '2000', '9e+09', 2000, 2000, 2000); # -------------------------------------------------------- # # 表的结构 `ftpquotatallies` # CREATE TABLE `ftpquotatallies` ( `name` varchar(30) NOT NULL default '', `quota_type` enum('user','group','class','all') NOT NULL default 'user', `bytes_in_used` float NOT NULL default '0', `bytes_out_used` float NOT NULL default '0', `bytes_xfer_used` float NOT NULL default '0', `files_in_used` int(10) unsigned NOT NULL default '0', `files_out_used` int(10) unsigned NOT NULL default '0', `files_xfer_used` int(10) unsigned NOT NULL default '0' ) TYPE=MyISAM; # # 导出表中的数据 `ftpquotatallies` # INSERT INTO `ftpquotatallies` VALUES ('test', 'user', '2000', '2000', '2000', 2000, 2000, 2000); # -------------------------------------------------------- # # 表的结构 `ftpuser` # CREATE TABLE `ftpuser` ( `id` int(10) unsigned NOT NULL auto_increment, `userid` varchar(32) NOT NULL default '', `passwd` varchar(32) NOT NULL default '', `uid` smallint(6) NOT NULL default '5500', `gid` smallint(6) NOT NULL default '5500', `homedir` varchar(255) NOT NULL default '', `shell` varchar(16) NOT NULL default '/sbin/nologin', `count` int(11) NOT NULL default '0', `accessed` datetime NOT NULL default '0000-00-00 00:00:00', `modified` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`id`) ) TYPE=MyISAM COMMENT='ProFTP user table' AUTO_INCREMENT=3 ; # # 导出表中的数据 `ftpuser` # INSERT INTO `ftpuser` VALUES (1, 'test', '123456', 5500, 5500, '/home/test', '/sbin/nologin', 36, '2004-09-28 13:07:41', '2004-09-28 13:07:42'); |
代码: |
name: - 用户帐号 quota type: - user, group, class, all (we use user) per_session: - true or false (we use true) limit_type: - 硬限制 or 软限制 (我们一般用硬限制) bytes_in_avail: - 允许上传的字节数 bytes_out_avail: - 允许下载的字节数 bytes_xfer_avail: - 允许传输的字节数(包括上传/下载) files_in_avail: - 允许上传的文件数 files_out_avail: - 允许下载的文件数 files_xfer_avail: - 允许传输的文件数(包括上传/下载) |
按这些步骤来安装,应该没问题。老实说用mysql和quota模块来验证用户和设置磁盘限额,但我总觉得还是不够完善,因为在这个方法中,数据库表里还没有相应的权限的字段,所以说相应用户的权限还是得用实际得用户即mysql对应得uid和gid来控制权限,那天要是mysql数据库也能完全控制权限就好了。
=============================proftpd.conf中文解说=========================================
#设置MySQL认证:
#数据库联接的信息,DatabaseName是数据库名, HostName是主机名,
#Port是端口号,UserName是连接数据库的用户名,Password是密码。
SQLConnectInfo DatabaseName@HostName:port UserName Password
#数据库认证的类型:
SQLAuthTypes Backend Plaintext
#指定用来做用户认证的表的有关信息。("FTPUSERS"和"FTPGRPS"是数据表名字,等一会而在下面建立)
SQLUserInfo FTPUSERS userid passwd uid gid homedir shell
SQLGroupInfo FTPGRPS groupname gid members
#设置如果shell为空时允许用户登录:
RequireValidShell off
#数据库的鉴别
SQLAuthenticate users groups usersetfast groupsetfast
#如果home目录不存在,则系统会为根据它的home项新建一个目录:
SQLHomedirOnDemand on
#磁盘限额部分
QuotaDirectoryTally on
#磁盘限额单位 b"|"Kb"|"Mb"|"Gb"
QuotaDisplayUnits "Kb"
QuotaEngine on
#磁盘限额日志记录
QuotaLog "你的LOG路径"
# 打开磁盘限额信息,当登陆FTP帐户后,使用命令 "quote SITE QUOTA" 后可显示当前用户的磁盘限额
QuotaShowQuotas on
#以下是SQL调用语句,不用修改直接拷贝过去
SQLNamedQuery get-quota-limit SELECT "name, quota_type, per_session, limit_type, bytes_in_avail, /
bytes_out_avail, bytes_xfer_avail, files_in_avail, files_out_avail, files_xfer_avail FROM quotalimits /
WHERE name = '%{0}' AND quota_type = '%{1}'"
SQLNamedQuery get-quota-tally SELECT "name, quota_type, bytes_in_used, bytes_out_used, /
bytes_xfer_used, files_in_used, files_out_used, files_xfer_used FROM quotatallies /
WHERE name = '%{0}' AND quota_type = '%{1}'"
SQLNamedQuery update-quota-tally UPDATE "bytes_in_used = bytes_in_used + %{0}, /
bytes_out_used = bytes_out_used + %{1}, bytes_xfer_used = bytes_xfer_used + %{2}, /
files_in_used = files_in_used + %{3}, files_out_used = files_out_used + %{4}, /
files_xfer_used = files_xfer_used + %{5} /
WHERE name = '%{6}' AND quota_type = '%{7}'" quotatallies
SQLNamedQuery insert-quota-tally INSERT "%{0}, %{1}, %{2}, %{3}, %{4}, %{5}, %{6}, %{7}" quotatallies
QuotaLimitTable sql:/get-quota-limit
QuotaTallyTable sql:/get-quota-tally/update-quota-tally/insert-quota-tally
ftpquotatallies 表里的
quota_type 磁盘限额的鉴别,可以设置单各用户,也可以设置一各组中的全部用户,还可以设置全部用户
bytes_in_avail 上传最大字节数,就是FTP用户空间容量 (设置个字段的时候是以byte(字节)为单位,如果要限额在10M,那就是10240000,下面也一样)
bytes_out_avail 下载最大字节数,需要注意的是,这个字段中记录的是用户总共能从服务器上下载多少数据,数据是累计的。
bytes_xfer_avail 总共可传输的文件的最大字节数(上传和下载流量)需要注意的是,这个字段中记录的是用户总共能传输文件的最大字节数,数据是累计的。
files_in_avail INT 总共能上传文件的数目
files_out_avail INT 能从服务器上下载文件的总数目
files_xfer_avail INT 总共可传输文件的数目(上传和下载)
参考
http://www.linuxsir.org/bbs/showthread.php?s=&threadid=1381
http://bbs.chinaunix.net/forum/viewtopic.php?t=423609
http://www.linuxsir.org/bbs/showthread.php?s=&threadid=33415