Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 360673 - sys-power/pm-utils-1.4.1*always succeeds, ignores hook exit codes
Summary: sys-power/pm-utils-1.4.1*always succeeds, ignores hook exit codes
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal major (vote)
Assignee: Freedesktop bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-27 00:08 UTC by Gerard Neil
Modified: 2014-06-04 19:52 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch (patch,537 bytes, patch)
2011-03-27 00:10 UTC, Gerard Neil
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gerard Neil 2011-03-27 00:08:54 UTC
A wee klanger in /usr/lib64/pm-utils/pm-functions cause pm-utils to ignore the exit codes of all hook functions. This means that suspend, hibernate etc. always proceed ("succeed"), event when a hook has indicated that the process should abort.

Reproducible: Always

Steps to Reproduce:
# cd /etc/pm/sleep.d
# cat > 00forcefail
$!/bin/bash 
echo === $0: FAILING ====
exit 1
^D
# chmod u+x 00forcefail 
# rm /var/log/pm-suspend.log 
rm: remove regular file `/var/log/pm-suspend.log'? y
# pm-suspend

Actual Results:  
  ... suspend proceeds ....
  (now wake the system)
# cat /var/log/pm-suspend.log 
Initial commandline parameters: 
Blacklisting 01grub.
Sun Mar 27 10:23:57 EST 2011: Running hooks for suspend.
Running hook /etc/pm/sleep.d/00forcefail suspend suspend:
=== /etc/pm/sleep.d/00forcefail: FAILING ====

/etc/pm/sleep.d/00forcefail suspend suspend: success.
                                             ^^^^^^^^
 ... log continues


Expected Results:  
The suspend should not proceed, /var/log/pm-suspend.log should indicate it was aborted.

According to the documentation (see /usr/share/doc/pm-utils-1.4.1-r1/HOWTO.hooks.bz2) the failure of any hook function in /etc/pm/sleep.d should prevent the system suspending or hibernating.

I have a pm-utils hook which prevents the system hibernating with any ntfs-3g partitions mounted. I dual boot this system with Windows 7 and share an NTFS partition - for me this is supposed to prevent data loss in the case where I hibernate linux and later accidentally reboot into windows.

Patch attached (you'll chuckle).
Comment 1 Gerard Neil 2011-03-27 00:10:13 UTC
Created attachment 267333 [details, diff]
Patch
Comment 2 Thomas Kahle (RETIRED) gentoo-dev 2011-04-19 14:50:27 UTC
That's important! Please apply the patch freedesktop.
Comment 3 Gilles Dartiguelongue (RETIRED) gentoo-dev 2011-04-19 15:57:56 UTC
someone reported it upstream yet ?
Comment 4 Thomas Kahle (RETIRED) gentoo-dev 2011-04-20 05:16:42 UTC
Appearently not.  The bug is still present in their git master at git://anongit.freedesktop.org/git/pm-utils
Comment 5 Gerard Neil 2011-04-21 00:06:46 UTC
Hmmm... on second thoughts, preventing a suspend or hibernate from succeeding is a pretty nasty thing to do. At least without checking on the power situation... some time after I fixed this bug, my laptop battery ran down, my hook prevented hibernation, and so the machine simply ran out of power. So much for my data-loss-preventing hook.

Perhaps this is why the bug hasn't been noticed/fixed earlier; the hook fail capability is in itself a bit questionable and rarely used. In my case (prevent hibernating with mounted ntfs-3g partition), forcibly unmounting in the hook is a better idea than allowing a power fail to occur.

It seems to me pm-utils would be better off if it supported a "forced" hibernation/suspend (seeing as the client of pm_utils presumably knows whether the hibernation is due to a critical power situation). Also, if a hook can fail, a means of passing the reason it failed back up to the client is a good idea.

In any case a note about the potential power loss situation in the HOWTO.hooks document wouldn't go astray.
Comment 6 Samuli Suominen (RETIRED) gentoo-dev 2014-06-04 19:47:03 UTC
Looks like this is,

http://bugs.freedesktop.org/show_bug.cgi?id=32210

And it's applied in Debian as 26-inhibit-on-right-status.patch inside http://ftp.de.debian.org/debian/pool/main/p/pm-utils/pm-utils_1.4.1-14.debian.tar.xz
Comment 7 Samuli Suominen (RETIRED) gentoo-dev 2014-06-04 19:52:11 UTC
Fix applied as pm-utils-1.4.1-r3