summaryrefslogtreecommitdiffstats
path: root/x11vnc/ssltools.h
diff options
context:
space:
mode:
Diffstat (limited to 'x11vnc/ssltools.h')
-rw-r--r--x11vnc/ssltools.h186
1 files changed, 178 insertions, 8 deletions
diff --git a/x11vnc/ssltools.h b/x11vnc/ssltools.h
index 33576ff..763597c 100644
--- a/x11vnc/ssltools.h
+++ b/x11vnc/ssltools.h
@@ -799,7 +799,7 @@ char find_display[] =
" if [ -d \"/proc/$pid\" ]; then\n"
" ok=1\n"
" fi\n"
-" elif echo \"$ps_out\" | awk '{print $2}' | grep -w \"$pid\" > /dev/null; then\n"
+" elif echo \"$psout\" | awk '{print $2}' | grep -w \"$pid\" > /dev/null; then\n"
" ok=1\n"
" fi\n"
" fi\n"
@@ -820,6 +820,14 @@ char find_display[] =
" do\n"
" xdpyinfo -display \"$p\" >/dev/null 2>&1\n"
" if [ $? = 0 ]; then\n"
+" if [ \"X$FD_TAG\" != \"X\" ]; then\n"
+" if xprop -display \"$p\" -root -len 128 FD_TAG | grep -iv no.such.atom \\\n"
+" | grep \"=[ ][ ]*\\\"$FD_TAG\\\"\" > /dev/null; then\n"
+" :\n"
+" else\n"
+" continue\n"
+" fi\n"
+" fi\n"
" # try again with no authority:\n"
" env XAUTHORITY=/dev/null xdpyinfo -display \"$p\" >/dev/null 2>&1\n"
" # 0 means got in for free... skip it.\n"
@@ -1004,7 +1012,15 @@ char create_display[] =
" echo \"$have_xterm\"\n"
" return\n"
" fi\n"
-" home=`csh -f -c \"echo ~$USER\"`\n"
+" if type csh > /dev/null 2>&1; then\n"
+" home=`csh -f -c \"echo ~$USER\"`\n"
+" elif type tcsh > /dev/null 2>&1; then\n"
+" home=`tcsh -f -c \"echo ~$USER\"`\n"
+" elif type bash > /dev/null 2>&1; then\n"
+" home=`bash -c \"echo ~$USER\"`\n"
+" else\n"
+" home=\"\"\n"
+" fi\n"
" if [ \"X$home\" = \"X\" -o ! -d \"$home\" ]; then\n"
" if [ \"X$have_root\" != \"X\" -a \"X$USER\" != \"Xroot\" ]; then\n"
" home=`su - $USER -c 'echo $HOME'`\n"
@@ -1058,6 +1074,101 @@ char create_display[] =
" fi\n"
"}\n"
"\n"
+"check_redir_services() {\n"
+" redir_daemon=\"\"\n"
+" need_env=\"\"\n"
+" if echo \"$sess\" | grep '^env ' > /dev/null; then\n"
+" sess=`echo \"$sess\" | sed -e 's/^env //'`\n"
+" need_env=1\n"
+" fi\n"
+" if [ \"X$FD_ESD\" != \"X\" -a \"X$have_esddsp\" != \"X\" ]; then\n"
+" if echo \"$FD_ESD\" | grep '^DAEMON-' > /dev/null; then\n"
+" FD_ESD=`echo \"$FD_ESD\" | sed -e 's/DAEMON-//'`\n"
+" rport=`echo \"$FD_ESD\" | sed -e 's/^.*://'`\n"
+" dport=`expr $rport + 1`\n"
+" dport=`freeport $dport`\n"
+" FD_ESD=$dport\n"
+" redir_daemon=\"$redir_daemon,TS_ESD_REDIR:$dport:$rport\"\n"
+" fi\n"
+" if echo \"$FD_ESD\" | grep ':' > /dev/null; then\n"
+" :\n"
+" else\n"
+" FD_ESD=\"localhost:$FD_ESD\"\n"
+" fi\n"
+" sess=\"ESPEAKER=$FD_ESD $have_esddsp -s $FD_ESD $sess\"\n"
+" need_env=1\n"
+" fi\n"
+" if [ \"X$FD_CUPS\" != \"X\" ]; then\n"
+" if echo \"$FD_CUPS\" | grep '^DAEMON-' > /dev/null; then\n"
+" FD_CUPS=`echo \"$FD_CUPS\" | sed -e 's/DAEMON-//'`\n"
+" rport=`echo \"$FD_CUPS\" | sed -e 's/^.*://'`\n"
+" dport=`expr $rport + 1`\n"
+" dport=`freeport $dport`\n"
+" FD_CUPS=$dport\n"
+" redir_daemon=\"$redir_daemon,TS_CUPS_REDIR:$dport:$rport\"\n"
+"#echo \"redir_daemon=$redir_daemon\" 1>&2\n"
+" fi\n"
+" if echo \"$FD_CUPS\" | grep ':' > /dev/null; then\n"
+" :\n"
+" else\n"
+" FD_CUPS=\"localhost:$FD_CUPS\"\n"
+" fi\n"
+" csr=`echo \"$FD_CUPS\" | awk -F: '{print $1}'`\n"
+" ipp=`echo \"$FD_CUPS\" | awk -F: '{print $2}'`\n"
+" old=`strings -a /usr/sbin/cupsd 2>/dev/null | grep 'CUPS.v1\\.[01]'`\n"
+" if [ \"X$old\" != \"X\" ]; then\n"
+" FD_CUPS=`echo \"$FD_CUPS\" | sed -e 's/:.*$//'`\n"
+" fi\n"
+" sess=\"CUPS_SERVER=$FD_CUPS IPP_PORT=$ipp $sess\"\n"
+" need_env=1\n"
+" fi\n"
+"\n"
+" if [ \"X$FD_SMB\" != \"X\" ]; then\n"
+" if echo \"$FD_SMB\" | grep '^DAEMON-' > /dev/null; then\n"
+" FD_SMB=`echo \"$FD_SMB\" | sed -e 's/DAEMON-//'`\n"
+" rport=`echo \"$FD_SMB\" | sed -e 's/^.*://'`\n"
+" dport=`expr $rport + 1`\n"
+" dport=`freeport $dport`\n"
+" FD_SMB=$dport\n"
+" redir_daemon=\"$redir_daemon,TS_SMB_REDIR:$dport:$rport\"\n"
+" fi\n"
+" if echo \"$FD_SMB\" | grep ':' > /dev/null; then\n"
+" :\n"
+" else\n"
+" FD_SMB=\"localhost:$FD_SMB\"\n"
+" fi\n"
+" smh=`echo \"$FD_SMB\" | awk -F: '{print $1}'`\n"
+" smp=`echo \"$FD_SMB\" | awk -F: '{print $2}'`\n"
+" if [ \"X$smh\" = \"X\" ]; then\n"
+" smh=localhost\n"
+" fi\n"
+" sess=\"SMB_SERVER=$FD_SMB SMB_HOST=$smh SMB_PORT=$smp $sess\"\n"
+" need_env=1\n"
+" fi\n"
+"\n"
+" if [ \"X$FD_NAS\" != \"X\" ]; then\n"
+" if echo \"$FD_NAS\" | grep '^DAEMON-' > /dev/null; then\n"
+" FD_NAS=`echo \"$FD_NAS\" | sed -e 's/DAEMON-//'`\n"
+" rport=`echo \"$FD_NAS\" | sed -e 's/^.*://'`\n"
+" dport=`expr $rport + 1`\n"
+" dport=`freeport $dport`\n"
+" FD_NAS=$dport\n"
+" redir_daemon=\"$redir_daemon,TS_NAS_REDIR:$dport:$rport\"\n"
+" fi\n"
+" if echo \"$FD_NAS\" | grep ':' > /dev/null; then\n"
+" :\n"
+" else\n"
+" FD_NAS=\"tcp/localhost:$FD_NAS\"\n"
+" fi\n"
+" sess=\"AUDIOSERVER=$FD_NAS $sess\"\n"
+" need_env=1\n"
+" fi\n"
+" if [ \"X$need_env\" != \"X\" ]; then\n"
+" sess=\"env $sess\"\n"
+" fi\n"
+" redir_daemon=`echo \"$redir_daemon\" | sed -e 's/^,*//'`\n"
+"}\n"
+"\n"
"server() {\n"
" authfile=`auth`\n"
" sess=`findsession`\n"
@@ -1067,6 +1178,10 @@ char create_display[] =
" if [ \"X$have_root\" != \"X\" -a \"X$USER\" != \"Xroot\" ]; then\n"
" sess=\"env DISPLAY=:$N $sess\"\n"
" fi\n"
+"\n"
+" redir_daemon=\"\"\n"
+" check_redir_services\n"
+"\n"
" rmf=\"/nosuch\"\n"
" if echo \"$sess\" | grep '[ ]' > /dev/null; then\n"
" stmp=/tmp/.cd$$`random`\n"
@@ -1163,6 +1278,15 @@ char create_display[] =
" else\n"
" $have_nohup sh -c \"(sleep 60; rm -f $rmf $authfile)\" 1>&2 &\n"
" fi\n"
+"\n"
+" if [ \"X$redir_daemon\" != \"X\" -a \"X$result\" = \"X1\" ]; then\n"
+" redir_daemon=`echo \"$redir_daemon\" | sed -e 's|[^A-z0-9:,/]||g'`\n"
+" xprog=$X11VNC_PROG\n"
+" if [ \"X$xprog\" = \"X\"]; then\n"
+" xprog=x11vnc\n"
+" fi\n"
+" $have_nohup sh -c \"$xprog -sleepin 10 -auth $authfile -tsd $redir_daemon\" 2>.tsd.log.$USER 1>&2 &\n"
+" fi\n"
"}\n"
"\n"
"try_X() {\n"
@@ -1190,14 +1314,13 @@ char create_display[] =
" if [ \"X$have_Xdummy\" = \"X\" ]; then\n"
" return\n"
" fi\n"
-" if [ \"X$have_root\" = \"X\" ]; then\n"
+" if [ \"X$FD_XDUMMY_NOROOT\" != \"X\" ]; then\n"
+" :\n"
+" elif [ \"X$have_root\" = \"X\" ]; then\n"
" return\n"
" fi\n"
"\n"
-" #save_have_startx=$have_startx\n"
-" #have_startx=\"\"\n"
-" server $have_Xdummy :$N -geom $geom -depth $depth\n"
-" #have_startx=$save_have_startx\n"
+" server $have_Xdummy :$N -geometry $geom -depth $depth\n"
"}\n"
"\n"
"try_Xvnc() {\n"
@@ -1336,6 +1459,46 @@ char create_display[] =
" echo \"$tmp\"\n"
"}\n"
"\n"
+"freeport() {\n"
+" base=$1\n"
+" if [ \"X$have_uname\" != \"X\" -a \"X$have_netstat\" != \"X\" ]; then\n"
+" inuse=\"\"\n"
+" if $have_uname | grep Linux > /dev/null; then\n"
+" inuse=`$have_netstat -ant | egrep 'LISTEN|WAIT|ESTABLISH|CLOSE' | awk '{print $4}' | sed 's/^.*://'`\n"
+" elif $have_uname | grep SunOS > /dev/null; then\n"
+" inuse=`$have_netstat -an -f inet -P tcp | grep LISTEN | awk '{print $1}' | sed 's/^.*\\.//'`\n"
+" elif $have_uname | grep -i bsd > /dev/null; then\n"
+" inuse=`$have_netstat -ant -f inet | grep LISTEN | awk '{print $4}' | sed 's/^.*\\.//'`\n"
+" # add others...\n"
+" fi\n"
+" fi\n"
+" i=0\n"
+" ok=\"\"\n"
+" while [ $i -lt 500 ]\n"
+" do\n"
+" tryp=`expr $base + $i`\n"
+" if echo \"$inuse\" | grep -w \"$tryp\" > /dev/null; then\n"
+" :\n"
+" elif echo \"$palloc\" | tr ' ' '\\n' | grep -w \"$tryp\" > /dev/null; then\n"
+" :\n"
+" else\n"
+" ok=$tryp\n"
+" break\n"
+" fi\n"
+" i=`expr $i + 1`\n"
+" done\n"
+" if [ \"X$ok\" != \"X\" ]; then\n"
+" base=$ok\n"
+" fi\n"
+" if [ \"X$palloc\" = \"X\" ]; then\n"
+" palloc=\"$base\"\n"
+" else\n"
+" palloc=\"$palloc $base\"\n"
+" fi\n"
+" echo \"$base\"\n"
+"}\n"
+"\n"
+"\n"
"depth=${depth:-16}\n"
"geom=${geom:-1280x1024}\n"
"\n"
@@ -1389,7 +1552,7 @@ char create_display[] =
" p_ok=1\n"
"fi\n"
"\n"
-"for prog in startx xinit xdm gdm kdm xterm Xdummy Xvfb Xvnc xauth mcookie md5sum xmodmap startkde gnome-session blackbox fvwm2 mwm openbox twm windowmaker wmaker metacity X Xorg XFree86 Xsun Xsession dtwm netstat nohup\n"
+"for prog in startx xinit xdm gdm kdm xterm Xdummy Xvfb Xvnc xauth mcookie md5sum xmodmap startkde gnome-session blackbox fvwm2 mwm openbox twm windowmaker wmaker metacity X Xorg XFree86 Xsun Xsession dtwm netstat nohup esddsp konsole gnome-terminal\n"
"do\n"
" p2=`echo \"$prog\" | sed -e 's/-/_/g'`\n"
" eval \"have_$p2=''\"\n"
@@ -1406,6 +1569,13 @@ char create_display[] =
" eval \"have_$p2=$bpath\"\n"
" fi\n"
"done\n"
+"if [ \"X$have_xterm\" = \"X\" ]; then\n"
+" if [ \"X$have_konsole\" != \"X\" ]; then\n"
+" have_xterm=$have_konsole\n"
+" elif [ \"X$have_gnome_terminal\" != \"X\" ]; then\n"
+" have_xterm=$have_gnome_terminal\n"
+" fi\n"
+"fi\n"
"\n"
"if [ \"X$have_nohup\" = \"X\" ]; then\n"
" have_nohup=\"nohup\"\n"