No alternative for this gksu usage

No alternative for this gksu usage



Ubuntu 18.04 removed the gksu package entirely from its repositories.



The rational behind this is that gksu is thought to be used only in this way:


gksu gedit /some/root/setting



But there are other usages of gksu as well. Gksu is an important program because unlike sudo or graphical programs like pkexec it prevents other programs from stealing focus.



So when you want to type your password using simple cli sudo, and some chat window pops up, what happens is that the password is entered into the chat window (if you don't look at the screen for a moment), and your root password is sent to you chatting buddy. It happened to me once and I don't want it to happen ever again.



This is why gksu is ideal security wise, and I use it often at command line level. So not to launch gedit, but to do command line stuff, e.g. apt-get update && apt-get upgrade or execute some bash scripts.



And no, pkexec is not an alternative to gksu, because 1) it does not execute scripts, only binaries and 2) it doesn't prevent other programs from stealing focus.



Secondly, you can also use gksu to ask for non-root passwords in a secure manner. For example:


ccrypt -K `gksu -p --message "Password:"` -d data.tar



So my question is: what program can be used as an alternative to gksu in these cases?




2 Answers
2



You can still obtain gksu as follows:


wget http://mirrors.kernel.org/ubuntu/pool/universe/libg/libgksu/libgksu2-0_2.0.13~pre1-9ubuntu2_amd64.deb

sudo apt install ./libgksu2-0_2.0.13~pre1-9ubuntu2_amd64.deb

wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gksu/gksu_2.0.2-9ubuntu1_amd64.deb

sudo apt install ./gksu_2.0.2-9ubuntu1_amd64.deb





That would be great. But wouldn't that cause security problems? (not a retorical question) gksu is critical...
– L.A. Rabida
2 days ago



This answer deals only with gksu gedit and nothing else.


gksu gedit



Besides the disappearance of gksu with Ubuntu 17.10, I've had long standing problems where my regular user settings for font name, font size, tab stops, convert tabs to spaces, etc. were never carried over to sudo / gksudo and I'd always have to reset them.


gksu


sudo


gksudo



Furthermore sudo gets no top-level menu for editing preferences.


sudo



The script I wrote not only allows gksu-like usage with gedit but also copies my user gedit preferences over to the sudo account.


gksu


gedit


gedit


sudo



You will need to change one line of code:


nohup gedit -g 1300x840+1+1220 $@ &>/dev/null &



This positions the window 1 pixel right and 1220 pixels down. You might prefer 1+1 instead of 1+1220.


1


1220


1+1


1+1220



The window size is set to 1300 pixels wide by 840 pixels high. You might prefer a smaller or larger size depending on Monitor resolution and HiDPI. So change 1330x840 to your preferences.


1300


840


1330x840


#!/bin/bash

# NAME: sgedit
# PATH: /mnt/e/bin
# DESC: Run gedit as sudo using $USER preferences
# DATE: June 17, 2018.

# Must not prefix with sudo when calling script
if [[ $(id -u) == 0 ]]; then
zenity --error --text "You cannot call this script using sudo. Aborting."
exit 99
fi

# Get user preferences before elevating to sudo
gsettings list-recursively | grep -i gedit | grep -v history |
grep -v docinfo |
grep -v virtual-root | grep -v state.window > /tmp/gedit.gsettings

sudoFunc ()
grep -v docinfo

FUNC=$(declare -f sudoFunc)
sudo -H bash -c "$FUNC; sudoFunc $*;"

exit 0



Create the bash script somewhere in your path and mark it as executable using:


sudo chmod a+x /path/to-script/sgedit



Then to call it use:


sgedit <file-name>



instead of the old system of:


gksu gedit <file-name>



HTH



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Some of your past answers have not been well-received, and you're in danger of being blocked from answering.



Please pay close attention to the following guidance:



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

How do I collapse sections of code in Visual Studio Code for Windows?

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