python-websockify/u_Fix-inetd-mode-on-python-2.patch
2017-09-26 08:40:44 +00:00

28 lines
1.2 KiB
Diff

From 7b382d043e9b85fab2fcddf46a54d19bbd4d601c Mon Sep 17 00:00:00 2001
From: Michal Srb <msrb@suse.com>
Date: Tue, 1 Aug 2017 15:35:34 +0200
Subject: [PATCH] Fix inetd mode on Python 2.
In python 2 the ssl.wrap_socket doesn't work on sockets created using socket.fromfd.
The workaround is to wrap the socket returned by socket.fromfd into another socket
object using the private _sock constructor parameter.
---
websockify/websockifyserver.py | 4 ++++
1 file changed, 4 insertions(+)
Index: websockify-0.8.0/websockify/websocket.py
===================================================================
--- websockify-0.8.0.orig/websockify/websocket.py
+++ websockify-0.8.0/websockify/websocket.py
@@ -972,6 +972,10 @@ class WebSocketServer(object):
if self.listen_fd != None:
lsock = socket.fromfd(self.listen_fd, socket.AF_INET, socket.SOCK_STREAM)
+ if sys.hexversion < 0x3000000:
+ # For python 2 we have to wrap the "raw" socket into a socket object,
+ # otherwise ssl wrap_socket doesn't work.
+ lsock = socket.socket(_sock=lsock)
else:
lsock = self.socket(self.listen_host, self.listen_port, False,
self.prefer_ipv6,