Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 of course 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. Am I missing something? Is there another variable I'm supposed to use? Why isn't %u being replaced by the FTP username? I know that everything else is fine because 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'"
share|improve this question
add comment

1 Answer 1

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".

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.