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
=== modified file 'DistUpgrade/DistUpgradeQuirks.py'
--- DistUpgrade/DistUpgradeQuirks.py 2016-03-30 03:39:16 +0000
+++ DistUpgrade/DistUpgradeQuirks.py 2016-04-05 10:09:56 +0000
@@ -60,6 +60,8 @@
60 self.arch = get_arch()60 self.arch = get_arch()
61 self.plugin_manager = PluginManager(self.controller, ["./plugins"])61 self.plugin_manager = PluginManager(self.controller, ["./plugins"])
62 self._poke = None62 self._poke = None
63 self._uid = os.environ['SUDO_UID']
64 self._user_env = {}
6365
64 # the quirk function have the name:66 # the quirk function have the name:
65 # $Name (e.g. PostUpgrade)67 # $Name (e.g. PostUpgrade)
@@ -135,6 +137,7 @@
135 self._killKBluetooth()137 self._killKBluetooth()
136 self._killScreensaver()138 self._killScreensaver()
137 self._pokeScreensaver()139 self._pokeScreensaver()
140 self._inhibitIdle()
138 self._stopDocvertConverter()141 self._stopDocvertConverter()
139 self._fixupDbusDaemonLaunchHelperPerms()142 self._fixupDbusDaemonLaunchHelperPerms()
140143
@@ -405,6 +408,42 @@
405 except:408 except:
406 logging.exception("failed to setup screensaver poke")409 logging.exception("failed to setup screensaver poke")
407410
411 def _getUserEnv(self):
412 try:
413 pid = subprocess.check_output(["pgrep","-u",self._uid,
414 "gnome-session"])
415 pid = pid.decode().split('\n')[0]
416 with open('/proc/'+pid+'/environ','r') as f:
417 data = f.read().split('\x00')
418 for line in data:
419 if len(line):
420 env = line.split('=', 1)
421 self._user_env[env[0]] = env[1]
422 except:
423 logging.exception("failed to read user env")
424
425 def _inhibitIdle(self):
426 if os.path.exists("/usr/bin/gnome-session-inhibit"):
427 self._getUserEnv()
428 #seteuid so dbus user session can be accessed
429 os.seteuid(int(self._uid))
430
431 logging.debug("inhibit gnome-session idle")
432 try:
433 idle = subprocess.Popen(["gnome-session-inhibit","--inhibit",
434 "idle", "--inhibit-only"],
435 env=self._user_env)
436 # leave the inhibitor in place on Ubuntu GNOME, since the
437 # lock screen will be broken after upgrade (LP :#1565178)
438 xdg_desktop = self._user_env["XDG_CURRENT_DESKTOP"].split(':')
439 for desktop in xdg_desktop:
440 if "GNOME" not in desktop:
441 atexit.register(idle.terminate);
442 except:
443 logging.exception("failed to inhibit gnome-session idle")
444 os.seteuid(os.getuid())
445
446
408 def _stopPokeScreensaver(self):447 def _stopPokeScreensaver(self):
409 res = False448 res = False
410 if self._poke is not None:449 if self._poke is not None:
411450
=== modified file 'debian/changelog'
--- debian/changelog 2016-03-30 03:39:16 +0000
+++ debian/changelog 2016-04-05 10:09:56 +0000
@@ -1,5 +1,6 @@
1ubuntu-release-upgrader (1:16.04.9) UNRELEASED; urgency=medium1ubuntu-release-upgrader (1:16.04.9) UNRELEASED; urgency=medium
22
3 [ Mathieu Trudel-Lapierre ]
3 * DistUpgrade/DistUpgradeController.py: fix typo in variable name for4 * DistUpgrade/DistUpgradeController.py: fix typo in variable name for
4 RELEASE_UPGRADER_ALLOW_THIRD_PARTY; this will help running with third-5 RELEASE_UPGRADER_ALLOW_THIRD_PARTY; this will help running with third-
5 party mirrors in sources via just the environment variable for one-shot6 party mirrors in sources via just the environment variable for one-shot
@@ -10,7 +11,13 @@
10 since the upgrade might try to reload dbus a few times before the postinst11 since the upgrade might try to reload dbus a few times before the postinst
11 actually runs.12 actually runs.
1213
13 -- Mathieu Trudel-Lapierre <mathieu-tl@ubuntu.com> Tue, 29 Mar 2016 23:18:01 -040014 [ Tim Lunn ]
15 * DistUpgradeQuirks.py: add a quirk to add a gnome-session idle inhibitor
16 this will fix the screensaver activating on Ubuntu GNOME (LP: #1565177)
17 Leave this inhibitor in place on GNOME desktop to workaround broken
18 lock screen after upgrade (LP: #1565178)
19
20 -- Tim Lunn <tim@feathertop.org> Sat, 02 Apr 2016 14:28:20 +1100
1421
15ubuntu-release-upgrader (1:16.04.8) xenial; urgency=medium22ubuntu-release-upgrader (1:16.04.8) xenial; urgency=medium
1623

Subscribers

People subscribed via source and target branches