You are not logged in.

#1 2024-01-24 12:17:20

anarki@buttereblume
Member
Registered: 2015-12-29
Posts: 64

[SOLVED] Hibernation and polkit

Hi all. After somewhat 10 years I'm using hibernation on my laptop again. I like the idea leaving it in a saved state for days without draining battery.

The thing is, polkit wants me to authenticate:

systemctl hibernate
Call to Hibernate failed: No such file or directory
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ====
Authentication is required to start 'hibernate.target'.
Authenticating as: anarki
Password:

On the other hand, suspend is working without further auth:

systemctl suspend

My first question: Is that usual? I don't have any dropins at /etc/polkit-1/rules.d nor /etc/sudoers.d.

Now, it doesn't feel right to put me on sudoers just to call for hibernation without auth. I'd rather like polkit to allow this, like it does for suspend. I can achieve it by granting me the action in question:

cat /etc/polkit-1/rules.d/01-hibernate.rules
polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.systemd1.manage-units" &&
        subject.isInGroup("wheel")) {
        return polkit.Result.YES;
    }
});

My second question: Action org.freedesktop.systemd1.manage-unit feels too unspecific, like granting a bit too much. Do you know a better way?

And last question: Although hibernating works as expected, systemctl returns

Call to Hibernate failed: No such file or directory

Red status messages on normal actions give me the creeps.

Thank you!

Edit: Clarify 3rd question

Edit:
Solution: The behaviour is due to my swapfile being located at /home. If /home is a directory on / or a different lvm partition makes no difference
Workaround:

systemctl edit systemd-logind.service

and insert

[Service]
ProtectHome=no

Last edited by anarki@buttereblume (2024-01-26 12:03:06)

Offline

#2 2024-01-24 14:24:59

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,394

Re: [SOLVED] Hibernation and polkit

Sanity check:

loginctl session-status

Offline

#3 2024-01-24 16:44:47

anarki@buttereblume
Member
Registered: 2015-12-29
Posts: 64

Re: [SOLVED] Hibernation and polkit

seth wrote:

Sanity check:

loginctl session-status
loginctl session-status                                                                                                                                                              17:39:04
1 - anarki (1000)
  Since: Wed 2024-01-24 17:38:57 CET; 8s ago
  State: active
 Leader: 738 (login)
   Seat: seat0; vc1
    TTY: tty1
 Remote: no
Service: login
   Type: tty> loginctl session-status                                                                                                                                                              17:39:04
1 - anarki (1000)
  Since: Wed 2024-01-24 17:38:57 CET; 8s ago
  State: active
 Leader: 738 (login)
   Seat: seat0; vc1
    TTY: tty1
 Remote: no
Service: login
   Type: tty
  Class: user
   Idle: no
   Unit: session-1.scope
         ├─738 "login -- anarki"
         ├─775 /bin/sh /usr/bin/startx -- vt1
         ├─802 xinit /home/anarki/.xinitrc -- /usr/bin/X :0 vt1 -auth /tmp/serverauth.ZGZfwSaBg9
         ├─803 /usr/lib/Xorg :0 vt1 -auth /tmp/serverauth.ZGZfwSaBg9
         ├─813 bspwm
         ├─842 picom
         ├─843 sxhkd
         ├─870 alacritty
         ├─880 /usr/bin/zsh
         ├─920 loginctl session-status
         └─921 less

Jan 24 17:38:58 butterblume login[738]: LOGIN ON tty1 BY anarki
Jan 24 17:38:58 butterblume systemd[1]: Started Session 1 of User anarki.

Offline

#4 2024-01-24 17:02:09

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,394

Re: [SOLVED] Hibernation and polkit

Please post your xintrc, in doubt see the last link below and the 2nd blue note there.

Offline

#5 2024-01-24 23:38:59

anarki@buttereblume
Member
Registered: 2015-12-29
Posts: 64

Re: [SOLVED] Hibernation and polkit

seth wrote:

Please post your xintrc, in doubt see the last link below and the 2nd blue note there.

cat ~/.xinitrc
## Set screen profile
set-screen

## X Display Resources
xrdb -merge -I$HOME ~/.Xresources

## X Input Resources
set-keyboard
set-mouse
set-touchpad -d
set-cursor

## Composition manager
picom&

## Hotkeys
sxhkd&

## Window Manager
exec bspwm

