Skip to content

Commit

Permalink
tunnel.py fix socket creation problem
Browse files Browse the repository at this point in the history
  • Loading branch information
catborise committed Jul 14, 2020
1 parent f23e6b0 commit b6cb81c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
14 changes: 3 additions & 11 deletions console/novncd
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ django.setup()
import re
import socket
from six.moves import http_cookies as Cookie
from webvirtcloud.settings import WS_PORT, WS_HOST, WS_CERT
from webvirtcloud.settings import WS_PUBLIC_PORT, WS_HOST, WS_CERT
from vrtManager.connection import CONN_SSH, CONN_SOCKET
from console.tunnel import Tunnel
from optparse import OptionParser
Expand Down Expand Up @@ -55,7 +55,7 @@ parser.add_option("-p",
dest="port",
action="store",
help="Listen port",
default=WS_PORT or 6080)
default=WS_PUBLIC_PORT or 6080)

parser.add_option("-c",
"--cert",
Expand Down Expand Up @@ -145,13 +145,6 @@ class CompatibilityMixIn(object):
if 'token' in cookie:
token = cookie['token'].value

# cookie = Cookie.SimpleCookie()
# cookie.load(self.headers.getheader('cookie'))
# if 'token' not in cookie:
# self.msg('No token cookie found !')
# return False
# token = cookie['token'].value

(connhost, connport, connuser, conntype, console_host, console_port,
console_socket) = get_connection_infos(token)

Expand Down Expand Up @@ -213,8 +206,7 @@ class CompatibilityMixIn(object):
if tsock:
tsock.shutdown(socket.SHUT_RDWR)
tsock.close()
if tunnel:
tunnel.close()
tunnel.close()
raise


Expand Down
7 changes: 3 additions & 4 deletions console/tunnel.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import logging
from functools import reduce


class Tunnel(object):
def __init__(self):
self.outfd = None
Expand Down Expand Up @@ -92,9 +91,9 @@ def open(self, connhost, connuser, connport, gaddr, gport, gsocket):
os.close(0)
os.close(1)
os.close(2)
os.dup(fds[1].fileno())
os.dup(fds[1].fileno())
os.dup(errorfds[1].fileno())
os.dup2(fds[1].fileno(), 0)
os.dup2(fds[1].fileno(), 1)
os.dup2(errorfds[1].fileno(), 2)
os.execlp(*argv)
os._exit(1)
else:
Expand Down

0 comments on commit b6cb81c

Please sign in to comment.