[SOLVED] Running pkexec in terminal works but not in Alt-F2

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
kayeng

[SOLVED] Running pkexec in terminal works but not in Alt-F2

Post by kayeng »

Hi guys,

I open terminal, type "pkexec synaptic", I am prompted to enter password, then synaptic opens. No problem.

I press Alt-F2, type "pkexec synaptic", nothing happens.

I press Alt-F2, type "synaptic", Synaptic opens but without administrative privileges.

My system:
Kernel: 4.15.0-20-generic x86_64 bits: 64
Desktop: Cinnamon 3.8.8 Distro: Linux Mint 19 Tara

1. gksu is no longer supported in all versions, correct? Pkexec is the replacement? Is it the only alternative to the discontinued gksu?

2. Any solution to my problem of not being able to execute pkexec via Alt-F2 ?

Thank you very much!
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
altair4
Level 20
Level 20
Posts: 11461
Joined: Tue Feb 03, 2009 10:27 am

Re: Running pkexec in terminal works but not in Alt-F2

Post by altair4 »

I press Alt-F2, type "pkexec synaptic", nothing happens.
Press Alt-F2 then type "synaptic-pkexec" instead.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
kayeng

Re: Running pkexec in terminal works but not in Alt-F2

Post by kayeng »

That worked, thank you. But how come it does not work with nemo?

Alt-F2 -> nemo-pkexec results in:

Failed to execute child process "nemo-pkexec"

pkexec nemo does not work either, but no error message. Alt_F2 window just disappears.

Thank you.
altair4
Level 20
Level 20
Posts: 11461
Joined: Tue Feb 03, 2009 10:27 am

Re: Running pkexec in terminal works but not in Alt-F2

Post by altair4 »

Welcome to the wacky world of Linux on the Desktop.

You just can't willy nilly run pkexec as if it were a replacement for gksu. That would make far too much sense. Instead for every application that you want to use pkexec it's inventor imagined that a Policykit "policy" be created that allows the end user to use it. In the case of synaptic the rule is here: /usr/share/polkit-1/actions/com.ubuntu.pkexec.synaptic.policy

One wasn't created for nemo. The only desktop Linux I personally know of that made the effort to make it usable for it's default file manager ( Thunar ) and text editor ( mousepad ) is Xubuntu.

You can create your own "policy" for nemo if you wish or you can run it this way:

Code: Select all

nemo admin:///
Or you can follow this thread for 516 other ways to do it: viewtopic.php?f=61&t=268140
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
gm10

Re: Running pkexec in terminal works but not in Alt-F2

Post by gm10 »

@altair4 what?

@OP: Don't worry about the policy stuff mentioned above, it's not relevant. I tried what you described in a Cinnamon live environment and seems this is a bug with Cinnamon. Somebody should check in the LM19.1 Cinnamon beta and if it's still broken it needs a bug report. In the meantime just use a terminal window. Or another desktop environment, works fine in MATE. ;)

You can also create your own gksudo:

Code: Select all

mkdir -p ~/.local/bin
echo -e '#!/bin/sh\n/usr/bin/pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY HOME=$HOME "$@"' > ~/.local/bin/gksudo
chmod u+x ~/.local/bin/gksudo
Reload Cinnamon or relog, then you can prefix that instead of pkexec. Interestingly that one works, wonder what they did that pkexec doesn't.
altair4
Level 20
Level 20
Posts: 11461
Joined: Tue Feb 03, 2009 10:27 am

Re: Running pkexec in terminal works but not in Alt-F2

Post by altair4 »

kayeng wrote: Mon Dec 10, 2018 8:52 am That worked, thank you. But how come it does not work with nemo?

Alt-F2 -> nemo-pkexec
Please note: This is a thought experiment that got totally out of control. I'm not recommending that you or anyone else do this. I just wanted to see if it worked.

Had another look at this and I was thinking that synaptic had the same disease that nemo has but they went to a Doctor so I:

Copied the synaptic-pkexec bin to a nemo-pkexec bin:

Code: Select all

sudo cp -a /usr/bin/synaptic-pkexec /usr/bin/nemo-pkexec
Then edited the nemo bin:

Code: Select all

sudo nano /usr/bin/nemo-pkexec
And changed the last line from this:
pkexec "/usr/sbin/synaptic" "$@"
To this:

Code: Select all

pkexec "/usr/bin/nemo" "$@"
Alt-F2 with nemo-pkexec works.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
gm10

Re: Running pkexec in terminal works but not in Alt-F2

Post by gm10 »

