Bug 298712 - Power management broken with multiple users
Summary: Power management broken with multiple users
Status: RESOLVED FIXED
Alias: None
Product: solid
Classification: Frameworks and Libraries
Component: powermanagement (show other bugs)
Version: 4.9.1
Platform: openSUSE Linux
: NOR major
Target Milestone: ---
Assignee: Dario Freddi
URL: http://forum.kde.org/viewtopic.php?f=...
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-24 04:05 UTC by Eric Johnson
Modified: 2012-12-06 00:11 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.9.3


Attachments
text file containing contents of all files with string "org.freedesktop.upower" (8.80 KB, text/plain)
2012-09-20 04:25 UTC, Eric Johnson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Johnson 2012-04-24 04:05:10 UTC
System will not sleep if more that one user session is used.  Authentication is not remembered even when "remember authentication" is selected. 

Reproducible: Always

Steps to Reproduce:
1 ) bootup machine and login as userA (vt7)
2 ) configure userA power settings to put the system to sleep after 30 seconds and nothing else - apply setting.
3 ) wait 30 seconds -> system goes to sleep -> wake system
4 ) unlock screen, logout, open a new session as userB (vt7), and repeat steps 2) and 3) as userB.

OK at this point power management is working perfectly for userA and userB as system sleeps after 30 seconds inactivity. It works for user A, B, C ,D etc when only a single user is logged in.

Now lets move the config to /etc and see what happens.
5 ) login as userA
6 ) as root copy /home/userA/.kde4/share.config/powermanagementprofilesrc to
/etc/kde4/share/config/powermanagementprofilesrc
7 ) configure userA power setting by deselecting any actions (unchecking all boxes under battery monitor -> configure power management -> energy saving settings)
8 ) logout and log back in, wait 30 seconds, system goes to sleep.
9 ) logout and login as userB
10 ) repeat steps 7 ) and 8 ) for userB

OK userA and userB are configured to do nothing, the configuration from /etc is putting the system to sleep after 30 seconds of inactivity. Great! So far . . .

Now lets see what happens with multiple logins!

11 ) logout of all sessions
12 ) login as userA (vt7) and confirm system sleeps after 30 seconds -> confirmed -> wake system and unlock screen
13 ) Alt+F2 -> type "new session" -> press enter and login as userB (vt8), wait 30 seconds
14 ) system DOES NOT sleep after 30 seconds, but screen turns off.
15 ) wiggle mouse and screen turns on, ctl+alt+F7 to switch to vt7 userA session
16 ) dialog box has popped up asking for root password to authenticate for putting sytem to sleep.
17 ) in dialog box select "remember authentication" checkbox and do not select "for this session only" checkbox, enter root password and click ok.
18 ) system immediately sleeps
19 ) wake system by pressing power button -> system wakes and session resumes (session is NOT locked as usual)
20 ) ctl+alt+F8 to switch back to vt8 userB session, wait 30 seconds -> system DOES NOT sleep but screen turns off.
21 ) repeat steps 15) and 16)

Again the dialog box has popped up asking for root password to authenticate even though I had previously selected "remember authentication".

This behavior is also observed before copying config to /etc
Actual Results:  
system does not sleep

Expected Results:  
system should go to sleep

This seems to be a long standing bug persisting through kde 4 releases.  I consider this  major issue - power saving is a very important and basic feature, and should function with one or multiple users running in vt7, vt8 etc etc.
Comment 1 Myriam Schweingruber 2012-09-07 11:28:37 UTC
Which exact KDE version is this about? Please set the version field.
Comment 2 Eric Johnson 2012-09-11 16:01:17 UTC
Did you read the last line in the bug report? "This seems to be a long standing bug persisting through kde 4 releases."  In fact I tend to upgrade my kde as new releases become available and I have observed this behavior for as long as I can remember using KDE 4.x (after many years of KDE 3.x).  So pick a KDE 4.x version and you will find the bug. Having said that, the precise tests described in the bug were done using kdebase4-runtime-4.7.4 as installed from the following repository: 

http://download.opensuse.org/repositories/KDE:/Release:/47/openSUSE_11.4/x86_64/ (In reply to comment #1)

