Ftp – ProFTPD Inconsistent Errors

ftpproftpd

Ever since I went from Ubuntu 9.04 to Debian 6.0, I've been having this issue:

Filezilla will do this:

Status: Connecting to x.x.x.x:21...
Status: Connection established, waiting for welcome message...
Response:   220-Connected!
Response:   220 xxx Home Server
Command:    USER xxx
Response:   331 Password required for xxx
Command:    PASS ********
Response:   230-Welcome!
Response:   230 User xxx logged in
Command:    SYST
Response:   230 Ls oi a:2011-11-06 00:41:06
Command:    FEAT
Response:   215 UNIX Type: L8
Status: Connected
Status: Retrieving directory listing...
Command:    PWD
Response:   211-Features:
Response:    LANG en-US.UTF-8*;en-US
Response:    MDTM
Response:    MFMT
Response:    TVFS
Response:    UTF8
Response:    MFF modify;UNIX.group;UNIX.mode;
Response:    MLST modify*;perm*;size*;type*;unique*;UNIX.group*;UNIX.mode*;UNIX.owner*;
Response:    REST STREAM
Response:    SIZE
Response:   211 End
Error:  Failed to parse returned path.
Error:  Failed to retrieve directory listing
Response:   257 "/" is the current directory
Error:  Connection closed by server

However if I click quick connect again:

Status: Connecting to x.x.x.x:21...
Status: Connection established, waiting for welcome message...
Response:   220-Connected!
Response:   220 xxxx Home Server
Command:    USER xxxx
Response:   331 Password required for xxxx
Command:    PASS ********
Response:   230-Welcome!
Response:   230 User xxxx logged in
Status: Connected
Response:   230 Ls oi a:2011-11-06 00:48:32
Status: Retrieving directory listing...
Command:    PWD
Response:   257 "/" is the current directory
Status: Directory listing successful

Whoa, odd, I also see that features are not being printed, if I try with an online FTP tester:

Status: Connecting to x.x.x.x
Status: Connected, waiting for welcome message
Reply: 220-Connected!
Reply: 220 xxxx Home Server
Command: CLNT http://ftptest.net on behalf of y.y.y.y
Reply: 500 CLNT not understood
Command: USER xxxx
Reply: 331 Password required for xxxx
Command: PASS ********
Reply: 230-Welcome!
Reply: 230 User xxxx logged in
Command: SYST
Reply: 230 Ls oi a:2011-11-06 00:44:45
Command: FEAT
Reply: 215 UNIX Type: L8
Command: PWD
Reply: 211-Features:
Reply: LANG en-US.UTF-8;en-US*
Reply: MDTM
Reply: MFMT
Reply: TVFS
Reply: UTF8
Reply: MFF modify;UNIX.group;UNIX.mode;
Reply: MLST modify*;perm*;size*;type*;unique*;UNIX.group*;UNIX.mode*;UNIX.owner*;
Reply: REST STREAM
Reply: SIZE
Reply: 211 End
Error: No path found in PWD reply

I've been poking at configs for awhile and am completely stumped on where to go from here (it seems to have to do with how ProFTPd is responding to the requests, but I have yet to nail down why it's spitting out feature lists randomly). 🙁 Any ideas? Did ProFTPd just break itself in 1.3.3?

proftpd.conf:

LoadModule mod_sql.c
LoadModule mod_sql_mysql.c
#LoadModule mod_tls.c
ServerName xxxx
ServerType standalone
ServerIdent on "xxxx Home Server"
DeferWelcome on
DefaultServer on

AllowStoreRestart on
AllowRetrieveRestart on
RequireValidShell               off
PathDenyFilter                  "\\.ftp)|\\.ht)[a-z]+$"
DefaultRoot             ~
DenyFilter \*.*/
UseReverseDNS off
IdentLookups off



# Various messages.
DisplayLogin            /etc/proftpd/.welcome       # Textfile to display on login
DisplayConnect          /etc/proftpd/.connect       # Textfile to display on connection
DisplayChdir            /etc/proftpd/.firstchdir    # Textfile to display on first changedir

Port                    21
PassivePorts            49152 65535

MaxInstances 15
MaxClientsPerHost       50 "Only %m connections per host allowed"
MaxClients              100 "Only %m total simultanious logins allowed"
MaxHostsPerUser         10

User                    nobody
Group                   nogroup
Umask                   000

ScoreboardFile          /var/log/scoreboard

Include /etc/proftpd/sql.conf

<Global>
DeferWelcome on
</Global>

sql.conf:

# Set up authentication via SQL
# ===========
AuthOrder                       mod_sql.c
SQLAuthTypes            Backend
SQLConnectInfo              proftpd_admin@localhost user pass
SQLUserInfo             usertable userid passwd uid gid homedir shell 
SQLGroupInfo            grouptable groupname gid members 
SQLUserWhereClause          "disabled=0 and (NOW()<=expiration or expiration=-1 or expiration=0)"

# Log the user logging in
SQLLog PASS counter
SQLNamedQuery counter UPDATE "lastlogin=now(), count=count+1 WHERE userid='%u'" usertable

# logout log
SQLLog EXIT time_logout
SQLNamedQuery time_logout UPDATE "lastlogout=now() WHERE userid='%u'" usertable

# display last login time when PASS command is given
SQLNamedQuery login_time SELECT "lastlogin from usertable where userid='%u'"
SQLShowInfo PASS "230" "Last login was: %{login_time}"

# xfer Log in mysql
SQLLog RETR,STOR transfer1
SQLNamedQuery  transfer1 INSERT "'%u', '%f', '%b', '%h', '%a', '%m', '%T', now(), 'c', NULL" xfer_stat
SQLLOG ERR_RETR,ERR_STOR transfer2
SQLNamedQuery  transfer2 INSERT "'%u', '%f', '%b', '%h', '%a', '%m', '%T', now(), 'i', NULL" xfer_stat

Best Answer

There is a bug in ProFTPd v1.3.3 with multi-line output.

This line of output shouldn't be there, or at least shouldn't look like it does:

Reply: 230 Ls oi a:2011-11-06 00:44:45

It is being interpreted as the output for 'SYST', so when the 'FEAT' command it issued, the 'SYST' output is being read, and when 'PWD' is issued, some of the feature response is being read.

The second connection doesn't ask for SYST and FEAT, so the timings seem to be more forgiving.

The internet knows of one other person who has had this problem (with that combination of letters missing!) and their workaround is:

Try commenting out the SQLShowInfo lines from your sql.conf file.

This Debian bug says the problem is fixed in 1.3.4 pre-release upstream, and suggests you may have to use a backport to get the correct behaviour as it is unlikely to be considered critical functionality or security, thus warranting a stable patch.