PureFtpd-MySQL Support for ispCP


I managed to add pure-ftp - Support with only little changes to ispCP.
I've to admit, that pure-ftpd has many useful features - but i'm not
using everything possible atm.
My Installation works on Debian Etch

0) Please backup:

cp /etc/ispcp/ispcp.conf /etc/ispcp/ispcp.conf.bak
cp /var/www/ispcp/engine/quota/ispcp-dsk-quota
/var/www/ispcp/engine/quota/ispcp-dsk-quota.bak


1) Install needed packages

apt-get install pure-ftpd-mysql pure-ftpd-common


2) This is for the debian - configuration of pure-ftpd

echo "no" > /etc/pure-ftpd/conf/PAMAuthentication
echo "no" > /etc/pure-ftpd/conf/UnixAuthentication
echo "yes" > /etc/pure-ftpd/conf/ChrootEveryone
echo "yes" > /etc/pure-ftpd/conf/CreateHomeDir
echo "2000" > /etc/pure-ftpd/conf/MinUID
echo "yes" > /etc/pure-ftpd/conf/NoAnonymous
echo "/etc/pure-ftpd/db/mysql.conf" > /etc/pure-ftpd/conf/MySQLConfigFile


3) Now open phpmyadmin and add a new user "ispcp_ftp". Give him a reasonable difficult password and give him only access to the tables domain and ftp_users. If you can try to limit its rights to only select commands. In my setup the following SQL-code may help you.

GRANT SELECT ON `ispcp`.`domain` TO 'ispcp_ftp'@'localhost';
GRANT SELECT ON `ispcp`.`ftp_users` TO 'ispcp_ftp'@'localhost';


4) Edit your /etc/pure-ftpd/db/mysql.conf

MYSQLSocket      /var/run/mysqld/mysqld.sock
MYSQLUser       ispcp_ftp
MYSQLPassword   "secret"
MYSQLDatabase   ispcp
MYSQLCrypt      crypt
MYSQLGetPW      SELECT passwd FROM ftp_users WHERE userid="\L"
MYSQLGetUID     SELECT uid FROM ftp_users WHERE userid="\L"
MYSQLGetGID     SELECT gid FROM ftp_users WHERE userid="\L"
MYSQLGetDir     SELECT homedir FROM ftp_users WHERE userid="\L"
MySQLGetQTASZ  SELECT  domain.domain_disk_limit FROM domain,ftp_users WHERE ftp_users.userid="\L" and ftp_users.uid=domain.domain_uid


5) Finally if all went right - my pureftp-mysql is started with the following command (just for those who don't use debian)

/usr/sbin/pure-ftpd-mysql -l mysql:/etc/pure-ftpd/db/mysql.conf -u 1000 -E -j -O clf:/var/log/pure-ftpd/transfer.log -A -B


6) Try to login. If you can - wonderful. If not, watch i.e. /var/log/messages for pure-ftpd errors while you try to log in. Also try to login into your phpmyadmin as user ispcp_ftp with your chosen password and try to access ispcp -> ftp_users table.

7) Now we've to edit /etc/ispcp/ispcp.conf search:

CMD_DU = /usr/bin/du
CMD_QUOTACHECK = /usr/sbin/pure-quotacheck


8) Now edit /var/www/ispcp/engine/quota/ispcp-dsk-quota

search for:

my $sql = "select domain_id, domain_name from domain where domain_status = 'ok';";


replace with:

my $sql = "select domain_id, domain_name, concat('vu',domain_uid) from domain where domain_status = 'ok';";


my $cmd_du = $main::cfg{'CMD_DU'};
my $cmd_quota = $main::cfg{'CMD_QUOTACHECK'};


seach for:

my $disk_limit  = @$_[2];


replace with:

my $domain_uid  = @$_[2];


my $size = `$cmd_du -sb $main::cfg{APACHE_WWW_DIR}/$domain_name`;
my $quotacheck = `$cmd_quota -u $domain_uid -d $main::cfg{APACHE_WWW_DIR}/$domain_name`;


That's all!

Hints:

  • be sure you've pure-quotacheck available
  • be sure pure-ftpd is compiled with support for mysql + quotas
  • check the path of pure-quotacheck - if it differs from yours - of course use your path in ispcp.conf
  • if all goes wrong revert to your backups.
  • if you're not satisfied with pureftpd you can still use proftpd-mysql without reverting to your backups.
  • run ispcp-dsk-quota from your terminal - if everything is ok there will be a file named .ftpquota in every Domain-Home-Directory

Good luck!

back to WikiStart