Running graphical programs as root

houghi houghi at houghi.org
Sat May 5 17:03:59 CEST 2012


On Sat, May 05, 2012 at 03:48:55PM +0200, houghi wrote:
> I would make that:
> #!/bin/bash
> pass=$(zenity --password);
> echo $pass | sudo -S env HOME=$HOME $@

I have an even better solution. It might depend on your version:
houghi at penne : ssh -V
OpenSSH_5.8p2, OpenSSL 1.0.0e 6 Sep 2011

The reason I started looking was because with e.g. gvim, I would get a
running gvim, even when I eneterd a wrong password. So I looked at the
openssh man page and found the -A option.

1) A way of entering a password in a GUI. On my system there already is
ssh-askpass installed at /usr/lib/ssh/ssh-askpass as well as
x11-ssh-askpass. There also exists gnome-ssh-askpass which might look
nicer. A KDE package exists as well.
As an alternative you might want to make a bash script with the content:
#!/bin/bash
zenity --password

2) Add the following to the file /etc/sudo.conf (Make a new file if it
does not yet exists)

Path askpass /usr/lib/ssh/ssh-askpass

Obviously the path to the filename will differ depending of the file.
You can also set the enviroment SUDO_ASKPASS to whatever you desire. See
the manpage of sudo for this.

3) Use the command line `sudo -A gvim`. The -A option is the askpass
option.


Advantage is that it will give you the password 3 times and you do not see
the password when you type it. To make it complete what you could do is
point to the following script that could be name e.g. sudo-for-X

#!/bin/bash
sudo -A $@ || zenity --warning --text="Wrong root password" --timeout=3

As shortcut you use `sudo-for-X gvim --options`

Again, for me it is importand that I can enter the wrong password once in
a while and that nobody looks over my shoulder.

houghi
-- 
This is written under the inluence of the following:
>   Artist : Die Toten Hosen
>     Song : Weltmeister
>    Album : Nur zu Besuch (Unplugged im Wiener Burgtheater)


More information about the Xfce mailing list