summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2022-02-23 22:04:21 -0500
committerS <sv@omni.local>2022-02-24 10:36:32 -0500
commite20447f68b3385a53f2585014632eedb814a4518 (patch)
tree7ba52558dfa97f1bbcd09ed7de1cc0abd5bcf086
parenta16610ab472447adda53230c8fbfa748499b7e89 (diff)
xvnc "-r" option: working solution!
Works around regression in xvncviewer where reverse connections no longer work. We now use direct connections for -r. Also, we now default to direct connections without '-r', since reverse connections fail to forward mouse+keyboard. The occupation of the port on both connection sides is not ideal. Also note that this also shares the local desktop with all other local users. Limiting the port to the calling user would be a good security feature! This may be relevant: https://serverfault.com/questions/127794/forward-local-port-or-socket-file-to-remote-socket-file/753733#753733 Not sure if either x11vnc or xvncviewer can use socket files.
-rwxr-xr-xdot/local/bin/xvnc50
1 files changed, 47 insertions, 3 deletions
diff --git a/dot/local/bin/xvnc b/dot/local/bin/xvnc
index 957fa2b..e1e99a1 100755
--- a/dot/local/bin/xvnc
+++ b/dot/local/bin/xvnc
@@ -1,4 +1,4 @@
1#!/bin/sh 1#!/bin/bash
2 2
3# x11vnc option '-noxrecord' added as workaround for crashing bug 3# x11vnc option '-noxrecord' added as workaround for crashing bug
4# See https://github.com/LibVNC/x11vnc/issues/61 4# See https://github.com/LibVNC/x11vnc/issues/61
@@ -40,6 +40,49 @@ reverse_connection()
40 kill $pid 40 kill $pid
41} 41}
42 42
43ssh()
44{
45 command ssh "$@" 2>&1 | sed 's/^/REMOTE> /'
46}
47
48share_display_direct()
49{
50 if [ "$DEBUG" ]
51 then
52 set -x
53 fi
54
55 port=5500
56 while fuser -vk $port/tcp
57 do
58 sleep 0.1
59 done
60 x11vnc -noxrecord -q -nopw -ncache -ncache_cr -localhost -display "${local_display}" -rfbport "$port" &
61 X11VNC=$!
62 trap 'if [ ! "$DEBUG" ]; then exec 2>/dev/null; fi; set -- "$X11VNC" "$SSH"; ps hu "$@"; kill "$@"' EXIT
63
64 while ! fuser -v $port/tcp
65 do
66 [ -e /proc/"$X11VNC" ] || break
67 sleep 0.1
68 done
69
70 # TODO: spin waiting for port 5500
71 ssh -n \
72 ${remote_port:+ -p "$remote_port" } \
73 "$remote_host" \
74 "fuser -vk $port/tcp && sleep 1"
75 ssh -n \
76 -o ControlPath=none \
77 -o ExitOnForwardFailure=yes \
78 -R "localhost:$port:localhost:$port" \
79 ${remote_port:+ -p "$remote_port" } \
80 "$remote_host" \
81 "DISPLAY=${remote_display} xvncviewer localhost:$port" 2>&1 &
82 SSH=$!
83 wait -n
84}
85
43share_display() 86share_display()
44{ 87{
45 set -x 88 set -x
@@ -60,13 +103,14 @@ share_display()
60if [ "$1" = -r ] 103if [ "$1" = -r ]
61then 104then
62 shift 105 shift
63 cmd=share_display 106 cmd=share_display_direct
64elif [ "$1" = -d ] 107elif [ "$1" = -d ]
65then 108then
66 shift 109 shift
67 cmd=direct_connection 110 cmd=direct_connection
68else 111else
69 cmd=reverse_connection 112 # cmd=reverse_connection
113 cmd=direct_connection
70fi 114fi
71 115
72remote_host=${1:-blackboard} 116remote_host=${1:-blackboard}