[ubuntu-uk] gksu

Jim Price d1version at hotmail.com
Sat Sep 1 21:31:10 UTC 2018


Having been annoyed enough about the removal of gksu from Ubuntu 18.04 I 
finally got around to doing something about it. Can anyone comment on 
whether this has the same security issues that caused gksu to be 
removed? As it just does stuff you could do from the command line I 
would hope not. I should point out that I don't use one of the standard 
Ubuntu desktops so I'm only doing this to get around a problem for me 
and my disappointment with the googled solutions.

Anyway, at the risk of a lesson in egg sucking, here it is (only 4 lines 
of actual code!). Instructions for scripts for Ubuntu 18.04 to run a lot 
like gksu:

Create a script called gksu.sh and put it in <path-to>
~/bin as <path-to> is good, as that gets added to $PATH by default

[code]
#! /bin/bash
# Run argument as root with prompt for password
# note: only 1 argument supported
PROGNAME=$1
export SUDO_ASKPASS=$HOME/bin/askpass.sh; sudo -A "$PROGNAME"
exit
[/code]

Make it executable.

This is going to call another script called askpass.sh:

[code]
#! /bin/bash
# Get a password and return it on stdout
PW=$(zenity --password --title="Password for user $USER" --timeout=10)
echo $PW
exit
[/code]

Make it executable.

Now set up a launcher with the following command:

<path-to>gksu.sh <progname>

e.g. for synaptic:

/home/jim/bin/gksu.sh synaptic

or from the command line, to run a program with elevated permissions:

gksu.sh <progname>

It could also be renamed to remove the .sh, so it is even more like gksu.

JimP




More information about the ubuntu-uk mailing list