summaryrefslogtreecommitdiffstats
path: root/x11vnc/ssltools.h
diff options
context:
space:
mode:
Diffstat (limited to 'x11vnc/ssltools.h')
-rw-r--r--x11vnc/ssltools.h322
1 files changed, 229 insertions, 93 deletions
diff --git a/x11vnc/ssltools.h b/x11vnc/ssltools.h
index dc38ef7..90002d1 100644
--- a/x11vnc/ssltools.h
+++ b/x11vnc/ssltools.h
@@ -688,7 +688,7 @@ char find_display[] =
"# x11vnc then uses the info to open the display.\n"
"#\n"
"\n"
-"FIND_DISPLAY_OUTPUT=/tmp/fdo.txt\n"
+"#FIND_DISPLAY_OUTPUT=/tmp/fdo.$USER.txt\n"
"if [ \"X$FIND_DISPLAY_OUTPUT\" != \"X\" ]; then\n"
" if [ \"X$FIND_DISPLAY_EXEC\" = \"X\" ]; then\n"
" FIND_DISPLAY_EXEC=1\n"
@@ -747,72 +747,112 @@ char find_display[] =
"# Now try to match X DISPLAY to user:\n"
"\n"
"# who(1) output column 2:\n"
-"display=`who | grep \"^${user}[ ][ ]*:[0-9]\" | head -1 \\\n"
-" | awk '{print $2}'`\n"
-"\n"
-"if [ \"X$display\" = \"X\" ]; then\n"
-" # who(1) output, last column:\n"
-" display=`who | grep \"^${user}[ ]\" | awk '{print $NF}' \\\n"
-" | grep '(:[0-9]' | sed -e 's/[()]//g' | head -1`\n"
-" if [ \"X$display\" = \"X\" ]; then\n"
-" if [ \"X$X11VNC_FINDDISPLAY_SKIP_XAUTH\" != \"X\" ]; then\n"
-" echo \"\" # failure\n"
-" exit 1\n"
+"#gone=`last $user | grep 'gone.*no.logout' | awk '{print $2}' | grep '^:' | sed -e 's,/.*,,' | tr '\\n' '|'`\n"
+"#gone=\"${gone}__quite_impossible__\"\n"
+"#display=`who | grep \"^${user}[ ][ ]*:[0-9]\" | egrep -v \" ($gone)\\>\" | head -1 \\\n"
+"# | awk '{print $2}' | sed -e 's,/.*$,,'`\n"
+"poss=\"\"\n"
+"list=`who | grep \"^${user}[ ][ ]*:[0-9]\" | awk '{print $2}' | sed -e 's,/.*$,,'`\n"
+"list=\"$list \"`w -h \"$user\" | grep \"^${user}[ ][ ]*:[0-9]\" | awk '{print $2}' | sed -e 's,/.*$,,'`\n"
+"list=\"$list \"`who | grep \"^${user}[ ]\" | awk '{print $NF}' | grep '(:[0-9]' | sed -e 's/[()]//g'`\n"
+"host=`hostname | sed -e 's/\\..*$//'`\n"
+"if [ \"X$X11VNC_FINDDISPLAY_SKIP_XAUTH\" = \"X\" ]; then\n"
+" list=\"$list \"`xauth list | awk '{print $1}' | grep /unix | grep \"^${host}\" | sed -e 's/^.*:/:/' | sort -n | uniq`\n"
+"fi\n"
+"uname=`uname`\n"
+"nsout=`netstat -an`\n"
+"psout=`ps -ef`\n"
+"for p in $list\n"
+"do\n"
+" d=`echo \"$p\" | sed -e 's/://' -e 's/\\..*$//'`\n"
+" ok=\"\"\n"
+" xd=\"/tmp/.X11-unix/X$d\"\n"
+" if [ -r \"$xd\" -o -w \"$xd\" -o -x \"$xd\" ]; then\n"
+" if echo \"$nsout\" | grep \"/tmp/.X11-unix/X$d[ ]*\\$\" > /dev/null; then\n"
+" ok=1\n"
" fi\n"
-" # loop over xauth list items machine ^hostname/unix:N\n"
-" host=`hostname | sed -e 's/\\..*$//'`\n"
-" tries1=\"\"\n"
-" tries2=\"\"\n"
-" for d in `xauth list | awk '{print $1}' | grep /unix \\\n"
-" | grep \"^${host}\" | sed -e 's/^.*://' | sort -n | uniq`\n"
-" do\n"
-" if [ -e \"/tmp/.X$d-lock\" -o -e \"/tmp/.X11-unix/X$d\" ]; then\n"
-" tries1=\"$tries1 $d\"\n"
-" else\n"
-" # these are often ssh X redirs so try them last or skip:\n"
-" #tries2=\"$tries2 $d\"\n"
-" :\n"
+" fi\n"
+" if [ \"X$ok\" = \"X\" ]; then\n"
+" if [ -f \"/tmp/.X$d-lock\" ]; then\n"
+" pid=`cat \"/tmp/.X$d-lock\" | sed -e 's/[ ]//g'`\n"
+" if echo \"$pid\" | grep '^[0-9][0-9]*$' > /dev/null; then\n"
+" if [ \"X$uname\" = \"XLinux\" -o \"X$uname\" = \"XSunOS\" ]; then\n"
+" 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"
+" ok=1\n"
+" fi\n"
" fi\n"
-" done\n"
-" \n"
+" fi\n"
+" fi\n"
+" if [ \"X$ok\" = \"X1\" ]; then\n"
+" poss=\"$poss $p\"\n"
+" fi\n"
+"done\n"
"\n"
-" for d in $tries1 $tries2\n"
-" do\n"
-" xdpyinfo -display \":$d\" >/dev/null 2>&1\n"
-" if [ $? = 0 ]; then\n"
-" # try again with no authority:\n"
-" env XAUTHORITY=/dev/null xdpyinfo \\\n"
-" -display \":$d\" >/dev/null 2>&1\n"
-" # 0 means got in for free... skip it.\n"
-" if [ $? != 0 ]; then\n"
-" # keep it\n"
-" display=\":$d\"\n"
-" break\n"
+"poss=`echo \"$poss\" | sed -e 's/^ *//' -e 's/ *$//'`\n"
+"\n"
+"if [ \"X$X11VNC_FINDDISPLAY_SKIP_XAUTH\" != \"X\" ]; then\n"
+" display=`echo \"$poss\" | tr ' ' '\\n' | head -1`\n"
+"else\n"
+" freebie=\"\"\n"
+" for p in $poss\n"
+" do\n"
+" xdpyinfo -display \"$p\" >/dev/null 2>&1\n"
+" if [ $? = 0 ]; then\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"
+" if [ $? != 0 ]; then\n"
+" # keep it\n"
+" display=\"$p\"\n"
+" break\n"
+" else\n"
+" if [ \"X$freebie\" = \"X\" ]; then\n"
+" freebie=\"$p\"\n"
" fi\n"
" fi\n"
-" done\n"
-" if [ \"X$display\" = \"X\" ]; then\n"
-" echo \"\" # failure\n"
-" exit 1\n"
" fi\n"
+" done\n"
+" if [ \"X$display\" = \"X\" -a \"X$freebie\" != \"X\" ]; then\n"
+" display=\"$freebie\"\n"
" fi\n"
"fi\n"
"\n"
+"if [ \"X$display\" = \"X\" ]; then\n"
+" echo \"\" # failure\n"
+" exit 1\n"
+"fi\n"
+"\n"
"chvt=\"\"\n"
-"if [ \"X`uname`\" = \"XLinux\" ]; then\n"
-" vt=`ps wwwwwaux | grep X | egrep -v 'startx|xinit' | grep \" $display \" | egrep ' vt([789]|[1-9][0-9][0-9]*) ' | grep -v grep | head -1`\n"
+"if [ \"X$uname\" = \"XLinux\" ]; then\n"
+" d2=$display\n"
+" d3=`echo \"$d2\" | sed -e 's/^.*:/:/' -e 's/\\..*$//'`\n"
+" d4=\"($d2|$d3)\"\n"
+" vt=`ps wwwwwaux | grep X | egrep -v 'startx|xinit' | egrep \" $d4 \" | egrep ' vt([789]|[1-9][0-9][0-9]*) ' | grep -v grep | head -1`\n"
" if [ \"X$vt\" != \"X\" ]; then\n"
" vt=`echo \"$vt\" | sed -e 's/^.* vt\\([0-9][0-9]*\\) .*$/\\1/'`\n"
" if echo \"$vt\" | grep '^[0-9][0-9]*$' > /dev/null; then\n"
" chvt=\",VT=$vt\"\n"
" fi\n"
" else\n"
-" vt=`ps wwwwwaux | grep X | grep \" $display \" | egrep ' tty([789]|[1-9][0-9][0-9]*) ' | grep -v grep | head -1`\n"
+" vt=`ps wwwwwaux | grep X | egrep \" $d4 \" | egrep ' tty([789]|[1-9][0-9][0-9]*) ' | grep -v grep | head -1`\n"
" if [ \"X$vt\" != \"X\" ]; then\n"
" vt=`echo \"$vt\" | sed -e 's/^.* tty\\([0-9][0-9]*\\) .*$/\\1/'`\n"
" if echo \"$vt\" | grep '^[0-9][0-9]*$' > /dev/null; then\n"
" chvt=\",VT=$vt\"\n"
" fi\n"
+" else\n"
+" pvt=`ps wwwwwaux | grep X | egrep -v 'startx|xinit' | egrep \" $d4 \" | head -1 | awk '{print $2}'`\n"
+" if [ \"X$pvt\" != \"X\" ]; then\n"
+" vt=`lsof -p \"$pvt\" | egrep '/dev/tty([789]|[1-9][0-9][0-9]*)$' | grep -v grep | head -1 | awk '{print $NF}' | sed -e 's,/dev/tty,,'`\n"
+" if echo \"$vt\" | grep '^[0-9][0-9]*$' > /dev/null; then\n"
+" chvt=\",VT=$vt\"\n"
+" else\n"
+" chvt=\",XPID=$pvt\"\n"
+" fi\n"
+" fi\n"
" fi\n"
" fi\n"
"fi\n"
@@ -822,7 +862,6 @@ char find_display[] =
" xauth extract - \"$display\" 2>/dev/null\n"
"fi\n"
"\n"
-"\n"
"exit 0\n"
;
@@ -830,17 +869,20 @@ char create_display[] =
"#!/bin/sh\n"
"\n"
"#CREATE_DISPLAY_OUTPUT=/tmp/cdo.txt\n"
-"if [ \"X$CREATE_DISPLAY_EXEC\" = \"X\" ]; then\n"
-" CREATE_DISPLAY_EXEC=1\n"
-" export CREATE_DISPLAY_EXEC\n"
-" if [ \"X$CREATE_DISPLAY_OUTPUT\" != \"X\" ]; then\n"
-" /bin/sh $0 \"$@\" 2> $CREATE_DISPLAY_OUTPUT\n"
-" else\n"
-" /bin/sh $0 \"$@\" 2> /dev/null\n"
+"if [ \"X$CREATE_DISPLAY_OUTPUT\" != \"X\" ]; then\n"
+" if [ \"X$CREATE_DISPLAY_EXEC\" = \"X\" ]; then\n"
+" CREATE_DISPLAY_EXEC=1\n"
+" export CREATE_DISPLAY_EXEC\n"
+" if [ \"X$CREATE_DISPLAY_OUTPUT\" != \"X\" ]; then\n"
+" /bin/sh $0 \"$@\" 2> $CREATE_DISPLAY_OUTPUT\n"
+" else\n"
+" /bin/sh $0 \"$@\" 2> /dev/null\n"
+" fi\n"
+" exit $?\n"
" fi\n"
-" exit $?\n"
"fi\n"
"\n"
+"\n"
"if [ \"X$CREATE_DISPLAY_OUTPUT\" != \"X\" ]; then\n"
" set -xv\n"
"fi\n"
@@ -848,17 +890,44 @@ char create_display[] =
"findfree() {\n"
" try=20\n"
" n=\"\"\n"
+" nsout=\"\"\n"
+" if [ \"X$have_netstat\" != \"X\" ]; then\n"
+" nsout=`$have_netstat -an`\n"
+" fi\n"
" while [ $try -lt 99 ]\n"
" do\n"
-" if [ ! -e \"/tmp/.X${try}-lock\" ]; then\n"
-" n=$try\n"
-" break\n"
+" if [ ! -f \"/tmp/.X${try}-lock\" ]; then\n"
+" if echo \"$nsout\" | grep \"/tmp/.X11-unix/X${try}[ ]*\\$\" > /dev/null; then\n"
+" :\n"
+" else\n"
+" n=$try\n"
+" break\n"
+" fi\n"
" fi\n"
" try=`expr $try + 1`\n"
" done\n"
" echo \"$n\"\n"
"}\n"
"\n"
+"random() {\n"
+" if [ \"X$RANDOM\" != \"X\" ]; then\n"
+" echo \"$RANDOM\"\n"
+" else\n"
+" r1=`bash -c 'echo $RANDOM' 2>/dev/null`\n"
+" if echo \"$r1\" | grep '^[0-9][0-9]*$' > /dev/null; then\n"
+" echo \"$r1\"\n"
+" else\n"
+" r2=`sh -c 'echo $$; date; ps -elf' 2>/dev/null | sum -r 2>/dev/null | awk '{print $1}'`\n"
+" if echo \"$r2\" | grep '^[0-9][0-9]*$' > /dev/null; then\n"
+" echo \"$r2\"\n"
+" else\n"
+" r3=`sh -c 'echo $$'`\n"
+" echo \"$r3\"\n"
+" fi\n"
+" fi\n"
+" fi\n"
+"}\n"
+"\n"
"findsession() {\n"
" if [ \"X$session\" != \"X\" ]; then\n"
" echo \"$session\"\n"
@@ -927,21 +996,30 @@ char create_display[] =
" if [ \"X$have_root\" != \"X\" -a \"X$USER\" != \"Xroot\" ]; then\n"
" sess=\"env DISPLAY=:$N $sess\"\n"
" fi\n"
+" rmf=\"/nosuch\"\n"
" if echo \"$sess\" | grep '[ ]' > /dev/null; then\n"
-" stmp=/tmp/.cd$$\n"
+" stmp=/tmp/.cd$$`random`\n"
" rm -f $stmp\n"
+" if [ -f $stmp ]; then\n"
+" exit 1\n"
+" fi\n"
" touch $stmp\n"
-" chmod 755 $stmp\n"
+" chmod 755 $stmp || exit 1\n"
" echo \"#!/bin/sh\" > $stmp\n"
" echo \"$sess\" >> $stmp\n"
" echo \"sleep 1\" >> $stmp\n"
" echo \"rm -f $stmp\" >> $stmp\n"
" sess=$stmp\n"
+" rmf=\"$stmp\"\n"
" fi\n"
" if [ \"X$have_root\" != \"X\" -a \"X$USER\" != \"Xroot\" ]; then\n"
-" ctmp=\"/tmp/.xa.$$\"\n"
+" ctmp=/tmp/.xat$$`random`\n"
+" rm -f $ctmp\n"
+" if [ -f $ctmp ]; then\n"
+" exit 1\n"
+" fi\n"
" touch $ctmp\n"
-" chmod 644 $ctmp\n"
+" chmod 644 $ctmp || exit 1\n"
" $have_xauth -f $authfile nextract - :$N > $ctmp\n"
" su - $USER -c \"$have_xauth nmerge - < $ctmp\" 1>&2\n"
" $have_xauth -f $authfile nextract - `hostname`:$N > $ctmp\n"
@@ -954,18 +1032,25 @@ char create_display[] =
" $have_xauth -f $authfile nextract - :$N | $have_xauth nmerge -\n"
" $have_xauth -f $authfile nextract - `hostname`:$N | $have_xauth nmerge -\n"
" fi\n"
-" \n"
-" if [ \"X$have_startx\" != \"X\" ]; then\n"
-" echo \"$have_startx $sess -- $* -auth $authfile\" 1>&2\n"
-" $have_startx $sess -- $* -auth $authfile 1>&2 &\n"
+"\n"
+" if [ \"X$use_xdmcp_query\" = \"X1\" ]; then\n"
+" # we cannot use -nolisten tcp\n"
+" #echo \"$* -from localhost -once -query localhost\"\n"
+" #nohup $* -from localhost -once -query localhost 1>&2 &\n"
+" echo \"$* -once -query localhost\" 1>&2\n"
+" nohup $* -once -query localhost 1>&2 &\n"
+" pid=$!\n"
+" elif [ \"X$have_startx\" != \"X\" ]; then\n"
+" echo \"$have_startx $sess -- $* -nolisten tcp -auth $authfile\" 1>&2\n"
+" $have_startx $sess -- $* -nolisten tcp -auth $authfile 1>&2 &\n"
" pid=$!\n"
" elif [ \"X$have_xinit\" != \"X\" ]; then\n"
-" echo \"$have_xinit $sess -- $* -auth $authfile\" 1>&2\n"
-" $have_xinit $sess -- $* -auth $authfile 1>&2 &\n"
+" echo \"$have_xinit $sess -- $* -nolisten tcp -auth $authfile\" 1>&2\n"
+" $have_xinit $sess -- $* -nolisten tcp -auth $authfile 1>&2 &\n"
" pid=$!\n"
" else\n"
-" echo \"$*\"\n"
-" nohup $* 1>&2 &\n"
+" echo \"$* -nolisten tcp -auth $authfile\" 1>&2\n"
+" nohup $* -nolisten tcp -auth $authfile 1>&2 &\n"
" pid=$!\n"
" nohup $sess 1>&2 &\n"
" fi\n"
@@ -975,15 +1060,31 @@ char create_display[] =
" else\n"
" result=0\n"
" fi\n"
-" #(sleep 120; rm -f $authfile) &\n"
+" if uname | grep SunOS > /dev/null; then\n"
+" nohup sh -c \"(sleep 60; rm -f $rmf)\" 1>&2 &\n"
+" else\n"
+" nohup sh -c \"(sleep 60; rm -f $rmf $authfile)\" 1>&2 &\n"
+" fi\n"
"}\n"
"\n"
"try_X() {\n"
-" if [ \"X$have_xinit\" != \"X\" ]; then\n"
+" if [ \"X$use_xdmcp_query\" = \"X1\" ]; then\n"
+" if [ \"X$have_X\" != \"X\" ]; then\n"
+" server $have_X :$N\n"
+" elif [ \"X$have_Xorg\" != \"X\" ]; then\n"
+" server $have_Xorg :$N\n"
+" elif [ \"X$have_XFree86\" != \"X\" ]; then\n"
+" server $have_XFree86 :$N\n"
+" elif [ \"X$have_Xsun\" != \"X\" ]; then\n"
+" server $have_Xsun :$N\n"
+" fi\n"
+" elif [ \"X$have_xinit\" != \"X\" ]; then\n"
" save_have_startx=$have_startx\n"
" have_startx=\"\"\n"
" server :$N\n"
" have_startx=$save_have_startx\n"
+" else\n"
+" server :$N\n"
" fi\n"
"}\n"
"\n"
@@ -1008,7 +1109,17 @@ char create_display[] =
"\n"
" #save_have_startx=$have_startx\n"
" #have_startx=\"\"\n"
-" server $have_Xvfb :$N -screen 0 ${geom}x${depth}\n"
+" sarg=\"-screen\"\n"
+" if uname | grep SunOS > /dev/null; then\n"
+" if grep /usr/openwin/bin/Xsun $have_Xvfb > /dev/null; then\n"
+" sarg=\"screen\"\n"
+" if [ \"X$depth\" = \"X16\" ]; then\n"
+" #depth=24\n"
+" :\n"
+" fi\n"
+" fi\n"
+" fi\n"
+" server $have_Xvfb :$N $sarg 0 ${geom}x${depth}\n"
" #have_startx=$save_have_startx\n"
"\n"
" if [ \"X$result\" = \"X1\" -a \"X$have_xmodmap\" != \"X\" ]; then\n"
@@ -1031,23 +1142,25 @@ char create_display[] =
" if [ \"X$have_mcookie\" != \"X\" ]; then\n"
" cookie=`mcookie`\n"
" elif [ \"X$have_md5sum\" != \"X\" ]; then\n"
-" if [ -e /dev/urandom ]; then\n"
+" if [ -c /dev/urandom ]; then\n"
" cookie=`dd if=/dev/urandom count=32 2>/dev/null | md5sum | awk '{print $1}'`\n"
-" elif [ -e /dev/random ]; then\n"
+" elif [ -c /dev/random ]; then\n"
" cookie=`dd if=/dev/random count=32 2>/dev/null | md5sum | awk '{print $1}'`\n"
" fi\n"
" if [ \"X$cookie\" = \"X\" ]; then\n"
-" cookie=`(echo $RANDOM; date; uptime; ps -ealf 2>&1) | md5sum | awk '{print $1}'`\n"
+" r=`random`\n"
+" cookie=`(echo $r; date; uptime; ps -ealf 2>&1) | md5sum | awk '{print $1}'`\n"
" fi\n"
" elif [ \"X$have_xauth\" != \"X\" ]; then\n"
" cookie=`$have_xauth list | awk '{print $NF}' | tail -1`\n"
" fi\n"
" if [ \"X$cookie\" = \"X\" ]; then\n"
" # oh well..\n"
-" cookie=$cookie`printf \"%08x\" \"$RANDOM$$\"`\n"
-" cookie=$cookie`printf \"%08x\" \"$RANDOM$$\"`\n"
-" cookie=$cookie`printf \"%08x\" \"$RANDOM$$\"`\n"
-" cookie=$cookie`printf \"%08x\" \"$RANDOM$$\"`\n"
+" for k in 1 2 3 4\n"
+" do\n"
+" r=`random`\n"
+" cookie=$cookie`printf \"%08x\" \"${r}$$\"`\n"
+" done\n"
" fi\n"
" echo \"$cookie\"\n"
"}\n"
@@ -1056,10 +1169,13 @@ char create_display[] =
" if [ \"X$have_xauth\" = \"X\" ]; then\n"
" exit 1\n"
" fi\n"
-" tmp=\"/tmp/.xauth$$$RANDOM\"\n"
+" tmp=/tmp/.xas$$`random`\n"
" rm -f $tmp\n"
+" if [ -f $tmp ]; then\n"
+" exit 1\n"
+" fi\n"
" touch $tmp\n"
-" chmod 600 $tmp\n"
+" chmod 600 $tmp || exit 1\n"
" if [ ! -f $tmp ]; then\n"
" exit 1\n"
" fi\n"
@@ -1073,13 +1189,6 @@ char create_display[] =
"depth=${depth:-16}\n"
"geom=${geom:-1280x1024}\n"
"\n"
-"N=`findfree`\n"
-"\n"
-"if [ \"X$N\" = \"X\" ]; then\n"
-" exit 1\n"
-"fi\n"
-"echo \"trying N=$N ...\" 1>&2\n"
-"\n"
"if [ \"X$USER\" = \"X\" ]; then\n"
" USER=$LOGNAME\n"
"fi\n"
@@ -1087,7 +1196,7 @@ char create_display[] =
" USER=`whoami`\n"
"fi\n"
"\n"
-"PATH=$PATH:/usr/X11R6/bin:/usr/bin/X11:/usr/openwin/bin:/usr/dt/bin:/opt/kde3/bin:/opt/gnome/bin:/usr/bin:/bin\n"
+"PATH=$PATH:/usr/X11R6/bin:/usr/bin/X11:/usr/openwin/bin:/usr/dt/bin:/opt/kde3/bin:/opt/gnome/bin:/usr/bin:/bin:/usr/sfw/bin\n"
"\n"
"have_root=\"\"\n"
"id0=`id`\n"
@@ -1095,17 +1204,38 @@ char create_display[] =
" have_root=\"1\"\n"
"fi\n"
"\n"
-"for prog in startx xinit xdm gdm kdm xterm Xdummy Xvfb xauth mcookie md5sum xmodmap startkde gnome-session blackbox fvwm mwm openbox twm windowmaker metacity\n"
+"p_ok=0\n"
+"if [ \"`type -p /bin/sh`\" = \"/bin/sh\" ]; then\n"
+" p_ok=1\n"
+"fi\n"
+"\n"
+"for prog in startx xinit xdm gdm kdm xterm Xdummy Xvfb xauth mcookie md5sum xmodmap startkde gnome-session blackbox fvwm mwm openbox twm windowmaker metacity X Xorg XFree86 Xsun Xsession netstat\n"
"do\n"
" p2=`echo \"$prog\" | sed -e 's/-/_/g'`\n"
" eval \"have_$p2=''\"\n"
" if type $prog > /dev/null 2>&1; then\n"
-" eval \"have_$p2=`which $prog`\"\n"
+" bpath=`which $prog | awk '{print $NF}'`\n"
+" if [ ! -x \"$bpath\" -o -d \"$bpath\" ]; then\n"
+" if [ \"X$p_ok\" = \"X1\" ]; then\n"
+" bpath=`type -p $prog | awk '{print $NF}'`\n"
+" fi\n"
+" if [ ! -x \"$bpath\" -o -d \"$bpath\" ]; then\n"
+" bpath=`type $prog | awk '{print $NF}'`\n"
+" fi\n"
+" fi\n"
+" eval \"have_$p2=$bpath\"\n"
" fi\n"
"done\n"
"\n"
+"N=`findfree`\n"
+"\n"
+"if [ \"X$N\" = \"X\" ]; then\n"
+" exit 1\n"
+"fi\n"
+"echo \"trying N=$N ...\" 1>&2\n"
+"\n"
"if [ \"X$CREATE_DISPLAY_OUTPUT\" != \"X\" ]; then\n"
-" set | grep ^have_ 1>&2\n"
+" set | grep \"^have_\" 1>&2\n"
"fi\n"
"\n"
"TRY=\"$1\"\n"
@@ -1116,6 +1246,12 @@ char create_display[] =
"for curr_try in `echo \"$TRY\" | tr ',' ' '`\n"
"do\n"
" result=0\n"
+" use_xdmcp_query=0\n"
+" if echo \"$curr_try\" | egrep '[+.-]xdmcp' > /dev/null; then\n"
+" use_xdmcp_query=1\n"
+" fi\n"
+" curr_try=`echo \"$curr_try\" | sed -e 's/[+.-]xdmcp//'`\n"
+" \n"
" if echo \"$curr_try\" | grep -iw \"Xdummy\" > /dev/null; then\n"
" try_Xdummy\n"
" elif echo \"$curr_try\" | grep -iw \"Xvfb\" > /dev/null; then\n"
OpenPOWER on IntegriCloud