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.


CommentiCondividi contenuti

Invia nuovo commento

Il contenuto di questo campo è privato e non verrà mostrato pubblicamente. If you have a Gravatar account associated with the e-mail address you provide, it will be used to display your avatar.
  • Indirizzi web o e-mail vengono trasformati in link automaticamente
  • Elementi HTML permessi: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Linee e paragrafi vanno a capo automaticamente.

Ulteriori informazioni sulle opzioni di formattazione

CAPTCHA
Questa domanda serve a verificare che il form non venga inviato da procedure automatizzate
A
K
k
T
B
c
Enter the code without spaces.