3

I am trying to use ProFTPd's MySQL configuration to set up FTP login to my server. I have a SQLNamedQuery that is used to get the user info from the database (see Setting up ProFTPd with default home directory based on username), and as part of the query I use the %u variable to insert the username. When I try to connect, I always get login incorrect. Checking the SQL log file, it seems that the login fails because %u is not being replaced by the username sent via FTP, but rather always by proftpd. Is there another variable I'm supposed to use? Why isn't %u being replaced by the FTP username? When I replace %u with a username that's in the MySQL user table, I can connect.

Here is my config:

<IfModule mod_sql.c>
        SQLLogFile              /var/log/proftpd/sql.log
        SQLDefaultUID           2001
        SQLDefaultGID           2001
        SQLBackend              mysql
        SQLPasswordEngine       on
        SQLAuthTypes            sha1
        SQLConnectInfo          *****@localhost ***** **********
        SQLNamedQuery           userinfo SELECT "uname, passwd, CONCAT('2001'), CONCAT('2001'), CONCAT('/var/projects/users/', uname) AS homedir FROM users WHERE uname='%u'"
        SQLUserInfo             custom:/userinfo
        SQLGroupInfo            ftpgroups groupname gid members
</IfModule>

And here is the relevant line in my SQL log file (notice the uname='proftpd' bit at the end):

query "SELECT uname, passwd, CONCAT('2001'), CONCAT('2001'), CONCAT('/var/projects/users/', uname) AS homedir FROM users WHERE uname='proftpd'"
Ashley Strout
  • 218
  • 1
  • 13

1 Answers1

4

The problem is that %u refers to the local user (which in your case is proftpd). You shoulduse %U (note the capital U), which refers to the FTP user. Note the last paragraph on the ProFTPd SQLUserInfo page, above "See Also".

Ashley Strout
  • 218
  • 1
  • 13