LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Suspend to ram as non-root (http://www.linuxquestions.org/questions/slackware-14/suspend-to-ram-as-non-root-4175471661/)

Woodsman 07-31-2013 04:47 PM

Suspend to ram as non-root
 
Slackware 14.0, generic kernel with mkinitrd.

I'm still learning my way with my Thinkpad T400. I seem to lack the big picture with suspend to ram.

I probably missed another memo somewhere. When I run upower -d as non-root, the output reveals the user does not have permission to suspend (can-suspend: no). The account is a member of the power and plugdev group.

pm-suspend is installed at /usr/sbin rather than /usr/bin and the script won't let non-root users execute. pm-suspend works fine as root.

/sys/power/state has permissions of 644, root:root. Of course, with those permissions I can't change the contents as non-root.

All scripts in /usr/lib/pm-utils are executable with 755 permissions.

Full install, so upower, et. al., are installed.

I've been browsing the forum and web to no avail. How do I programmatically execute suspend to ram as a non root user? I have the lid configured as well as Fn-F4, but want to have programmatic access too (can-suspend: yes).

Thanks. :)

yenn 07-31-2013 06:37 PM

Did you read SlackDocs article about hibernating? Suspend to ram isn't covered there, but you can get basic idea.

There are two ways to achieve that:
1) pm-utils via sudo
2) UPower + D-Bus
Code:

$ dbus-send --system --print-reply --dest="org.freedesktop.UPower" \
/org/freedesktop/UPower org.freedesktop.UPower.Suspend

Until I'll update and extend SlackDocs article mentioned above, I recommend ArchWiki - https://wiki.archlinux.org/index.php...s_regular_user.

Woodsman 07-31-2013 07:04 PM

Let's start with the basics. :)

When I run upower -d I see the following at the end:

can-suspend: no

What is needed to change that to yes?

Quote:

dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend
Are you saying a non-root user has to type that entire gobbledygook string to suspend to ram? Or place that string into a script wrapper? Even if a non-root does that, upower -d still informs that the user does not have permissions. What is needed to obtain those permissions?

Note: when I run the gobbledygook above I receive a stdout message of "not authorized," which matches the upower -d output of can-suspend: no.

mancha 07-31-2013 09:01 PM

I'm afraid I can't test this now but give this a shot, put the following in: /etc/polkit-1/localauthority/50-local.d/30-power-group.suspend-override.pkla

Code:

[Suspend power group override]
Identity=unix-group:power
Action=org.freedesktop.upower.suspend
ResultAny=yes
ResultInactive=yes
ResultActive=yes

--mancha

Woodsman 07-31-2013 09:20 PM

Thanks. :) That pkla file did the trick. Now upower -d shows can-suspend: yes. No reboot required, just logout/login.

Now, where in the Slackware documentation would I have found that solution?

I'm still confused. Most people using a laptop don't run as root. So why is this pkla policy not standard? How do folks use various graphical applets to suspend to ram when this policy is not present? Yeah, okay, most folks just close the lid, but for me to even get that to work I had to spend time on the web to learn how to add various acpi scripts. I find acpi on laptops to be ridiculously complicated. Suspend to ram on a laptop does not "just work" on linux based systems. :banghead:

Kallaste 07-31-2013 11:24 PM

I cannot answer that, but in case it is pertinent, when I run "upower -d," I get "can-suspend: yes."

The only thing I ever do for my machines is to make a small addition to /etc/acpi/acpi_handler.sh telling it to suspend on a lid event.

Woodsman 07-31-2013 11:32 PM

Quote:

I cannot answer that, but in case it is pertinent, when I run "upower -d," I get "can-suspend: yes."
Huh. I wonder why that does not happen on my systems? I wonder whether I've configured something that causes that effect. :)

I might have to create a quick temporary VM and fresh install to see what happens to can-suspend.

dive 08-01-2013 05:55 AM

I think it's just a permissions thing in the /proc and /sys files that actually do the suspend/hibernation. If you chown/chmod those at boot you should be able to suspend as normal user like I do. My suspend script:

Code:

killall ssh
sync
echo "0 blink" > /proc/acpi/ibm/led
echo -n mem > /sys/power/state

I have an entry in fluxbox menu for this, but I also use an acpi script that gets called when I press the power button, and which runs as root.

