[Gambas-user] EXEC ... WITH
Tobias Boege
tobs at taboege.de
Tue Jul 20 08:32:58 CEST 2021
On Mon, 19 Jul 2021, jose.rodriguez at cenpalab.cu wrote:
> July 19, 2021 6:56 AM, "Dimitris Anogiatis" <dosida at gmail.com (mailto:dosida at gmail.com?to=%22Dimitris%20Anogiatis%22%20<dosida at gmail.com>)> wrote:
> This actually worked out for me (i'm on Debian 10.10 with MATE Desktop):
>
> Exec ["pkexec", "env", "DISPLAY=" & Env["DISPLAY"], "XAUTHORITY=" & Env["XAUTHORITY"], Application.Path &/ "vcpufreq-gui.gambas"] Wait
>
> Yes It's an older version of Gambas (3.12) but it showed me that the plugin it used was qt5ct.
> Ooops, my bad, there was a certain degree of PEBKAC involved. I placed that option on the wrong If statement. In my defense, I was seeing cross-eyed by that point, LOL. Now confirmed it works on Mint 20.1 Cinnamon.
>
> However, shouldn't this one work too?:
>
> Exec ["pkexec", Application.Path &/ "vcpufreq-gui.gambas"] With ["DISPLAY=" & Env["DISPLAY"], "XAUTHORITY=" & Env["XAUTHORITY"]] Wait
>
No, read the manpage of pkexec:
The environment that PROGRAM will run it, will be set to a minimal
known and safe environment in order to avoid injecting code through
LD_LIBRARY_PATH or similar mechanisms. In addition the PKEXEC_UID
environment variable is set to the user id of the process invoking
pkexec. As a result, pkexec will not by default allow you to run X11
applications as another user since the $DISPLAY and $XAUTHORITY
environment variables are not set. These two variables will be retained
if the org.freedesktop.policykit.exec.allow_gui annotation on an action
is set to a nonempty value; this is discouraged, though, and should
only be used for legacy programs.
The WITH statement sets the environment variables in the Gambas program
before launching pkexec, then pkexec clears these variables immediately
afterwards.
Best,
Tobias
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
More information about the User
mailing list