Bug 819547 - Power button press always results in shutdown
Summary: Power button press always results in shutdown
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: acpid
Version: 17
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jaroslav Škarvada
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 848424 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-05-07 14:16 UTC by Charles Ghislain
Modified: 2012-10-09 08:55 UTC (History)
8 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2012-07-26 22:35:48 UTC
Type: Bug
Embargoed:


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

Description Charles Ghislain 2012-05-07 14:16:11 UTC
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 13:27:35 UTC
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 12:21:22 UTC
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 21:34:54 UTC
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 22:03:15 UTC
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 07:03:22 UTC
(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 08:12:34 UTC
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 16:26:55 UTC
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 13:59:00 UTC
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 14:49:49 UTC
(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 22:35:48 UTC
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 07:36:03 UTC
*** Bug 848424 has been marked as a duplicate of this bug. ***

Comment 12 addammo 2012-08-16 07:52:07 UTC
(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 08:17:01 UTC
(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 09:00:59 UTC
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 09:13:56 UTC
(In reply to comment #14)
Hmm, shouldn't be a selinux issue?

Try with "setenforce 0".

Comment 16 addammo 2012-08-16 09:42:15 UTC
(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 09:45:19 UTC
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 12:03:13 UTC
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 12:21:23 UTC
(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 08:55:09 UTC
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.