Use "sudo -H" to cover the case when env_keep+="HOME" is set in /etc/sudoers
[xudo.git] / xudo.sh
diff --git a/xudo.sh b/xudo.sh
index 981bcfd..6947d7b 100755 (executable)
--- a/xudo.sh
+++ b/xudo.sh
@@ -70,9 +70,10 @@ id $USERNAME > /dev/null || { echo "Invalid user." 1>&2; exit 1; }
 
 [ "x$@" != "x" ] || { usage 1>&2; exit 1; }
 
-# Authorize the user
-xauth extract - $DISPLAY | sudo -u "$USERNAME" xauth merge -
+# Authorize the user.
+# Use "sudo -H" to cover the case when env_keep+="HOME" is set in /etc/sudoers
+xauth extract - $DISPLAY | sudo -H -u "$USERNAME" xauth merge -
 
 # Execute the command.
-# NOTE: -i or -s have to be passed in order to open a shell
+# NOTE: -i or -s can be passed in order to open a shell
 sudo DISPLAY="$DISPLAY" -u "$USERNAME" "$@"