[ltp] confused about power managment with T520 with Debian with no DE

Joerg Bruehe linux-thinkpad@linux-thinkpad.org
Sun, 05 Feb 2012 12:45:37 +0100


Hi Keith!


keitho@strucktower.com wrote:
> [[...]]
> 
> pm-suspend says only root can invoke it. How to make it so I can do it
> with my regular login?

1) The official way: use "sudo".

This requires that your regular login is listed as one of the accounts
who may do that, and you will be asked to enter your own password.

You can get of the password question by configuring your account in the
"/etc/sudoers" file with the "NOPASSWD" setting.
I do that on all my machines.

Relevant man pages: sudo, sudoers, visudo


2) The hack: use the "setuid" bit.

I have done this with the "/sbin/shutdown" command, it is owned by root:

  joerg@trift-6core:~$ ls -ld /sbin/shutdown
  -rwsr-xr-x 1 root root 23608 12. Aug 2008  /sbin/shutdown
     ^
Note the "s" where you normally would see an "x".
Anybody can call this program (see the final "x"), but when it starts it
will assume the "effective UID" of its owner, "root". Now, it will do
its actions.

Again, I typically do this on all my machines. By this setting, I make
it possible to enter this command after some long-running action, and my
machine will shut down eventually without me being present:

  /do/some/thing --long --hours ; /sbin/shutdown -h now

Assuming "pm-suspend" only checks its effective UID, this should work
the same way.

Note that this setting includes a risk: Any user of the machine, local
or remote, with the least privileges can now shut it down (suspend it).

Relevant man page: chmod


> 
> In addition, it would be much easier if I could invoke it with the Fn-F3
> button. This used to work under Gnome. In fact, since I moved away from
> Gnome the laptop no longer goes into sleep mode when I close the lid.
> 
> Can someone teach me how to enable the Fn-F3 button to invoke sleep, and
> how to configure the system so that closing the lid puts the laptop to
> sleep?

AIUI, there should be ways to configure any of these buttons so that its
press will trigger some configured action, but I never looked into this.
Most probably, the details depend on the window manager you are using now.
I have no specific idea about text mode for this.


HTH and regards,
Joerg

-- 
Joerg Bruehe  - persoenliche Aeusserung / speaking only for himself
mailto:joerg.bruehe@web.de