Merge lp:~laney/ubiquity/dbus-session-bus into lp:ubiquity

Proposed by Iain Lane
Status: Merged
Merged at revision: 6624
Proposed branch: lp:~laney/ubiquity/dbus-session-bus
Merge into: lp:ubiquity
Diff against target: 93 lines (+16/-8)
4 files modified
data/ubiquity.desktop.in (+1/-1)
debian/changelog (+5/-0)
ubiquity/gsettings.py (+7/-4)
ubiquity/misc.py (+3/-3)
To merge this branch: bzr merge lp:~laney/ubiquity/dbus-session-bus
Reviewer Review Type Date Requested Status
Sebastien Bacher Approve
Ubuntu Installer Team Pending
Review via email: mp+343838@code.launchpad.net

Description of the change

Pass user session bus address through from desktop into ubiquity, & execute gsettings with that bus.

Also use SUDO_UID if PKEXEC_UID is not set.

To post a comment you must log in.
Revision history for this message
Iain Lane (laney) wrote :
Revision history for this message
Sebastien Bacher (seb128) wrote :

Looks good to me, thanks!

review: Approve
Revision history for this message
Iain Lane (laney) wrote :

My bad, I accidentally pushed this to trunk before an ~ubuntu-installer member reviewed.

Feel free to do so, or it'll get reviewed in the unapproved queue anyway.

Revision history for this message
Sebastien Bacher (seb128) wrote :

the version pushed with the extra XDG_RUNTIME_DIR env looks good/works fine, +1 from but I'm not in the ~ubuntu-installer so my review might not count

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/ubiquity.desktop.in'
2--- data/ubiquity.desktop.in 2016-09-27 02:36:35 +0000
3+++ data/ubiquity.desktop.in 2018-04-23 17:21:26 +0000
4@@ -6,7 +6,7 @@
5 _Comment=Install this system permanently to your hard disk
6 _Keywords=ubiquity;
7 #use sh because pkexec is broken under xfce/lxce http://pad.lv/1193526
8-Exec=sudo sh -c 'ubiquity gtk_ui'
9+Exec=sudo --preserve-env=DBUS_SESSION_BUS_ADDRESS sh -c 'ubiquity gtk_ui'
10 Icon=ubiquity
11 Terminal=false
12 Categories=GTK;System;Settings;
13
14=== modified file 'debian/changelog'
15--- debian/changelog 2018-04-23 16:43:06 +0000
16+++ debian/changelog 2018-04-23 17:21:26 +0000
17@@ -3,6 +3,11 @@
18 [ Didier Roche ]
19 * Record OEM installation mode in telemetry data. (LP: #1765693)
20
21+ [ Iain Lane ]
22+ * misc.py: Fall back to SUDO_UID if PKEXEC_UID is not set.
23+ * ubiquity.desktop.in, misc.py: Pass through the ubuntu user's D-Bus session
24+ bus, if set, so that we can communicate with it.
25+
26 -- Iain Lane <iain.lane@canonical.com> Mon, 23 Apr 2018 17:42:27 +0100
27
28 ubiquity (18.04.10) bionic; urgency=medium
29
30=== modified file 'ubiquity/gsettings.py'
31--- ubiquity/gsettings.py 2017-07-18 15:21:41 +0000
32+++ ubiquity/gsettings.py 2018-04-23 17:21:26 +0000
33@@ -48,7 +48,8 @@
34 user = os.getenv("SUDO_USER", os.getenv("USER", "root"))
35
36 subp = subprocess.Popen(
37- ['sudo', '-H', '-u', user, 'gsettings', 'get', schema, key],
38+ ['sudo', '--preserve-env=DBUS_SESSION_BUS_ADDRESS', '-H', '-u', user,
39+ 'gsettings', 'get', schema, key],
40 stdout=subprocess.PIPE, stderr=subprocess.PIPE,
41 preexec_fn=misc.drop_all_privileges, universal_newlines=True)
42 value = subp.communicate()[0].rstrip('\n')
43@@ -103,8 +104,9 @@
44 value = "true" if value else "false"
45
46 subprocess.call(
47- ['sudo', '-H', '-u', user, 'gsettings', 'set', schema, key,
48- str(value)], preexec_fn=misc.drop_all_privileges)
49+ ['sudo', '--preserve-env=DBUS_SESSION_BUS_ADDRESS', '-H', '-u', user,
50+ 'gsettings', 'set', schema, key, str(value)],
51+ preexec_fn=misc.drop_all_privileges)
52
53
54 def set_list(schema, key, values, user=None):
55@@ -123,5 +125,6 @@
56 user = os.getenv("SUDO_USER", os.getenv("USER", "root"))
57
58 subprocess.call(
59- ['sudo', '-H', '-u', user, 'gsettings', 'reset', schema, key],
60+ ['sudo', '--preserve-env=DBUS_SESSION_BUS_ADDRESS', '-H', '-u', user,
61+ 'gsettings', 'reset', schema, key],
62 preexec_fn=misc.drop_all_privileges)
63
64=== modified file 'ubiquity/misc.py'
65--- ubiquity/misc.py 2017-07-18 15:21:41 +0000
66+++ ubiquity/misc.py 2018-04-23 17:21:26 +0000
67@@ -50,7 +50,7 @@
68 def drop_all_privileges():
69 # gconf needs both the UID and effective UID set.
70 global _dropped_privileges
71- uid = os.environ.get('PKEXEC_UID')
72+ uid = os.environ.get('PKEXEC_UID', os.environ.get('SUDO_UID'))
73 gid = None
74 if uid is not None:
75 uid = int(uid)
76@@ -71,7 +71,7 @@
77 global _dropped_privileges
78 assert _dropped_privileges is not None
79 if _dropped_privileges == 0:
80- uid = os.environ.get('PKEXEC_UID')
81+ uid = os.environ.get('PKEXEC_UID', os.environ.get('SUDO_UID'))
82 gid = None
83 if uid is not None:
84 uid = int(uid)
85@@ -100,7 +100,7 @@
86 # At the moment, we only know how to handle this when effective
87 # privileges were already dropped.
88 assert _dropped_privileges is not None and _dropped_privileges > 0
89- uid = os.environ.get('PKEXEC_UID')
90+ uid = os.environ.get('PKEXEC_UID', os.environ.get('SUDO_UID'))
91 gid = None
92 if uid is not None:
93 uid = int(uid)

Subscribers

People subscribed via source and target branches

to status/vote changes: