summaryrefslogtreecommitdiff
path: root/nova/console/websocketproxy.py
diff options
context:
space:
mode:
authorStephen Finucane <sfinucan@redhat.com>2018-01-08 15:55:30 +0000
committerStephen Finucane <sfinucan@redhat.com>2018-01-12 10:00:10 +0000
commit4d520e3cae4cc530d85290b425d40aef597df0a1 (patch)
treeaf47440f3c27af4840a00824eecfeec09346edd5 /nova/console/websocketproxy.py
parent614403370a877d6c8ab841cd593f822d4675319b (diff)
downloadnova-4d520e3cae4cc530d85290b425d40aef597df0a1.tar.gz
console: Send bytes to sockets
Sockets expect byte strings. The default string type in Python 3 is unicode, meaning calls to socket functions with unencoded strings will fail. Fix two paths where we were potentially sending unicode, thus resolving this issue. One of these paths is tested here. The other in currently unexercised code and will be tested in a future change. Change-Id: If8fb291ae672a01af4bde96d55b487c450fb2564 Implements: bp websocket-proxy-to-host-security
Diffstat (limited to 'nova/console/websocketproxy.py')
-rw-r--r--nova/console/websocketproxy.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/nova/console/websocketproxy.py b/nova/console/websocketproxy.py
index 7f42d3e79e..b87abb17bb 100644
--- a/nova/console/websocketproxy.py
+++ b/nova/console/websocketproxy.py
@@ -22,6 +22,7 @@ import socket
import sys
from oslo_log import log as logging
+from oslo_utils import encodeutils
import six
from six.moves import http_cookies as Cookie
import six.moves.urllib.parse as urlparse
@@ -76,7 +77,7 @@ class TenantSock(object):
return b''.join(popped)
def sendall(self, data):
- self.reqhandler.send_frames([data])
+ self.reqhandler.send_frames([encodeutils.safe_encode(data)])
def finish_up(self):
self.reqhandler.send_frames([b''.join([self.queue])])
@@ -193,8 +194,9 @@ class NovaProxyRequestHandlerBase(object):
# Handshake as necessary
if connect_info.get('internal_access_path'):
- tsock.send("CONNECT %s HTTP/1.1\r\n\r\n" %
- connect_info['internal_access_path'])
+ tsock.send(encodeutils.safe_encode(
+ "CONNECT %s HTTP/1.1\r\n\r\n" %
+ connect_info['internal_access_path']))
end_token = "\r\n\r\n"
while True:
data = tsock.recv(4096, socket.MSG_PEEK)