ProFTPD + MySQL + quota

Source: Internet
Author: User
I found that many of my colleagues on the Internet are worried about installing ProFTPD + MySQL + quota.
I just sorted out my installation process, and of course it was not original. Related software packages are also provided for permanent download.
, MySQL/PHP/Apache installation is free. My MySQL is installed using source code!
Related Software:
---------------------------------------------------------------
Proftpd-1.2.9.tar.gz
Proftpd-mod-quotatab-1.2.11.tar.gz
Ftpdb. SQL
ProFTPD. conf

---------------------------------------------------------------
The procedure is as follows:

Code:
VI/etc/lD. So. conf
Add:/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. h>
Modify the actual path of 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-supported des =/usr/local/MySQL/include \ -- With-libraries =/usr/local/MySQL/lib
Make
Make install
Proftpd-1.2.9/contrib/Dist/RPM/ProFTPd. init. d/etc/rc. d/init. d/ProFTPD
VI/etc/rc. d/init. d/ProFTPD
Modify: 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
Then configure your ProFTPd. conf
Finally, it starts. /Usr/local/ProFTPD/sbin/ProFTPD

------------------------------- ProFTPd. conf ----------------------------------

Code:
# This is a basic ProFTPD configuration file (rename it
# '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 shoshould 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, delimiter, 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 = bytes + % {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

Create the ftpdb library and import ftpdb. SQL in phpMyAdmin.
------------------------------------ Ftpdb. SQL ---------------------------------

Code:
# Table structure 'ftpgroup'
#

Create Table 'ftpgroup '(
'Groupname' varchar (16) not null default '',
'Gid' smallint (6) Not null default '20140901 ',
'Members 'varchar (16) not null default '',
Key 'groupname' ('groupname ')
) Type = MyISAM comment = 'proftp group table ';

#
# Export the data in the table 'ftpgroup'
#

Insert into 'ftpgroup' values ('ftpgroup', 5500, 'ftpuser ');

#--------------------------------------------------------

#
# Table structure '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;

#
# Export the data in the table 'ftpquotalimits'
#

Insert into 'ftpquotalimits 'values ('test', 'user', 'true', 'hard', '9e + 06', '9e + 09 ', 2000,200 0, 2000 );

#--------------------------------------------------------

#
# Table structure '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;

#
# Export the table data 'ftpquotatallies'
#

Insert into 'ftpquotatallies' values ('test', 'user', '000000', '000000', '000000', 2000 0, 2000 );

#--------------------------------------------------------

#
# Table structure '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 '123 ',
'Gid' smallint (6) Not null default '20140901 ',
'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 '2017-00-00 00:00:00 ',
'Modified' datetime not null default '2017-00-00 00:00:00 ',
Primary Key ('id ')
) Type = MyISAM comment = 'proftp user table' auto_increment = 3;

#
# Export the data 'ftpuser' In the table'
#

Insert into 'ftpuser' values (1, 'test', '000000', 123456 0, '/home/test','/sbin/nologin', 36, '2017-09-28 13:07:41 ', '2017-09-28 13:07:42 ');

Quotalimits table

Code:
Name:-User Account
Quota type:-user, group, class, all (we use user)
Per_session:-True or false (we use True)
Limit_type:-Hard limit or soft limit (we usually use hard limit)
Bytes_in_avail:-number of bytes allowed for upload
Bytes_out_avail:-number of bytes that can be downloaded
Bytes_xfer_avail:-number of bytes allowed for transmission (including upload/download)
Files_in_avail:-number of files that can be uploaded
Files_out_avail:-number of files that can be downloaded
Files_xfer_avail:-number of files that can be transferred (including upload/download)


Follow these steps to install the SDK. To be honest, I used the MySQL and quota modules to verify the user and set the disk quota, but I still think it is not perfect, because in this method, the database table does not have the corresponding permission field, therefore, the permissions of the corresponding user must be controlled by the actual user, that is, the UID and GID corresponding to MySQL. That day, if the MySQL database can also have full control of permissions.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.