After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 763531 - pkexec in .desktop no longer works
pkexec in .desktop no longer works
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: overview
3.20.x
Other Linux
: Normal critical
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2016-03-12 12:33 UTC by Inactive account
Modified: 2017-10-05 07:43 UTC
See Also:
GNOME target: ---
GNOME version: 3.19/3.20


Attachments
app: Work around pkexec restriction when launching (2.97 KB, patch)
2017-03-25 02:07 UTC, Florian Müllner
none Details | Review
app: Work around pkexec restriction when launching (2.05 KB, patch)
2017-09-07 14:11 UTC, Florian Müllner
committed Details | Review

Description Inactive account 2016-03-12 12:33:23 UTC
I am in need of doing some diagnostics work with "xdiagnose", however when searching for it in the Activities Overview, and then clicking on it, absolutely nothing happens, when in the past it would ask me for my password so that I could run it as root.

I looked further into the issue and when trying to run it through Terminal:

    xdiagnose

This was the output I got:

    Error: Must run as superuser

But when running it in Terminal like so:

    pkexec xdiagnose

It prompted for the password as it normally would and should (so pkexec is not the issue).

There was also no output from the command:

    grep -r 'xdiagnose' ~/.local/share/applications

And the output of this command "grep -r 'xdiagnose' /usr/share/applications" was:

    /usr/share/applications/xdiagnose.desktop:Name=xdiagnose
    /usr/share/applications/xdiagnose.desktop:Exec=pkexec xdiagnose
    /usr/share/applications/xdiagnose.desktop:Icon=/usr/share/xdiagnose/icons/microscope.svg
    /usr/share/applications/xdiagnose.desktop:X-Ubuntu-Gettext-Domain=xdiagnose

The contents of the file is this:

    [Desktop Entry]
    Name=xdiagnose
    GenericName=Diagnose Graphics Issues
    Comment=X.org Diagnostic and Repair Utility
    Exec=pkexec xdiagnose
    Icon=/usr/share/xdiagnose/icons/microscope.svg
    Terminal=false
    Type=Application
    Categories=System;Settings;
    X-Ubuntu-Gettext-Domain=xdiagnose

I have reinstalled it with "sudo apt-get install --reinstall xdiagnose", however this seems to have made no difference at all to anything.

I have also attempted to launch another application via the Activities Overview that uses 'pkexec' to start, and it works fine as normal.

I initially experienced this issue on Ubuntu GNOME 15.04 with GNOME 3.16, then on Ubuntu GNOME 15.10 with GNOME 3.18, and now on Ubuntu GNOME 16.04 with GNOME 3.19. Though I remember a time when this issue wasn't present (probably when I was running Ubuntu GNOME 15.04 with GNOME 3.14 - I will test it and then update the report).

I also initially report this issue here but thought I should also do so upstream: https://bugs.launchpad.net/ubuntu-gnome/+bug/1483276
Comment 1 Inactive account 2016-03-12 21:37:57 UTC
Sorry, it seems that I am unable to get an Ubuntu GNOME 15.04 (EOL) version anywhere legit so I will be unable to test whether or not it works there with GNOME 3.14.
Comment 2 Inactive account 2016-05-29 18:36:58 UTC
I am still experiencing this issue on Ubuntu GNOME 16.04 with GNOME 3.20.
Comment 3 Inactive account 2016-06-01 10:45:26 UTC
I have tested this on Ubuntu Unity 16.04, and it works fine so this is most likely a GNOME issue.
Comment 4 Inactive account 2016-08-22 16:47:04 UTC
The fix in this bug report: https://bugs.launchpad.net/ubuntu/xenial/+source/xdiagnose/+bug/1483276 Seemingly fixes the issue so I am closing this bug as it appears to have been a downstream issue even though strangely not affecting all and not affecting my Unity VM at the time.
Comment 5 Jeremy Bicha 2016-08-23 03:42:20 UTC
Just because it was worked around in Ubuntu and just because it doesn't affect Unity does not mean that it's a Ubuntu-specific issue. Someone will need to do more investigation to find out what made 'pkexec xdiagnose' stop working from GNOME Shell's Activities Overview since this may affect other apps that try to do that too. A wrapper script whose only contents is "pkexec xdiagnose' is just a workaround.
Comment 6 Jeremy Bicha 2016-08-23 03:46:38 UTC
A bug that affects gnome-shell in Ubuntu but not gnome-shell in Fedora or other distros might be a downstream bug if Ubuntu did something different in their gnome-shell packaging related to the bug. From your bug report, you haven't tested gnome-shell in other distros.
Comment 7 Florian Müllner 2017-03-25 02:07:48 UTC
Created attachment 348678 [details] [review]
app: Work around pkexec restriction when launching

Unless automatic child reaping is disabled in GSpawnFlags, glib's
g_spawn_* functions will reparent the spawned process to init by
double-forking. Unfortunately pkexec bails out in this case[0],
which means that it no longer works in .desktop files since the
PID tracking removal in commit 01c6392c1373.
Fix this by going back to manual child reaping when an app is launched
through pkexec.

[0] https://cgit.freedesktop.org/polkit/tree/src/programs/pkexec.c#n728
Comment 8 Jeremy Bicha 2017-03-25 02:47:34 UTC
Thanks, patch 348678 fixes the xdiagnose test case.
Comment 9 Jeremy Bicha 2017-03-25 02:48:07 UTC
(I applied it locally to gnome-shell 3.24 on Ubuntu GNOME 17.04 Beta).
Comment 10 cc rstrode@redhat.com not me 2017-09-06 13:35:58 UTC
Review of attachment 348678 [details] [review]:

::: src/shell-app.c
@@ +1245,3 @@
+  if (g_strcmp0 (g_app_info_get_executable (G_APP_INFO (app->info)), "pkexec") == 0)
+    {
+      flags |= G_SPAWN_DO_NOT_REAP_CHILD;

probably should just do this unconditionally, right? There's no advantage to orphaning the children by default is there?
Comment 11 Ray Strode [halfline] 2017-09-06 18:43:44 UTC
(In reply to cc rstrode@redhat.com not me from comment #10)
^ (oops was logged into the wrong account)
Comment 12 Florian Müllner 2017-09-07 14:11:46 UTC
Created attachment 359356 [details] [review]
app: Work around pkexec restriction when launching

(In reply to cc rstrode@redhat.com not me from comment #10)
> probably should just do this unconditionally, right? There's no advantage to
> orphaning the children by default is there?

Not as far as I can see, other than letting GLib do the cleanup for us. Of course if we handle the cleanup for *some* apps, we can do it just as well for all of them ...
Comment 13 Ray Strode [halfline] 2017-09-08 18:45:35 UTC
Review of attachment 359356 [details] [review]:

looks good to me.
Comment 14 Florian Müllner 2017-09-12 15:34:15 UTC
Attachment 359356 [details] pushed as 053b8da - app: Work around pkexec restriction when launching