summaryrefslogtreecommitdiffstats
path: root/x11vnc/ssltools.h
diff options
context:
space:
mode:
Diffstat (limited to 'x11vnc/ssltools.h')
-rw-r--r--x11vnc/ssltools.h94
1 files changed, 66 insertions, 28 deletions
diff --git a/x11vnc/ssltools.h b/x11vnc/ssltools.h
index a454772..e6f82c3 100644
--- a/x11vnc/ssltools.h
+++ b/x11vnc/ssltools.h
@@ -1017,6 +1017,14 @@ char find_display[] =
" fi\n"
"}\n"
"\n"
+"am_root=\"\"\n"
+"if id | sed -e 's/ gid.*$//' | grep -w root > /dev/null; then\n"
+" am_root=1\n"
+"fi\n"
+"am_gdm=\"\"\n"
+"if id | sed -e 's/ gid.*$//' | grep -w gdm > /dev/null; then\n"
+" am_gdm=1\n"
+"fi\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"
@@ -1037,42 +1045,72 @@ 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"
-" xtf=$HOME/.xat.$$\n"
-" xtf=`mytmp \"$xtf\"`\n"
-" if [ ! -f $xtf ]; then\n"
-" xtf=/tmp/.xat.$$\n"
-" xtf=`mytmp \"$xtf\"`\n"
+" si_root=\"\"\n"
+" si_gdm=\"\"\n"
+" # recent gdm seems to use SI:localuser: for xauth.\n"
+" if env DISPLAY=\"$da\" xhost 2>/dev/null | grep -i '^SI:localuser:root$' > /dev/null; then\n"
+" si_root=1\n"
+" fi\n"
+" if env DISPLAY=\"$da\" xhost 2>/dev/null | grep -i '^SI:localuser:gdm$' > /dev/null; then\n"
+" si_gdm=1\n"
+" fi\n"
+" env XAUTHORITY=/dev/null xdpyinfo -display \"$da\" >/dev/null 2>&1\n"
+" rc=$?\n"
+" if [ \"X$rc\" = \"X0\" ]; then\n"
+" # assume it is ok for server interpreted case.\n"
+" if [ \"X$am_root\" = \"X1\" -a \"X$si_root\" = \"X1\" ]; then\n"
+" rc=5\n"
+" elif [ \"X$am_gdm\" = \"X1\" -a \"X$si_gdm\" = \"X1\" ]; then\n"
+" rc=6\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"
+" if [ $rc != 0 ]; then\n"
+" y=`prdpy $da`\n"
+" if [ \"X$FIND_DISPLAY_NO_SHOW_DISPLAY\" = \"X\" ]; then\n"
+" echo \"DISPLAY=$y\"\n"
+" fi\n"
+" if [ \"X$FIND_DISPLAY_XAUTHORITY_PATH\" != \"X\" ]; then\n"
+" # caller wants XAUTHORITY printed out too.\n"
+" if [ \"X$xa\" != \"X\" -a -f \"$xa\" ]; then\n"
+" echo \"XAUTHORITY=$xa\"\n"
+" else\n"
+" echo \"XAUTHORITY=$XAUTHORITY\"\n"
+" fi\n"
+" fi\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"
-" touch $xtf 2>/dev/null\n"
-" chmod 600 $xtf 2>/dev/null\n"
" if [ ! -f $xtf ]; then\n"
-" exit 1\n"
+" xtf=/tmp/.xatb.$$\n"
+" rm -f $xtf\n"
+" if [ -f $xtf ]; 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"
" fi\n"
+" xauth -f $xtf add \"$da\" . $cook\n"
+" xauth -f $xtf extract - \"$da\" 2>/dev/null\n"
+" rm -f $xtf\n"
" fi\n"
-" xauth -f $xtf add \"$da\" . $cook\n"
-" xauth -f $xtf extract - \"$da\" 2>/dev/null\n"
-" rm -f $xtf\n"
+" # DONE\n"
+" exit 0\n"
" fi\n"
-" # DONE\n"
-" exit 0\n"
-" fi\n"
" fi\n"
" fi\n"
" done\n"
-" echo \"\" # failure\n"
+" if [ \"X$FIND_DISPLAY_XAUTHORITY_PATH\" = \"X\" ]; then\n"
+" echo \"\" # failure\n"
+" fi\n"
" if [ \"X$showxauth\" != \"X\" ]; then\n"
" echo \"\"\n"
" fi\n"
@@ -1106,7 +1144,7 @@ char find_display[] =
" for xa in /tmp/.gdm* /tmp/.Xauth* /var/run/gdm/auth-for-*/database /var/run/gdm/auth-cookie-*-for-*\n"
" do\n"
" # try to be somewhat careful about the real owner of the file:\n"
-" if id | sed -e 's/ gid.*$//' | grep -w root > /dev/null; then\n"
+" if [ \"X$am_root\" = \"X1\" ]; then\n"
" break\n"
" fi\n"
" if [ -f $xa -a -r $xa ]; then\n"