mysqlftpproftpd

Proftpd specific user configuration from MySQL


I have already set up a proftpd server with a MySQL connection. Everything works fine.

I would like to set specific permissions for each user from the database using (PathAllowFilter, PathDenyFilter, ...)

The server running on Ubuntu 12.04 LTS distribution.


Solution

  • It is not so easy, there is no single module to do this. But I found a solution for this.

    It's not optimal because you have to restart ProFTPd server each time you change MySQL configuration, but it works.

    As you have a ProFTPd server that already run with MySQL, i will explain only the part of specific user configuration.

    For this solution you need ProFTPd to be compiled with these modules:

    To help you with ProFTPd recompilation, you can run this command proftpd -V to see how your version is configured. You can found some documentation here.

    Once you have compiled your ProFTPd server and it's run, you will have to log on your MySQL server.

    If you read mod_conf_sql, they say to create 3 tables ftpctxt, ftpconf, ftpmap. We will not create these tables unless you want to have global configuration from MySQL.

    We will fake the MySQL configuration with "views".

    1. First you add each specific configuration as user column (make sure to have a default value):

    ALTER TABLE ftpuser #
    ADD PathDenyFilter VARCHAR( 255 ) NOT NULL DEFAULT '(\.ftp)|(\.hta)[a-z]+$';`
    
    ALTER TABLE ftpuser 
    ADD PathAllowFilter VARCHAR( 255 ) NOT NULL DEFAULT '.*$';`
    ....
    

    2. Create the conf view:

    3. Create the ctxt view

    4. Create the map view

    5. Add these lines to your ProFTPd configuration

    <IfModule mod_conf_sql.c>
        Include sql://user:password@host/db:database/ctxt:ftpuser_ctxt:id,parent_id,type,info/conf:ftpuser_conf:id,type,info/map:ftpuser_map:conf_id,ctxt_id/base_id=1
    </IfModule>
    

    Where:

    6. Restart your ProFTPd server

    I hope this will help you. Good luck