> Which exact KDE version is this about? Please set the version field.
Comment 3 Eric Johnson 2012-09-11 16:01:46 UTC
Did you read the last line in the bug report? "This seems to be a long standing bug persisting through kde 4 releases."  In fact I tend to upgrade my kde as new releases become available and I have observed this behavior for as long as I can remember using KDE 4.x (after many years of KDE 3.x).  So pick a KDE 4.x version and you will find the bug. Having said that, the precise tests described in the bug were done using kdebase4-runtime-4.7.4 as installed from the following repository: 

http://download.opensuse.org/repositories/KDE:/Release:/47/openSUSE_11.4/x86_64/ (In reply to comment #1)

> Which exact KDE version is this about? Please set the version field.
Comment 4 Myriam Schweingruber 2012-09-12 07:43:26 UTC
Thank you for the feedback. JFYI: the current stable KDE release is 4.9.1 so it would be really useful to know if this still applies, since there have been quite some changes in that code in KDE 4.8.x...
Comment 5 Oliver Henshaw 2012-09-17 14:30:12 UTC
(Not an expert, found this bug while researching an unrelated power management bug).

The part where the other session pops up a root password dialog suggests this is may be polkit related (I think opensuse uses polkit, right?). The policy on my (fedora) system simply allows suspend on active sessions and disallows it on inactive ones, but I think it would be possible to write a policy that asks for a root password in some situations.

