Bug 819547 - Power button press always results in shutdown
Power button press always results in shutdown
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: acpid (Show other bugs)
17
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Jaroslav Škarvada
Fedora Extras Quality Assurance
:
: 848424 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-05-07 10:16 EDT by Charles Ghislain
Modified: 2012-10-09 04:55 EDT (History)
8 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-07-26 18:35:48 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
systemd enabled power.sh (773 bytes, text/plain)
2012-06-26 17:34 EDT, Mikko Tiihonen
no flags Details

  None (edit)
Description Charles Ghislain 2012-05-07 10:16:11 EDT
Hi,

I'm using fedora 17 and KDE 4.8.3
I've set the kde power manager to sleep on power button press.
However, pressing the button always results in shutdown.

I see in /etc/acpi/actions/power.sh the use of ck-list-sessions to figure out the user id. Entering that command manually, both as the user running kde or root, do not output anything and always returns 0.

Modifying this file to directly exit prevents the shutdown, but the machine do not get to sleep.
Comment 1 Dan Stahlke 2012-06-03 09:27:35 EDT
I have a similar problem since upgrade from F16 to F17.  In an effort to fix, I changed the KDE power manager to pop up the "prompt logout dialog" instead of going to sleep.  Now when I press the power button, the logout dialog appears for a fraction of a second before the system proceeds with shutdown.

For me, the ck-list-sessions command does produce output.  However, the output produced contains the line "active = FALSE", which causes /etc/acpi/actions/power.sh to disregard me.

In case it is relevant, after upgrade I experienced many error messages followed by kernel panic when I press the shutdown button.  Eventually I found this to be caused by a F16 kernel that was lingering after upgrade.  Removing the F16 kernel fixed those errors, but still the error described in this report remains.
Comment 2 Dan Stahlke 2012-06-04 08:21:22 EDT
A workaround is to comment out everything in /etc/acpi/actions/power.sh.  The side effect, as far as I can guess, is that the power button would not do anything when there is nobody logged into an X session.
Comment 3 Mikko Tiihonen 2012-06-26 17:34:54 EDT
Created attachment 594608 [details]
systemd enabled power.sh

I rewrote the consolekit based script to use systemd commands instead.

