Commit 95d7788e authored by runge's avatar runge

x11vnc: -sleepin m-n for random sleep. More mktemp and mkstemp

protections. SSL_INIT_TIMEOUT=n env. var.  Fix macosx console
X call bug.  Synchronize other projects sources.
parent d5cba7a5
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
...@@ -39,7 +39,8 @@ ...@@ -39,7 +39,8 @@
# and then a 2nd CONNECT to the destination VNC server.) # and then a 2nd CONNECT to the destination VNC server.)
# #
# Use socks://host:port, socks4://host:port, or socks5://host,port # Use socks://host:port, socks4://host:port, or socks5://host,port
# to force usage of a SOCKS proxy. Also repeater://host:port. # to force usage of a SOCKS proxy. Also repeater://host:port and
# sslrepeater://host:port.
# #
# -showcert Only fetch the certificate using the 'openssl s_client' # -showcert Only fetch the certificate using the 'openssl s_client'
# command (openssl(1) must in installed). # command (openssl(1) must in installed).
...@@ -284,6 +285,19 @@ fi ...@@ -284,6 +285,19 @@ fi
orig="$1" orig="$1"
shift shift
# set up special case of ultravnc single click III mode:
if echo "$proxy" | egrep "^sslrepeater://" > /dev/null; then
pstr=`echo "$proxy" | sed -e 's,sslrepeater://,,'`
pstr1=`echo "$pstr" | sed -e 's/+.*$//'`
pstr2=`echo "$pstr" | sed -e 's/^[^+]*+//'`
SSVNC_REPEATER="SCIII=$pstr2"; export SSVNC_REPEATER
orig=$pstr1
echo
echo "reset: SSVNC_REPEATER=$SSVNC_REPEATER orig=$orig proxy=''"
proxy=""
fi
# check -ssh and -mycert/-verify conflict: # check -ssh and -mycert/-verify conflict:
if [ "X$use_ssh" = "X1" -a "X$use_sshssl" = "X" ]; then if [ "X$use_ssh" = "X1" -a "X$use_sshssl" = "X" ]; then
if [ "X$mycert" != "X" -o "X$verify" != "X" ]; then if [ "X$mycert" != "X" -o "X$verify" != "X" ]; then
...@@ -322,6 +336,14 @@ elif echo "$orig" | grep '^vnc+ssh://' > /dev/null; then ...@@ -322,6 +336,14 @@ elif echo "$orig" | grep '^vnc+ssh://' > /dev/null; then
use_ssh=1 use_ssh=1
fi fi
if [ "X$SSVNC_ULTRA_DSM" != "X" ]; then
verify=""
mycert=""
use_ssh=""
use_sshssl=""
direct_connect=1
fi
# (possibly) tell the vncviewer to only listen on lo: # (possibly) tell the vncviewer to only listen on lo:
if [ "X$reverse" != "X" -a "X$direct_connect" = "X" ]; then if [ "X$reverse" != "X" -a "X$direct_connect" = "X" ]; then
VNCVIEWER_LISTEN_LOCALHOST=1 VNCVIEWER_LISTEN_LOCALHOST=1
...@@ -472,6 +494,14 @@ final() { ...@@ -472,6 +494,14 @@ final() {
kill -KILL "$stunnel_pid" 2>/dev/null kill -KILL "$stunnel_pid" 2>/dev/null
stunnel_pid="" stunnel_pid=""
fi fi
if [ "X$dsm_pid" != "X" ]; then
echo "Terminating background ultravnc_dsm_helper process"
echo kill -TERM "$dsm_pid"
kill -TERM "$dsm_pid" 2>/dev/null
sleep 1
kill -KILL "$dsm_pid" 2>/dev/null
stunnel_pid=""
fi
if [ "X$tail_pid" != "X" ]; then if [ "X$tail_pid" != "X" ]; then
kill -TERM $tail_pid kill -TERM $tail_pid
fi fi
...@@ -517,6 +547,19 @@ fi ...@@ -517,6 +547,19 @@ fi
# a portable, but not absolutely safe, tmp file creator # a portable, but not absolutely safe, tmp file creator
mytmp() { mytmp() {
tf=$1 tf=$1
if type mktemp > /dev/null 2>&1; then
# if we have mktemp(1), use it:
tf2="$tf.XXXXXX"
tf2=`mktemp "$tf2"`
if [ "X$tf2" != "X" -a -f "$tf2" ]; then
if [ "X$DEBUG_MKTEMP" != "X" ]; then
echo "mytmp-mktemp: $tf2" 1>&2
fi
echo "$tf2"
return
fi
fi
# fallback to multiple cmds:
rm -rf "$tf" || exit 1 rm -rf "$tf" || exit 1
if [ -d "$tf" ]; then if [ -d "$tf" ]; then
echo "tmp file $tf still exists as a directory." echo "tmp file $tf still exists as a directory."
...@@ -531,6 +574,10 @@ mytmp() { ...@@ -531,6 +574,10 @@ mytmp() {
touch "$tf" || exit 1 touch "$tf" || exit 1
chmod 600 "$tf" || exit 1 chmod 600 "$tf" || exit 1
rchk rchk
if [ "X$DEBUG_MKTEMP" != "X" ]; then
echo "mytmp-touch: $tf" 1>&2
fi
echo "$tf"
} }
# trick for the undocumented rsh://host:port method. # trick for the undocumented rsh://host:port method.
...@@ -1099,8 +1146,8 @@ Kecho sproxy1_host=$sproxy1_host ...@@ -1099,8 +1146,8 @@ Kecho sproxy1_host=$sproxy1_host
Kecho sproxy1_port=$sproxy1_port Kecho sproxy1_port=$sproxy1_port
Kecho sproxy1_user=$sproxy1_user Kecho sproxy1_user=$sproxy1_user
ptmp="/tmp/ss_vncviewer${RANDOM}.$$.pl" ptmp="/tmp/ss_vncviewer_ssh${RANDOM}.$$.pl"
mytmp "$ptmp" ptmp=`mytmp "$ptmp"`
PPROXY_REMOVE=1; export PPROXY_REMOVE PPROXY_REMOVE=1; export PPROXY_REMOVE
proxy=$pproxy proxy=$pproxy
port_save=$port port_save=$port
...@@ -1241,8 +1288,8 @@ Kecho proxy=$proxy ...@@ -1241,8 +1288,8 @@ Kecho proxy=$proxy
rc=$? rc=$?
elif [ "X$getport" != "X" ]; then elif [ "X$getport" != "X" ]; then
tport=/tmp/tport${RANDOM}.$$ tport=/tmp/ss_vncviewer_tport${RANDOM}.$$
mytmp $tport tport=`mytmp "$tport"`
if [ "X$rsh" != "X1" ]; then if [ "X$rsh" != "X1" ]; then
if echo "$ssh_cmd" | grep -w sudo > /dev/null; then if echo "$ssh_cmd" | grep -w sudo > /dev/null; then
...@@ -1441,7 +1488,7 @@ fi ...@@ -1441,7 +1488,7 @@ fi
ptmp="" ptmp=""
if [ "X$proxy" != "X" ]; then if [ "X$proxy" != "X" ]; then
ptmp="/tmp/ss_vncviewer${RANDOM}.$$.pl" ptmp="/tmp/ss_vncviewer${RANDOM}.$$.pl"
mytmp "$ptmp" ptmp=`mytmp "$ptmp"`
PPROXY_REMOVE=1; export PPROXY_REMOVE PPROXY_REMOVE=1; export PPROXY_REMOVE
pcode "$ptmp" pcode "$ptmp"
if [ "X$showcert" != "X1" -a "X$direct_connect" = "X" ]; then if [ "X$showcert" != "X1" -a "X$direct_connect" = "X" ]; then
...@@ -1484,7 +1531,14 @@ if [ "X$showcert" = "X1" ]; then ...@@ -1484,7 +1531,14 @@ if [ "X$showcert" = "X1" ]; then
fi fi
if [ "X$direct_connect" != "X" ]; then if [ "X$direct_connect" != "X" ]; then
if [ "X$getport" = "X" ]; then if [ "X$SSVNC_ULTRA_DSM" != "X" ]; then
SSVNC_NO_ENC_WARN=1
echo ""
echo "Using UltraVNC DSM Plugin key for encryption:"
echo ""
echo " $SSVNC_ULTRA_DSM PORT HOST:PORT"
echo ""
elif [ "X$getport" = "X" ]; then
echo "" echo ""
echo "Running viewer for direct connection:" echo "Running viewer for direct connection:"
echo "" echo ""
...@@ -1508,9 +1562,22 @@ if [ "X$direct_connect" != "X" ]; then ...@@ -1508,9 +1562,22 @@ if [ "X$direct_connect" != "X" ]; then
fi fi
echo "" echo ""
if [ "X$ptmp" != "X" ]; then if [ "X$ptmp" != "X" ]; then
PPROXY_LISTEN=$use if [ "X$reverse" = "X" ]; then
export PPROXY_LISTEN PPROXY_LISTEN=$use
export PPROXY_LISTEN
else
PPROXY_REVERSE="localhost:$use"
export PPROXY_REVERSE
pps=3
if [ "X$SSVNC_EXTRA_SLEEP" != "X" ]; then
pps=`expr $pps + $SSVNC_EXTRA_SLEEP`
fi
PPROXY_SLEEP=$pps; export PPROXY_SLEEP;
PPROXY_KILLPID=+1; export PPROXY_KILLPID;
fi
$ptmp & $ptmp &
if [ "X$reverse" = "X" ]; then if [ "X$reverse" = "X" ]; then
#sleep 2 #sleep 2
#echo T sleep 1 #echo T sleep 1
...@@ -1518,29 +1585,52 @@ if [ "X$direct_connect" != "X" ]; then ...@@ -1518,29 +1585,52 @@ if [ "X$direct_connect" != "X" ]; then
fi fi
host="localhost" host="localhost"
disp="$N" disp="$N"
port=`expr $disp + 5900`
fi fi
if [ "X$SSVNC_EXTRA_SLEEP" != "X" ]; then if [ "X$SSVNC_EXTRA_SLEEP" != "X" ]; then
echo "T sleep $SSVNC_EXTRA_SLEEP" echo "T sleep $SSVNC_EXTRA_SLEEP"
sleep $SSVNC_EXTRA_SLEEP sleep $SSVNC_EXTRA_SLEEP
fi fi
if [ "X$reverse" = "X" ]; then if [ "X$reverse" = "X" ]; then
echo "$VNCVIEWERCMD" "$@" $host:$disp hostdisp="$host:$disp"
if [ "X$SSVNC_ULTRA_DSM" != "X" ]; then
hostdisp="exec=$SSVNC_ULTRA_DSM 0 $host:$port"
fi
echo "$VNCVIEWERCMD" "$@" "$hostdisp"
trap "final" 0 2 15 trap "final" 0 2 15
echo "" echo ""
$VNCVIEWERCMD "$@" $host:$disp $VNCVIEWERCMD "$@" "$hostdisp"
if [ $? != 0 ]; then if [ $? != 0 ]; then
echo "vncviewer command failed: $?" echo "vncviewer command failed: $?"
if [ "X$secondtry" = "X1" ]; then if [ "X$secondtry" = "X1" ]; then
sleep 2 sleep 2
$VNCVIEWERCMD "$@" $host:$disp $VNCVIEWERCMD "$@" "$hostdisp"
fi fi
fi fi
else else
echo "" echo ""
echo "NOTE: Press Ctrl-C to terminate viewer LISTEN mode." echo "NOTE: Press Ctrl-C to terminate viewer LISTEN mode."
echo "" echo ""
echo "$VNCVIEWERCMD" "$@" -listen $disp
trap "final" 0 2 15 trap "final" 0 2 15
if [ "X$SSVNC_ULTRA_DSM" != "X" ]; then
echo "NOTE: The ultravnc_dsm_helper only runs once. So after the first LISTEN"
echo " ends, you will have to Press Ctrl-C and restart for a new connection."
echo ""
dport=`expr 5500 + $disp`
cmd="$SSVNC_ULTRA_DSM $dport localhost:$use"
echo "Running:"
echo
echo "$cmd &"
echo
$cmd &
dsm_pid=$!
sleep 2
disp=$use
if [ $disp -ge 5500 ]; then
disp=`expr $disp - 5500`
fi
fi
echo "$VNCVIEWERCMD" "$@" -listen $disp
echo "" echo ""
$VNCVIEWERCMD "$@" -listen $disp $VNCVIEWERCMD "$@" -listen $disp
fi fi
...@@ -1548,12 +1638,13 @@ if [ "X$direct_connect" != "X" ]; then ...@@ -1548,12 +1638,13 @@ if [ "X$direct_connect" != "X" ]; then
fi fi
tmp_cfg=/tmp/ss_vncviewer${RANDOM}.$$ tmp_cfg=/tmp/ss_vncviewer${RANDOM}.$$
mytmp "$tmp_cfg" tmp_cfg=`mytmp "$tmp_cfg"`
# make_tcert is no longer invoked via the ssvnc gui (Listen mode). # make_tcert is no longer invoked via the ssvnc gui (Listen mode).
# make_tcert is for testing only now via -mycert BUILTIN # make_tcert is for testing only now via -mycert BUILTIN
make_tcert() { make_tcert() {
tcert="/tmp/tcert${RANDOM}.$$" tcert="/tmp/ss_vnc_viewer_tcert${RANDOM}.$$"
tcert=`mytmp "$tcert"`
cat > $tcert <<END cat > $tcert <<END
-----BEGIN RSA PRIVATE KEY----- -----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAvkfXxb0wcxgrjV2ziFikjII+ze8iKcTBt47L0GM/c21efelN MIIEowIBAAKCAQEAvkfXxb0wcxgrjV2ziFikjII+ze8iKcTBt47L0GM/c21efelN
...@@ -1617,7 +1708,7 @@ fi ...@@ -1617,7 +1708,7 @@ fi
if [ "X$reverse" = "X" ]; then if [ "X$reverse" = "X" ]; then
if echo "$proxy" | grep repeater:// > /dev/null; then if echo "$proxy" | grep "^repeater://" > /dev/null; then
if [ "X$cert" = "XBUILTIN" ]; then if [ "X$cert" = "XBUILTIN" ]; then
ttcert=`make_tcert` ttcert=`make_tcert`
cert="cert = $ttcert" cert="cert = $ttcert"
......
2008-09-14 Karl Runge <runge@karlrunge.com>
* x11vnc: -sleepin m-n for random sleep. More mktemp and mkstemp
protections. SSL_INIT_TIMEOUT=n env. var. Fix macosx console
X call bug. Synchronize other projects sources.
2008-09-06 Karl Runge <runge@karlrunge.com> 2008-09-06 Karl Runge <runge@karlrunge.com>
* x11vnc: kill gui_pid on exit in -connect/-connect_or_exit mode. * x11vnc: kill gui_pid on exit in -connect/-connect_or_exit mode.
-grablocal n experiment (not compiled by default). -macuskbd -grablocal n experiment (not compiled by default). -macuskbd
......
This diff is collapsed.
...@@ -667,24 +667,22 @@ void do_gui(char *opts, int sleep) { ...@@ -667,24 +667,22 @@ void do_gui(char *opts, int sleep) {
pid_t parent = getpid(); pid_t parent = getpid();
if (icon_mode) { if (icon_mode) {
char tf[100]; char tf[] = "/tmp/x11vnc.tray.XXXXXX";
double dn = dnow(); int fd;
struct stat sbuf; struct stat sbuf;
/* FIXME */
dn = dn - ((int) dn); fd = mkstemp(tf);
sprintf(tf, "/tmp/x11vnc.tray%d%d", (int) (1000000*dn), if (fd < 0) {
(int) getpid());
unlink(tf);
/* race begins.. */
if (stat(tf, &sbuf) == 0) {
icon_mode = 0; icon_mode = 0;
} else { } else {
close(fd);
icon_mode_fh = fopen(tf, "w"); icon_mode_fh = fopen(tf, "w");
if (! icon_mode_fh) { if (! icon_mode_fh) {
icon_mode = 0; icon_mode = 0;
} else { } else {
chmod(tf, 0400); chmod(tf, 0400);
icon_mode_file = strdup(tf); icon_mode_file = strdup(tf);
rfbLog("icon_mode_file=%s\n", icon_mode_file);
fprintf(icon_mode_fh, "none\n"); fprintf(icon_mode_fh, "none\n");
fprintf(icon_mode_fh, "none\n"); fprintf(icon_mode_fh, "none\n");
fflush(icon_mode_fh); fflush(icon_mode_fh);
......
...@@ -360,9 +360,14 @@ void print_help(int mode) { ...@@ -360,9 +360,14 @@ void print_help(int mode) {
"\n" "\n"
"-timeout n Exit unless a client connects within the first n seconds\n" "-timeout n Exit unless a client connects within the first n seconds\n"
" after startup.\n" " after startup.\n"
"\n"
"-sleepin n At startup sleep n seconds before proceeding (e.g. to\n" "-sleepin n At startup sleep n seconds before proceeding (e.g. to\n"
" allow redirs and listening clients to start up)\n" " allow redirs and listening clients to start up)\n"
"\n" "\n"
" If a range is given: '-sleepin min-max', a random value\n"
" between min and max is slept. E.g. '-sleepin 0-20' and\n"
" '-sleepin 10-30'. Floats are allowed too.\n"
"\n"
"-inetd Launched by inetd(8): stdio instead of listening socket.\n" "-inetd Launched by inetd(8): stdio instead of listening socket.\n"
" Note: if you are not redirecting stderr to a log file\n" " Note: if you are not redirecting stderr to a log file\n"
" (via shell 2> or -o option) you MUST also specify the -q\n" " (via shell 2> or -o option) you MUST also specify the -q\n"
...@@ -1296,6 +1301,10 @@ void print_help(int mode) { ...@@ -1296,6 +1301,10 @@ void print_help(int mode) {
" Set to zero to poll forever. Set to a negative value\n" " Set to zero to poll forever. Set to a negative value\n"
" to use the builtin setting.\n" " to use the builtin setting.\n"
"\n" "\n"
" Note that this value does not apply to the *initial* ssl\n"
" init connection. The default timeout for that is 20sec.\n"
" Use -env SSL_INIT_TIMEOUT=n to modify it.\n"
"\n"
"-sslnofail Exit at the first SSL connection failure. Useful when\n" "-sslnofail Exit at the first SSL connection failure. Useful when\n"
" scripting SSL connections (e.g. x11vnc is started via\n" " scripting SSL connections (e.g. x11vnc is started via\n"
" ssh) and you do not want x11vnc waiting around for more\n" " ssh) and you do not want x11vnc waiting around for more\n"
...@@ -2197,6 +2206,9 @@ void print_help(int mode) { ...@@ -2197,6 +2206,9 @@ void print_help(int mode) {
" where a Keysym is bound to multiple keys (e.g. \"<\" + \">\"\n" " where a Keysym is bound to multiple keys (e.g. \"<\" + \">\"\n"
" and \",\" + \"<\" keys). Default: %s\n" " and \",\" + \"<\" keys). Default: %s\n"
"\n" "\n"
" If you are having trouble with with keys and -xkb or\n"
" -noxkb, and similar things don't help, try -nomodtweak.\n"
"\n"
" On some HP-UX systems it is been noted that they have\n" " On some HP-UX systems it is been noted that they have\n"
" an odd keymapping where a single keycode will have a\n" " an odd keymapping where a single keycode will have a\n"
" keysym, e.g. \"#\", up to three times. You can check\n" " keysym, e.g. \"#\", up to three times. You can check\n"
......
...@@ -129,6 +129,9 @@ The enhanced TightVNC viewer features are: ...@@ -129,6 +129,9 @@ The enhanced TightVNC viewer features are:
- Support for UltraVNC Single Click operation. (both unencrypted: - Support for UltraVNC Single Click operation. (both unencrypted:
SC I, and SSL encrypted: SC III) SC I, and SSL encrypted: SC III)
- Support for UltraVNC DSM Encryption Plugin mode. (ARC4 and
AESV2, but not MSRC4 yet)
- Instead of hostname:display one can also supply "exec=command args..." - Instead of hostname:display one can also supply "exec=command args..."
to connect the viewer to the stdio of an external command to connect the viewer to the stdio of an external command
(e.g. stunnel or socat) rather than using a TCP/IP socket. (e.g. stunnel or socat) rather than using a TCP/IP socket.
......
...@@ -39,7 +39,8 @@ ...@@ -39,7 +39,8 @@
# and then a 2nd CONNECT to the destination VNC server.) # and then a 2nd CONNECT to the destination VNC server.)
# #
# Use socks://host:port, socks4://host:port, or socks5://host,port # Use socks://host:port, socks4://host:port, or socks5://host,port
# to force usage of a SOCKS proxy. Also repeater://host:port. # to force usage of a SOCKS proxy. Also repeater://host:port and
# sslrepeater://host:port.
# #
# -showcert Only fetch the certificate using the 'openssl s_client' # -showcert Only fetch the certificate using the 'openssl s_client'
# command (openssl(1) must in installed). # command (openssl(1) must in installed).
...@@ -284,6 +285,19 @@ fi ...@@ -284,6 +285,19 @@ fi
orig="$1" orig="$1"
shift shift
# set up special case of ultravnc single click III mode:
if echo "$proxy" | egrep "^sslrepeater://" > /dev/null; then
pstr=`echo "$proxy" | sed -e 's,sslrepeater://,,'`
pstr1=`echo "$pstr" | sed -e 's/+.*$//'`
pstr2=`echo "$pstr" | sed -e 's/^[^+]*+//'`
SSVNC_REPEATER="SCIII=$pstr2"; export SSVNC_REPEATER
orig=$pstr1
echo
echo "reset: SSVNC_REPEATER=$SSVNC_REPEATER orig=$orig proxy=''"
proxy=""
fi
# check -ssh and -mycert/-verify conflict: # check -ssh and -mycert/-verify conflict:
if [ "X$use_ssh" = "X1" -a "X$use_sshssl" = "X" ]; then if [ "X$use_ssh" = "X1" -a "X$use_sshssl" = "X" ]; then
if [ "X$mycert" != "X" -o "X$verify" != "X" ]; then if [ "X$mycert" != "X" -o "X$verify" != "X" ]; then
...@@ -322,6 +336,14 @@ elif echo "$orig" | grep '^vnc+ssh://' > /dev/null; then ...@@ -322,6 +336,14 @@ elif echo "$orig" | grep '^vnc+ssh://' > /dev/null; then
use_ssh=1 use_ssh=1
fi fi
if [ "X$SSVNC_ULTRA_DSM" != "X" ]; then
verify=""
mycert=""
use_ssh=""
use_sshssl=""
direct_connect=1
fi
# (possibly) tell the vncviewer to only listen on lo: # (possibly) tell the vncviewer to only listen on lo:
if [ "X$reverse" != "X" -a "X$direct_connect" = "X" ]; then if [ "X$reverse" != "X" -a "X$direct_connect" = "X" ]; then
VNCVIEWER_LISTEN_LOCALHOST=1 VNCVIEWER_LISTEN_LOCALHOST=1
...@@ -472,6 +494,14 @@ final() { ...@@ -472,6 +494,14 @@ final() {
kill -KILL "$stunnel_pid" 2>/dev/null kill -KILL "$stunnel_pid" 2>/dev/null
stunnel_pid="" stunnel_pid=""
fi fi
if [ "X$dsm_pid" != "X" ]; then
echo "Terminating background ultravnc_dsm_helper process"
echo kill -TERM "$dsm_pid"
kill -TERM "$dsm_pid" 2>/dev/null
sleep 1
kill -KILL "$dsm_pid" 2>/dev/null
stunnel_pid=""
fi
if [ "X$tail_pid" != "X" ]; then if [ "X$tail_pid" != "X" ]; then
kill -TERM $tail_pid kill -TERM $tail_pid
fi fi
...@@ -517,6 +547,19 @@ fi ...@@ -517,6 +547,19 @@ fi
# a portable, but not absolutely safe, tmp file creator # a portable, but not absolutely safe, tmp file creator
mytmp() { mytmp() {
tf=$1 tf=$1
if type mktemp > /dev/null 2>&1; then
# if we have mktemp(1), use it:
tf2="$tf.XXXXXX"
tf2=`mktemp "$tf2"`
if [ "X$tf2" != "X" -a -f "$tf2" ]; then
if [ "X$DEBUG_MKTEMP" != "X" ]; then
echo "mytmp-mktemp: $tf2" 1>&2
fi
echo "$tf2"
return
fi
fi
# fallback to multiple cmds:
rm -rf "$tf" || exit 1 rm -rf "$tf" || exit 1
if [ -d "$tf" ]; then if [ -d "$tf" ]; then
echo "tmp file $tf still exists as a directory." echo "tmp file $tf still exists as a directory."
...@@ -531,6 +574,10 @@ mytmp() { ...@@ -531,6 +574,10 @@ mytmp() {
touch "$tf" || exit 1 touch "$tf" || exit 1
chmod 600 "$tf" || exit 1 chmod 600 "$tf" || exit 1
rchk rchk
if [ "X$DEBUG_MKTEMP" != "X" ]; then
echo "mytmp-touch: $tf" 1>&2
fi
echo "$tf"
} }
# trick for the undocumented rsh://host:port method. # trick for the undocumented rsh://host:port method.
...@@ -1099,8 +1146,8 @@ Kecho sproxy1_host=$sproxy1_host ...@@ -1099,8 +1146,8 @@ Kecho sproxy1_host=$sproxy1_host
Kecho sproxy1_port=$sproxy1_port Kecho sproxy1_port=$sproxy1_port
Kecho sproxy1_user=$sproxy1_user Kecho sproxy1_user=$sproxy1_user
ptmp="/tmp/ss_vncviewer${RANDOM}.$$.pl" ptmp="/tmp/ss_vncviewer_ssh${RANDOM}.$$.pl"
mytmp "$ptmp" ptmp=`mytmp "$ptmp"`
PPROXY_REMOVE=1; export PPROXY_REMOVE PPROXY_REMOVE=1; export PPROXY_REMOVE
proxy=$pproxy proxy=$pproxy
port_save=$port port_save=$port
...@@ -1241,8 +1288,8 @@ Kecho proxy=$proxy ...@@ -1241,8 +1288,8 @@ Kecho proxy=$proxy
rc=$? rc=$?
elif [ "X$getport" != "X" ]; then elif [ "X$getport" != "X" ]; then
tport=/tmp/tport${RANDOM}.$$ tport=/tmp/ss_vncviewer_tport${RANDOM}.$$
mytmp $tport tport=`mytmp "$tport"`
if [ "X$rsh" != "X1" ]; then if [ "X$rsh" != "X1" ]; then
if echo "$ssh_cmd" | grep -w sudo > /dev/null; then if echo "$ssh_cmd" | grep -w sudo > /dev/null; then
...@@ -1441,7 +1488,7 @@ fi ...@@ -1441,7 +1488,7 @@ fi
ptmp="" ptmp=""
if [ "X$proxy" != "X" ]; then if [ "X$proxy" != "X" ]; then
ptmp="/tmp/ss_vncviewer${RANDOM}.$$.pl" ptmp="/tmp/ss_vncviewer${RANDOM}.$$.pl"
mytmp "$ptmp" ptmp=`mytmp "$ptmp"`
PPROXY_REMOVE=1; export PPROXY_REMOVE PPROXY_REMOVE=1; export PPROXY_REMOVE
pcode "$ptmp" pcode "$ptmp"
if [ "X$showcert" != "X1" -a "X$direct_connect" = "X" ]; then if [ "X$showcert" != "X1" -a "X$direct_connect" = "X" ]; then
...@@ -1484,7 +1531,14 @@ if [ "X$showcert" = "X1" ]; then ...@@ -1484,7 +1531,14 @@ if [ "X$showcert" = "X1" ]; then
fi fi
if [ "X$direct_connect" != "X" ]; then if [ "X$direct_connect" != "X" ]; then
if [ "X$getport" = "X" ]; then if [ "X$SSVNC_ULTRA_DSM" != "X" ]; then
SSVNC_NO_ENC_WARN=1
echo ""
echo "Using UltraVNC DSM Plugin key for encryption:"
echo ""
echo " $SSVNC_ULTRA_DSM PORT HOST:PORT"
echo ""
elif [ "X$getport" = "X" ]; then
echo "" echo ""
echo "Running viewer for direct connection:" echo "Running viewer for direct connection:"
echo "" echo ""
...@@ -1508,9 +1562,22 @@ if [ "X$direct_connect" != "X" ]; then ...@@ -1508,9 +1562,22 @@ if [ "X$direct_connect" != "X" ]; then
fi fi
echo "" echo ""
if [ "X$ptmp" != "X" ]; then if [ "X$ptmp" != "X" ]; then
PPROXY_LISTEN=$use if [ "X$reverse" = "X" ]; then
export PPROXY_LISTEN PPROXY_LISTEN=$use
export PPROXY_LISTEN
else
PPROXY_REVERSE="localhost:$use"
export PPROXY_REVERSE
pps=3
if [ "X$SSVNC_EXTRA_SLEEP" != "X" ]; then
pps=`expr $pps + $SSVNC_EXTRA_SLEEP`
fi
PPROXY_SLEEP=$pps; export PPROXY_SLEEP;
PPROXY_KILLPID=+1; export PPROXY_KILLPID;
fi
$ptmp & $ptmp &
if [ "X$reverse" = "X" ]; then if [ "X$reverse" = "X" ]; then
#sleep 2 #sleep 2
#echo T sleep 1 #echo T sleep 1
...@@ -1518,29 +1585,52 @@ if [ "X$direct_connect" != "X" ]; then ...@@ -1518,29 +1585,52 @@ if [ "X$direct_connect" != "X" ]; then
fi fi
host="localhost" host="localhost"
disp="$N" disp="$N"
port=`expr $disp + 5900`
fi fi
if [ "X$SSVNC_EXTRA_SLEEP" != "X" ]; then if [ "X$SSVNC_EXTRA_SLEEP" != "X" ]; then
echo "T sleep $SSVNC_EXTRA_SLEEP" echo "T sleep $SSVNC_EXTRA_SLEEP"
sleep $SSVNC_EXTRA_SLEEP sleep $SSVNC_EXTRA_SLEEP
fi fi
if [ "X$reverse" = "X" ]; then if [ "X$reverse" = "X" ]; then
echo "$VNCVIEWERCMD" "$@" $host:$disp hostdisp="$host:$disp"
if [ "X$SSVNC_ULTRA_DSM" != "X" ]; then
hostdisp="exec=$SSVNC_ULTRA_DSM 0 $host:$port"
fi
echo "$VNCVIEWERCMD" "$@" "$hostdisp"
trap "final" 0 2 15 trap "final" 0 2 15
echo "" echo ""
$VNCVIEWERCMD "$@" $host:$disp $VNCVIEWERCMD "$@" "$hostdisp"
if [ $? != 0 ]; then if [ $? != 0 ]; then
echo "vncviewer command failed: $?" echo "vncviewer command failed: $?"
if [ "X$secondtry" = "X1" ]; then if [ "X$secondtry" = "X1" ]; then
sleep 2 sleep 2
$VNCVIEWERCMD "$@" $host:$disp $VNCVIEWERCMD "$@" "$hostdisp"
fi fi
fi fi
else else
echo "" echo ""
echo "NOTE: Press Ctrl-C to terminate viewer LISTEN mode." echo "NOTE: Press Ctrl-C to terminate viewer LISTEN mode."
echo "" echo ""
echo "$VNCVIEWERCMD" "$@" -listen $disp
trap "final" 0 2 15 trap "final" 0 2 15
if [ "X$SSVNC_ULTRA_DSM" != "X" ]; then
echo "NOTE: The ultravnc_dsm_helper only runs once. So after the first LISTEN"
echo " ends, you will have to Press Ctrl-C and restart for a new connection."
echo ""
dport=`expr 5500 + $disp`
cmd="$SSVNC_ULTRA_DSM $dport localhost:$use"
echo "Running:"
echo
echo "$cmd &"
echo
$cmd &
dsm_pid=$!
sleep 2
disp=$use
if [ $disp -ge 5500 ]; then
disp=`expr $disp - 5500`
fi
fi
echo "$VNCVIEWERCMD" "$@" -listen $disp
echo "" echo ""
$VNCVIEWERCMD "$@" -listen $disp $VNCVIEWERCMD "$@" -listen $disp
fi fi
...@@ -1548,12 +1638,13 @@ if [ "X$direct_connect" != "X" ]; then ...@@ -1548,12 +1638,13 @@ if [ "X$direct_connect" != "X" ]; then
fi fi
tmp_cfg=/tmp/ss_vncviewer${RANDOM}.$$ tmp_cfg=/tmp/ss_vncviewer${RANDOM}.$$
mytmp "$tmp_cfg" tmp_cfg=`mytmp "$tmp_cfg"`
# make_tcert is no longer invoked via the ssvnc gui (Listen mode). # make_tcert is no longer invoked via the ssvnc gui (Listen mode).
# make_tcert is for testing only now via -mycert BUILTIN # make_tcert is for testing only now via -mycert BUILTIN
make_tcert() { make_tcert() {
tcert="/tmp/tcert${RANDOM}.$$" tcert="/tmp/ss_vnc_viewer_tcert${RANDOM}.$$"
tcert=`mytmp "$tcert"`
cat > $tcert <<END cat > $tcert <<END
-----BEGIN RSA PRIVATE KEY----- -----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAvkfXxb0wcxgrjV2ziFikjII+ze8iKcTBt47L0GM/c21efelN MIIEowIBAAKCAQEAvkfXxb0wcxgrjV2ziFikjII+ze8iKcTBt47L0GM/c21efelN
...@@ -1617,7 +1708,7 @@ fi ...@@ -1617,7 +1708,7 @@ fi
if [ "X$reverse" = "X" ]; then if [ "X$reverse" = "X" ]; then
if echo "$proxy" | grep repeater:// > /dev/null; then if echo "$proxy" | grep "^repeater://" > /dev/null; then
if [ "X$cert" = "XBUILTIN" ]; then if [ "X$cert" = "XBUILTIN" ]; then
ttcert=`make_tcert` ttcert=`make_tcert`
cert="cert = $ttcert" cert="cert = $ttcert"
......
...@@ -55,7 +55,7 @@ Normally you do not specify any command line options. You simply ...@@ -55,7 +55,7 @@ Normally you do not specify any command line options. You simply
run \fBssvnc\fR and use the GUI that starts up. run \fBssvnc\fR and use the GUI that starts up.
However, as shortcuts you can supply a VNC host:display (or host:port) However, as shortcuts you can supply a VNC host:display (or host:port)
on the command line. to connect to immediately (the GUI is started on the command line to connect to immediately (the GUI is started
and the connection is initiated). For example, "\fBssvnc far-away.east:0\fR" and the connection is initiated). For example, "\fBssvnc far-away.east:0\fR"
Instead of a host:display, you can specify the name of a saved profile to Instead of a host:display, you can specify the name of a saved profile to
automatically load that profile and then connect to its server. automatically load that profile and then connect to its server.
......
...@@ -194,6 +194,9 @@ Note: F9 is shortcut to Toggle FullScreen mode. ...@@ -194,6 +194,9 @@ Note: F9 is shortcut to Toggle FullScreen mode.
.TP .TP
Note: In -listen mode set the env var. SSVNC_MULTIPLE_LISTEN=1 Note: In -listen mode set the env var. SSVNC_MULTIPLE_LISTEN=1
to allow more than one incoming VNC server at a time. to allow more than one incoming VNC server at a time.
This is the same as -multilisten described below. Set
SSVNC_MULTIPLE_LISTEN=MAX:n to allow no more than "n"
simultaneous reverse connections.
.TP .TP
Note: If the host:port is specified as "exec=command args..." Note: If the host:port is specified as "exec=command args..."
then instead of making a TCP/IP socket connection to the then instead of making a TCP/IP socket connection to the
...@@ -206,6 +209,14 @@ This mode does not work for -listen reverse connections. ...@@ -206,6 +209,14 @@ This mode does not work for -listen reverse connections.
Note: If the host:port contains a '/' it is interpreted as a Note: If the host:port contains a '/' it is interpreted as a
unix-domain socket (AF_LOCAL insead of AF_INET) unix-domain socket (AF_LOCAL insead of AF_INET)
.TP .TP
\fB\-multilisten\fR
As in -listen (reverse connection listening) except
allow more than one incoming VNC server to be connected
at a time. The default for -listen of only one at a
time tries to play it safe by not allowing anyone on
the network to put (many) desktops on your screen over
a long window of time. Use -multilisten for no limit.
.TP
\fB\-use64\fR \fB\-use64\fR
In \fB\-bgr233\fR mode, use 64 colors instead of 256. In \fB\-bgr233\fR mode, use 64 colors instead of 256.
.TP .TP
...@@ -290,8 +301,8 @@ Disable use of MIT shared memory extension (not recommended) ...@@ -290,8 +301,8 @@ Disable use of MIT shared memory extension (not recommended)
Do the UltraVNC chat in the terminal vncviewer is in Do the UltraVNC chat in the terminal vncviewer is in
instead of in an independent window. instead of in an independent window.
.TP .TP
\fB\-unixpw\fR \fB\-unixpw\fR \fIstr\fR
str Useful for logging into x11vnc in \fB\-unixpw\fR mode. "str" is a Useful for logging into x11vnc in \fB\-unixpw\fR mode. "str" is a
string that allows many ways to enter the Unix Username string that allows many ways to enter the Unix Username
and Unix Password. These characters: username, newline, and Unix Password. These characters: username, newline,
password, newline are sent to the VNC server after any VNC password, newline are sent to the VNC server after any VNC
...@@ -313,17 +324,45 @@ after reading. Otherwise, if str has a "@" character, ...@@ -313,17 +324,45 @@ after reading. Otherwise, if str has a "@" character,
it is taken as username@password. Otherwise, the program it is taken as username@password. Otherwise, the program
exits with an error. Got all that? exits with an error. Got all that?
.TP .TP
\fB-repeater\fR str This is for use with UltraVNC repeater proxy described \fB-repeater\fR \fIstr\fR
This is for use with UltraVNC repeater proxy described
here: http://www.uvnc.com/addons/repeater.html. The "str" here: http://www.uvnc.com/addons/repeater.html. The "str"
is the ID string to be sent to the repeater. E.g. ID:1234 is the ID string to be sent to the repeater. E.g. ID:1234
It can also be the hostname and port or display of the VNC It can also be the hostname and port or display of the VNC
server, e.g. 12.34.56.78:0 or snoopy.com:1. Note that when server, e.g. 12.34.56.78:0 or snoopy.com:1. Note that when
using -repeater, the host:dpy on the cmdline is the repeater using -repeater, the host:dpy on the cmdline is the repeater
server, NOT the VNC server. The repeater will connect you. server, NOT the VNC server. The repeater will connect you.
Example: vncviewer ... -repeater ID:3333 repeat.host:5900 Example: vncviewer ... -repeater ID:3333 repeat.host:5900
Example: vncviewer ... -repeater vhost:0 repeat.host:5900 Example: vncviewer ... -repeater vhost:0 repeat.host:5900
.TP
\fB\-printres\fR Print out the Ssvnc X resources (appdefaults) and Use, e.g., '-repeater SCIII=ID:3210' if the repeater is a
Single Click III (SSL) repeater (repeater_SSL.exe) and you
are passing the SSL part of the connection through stunnel, socat, etc.
This way the magic UltraVNC string 'testB' needed to work with the
repeater is sent to it.
.TP
\fB-rfbversion\fR \fIstr\fR
Set the advertised RFB version. E.g.: -rfbversion 3.6 For some
servers, e.g. UltraVNC this needs to be done.
.TP
\fB-ultradsm\fR
UltraVNC has symmetric private encryption DSM plugins. See
http://www.uvnc.com/features/encryption.html. It is assumed
you are using a unix program (e.g. our ultravnc_dsm_helper) to
encrypt and decrypt the UltraVNC DSM stream. IN ADDITION TO
THAT supply -ultradsm to tell THIS viewer to modify the RFB
data sent so as to work with the UltraVNC Server. For some
reason, each RFB msg type must be sent twice under DSM.
.TP
\fB-env\fR \fIVAR=VALUE\fR
To save writing a shell script to set environment
variables, specify as many as you need on the command line. For example,
-env SSVNC_MULTIPLE_LISTEN=MAX:5 -env EDITOR=vi
.TP
\fB\-printres\fR
Print out the Ssvnc X resources (appdefaults) and
then exit. You can save them to a file and customize them (e.g. the then exit. You can save them to a file and customize them (e.g. the
keybindings and Popup menu) Then point to the file via keybindings and Popup menu) Then point to the file via
XENVIRONMENT or XAPPLRESDIR. XENVIRONMENT or XAPPLRESDIR.
...@@ -568,8 +607,8 @@ local TCP port number; ...@@ -568,8 +607,8 @@ local TCP port number;
.B %R .B %R
remote TCP port number. remote TCP port number.
.SH SEE ALSO .SH SEE ALSO
\fBvncserver\fR(1), \fBXvnc\fR(1), \fBvncpasswd\fR(1), \fBvncserver\fR(1), \fBx11vnc\fR(1), \fBssvnc\fR(1), \fBXvnc\fR(1), \fBvncpasswd\fR(1),
\fBvncconnect\fR(1), \fBssh\fR(1) \fBvncconnect\fR(1), \fBssh\fR(1), http://www.karlrunge.com/x11vnc, http://www.karlrunge.com/x11vnc/ssvnc.html
.SH AUTHORS .SH AUTHORS
Original VNC was developed in AT&T Laboratories Cambridge. TightVNC Original VNC was developed in AT&T Laboratories Cambridge. TightVNC
additions was implemented by Constantin Kaplinsky. Many other people additions was implemented by Constantin Kaplinsky. Many other people
...@@ -584,3 +623,5 @@ Terran Melconian <terran@consistent.org>, ...@@ -584,3 +623,5 @@ Terran Melconian <terran@consistent.org>,
Tim Waugh <twaugh@redhat.com>, Tim Waugh <twaugh@redhat.com>,
.br .br
Constantin Kaplinsky <const@ce.cctpu.edu.ru> Constantin Kaplinsky <const@ce.cctpu.edu.ru>
.br
Karl Runge <runge@karlrunge.com>
...@@ -62,7 +62,10 @@ zip -9 -r ssvnc-$vers.zip ssvnc -x '*.zip' '*.tar.gz' ...@@ -62,7 +62,10 @@ zip -9 -r ssvnc-$vers.zip ssvnc -x '*.zip' '*.tar.gz'
tar cvf - --exclude='*.zip' --exclude='*.tar.gz' ssvnc | gzip -9 > ssvnc-$vers.tar.gz tar cvf - --exclude='*.zip' --exclude='*.tar.gz' ssvnc | gzip -9 > ssvnc-$vers.tar.gz
tar cvf - --exclude='*.zip' --exclude='*.tar.gz' --exclude='*.dll' --exclude='*.exe' --exclude ssvnc/Windows/util ssvnc | gzip -9 > ssvnc_no_windows-$vers.tar.gz tar cvf - --exclude='*.zip' --exclude='*.tar.gz' --exclude='*.dll' --exclude='*.exe' --exclude ssvnc/Windows/util ssvnc | gzip -9 > ssvnc_no_windows-$vers.tar.gz
echo
ls -l ssvnc*-$vers.* ls -l ssvnc*-$vers.*
echo
########################################### ###########################################
dest=./t.windows_only dest=./t.windows_only
...@@ -84,3 +87,18 @@ rm -f $zip ...@@ -84,3 +87,18 @@ rm -f $zip
ls -l $zip ls -l $zip
rm -rf $dest rm -rf $dest
sync
echo
for g in ssvnc*-$vers*.gz
do
md5sum $g
gzip -t $g || (tput bel; sleep 2)
done
for g in ssvnc*-$vers*.zip
do
md5sum $g
done
sleep 3
echo
...@@ -2041,6 +2041,9 @@ static int ssl_init(int s_in, int s_out) { ...@@ -2041,6 +2041,9 @@ static int ssl_init(int s_in, int s_out) {
if (getenv("SSL_DEBUG")) { if (getenv("SSL_DEBUG")) {
db = atoi(getenv("SSL_DEBUG")); db = atoi(getenv("SSL_DEBUG"));
} }
if (getenv("SSL_INIT_TIMEOUT")) {
timeout = atoi(getenv("SSL_INIT_TIMEOUT"));
}
if (db) fprintf(stderr, "ssl_init: %d/%d\n", s_in, s_out); if (db) fprintf(stderr, "ssl_init: %d/%d\n", s_in, s_out);
ssl = SSL_new(ctx); ssl = SSL_new(ctx);
......
...@@ -830,6 +830,52 @@ char find_display[] = ...@@ -830,6 +830,52 @@ char find_display[] =
" pslist=`echo \"$psout\" | awk '{print $2}'`\n" " pslist=`echo \"$psout\" | awk '{print $2}'`\n"
"fi\n" "fi\n"
"\n" "\n"
"rchk() {\n"
" rr=rr \n"
"}\n"
"\n"
"dL=\"-L\"\n"
"if uname -sr | egrep 'SunOS 5\\.[5-8]' > /dev/null; then\n"
" dL=\"-h\"\n"
"fi\n"
"\n"
"# a portable, but not absolutely safe, tmp file creator\n"
"mytmp() {\n"
" tf=$1\n"
" if type mktemp > /dev/null 2>&1; then\n"
" # if we have mktemp(1), use it:\n"
" tf2=\"$tf.XXXXXX\"\n"
" tf2=`mktemp \"$tf2\"`\n"
" if [ \"X$tf2\" != \"X\" -a -f \"$tf2\" ]; then\n"
" if [ \"X$DEBUG_MKTEMP\" != \"X\" ]; then\n"
" echo \"mytmp-mktemp: $tf2\" 1>&2\n"
" fi\n"
" echo \"$tf2\"\n"
" return\n"
" fi\n"
" fi\n"
" # fallback to multiple cmds:\n"
" rm -rf \"$tf\" || exit 1\n"
" if [ -d \"$tf\" ]; then\n"
" echo \"tmp file $tf still exists as a directory.\"\n"
" exit 1\n"
" elif [ $dL \"$tf\" ]; then\n"
" echo \"tmp file $tf still exists as a symlink.\"\n"
" exit 1\n"
" elif [ -f \"$tf\" ]; then\n"
" echo \"tmp file $tf still exists.\"\n"
" exit 1\n"
" fi\n"
" touch \"$tf\" || exit 1\n"
" chmod 600 \"$tf\" || exit 1\n"
" rchk\n"
" if [ \"X$DEBUG_MKTEMP\" != \"X\" ]; then\n"
" echo \"mytmp-touch: $tf\" 1>&2\n"
" fi\n"
" echo \"$tf\"\n"
"}\n"
"\n"
"\n"
"# this mode is to try to grab a display manager (gdm, kdm, xdm...) display\n" "# this mode is to try to grab a display manager (gdm, kdm, xdm...) display\n"
"# when we are run as root (e.g. no one is logged in yet). We look at the\n" "# when we are run as root (e.g. no one is logged in yet). We look at the\n"
"# -auth line in the X/Xorg commandline.\n" "# -auth line in the X/Xorg commandline.\n"
...@@ -845,39 +891,38 @@ char find_display[] = ...@@ -845,39 +891,38 @@ char find_display[] =
" #\n" " #\n"
" env XAUTHORITY=\"$xa\" xdpyinfo -display \"$da\" >/dev/null 2>&1\n" " env XAUTHORITY=\"$xa\" xdpyinfo -display \"$da\" >/dev/null 2>&1\n"
" if [ $? = 0 ]; then\n" " if [ $? = 0 ]; then\n"
" env XAUTHORITY=/dev/null xdpyinfo -display \"$da\" >/dev/null 2>&1\n" " env XAUTHORITY=/dev/null xdpyinfo -display \"$da\" >/dev/null 2>&1\n"
" if [ $? != 0 ]; then\n" " if [ $? != 0 ]; then\n"
" y=`prdpy $da`\n" " y=`prdpy $da`\n"
" echo \"DISPLAY=$y\"\n" " echo \"DISPLAY=$y\"\n"
" if [ \"X$showxauth\" != \"X\" ]; then\n" " if [ \"X$showxauth\" != \"X\" ]; then\n"
" # copy the cookie:\n" " # copy the cookie:\n"
" cook=`xauth -f \"$xa\" list | head -n 1 | awk '{print $NF}'`\n" " cook=`xauth -f \"$xa\" list | head -n 1 | awk '{print $NF}'`\n"
" tf=$HOME/.xat.$$\n" " xtf=$HOME/.xat.$$\n"
" rm -f $tf\n" " xtf=`mytmp \"$xtf\"`\n"
" if [ -f $tf ]; then\n" " if [ ! -f $xtf ]; then\n"
" xtf=/tmp/.xat.$$\n"
" xtf=`mytmp \"$xtf\"`\n"
" fi\n"
" if [ ! -f $xtf ]; then\n"
" xtf=/tmp/.xatb.$$\n"
" rm -f $xtf\n"
" if [ -f $xtf ]; then\n"
" exit 1\n" " exit 1\n"
" fi\n" " fi\n"
" touch $tf 2>/dev/null\n" " touch $xtf 2>/dev/null\n"
" chmod 600 $tf 2>/dev/null\n" " chmod 600 $xtf 2>/dev/null\n"
" if [ ! -f $tf ]; then\n" " if [ ! -f $xtf ]; then\n"
" tf=/tmp/.xat.$$\n" " exit 1\n"
" rm -f $tf\n"
" if [ -f $tf ]; then\n"
" exit 1\n"
" fi\n"
" touch $tf 2>/dev/null\n"
" chmod 600 $tf 2>/dev/null\n"
" if [ ! -f $tf ]; then\n"
" exit 1\n"
" fi\n"
" fi\n" " fi\n"
" xauth -f $tf add \"$da\" . $cook\n"
" xauth -f $tf extract - \"$da\" 2>/dev/null\n"
" rm -f $tf\n"
" fi\n" " fi\n"
" # DONE\n" " xauth -f $xtf add \"$da\" . $cook\n"
" exit 0\n" " xauth -f $xtf extract - \"$da\" 2>/dev/null\n"
" rm -f $xtf\n"
" fi\n" " fi\n"
" # DONE\n"
" exit 0\n"
" fi\n"
" fi\n" " fi\n"
" fi\n" " fi\n"
" done\n" " done\n"
...@@ -1459,6 +1504,51 @@ char create_display[] = ...@@ -1459,6 +1504,51 @@ char create_display[] =
" redir_daemon=`echo \"$redir_daemon\" | sed -e 's/^,*//'`\n" " redir_daemon=`echo \"$redir_daemon\" | sed -e 's/^,*//'`\n"
"}\n" "}\n"
"\n" "\n"
"rchk() {\n"
" rr=rr\n"
"}\n"
"\n"
"dL=\"-L\"\n"
"if uname -sr | egrep 'SunOS 5\\.[5-8]' > /dev/null; then\n"
" dL=\"-h\"\n"
"fi\n"
"\n"
"# a portable, but not absolutely safe, tmp file creator\n"
"mytmp() {\n"
" tf=$1\n"
" if type mktemp > /dev/null 2>&1; then\n"
" # if we have mktemp(1), use it:\n"
" tf2=\"$tf.XXXXXX\"\n"
" tf2=`mktemp \"$tf2\"`\n"
" if [ \"X$tf2\" != \"X\" -a -f \"$tf2\" ]; then\n"
" if [ \"X$DEBUG_MKTEMP\" != \"X\" ]; then\n"
" echo \"mytmp-mktemp: $tf2\" 1>&2\n"
" fi\n"
" echo \"$tf2\"\n"
" return\n"
" fi\n"
" fi\n"
" # fallback to multiple cmds:\n"
" rm -rf \"$tf\" || exit 1\n"
" if [ -d \"$tf\" ]; then\n"
" echo \"tmp file $tf still exists as a directory.\"\n"
" exit 1\n"
" elif [ $dL \"$tf\" ]; then\n"
" echo \"tmp file $tf still exists as a symlink.\"\n"
" exit 1\n"
" elif [ -f \"$tf\" ]; then\n"
" echo \"tmp file $tf still exists.\"\n"
" exit 1\n"
" fi\n"
" touch \"$tf\" || exit 1\n"
" chmod 600 \"$tf\" || exit 1\n"
" rchk\n"
" if [ \"X$DEBUG_MKTEMP\" != \"X\" ]; then\n"
" echo \"mytmp-touch: $tf\" 1>&2\n"
" fi\n"
" echo \"$tf\"\n"
"}\n"
"\n"
"server() {\n" "server() {\n"
" authfile=`auth`\n" " authfile=`auth`\n"
" sess=`findsession`\n" " sess=`findsession`\n"
...@@ -1475,10 +1565,7 @@ char create_display[] = ...@@ -1475,10 +1565,7 @@ char create_display[] =
" rmf=\"/nosuch\"\n" " rmf=\"/nosuch\"\n"
" if echo \"$sess\" | grep '[ ]' > /dev/null; then\n" " if echo \"$sess\" | grep '[ ]' > /dev/null; then\n"
" stmp=/tmp/.cd$$`random`\n" " stmp=/tmp/.cd$$`random`\n"
" rm -f $stmp\n" " stmp=`mytmp \"$stmp\"`\n"
" if [ -f $stmp ]; then\n"
" exit 1\n"
" fi\n"
" touch $stmp\n" " touch $stmp\n"
" chmod 755 $stmp || exit 1\n" " chmod 755 $stmp || exit 1\n"
" echo \"#!/bin/sh\" > $stmp\n" " echo \"#!/bin/sh\" > $stmp\n"
...@@ -1490,10 +1577,7 @@ char create_display[] = ...@@ -1490,10 +1577,7 @@ char create_display[] =
" fi\n" " fi\n"
" if [ \"X$have_root\" != \"X\" -a \"X$USER\" != \"Xroot\" ]; then\n" " if [ \"X$have_root\" != \"X\" -a \"X$USER\" != \"Xroot\" ]; then\n"
" ctmp=/tmp/.xat$$`random`\n" " ctmp=/tmp/.xat$$`random`\n"
" rm -f $ctmp\n" " ctmp=`mytmp \"$ctmp\"`\n"
" if [ -f $ctmp ]; then\n"
" exit 1\n"
" fi\n"
" touch $ctmp\n" " touch $ctmp\n"
" chmod 644 $ctmp || exit 1\n" " chmod 644 $ctmp || exit 1\n"
" $have_xauth -f $authfile nextract - :$N > $ctmp\n" " $have_xauth -f $authfile nextract - :$N > $ctmp\n"
...@@ -1799,10 +1883,7 @@ char create_display[] = ...@@ -1799,10 +1883,7 @@ char create_display[] =
" exit 1\n" " exit 1\n"
" fi\n" " fi\n"
" tmp=/tmp/.xas$$`random`\n" " tmp=/tmp/.xas$$`random`\n"
" rm -f $tmp\n" " tmp=`mytmp \"$tmp\"`\n"
" if [ -f $tmp ]; then\n"
" exit 1\n"
" fi\n"
" touch $tmp\n" " touch $tmp\n"
" chmod 600 $tmp || exit 1\n" " chmod 600 $tmp || exit 1\n"
" if [ ! -f $tmp ]; then\n" " if [ ! -f $tmp ]; then\n"
......
...@@ -6275,10 +6275,17 @@ proc restart_everything {gui_mode} { ...@@ -6275,10 +6275,17 @@ proc restart_everything {gui_mode} {
exit 1; exit 1;
} }
set tmp "/tmp/x11vnc[pid]" set tmp "/tmp/x11vnc[pid]"
file delete -force $tmp append tmp [clock clicks]
if {[file exists $tmp]} { set tmp2 ""
puts stderr "failure in restart_everything." catch {set tmp2 [exec mktemp $tmp.XXXXXX 2>/dev/null]}
exit 1; if {$tmp2 != "" && [file exists $tmp2]} {
set tmp $tmp2
} else {
file delete -force $tmp
if {[file exists $tmp]} {
puts stderr "failure in restart_everything."
exit 1;
}
} }
set fh [open $tmp "a"] set fh [open $tmp "a"]
if {![file owned $tmp]} { if {![file owned $tmp]} {
......
...@@ -6286,10 +6286,17 @@ char gui_code[] = ""; ...@@ -6286,10 +6286,17 @@ char gui_code[] = "";
" exit 1;\n" " exit 1;\n"
" }\n" " }\n"
" set tmp \"/tmp/x11vnc[pid]\"\n" " set tmp \"/tmp/x11vnc[pid]\"\n"
" file delete -force $tmp\n" " append tmp [clock clicks]\n"
" if {[file exists $tmp]} {\n" " set tmp2 \"\"\n"
" puts stderr \"failure in restart_everything.\"\n" " catch {set tmp2 [exec mktemp $tmp.XXXXXX 2>/dev/null]}\n"
" exit 1;\n" " if {$tmp2 != \"\" && [file exists $tmp2]} {\n"
" set tmp $tmp2\n"
" } else {\n"
" file delete -force $tmp\n"
" if {[file exists $tmp]} {\n"
" puts stderr \"failure in restart_everything.\"\n"
" exit 1;\n"
" }\n"
" }\n" " }\n"
" set fh [open $tmp \"a\"]\n" " set fh [open $tmp \"a\"]\n"
" if {![file owned $tmp]} {\n" " if {![file owned $tmp]} {\n"
......
...@@ -7656,6 +7656,10 @@ void xselectinput(Window w, unsigned long evmask, int sync) { ...@@ -7656,6 +7656,10 @@ void xselectinput(Window w, unsigned long evmask, int sync) {
XErrorHandler old_handler1; XErrorHandler old_handler1;
XIOErrorHandler old_handler2; XIOErrorHandler old_handler2;
if (macosx_console || !dpy) {
return;
}
old_handler1 = XSetErrorHandler(trap_xerror); old_handler1 = XSetErrorHandler(trap_xerror);
old_handler2 = XSetIOErrorHandler(trap_xioerror); old_handler2 = XSetIOErrorHandler(trap_xioerror);
trapped_xerror = 0; trapped_xerror = 0;
...@@ -8812,7 +8816,7 @@ if (ncdb) fprintf(stderr, "*VIS BS_save: 0x%lx %d %d %d\n", win, cache_list[i]. ...@@ -8812,7 +8816,7 @@ if (ncdb) fprintf(stderr, "*VIS BS_save: 0x%lx %d %d %d\n", win, cache_list[i].
last_sched_bs = dnow(); last_sched_bs = dnow();
} }
#if !NO_X11 #if !NO_X11
if (atom_XROOTPMAP_ID == None && now > last_pixmap + 5.0) { if (dpy && atom_XROOTPMAP_ID == None && now > last_pixmap + 5.0) {
atom_XROOTPMAP_ID = XInternAtom(dpy, "_XROOTPMAP_ID", True); atom_XROOTPMAP_ID = XInternAtom(dpy, "_XROOTPMAP_ID", True);
last_pixmap = now; last_pixmap = now;
} }
......
...@@ -399,8 +399,23 @@ double rnow(void) { ...@@ -399,8 +399,23 @@ double rnow(void) {
} }
double rfac(void) { double rfac(void) {
double f = (double) rand(); double f;
static int first = 1;
if (first) {
unsigned int s;
if (getenv("RAND_SEED")) {
s = (unsigned int) atoi(getenv("RAND_SEED"));
} else {
s = (unsigned int) ((int) getpid() + 100000 * rnow());
}
srand(s);
first = 0;
}
f = (double) rand();
f = f / ((double) RAND_MAX); f = f / ((double) RAND_MAX);
return f; return f;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
.TH X11VNC "1" "September 2008" "x11vnc " "User Commands" .TH X11VNC "1" "September 2008" "x11vnc " "User Commands"
.SH NAME .SH NAME
x11vnc - allow VNC connections to real X11 displays x11vnc - allow VNC connections to real X11 displays
version: 0.9.4, lastmod: 2008-09-06 version: 0.9.4, lastmod: 2008-09-14
.SH SYNOPSIS .SH SYNOPSIS
.B x11vnc .B x11vnc
[OPTION]... [OPTION]...
...@@ -423,6 +423,10 @@ after startup. ...@@ -423,6 +423,10 @@ after startup.
.IP .IP
At startup sleep n seconds before proceeding (e.g. to At startup sleep n seconds before proceeding (e.g. to
allow redirs and listening clients to start up) allow redirs and listening clients to start up)
.IP
If a range is given: '-sleepin min-max', a random value
between min and max is slept. E.g. '-sleepin 0-20' and
\'-sleepin 10-30'. Floats are allowed too.
.PP .PP
\fB-inetd\fR \fB-inetd\fR
.IP .IP
...@@ -1485,6 +1489,10 @@ talking and the connection is dropped after the default ...@@ -1485,6 +1489,10 @@ talking and the connection is dropped after the default
timeout (25s for about the first minute, 43200s later). timeout (25s for about the first minute, 43200s later).
Set to zero to poll forever. Set to a negative value Set to zero to poll forever. Set to a negative value
to use the builtin setting. to use the builtin setting.
.IP
Note that this value does not apply to the *initial* ssl
init connection. The default timeout for that is 20sec.
Use \fB-env\fR SSL_INIT_TIMEOUT=n to modify it.
.PP .PP
\fB-sslnofail\fR \fB-sslnofail\fR
.IP .IP
...@@ -2528,6 +2536,9 @@ identical keyboards). Also useful in resolving cases ...@@ -2528,6 +2536,9 @@ identical keyboards). Also useful in resolving cases
where a Keysym is bound to multiple keys (e.g. "<" + ">" where a Keysym is bound to multiple keys (e.g. "<" + ">"
and "," + "<" keys). Default: \fB-modtweak\fR and "," + "<" keys). Default: \fB-modtweak\fR
.IP .IP
If you are having trouble with with keys and \fB-xkb\fR or
\fB-noxkb,\fR and similar things don't help, try \fB-nomodtweak.\fR
.IP
On some HP-UX systems it is been noted that they have On some HP-UX systems it is been noted that they have
an odd keymapping where a single keycode will have a an odd keymapping where a single keycode will have a
keysym, e.g. "#", up to three times. You can check keysym, e.g. "#", up to three times. You can check
......
...@@ -2293,6 +2293,38 @@ char msg2[] = ...@@ -2293,6 +2293,38 @@ char msg2[] =
&& !query_cmd && !remote_cmd && !unixpw && !got_gui_pw \ && !query_cmd && !remote_cmd && !unixpw && !got_gui_pw \
&& ! ssl_verify && !inetd && !terminal_services_daemon) && ! ssl_verify && !inetd && !terminal_services_daemon)
static void do_sleepin(char *sleep) {
int n1, n2, nt;
double f1, f2, ft;
if (strchr(sleep, '-')) {
double s = atof(strchr(sleep, '-')+1);
if (sscanf(sleep, "%d-%d", &n1, &n2) == 2) {
if (n1 > n2) {
nt = n1;
n1 = n2;
n2 = nt;
}
s = n1 + rfac() * (n2 - n1);
} else if (sscanf(sleep, "%lf-%lf", &f1, &f2) == 2) {
if (f1 > f2) {
ft = f1;
f1 = f2;
f2 = ft;
}
s = f1 + rfac() * (f2 - f1);
}
if (getenv("DEBUG_SLEEPIN")) fprintf(stderr, "sleepin: %f secs\n", s);
usleep( (int) (1000*1000*s) );
} else {
n1 = atoi(sleep);
if (getenv("DEBUG_SLEEPIN")) fprintf(stderr, "sleepin: %d secs\n", n1);
if (n1 > 0) {
usleep(1000*1000*n1);
}
}
}
extern int dragum(void); extern int dragum(void);
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
...@@ -2581,10 +2613,7 @@ int main(int argc, char* argv[]) { ...@@ -2581,10 +2613,7 @@ int main(int argc, char* argv[]) {
} else if (!strcmp(arg, "-sleepin")) { } else if (!strcmp(arg, "-sleepin")) {
int n; int n;
CHECK_ARGC CHECK_ARGC
n = atoi(argv[++i]); do_sleepin(argv[++i]);
if (n > 0) {
usleep(1000*1000*n);
}
} else if (!strcmp(arg, "-users")) { } else if (!strcmp(arg, "-users")) {
CHECK_ARGC CHECK_ARGC
users_list = strdup(argv[++i]); users_list = strdup(argv[++i]);
......
...@@ -15,7 +15,7 @@ int xtrap_base_event_type = 0; ...@@ -15,7 +15,7 @@ int xtrap_base_event_type = 0;
int xdamage_base_event_type = 0; int xdamage_base_event_type = 0;
/* date +'lastmod: %Y-%m-%d' */ /* date +'lastmod: %Y-%m-%d' */
char lastmod[] = "0.9.4 lastmod: 2008-09-06"; char lastmod[] = "0.9.4 lastmod: 2008-09-14";
/* X display info */ /* X display info */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment