Why Not pkexec?

Technical issues/questions of an intermediate or advanced nature.
johnywhy
Samurai
Samurai
Posts: 108
Joined: 29 Mar 2017, 17:26
Distribution: Kiosk
Location: Cali

Why Not pkexec?

Post#1 by johnywhy » 31 Aug 2018, 19:52

hi, why does root thunar launcher use
/opt/porteus-scripts/xorg/psu "dbus-launch --exit-with-session thunar %F"

instead of
pkexec thunar

?

THX

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3933
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

Why Not pkexec?

Post#2 by ncmprhnsbl » 01 Sep 2018, 06:55

that command, which actually needs to be gksu -l dbus-launch --exit-with-session thunar %F (pending bugfix) (note: in xfce(and others) /opt/porteus-scripts/xorg/psu is a symlink to /usr/bin/gksu )
is mainly to remove unwanted (system)mount entries in thunars' sidebar (some gvfs issue i think)
my own experiments with pkexec seemed to suggest that it doesn't take extra arguments (ie dbus-launch --exit-with-session)
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

johnywhy
Samurai
Samurai
Posts: 108
Joined: 29 Mar 2017, 17:26
Distribution: Kiosk
Location: Cali

Why Not pkexec?

Post#3 by johnywhy » 01 Sep 2018, 08:16

i just changed the built-in Thunar (root) launcher to your command
gksu -l dbus-launch --exit-with-session thunar %F

and now it fails.
it works with default command.

THX

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3933
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

Why Not pkexec?

Post#4 by ncmprhnsbl » 01 Sep 2018, 08:33

yeah, sorry, that should have quotes: gksu -l "dbus-launch --exit-with-session thunar %F"
the -l option(login shell) fixes some issue affecting child processes if remember correctly...
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

johnywhy
Samurai
Samurai
Posts: 108
Joined: 29 Mar 2017, 17:26
Distribution: Kiosk
Location: Cali

Why Not pkexec?

Post#5 by johnywhy » 01 Sep 2018, 15:55

why not pkexec?

ToZ says it's ok, if org.xfce.thunar.policy contains

Code: Select all

<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
https://forum.xfce.org/viewtopic.php?pid=49488#p49488

Porteus does. So, pkexec should be ok, no?

THX
Linux porteus 4.16.3-porteus #1 SMP PREEMPT - x86_64 Intel(R) Pentium(R) Dual CPU T2310 @ 1.46GHz GenuineIntel GNU/Linux

User avatar
Ed_P
Contributor
Contributor
Posts: 8360
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Why Not pkexec?

Post#6 by Ed_P » 01 Sep 2018, 16:54

Why have two commands to do the same thing? Which one is smaller?
Ed

johnywhy
Samurai
Samurai
Posts: 108
Joined: 29 Mar 2017, 17:26
Distribution: Kiosk
Location: Cali

Why Not pkexec?

Post#7 by johnywhy » 01 Sep 2018, 16:58

Ed_P wrote:
01 Sep 2018, 16:54
Why have two commands to do the same thing? Which one is smaller?
exactly. This:

Code: Select all

pkexec thunar
is smaller than

Code: Select all

gksu -l dbus-launch --exit-with-session thunar %F
Functionally, what's the difference?
Linux porteus 4.16.3-porteus #1 SMP PREEMPT - x86_64 Intel(R) Pentium(R) Dual CPU T2310 @ 1.46GHz GenuineIntel GNU/Linux

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Why Not pkexec?

Post#8 by brokenman » 01 Sep 2018, 17:44

I believe ncmprhnsbl already answered this question in his first post.
How do i become super user?
Wear your underpants on the outside and put on a cape.

johnywhy
Samurai
Samurai
Posts: 108
Joined: 29 Mar 2017, 17:26
Distribution: Kiosk
Location: Cali

Why Not pkexec?

Post#9 by johnywhy » 01 Sep 2018, 18:22

brokenman wrote:
01 Sep 2018, 17:44
I believe ncmprhnsbl already answered this question in his first post.
Whether i can understand is a separate issue :%)

i think exit-with-session is the sole reason ncmprhnsbl uses dbus-launch. Correct?
-l is the sole reason ncmprhnsbl uses gksu, correct?

gksu man says
--login, -l
Make this a login shell. Beware this may cause problems with the Xauthority magic. Run xhost to allow the target user to open windows on your display!
https://linux.die.net/man/1/gksu
i'm not sure if they mean run xhost instead, or in addition. Could this cause problems with porteus Xauthority?

Why do we need a login shell? This post says
login shells typically read a file that does things like setting environment variables
I'm taking a wild guess, that this has something to do with the environment variables which we want set to the local user, not root, to avoid the issue of root taking ownership of Thunar config files. Correct?

if we're avoiding pkexec to avoid making a policy file, we can do pkexec without a policy file by putting the environment variables on the command line. https://askubuntu.com/a/332847

so, maybe i should really compare these two. Correct?

Code: Select all

pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY thunar
gksu -l dbus-launch --exit-with-session thunar %F
freedesktop.org doesn't recommend using ncmprhnsbl's exit-with-session switch
exit-with-session
If this option is provided, a persistent "babysitter" process will be created, as if for --exit-with-x11. If it cannot connect to the X server, it will monitor the terminal from which dbus-launch was started instead, and if it gets a HUP on stdin, the message bus daemon will be killed. This option is not recommended, since it will consume input from the terminal where it was started; it is mainly provided for backwards compatibility.
https://dbus.freedesktop.org/doc/dbus-launch.1.html
So what's their modern alternative to exit-with-session?

btw, is gksu on porteus an alias? On Mint forum, i got pkexec for a gksudo alias:

Code: Select all

echo '/usr/bin/pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY $@'|sudo tee /usr/local/bin/gksudo
chmod +x /usr/local/bin/gksudo
THX
Linux porteus 4.16.3-porteus #1 SMP PREEMPT - x86_64 Intel(R) Pentium(R) Dual CPU T2310 @ 1.46GHz GenuineIntel GNU/Linux

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3933
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

Why Not pkexec?

Post#10 by ncmprhnsbl » 01 Sep 2018, 22:35

johnywhy wrote:
01 Sep 2018, 18:22
think exit-with-session is the sole reason ncmprhnsbl uses dbus-launch. Correct?
no, dbus-launch is for dbus-launch "is mainly to remove unwanted (system)mount entries in root thunars' sidebar (some gvfs issue i think)"
johnywhy wrote:
01 Sep 2018, 18:22
So what's their modern alternative to exit-with-session?
if i reading correctly, probably the "--exit-with-x11" because it doesn't "consume input from the terminal where it was started", whatever that means... thanks for pointing that out , i'll look into it..
johnywhy wrote:
01 Sep 2018, 18:22
btw, is gksu on porteus an alias? On Mint forum, i got pkexec for a gksudo alias:
no. gksu is /usr/bin/gksu.
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

johnywhy
Samurai
Samurai
Posts: 108
Joined: 29 Mar 2017, 17:26
Distribution: Kiosk
Location: Cali

Why Not pkexec?

Post#11 by johnywhy » 02 Sep 2018, 02:29

thx, can't say i fully understand, but slowly, slowly... :%)
Linux porteus 4.16.3-porteus #1 SMP PREEMPT - x86_64 Intel(R) Pentium(R) Dual CPU T2310 @ 1.46GHz GenuineIntel GNU/Linux

Post Reply