Question: should we leave the original consolekit enabled version into that script too in case someone is not using systemd but running consolekit?
- or does Fedora 17 even support running without systemd sessions?
Comment 4 Peter Oliver 2012-07-05 18:03:15 EDT
See also #819559, which claims to fix this.  It fails for me, partly because it looks for "Active: yes" in the output of "systemd-loginctl session-status", but the version in systemd-44-17.fc17.i686 outputs "State: active" instead.
Comment 5 Jaroslav Škarvada 2012-07-09 03:03:22 EDT
(In reply to comment #4)
> See also #819559, which claims to fix this.  It fails for me, partly because
> it looks for "Active: yes" in the output of "systemd-loginctl
> session-status", but the version in systemd-44-17.fc17.i686 outputs "State:
> active" instead.

It seems the output of systemd-loginctl changed, thanks for info.
Comment 6 Fedora Update System 2012-07-09 04:12:34 EDT
acpid-2.0.16-4.fc17 has been submitted as an update for Fedora 17.
https://admin.fedoraproject.org/updates/acpid-2.0.16-4.fc17
Comment 7 Fedora Update System 2012-07-10 12:26:55 EDT
Package acpid-2.0.16-4.fc17:
* should fix your issue,
* was pushed to the Fedora 17 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing acpid-2.0.16-4.fc17'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-10439/acpid-2.0.16-4.fc17
then log in and leave karma (feedback).
Comment 8 Petr Kočandrle 2012-07-16 09:59:00 EDT
I've had the same issue. After update to 2.0.16-4 it's almost OK. The only problem I've noticed is when I run amarok. Pressing the power button results in amarok shutdown and dialog which reads "Shutting down" and the whole enviroment acts strangely until I press Ctrl+Alt+Backspace and login again. I use Gnome 3.
Comment 9 Jaroslav Škarvada 2012-07-16 10:49:49 EDT
(In reply to comment #8)
> I've had the same issue. After update to 2.0.16-4 it's almost OK. The only
> problem I've noticed is when I run amarok. Pressing the power button results
> in amarok shutdown and dialog which reads "Shutting down" and the whole
> enviroment acts strangely until I press Ctrl+Alt+Backspace and login again.
> I use Gnome 3.

This one doesn't seem to be an acpid issue, because I can reproduce this even after:
# yum remove acpid

Probably the KDE stub acts strangely after catching the shutdown event, that should be handled by gnome-settings-daemon (correctly handed over by acpid). Probably amarok or kdelibs issue.
Comment 10 Fedora Update System 2012-07-26 18:35:48 EDT
acpid-2.0.16-4.fc17 has been pushed to the Fedora 17 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 11 Michal Schmidt 2012-08-16 03:36:03 EDT
*** Bug 848424 has been marked as a duplicate of this bug. ***
Comment 12 addammo 2012-08-16 03:52:07 EDT
(In reply to comment #10)
> acpid-2.0.16-4.fc17 has been pushed to the Fedora 17 stable repository.  If
> problems still persist, please make note of it in this bug report.

The problem still persists. I upgraded acpid to version 2.0.16-4.fc17 but after pressing Power button of my keyboard, my PC shuts down immediately and the shutdown confirmation dialog of my Kde desktop (version 4.8.3) never appears. Renaming the file /etc/acpi/actions/power.sh solves this issue.
I don't know weather the command ck-list-sessions written in the file /etc/acpid/actions/power.sh works, in the terminal it outputs nothing.
Comment 13 Jaroslav Škarvada 2012-08-16 04:17:01 EDT
(In reply to comment #12)
> I don't know weather the command ck-list-sessions written in the file
> /etc/acpid/actions/power.sh works, in the terminal it outputs nothing.

Right, but there is 'systemd-loginctl list-sessions' that should take preference.

Please check:
# yum list installed '*acpid*'
# rpm -qV acpid

The code snippet from power.sh that should handle it is pretty simple:
 session_ids=$(systemd-loginctl list-sessions 2>/dev/null | awk '{print $1}')
 for session in ${session_ids} ; do
   session_status=$(systemd-loginctl session-status ${session})
   echo "${session_status}" | grep -e '\(Active: yes\|State: active\)' &> /dev/null &&
     echo "${session_status}" | grep -e '\(gnome-settings-daemon\|kded4\|xfce4-power-manager\)' &> /dev/null && exit 0
 done
 ...
 shutdown -h now

I.e. if "kded4" is detected in you session the shutdown is not executed by acpid, otherwise the "shutdown -h now" is run. Currently I have no idea why it is not working for you, I was unable to reproduce on my systems.
Comment 14 addammo 2012-08-16 05:00:59 EDT
I removed the acpid package and the shutdown confirmation dialog appears.
I upgraded the systemd package and that issue is still present.

About the power.sh script:
I execute in the terminal the command systemd-loginctl list-sessions 2>/dev/null | awk '{print $1}' and the output is

1 ;

I execute in the terminal the command systemd-loginctl session-status 1 | grep -e '\(Active: yes\|State: active\)' and the output is 

Active: yes
        └ 1823 grep --color=auto -e \(Active: yes\|State: active\...

I execute in the terminal the command systemd-loginctl session-status 1 | grep -e '\(gnome-settings-daemon\|kded4\|xfce4-power-manager\)' and the output is

├  802 kded4
└ 1825 grep --color=auto -e \(gnome-settings-daemon\|kded...

This piece of the power.sh script seems OK.
Comment 15 Jaroslav Škarvada 2012-08-16 05:13:56 EDT
(In reply to comment #14)
Hmm, shouldn't be a selinux issue?

Try with "setenforce 0".
Comment 16 addammo 2012-08-16 05:42:15 EDT
(In reply to comment #15)
> (In reply to comment #14)
> Hmm, shouldn't be a selinux issue?
> 
> Try with "setenforce 0".

Now the script works.
Comment 17 Jaroslav Škarvada 2012-08-16 05:45:19 EDT
Please try to update your selinux-policy to latest version, than:
 touch /.autorelabel
 reboot

It should work then.
Comment 18 Dan Stahlke 2012-08-16 08:03:13 EDT
I still experienced a shutdown last week.  I had opened the laptop lid and pressed the power button (thinking "on").  Probably opening the lid did a wakeup, and pressing the button triggered power.sh before KDE had started up.

Is there any reason to ever do a shutdown on button press?  It seems to me that if there is no power manager running, it would be safer to ignore the button press.  Shutting down without confirmation isn't a safe choice for a default action.  For now, I have emptied the contents of power.sh and things work fine.
Comment 19 addammo 2012-08-16 08:21:23 EDT
(In reply to comment #17)
> Please try to update your selinux-policy to latest version, than:
>  touch /.autorelabel
>  reboot
> 
> It should work then.

Well, upgraded selinux-policy and selinux-policy-targeted and selinux-policy-devel. Now that issue seems solved.
Comment 20 Charles Ghislain 2012-10-09 04:55:09 EDT
To all with had the same issue than me : With the updated script, the shutdown command was correctly discarded but no action was taken by my DM. In kde, I had to ensure the global shortcut (Kde Daemon module) for the 'PowerOff' action was correctly set to the default 'Power off' key. Only after that I was able to set the custom actions in the power management settings for that button.

Note You need to log in before you can comment on or make changes to this bug.