From: Chris Koeritz Date: Thu, 30 Apr 2020 19:36:17 +0000 (-0400) Subject: approach for sudo to have X windows working X-Git-Tag: 2.140.117^2~8 X-Git-Url: https://feistymeow.org/gitweb/?p=feisty_meow.git;a=commitdiff_plain;h=12d3b0a9a2dae8d187318c52465fd262c74b0c85 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. --- 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 ##############