gksu removed from the repo's of Ubuntu 18.04

Chat about Linux in general
User avatar
trytip
Level 8
Level 8
Posts: 2422
Joined: Tue Jul 05, 2016 1:20 pm

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

Post by trytip » Mon Aug 20, 2018 2:27 pm

Mr_Sinister wrote:
Thu Jul 05, 2018 8:00 am
Just upgraded from 18.3 to 19 and this particular feature is gone. And I need it badly.
open .bashrc and at the bottom add these lines:

Code: Select all

alias gksu=pkexec
alias pkexec='pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY'
Last edited by trytip on Mon Aug 20, 2018 3:38 pm, edited 1 time in total.
Image

gm10
Level 12
Level 12
Posts: 4187
Joined: Thu Jun 21, 2018 5:11 pm

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

Post by gm10 » Mon Aug 20, 2018 2:52 pm

trytip wrote:
Mon Aug 20, 2018 2:27 pm

Code: Select all

alias gksu='pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY'
alias pkexec='pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY'
Good suggestion but there's a problem there: You reference the pkexec alias in your gksu alias. So gksu will actually run this: pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY.
While that will still run, better just do like this:

Code: Select all

alias gksu=pkexec
alias pkexec='pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY'
However, my suggestion would be that instead of the alias (not in addition to!) you can create a script ~/.local/bin/gksu with this content:

Code: Select all

/usr/bin/pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY $@
Don't forget to chmod u+x ~/.local/bin/gksu. That way you can use gksu even in launchers. The alias only works in a shell.
Last edited by gm10 on Tue Aug 21, 2018 7:22 am, edited 1 time in total.

User avatar
trytip
Level 8
Level 8
Posts: 2422
Joined: Tue Jul 05, 2016 1:20 pm

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

Post by trytip » Mon Aug 20, 2018 3:16 pm

i was playing with option in here https://sites.google.com/site/installat ... and-gksudo for me the simple alias is much easier. having the .bashrc as they describe it i didn't think of the redundancy , thanx

they also mention as to save the password but haven't found many options that work

Code: Select all

      <allow_any>auth_admin</allow_any>
      <allow_inactive>auth_admin</allow_inactive>
      <allow_active>auth_admin_keep</allow_active>
for instance in /usr/share/polkit-1/actions/com.ubuntu.pkexec.synaptic.policy option for auth_admin_keep doesn't work
Image

gm10
Level 12
Level 12
Posts: 4187
Joined: Thu Jun 21, 2018 5:11 pm

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

Post by gm10 » Mon Aug 20, 2018 3:59 pm

May be minimally easier to set up but as I said it will only work in a bash shell. The solution with a script works from anywhere (within your desktop session). That makes it easier in the end.

auth_admin_keep works in principle, it's in use for many programs. I don't know why it wouldn't work for synaptic, maybe it gets overridden somewhere.

User avatar
trytip
Level 8
Level 8
Posts: 2422
Joined: Tue Jul 05, 2016 1:20 pm

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

Post by trytip » Mon Aug 20, 2018 4:07 pm

gm10 wrote:
Mon Aug 20, 2018 3:59 pm
May be minimally easier to set up but as I said it will only work in a bash shell. The solution with a script works from anywhere (within your desktop session). That makes it easier in the end.

auth_admin_keep works in principle, it's in use for many programs. I don't know why it wouldn't work for synaptic, maybe it gets overridden somewhere.
you right, if the OP needs it in launchers that's a great substitute. for me the only thing that bugs me about gksu removed is that i have to enter passwords one instance after another which gksu had stored in keyring

hopefully i can get pkexec to remember passwords without having to use <allow_active>yes</allow_active> yes instead of auth_admin_keep, but then it opens without asking password
Image

gm10
Level 12
Level 12
Posts: 4187
Joined: Thu Jun 21, 2018 5:11 pm

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

Post by gm10 » Mon Aug 20, 2018 4:15 pm

