Author giampaolo.rodola
Recipients giampaolo.rodola, gregory.p.smith, janssen
Date 2008-02-21.00:19:07
SpamBayes Score 0.00207522
Marked as misclassified No
Message-id <1203553151.33.0.141968162989.issue2054@psf.upfronthosting.co.za>
In-reply-to
Content
I've tried to work on this in the last 2 days and here is my
implementation attempt.
The patch in attachment provides a new FTP subclass which connects to
port 21 as usual leaving control and data channels implicitly unprotected.
Securing control and data channels requires user to explicitly ask for
it by using the new auth_tls() and prot_p() methods as recommended by
the standard RFC.

Usage example:

>>> from ftplib import FTP_TLS
>>> ftps = FTP_TLS('ftp.python.org')
>>> ftps.auth_tls()  # switch to secure control connection
'234 Using authentication type TLS'
>>> ftps.login()  # login anonimously
'230 Guest login ok, access restrictions apply.'
>>> ftps.prot_p()  # switch to secure data connection
'200 Protection level set to P'
>>> ftps.retrlines('LIST')  # list directory content securely
total 9
drwxr-xr-x   8 root     wheel        1024 Jan  3  1994 .
drwxr-xr-x   8 root     wheel        1024 Jan  3  1994 ..
drwxr-xr-x   2 root     wheel        1024 Jan  3  1994 bin
drwxr-xr-x   2 root     wheel        1024 Jan  3  1994 etc
d-wxrwxr-x   2 ftp      wheel        1024 Sep  5 13:43 incoming
drwxr-xr-x   2 root     wheel        1024 Nov 17  1993 lib
drwxr-xr-x   6 1094     wheel        1024 Sep 13 19:07 pub
drwxr-xr-x   3 root     wheel        1024 Jan  3  1994 usr
-rw-r--r--   1 root     root          312 Aug  1  1994 welcome.msg
'226 Transfer complete.'
>>> ftps.quit()
'221 Goodbye.'
>>>

It also provides a prot_c() method to switch back to a plain text data
channel.
Sorry in advance for any grammatical error I could have made in comments
and docstrings.

Comments are greatly appreciated.
History
Date User Action Args
2008-02-21 00:19:11giampaolo.rodolasetspambayes_score: 0.00207522 -> 0.00207522
recipients: + giampaolo.rodola, gregory.p.smith, janssen
2008-02-21 00:19:11giampaolo.rodolasetspambayes_score: 0.00207522 -> 0.00207522
messageid: <1203553151.33.0.141968162989.issue2054@psf.upfronthosting.co.za>
2008-02-21 00:19:09giampaolo.rodolalinkissue2054 messages
2008-02-21 00:19:08giampaolo.rodolacreate