yenn 08-01-2013 08:20 AM

Quote:

Originally Posted by Woodsman (Post 5000602)
When I run upower -d I see the following at the end:

can-suspend: no

Oh, sorry. I don't use pm-suspend/hibernate so it didn't realized at first what that meant.

Quote:

Originally Posted by Woodsman (Post 5000602)
Are you saying a non-root user has to type that entire gobbledygook string to suspend to ram? Or place that string into a script wrapper?

I use bash script as wrapper and as far as I know, there isn't better way. I don't like it much either, but once it's set up, it just works ;) I have menu entry for suspend and hibernation in Fluxbox and sometimes I forget that these scripts are there.

I wonder why it doesn't work on your system. On both 14.0 and current it works like a charm without any polkit configuration file. It works from either console or XFCE logout GUI, which I believe uses the same thing under the hood.

elesmod 08-01-2013 02:11 PM

On my computer, I went the "sudo" way.

with visudo I've added:
Code:

elesmod ALL=NOPASSWD: /usr/sbin/pm-suspend
and I've made an alias for it:
Code:

alias susp='sudo /usr/sbin/pm-suspend'
so whenever I want to suspend my machine to RAM, I just type "susp" in xterm :)

mancha 08-03-2013 03:03 PM

Quote:

Originally Posted by Woodsman (Post 5000667)
Thanks. :) That pkla file did the trick. Now upower -d shows can-suspend: yes. No reboot required, just logout/login.

Now, where in the Slackware documentation would I have found that solution?
:banghead:

You can get more information with man pklocalauthority. There's also the polkit reference @freedesktop.org.

--mancha

the3dfxdude 08-03-2013 04:56 PM

I don't use PolicyKit, or polkit, or whatever it will end up being.

In /etc/rc.d/rc.local, I set my permissions

chmod 664 /sys/power/state
chgrp power /sys/power/state

Now anyone that logs in with the power group can do

echo 'mem' > /sys/power/state

This makes it dead simple.

Woodsman 08-03-2013 06:20 PM

Quote:

This makes it dead simple.
Well, sort of --- to experienced users. My "confusion" is why aren't those settings the default? This is similar to Torvalds' rant months ago about not letting non-root users configure printers.

yenn 08-03-2013 07:26 PM

Quote:

Originally Posted by Woodsman (Post 5002414)
Well, sort of --- to experienced users. My "confusion" is why aren't those settings the default? This is similar to Torvalds' rant months ago about not letting non-root users configure printers.

Is your slackware 14.0 clean install or upgraded from previous version? I just checked one machine with slack 14.0 (32 bit, but it shouldn't matter) and it lets me suspend or hibernate as regular user. Well, suspend doesn't work quite right as it freeze on black screen after wakeup, but at least it lets me suspend system to ram.

Are you sure you don't have any leftover or old configuration files from older slack?

Try these commands and compare output with this.
Code:

[user] $ groups
users lp floppy audio video cdrom plugdev power netdev scanner

[root] # tree /etc/polkit-1/
/etc/polkit-1/
|-- localauthority
|  |-- 10-vendor.d
|  |-- 20-org.d
|  |-- 30-site.d
|  |-- 50-local.d
|  |  |-- 10-org.freedesktop.NetworkManager.pkla
|  |  `-- 20-plugdev-group-mount-override.pkla
|  `-- 90-mandatory.d
|-- localauthority.conf.d
|  `-- 50-localauthority.conf
`-- nullbackend.conf.d
    `-- 50-nullbackend.conf


the3dfxdude 08-03-2013 07:57 PM

On my eeepc, suspend works fine from the lid and the dock on XFCE when I got the appropriate environment running on the stock Slackware 14.0. I have my eeepc set up this way so the wife won't get frustrated with me. I think some of this polkit desktop integration must be untested, as I've seen your question asked before (why permissions for can-suspend is no for no good reason). If I was in your boat, I would probably be ranting like Torvalds.

I'm not sure what DE your are using. If you are using XFCE, I am seriously contemplating forking xfce4-session to bypass polkit/consolekit for stuff like suspend when I upgrade to Slackware 14.1. I'm doing this to try to get a system that is future proof to this userspace madness. This should make the same functions transparent to less experience users, and work at least more often than polkit.


All times are GMT -5. The time now is 09:31 AM.