projects
/
xudo.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c2b73b5
)
Split getting ans setting the cookie, and unset XAUTHORITY
master
author
Antonio Ospite <ospite@studenti.unina.it>
Mon, 18 Mar 2013 16:48:37 +0000
(17:48 +0100)
committer
Antonio Ospite <ospite@studenti.unina.it>
Mon, 18 Mar 2013 16:48:37 +0000
(17:48 +0100)
xudo.sh
patch
|
blob
|
history
diff --git
a/xudo.sh
b/xudo.sh
index
6947d7b
..
2e34bae
100755
(executable)
--- a/
xudo.sh
+++ b/
xudo.sh
@@
-70,9
+70,18
@@
id $USERNAME > /dev/null || { echo "Invalid user." 1>&2; exit 1; }
[ "x$@" != "x" ] || { usage 1>&2; exit 1; }
[ "x$@" != "x" ] || { usage 1>&2; exit 1; }
+
+# Get the authorization cookie from the current user.
+COOKIE="$(xauth nextract - $DISPLAY)"
+
+# XAUTHORITY needs to be unset now, so that the default $HOME/.Xauthority will
+# be used for the target user and not some locked auth file from the current
+# user.
+unset XAUTHORITY
+
# Authorize the user.
# Use "sudo -H" to cover the case when env_keep+="HOME" is set in /etc/sudoers
# 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 -
+
echo "$COOKIE" | sudo -H -u "$USERNAME" xauth n
merge -
# Execute the command.
# NOTE: -i or -s can be passed in order to open a shell
# Execute the command.
# NOTE: -i or -s can be passed in order to open a shell