Sure that works, it's basically the same as my (more flexible) gksudo replacement suggestion above. I don't know why Cinnamon fails with a direct pkexec command line, maybe they even block it intentionally.
dkebler
Level 1
Level 1
Posts: 26
Joined: Thu Aug 07, 2014 2:48 pm

Re: Running pkexec in terminal works but not in Alt-F2

Post by dkebler »

if you ended up here because 19.1 broke all your launchers that used gksu then this answer provided above and repeated here was the best/simpliest solution (for me). The new launcher flags gksu and doesn't allow you to preface any command with it. But this `gksudo` or whatever you want to call it is accepted and will get the familiar behavior (launcher that launches the app as root). This was critical for launching things like gnome-disks. I probably post this under a new title so it can be found easier.

Code: Select all

mkdir -p ~/.local/bin
echo -e '#!/bin/sh\n/usr/bin/pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY HOME=$HOME "$@"' > ~/.local/bin/gksudo
chmod u+x ~/.local/bin/gksudo
Reload Cinnamon or relog, then you can prefix that instead of pkexec. Interestingly that one works, wonder what they did that pkexec doesn't.
kayeng

Re: Running pkexec in terminal works but not in Alt-F2

Post by kayeng »

The three lines of code to create gksudo works.

Thanks very much guys.

I'll label the title as solved.
gm10

Re: Running pkexec in terminal works but not in Alt-F2

Post by gm10 »

You are welcome. It's still just a workaround. The Alt+F2 issue will be properly fixed in the upcoming LM19.1 point-release.
kayeng

Re: Running pkexec in terminal works but not in Alt-F2

Post by kayeng »

gm10 wrote: Mon Dec 17, 2018 5:06 am You are welcome. It's still just a workaround. The Alt+F2 issue will be properly fixed in the upcoming LM19.1 point-release.
...and that will make both pkexec and gksudo work?
gm10

Re: Running pkexec in terminal works but not in Alt-F2

Post by gm10 »

kayeng wrote: Tue Dec 18, 2018 5:00 am
gm10 wrote: Mon Dec 17, 2018 5:06 am You are welcome. It's still just a workaround. The Alt+F2 issue will be properly fixed in the upcoming LM19.1 point-release.
...and that will make both pkexec and gksudo work?
It will make pkexec work like you originally tried, yes. The usual limitations with pkexec remain.

The "real" gksudo is gone and won't be coming back, but if you're referring to my workaround above, that will still work.
BeyondLies_MintForum
Level 3
Level 3
Posts: 187
Joined: Wed Aug 14, 2019 1:23 pm

Re: [SOLVED] Running pkexec in terminal works but not in Alt-F2

Post by BeyondLies_MintForum »

Is anyone finding that, since some recent updates, alt-2 `pkexec timeshift` (for example) produces an authentication box but does not actually run the program?

I've reverted sudo and dbus - both of which got upgrades recently - but it doesn't seem to have fixed the problem.
User avatar
smurphos
Level 18
Level 18
Posts: 8498
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: [SOLVED] Running pkexec in terminal works but not in Alt-F2

Post by smurphos »

BeyondLies_MintForum wrote: Mon Feb 03, 2020 10:53 pm Is anyone finding that, since some recent updates, alt-2 `pkexec timeshift` (for example) produces an authentication box but does not actually run the program?

I've reverted sudo and dbus - both of which got upgrades recently - but it doesn't seem to have fixed the problem.
Wrong command - for timeshift GUI you should be running the below which is working fine.

Code: Select all

pkexec timeshift-gtk
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
BeyondLies_MintForum
Level 3
Level 3
Posts: 187
Joined: Wed Aug 14, 2019 1:23 pm

Re: [SOLVED] Running pkexec in terminal works but not in Alt-F2

Post by BeyondLies_MintForum »

> Wrong command

Ah yes. Apologies. However, on one of my Mint machines, `pkexec timeshift-gtk` works in the terminal but not in the alt-F2 prompt. And the same for `pkexec synaptic`. However, on another Mint machine, all is as it should be. Perhaps I have messed up a file permission somewhere.

EDIT: Actually, everything works, on both machines, when I use the default alt-F2 program (I had changed it, because of bugs with the default program) and when I do not use Ulauncher. On one machine, but not another, using Ulauncher (to run e.g. `pkexec timeshift-gtk` or `pkexec mintsources`) has no result and on the other machine, it works. SOLVED: in fstab, I had added - as a security precaution - `noexec` - to tmpfs. Removing that fixed the problem.
Locked

Return to “Software & Applications”