From 4a01257401e93eba244af4c854d4c9adea514a75 Mon Sep 17 00:00:00 2001 From: Tony Asleson Date: Mon, 11 Dec 2023 15:39:57 -0600 Subject: [PATCH 1/2] main.py: Replace ssl.wrap_socket -> SSLContext.wrap_socket Changes required for python 3.12 breaking changes. Signed-off-by: Tony Asleson --- targetd/main.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/targetd/main.py b/targetd/main.py index 2184980..c287b7d 100644 --- a/targetd/main.py +++ b/targetd/main.py @@ -203,17 +203,6 @@ class HTTPService(ThreadingMixIn, HTTPServer, object): class TLSHTTPService(HTTPService): """Also use TLS to encrypt the connection""" - def finish_request(self, sock, addr): - sockssl = ssl.wrap_socket( - sock, - server_side=True, - keyfile=config["ssl_key"], - certfile=config["ssl_cert"], - ciphers="HIGH:-aNULL:-eNULL:-PSK", - suppress_ragged_eofs=True, - ) - return self.RequestHandlerClass(sockssl, addr, self) - @staticmethod def _verify_ssl_file(f): rc = False @@ -319,6 +308,14 @@ def handler(signum, frame): RUN = False +def wrap_socket(s): + context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) + context.check_hostname = False + context.load_cert_chain(config["ssl_cert"], config["ssl_key"]) + context.set_ciphers("HIGH:-aNULL:-eNULL:-PSK") + wrapped = context.wrap_socket(s, server_side=True) + return wrapped + def main(): signal.signal(signal.SIGINT, handler) @@ -349,6 +346,7 @@ def main(): note = "(TLS no)" server = server_class(("", 18700), TargetHandler) + server.socket = wrap_socket(server.socket) log.info("started server %s", note) server.timeout = 0.5 From 4b3c2702953def07441db4502066dd93f8e99090 Mon Sep 17 00:00:00 2001 From: Tony Asleson Date: Mon, 11 Dec 2023 15:40:31 -0600 Subject: [PATCH 2/2] zfs.py: Remove escape character which isn't needed Signed-off-by: Tony Asleson --- targetd/backends/zfs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targetd/backends/zfs.py b/targetd/backends/zfs.py index b35f994..d22b7fa 100755 --- a/targetd/backends/zfs.py +++ b/targetd/backends/zfs.py @@ -26,7 +26,7 @@ pools_fs = dict() zfs_cmd = "" zfs_enable_copy = False -ALLOWED_DATASET_NAMES = re.compile("^[A-Za-z0-9][A-Za-z0-9_.\-]*$") +ALLOWED_DATASET_NAMES = re.compile("^[A-Za-z0-9][A-Za-z0-9_.-]*$") class VolInfo(object):