Authentication and persistant ratio support for the mod_ratio module are provided using SQL databases. The official documentation for this feature is currently a little thin on the ground. At the moment unless SQL support is provided for mod_ratio the ratios are only considered within a single connection with no persistance of credits recorded.
To include support for sql the appropriate module has to be added prior to building the binary for the host system
./configure --with-modules=mod_sqlpw:mod_mysql make make installThis should ensure that support is properly enabled, in addiiton to this a local MySQL (or similar) server should be installed and configured with the appropriate accesses and tables for yor setup. This is covered in later sections of this chapter.
Example 21-1.
mysql> show fields from proftp; +----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+-------------+------+-----+---------+-------+ | username | varchar(30) | YES | | NULL | | | uid | int(11) | YES | | NULL | | | gid | int(11) | YES | | NULL | | | password | varchar(30) | YES | | NULL | | | homedir | varchar(50) | YES | | NULL | | | count | int(11) | YES | | NULL | | +----------+-------------+------+-----+---------+-------+
Example 21-2. Contents
mysql> select * from proftp; +----------+------+------+----------+----------+-------+ | username | uid | gid | password | homedir | count | +----------+------+------+----------+----------+-------+ | oli | 500 | 500 | test | /home/om | 2 | | oli2 | 500 | 500 | test | / | 1 | +----------+------+------+----------+----------+-------+
(take care : uid and gid must be > 500. or change the source code of the module).
Authentication and persistant ratio support for the mod_ratio module are provided using SQL databases. The official documentation for this feature is currently a little thin on the ground. At the moment unless SQL support is provided for mod_ratio the ratios are only considered within a single connection with no persistance of credits recorded.
To include support for sql the appropriate module has to be added prior to building the binary for the host system
./configure --with-modules=mod_mysql make make installThis should ensure that support is properly enabled, in addiiton to this a local MySQL (or similar) server should be installed and configured with the appropriate accesses and tables for yor setup. This is covered in later sections of this chapter.
o Install MySQL o Compile Proftpd with the --with-modules=mod_sqlpw:mod_mysql flags
Note: I had to alter the path slighly so the modules got mysql.h from the rightplace.
Detailing how to use MySQL is outside the scope of this document, so here's some links.
o http://www.devshed.com/Server_Side/MySQL/Administration/ o http://www.devshed.com/Server_Side/MySQL/Intro/
Quick rundown of what's needed to make a databae
o create a user for proftpd to access the database as o create permissions for this user o create new database (mine is called proftpd) o reload as required to make this live o create a table within proftpd (mine is ftp)
Example 21-3. SQL database layout
mysql> use proftpd; Database changed mysql> show tables; +-------------------+ | Tables in proftpd | +-------------------+ | ftp | +-------------------+ 1 row in set (0.02 sec) mysql> show columns from ftp ; +----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+-------------+------+-----+---------+-------+ | username | varchar(60) | YES | | NULL | | | uid | int(11) | YES | | NULL | | | gid | int(11) | YES | | NULL | | | password | varchar(30) | YES | | NULL | | | homedir | varchar(50) | YES | | NULL | | | count | int(11) | YES | | NULL | | +----------+-------------+------+-----+---------+-------+ 6 rows in set (0.00 sec)
Example 21-4. Configuration fragment for SQL
--[ proftpd.conf ]-- # auth using mysql host login pass db MySQLInfo localhost hamster ***** proftpd SQLUserTable ftp SQLUsernameField username SQLUidField uid SQLGidField gid SQLPasswordField password SQLHomedirField homedir SQLLoginCountField count SQLAuthoritative on SQLPlaintextPasswords on --[ proftpd.conf ]--
421 Service not availible Make sure that the home directory of the user concerned actually exists and has the right ownerships/permissions Can't connect to the database Is it running? Is it listening? Does the user proftpd is using have the right permissions?
Example 21-5.
mysql> show fields from proftp; +----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+-------------+------+-----+---------+-------+ | username | varchar(30) | YES | | NULL | | | uid | int(11) | YES | | NULL | | | gid | int(11) | YES | | NULL | | | password | varchar(30) | YES | | NULL | | | homedir | varchar(50) | YES | | NULL | | | count | int(11) | YES | | NULL | | +----------+-------------+------+-----+---------+-------+
Example 21-6. Contents
mysql> select * from proftp; +----------+------+------+----------+----------+-------+ | username | uid | gid | password | homedir | count | +----------+------+------+----------+----------+-------+ | oli | 500 | 500 | test | /home/om | 2 | | oli2 | 500 | 500 | test | / | 1 | +----------+------+------+----------+----------+-------+
(take care : uid and gid must be > 500. or change the source code of the module).
The following configuration is needed in the proftpd.conf file to enable sql support
Example 21-7. proftpd.conf
MySQLInfo localhost test "" test # HOST login password database MySQLUserTable proftp MySQLUsernameField username MySQLUidField uid MySQLGidField gid MySQLPasswordField password MySQLHomedirField homedir MySQLLoginCountField count MySQLAuthoritative on MySQLPlaintextPasswords on
Example 21-8. Updated authentication table
mysql> show columns from ftpusers; +----------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+---------------+------+-----+---------+-------+ | username | varchar(60) | YES | | NULL | | | uid | int(11) | YES | | NULL | | | gid | int(11) | YES | | NULL | | | password | varchar(30) | YES | | NULL | | | homedir | varchar(50) | YES | | NULL | | | count | int(11) | YES | | NULL | | | fretr | int(10) | YES | | NULL | | | bretr | int(10) | YES | | NULL | | | bstor | int(10) | YES | | NULL | | | fstor | int(10) | YES | | NULL | | | ftime | timestamp(14) | YES | | NULL | | | faddr | varchar(255) | YES | | NULL | | | fhost | varchar(255) | YES | | NULL | | | fcdir | varchar(255) | YES | | NULL | | +----------+---------------+------+-----+---------+-------+ 14 rows in set (0.01 sec)
Example 21-9. File tracking table
mysql> show columns from logging2; +----------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+--------------+------+-----+---------+-------+ | fstor | int(11) | YES | | NULL | | | fretr | int(11) | YES | | NULL | | | bstor | int(11) | YES | | NULL | | | bretr | int(11) | YES | | NULL | | | fcdir | varchar(255) | YES | | NULL | | | fhost | varchar(255) | YES | | NULL | | | faddr | varchar(255) | YES | | NULL | | | ftime | varchar(255) | YES | | NULL | | | count | int(11) | YES | | NULL | | | filename | varchar(255) | YES | | NULL | | +----------+--------------+------+-----+---------+-------+ 10 rows in set (0.01 sec)