[PATCH] NLST -CF support

19 views
Skip to first unread message

Brian Rak

unread,
Jul 12, 2011, 11:51:46 AM7/12/11
to Python FTP server library - Discussion group
We've encountered an issue where old versions of ncftp send the 'NLST -
CF' command, which doesn't actually work. It's a violation of the RFC
as far as I can tell, but for us patching the client is impossible.
I've come up with this patch to fix the issue, it transforms 'NLST -
CF' requests into NLST requests for the current directory. I suppose
if you have directories ending with -CF, this could cause issues for
you:

--- a/pyftpdlib-0.6.0/pyftpdlib/ftpserver.py
+++ b/pyftpdlib-0.6.0/pyftpdlib/ftpserver.py
@@ -2576,6 +2576,8 @@ class FTPHandler(object, asynchat.async_chat):
"""Return a list of files in the specified directory in a
compact form to the client.
"""
+ if path.endswith("-CF"):
+ path = path[:-3]
line = self.fs.fs2ftp(path)
try:
if self.fs.isdir(path):

Giampaolo Rodolà

unread,
Jul 12, 2011, 12:14:15 PM7/12/11
to pyft...@googlegroups.com
Urgh! This is even worse than "LIST -la".
I don't think we should cover this case.
NLST is a very old command. No clients should be using it anymore.
Plus, by specifying -CF option client expects that directories will be
listed with a slash appended at the end of the name (see ls -CA
output) so it's likely that your patch won't work.

I've just tried ncftp 3.2.4 and noticed it uses MLSD.
A version using 'NLST -CF' instead must be *very* old.

Regards,

Giampaolo

2011/7/12 Brian Rak <d...@devicenull.org>:

> --
> You received this message because you are subscribed to the "Python FTP server library" project group:
> http://code.google.com/p/pyftpdlib/
> To post to this group, send email to pyft...@googlegroups.com
> To unsubscribe from this group, send email to pyftpdlib-...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/pyftpdlib

Brian Rak

unread,
Jul 13, 2011, 11:18:01 PM7/13/11
to Python FTP server library - Discussion group
Yea, I'm not terribly surprised by you not wanting to support it. We
already maintain a somewhat customized version of the library (with
http://code.google.com/p/pyftpdlib/issues/detail?id=170 , and the
chmod implementation I wrote before I realized it was already in
trunk), so it's not a problem for us anymore. I was mainly posting
this in case anyone else runs into the same issue.

I don't have a specific version number on this handy, but yea it's
probably 5+ year old software that it's an issue in.
Reply all
Reply to author
Forward
0 new messages