xauth and sudo

Chris Covington ccoving at uhc.com
Thu Nov 1 18:23:49 EST 2001

A user wants to sudo to a user and pick up the user's environment, but
when they try, they aren't able to use XWindows.  Is there a way
around this?

In sudo is it possible to read in a .profile, have xauth info merged
in from the old user, and then have a command executed?

For example, how would I get this (or something like it) to work:

XAUTHKEY="`xauth nlist $D`"

sudo -u root ". /.profile; DISPLAY=$D; echo $XAUTHKEY |\
  xauth nmerge -; $COMMAND; xauth remove $D"

Sudo seems to treat the item in quotes as one command rather than a
series of commands.

Chris Covington, ccoving at uhc.com

More information about the sudo-users mailing list