summaryrefslogtreecommitdiffstats
path: root/x11vnc/ssltools.h
diff options
context:
space:
mode:
Diffstat (limited to 'x11vnc/ssltools.h')
-rw-r--r--x11vnc/ssltools.h161
1 files changed, 121 insertions, 40 deletions
diff --git a/x11vnc/ssltools.h b/x11vnc/ssltools.h
index a2d6499..3824870 100644
--- a/x11vnc/ssltools.h
+++ b/x11vnc/ssltools.h
@@ -830,6 +830,52 @@ char find_display[] =
" pslist=`echo \"$psout\" | awk '{print $2}'`\n"
"fi\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"
"# 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"
@@ -845,39 +891,38 @@ char find_display[] =
" #\n"
" env XAUTHORITY=\"$xa\" xdpyinfo -display \"$da\" >/dev/null 2>&1\n"
" if [ $? = 0 ]; then\n"
-" env XAUTHORITY=/dev/null xdpyinfo -display \"$da\" >/dev/null 2>&1\n"
-" if [ $? != 0 ]; then\n"
-" y=`prdpy $da`\n"
-" echo \"DISPLAY=$y\"\n"
-" if [ \"X$showxauth\" != \"X\" ]; then\n"
-" # copy the cookie:\n"
-" cook=`xauth -f \"$xa\" list | head -n 1 | awk '{print $NF}'`\n"
-" tf=$HOME/.xat.$$\n"
-" rm -f $tf\n"
-" if [ -f $tf ]; then\n"
+" env XAUTHORITY=/dev/null xdpyinfo -display \"$da\" >/dev/null 2>&1\n"
+" if [ $? != 0 ]; then\n"
+" y=`prdpy $da`\n"
+" echo \"DISPLAY=$y\"\n"
+" if [ \"X$showxauth\" != \"X\" ]; then\n"
+" # copy the cookie:\n"
+" cook=`xauth -f \"$xa\" list | head -n 1 | awk '{print $NF}'`\n"
+" xtf=$HOME/.xat.$$\n"
+" xtf=`mytmp \"$xtf\"`\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"
" fi\n"
-" touch $tf 2>/dev/null\n"
-" chmod 600 $tf 2>/dev/null\n"
-" if [ ! -f $tf ]; then\n"
-" tf=/tmp/.xat.$$\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"
+" touch $xtf 2>/dev/null\n"
+" chmod 600 $xtf 2>/dev/null\n"
+" if [ ! -f $xtf ]; then\n"
+" exit 1\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"
-" # DONE\n"
-" exit 0\n"
+" xauth -f $xtf add \"$da\" . $cook\n"
+" xauth -f $xtf extract - \"$da\" 2>/dev/null\n"
+" rm -f $xtf\n"
" fi\n"
+" # DONE\n"
+" exit 0\n"
+" fi\n"
" fi\n"
" fi\n"
" done\n"
@@ -1459,6 +1504,51 @@ char create_display[] =
" redir_daemon=`echo \"$redir_daemon\" | sed -e 's/^,*//'`\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"
" authfile=`auth`\n"
" sess=`findsession`\n"
@@ -1475,10 +1565,7 @@ char create_display[] =
" rmf=\"/nosuch\"\n"
" if echo \"$sess\" | grep '[ ]' > /dev/null; then\n"
" stmp=/tmp/.cd$$`random`\n"
-" rm -f $stmp\n"
-" if [ -f $stmp ]; then\n"
-" exit 1\n"
-" fi\n"
+" stmp=`mytmp \"$stmp\"`\n"
" touch $stmp\n"
" chmod 755 $stmp || exit 1\n"
" echo \"#!/bin/sh\" > $stmp\n"
@@ -1490,10 +1577,7 @@ char create_display[] =
" fi\n"
" if [ \"X$have_root\" != \"X\" -a \"X$USER\" != \"Xroot\" ]; then\n"
" ctmp=/tmp/.xat$$`random`\n"
-" rm -f $ctmp\n"
-" if [ -f $ctmp ]; then\n"
-" exit 1\n"
-" fi\n"
+" ctmp=`mytmp \"$ctmp\"`\n"
" touch $ctmp\n"
" chmod 644 $ctmp || exit 1\n"
" $have_xauth -f $authfile nextract - :$N > $ctmp\n"
@@ -1799,10 +1883,7 @@ char create_display[] =
" exit 1\n"
" fi\n"
" tmp=/tmp/.xas$$`random`\n"
-" rm -f $tmp\n"
-" if [ -f $tmp ]; then\n"
-" exit 1\n"
-" fi\n"
+" tmp=`mytmp \"$tmp\"`\n"
" touch $tmp\n"
" chmod 600 $tmp || exit 1\n"
" if [ ! -f $tmp ]; then\n"