diff --git a/dput/methods/ftp.py b/dput/methods/ftp.py index a935d0854d904df75976a5176a10212b8a6e6857..0ad82140ec6816d1f73c32cc0e4de4a323d02bf7 100644 --- a/dput/methods/ftp.py +++ b/dput/methods/ftp.py @@ -17,16 +17,24 @@ from ..helper import dputhelper def upload( fqdn, login, incoming, files_to_upload, debug, ftp_mode, - progress=0, port=21): + progress=0, port=21, use_tls=False): """ Upload the files via FTP. (Could need a bit more error-checking.) """ + # Custom port: ftplib.FTP somehow implicitly works with port appendix to fqdn, ftplib.FTP_TLS does not. + _fqdn, _sep, _port = fqdn.partition(":") + if _port: + fqdn = _fqdn + port = int(_port) try: - ftp_connection = ftplib.FTP() + ftp_connection = ftplib.FTP_TLS() if use_tls else ftplib.FTP() ftp_connection.connect(fqdn, port) + if use_tls: + ftp_connection.auth() + ftp_connection.prot_p() if debug: sys.stdout.write("D: FTP-Connection to host: %s\n" % fqdn) except ftplib.all_errors as e: diff --git a/dput/methods/ftps.py b/dput/methods/ftps.py new file mode 100644 index 0000000000000000000000000000000000000000..7849123d96b598e964214a6a0963604e0c223d57 --- /dev/null +++ b/dput/methods/ftps.py @@ -0,0 +1,16 @@ +# dput/methods/ftps.py +# Part of ‘dput’, a Debian package upload toolkit. +# +# This is free software, and you are welcome to redistribute it under +# certain conditions; see the end of this file for copyright +# information, grant of license, and disclaimer of warranty. + +""" Implementation for FTPS (RFC 4217) upload method. """ + +from . import ftp + + +def upload( + fqdn, login, incoming, files_to_upload, debug, ftp_mode, + progress=0, port=990): + ftp.upload(fqdn, login, incoming, files_to_upload, debug, ftp_mode, progress, port, use_tls=True)