LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
LinkBack Search this Thread
Old 07-31-2013, 04:47 PM   #1
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.0
Posts: 3,253

Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
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.
 
Old 07-31-2013, 06:37 PM   #2
yenn
Member
 
Registered: Jan 2011
Location: Czech Republic
Distribution: Slackware, Gentoo
Posts: 144

Rep: Reputation: 21
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.

Last edited by yenn; 07-31-2013 at 06:39 PM. Reason: url edit
 
1 members found this post helpful.
Old 07-31-2013, 07:04 PM   #3
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.0
Posts: 3,253

Original Poster
Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
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.

Last edited by Woodsman; 07-31-2013 at 07:08 PM.
 
Old 07-31-2013, 09:01 PM   #4
mancha
Member
 
Registered: Aug 2012
Posts: 244

Rep: Reputation: Disabled
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
 
1 members found this post helpful.
Old 07-31-2013, 09:20 PM   #5
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.0
Posts: 3,253

Original Poster
Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
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.
 
Old 07-31-2013, 11:24 PM   #6
Kallaste
Member
 
Registered: Nov 2011
Posts: 343

Rep: Reputation: Disabled
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.

Last edited by Kallaste; 07-31-2013 at 11:27 PM. Reason: typo
 
Old 07-31-2013, 11:32 PM   #7
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.0
Posts: 3,253

Original Poster
Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
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.
 
Old 08-01-2013, 05:55 AM   #8
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,185

Rep: Reputation: 285Reputation: 285Reputation: 285
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.
 
Old 08-01-2013, 08:20 AM   #9
yenn
Member
 
Registered: Jan 2011
Location: Czech Republic
Distribution: Slackware, Gentoo
Posts: 144

Rep: Reputation: 21
Quote:
Originally Posted by Woodsman View Post
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 View Post
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.
 
Old 08-01-2013, 02:11 PM   #10
elesmod
Member
 
Registered: Sep 2012
Distribution: Slackware
Posts: 84

Rep: Reputation: Disabled
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
 
Old 08-03-2013, 03:03 PM   #11
mancha
Member
 
Registered: Aug 2012
Posts: 244

Rep: Reputation: Disabled
Quote:
Originally Posted by Woodsman View Post
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?
You can get more information with man pklocalauthority. There's also the polkit reference @freedesktop.org.

--mancha
 
Old 08-03-2013, 04:56 PM   #12
the3dfxdude
Member
 
Registered: May 2007
Posts: 304

Rep: Reputation: 66
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.
 
Old 08-03-2013, 06:20 PM   #13
Woodsman
Senior Member
 
Registered: Oct 2005
Distribution: Slackware 14.0
Posts: 3,253

Original Poster
Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
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.
 
Old 08-03-2013, 07:26 PM   #14
yenn
Member
 
Registered: Jan 2011
Location: Czech Republic
Distribution: Slackware, Gentoo
Posts: 144

Rep: Reputation: 21
Quote:
Originally Posted by Woodsman View Post
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
 
Old 08-03-2013, 07:57 PM   #15
the3dfxdude
Member
 
Registered: May 2007
Posts: 304

Rep: Reputation: 66
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Automatically Resume from Suspend to Ram and Suspend to Disk to Save Battery in Linux LXer Syndicated Linux News 0 05-10-2013 02:40 AM
Suspend to RAM yegnal Linux - Hardware 1 05-23-2009 06:21 PM
WOL from suspend to ram? MasterC Linux - Networking 7 06-06-2008 01:19 AM
Plz explain Suspend to Disk and Suspend to Ram pkhera_2001 Linux - Newbie 2 02-18-2008 07:23 AM
[Help!]Laptop can not suspend to ram Crossa Linux - Laptop and Netbook 3 08-20-2006 12:29 AM


All times are GMT -5. The time now is 10:02 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration