Run commands as another user, with access to the X display
I've uploaded a simple wrapper around sudo, for executing commands as another user with full access to the X display (GLX works too); I call it xudo.
The script basically does two things:
- Authorize the user:
xauth extract - $DISPLAY | sudo -u SOMEUSER xauth merge -
- Run the command preserving the
DISPLAY
environment variable:sudo DISPLAY="$DISPLAY" -u SOMEUSER SUDO_OPTIONS
And you can of course use the
-i
or-s
sudo options to get a shell as the other user, from where you can launch graphical applications.
All the other bits in the script are really just boilerplate.
Keep in mind that security-wise this is indeed a little stricter than the xhost +local:
and xauth generate
combination, as it authorizes only the user you want, but the command you execute still gets access to the whole X server, so you still don't want to run programs you don't trust using this method.
Comments
Post new comment