Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 726092 - sys-power/acpid-2.0.32-r1 doesn't power off when sys-apps/openrc[sysv-utils] installed
Summary: sys-power/acpid-2.0.32-r1 doesn't power off when sys-apps/openrc[sysv-utils] ...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Andriy Utkin (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on: 755422
Blocks:
  Show dependency tree
 
Reported: 2020-05-29 13:43 UTC by Jaak Ristioja
Modified: 2021-04-26 09:28 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jaak Ristioja 2020-05-29 13:43:19 UTC
From /etc/acpi/actions/powerbtn.sh (note also typo in "managment"):

# No power managment system appears to be running.  Just initiate a plain 
# shutdown.
CURRENT_INIT=`ps -p 1 -o comm=`
if [ "$CURRENT_INIT" = "openrc-init" ]
then
    /sbin/openrc-shutdown -p
else
    /sbin/shutdown -h now "Power button pressed"
fi

If sys-apps/openrc is installed with USE="sysv-utils" (whereby /sbin/init is a symlink to "openrc-init") and the kernel is booted without an explicit init=/sbin/openrc-init option, then `ps -p 1 -o comm=` outputs "init" instead of "openrc-init".

This in turn causes the else-branch in powerbtn.sh to be taken and /sbin/shutdown to be executed. With sys-apps/openrc[sysv-utils] the file /sbin/shutdown is a symlink to the /lib/rc/bin/shutdown script from openrc, and the -h command line option causes the latter to only halt the system and not power it off.

This results in machines hanging and not powering off.
Comment 1 Jaak Ristioja 2020-05-29 21:50:13 UTC
And it appears that the "/sbin/openrc-shutdown -p" command line is also missing the last "now" argument.
Comment 2 Jonathan Davies 2020-10-26 11:47:48 UTC
Pushed a fix upstream to https://sourceforge.net/p/acpid2/code/merge-requests/3/
Comment 3 Andriy Utkin (RETIRED) gentoo-dev 2020-11-09 13:20:27 UTC
Thanks for raising this, Jaak.

So I see two distinct issues being reported there:

* With the shipped powerbtn.sh and openrc[sysv-utils], pressing the power button does not power off the machine.

* When you make the script do the openrc-specific handling, the invocation `/sbin/openrc-shutdown -p` is invalid because it misses the mandatory "when" argument.

The second one has been patched upstream by Jonathan Davies (huge thanks!). There's no release from the upstream yet, but that's not a blocker as we can apply a patch at Gentoo level.

The first one is not resolved yet.

I am suspicious that the issue is not that acpid fails to recognize openrc, because openrc mimics System V init system in this case, so System V init system interfaces documentation define how things must work.

According to shutdown(8) man page from sys-apps/sysvinit, `/sbin/shutdown -h ...` means "Equivalent to -P, unless -H is specified". And the option `-P` means "Action is to turn off the power". So acpid invokes a command which means powering off. So if openrc-provided shutdown tool doesn't power off the machine, it's the fault of openrc-provided shutdown tool.

So I think this is an interface adherence issue for openrc.

I guess the issue is in this file: https://github.com/OpenRC/openrc/blob/master/scripts/shutdown.in

Could you confirm the following, Jaak?

* Commands "/sbin/shutdown -P", "/lib/rc/bin/shutdown -P" do turn off the power.
* /lib/rc/bin/shutdown file installed on your system resembles the shutdown.in script I linked above.
* Manually editing "h) shutdown_arg=--halt ;;" to "h) shutdown_arg=--poweroff ;;" makes power button press to power off your machine.

Once my hypothesis is confirmed, we will bring it (with a trivial patch I guess) to openrc folks.
Comment 4 Jaak Ristioja 2020-11-10 07:20:25 UTC
(In reply to Andrey Utkin from comment #3)
> Could you confirm the following, Jaak?
> 
> * Commands "/sbin/shutdown -P", "/lib/rc/bin/shutdown -P" do turn off the
> power.

Both "/sbin/shutdown -P" and "/lib/rc/bin/shutdown -P" do NOT turn off the power, but error with the output

  /sbin/openrc-shutdown --poweroff
  * openrc-shutdown: No shutdown time specified

followed by the usage information of openrc-shutdown. Note that /sbin/shutdown is symlinked to /lib/rc/bin/shutdown (probably by openrc[sysv-utils]).

> * /lib/rc/bin/shutdown file installed on your system resembles the
> shutdown.in script I linked above.

I confirm this. The /lib/rc/bin/shutdown file seems to be an the shutdown.in script with @SBINDIR@ expanded.

> * Manually editing "h) shutdown_arg=--halt ;;" to "h)
> shutdown_arg=--poweroff ;;" makes power button press to power off your
> machine.

No it doesn't. Instead, nothing happens, except this in the logs:

  Nov 10 09:18:44 my_vm /etc/init.d/acpid[1664]: openrc-shutdown: No shutdown time specified
  Nov 10 09:18:45 my_vm /etc/init.d/acpid[1674]: openrc-shutdown: No shutdown time specified
Comment 5 Andriy Utkin (RETIRED) gentoo-dev 2020-11-10 12:20:06 UTC
Oh.
I forgot about the "when" argument.

Could you confirm the following?

* Commands "/sbin/shutdown -P now", "/lib/rc/bin/shutdown -P now" do turn off the power.
* Power button press powers off your machine once you do both of the following.
** You patch the /etc/acpi/actions/powerbtn.sh as needed to insert the "now" arg.
** Manually edit "h) shutdown_arg=--halt ;;" to "h) shutdown_arg=--poweroff ;;"
Comment 6 Jaak Ristioja 2020-11-10 15:19:51 UTC
(In reply to Andrey Utkin from comment #5)
> Could you confirm the following?
> 
> * Commands "/sbin/shutdown -P now", "/lib/rc/bin/shutdown -P now" do turn
> off the power.

I can confirm this.

> * Power button press powers off your machine once you do both of the
> following.
> ** You patch the /etc/acpi/actions/powerbtn.sh as needed to insert the "now"
> arg.
> ** Manually edit "h) shutdown_arg=--halt ;;" to "h) shutdown_arg=--poweroff
> ;;"

I can confirm this as well.
Comment 7 Andriy Utkin (RETIRED) gentoo-dev 2020-11-19 06:37:16 UTC
Reported for openrc https://bugs.gentoo.org/755422 .
Comment 8 Andriy Utkin (RETIRED) gentoo-dev 2020-12-01 14:45:00 UTC
openrc has got a commit by williamh addressing this issue: https://github.com/OpenRC/openrc/commit/38aaba28ee86602e29d8a31f155dfa72f5481e68

It doesn't seem that openrc does releases often nowadays, though. openrc-9999 should get you the fix, but I won't recommend doing this :) But you could apply this patch to your stable openrc locally :)
Comment 9 Andriy Utkin (RETIRED) gentoo-dev 2020-12-29 13:02:29 UTC
Still awaiting OpenRC release.
I've got some words from WilliamH on IRC that he does intend to make a release soon.
Comment 10 Andriy Utkin (RETIRED) gentoo-dev 2021-04-26 09:28:27 UTC
OpenRC 0.43 is out with the fix.

Jaak, with OpenRC 0.43 or later, you should be able to enjoy stuff working without any patches to any of the relevant packages.

Please let us know here if the issue persists.