Public bug reported:

Binary package hint: pm-utils

1) ubuntu version

Description:    Ubuntu 10.10
Release:        10.10

2) package version:

pm-utils:
  Instalado: 1.4.1-3
  Candidato: 1.4.1-3
  Tabela de versão:
 *** 1.4.1-3 0
        500 http://br.archive.ubuntu.com/ubuntu/ maverick/main amd64 Packages
        100 /var/lib/dpkg/status

3) If a script in /etc/pm/sleep.d returns a non-zero value upon requests
to suspend or hibernate, the suspend/hibernate process should be
aborted.

4) The system ignores the return value and supends/hibernates anyhow.

In order to reproduce the bug just drop the 00_avoid_suspend script in 
/etc/pm/sleep.d, make it executable and try to sleep.
The system should refuse to sleep but, at least here, it doesn't.

The problems seems to be in the _run_hook() function defined in file
/usr/lib/pm-utils/pm-fuctions. This is the function that calls the
scripts in the /etc/pm/sleep.d directory. After calling the script,
_run_hook calls the function log twice before checking the script return
value. It seems that the return value is being set back to 0 in these
calls to log (but I am no bash expert).

To walk around I just added a line to store the script return value in a
temporary variable and used that variable after the log calls to check
the original result. Now it seems to work. My current _run_hook function
looks like this:

_run_hook() {
        # $1 = hook to run
        # rest of args passed to hook unchanged.
        log "Running hook $*:"
        hook_ok "$1" && "$@"
        status=$?
        log ""
        log -n "$*: " 
        hook_exit_status $status && LAST_HOOK="${1##*/}" || inhibit
}

Since I am no bash expert, I can not assure that this is a proper
solution, but it works here.

** Affects: pm-utils (Ubuntu)
     Importance: Undecided
         Status: New

-- 
pm-utils does not follow requests to inhibit suspend/hibernate from scripts in 
/etc/pm/sleep.d
https://bugs.launchpad.net/bugs/665651
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to