summaryrefslogtreecommitdiffstats
path: root/x11vnc/ssltools.h
diff options
context:
space:
mode:
Diffstat (limited to 'x11vnc/ssltools.h')
-rw-r--r--x11vnc/ssltools.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/x11vnc/ssltools.h b/x11vnc/ssltools.h
index b587dcd..98ee802 100644
--- a/x11vnc/ssltools.h
+++ b/x11vnc/ssltools.h
@@ -676,4 +676,75 @@ char genCert[] =
"sign_key\n"
;
+char find_display[] =
+"#!/bin/sh\n"
+"#\n"
+"# Script for use in -display WAIT:cmd=FINDDISPLAY -unixpw mode.\n"
+"# Attempts to find 1) DISPLAY and 2) XAUTH data for the user and\n"
+"# returns them to caller.\n"
+"#\n"
+"# The idea is this script is run via su - user -c ... and returns\n"
+"# display + xauth info to caller (x11vnc running as root or nobody).\n"
+"# x11vnc then uses the info to open the display.\n"
+"#\n"
+"\n"
+"#env; set -xv\n"
+"PATH=$PATH:/bin:/usr/bin:/usr/X11R6/bin:/usr/bin/X11:/usr/openwin/bin:/usr/ucb\n"
+"export PATH\n"
+"\n"
+"# -n means no xauth, -f prescribes file to use.\n"
+"showxauth=1\n"
+"if [ \"X$1\" = \"X-n\" ]; then\n"
+" showxauth=\"\"\n"
+" shift\n"
+"elif [ \"X$1\" = \"X-f\" ]; then\n"
+" shift\n"
+" showxauth=\"$1\"\n"
+" shift\n"
+"fi\n"
+"\n"
+"user=\"$1\" # cmd line arg takes precedence\n"
+"if [ \"X$user\" = \"X\" ]; then\n"
+" user=$X11VNC_USER # then X11VNC_USER\n"
+"fi\n"
+"if [ \"X$user\" = \"X\" ]; then\n"
+" user=$USER # then USER\n"
+"fi\n"
+"if [ \"X$user\" = \"X\" ]; then\n"
+" user=$LOGNAME # then LOGNAME\n"
+"fi\n"
+"if [ \"X$user\" = \"X\" ]; then\n"
+" user=`whoami 2>/dev/null` # desperation whoami\n"
+"fi\n"
+"if [ \"X$user\" = \"X\" ]; then\n"
+" echo \"\" # failure\n"
+" exit 1\n"
+"fi\n"
+"\n"
+"# Now try to match X DISPLAY to user:\n"
+"\n"
+"# who(1) output column 2:\n"
+"display=`who | grep \"^${user}[ ][ ]*:[0-9]\" | head -1 | awk '{print $2}'`\n"
+"\n"
+"if [ \"X$display\" = \"X\" ]; then\n"
+" # who(1) output, last column:\n"
+" display=`who | grep \"^${user}[ ]\" | awk '{print $NF}' | grep '(:[0-9]' | sed -e 's/[()]//g' | head -1`\n"
+" if [ \"X$display\" = \"X\" ]; then\n"
+" echo \"\" # failure\n"
+" exit 1\n"
+" fi\n"
+"fi\n"
+"\n"
+"echo \"DISPLAY=$display\"\n"
+"if [ \"X$showxauth\" != \"X\" ]; then\n"
+" if [ \"X$showxauth\" = \"X1\" ]; then\n"
+" xauth extract - \"$display\" 2>/dev/null\n"
+" else\n"
+" xauth -f \"$showxauth\" extract - \"$display\" 2>/dev/null\n"
+" fi\n"
+"fi\n"
+"\n"
+"exit 0\n"
+;
+
#endif /* _SSLTOOLS_H */
OpenPOWER on IntegriCloud