gksu removed from the repo's of Ubuntu 18.04

Chat about Linux in general
Forum rules
Do not post support questions here. Before you post read the forum rules. Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
Pjotr
Level 24
Level 24
Posts: 20092
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland) 🇳🇱
Contact:

Re: gksu removed from the repo's of Ubuntu 18.04

Post by Pjotr »

smurphos wrote: Mon Dec 16, 2019 1:11 am I do wonder how many people on Mint 20.x will blindly run a commonly recommended command on the forum to fix home ownership issues sudo chown -Rc $USER:$USER $HOME and break root's ownership... :roll: :mrgreen:
I'm not particularly bright this morning, but does this mean that that command (which I apply as a matter of course in each new install) will be harmful in Ubuntu 20.04? :shock:
Tip: 10 things to do after installing Linux Mint 21.3 Virginia
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.
User avatar
karlchen
Level 23
Level 23
Posts: 18212
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: gksu removed from the repo's of Ubuntu 18.04

Post by karlchen »

Hm. Seems as if the shell (/bin/bash) expands the variables $USER and $HOME to the expected values, before executing sudo.
Commandlines tested:

Code: Select all

sudo echo $USER_$USER $HOME
sudo -H echo  $USER:$USER $HOME
sudo -s echo  $USER:$USER $HOME
sudo -i echo  $USER:$USER $HOME
Results:

Code: Select all

karl@computer:~$ sudo echo  $USER:$USER $HOME
karl:karl /home/karl
karl@computer:~$ sudo -H echo  $USER:$USER $HOME
karl:karl /home/karl
karl@computer:~$ sudo -i echo  $USER:$USER $HOME
karl:karl /home/karl
karl@computer:~$ sudo -s echo  $USER:$USER $HOME
karl:karl /home/karl
Image
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 771 days now.
Lifeline
User avatar
xenopeek
Level 25
Level 25
Posts: 29597
Joined: Wed Jul 06, 2011 3:58 am

Re: gksu removed from the repo's of Ubuntu 18.04

Post by xenopeek »

Yes, the shell expands variables before executing a command. If you don't want the shell to expand variables, you must single-quote them. But then echo will just print $USER_$USER $HOME literally.

To have the shell expand the single-quoted variables after running sudo, you must single-quote the entire command and have sudo run that in a shell. So:

Code: Select all

$ sudo bash -c 'echo $USER_$USER $HOME'
root /root
Image
User avatar
karlchen
Level 23
Level 23
Posts: 18212
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: gksu removed from the repo's of Ubuntu 18.04

Post by karlchen »

Hi, xenopeek.

Right. And this suggests that the commandline, which is frequently given to forum users for the purpose of re-instating their user account as the owner of everything in their home directory, sudo chown -Rc $USER:$USER $HOME, will not change its behaviour starting with Ubuntu 20.04.
The variables $USER and $HOME are expanded by the shell, before passing it to sudo.

Cheers,
Karl
Image
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 771 days now.
Lifeline
User avatar
xenopeek
Level 25
Level 25
Posts: 29597
Joined: Wed Jul 06, 2011 3:58 am

Re: gksu removed from the repo's of Ubuntu 18.04

Post by xenopeek »

karlchen wrote: Mon Dec 16, 2019 7:15 amThe variables $USER and $HOME are expanded by the shell, before passing it to sudo.
Correct. The shell expands variables on the command line before invoking the command, unless they are single-quoted.
Image
User avatar
smurphos
Level 18
Level 18
Posts: 8498
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: gksu removed from the repo's of Ubuntu 18.04

Post by smurphos »

Pjotr wrote: Mon Dec 16, 2019 5:41 am
smurphos wrote: Mon Dec 16, 2019 1:11 am I do wonder how many people on Mint 20.x will blindly run a commonly recommended command on the forum to fix home ownership issues sudo chown -Rc $USER:$USER $HOME and break root's ownership... :roll: :mrgreen:
I'm not particularly bright this morning, but does this mean that that command (which I apply as a matter of course in each new install) will be harmful in Ubuntu 20.04? :shock:
Probably brighter than I was when I posed the question, as a soon as i read xenopeeks last reply I thought - Oh yeah - I knew that.. :roll: :oops:
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
User avatar
trytip
Level 14
Level 14
Posts: 5366
Joined: Tue Jul 05, 2016 1:20 pm

Re: gksu removed from the repo's of Ubuntu 18.04

Post by trytip »

majpooper wrote: Sat Dec 14, 2019 1:53 pm Well I got gksu back -
Download it here:

Code: Select all

https://pkgs.org/download/gksu
You should be aware that these .deb packes are based on Ubuntu 16.04 or Debian 9.
LM 19.x as you are aware is based on Ubuntu 18.04 and LMDE 3 is based on Debian 10. So if installing a .deb package designed for 16.04 is a concern I would understand. Just for the record though I have been running gksu on 19.x and LMDE 3 with no issues for months.
if you don't get a save to keyring or session password dialog, using gksu is no sense any longer. you might as well trick gksu to run pkexec as i do. my whole point for using gksu is that it can remember passwords, but it no longer does this.
so installing gksu (and jumping through hoops to find all the correct dependencies) gives you this password window which is basically the same as pkexec window.
Image

if you get this windows and are able to save passwords in keyring or session, than you da man.

Image
Image
User avatar
majpooper
Level 8
Level 8
Posts: 2085
Joined: Thu May 09, 2013 1:56 pm
Location: North Carolina, USA

Re: gksu removed from the repo's of Ubuntu 18.04

Post by majpooper »

trytip wrote: Tue Dec 17, 2019 10:27 am if you don't get a save to keyring or session password dialog, using gksu is no sense any longer. you might as well trick gksu to run pkexec as i do. my whole point for using gksu is that it can remember passwords, but it no longer does this.
so installing gksu (and jumping through hoops to find all the correct dependencies) gives you this password window which is basically the same as pkexec window.
if you get this windows and are able to save passwords in keyring or session, than you da man.
No - It does not save your password.
I am not familiar pkexec - actually I never even heard of it. I want gksu because I am a leafpad txt editor fan and refuse to change - I want to use leafpad from the terminal when I want to how I want when I want to.
With 19.x I could not do

Code: Select all

gksudo leafpad
to open files and edit them but instead the 19.x way is

Code: Select all

xed admin://
which not to be too harsh - sucks - I hated it - it fails, then you have to do it again and so on. So being a creature of habit I wanted gksu back. But I get it - it's the password thing for you so this won't work.
User avatar
xenopeek
Level 25
Level 25
Posts: 29597
Joined: Wed Jul 06, 2011 3:58 am

Re: gksu removed from the repo's of Ubuntu 18.04

Post by xenopeek »

This also works:
SUDO_EDITOR=leafpad sudoedit /dir/file

Add export SUDO_EDITOR=leafpad to your .bashrc or .profile and you can just use this:
sudoedit /dir/file

Benefit of sudoedit is your GUI editor isn't run as root. sudoedit just makes a user-writable temporary copy of the file, opens Leafpad to edit it and after Leafpad close copies the modified file back.
Image
User avatar
majpooper
Level 8
Level 8
Posts: 2085
Joined: Thu May 09, 2013 1:56 pm
Location: North Carolina, USA

Re: gksu removed from the repo's of Ubuntu 18.04

Post by majpooper »

xenopeek wrote: Tue Dec 17, 2019 3:41 pm This also works:
SUDO_EDITOR=leafpad sudoedit /dir/file

Add export SUDO_EDITOR=leafpad to your .bashrc or .profile and you can just use this:
sudoedit /dir/file