Edit: I may add that the described behaviour is true right after login at tty1 and before executing startx.

Last edited by anarki@buttereblume (2024-01-24 23:44:20)

Offline

#6 2024-01-25 07:44:48

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,394

Re: [SOLVED] Hibernation and polkit

I may add that the described behaviour is true right after login at tty1 and before executing startx.

Ok, but your xinitrc will still leave you with a broken session, last link below.

/usr/share/polkit-1/actions/org.freedesktop.login1.polic is supposed to have

        <action id="org.freedesktop.login1.hibernate">
                <description gettext-domain="systemd">Hibernate the system</description>
                <message gettext-domain="systemd">Authentication is required to hibernate the system.</message>
                <defaults>
                        <allow_any>auth_admin_keep</allow_any>
                        <allow_inactive>auth_admin_keep</allow_inactive>
                        <allow_active>yes</allow_active>
                </defaults>
        </action>

Do you try to manage other units w/ some hibernation hook?
What's the output of

systemd-inhibit --list

Red status messages on normal actions give me the creeps.

https://github.com/systemd/systemd/issues/30083

swapon

Offline

#7 2024-01-25 11:05:51

anarki@buttereblume
Member
Registered: 2015-12-29
Posts: 64

Re: [SOLVED] Hibernation and polkit

seth wrote:

Do you try to manage other units w/ some hibernation hook?
What's the output of

systemd-inhibit --list
systemd-inhibit --list
WHO    UID USER PID COMM    WHAT  WHY                  MODE
UPower 0   root 739 upowerd sleep Pause device polling delay

1 inhibitors listed.
seth wrote:
swapon
swapon
NAME           TYPE SIZE USED PRIO
/home/swapfile file  16G   4K   -2

systemctl hibernate
Call to Hibernate failed: No such file or directory

Yes, that's exactly what I see as well. Will wait for coming systemd release.

Last edited by anarki@buttereblume (2024-01-25 11:10:06)

Offline

#8 2024-01-25 11:09:14

anarki@buttereblume
Member
Registered: 2015-12-29
Posts: 64

Re: [SOLVED] Hibernation and polkit

seth wrote:

/usr/share/polkit-1/actions/org.freedesktop.login1.polic is supposed to have
[...]
Do you try to manage other units w/ some hibernation hook?

Mine includes that block exactly and there are no multiple definitions. There also are no hooks that I'm aware of.

Offline

#9 2024-01-25 11:37:22

anarki@buttereblume
Member
Registered: 2015-12-29
Posts: 64

Re: [SOLVED] Hibernation and polkit

seth wrote:

Ok, but your xinitrc will still leave you with a broken session, last link below.

Please enlighten me.

The part of sourcing further scripts at

ls -l /etc/X11/xinit/xinitrc.d
total 12
-rwxr-xr-x 1 root root 318 Jan 29  2023 40-libcanberra-gtk-module.sh
-rwxr-xr-x 1 root root 538 Jan 17 22:46 50-systemd-user.sh
-rwxr-xr-x 1 root root 243 Jan  6 20:07 80xapp-gtk3-module.sh

I'm afraid, never did before. I shall do now.

Offline

#10 2024-01-25 14:09:41

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,394

Re: [SOLVED] Hibernation and polkit

50-systemd-user.sh is the critical script to import the session variables.

I don't think the red warning there is the main issue, it doesn't seem to inhibit the hibernation in any way for tha bug, I just linked it for reference.
/home/swapfile is also your hibernation image?

Nothing inhibits hibernation either.
Unless you've an extra rule like https://wiki.archlinux.org/title/Polkit … _hibernate it would have to be the session state, does it work w/o password if you

<allow_inactive>auth_admin_keep</allow_inactive>

Edit: and try to stop upowerd, though idg why it'd inhibit hibernation but not sleep hmm

Last edited by seth (2024-01-25 14:11:03)

Offline

#11 2024-01-25 14:29:13

anarki@buttereblume
Member
Registered: 2015-12-29
Posts: 64

Re: [SOLVED] Hibernation and polkit

seth wrote:

Unless you've an extra rule like https://wiki.archlinux.org/title/Polkit … _hibernate it would have to be the session state, does it work w/o password if you

<allow_inactive>auth_admin_keep</allow_inactive>

That line is exactly in every block (suspend, hibernate, power-off).

ls -l /etc/polkit-1/rules.d
total 0

