Package: pm-utils
Version: 1.4.1-8
Severity: important
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu oneiric ubuntu-patch

It was discovered by an Ubuntu bug reporter that the exist status of log
is used in when running a hook so that suspend is never inhibited as log
always returns 0.  As a test case create /etc/pm/sleep.d/05_avoid_sleep
with the following contents (taken from the Ubuntu bug):

#!/bin/sh

# Avoid suspend
#
# Copyright: Copyright (c) 2010 Paulo J. S. Silva
# License:   GPL-2
#

case "${1}" in
        suspend|hibernate)
                exit 1
                ;;
        resume|thaw)
                exit 0
                ;;
esac

Then execute sudo pm-suspend and observe your system suspending.  With the
included patch the exit status of the hook is used and suspend is inhibited.
This was originally reported in
https://bugs.launchpad.net/ubuntu/+source/pm-utils/+bug/665651 and upstream at
http://bugs.freedesktop.org/show_bug.cgi?id=32210.

  * Add 26-inhibit-on-right-status.patch: Do not use the exit status of log
    rather the exit status of the hook thereby allowing inhibit to work.
    Thanks to Launchpad user Lekensteyn for the patch. (LP: #665651)


Thanks for considering the patch.


-- System Information:
Debian Release: squeeze/sid
  APT prefers natty-updates
  APT policy: (500, 'natty-updates'), (500, 'natty-security'), (500, 'natty')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.38-8-generic (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
diff -Nru pm-utils-1.4.1/debian/patches/26-inhibit-on-right-status.patch pm-utils-1.4.1/debian/patches/26-inhibit-on-right-status.patch
--- pm-utils-1.4.1/debian/patches/26-inhibit-on-right-status.patch	1969-12-31 16:00:00.000000000 -0800
+++ pm-utils-1.4.1/debian/patches/26-inhibit-on-right-status.patch	2011-07-08 15:02:05.000000000 -0700
@@ -0,0 +1,23 @@
+Origin: https://launchpad.net/bugs/665651
+Description: Do not use the exit status of log rather the exit status of the hook.
+Bug: https://bugs.freedesktop.org/show_bug.cgi?id=32210
+Bug-Ubuntu: https://launchpad.net/bugs/665651
+
+
+Index: pm-utils-1.4.1/pm/pm-functions.in
+===================================================================
+--- pm-utils-1.4.1.orig/pm/pm-functions.in	2011-07-08 14:55:15.000000000 -0700
++++ pm-utils-1.4.1/pm/pm-functions.in	2011-07-08 14:55:57.000000000 -0700
+@@ -197,9 +197,11 @@
+ 	# rest of args passed to hook unchanged.
+ 	log "Running hook $*:"
+ 	hook_ok "$1" && "$@"
++	# log() changes the return value, so save it for later
++	local status=$?
+ 	log ""
+ 	log -n "$*: " 
+-	hook_exit_status $? && LAST_HOOK="${1##*/}" || inhibit
++	hook_exit_status $status && LAST_HOOK="${1##*/}" || inhibit
+ }
+ 
+ if profiling; then
diff -Nru pm-utils-1.4.1/debian/patches/series pm-utils-1.4.1/debian/patches/series
--- pm-utils-1.4.1/debian/patches/series	2011-04-12 04:25:09.000000000 -0700
+++ pm-utils-1.4.1/debian/patches/series	2011-07-08 14:54:43.000000000 -0700
@@ -8,3 +8,4 @@
 25-pmu.patch
 80-service.patch
 90-nm-proper-wakeup.patch
+26-inhibit-on-right-status.patch

Reply via email to