分享
 
 
 

proftpd+mysql+quota

王朝mysql·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

下载软件

proftpd-1.2.9.tar.gz

proftpd-mod-quotatab-1.2.11.tar.gz

注:proftpd-1.2.10版本后就不需要proftpd-modquotatab了

步骤如下:

代码:

¢

vi /etc/ld.so.conf

添加:/usr/local/mysql/lib

tar zvxf proftpd-1.2.9.tar.gz

tar zvxf proftpd-mod-quotatab-1.2.11.tar.gz

cp mod_quotatab/*.c proftpd-1.2.9/contrib/

cp mod_quotatab/*.h proftpd-1.2.9/contrib/

vi proftpd-1.2.9/contrib/mod_sql_mysql.c

#include</usr/local/mysql/include/mysql/mysql.h>

修改mysql.h的实际路径

cd proftpd-1.2.9

./configure \--prefix=/usr/local/proftpd \--with-modules=mod_sql:mod_sql_mysql:mod_quotatab\:mod_quotatab_sql:mod_ratio \--with-includes=/usr/local/mysql/include \--with-libraries=/usr/local/mysql/lib

make

make install

cp proftpd-1.2.9/contrib/dist/rpm/proftpd.init.d /etc/rc.d/init.d/proftpd

vi /etc/rc.d/init.d/proftpd

修改:PATH="$PATH:/usr/local/proftpd/sbin"

chmod 755 /etc/rc.d/init.d/proftpd

chkconfig --level 3 proftpd on

groupadd -g 5500 ftpgroup

adduser -u 5500 -s /bin/false -d /bin/null -c "proftpd user" -g ftpgroup ftpuser

然后配置你的Proftpd.conf

最后就是启动啦。/usr/local/proftpd/sbin/proftpd

-------------------------------Proftpd.conf----------------------------------

代码:

# 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 ftpdb@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

建ftpdb库,在phpMyAdmin中导入ftpdb.sql就ok。

--------------------------------------ftpdb.sql---------------------------------

代码:

# 表的结构 `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');

quotalimits表

代码:

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数据库也能完全控制权限就好了。

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有