ProFTPD是一个Unix平台上或者类Unix平台(如Linux,FreeBSD...)的FTP服务器程序,它是在自由软件基金会的版权声明下开发的、发布免费的软件,也就是说任何只要遵守自由软件基金会版权声明的人,全都可以随意修改源始码。本文主要说明的是ProFTPD用户磁盘限额的
ProFTPD是一个Unix平台上或者类Unix平台(如Linux,
FreeBSD...)的FTP服务器程序,它是在自由软件基金会的版权声明下开发的、发布免费的软件,也就是说任何只要遵守自由软件基金会版权声明的人,全都可以随意修改源始码。本文主要说明的是ProFTPD
用户磁盘限额的管理。先从ProFTPD表中看起。
CREATE TABLE `quotalimits` (
`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"
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
说明:
上面其实就是在proftpd库中创建一个表quotalimits;我们在proftpd的数据库中,再来查看一下quotalimits表的结构,这样方便我们理解和使用磁盘限额;
mysql> DESCRIBE quotalimits;
+------------------+------------------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------+------------------------------------+------+-----+---------+-------+
| name | varchar(30) | YES | | NULL | |
| quota_type | enum("user","group","class","all") | | | user | |
| per_session | enum("false","true") | | | false | |
| limit_type | enum("soft","hard") | | | soft | |
| bytes_in_avail | float | | | 0 | |
| bytes_out_avail | float | | | 0 | |
| bytes_xfer_avail | float | | | 0 | |
| files_in_avail | int(10) unsigned | | | 0 | |
| files_out_avail | int(10) unsigned | | | 0 | |
| files_xfer_avail | int(10) unsigned | | | 0 | |
+------------------+------------------------------------+------+-----+---------+-------+
说明;
quotalimits
name - username
quota_type - user, group, class, all (we use user)
per_session - true or false (we use false)
limit_type - quota limit type - hard or soft (we use soft)
bytes_in_avail - upload limit in bytes - allowed bytes on disk (eg diskquota)
bytes_out_avail - download limit in bytes - allowed bytes a user can download
bytes_xfer_avail - allowed bytes a user can transfer in/out
files_in_avail - upload limit in files - allowed number of uploaded files
files_out_avail - allowed number of downloaded files
files_xfer_avail - allowed number of files a user can transfer in/out
name
应该这样理解,既能表示单个用户,也能表示用户组名;如果我们在quota_type(限额类型)中使用group来认证的话,那就得在这里设置组名,这样整组都具有统一的磁盘限额的特性;当然您要在ftpgroups表中插入组纪录;并且在member字段中得把用户一个一个的列进去,这是后话了;先自己研究一下,只是插入纪录的事;我们只说最简单的单个用户的磁盘限额;默认值可以为空NULL,如果为空则针对所在有quota_type中设置的类型,比如在quota_type中设置为user
,就是针对所有ftpusers 中的用户起作用;如果是group名,也是对ftpgroups 所有组作用;
quota_type 磁盘限额类型,可以设置为用户,也可以设置为用户组group
;如果您的name写的是用户组,那在这里就得设置为group来认定;默认为user认证;
per_session 默认为false;
limit_type 默认为soft;
bytes_in_avail
用户占用空间大小,也就是家目录的空间最大可以让用户占用多少,单位是byte;默认为0,0是不受限制,以下同理;
bytes_out_avail 注;所有下载文件的总和,默认为0;
bytes_xfer_avail 注;一个用户上传下载流量总和,默认为0
files_in_avail 注:限制上传文件总数,默认为0;
files_out_avail 注;限制下载文件个数总计,默认为0
files_xfer_avail 注:允许下载和上传的文件总和我,默认为0;
由此看来,我们比如想让test用户,约束空间大小为100M,其它不受限制;则可用下面的mysql命令添加;
先让我们对照quotalimits表的结构,然后根据表的结构来添加;
mysql> describe quotalimits;
+------------------+------------------------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------+------------------------------------+------+-----+---------+-------+
| name | varchar(30) | YES | | NULL | |
| quota_type | enum("user","group","class","all") | | | user | |
| per_session | enum("false","true") | | | false | |
| limit_type | enum("soft","hard") | | | soft | |
| bytes_in_avail | float | | | 0 | |
| bytes_out_avail | float | | | 0 | |
| bytes_xfer_avail | float | | | 0 | |
| files_in_avail | int(10) unsigned | | | 0 | |
| files_out_avail | int(10) unsigned | | | 0 | |
| files_xfer_avail | int(10) unsigned | | | 0 | |
+------------------+------------------------------------+------+-----+---------+-------+
10 rows in set (0.00 sec)
添加记录
mysql>insert into quotalimits VALUES ("test","user","false","soft","104857600","0","0","0","0","0");
运算公式:
1Kb=1024 byte
1M=1024 Kb
100M=100x1024 Kb= 100x1024x1024 byte=104857600 byte
注意:磁盘限额生效,必须让FTP用户重新登录才有效;比如test用户正在ftp上,这时要先退出,然后再登录,这是磁盘限额就有效了;
查看用户空间使用情况
登录FTP后用下面的命令;
quote site quota;
举例:
lftp test@192.168.1.5:/> quote site quota;
200-The current quota for this session are [current/limit]:
Name: test
Quota Type: User
Per Session: False
Limit Type: Soft
Uploaded Mb: 19.00/95.37
Downloaded Mb: unlimited
Transferred Mb: unlimited
Uploaded files: unlimited
Downloaded files: unlimited
Transferred files: unlimited
200 Please contact xxxxx@xxxxxxxxxxx.com if these entries are inaccurate