Offline

#12 2024-01-25 14:34:52

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,394

Re: [SOLVED] Hibernation and polkit

Sorry, I forgot to edit the copypaste big_smile

<allow_inactive>yes</allow_inactive>

And *only* in <action id="org.freedesktop.login1.hibernate"> and *only* for testing purposes.

Offline

#13 2024-01-25 14:36:08

anarki@buttereblume
Member
Registered: 2015-12-29
Posts: 64

Re: [SOLVED] Hibernation and polkit

Now with sourcing of 50-systemd-users.sh and

<allow_inactive>yes</allow_inactive>

this is what I get:

systemctl hibernate
Call to Hibernate failed: No such file or directory
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ====
Authentication is required to start 'hibernate.target'.
Authenticating as: anarki
Password:Failed to start hibernate.target: Connection timed out
See system logs and 'systemctl status hibernate.target' for details.

while

systemctl status hibernate.target

yields no information on this event.

Edit: Refer to polkit code also.

Last edited by anarki@buttereblume (2024-01-25 14:39:02)

Offline

#14 2024-01-25 14:39:49

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,394

Re: [SOLVED] Hibernation and polkit

seth wrote:

I don't think the red warning there is the main issue …
/home/swapfile is also your hibernation image?

But assuming /home isn't on the root partition, try to target a file on that.

Sourcing of 50-systemd-users.sh won't have done anything itr since the same issue exists on the multi-user.target.

Offline

#15 2024-01-25 14:48:57

anarki@buttereblume
Member
Registered: 2015-12-29
Posts: 64

Re: [SOLVED] Hibernation and polkit

seth wrote:
seth wrote:

I don't think the red warning there is the main issue …
/home/swapfile is also your hibernation image?

But assuming /home isn't on the root partition, try to target a file on that.

Unoptimal partitioning doesn't allow for that (very low memory in /). Wanted to rework that anyway.

Offline

#16 2024-01-25 14:50:55

anarki@buttereblume
Member
Registered: 2015-12-29
Posts: 64

Re: [SOLVED] Hibernation and polkit

Why do you think polkit refers to

==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ====
Authentication is required to start 'hibernate.target'.

instead org.freedesktop.systemd1.hibernate?

Offline

#17 2024-01-25 15:10:01

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,394

Re: [SOLVED] Hibernation and polkit

You're ultimately starting that target.

sudo systemctl start hibernate.target

Back to the bug and your swapfilw position. Does /etc/systemd/system/systemd-logind.service.d/disable-hibernation-swap-check.conf with

[Service]
Environment="SYSTEMD_BYPASS_HIBERNATION_MEMORY_CHECK=1"

