Partial and release upgrade buttons don't work

Bug #1020115 reported by Michael Terry
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
unity-lens-applications
Won't Fix
Undecided
Bilal Akhtar
update-manager (Ubuntu)
Fix Released
High
Michael Terry

Bug Description

Commands spawned from unity (from the Dash, from Alt+F2, from indicators) can't use pkexec.

To reproduce:

1) Download attached test-getppid.py and put it in /usr/bin and chmod +x it
2) Press Alt+F2
3) Type in test-getppid.py and press Enter
4) Click the button
5) A pkexec dialog should pop up, trying to run gcalctool

When you try this script from a Terminal, it works fine.

Impact:

The Desktop team is porting uses of gksu over to pkexec. For example, in Software Updater, the partial upgrade and release upgrade buttons now use pkexec. They will be broken in quantal unless this bug is fixed (or they are reverted to gksu to work around this).

Analysis:

The problem appears to be that getppid() returns 1. And pkexec has the following code:

  /* Figure out the parent process */
  pid_of_caller = getppid ();
  if (pid_of_caller == 1)
    {
      /* getppid() can return 1 if the parent died (meaning that we are reaped
       * by /sbin/init); In that case we simpy bail.
       */
      g_printerr ("Refusing to render service to dead parents.\n");
      goto out;
    }

I'm assuming that getppid() returning 1 is at fault here, not the pkexec code, so I filed this against unity.

ProblemType: Bug
DistroRelease: Ubuntu 12.10
Package: unity 5.12-0ubuntu3
ProcVersionSignature: Ubuntu 3.5.0-2.2-generic 3.5.0-rc4
Uname: Linux 3.5.0-2-generic i686
ApportVersion: 2.2.5-0ubuntu1
Architecture: i386
CheckboxSubmission: 9a284f3f6b4f7829abbe27ad9573a709
CheckboxSystem: 3935143777c965daaa64b51f0134f712
Date: Mon Jul 2 09:58:25 2012
EcryptfsInUse: Yes
InstallationMedia: Ubuntu 11.04 "Natty Narwhal" - Release i386 (20110422)
SourcePackage: unity
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Michael Terry (mterry) wrote :
Revision history for this message
Michael Terry (mterry) wrote :
Revision history for this message
Michael Terry (mterry) wrote :

(I suppose a workaround would be to not execl into pkexec, but rather spawn it as a sub-child. But execl should be a viable tactic, I believe?)

Revision history for this message
Bilal Akhtar (bilalakhtar) wrote :

High for blocking bugs in Software Updater.

Changed in unity:
status: New → Triaged
Changed in unity (Ubuntu):
status: New → Triaged
Changed in unity:
importance: Undecided → High
Changed in unity (Ubuntu):
importance: Undecided → High
Changed in unity:
milestone: none → 6.0
Revision history for this message
Michael Terry (mterry) wrote :

After talking to mhr3 on IRC, it seems that g_spawn* and friends automatically reap the child by default. So this is somewhat expected.

Other packages have apparently worked around this by using a wrapper script. Software Updater may have to do the same.

Changed in unity:
importance: High → Medium
Changed in unity (Ubuntu):
importance: High → Medium
Michael Terry (mterry)
affects: unity (Ubuntu) → update-manager (Ubuntu)
Changed in update-manager (Ubuntu):
importance: Medium → High
affects: unity → update-manager
Changed in update-manager:
milestone: 6.0 → none
summary: - Spawned commands can't use pkexec
+ Partial and release upgrade buttons don't work
Changed in update-manager (Ubuntu):
assignee: nobody → Michael Terry (mterry)
Revision history for this message
Bilal Akhtar (bilalakhtar) wrote :

I fixed this in the applications place daemon, so Michael's test now works fine. But update manager (err, I mean, software updater) might still need changes to use polkit, but my branch (see attached) should reduce the priority of getting that right.

Changed in unity-lens-applications:
status: New → In Progress
assignee: nobody → Bilal Akhtar (bilalakhtar)
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

If it is a general thing that g_spawn_*() doesn't work with pkexec then it suggests that the bug is in glib or pk I think.

Is this not a bug everywhere we launch desktop files? The g_app_info_launch() family, which is used extensively throughout Unity, just uses G_SPAWN_SEARCH_PATH, but would also require G_SPAWN_DO_NOT_REAP_CHILD as seen in Bilal's branch. I wouldn't want to add manual reaping everywhere we do this...

Revision history for this message
Michael Terry (mterry) wrote :

Pushed in a workaround for this in Software Updater by wrapping the call in a /bin/sh invokation.

no longer affects: update-manager
Changed in update-manager (Ubuntu):
status: Triaged → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package update-manager - 1:0.166

---------------
update-manager (1:0.166) quantal; urgency=low

  [ Colin Watson ]
  * Write metarelease file as UTF-8 (LP: #1020526)

  [ Michael Terry ]
  * Use a wrapper script of /bin/sh when calling pkexec, to workaround its
    requirement that the ppid not be 1. (LP: #1020115)
  * Update Unity badge count before showing "please restart" dialog
  * Don't allow closing the "please restart" dialog via window manager
  * Show "please restart" dialog on startup if needed, instead of only
    after installing some updates
 -- Colin Watson <email address hidden> Tue, 10 Jul 2012 11:39:44 +0100

Changed in update-manager (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Tiago Neiva (tneiva) wrote :

other packages suffer the same issue, for example gnome-system-log lp bugs #957641 #1021410

Michal Hruby (mhr3)
Changed in unity-lens-applications:
status: In Progress → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.