It would be interesting to see the contents of all files that contain the string "freedesktop.upower" in /usr/share/polkit-1 or /etc/polkit-1 or /var/lib/polkit-1.
Comment 6 Eric Johnson 2012-09-20 04:21:55 UTC
(In reply to comment #4)
> Thank you for the feedback. JFYI: the current stable KDE release is 4.9.1 so
> it would be really useful to know if this still applies, since there have
> been quite some changes in that code in KDE 4.8.x...

Have now updated to the latest KDE 4.9.1 with the following repository:
http://download.opensuse.org/repositories/KDE:/Release:/49/openSUSE_12.1/

Behavior described above still persists.  Please also see comments #5 and reply.  Thanks!
Comment 7 Eric Johnson 2012-09-20 04:25:26 UTC
Created attachment 74043 [details]
text file containing contents of all files with string "org.freedesktop.upower"
Comment 8 Eric Johnson 2012-09-20 04:28:12 UTC
(In reply to comment #5)
> (Not an expert, found this bug while researching an unrelated power
> management bug).
> 
> The part where the other session pops up a root password dialog suggests
> this is may be polkit related (I think opensuse uses polkit, right?). The
> policy on my (fedora) system simply allows suspend on active sessions and
> disallows it on inactive ones, but I think it would be possible to write a
> policy that asks for a root password in some situations.
> 
> It would be interesting to see the contents of all files that contain the
> string "freedesktop.upower" in /usr/share/polkit-1 or /etc/polkit-1 or
> /var/lib/polkit-1.


Oliver,

Thanks much for your insight here.  Yes Suse does use polkit and you are probably right that this is polkit related.  I'm pasting below the contents of all files that contain the string "freedesktop.upower" in /usr/share/polkit-1 or /etc/polkit-1 or
/var/lib/polkit-1.

format is: file path followed by file contents.  Also attached as a text file in case email formatting does something weird.  Would greatly appreciate if anyone can make sense of this.

Cheers,

Eric


/usr/share/polkit-1/org.freedesktop.upower.qos.policy

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
 "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
<policyconfig>
  <vendor>The UPower Project</vendor>
  <vendor_url>http://upower.freedesktop.org/</vendor_url>
  <icon_name>system-suspend</icon_name>

  <action id="org.freedesktop.upower.qos.request-latency">
    <description>Set the required latency of an application</description>
    <description xml:lang="fr">Définir la latence requise d'une application</description>
    <description xml:lang="it">Imposta la latenza richiesta di un'applicazione</description>
    <description xml:lang="pl">Ustawienie wymaganego opóźnienia programu</description>
    <description xml:lang="sv">Ställ in nödvändig fördröjning för ett program</description>
    <message>Authentication is required to set the required latency of an application</message>
    <message xml:lang="fr">Vous devez vous identifier pour définir la latence requise d'une application</message>
    <message xml:lang="it">È richiesto autenticarsi per impostare la latenza richiesta di un'applicazione</message>
    <message xml:lang="pl">Wymagane jest uwierzytelnienie, aby ustawić wymagane opóźnienie programu</message>
    <message xml:lang="sv">Autentisering krävs för att ställa in nödvändig fördröjning för ett program</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>
  </action>

  <action id="org.freedesktop.upower.qos.request-latency-persistent">
    <description>Set a persistent latency setting</description>
    <description xml:lang="fr">Définir une latence persistante</description>
    <description xml:lang="it">Imposta una impostazione di latenza duratura</description>
    <description xml:lang="pl">Ustanowienie ustawienia trwałego opóźnienia</description>
    <description xml:lang="sv">Ställ in en bestående fördröjningsinställning</description>
    <message>Authentication is required to set a persistent latency setting</message>
    <message xml:lang="fr">Vous devez vous identifier pour définir de latence persistante</message>
    <message xml:lang="it">È richiesto autenticarsi per impostare una impostazione di latenza duratura</message>
    <message xml:lang="pl">Wymagane jest uwierzytelnienie, aby ustanowić trwałe ustawienie opóźnienia</message>
    <message xml:lang="sv">Autentisering krävs för att ställa in en bestående fördröjningsinställning</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>
  </action>

  <action id="org.freedesktop.upower.qos.set-minimum-latency">
    <description>Set administrator settings for latency control</description>
    <description xml:lang="fr">Définir les paramètres administrateur pour le contrôle de la latence</description>
    <description xml:lang="it">Imposta le impostazioni di amministrazione per il controllo della latenza</description>
    <description xml:lang="pl">Ustanowienie ustawień administratora do kontroli opóźnienia</description>
    <description xml:lang="sv">Ställ in administratörsinställningar för fördröjningskontroll</description>
    <message>Authentication is required to set administrator settings for latency control</message>
    <message xml:lang="fr">Vous devez vous identifier pour définir les paramètres administrateur de contrôle de latence</message>
    <message xml:lang="it">È richiesto autenticarsi per impostare le impostazioni di amministrazione per il controllo della latenza</message>
    <message xml:lang="pl">Wymagane jest uwierzytelnienie, aby ustanowić ustawienia administratora do kontroli opóźnienia</message>
    <message xml:lang="sv">Autentisering krävs för att ställa in administratörsinställningar för fördröjningskontroll</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>auth_admin</allow_active>
    </defaults>
  </action>

  <action id="org.freedesktop.upower.qos.cancel-request">
    <description>Cancel a latency request</description>
    <description xml:lang="fr">Annuler une demande de latence</description>
    <description xml:lang="it">Annulla una richiesta di latenza</description>
    <description xml:lang="pl">Anulowanie żądania opóźnienia</description>
    <description xml:lang="sv">Avbryt en fördröjningsbegäran</description>
    <message>Authentication is required to cancel a latency request</message>
    <message xml:lang="fr">Vous devez vous identifier pour annuler une demande de latence</message>
    <message xml:lang="it">È richiesto autenticarsi per annullare una richiesta di latenza</message>
    <message xml:lang="pl">Wymagane jest uwierzytelnienie, aby anulować żądanie opóźnienia</message>
    <message xml:lang="sv">Autentisering krävs för att avbryta en fördröjningsbegäran</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>auth_admin</allow_active>
    </defaults>
  </action>

</policyconfig>

/usr/share/polkit-1/org.freedesktop.upower.policy

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
 "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
<policyconfig>
  <vendor>The UPower Project</vendor>
  <vendor_url>http://upower.freedesktop.org/</vendor_url>
  <icon_name>system-suspend</icon_name>

  <action id="org.freedesktop.upower.suspend">
    <description>Suspend the system</description>
    <description xml:lang="fr">Mettre le système en veille</description>
    <description xml:lang="it">Sospende il sistema</description>
    <description xml:lang="pl">Wstrzymanie systemu</description>
    <description xml:lang="sv">Försätt systemet i vänteläge</description>
    <message>Authentication is required to suspend the system</message>
    <message xml:lang="fr">Vous devez vous identifier pour mettre le système en veille</message>
    <message xml:lang="it">È richiesto autenticarsi per sospendere il sistema</message>
    <message xml:lang="pl">Wymagane jest uwierzytelnienie, aby wstrzymać system</message>
    <message xml:lang="sv">Autentisering krävs för att försätta systemet i vänteläge</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>
  </action>

  <action id="org.freedesktop.upower.hibernate">
    <description>Hibernate the system</description>
    <description xml:lang="fr">Mettre le système en hibernation</description>
    <description xml:lang="it">Iberna il sistema</description>
    <description xml:lang="pl">Hibernacja systemu</description>
    <description xml:lang="sv">Försätt systemet i viloläge</description>
    <message>Authentication is required to hibernate the system</message>
    <message xml:lang="fr">Vous devez vous identifier pour mettre le système en hibernation</message>
    <message xml:lang="it">È richiesto autenticarsi per ibernare il sistema</message>
    <message xml:lang="pl">Wymagane jest uwierzytelnienie, aby zahibernować system</message>
    <message xml:lang="sv">Autentisering krävs för att försätta systemet i viloläge</message>
    <defaults>
      <allow_inactive>no</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>
  </action>

</policyconfig>

/var/lib/polkit-1/org.freedesktop.upower.qos.cancel-request.pkla

[org.freedesktop.upower.qos.cancel-request]
Identity=unix-group:*
Action=org.freedesktop.upower.qos.cancel-request
ResultAny=auth_admin
ResultInactive=auth_admin
ResultActive=auth_admin

var/lib/polkit-1/org.freedesktop.upower.hibernate.pkla

[org.freedesktop.upower.hibernate]
Identity=unix-group:*
Action=org.freedesktop.upower.hibernate
ResultAny=auth_admin
ResultInactive=auth_admin
ResultActive=yes

var/lib/polkit-1/org.freedesktop.upower.suspend.pkla

[org.freedesktop.upower.suspend]
Identity=unix-group:*
Action=org.freedesktop.upower.suspend
ResultAny=auth_admin
ResultInactive=auth_admin
ResultActive=yes

var/lib/polkit-1/org.freedesktop.upower.qos.request-latency.pkla

[org.freedesktop.upower.qos.request-latency]
Identity=unix-group:*
Action=org.freedesktop.upower.qos.request-latency
ResultAny=auth_admin
ResultInactive=auth_admin
ResultActive=yes

var/lib/polkit-1/org.freedesktop.upower.qos.set-minimum-latency.pkla

[org.freedesktop.upower.qos.set-minimum-latency]
Identity=unix-group:*
Action=org.freedesktop.upower.qos.set-minimum-latency
ResultAny=auth_admin
ResultInactive=auth_admin
ResultActive=auth_admin

var/lib/polkit-1/org.freedesktop.upower.qos.request-latency-persistent

[org.freedesktop.upower.qos.request-latency-persistent]
Identity=unix-group:*
Action=org.freedesktop.upower.qos.request-latency-persistent
ResultAny=auth_admin
ResultInactive=auth_admin
ResultActive=yes

END
Comment 9 Oliver Henshaw 2012-09-21 17:17:51 UTC
(In reply to comment #8)
> Would greatly
> appreciate if anyone can make sense of this.
> 
> 
> /usr/share/polkit-1/org.freedesktop.upower.policy
> [...] 
>   <action id="org.freedesktop.upower.suspend">
>     <description>Suspend the system</description>
> [...]
>     <defaults>
>       <allow_inactive>no</allow_inactive>
>       <allow_active>yes</allow_active>
>     </defaults>
>   </action>
This is what I have in fedora.

> var/lib/polkit-1/org.freedesktop.upower.suspend.pkla
> 
> [org.freedesktop.upower.suspend]
> Identity=unix-group:*
> Action=org.freedesktop.upower.suspend
> ResultAny=auth_admin
> ResultInactive=auth_admin
> ResultActive=yes

This looks like the immediate cause of the problem. ResultInActive=auth_admin means that it will ask for a root password from an active local (and specifically not remote) session, if I understand correctly. This doesn't make any sense to me, since how can someone not in front of the computer enter a root password? Is this a system provided file or one you've created/edited yourself? You can check with 'rpm -qf FILE' and then 'rpm -qV PACKAGE'. If it does come from opensuse, could you file a bug asking whether "ResultInactive=auth_admin" makes any sense.

That said, I think powerdevil is handling this badly too. I think this was caused by commit 2606ff0045470d360a2ad4ad8aeb2819f653676f - an attempt to fix an issue that was probably better fixed by commit d30b646dd83b81f750d786dab08a91dba7c49f3a - if I'm reading this right, Powerdevil attempts to autosuspend the system even when the session is inactive. Normally polkit disallows this and no harm is done. But on your system it brings up a root dialogue on the inactive session, and obviously an inactive session will idle out before an active one.

The third problem is that a root dialogue on the inactive session might be annoying but it shouldn't block polkit-allowed actions in the active session. I can't see any reason why powerdevil should be to blame for this, but maybe someone more familiar with the code might: for now I'm going to blame polkit.
Comment 10 Oliver Henshaw 2012-09-22 11:28:49 UTC
Bug 295381 describes the same issue: the reporter notes problem #1 and posits problem #3 as the central bug. See also bug 294712 for other issues with upower and polkit authentication.
Comment 11 Eric Johnson 2012-10-04 23:17:46 UTC
Also described in opensuse bugzilla report:

Bug 734829 - kde: suspend does not work if more then one kde session is running
https://bugzilla.novell.com/show_bug.cgi?id=734829

Please set this bug as "Status: CONFIRMED"!
Comment 12 Myriam Schweingruber 2012-10-06 11:15:42 UTC
Setting status correctly.
Comment 13 Oliver Henshaw 2012-10-24 14:18:22 UTC
(In reply to comment #9)
> (In reply to comment #8)
> 
> That said, I think powerdevil is handling this badly too. I think this was
> caused by commit 2606ff0045470d360a2ad4ad8aeb2819f653676f - an attempt to
> fix an issue that was probably better fixed by commit
> d30b646dd83b81f750d786dab08a91dba7c49f3a - if I'm reading this right,
> Powerdevil attempts to autosuspend the system even when the session is
> inactive. Normally polkit disallows this and no harm is done. But on your
> system it brings up a root dialogue on the inactive session, and obviously
> an inactive session will idle out before an active one.

https://git.reviewboard.kde.org/r/107022/
Comment 14 Oliver Henshaw 2012-11-01 15:18:00 UTC
Git commit c4391232658790b471d4e3eddf76a31e6a8e2694 by Oliver Henshaw.
Committed on 24/10/2012 at 15:05.
Pushed by oliverhenshaw into branch 'push/4.9'.

Don't give InterruptSession special treatment

Revert "Override ck check if the last active user requested to shutdown
the session." and matching check in systemd support.

Allowing InterruptSession when another consolekit/loginctl session is
Active means that PowerDevil may attempt to autosuspend the system from
the Inactive session. Normally polkit disallows this and no harm is done
but some systems have a "ResultInactive=auth_admin" policy. This will
bring up a root dialogue on the inactive session, which is annoying and
unnecessary at best. Due to a (upower?) bug this will also block
upower suspend actions in the active session.

This reverts commit 2606ff0045470d360a2ad4ad8aeb2819f653676f. It's not
clear whether https://bugs.kde.org/show_bug.cgi?id=277774 was ever fixed
by that commit.
REVIEW: 107022

M  +2    -2    powerdevil/daemon/powerdevilpolicyagent.cpp

http://commits.kde.org/kde-workspace/c4391232658790b471d4e3eddf76a31e6a8e2694
Comment 15 Oliver Henshaw 2012-11-01 16:14:34 UTC
Git commit c7b72b6f6707df83b52c18ac74a9932488968895 by Oliver Henshaw.
Committed on 24/10/2012 at 15:05.
Pushed by oliverhenshaw into branch 'master'.

Don't give InterruptSession special treatment

Revert "Override ck check if the last active user requested to shutdown
the session." and matching check in systemd support.

Allowing InterruptSession when another consolekit/loginctl session is
Active means that PowerDevil may attempt to autosuspend the system from
the Inactive session. Normally polkit disallows this and no harm is done
but some systems have a "ResultInactive=auth_admin" policy. This will
bring up a root dialogue on the inactive session, which is annoying and
unnecessary at best. Due to a (upower?) bug this will also block
upower suspend actions in the active session.

This reverts commit 2606ff0045470d360a2ad4ad8aeb2819f653676f. It's not
clear whether https://bugs.kde.org/show_bug.cgi?id=277774 was ever fixed
by that commit.
REVIEW: 107022
(cherry picked from commit c4391232658790b471d4e3eddf76a31e6a8e2694)

M  +2    -2    powerdevil/daemon/powerdevilpolicyagent.cpp

http://commits.kde.org/kde-workspace/c7b72b6f6707df83b52c18ac74a9932488968895
Comment 16 Eric Johnson 2012-12-05 04:28:49 UTC
Confirmed power management is working as expected under KDE 4.9.3, open Suse 12.1 and 12.2 after commit! Finally my system sleeps as expected.  Hope it sticks in today's release of 4.9.4.   Thanks to everyone for helping with this bugfix and making KDE better: Oliver Henshaw, Myriam Schweingruber, Dario Freddi and anyone else I'm forgetting.

Thank you and long live KDE!

Eric