[Pm-utils] [RFC] [patch review] Hook independence and security fixups, part 1

Dan Nicholson dbn.lists at gmail.com
Sat Feb 2 13:57:21 PST 2008

On Feb 2, 2008 7:16 AM, Michael Biebl <mbiebl at gmail.com> wrote:
> 2008/2/2, Victor Lowther <victor.lowther at gmail.com>:
> >
> > Well, the conditional blocks around the current
> > do_(suspend|hibernate|suspend_hybrid) are my stab at making tuxonice and
> > userspace suspend support easy to implement without having to patch the
> > pm-utils core.  Since (in the end), it all comes down to calling one of
> > those three functions anyways, why not make them easy to override with
> > whatever the distro maintainer or end user want?
> >
> I don't think we should overwrite the do_suspend/do_hibernate methods.
> As I outlined in a previous mail, I'd add a
> (suspend,hibernate)_method() function, that either return the value of
> the (SUSPEND,HIBERNATE)_METHOD config variable or otherwise check for
> tuxonice, userspace or kernel support and return a corresponding
> string.
> In pm_action you would then simply call pm_suspend_$method.
> The do_suspend_(tuxonice,userpace,whatever) functions could either be
> defined in functions, or if you prefer to keep them separate in
> functions.d/. config.d doesn't seem to be the right place for this to
> me.

IMO, this is the way to go. *_METHOD in config just controls which
real do_$action function is called:

# ensure var is set to something
: ${SUSPEND_METHOD:=kernel}
    case "$SUSPEND_METHOD" in
        do_suspend_kernel ;;
        do_suspend_tuxonice ;;
        echo "Invalid suspend method '$SUSPEND_METHOD'"
        return 1

More information about the Pm-utils mailing list