Merge ~macg3/ubuntu/+source/gdebi:fix_pkexec into ubuntu/+source/gdebi:ubuntu/devel

Proposed by Doug Brown
Status: Needs review
Proposed branch: ~macg3/ubuntu/+source/gdebi:fix_pkexec
Merge into: ubuntu/+source/gdebi:ubuntu/devel
Diff against target: 64 lines (+40/-4)
2 files modified
GDebi/ (+5/-4)
GDebi/ (+35/-0)
Reviewer Review Type Date Requested Status
Ubuntu Sponsors Team Pending
git-ubuntu import Pending
Review via email:

Description of the change

This fixes a longstanding issue that prevents GDebi from working properly when it is launched by a GUI app, such as Firefox or Chrome after downloading a deb file. Ever since Ubuntu 17.10, GDebi just quits immediately when you click Install. It works properly when you run it from a terminal window, but not when launched from Firefox or Chrome. The reason is because pkexec refuses to work if its parent process is init. This change adds an intermediate script that acts as the parent for pkexec.

To test:

- Download a deb file in Firefox/Chrome.
- Open it from within the browser's downloads screen, and choose to open it with GDebi.
- It will open fine. Now, click Install.

Without this change applied, GDebi will immediately quit and the package won't be installed.
After this change is applied, GDebi will successfully install the package.

Another way to test is by directly running GDebi with setsid:

setsid gdebi-gtk package.deb

Without this change, it will fail in the same way. With this change, it will succeed.

The bug that this fixes is Launchpad #1854588. Ideally this would be ported to all of the LTS releases. I'm brand new to this Launchpad workflow, so I'm not sure if there's anything I need to do in order to kickstart this process.

To post a comment you must log in.
Revision history for this message
Robie Basak (racb) wrote :

> I'm brand new to this Launchpad workflow, so I'm not sure if there's anything I need to do in order to kickstart this process.

Sorry, we don't really have a formal way for third parties to submit into this workflow yet - in that there are no reviewers at the other end. To connect the dots, I'm going to link this MP to the bug, and then subscribe ~ubuntu-sponsors to the bug. That way the request will end up in the old sponsorship queue.

Unmerged commits

318f5d2... by Doug Brown <email address hidden>

Create separate script to act as pkexec parent

This fixes the issue of GDebi closing immediately when you click Install
after opening a .deb file from inside of Firefox or Chrome.

Fixes LP #1854588

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/GDebi/ b/GDebi/
2index e0faa49..23e9109 100644
3--- a/GDebi/
4+++ b/GDebi/
5@@ -602,13 +602,14 @@ class GDebiGtk(SimpleGtkbuilderApp, GDebiCommon):
6 return
8 if os.getuid() != 0:
9- pkexec_cmd = "/usr/bin/pkexec"
10- pkexec_args = ["pkexec"]
11- gdebi_args = ["gdebi-gtk", "--non-interactive",
12+ gdebi_dir = os.path.dirname(os.path.abspath(__file__))
13+ pkexec_script = os.path.join(gdebi_dir, "")
14+ gdebi_args = [pkexec_script, "--non-interactive",
15 self._deb.filename]
16 if not install:
17 gdebi_args.append("--remove")
18- os.execv(pkexec_cmd, pkexec_args+gdebi_args)
19+ os.execv(sys.executable,
20+ [os.path.basename(sys.executable)] + gdebi_args)
22 if not self.try_acquire_lock():
23 if install:
24diff --git a/GDebi/ b/GDebi/
25new file mode 100644
26index 0000000..b6181b9
27--- /dev/null
28+++ b/GDebi/
29@@ -0,0 +1,35 @@
30+#! /usr/bin/python3
32+# AUTHOR:
33+# Doug Brown <>
35+# This file is part of GDebi
37+# GDebi is free software; you can redistribute it and/or
38+# modify it under the terms of the GNU General Public License as published
39+# by the Free Software Foundation; either version 2 of the License, or (at
40+# your option) any later version.
42+# GDebi is distributed in the hope that it will be useful,
43+# but WITHOUT ANY WARRANTY; without even the implied warranty of
45+# General Public License for more details.
47+# You should have received a copy of the GNU General Public License
48+# along with GDebi; if not, write to the Free Software
49+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
52+import sys
53+import subprocess
55+# This script exists so that pkexec can be called correctly. cannot
56+# directly use os.execv to run pkexec, because when it is called from GUI
57+# applications such as Firefox, it is orphaned and thus parented by init. pkexec
58+# doesn't like being called like that. This script acts as a parent.
60+cmd = ["/usr/bin/pkexec", "gdebi-gtk"]
61+cmd += sys.argv[1:]
63+result =


People subscribed via source and target branches