44# --- BEGIN_HEADER ---
55#
66# grid_ftps - secure ftp server wrapping ftp in tls/ssl and mapping user home
7- # Copyright (C) 2014-2022 The MiG Project lead by Brian Vinter
7+ # Copyright (C) 2014-2026 The MiG Project by the Science HPC Center at UCPH
88#
99# This file is part of MiG.
1010#
2020#
2121# You should have received a copy of the GNU General Public License
2222# along with this program; if not, write to the Free Software
23- # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
24+ # USA.
2425#
2526# -- END_HEADER ---
2627#
9596from mig .shared .accountstate import check_account_accessible
9697from mig .shared .base import invisible_path , force_utf8 , force_native_str
9798from mig .shared .conf import get_configuration_object
99+ from mig .shared .defaults import STRONG_TLS_CIPHERS , STRONG_TLS_LEGACY_CIPHERS
98100from mig .shared .fileio import user_chroot_exceptions
99101from mig .shared .griddaemons .ftps import default_max_user_hits , \
100102 default_user_abuse_hits , default_proto_abuse_hits , \
@@ -333,7 +335,7 @@ class MiGRestrictedFilesystem(AbstractedFS):
333335
334336 def _acceptable_chmod (self , ftps_path , mode ):
335337 """Wrap helper"""
336- #logger.debug("acceptable_chmod: %s" % ftps_path)
338+ # logger.debug("acceptable_chmod: %s" % ftps_path)
337339 reply = acceptable_chmod (ftps_path , mode , self .chmod_exceptions )
338340 if not reply :
339341 logger .warning ("acceptable_chmod failed: %s %s %s" %
@@ -352,7 +354,7 @@ def validpath(self, path):
352354 try :
353355 get_fs_path (configuration , path , self .root ,
354356 daemon_conf ['chroot_exceptions' ])
355- #logger.debug("accepted access to %s" % path)
357+ # logger.debug("accepted access to %s" % path)
356358 return True
357359 except ValueError as err :
358360 logger .warning ("rejected illegal access to %s :: %s" % (path , err ))
@@ -490,14 +492,22 @@ def start_service(conf):
490492 handler .tls_data_required = True
491493 keyfile = certfile = conf .user_ftps_key
492494 handler .certfile = certfile
495+ # Mimic cipher setup from other daemons
496+ ciphers = daemon_conf ['ssl_ciphers' ] = None
493497 # Harden TLS/SSL if possible, requires recent pyftpdlib
494498 if hasattr (handler , 'ssl_context' ):
495- dhparamsfile = configuration .user_shared_dhparams
499+ dhparams_path = configuration .user_shared_dhparams
496500 legacy_tls = configuration .site_enable_ftps_legacy_tls
501+ if ciphers is not None :
502+ use_ciphers = ciphers
503+ elif legacy_tls :
504+ use_ciphers = STRONG_TLS_LEGACY_CIPHERS
505+ else :
506+ use_ciphers = STRONG_TLS_CIPHERS
497507 ssl_ctx = hardened_openssl_context (conf , OpenSSL , keyfile ,
498508 certfile ,
499- dhparamsfile = dhparamsfile ,
500- allow_pre_tlsv12 = legacy_tls )
509+ dhparamsfile = dhparams_path ,
510+ ciphers = use_ciphers )
501511 handler .ssl_context = ssl_ctx
502512 else :
503513 logger .warning ("Unable to enforce explicit strong TLS connections" )
0 commit comments