diff options
Diffstat (limited to 'x11vnc/ssltools.h')
-rw-r--r-- | x11vnc/ssltools.h | 53 |
1 files changed, 41 insertions, 12 deletions
diff --git a/x11vnc/ssltools.h b/x11vnc/ssltools.h index 9c74d5f..6557a9b 100644 --- a/x11vnc/ssltools.h +++ b/x11vnc/ssltools.h @@ -847,15 +847,18 @@ char find_display[] = "prdpy () {\n" " d1=$1\n" " chvt0=\"\"\n" +" if [ \"X$FIND_DISPLAY_NO_VT_FIND\" != \"X\" ]; then\n" +" :\n" " # we can only do chvt on Linux:\n" -" if [ \"X$uname\" = \"XLinux\" ]; then\n" +" elif [ \"X$uname\" = \"XLinux\" ]; then\n" " d2=$d1\n" " d3=`echo \"$d2\" | sed -e 's/^.*:/:/' -e 's/\\..*$//'`\n" " d4=\"($d2|$d3)\"\n" "\n" " # vt is usually in X server line:\n" " #\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 -n 1`\n" +" ps_tmp=`ps wwaux | grep X`\n" +" vt=`echo \"$ps_tmp\" | grep X | egrep -v 'startx|xinit' | egrep \" $d4 \" | egrep ' vt([789]|[1-9][0-9][0-9]*) ' | grep -v grep | head -n 1`\n" "\n" " if [ \"X$vt\" != \"X\" ]; then\n" " # strip it out and add it.\n" @@ -865,7 +868,7 @@ char find_display[] = " fi\n" " else\n" " # otherwise look for tty:\n" -" vt=`ps wwwwwaux | grep X | egrep \" $d4 \" | egrep ' tty([789]|[1-9][0-9][0-9]*) ' | grep -v grep | head -n 1`\n" +" vt=`echo \"$ps_tmp\" | grep X | egrep \" $d4 \" | egrep ' tty([789]|[1-9][0-9][0-9]*) ' | grep -v grep | head -n 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" @@ -873,8 +876,12 @@ char find_display[] = " fi\n" " else\n" " # otherwise try lsof:\n" -" pvt=`ps wwwwwaux | grep X | egrep -v 'startx|xinit' | egrep \" $d4 \" | head -n 1 | awk '{print $2}'`\n" -" if [ \"X$pvt\" != \"X\" ]; then\n" +" pvt=`echo \"$ps_tmp\" | grep X | egrep -v 'startx|xinit' | egrep \" $d4 \" | head -n 1 | awk '{print $2}'`\n" +" if [ \"X$FIND_DISPLAY_NO_LSOF\" != \"X\" ]; then\n" +" if [ \"X$pvt\" != \"X\" ]; then\n" +" chvt0=\",XPID=$pvt\"\n" +" fi\n" +" elif [ \"X$pvt\" != \"X\" ]; then\n" " vt=`lsof -b -p \"$pvt\" 2>/dev/null | egrep '/dev/tty([789]|[1-9][0-9][0-9]*)$' | grep -v grep | head -n 1 | awk '{print $NF}' | sed -e 's,/dev/tty,,'`\n" " if echo \"$vt\" | grep '^[0-9][0-9]*$' > /dev/null; then\n" " chvt0=\",VT=$vt\"\n" @@ -902,9 +909,9 @@ char find_display[] = "if [ \"X$uname\" = \"XDarwin\" ]; then\n" " psout=`ps aux 2>/dev/null | grep -wv PID | grep -v grep`\n" "elif [ \"X$uname\" = \"XLinux\" -o \"X$is_bsd\" = \"X1\" ]; then\n" -" psout=`ps wwwaux 2>/dev/null | grep -wv PID | grep -v grep`\n" +" psout=`ps wwaux 2>/dev/null | grep -wv PID | grep -v grep`\n" "elif [ \"X$uname\" = \"XSunOS\" -a -x /usr/ucb/ps ]; then\n" -" psout=`/usr/ucb/ps wwwaux 2>/dev/null | grep -wv PID | grep -v grep`\n" +" psout=`/usr/ucb/ps wwaux 2>/dev/null | grep -wv PID | grep -v grep`\n" "else\n" " psout=`ps -ef 2>/dev/null | grep -wv PID | grep -v grep`\n" "fi\n" @@ -1192,6 +1199,8 @@ char find_display[] = "\n" "# try the items in the list:\n" "#\n" +"nsout_trim=`echo \"$nsout\" | grep \"/tmp/.X11-unix/\"`\n" +"#\n" "for p in $list\n" "do\n" " xa=`echo \"$p\" | awk -F, '{print $2}'`\n" @@ -1205,7 +1214,7 @@ char find_display[] = " # check for the local X11 files:\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" +" if echo \"$nsout_trim\" | grep \"/tmp/.X11-unix/X$d[ ]*\\$\" > /dev/null; then\n" " ok=1\n" " fi\n" " fi\n" @@ -1473,6 +1482,7 @@ char create_display[] = "COLUMNS=256\n" "export COLUMNS\n" "\n" +"LC_ALL_save=$LC_ALL\n" "LC_ALL=C\n" "export LC_ALL\n" "\n" @@ -1491,11 +1501,12 @@ char create_display[] = " if [ \"X$have_netstat\" != \"X\" ]; then\n" " nsout=`$have_netstat -an`\n" " fi\n" +" nsout_trim=`echo \"$nsout\" | grep \"/tmp/.X11-unix/\"`\n" " while [ $try -lt $sry ]\n" " do\n" " tlock=\"/tmp/.X${try}-lock\"\n" " if [ -r $tlock ]; then\n" -" if echo \"$nsout\" | grep \"/tmp/.X11-unix/X${try}[ ]*\\$\" > /dev/null; then\n" +" if echo \"$nsout_trim\" | grep \"/tmp/.X11-unix/X${try}[ ]*\\$\" > /dev/null; then\n" " :\n" " else\n" " pid=`head -n 1 $tlock 2>/dev/null | sed -e 's/[ ]//g' | grep '^[0-9][0-9]*$'`\n" @@ -1513,7 +1524,7 @@ char create_display[] = " fi\n" " fi\n" " if [ ! -f $tlock ]; then\n" -" if echo \"$nsout\" | grep \"/tmp/.X11-unix/X${try}[ ]*\\$\" > /dev/null; then\n" +" if echo \"$nsout_trim\" | grep \"/tmp/.X11-unix/X${try}[ ]*\\$\" > /dev/null; then\n" " :\n" " else\n" " n=$try\n" @@ -1829,6 +1840,16 @@ char create_display[] = " echo \"\" 1>&2\n" "}\n" "\n" +"put_back_LC_ALL() {\n" +" if [ \"X$X11VNC_CREATE_LC_ALL_C_OK\" = \"X\" ]; then\n" +" if [ \"X$LC_ALL_save\" = \"X\" ]; then\n" +" unset LC_ALL\n" +" else\n" +" LC_ALL=\"$LC_ALL_save\"\n" +" fi\n" +" fi\n" +"}\n" +"\n" "server() {\n" " authfile=`auth`\n" " sess=`findsession`\n" @@ -1894,6 +1915,7 @@ char create_display[] = " # ns=2\n" " #fi\n" "\n" +"\n" " if [ \"X$use_xdmcp_query\" = \"X1\" ]; then\n" " # we cannot use -nolisten tcp\n" " if [ \"X$FD_XDMCP_IF\" != \"X\" ]; then\n" @@ -1908,6 +1930,7 @@ char create_display[] = " lhost=localhost\n" " fi\n" " echo \"$* -once -query $lhost $FD_OPTS\" 1>&2\n" +" put_back_LC_ALL\n" " if [ \"X$have_root\" != \"X\" ]; then\n" " if [ -r $authfile ]; then\n" " $have_nohup $* -once -query $lhost -auth $authfile $FD_OPTS 1>&2 &\n" @@ -1932,6 +1955,7 @@ char create_display[] = " sxcmd=$have_startx\n" " fi\n" " echo \"$sxcmd $sess -- $* $nolisten -auth $authfile $FD_OPTS\" 1>&2\n" +" put_back_LC_ALL\n" " if [ \"X$have_root\" != \"X\" ]; then\n" " $sxcmd $sess -- $* $nolisten -auth $authfile $FD_OPTS 1>&2 &\n" " else\n" @@ -1947,6 +1971,7 @@ char create_display[] = " else\n" " # need to emulate startx/xinit ourselves...\n" " echo \"$* $nolisten -auth $authfile $FD_OPTS\" 1>&2\n" +" put_back_LC_ALL\n" " if [ \"X$have_root\" != \"X\" ]; then\n" " $have_nohup $* $nolisten -auth $authfile $FD_OPTS 1>&2 &\n" " pid=$!\n" @@ -1964,10 +1989,14 @@ char create_display[] = " $have_nohup sh -c \"(sleep 3; $sess)\" 1>&2 &\n" " fi\n" " fi\n" +"\n" +" LC_ALL=C\n" +" export LC_ALL\n" +"\n" " if uname | grep SunOS > /dev/null; then\n" -" $have_nohup sh -c \"(sleep 60; rm -f $rmf)\" 1>&2 &\n" +" $have_nohup sh -c \"(sleep 150; rm -f $rmf)\" 1>&2 &\n" " else\n" -" $have_nohup sh -c \"(sleep 60; rm -f $rmf $authfile)\" 1>&2 &\n" +" $have_nohup sh -c \"(sleep 150; rm -f $rmf $authfile)\" 1>&2 &\n" " fi\n" "\n" " t=0\n" |