Merge ~osomon/ubiquity:impish-live-session-release-notes-1945658 into ubiquity:master

Proposed by Olivier Tilloy
Status: Merged
Merged at revision: 40e86a074c82caad2196f197698294ef1c7ebb1e
Proposed branch: ~osomon/ubiquity:impish-live-session-release-notes-1945658
Merge into: ubiquity:master
Diff against target: 74 lines (+24/-7)
3 files modified
data/ubiquity.desktop.in (+1/-1)
ubiquity/gsettings.py (+4/-6)
ubiquity/misc.py (+19/-0)
Reviewer Review Type Date Requested Status
Jean-Baptiste Lallement Approve
Iain Lane Approve
Review via email: mp+409584@code.launchpad.net

Commit message

Also preserve XDG_DATA_DIRS when running ubiquity in a live session.

This fixes opening the release notes hyperlink (and all other hyperlinks)
with the correct application (firefox vs gedit) (LP: #1945658).

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

👍

review: Approve
Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

Maybe move the sudo wrapper to misc.py. WDYT?

Revision history for this message
Olivier Tilloy (osomon) wrote :

Good suggestion. Done.

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

Approved! thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/data/ubiquity.desktop.in b/data/ubiquity.desktop.in
index 691f802..3cb3434 100644
--- a/data/ubiquity.desktop.in
+++ b/data/ubiquity.desktop.in
@@ -6,7 +6,7 @@ _Name=Install RELEASE
6_Comment=Install this system permanently to your hard disk6_Comment=Install this system permanently to your hard disk
7_Keywords=ubiquity;7_Keywords=ubiquity;
8#use sh because pkexec is broken under xfce/lxce http://pad.lv/11935268#use sh because pkexec is broken under xfce/lxce http://pad.lv/1193526
9Exec=sudo --preserve-env=DBUS_SESSION_BUS_ADDRESS,XDG_RUNTIME_DIR sh -c 'ubiquity gtk_ui'9Exec=sudo --preserve-env=DBUS_SESSION_BUS_ADDRESS,XDG_DATA_DIRS,XDG_RUNTIME_DIR sh -c 'ubiquity gtk_ui'
10Icon=ubiquity10Icon=ubiquity
11Terminal=false11Terminal=false
12Categories=GTK;System;Settings;12Categories=GTK;System;Settings;
diff --git a/ubiquity/gsettings.py b/ubiquity/gsettings.py
index 7b1cced..d31d044 100644
--- a/ubiquity/gsettings.py
+++ b/ubiquity/gsettings.py
@@ -48,8 +48,7 @@ def get(schema, key, user=None):
48 user = os.getenv("SUDO_USER", os.getenv("USER", "root"))48 user = os.getenv("SUDO_USER", os.getenv("USER", "root"))
4949
50 subp = subprocess.Popen(50 subp = subprocess.Popen(
51 ['sudo', '--preserve-env=DBUS_SESSION_BUS_ADDRESS,XDG_RUNTIME_DIR',51 misc.sudo_wrapper(user) + ['gsettings', 'get', schema, key],
52 '-H', '-u', user, 'gsettings', 'get', schema, key],
53 stdout=subprocess.PIPE, stderr=subprocess.PIPE,52 stdout=subprocess.PIPE, stderr=subprocess.PIPE,
54 preexec_fn=misc.drop_all_privileges, universal_newlines=True)53 preexec_fn=misc.drop_all_privileges, universal_newlines=True)
55 value = subp.communicate()[0].rstrip('\n')54 value = subp.communicate()[0].rstrip('\n')
@@ -106,8 +105,8 @@ def set(schema, key, value, user=None):
106 value = "true" if value else "false"105 value = "true" if value else "false"
107106
108 subprocess.call(107 subprocess.call(
109 ['sudo', '--preserve-env=DBUS_SESSION_BUS_ADDRESS,XDG_RUNTIME_DIR',108 misc.sudo_wrapper(user) +
110 '-H', '-u', user, 'gsettings', 'set', schema, key, str(value)],109 ['gsettings', 'set', schema, key, str(value)],
111 preexec_fn=misc.drop_all_privileges)110 preexec_fn=misc.drop_all_privileges)
112111
113112
@@ -127,6 +126,5 @@ def unset(schema, key, user=None):
127 user = os.getenv("SUDO_USER", os.getenv("USER", "root"))126 user = os.getenv("SUDO_USER", os.getenv("USER", "root"))
128127
129 subprocess.call(128 subprocess.call(
130 ['sudo', '--preserve-env=DBUS_SESSION_BUS_ADDRESS,XDG_RUNTIME_DIR',129 misc.sudo_wrapper(user) + ['gsettings', 'reset', schema, key],
131 '-H', '-u', user, 'gsettings', 'reset', schema, key],
132 preexec_fn=misc.drop_all_privileges)130 preexec_fn=misc.drop_all_privileges)
diff --git a/ubiquity/misc.py b/ubiquity/misc.py
index bc88d5d..7ff6629 100644
--- a/ubiquity/misc.py
+++ b/ubiquity/misc.py
@@ -1086,4 +1086,23 @@ class SystemdUnitWatcher:
1086 raise1086 raise
10871087
10881088
1089def sudo_wrapper(user):
1090 """Return a list of args suitable for use with the subprocess module,
1091 to invoke a command as a given user, while preserving a set of useful
1092 environment variables. Append the command and list of args to be invoked
1093 to the return value of this helper.
1094 """
1095 preserve_env = [
1096 'DBUS_SESSION_BUS_ADDRESS',
1097 'XDG_DATA_DIRS',
1098 'XDG_RUNTIME_DIR',
1099 ]
1100 return [
1101 'sudo',
1102 '--preserve-env={}'.format(','.join(preserve_env)),
1103 '-H',
1104 '-u', user
1105 ]
1106
1107
1089# vim:ai:et:sts=4:tw=80:sw=4:1108# vim:ai:et:sts=4:tw=80:sw=4:

Subscribers

People subscribed via source and target branches