trytip wrote:
Mon Aug 20, 2018 4:07 pm
hopefully i can get pkexec to remember passwords without having to use <allow_active>yes</allow_active> yes instead of auth_admin_keep, but then it opens without asking password
When it works it only stores it for a few minutes, anyway. Why do you keep closing and reopening synaptic within that time frame?

User avatar
trytip
Level 8
Level 8
Posts: 2422
Joined: Tue Jul 05, 2016 1:20 pm

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

Post by trytip » Mon Aug 20, 2018 8:20 pm

sometimes i get ideas and want to try something late at night with no light on the keyboard. for this i need to open synaptic and see if the software is available in repos first without resorting to ppa

late last night someone had issues with snes9x i open synaptic and search for it it's not there. i close it add the ppa in terminal and update in terminal. but i want to see what's in the ppa before i install it so i open synaptic type password again and look at the new ppa

then maybe i want to open file manager as root and edit some hosts which i always open file manager as root and open the document through that. typing all these passwords in dim light is not an option, i need to turn on overhead lamp so i can see the keyboard

i'm sure the frustration is not mine alone. once i type a password i shouldn't need to do it again 5 minutes later. so at least i found the option to not ask for password.
<allow_any>auth_admin</allow_any>
<allow_inactive>auth_admin</allow_inactive>
<allow_active>yes</allow_active>
very crude very dirty. now i need to do this to all the apps i use often with admin rights.

ps: if we go the route of making a pseudo-gksu why not just take usr/bin/pkexec copy/rename to usr/bin/gksu without having to resort to a local .bin directory or symlink gksu to pkexec ?
Image

gm10
Level 12
Level 12
Posts: 4187
Joined: Thu Jun 21, 2018 5:11 pm

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

Post by gm10 » Mon Aug 20, 2018 8:48 pm

trytip wrote:
Mon Aug 20, 2018 8:20 pm
ps: if you go the route of making a pseudo-gksu why not just take usr/bin/pkexec copy/rename to usr/bin/gksu without having to resort to a local .bin directory or symlink gksu to pkexec ?
You can't rename it because you'd lose access to pkexec. Also, same as when you make a copy, you create a binary outside of the package management system that won't receive any updates. So a symbolic link is the only viable option.

Whether you place the link into a system path or a user path is up to you. Personally I only make system-wide modifications where necessary. Other users can do their own thing if they want to. And I can take my home folder with me and basically have the same features available on every system I use it with.

User avatar
Pjotr
Level 20
Level 20
Posts: 10987
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 » Tue Aug 21, 2018 6:16 am

gm10 wrote:
Mon Aug 20, 2018 2:52 pm
However, my suggestion would be that instead of the alias (not in addition to!) you can create a script ~/.local/bin/gksu with this content:

Code: Select all

/usr/bin/pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY $@
Don't forget to chmod u+x ~/.local/bin/gksu. That way you can use gksu even in launchers. The alias only works in a shell.
That looks pretty cool! Is that 100 % effective, or is it a generic measure that will suffice for *most* applications (but not all)?
Last edited by Pjotr on Tue Aug 21, 2018 11:13 am, edited 1 time in total.
Tip: 10 things to do after installing Linux Mint 19 Tara
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.

gm10
Level 12
Level 12
Posts: 4187
Joined: Thu Jun 21, 2018 5:11 pm

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

Post by gm10 » Tue Aug 21, 2018 7:21 am

Pjotr wrote:
Tue Aug 21, 2018 6:16 am
gm10 wrote:
Mon Aug 20, 2018 2:52 pm
However, my suggestion would be that instead of the alias (not in addition to!) you can create a script ~/.local/bin/gksudo with this content:

Code: Select all

/usr/bin/pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY $@
Don't forget to chmod u+x ~/.local/bin/gksudo. That way you can use gksudo even in launchers. The alias only works in a shell.
That looks pretty cool! Is that 100 % effective, or is it a generic measure that will suffice for *most* applications (but not all)?
Except for a mistake that I made above (obviously it needs to be $@ instead of $1, hope nobody saw that, maybe edit your quote, too :P) it should work for everything.

