diff options
Diffstat (limited to 'classes/ssl/ss_vncviewer')
-rwxr-xr-x | classes/ssl/ss_vncviewer | 56 |
1 files changed, 48 insertions, 8 deletions
diff --git a/classes/ssl/ss_vncviewer b/classes/ssl/ss_vncviewer index 381e678..857cfce 100755 --- a/classes/ssl/ss_vncviewer +++ b/classes/ssl/ss_vncviewer @@ -3,7 +3,7 @@ # ss_vncviewer: wrapper for vncviewer to use an stunnel SSL tunnel # or an SSH tunnel. # -# Copyright (c) 2006 by Karl J. Runge <runge@karlrunge.com> +# Copyright (c) 2006-2007 by Karl J. Runge <runge@karlrunge.com> # # You must have stunnel(8) installed on the system and in your PATH # (however, see the -ssh option below, in which case you will need ssh(1) @@ -112,7 +112,9 @@ VNCVIEWERCMD=${VNCVIEWERCMD:-vncviewer} # Same for STUNNEL, e.g. set it to /path/to/stunnel or stunnel4, etc. # -#set -xv +if [ "X$SS_DEBUG" != "X" ]; then + set -xv +fi PATH=$PATH:/usr/sbin:/usr/local/sbin:/dist/sbin; export PATH @@ -146,6 +148,10 @@ showcert="" reverse="" if [ "X$1" = "X-viewerflavor" ]; then + if echo "$VNCVIEWERCMD" | egrep -i '^(xmessage|sleep )' > /dev/null; then + echo "unknown" + exit 0 + fi if echo "$VNCVIEWERCMD" | grep -i chicken.of > /dev/null; then echo "cotvnc" exit 0 @@ -167,6 +173,12 @@ if [ "X$1" = "X-viewerflavor" ]; then exit 0 fi +if [ "X$SS_VNCVIEWER_NO_MAXCONN" != "X" ]; then + STUNNEL_EXTRA_OPTS=`echo "$STUNNEL_EXTRA_OPTS" | sed -e 's/maxconn/#maxconn/'` +elif echo "$VNCVIEWERCMD" | egrep -i '^(xmessage|sleep )' > /dev/null; then + STUNNEL_EXTRA_OPTS=`echo "$STUNNEL_EXTRA_OPTS" | sed -e 's/maxconn/#maxconn/'` +fi + # grab our cmdline options: while [ "X$1" != "X" ] do @@ -215,10 +227,6 @@ else fi if [ "X$reverse" != "X" ]; then ssh_sleep=1800 - if [ "X$use_ssh" = "X1" ]; then - VNCVIEWER_LISTEN_LOCALHOST=1 - export VNCVIEWER_LISTEN_LOCALHOST - fi if [ "X$proxy" != "X" ]; then if [ "X$use_ssh" = "X" -a "X$use_sshssl" = "X" ]; then echo "" @@ -256,6 +264,15 @@ if echo "$orig" | grep '^vnc://' > /dev/null; then direct_connect=1 elif echo "$orig" | grep '^vncs://' > /dev/null; then orig=`echo "$orig" | sed -e 's,vncs://,,'` +elif echo "$orig" | grep '^vncssl://' > /dev/null; then + orig=`echo "$orig" | sed -e 's,vncssl://,,'` +elif echo "$orig" | grep '^vncssh://' > /dev/null; then + orig=`echo "$orig" | sed -e 's,vncssh://,,'` + use_ssh=1 +fi +if [ "X$reverse" != "X" -a "X$direct_connect" = "X" ]; then + VNCVIEWER_LISTEN_LOCALHOST=1 + export VNCVIEWER_LISTEN_LOCALHOST fi # play around with host:display port: @@ -264,6 +281,8 @@ if echo "$orig" | grep ':' > /dev/null; then else if [ "X$reverse" = "X" ]; then orig="$orig:0" + elif [ "X$orig" = "X" ]; then + orig=":0" fi fi @@ -295,11 +314,32 @@ fi date_sec=`date +%S` +if echo "$VNCVIEWERCMD" | grep '^sleep[ ][ ]*[0-9][0-9]*' > /dev/null; then + if [ "X$SS_VNCVIEWER_LISTEN_PORT" = "X" ]; then + p=`echo "$VNCVIEWERCMD" | awk '{print $3}'` + if [ "X$p" != "X" ]; then + SS_VNCVIEWER_LISTEN_PORT=$p + fi + fi + p2=`echo "$VNCVIEWERCMD" | awk '{print $2}'` + VNCVIEWERCMD="eval sleep $p2; echo Local " +elif echo "$VNCVIEWERCMD" | grep '^xmessage[ ][ ]*[0-9][0-9]*' > /dev/null; then + if [ "X$SS_VNCVIEWER_LISTEN_PORT" = "X" ]; then + p=`echo "$VNCVIEWERCMD" | awk '{print $2}'` + SS_VNCVIEWER_LISTEN_PORT=$p + fi +fi + findfree() { try0=$1 try=$try0 use0="" + if [ "X$SS_VNCVIEWER_LISTEN_PORT" != "X" ]; then + echo "$SS_VNCVIEWER_LISTEN_PORT" + return + fi + while [ $try -lt 6000 ] do if [ "X$inuse" = "X" ]; then @@ -763,10 +803,10 @@ if [ "X$direct_connect" != "X" ]; then echo "" echo "NOTE: Press Ctrl-C to terminate viewer LISTEN mode." echo "" - echo "$VNCVIEWERCMD" "$@" -listen $N + echo "$VNCVIEWERCMD" "$@" -listen $disp trap "final" 0 2 15 echo "" - $VNCVIEWERCMD "$@" -listen $N + $VNCVIEWERCMD "$@" -listen $disp fi exit $? fi |