Merge lp:~darkxst/ubuntu-release-upgrader/gnome-session-inhibit into lp:ubuntu-release-upgrader

Proposed by Tim Lunn
Status: Merged
Merged at revision: 2976
Proposed branch: lp:~darkxst/ubuntu-release-upgrader/gnome-session-inhibit
Merge into: lp:ubuntu-release-upgrader
Diff against target: 88 lines (+47/-1)
2 files modified
DistUpgrade/DistUpgradeQuirks.py (+39/-0)
debian/changelog (+8/-1)
To merge this branch: bzr merge lp:~darkxst/ubuntu-release-upgrader/gnome-session-inhibit
Reviewer Review Type Date Requested Status
Mathieu Trudel-Lapierre Needs Fixing
Review via email: mp+290792@code.launchpad.net

Description of the change

This branch should fix the disabling of the screensaver on Ubuntu GNOME (and any other gnome-session based DE). Although I couldnt test it properly, not sure how the quirks get pulled in. Update-manager doesnt use the locally installed quirks?

To post a comment you must log in.
Revision history for this message
Brian Murray (brian-murray) wrote :

The release upgrade process downloads a tarball of the release-upgrader from the archive for the target release e.g. http://archive.ubuntu.com/ubuntu/dists/xenial/main/dist-upgrader-all/current/xeinal.tar.gz then extracts it to a directory in /tmp/ and then runs xenial in that temporary directory. You could test it by either starting an upgrade, choosing to quit, and then make changes in /tmp/$tmpdir/DistUpgradeQuirks.py or build the package and manually extract dist-upgrader_$vernum.tar.gz.

Revision history for this message
Tim Lunn (darkxst) :
Revision history for this message
Tim Lunn (darkxst) wrote :

ok, managed to test it.

It didnt work though since the quirks are run under sudo, there is no access to the user dbus session.

Revision history for this message
Tim Lunn (darkxst) wrote :

This is fixed now, it kind of feels like jumping through hoops, but I am not sure there is a better way. This is not possible with logind inhibitors and we need the gnome-session-inhibit binary launched with the users (not root) environment and uid.

Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Since Brian uploaded a change with a sleep inhibitor using logind, I'm thinking this might be better handled by inhibiting "idle" as well in logind? This would fix the screensaver coming on for Kubuntu as well as the gnome-session-based flavors.

review: Needs Fixing
Revision history for this message
Tim Lunn (darkxst) wrote :

That was my patch and I would have included an inhibitor on idle if it worked like that.

Atleast on GNOME (although its likely the same on KDE), the logind "idle" inhibitors do not inhibit the idle monitors within the compositor. logind only deals with system level events/actions like shutdown/sleep, power buttons and lid switch, it has no concept of what his happening within the users session. Its the compositor that is monitoring user input (keyboard/mouse etc) and deciding when to activate the screensaver and screenblanking.

So we still need to install an "idle" inhibitor into the users session.

Revision history for this message
Brian Murray (brian-murray) wrote :

I'm testing this a bit and will upload / merge it today.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'DistUpgrade/DistUpgradeQuirks.py'
2--- DistUpgrade/DistUpgradeQuirks.py 2016-03-30 03:39:16 +0000
3+++ DistUpgrade/DistUpgradeQuirks.py 2016-04-05 10:09:56 +0000
4@@ -60,6 +60,8 @@
5 self.arch = get_arch()
6 self.plugin_manager = PluginManager(self.controller, ["./plugins"])
7 self._poke = None
8+ self._uid = os.environ['SUDO_UID']
9+ self._user_env = {}
10
11 # the quirk function have the name:
12 # $Name (e.g. PostUpgrade)
13@@ -135,6 +137,7 @@
14 self._killKBluetooth()
15 self._killScreensaver()
16 self._pokeScreensaver()
17+ self._inhibitIdle()
18 self._stopDocvertConverter()
19 self._fixupDbusDaemonLaunchHelperPerms()
20
21@@ -405,6 +408,42 @@
22 except:
23 logging.exception("failed to setup screensaver poke")
24
25+ def _getUserEnv(self):
26+ try:
27+ pid = subprocess.check_output(["pgrep","-u",self._uid,
28+ "gnome-session"])
29+ pid = pid.decode().split('\n')[0]
30+ with open('/proc/'+pid+'/environ','r') as f:
31+ data = f.read().split('\x00')
32+ for line in data:
33+ if len(line):
34+ env = line.split('=', 1)
35+ self._user_env[env[0]] = env[1]
36+ except:
37+ logging.exception("failed to read user env")
38+
39+ def _inhibitIdle(self):
40+ if os.path.exists("/usr/bin/gnome-session-inhibit"):
41+ self._getUserEnv()
42+ #seteuid so dbus user session can be accessed
43+ os.seteuid(int(self._uid))
44+
45+ logging.debug("inhibit gnome-session idle")
46+ try:
47+ idle = subprocess.Popen(["gnome-session-inhibit","--inhibit",
48+ "idle", "--inhibit-only"],
49+ env=self._user_env)
50+ # leave the inhibitor in place on Ubuntu GNOME, since the
51+ # lock screen will be broken after upgrade (LP :#1565178)
52+ xdg_desktop = self._user_env["XDG_CURRENT_DESKTOP"].split(':')
53+ for desktop in xdg_desktop:
54+ if "GNOME" not in desktop:
55+ atexit.register(idle.terminate);
56+ except:
57+ logging.exception("failed to inhibit gnome-session idle")
58+ os.seteuid(os.getuid())
59+
60+
61 def _stopPokeScreensaver(self):
62 res = False
63 if self._poke is not None:
64
65=== modified file 'debian/changelog'
66--- debian/changelog 2016-03-30 03:39:16 +0000
67+++ debian/changelog 2016-04-05 10:09:56 +0000
68@@ -1,5 +1,6 @@
69 ubuntu-release-upgrader (1:16.04.9) UNRELEASED; urgency=medium
70
71+ [ Mathieu Trudel-Lapierre ]
72 * DistUpgrade/DistUpgradeController.py: fix typo in variable name for
73 RELEASE_UPGRADER_ALLOW_THIRD_PARTY; this will help running with third-
74 party mirrors in sources via just the environment variable for one-shot
75@@ -10,7 +11,13 @@
76 since the upgrade might try to reload dbus a few times before the postinst
77 actually runs.
78
79- -- Mathieu Trudel-Lapierre <mathieu-tl@ubuntu.com> Tue, 29 Mar 2016 23:18:01 -0400
80+ [ Tim Lunn ]
81+ * DistUpgradeQuirks.py: add a quirk to add a gnome-session idle inhibitor
82+ this will fix the screensaver activating on Ubuntu GNOME (LP: #1565177)
83+ Leave this inhibitor in place on GNOME desktop to workaround broken
84+ lock screen after upgrade (LP: #1565178)
85+
86+ -- Tim Lunn <tim@feathertop.org> Sat, 02 Apr 2016 14:28:20 +1100
87
88 ubuntu-release-upgrader (1:16.04.8) xenial; urgency=medium
89

Subscribers

People subscribed via source and target branches