From 12d3b0a9a2dae8d187318c52465fd262c74b0c85 Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Thu, 30 Apr 2020 15:36:17 -0400 Subject: [PATCH] approach for sudo to have X windows working 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. --- scripts/core/functions.sh | 3 +++ scripts/core/launch_feisty_meow.sh | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/scripts/core/functions.sh b/scripts/core/functions.sh index 19e4306c..865aa251 100644 --- a/scripts/core/functions.sh +++ b/scripts/core/functions.sh @@ -451,6 +451,9 @@ if [ -z "$skip_all" ]; then # 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 diff --git a/scripts/core/launch_feisty_meow.sh b/scripts/core/launch_feisty_meow.sh index 0d7d54be..4a6184e6 100644 --- a/scripts/core/launch_feisty_meow.sh +++ b/scripts/core/launch_feisty_meow.sh @@ -92,6 +92,13 @@ if [ "$NO_REPAIRS_NEEDED" == "true" ]; then 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 ############## -- 2.34.1