Merge branch 'master' of feistymeow.org:feisty_meow
[feisty_meow.git] / scripts / security / get_x_auth.sh
diff --git a/scripts/security/get_x_auth.sh b/scripts/security/get_x_auth.sh
new file mode 100644 (file)
index 0000000..c9f2ea8
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/bash
+# This script finds the X window system authorization info that's already
+# been established for this display.  The information can then be used to
+# set the authorization for a new su session, which keeps X secure as
+# well as allowing the user to run X programs on the original display.
+
+# make sure we have some information to return in the first place.
+if [ ! -z "$DISPLAY" ]; then 
+  disp_search=$(echo $DISPLAY | sed -e 's/.*:\([0-9]*\).*/:\1/')
+#echo disp search is $disp_search
+  temp_auth=$(xauth list | grep -i $HOSTNAME | grep $disp_search)
+#echo temp auth is $temp_auth
+  temp_auth2=$(echo $temp_auth | sed -e "s/$HOSTNAME/; xauth add $HOSTNAME/g" )
+#echo temp auth2 is $temp_auth2
+  export X_auth_info="echo setting X permissions $temp_auth2"
+#echo $X_auth_info
+
+fi
+