nichot20
Level 1
Level 1
Posts: 3
Joined: Sun Aug 19, 2018 2:09 pm

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

Post by nichot20 » Wed Aug 22, 2018 5:20 am

nichot20 wrote:
Sun Aug 19, 2018 2:26 pm
I have fallen foul of the gksu removal, and none of the discussions I haver seen in this thread come anywhere near my use case AFAIK, so use of admin:// etc does not seem to work.
[snip]
using pkexec /home/tim/bin/mounter/unmount.sh woodentop pops up a password window similar to gksu but then fails with a "Unable to init server: Could not connect: Connection refused"
Having delved a little further it seems that just using the pkecec.... without any config file does sort of work. However the error message is due to the fact that once everything is done I use zenity to pop up a success/failure window and this is not allowed within pkexec.

I could use the terminal-true option as suggested but I was going for a 'tidy' solution. I will have a look at some of the other suggestions but I don't know if any will overcome pkexec's refusal to allow windows from a different user (and trying to pkexec back to myself doesn't fix it either)

nichot20
Level 1
Level 1
Posts: 3
Joined: Sun Aug 19, 2018 2:09 pm

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

Post by nichot20 » Sat Sep 22, 2018 1:32 pm

gm10 wrote:
Tue Aug 21, 2018 7:21 am
Pjotr wrote:
Tue Aug 21, 2018 6:16 am
gm10 wrote:
Mon Aug 20, 2018 2:52 pm
However, my suggestion would be that instead of the alias (not in addition to!) you can create a script ~/.local/bin/gksudo with this content:

Code: Select all

/usr/bin/pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY $@
Don't forget to chmod u+x ~/.local/bin/gksudo. That way you can use gksudo even in launchers. The alias only works in a shell.
That looks pretty cool! Is that 100 % effective, or is it a generic measure that will suffice for *most* applications (but not all)?
Except for a mistake that I made above (obviously it needs to be $@ instead of $1, hope nobody saw that, maybe edit your quote, too :P) it should work for everything.
I can confirm that this all worked in my use case once I had performed the extra step of removing the -S option from my gksu commands and simply having the command to execute after the gksu command.

gm10
Level 12
Level 12
Posts: 4187
Joined: Thu Jun 21, 2018 5:11 pm

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

Post by gm10 » Sat Sep 22, 2018 1:46 pm

nichot20 wrote:
Sat Sep 22, 2018 1:32 pm
gm10 wrote:
Tue Aug 21, 2018 7:21 am
Pjotr wrote:
Tue Aug 21, 2018 6:16 am

That looks pretty cool! Is that 100 % effective, or is it a generic measure that will suffice for *most* applications (but not all)?
Except for a mistake that I made above (obviously it needs to be $@ instead of $1, hope nobody saw that, maybe edit your quote, too :P) it should work for everything.
I can confirm that this all worked in my use case once I had performed the extra step of removing the -S option from my gksu commands and simply having the command to execute after the gksu command.

Yes, that approach does not support any command line arguments to gksudo, of course. I actually amended my script the other day since I ran into a program that expected $HOME to be set:

Code: Select all

#!/bin/sh
/usr/bin/pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY HOME=$HOME PWD=$PWD $@
Last edited by gm10 on Fri Nov 09, 2018 12:01 pm, edited 1 time in total.

User avatar
lewtwo
Level 3
Level 3
Posts: 143
Joined: Wed Oct 29, 2014 8:33 pm

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

Post by lewtwo » Fri Nov 09, 2018 11:28 am

gm10 wrote:
Sat Sep 22, 2018 1:46 pm

Code: Select all

/usr/bin/pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY HOME=$HOME PWD=$PWD $@
I know this is going to be a really stupid question but ......
I was taught, admonished, etc to always add the following two lines to a bash script file:
#!/bin/bash
# file ~/bin/<filename>

also another comment line with a description or purpose was considered to be good style
any reason NOT to do that here ???


.... interesting: running it without any parameters outputs a snapshot of its environment (that could be useful to know)
  • $ gksu
    SHELL=/bin/bash
    LANG=en_US.UTF-8
    LANGUAGE=en_US
    TERM=xterm
    COLORTERM=truecolor
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
    LOGNAME=root
    USER=root
    HOME=/home/lewis
    PKEXEC_UID=1000
    DISPLAY=:0
    XAUTHORITY=/home/lewis/.Xauthority
    PWD=/home/lewis
    $
Last edited by lewtwo on Fri Nov 09, 2018 12:00 pm, edited 1 time in total.
"Engineering is the art of planning and forethought."
http://www.keywild.com

User avatar
Flemur
Level 16
Level 16
Posts: 6205
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

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

Post by Flemur » Fri Nov 09, 2018 11:58 am

lewtwo wrote:
Fri Nov 09, 2018 11:28 am
I know this is going to be a really stupid question but ......
I was taught, admonished, etc to always add the following two lines to a bash script file:
#!/bin/bash
# file ~/bin/<filename>

also another comment line with a description or purpose was considered to be good style
any reason NOT to do that here ???
That's all excellent stuff. I often forget the #!/bin/bash part and the script will sometimes fail...like when

Code: Select all

$ ls -l `which sh`
... /bin/sh -> dash
I know next to nothing about scripts, but here's some of the bash/dash differences:
https://lwn.net/Articles/343924/
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
Mint 18.3 Xfce/fluxbox/pulse-less
Xubuntu 17.10/fluxbox/pulse-less

gm10
Level 12
Level 12
Posts: 4187
Joined: Thu Jun 21, 2018 5:11 pm

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

Post by gm10 » Fri Nov 09, 2018 12:00 pm

lewtwo wrote:
Fri Nov 09, 2018 11:28 am
I know this is going to be a really stupid question but ......
I was taught, admonished, etc to always add the following two lines to a bash script file:
#!/bin/bash
# file ~/bin/<filename>

also another comment line with a description or purpose was considered to be good style
any reason NOT to do that here ???
No, not a stupid question, I'm just setting a bad example. ;)
It's true you should always define a shebang, but this will do:

Code: Select all

#!/bin/sh
/bin/sh is the system default shell, which is actually dash in LM19. It's much more lightweight than bash, so unless you need specific bash functionality you should stick to the default.

The reason I can be lazy in shell scripts and do without is because if it doesn't find one it fails over and tries to run it as a shell script, anyway. But it's better to define it (edited it into my post that you quoted).

User avatar
lewtwo
Level 3
Level 3
Posts: 143
Joined: Wed Oct 29, 2014 8:33 pm

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

Post by lewtwo » Fri Nov 09, 2018 12:11 pm

gm10 wrote:
Fri Nov 09, 2018 12:00 pm
... snip...

Code: Select all

#!/bin/sh
/bin/sh is the system default shell, which is actually dash in LM19. It's much more lightweight than bash, so unless you need specific bash functionality you should stick to the default.

The reason I can be lazy in shell scripts and do without is because if it doesn't find one it fails over and tries to run it as a shell script, anyway. But it's better to define it (edited it into my post that you quoted).
Thank thee :D :) :D

I changed the parameters arguments as well ...
I wanted to be able to pass a filename as well such as in: gksu xed ~/stupidfile.txt

Mine now looks like this and appears to work (until it doesn't):

Code: Select all

#!/bin/sh
# file ~/bin/gksu
# The developers in their infinite wisdon --sarcasm-- depreciated the gksu command
# This is a substitute
/usr/bin/pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY HOME=$HOME PWD=$PWD $1 $2 $3 $4 $5 $6 $7 $8
I do get an WARNING (I can live with):
** (xed:23856): WARNING **: 10:04:40.812: Set document metadata failed: Setting attribute metadata::xed-position not supported
Note I ONLY get this from xed --- thus far.
"Engineering is the art of planning and forethought."
http://www.keywild.com

Post Reply

Return to “Chat about Linux”