[M2Crypto] Problems uploading to IIS using FTP over SSL

Stephen Nelson-Smith sanelson at gmail.com
Fri Feb 26 12:40:14 CET 2010


System:

# rpm -q python m2crypto
python-2.4.3-27.el5
m2crypto-0.16-6.el5.6
# cat /etc/redhat-release

Red Hat Enterprise Linux Server release 5.4 (Tikanga)
I have the following method:

def ftp_tarball(aggregation_dir, date_format, ftp_server, ftp_user,
ftp_pass):
  date = datetime.today().strftime(date_format)
  ftp = ftpslib.FTP_TLS()
  ftp.connect(ftp_server)
  ftp.auth_tls()
  ftp.set_pasv(0)
  ftp.login(ftp_user, ftp_pass)
  filename = aggregation_dir + 'zultys-logs_' + date + '.tar.gz'
  short_name = os.path.split(filename)[1]
  tarball = open(filename, 'rb')
  ftp.storbinary('STOR ' + short_name, tarball)
  tarball.close()
  ftp.quit()

This works perfectly with VSFTPD on Linux, with SSL forced for non-
anonymous users.

I try to connect to a supplier's IIS FTP server, and get:

Traceback (most recent call last):
  File "/usr/local/bin/lumberjack", line 45, in ?
    lumberjack.ftp_tarball( aggregation_dir, date_format, ftp_server,
ftp_user, ftp_pass )
  File "/usr/lib64/python2.4/site-packages/lumberjack.py", line 93, in
ftp_tarball
    ftp.storbinary('STOR ' + short_name, tarball)
  File "/usr/lib64/python2.4/ftplib.py", line 415, in storbinary
    conn = self.transfercmd(cmd)
  File "/usr/lib64/python2.4/ftplib.py", line 345, in transfercmd
    return self.ntransfercmd(cmd, rest)[0]
  File "/usr/lib64/python2.4/site-packages/M2Crypto/ftpslib.py", line
86, in ntransfercmd
    conn, size = FTP.ntransfercmd(self, cmd, rest)
  File "/usr/lib64/python2.4/ftplib.py", line 331, in ntransfercmd
    sock = self.makeport()
  File "/usr/lib64/python2.4/ftplib.py", line 292, in makeport
    resp = self.sendport(host, port)
  File "/usr/lib64/python2.4/ftplib.py", line 256, in sendport
    return self.voidcmd(cmd)
  File "/usr/lib64/python2.4/ftplib.py", line 246, in voidcmd
    return self.voidresp()
  File "/usr/lib64/python2.4/ftplib.py", line 221, in voidresp
    resp = self.getresp()
  File "/usr/lib64/python2.4/ftplib.py", line 216, in getresp
    raise error_perm, resp
ftplib.error_perm: 501 Server cannot accept argument.

A colleague is able to connect using the Filezilla client, configured
as servertype: FTPES - FTP over explicit TLS/SSL setting.

I've not been able to find any further guidnance on the web.

If you've experienced this before, or can see something that I've
obviously got wrong, I'd appreciate your help.

TIA,

S.



More information about the Python-list mailing list