this should enable root or other users to start X windows on the user's display, assuming that the DISPLAY variable is passed in and that the new xauth imported info is also available.
# label if they're doing an su with the sudo.
function sudo() {
save_terminal_title
+ # hoist our X authorization info in case environment is passed along;
+ # this can allow root to use our display to show Xorg windows.
+ export IMPORTED_XAUTH="$(xauth list $DISPLAY)"
/usr/bin/sudo "$@"
retval=$?
restore_terminal_title
if [ -z "$USER" -a ! -z "$CRONUSER" ]; then
export USER="$CRONUSER"
fi
+
+ # use the xauth info if we were given one in the environment.
+ # this allows root or other su'd identities to create windows with same
+ # display variable.
+ if [ ! -z "$DISPLAY" -a ! -z "$IMPORTED_XAUTH" ]; then
+ xauth add "$IMPORTED_XAUTH"
+ fi
##############