have any impact on the situation?
(You'll probably have to restart logind resp. reboot for that to apply)

Offline

#18 2024-01-25 15:34:00

anarki@buttereblume
Member
Registered: 2015-12-29
Posts: 64

Re: [SOLVED] Hibernation and polkit

seth wrote:

You're ultimately starting that target.

sudo systemctl start hibernate.target

Back to the bug and your swapfilw position. Does /etc/systemd/system/systemd-logind.service.d/disable-hibernation-swap-check.conf with

[Service]
Environment="SYSTEMD_BYPASS_HIBERNATION_MEMORY_CHECK=1"

have any impact on the situation?
(You'll probably have to restart logind resp. reboot for that to apply)

Restarted logind and left Xorg off. No change of situation.

Edit: Now I got your point. Will swapon /swapfile. One moment ...

Last edited by anarki@buttereblume (2024-01-25 15:35:07)

Offline

#19 2024-01-25 15:44:35

anarki@buttereblume
Member
Registered: 2015-12-29
Posts: 64

Re: [SOLVED] Hibernation and polkit

seth wrote:

Back to the bug and your swapfilw position. Does /etc/systemd/system/systemd-logind.service.d/disable-hibernation-swap-check.conf with

[Service]
Environment="SYSTEMD_BYPASS_HIBERNATION_MEMORY_CHECK=1"

have any impact on the situation?
(You'll probably have to restart logind resp. reboot for that to apply)

Now with 4G /swapfile and the conf you requested - this did something: No more authentication asked, no more "Call to Hibernate failed: No such file or directory", screen goes off immediately.

Memory issue now, of cause

Jan 25 16:37:53 butterblume systemd[1]: Reached target Sleep.
Jan 25 16:37:53 butterblume systemd[1]: Starting Hibernate...
Jan 25 16:37:53 butterblume systemd-sleep[2376]: Failed to find location to hibernate to: No space left on device
Jan 25 16:37:53 butterblume systemd[1]: systemd-hibernate.service: Main process exited, code=exited, status=1/FAILURE
Jan 25 16:37:53 butterblume systemd[1]: systemd-hibernate.service: Failed with result 'exit-code'.
Jan 25 16:37:53 butterblume systemd[1]: Failed to start Hibernate.
Jan 25 16:37:53 butterblume systemd[1]: Dependency failed for System Hibernation.
Jan 25 16:37:53 butterblume systemd[1]: hibernate.target: Job hibernate.target/start failed with result 'dependency'.
Jan 25 16:37:53 butterblume systemd-logind[611]: Operation 'sleep' finished.

Offline

#20 2024-01-25 15:55:27

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,394

Re: [SOLVED] Hibernation and polkit

Restore the original policy - we'll at least have the cause but I had assumed this was fixed in the systemd rc and skipping the memory check was sufficient.
Stupid question: what if you swapoff /home/swapfile (as the bug talks about ignoring the problem when no swap is available at all, the file doesn't have to be active swap to serve as hibernation target)

Offline

#21 2024-01-25 16:14:13

anarki@buttereblume
Member
Registered: 2015-12-29
Posts: 64

Re: [SOLVED] Hibernation and polkit

seth wrote:

Stupid question: what if you swapoff /home/swapfile (as the bug talks about ignoring the problem when no swap is available at all, the file doesn't have to be active swap to serve as hibernation target)

sudo swapon /home/swapfile
swapon
NAME           TYPE SIZE USED PRIO
/home/swapfile file  16G   0B   -3
/swapfile      file   4G   0B   -2
systemctl hibernate
Call to Hibernate failed: No such file or directory
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ====
Authentication is required to start 'hibernate.target'.
Authenticating as: anarki
Password:

Meanwhile

sudo swapoff /home/swapfile
swapon
NAME           TYPE SIZE USED PRIO
/swapfile      file   4G   0B   -2
systemctl hibernate
#attempting to hibernate

Offline

#22 2024-01-25 20:11:08

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,394

Re: [SOLVED] Hibernation and polkit

So bottom line is that you can hibernate w/o authentication if the off-root swapfile isn't active - and https://github.com/systemd/systemd/issues/30083 and the "No such file or directory" errors are actually relevant?

1. should allow you to run the system, you can have as many swap locations as you want and as mentioned the hibernation target doesn't have to be active swap.
2. if so, we should probably record that pecularity in the wiki
3. Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks. wink

Offline

#23 2024-01-26 09:57:53

anarki@buttereblume
Member
Registered: 2015-12-29
Posts: 64

Re: [SOLVED] Hibernation and polkit

seth wrote:

1. should allow you to run the system, you can have as many swap locations as you want and as mentioned the hibernation target doesn't have to be active swap.

Wait, don't you think it rather is a bug if swapfile location makes a difference? Didn't test swap logical volume, though.

Before using hibernate again, I never had a swap file on my devices, but thinking different since I read https://chrisdown.name/2018/01/02/in-de … -swap.html. On new systems I tend to not have more than one pe on a ssd or even not use lvm at all, so it's easy to have a swap file laying at /.

Last edited by anarki@buttereblume (2024-01-26 10:01:14)

Offline

#24 2024-01-26 10:21:28

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,394

Re: [SOLVED] Hibernation and polkit

There're a lot of things in systemd that a lot of people would deem bugs.

The problem isn't probably the location but the partition and yes, it absolutely does not matter where that is and it does even matter less whether the swapfile is active during the hibernation attempt and the error messages systemd spouts are meaningless gibberish so it all looks like unintended and completely uncontrolled behavior and you're free to file a bug and tell them and then get informed that you're stupid for using the system wrong /closed#notabug

Offline

#25 2024-01-26 11:05:19

anarki@buttereblume
Member
Registered: 2015-12-29
Posts: 64

Re: [SOLVED] Hibernation and polkit

seth wrote:

you're free to file a bug and tell them and then get informed that you're stupid for using the system wrong /closed#notabug

Haha, thank you for the advice. I shall file a bug and get popcorn ready, then.

Offline

Board footer

Powered by FluxBB