From 6f15f1b50a7ce1df73baede10297b64f83e05996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20S=C3=BCrken?= Date: Tue, 19 Jan 2021 14:09:16 +0100 Subject: [PATCH 1/2] methods/ftp.py: Explicitly set custom port from fqdn. --- dput/methods/ftp.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dput/methods/ftp.py b/dput/methods/ftp.py index a935d08..e6a9e5a 100644 --- a/dput/methods/ftp.py +++ b/dput/methods/ftp.py @@ -23,6 +23,11 @@ def upload( (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() -- GitLab From 0265d43af5c143ca1e81dd5212d571cf92836be5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20S=C3=BCrken?= Date: Tue, 19 Jan 2021 12:12:52 +0100 Subject: [PATCH 2/2] methods/ftp[s].py: Add support for 'ftps' method. --- dput/methods/ftp.py | 7 +++++-- dput/methods/ftps.py | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 dput/methods/ftps.py diff --git a/dput/methods/ftp.py b/dput/methods/ftp.py index e6a9e5a..0ad8214 100644 --- a/dput/methods/ftp.py +++ b/dput/methods/ftp.py @@ -17,7 +17,7 @@ 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.) @@ -30,8 +30,11 @@ def upload( 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 0000000..7849123 --- /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) -- GitLab