7
7
8
8
9
9
def setup_websockify ():
10
- # make a secure temporary directory for sockets
11
- # This is only readable, writeable & searchable by our uid
12
- sockets_dir = tempfile .mkdtemp ()
13
- sockets_path = os .path .join (sockets_dir , 'vnc-socket' )
14
10
vncserver = which ('vncserver' )
15
-
16
11
if not vncserver :
17
12
raise RuntimeError (
18
13
"vncserver executable not found, please install a VNC server"
19
14
)
20
15
21
- # TigerVNC provides the option to connect a Unix socket. TurboVNC does not.
22
16
# TurboVNC and TigerVNC share the same origin and both use a Perl script
23
17
# as the executable vncserver. We can determine if vncserver is TigerVNC
24
18
# by searching tigervnc string in the Perl script.
@@ -34,11 +28,17 @@ def setup_websockify():
34
28
is_tigervnc = "tigervnc" in vncserver_file .read ().casefold ()
35
29
36
30
if is_tigervnc :
31
+ # Make a secure temporary directory for sockets that is only readable,
32
+ # writeable, and searchable by our uid - TigerVNC can listen to a Unix
33
+ # socket!
34
+ sockets_dir = tempfile .mkdtemp ()
35
+ sockets_path = os .path .join (sockets_dir , 'vnc-socket' )
36
+
37
+ websockify_args = ['--unix-target' , sockets_path ]
37
38
vnc_args = [vncserver , '-rfbunixpath' , sockets_path ]
38
- socket_args = ['--unix-target' , sockets_path ]
39
39
else :
40
- vnc_args = [vncserver , '-rfbport' , '{port}' ]
41
- socket_args = []
40
+ websockify_args = []
41
+ vnc_args = [vncserver , '-localhost' , '-rfbport' , '{port}' ]
42
42
43
43
if not os .path .exists (os .path .expanduser ('~/.vnc/xstartup' )):
44
44
vnc_args .extend (['-xstartup' , os .path .join (HERE , 'share/xstartup' )])
@@ -47,23 +47,22 @@ def setup_websockify():
47
47
vnc_args
48
48
+ [
49
49
'-verbose' ,
50
+ '-fg' ,
50
51
'-geometry' ,
51
52
'1680x1050' ,
52
53
'-SecurityTypes' ,
53
54
'None' ,
54
- '-fg' ,
55
55
]
56
56
)
57
57
58
58
return {
59
59
'command' : [
60
60
'websockify' ,
61
- '-v' ,
62
- '--heartbeat' ,
63
- '30' ,
61
+ '--verbose' ,
62
+ '--heartbeat=30' ,
64
63
'{port}' ,
65
64
]
66
- + socket_args
65
+ + websockify_args
67
66
+ ['--' , '/bin/sh' , '-c' , f'cd { os .getcwd ()} && { vnc_command } ' ],
68
67
'timeout' : 30 ,
69
68
'new_browser_window' : True ,
0 commit comments