Benefit of sudoedit is your GUI editor isn't run as root. sudoedit just makes a user-writable temporary copy of the file, opens Leafpad to edit it and after Leafpad close copies the modified file back.
Hoooah ! Man I wish I would have known this back in July, August or whenever it was when I needed this - THX for better solution than adding obsolete software to solve an issue.
User avatar
Portreve
Level 13
Level 13
Posts: 4870
Joined: Mon Apr 18, 2011 12:03 am
Location: Within 20,004 km of YOU!
Contact:

Re: gksu removed from the repo's of Ubuntu 18.04

Post by Portreve »

Pjotr wrote: Sat Apr 21, 2018 5:41 am And for editing system config files, it almost feels as if we're being pushed towards abusing "sudo". :shock:
I'm not sure why this is a problem. I've always followed your online instructions using sudo nano {foo}. In fact, I've never really understood why you have your directions written the way you do when one can just as easily (I'd argue even more easily) do what I do and have an end to it.
Flying this flag in support of freedom 🇺🇦

Recommended keyboard layout: English (intl., with AltGR dead keys)

Podcasts: Linux Unplugged, Destination Linux

Also check out Thor Hartmannsson's Linux Tips YouTube Channel
User avatar
lewtwo
Level 4
Level 4
Posts: 254
Joined: Wed Oct 29, 2014 8:33 pm
Location: Houston, Texas

Re: gksu removed from the repo's of Ubuntu 18.04

Post by lewtwo »

I never understood why some people seemed to think the ONLY problem this caused was editing configuration files (which is easy enough to get around).
"Engineering is the art of planning and forethought."
http://www.keywild.com
User avatar
trytip
Level 14
Level 14
Posts: 5366
Joined: Tue Jul 05, 2016 1:20 pm

Re: gksu removed from the repo's of Ubuntu 18.04

Post by trytip »

majpooper wrote: Tue Dec 17, 2019 3:16 pm I am not familiar pkexec - actually I never even heard of it. I want gksu because I am a leafpad txt editor fan and refuse to change - I want to use leafpad from the terminal when I want to how I want when I want to.
With 19.x I could not do

Code: Select all

gksudo leafpad
to open files and edit them ...
here's how to trick the system thinking you have gksu: (but you have to uninstall the old gksu packages and dependencies)

Code: Select all

sudo touch /usr/bin/gksu
sudo xed /usr/bin/gksu
paste this, save and make it executable

Code: Select all

/usr/bin/pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY HOME=$HOME PWD=$PWD $@
sudo chmod +x /usr/bin/gksu

now gksu leafpad
Image
User avatar
robsku
Level 1
Level 1
Posts: 21
Joined: Tue May 21, 2019 5:27 am
Location: Helsinki, Finland

Re: gksu removed from the repo's of Ubuntu 18.04

Post by robsku »

smurphos wrote: Mon Dec 16, 2019 12:44 am
robsku wrote: Sat Dec 14, 2019 12:17 pm Still, what would I use to replace gksudo? I mean, I have a script that is meant to be driven from GUI, and it uses gksudo to provide GUI window for asking password, then for the rest of the commands needing root priviledges it uses plain sudo, because the sudo permissions should remain for some time without needing to ask again.
For this use case just use sudo's ASKPASS feature.

e.g. have this little script somewhere

Code: Select all

#!/bin/bash
zenity --password --title="Authenticate"
Then in your script

Code: Select all

 export SUDO_ASKPASS="/path/to/your/zenity_askpass_script"
  sudo -A whatever_the_command_is
Nice and elegant - I actually feel a bit sad I already installed lxsudo and made a gksudo symlink to it... But if that'll ever get removed or I face a Linux installation with no GUI front-end readily available, I will do this next time :) 😃
Jani "Sir Robin" Saksa,
Peace, Linux & Love
My website will be back (eventually)
yanush
Level 1
Level 1
Posts: 22
Joined: Sun Jun 28, 2020 9:04 am

Re: gksu removed from the repo's of Ubuntu 18.04

Post by yanush »

@smurphos
zenity - nice solution but it works in shell only.
I try to use it for item in cinammone menu and it doesn't work.

Have you got an idea why ?
Locked

Return to “Chat about Linux”