summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2022-02-24 10:52:18 -0500
committerAndrew Cady <d@jerkface.net>2022-02-24 10:52:18 -0500
commit46bca630bff7f30b69757e8f1d0945d447640590 (patch)
treeb5c226b7e43b9e552ebe7d79c919ca52eb1e492a
parentbbef862f4b4c3e540f3be43ce1f9c44cc0e9ffb8 (diff)
avoid use of local TCP port -- use socket file instead
-rwxr-xr-xdot/local/bin/xvnc20
1 files changed, 7 insertions, 13 deletions
diff --git a/dot/local/bin/xvnc b/dot/local/bin/xvnc
index 0a4f46c..ffae919 100755
--- a/dot/local/bin/xvnc
+++ b/dot/local/bin/xvnc
@@ -33,19 +33,13 @@ share_display()
33 fi 33 fi
34 34
35 port=5500 35 port=5500
36 while fuser -vk $port/tcp 36 OUR_TMP=$(mktemp -d) || exit
37 do 37 socket_file=$OUR_TMP/x11vnc.socket
38 sleep 0.1
39 done
40 x11vnc -noxrecord -q -nopw -ncache -ncache_cr -localhost -display "${local_display}" -rfbport "$port" &
41 X11VNC=$!
42 trap 'if [ ! "$DEBUG" ]; then exec 2>/dev/null; fi; set -- "$X11VNC" "$SSH"; ps hu "$@"; kill "$@"' EXIT
43 38
44 while ! fuser -v $port/tcp 39 # killall x11vnc
45 do 40 x11vnc -noxrecord -q -nopw -ncache -ncache_cr -display "${local_display}" -unixsock "$socket_file" &
46 [ -e /proc/"$X11VNC" ] || break 41 X11VNC=$!
47 sleep 0.1 42 trap '[ "$DEBUG" ] || exec 2>/dev/null; set -- "$X11VNC" "$SSH"; ps hu "$@"; kill "$@"' EXIT
48 done
49 43
50 # TODO: spin waiting for port 5500 44 # TODO: spin waiting for port 5500
51 ssh -n \ 45 ssh -n \
@@ -55,7 +49,7 @@ share_display()
55 ssh -n \ 49 ssh -n \
56 -o ControlPath=none \ 50 -o ControlPath=none \
57 -o ExitOnForwardFailure=yes \ 51 -o ExitOnForwardFailure=yes \
58 -R "localhost:$port:localhost:$port" \ 52 -R "localhost:$port:$socket_file" \
59 ${remote_port:+ -p "$remote_port" } \ 53 ${remote_port:+ -p "$remote_port" } \
60 "$remote_host" \ 54 "$remote_host" \
61 "DISPLAY=${remote_display} xvncviewer localhost:$port" 2>&1 & 55 "DISPLAY=${remote_display} xvncviewer localhost:$port" 2>&1 &