Skip to content

Commit 127dbb2

Browse files
committed
Ensure vncserver doesn't open a TCP port
1 parent c5aa5d1 commit 127dbb2

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

.github/workflows/test.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ jobs:
6060
6161
- name: Test vncserver
6262
run: |
63-
container_id=$(docker run -d -it test vncserver -xstartup /opt/install/jupyter_remote_desktop_proxy/share/xstartup -verbose -fg -geometry 1680x1050 -SecurityTypes None -rfbunixpath /tmp/vncserver.socket)
63+
# TigerVNC needs to be configured with -rfbport -1 to not open a TCP
64+
# port, while TurboVNC doesn't support being passed -1 and won't open
65+
# a TCP port anyhow.
66+
rfbport_arg="-rfbport -1"
67+
if [ "${{ matrix.vncserver }}" == "turbovnc" ]; then rfbport_arg=""; fi
68+
69+
container_id=$(docker run -d -it test vncserver -xstartup /opt/install/jupyter_remote_desktop_proxy/share/xstartup -verbose -fg -geometry 1680x1050 -SecurityTypes None -rfbunixpath /tmp/vncserver.socket $rfbport_arg)
6470
sleep 1
6571
6672
echo "::group::Install netcat, a test dependency"

jupyter_remote_desktop_proxy/setup_websockify.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,27 @@ def setup_websockify():
1212
"vncserver executable not found, please install a VNC server"
1313
)
1414

15+
# TurboVNC and TigerVNC share the same origin and both use a Perl script
16+
# as the executable vncserver. We can determine if vncserver is TigerVNC
17+
# by searching tigervnc string in the Perl script.
18+
#
19+
# The content of the vncserver executable can differ depending on how
20+
# TigerVNC and TurboVNC has been distributed. Below are files known to be
21+
# read in some situations:
22+
#
23+
# - https://github.com/TigerVNC/tigervnc/blob/v1.13.1/unix/vncserver/vncserver.in
24+
# - https://github.com/TurboVNC/turbovnc/blob/3.1.1/unix/vncserver.in
25+
#
26+
with open(vncserver) as vncserver_file:
27+
vncserver_file_text = vncserver_file.read().casefold()
28+
is_turbovnc = "turbovnc" in vncserver_file_text
29+
1530
# {unix_socket} is expanded by jupyter-server-proxy
16-
vnc_args = [vncserver, '-rfbunixpath', '{unix_socket}']
31+
vnc_args = [vncserver, '-rfbunixpath', "{unix_socket}", "-rfbport", "-1"]
32+
if is_turbovnc:
33+
# turbovnc doesn't handle being passed -rfbport -1, but turbovnc also
34+
# defaults to not opening a TCP port which is what we want to ensure
35+
vnc_args = [vncserver, '-rfbunixpath', "{unix_socket}"]
1736

1837
xstartup = os.getenv("JUPYTER_REMOTE_DESKTOP_PROXY_XSTARTUP")
1938
if not xstartup and not os.path.exists(os.path.expanduser('~/.vnc/xstartup')):

0 commit comments

Comments
 (0)