You are not logged in.

#1 2010-05-22 19:57:04

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

shutdown without sudo as normal user

Hello guys,

I'm looking for a way to turn off my laptop as normal user by pressing the power button without the need of using "sudo shutdown -h now".

The only alternative I know about is dbus/console-kit but as this method obviously uses HAL I'm looking for another (I don't like HAL dependecies *g*).

Suggestions?

Best regards

orschiro

Offline

#2 2010-05-22 20:06:51

Berticus
Member
Registered: 2008-06-11
Posts: 731

Re: shutdown without sudo as normal user

If you don't want to sudo, add yourself to the power group.

For using the laptop power button, I think you need ACPI.

Last edited by Berticus (2010-05-22 20:07:05)

Offline

#3 2010-05-22 20:08:47

lymphatik
Member
From: Somewhere else
Registered: 2009-03-07
Posts: 119

Re: shutdown without sudo as normal user

If I remember well it is stated in the wiki. That you should add your user to the group power and you might have to change the permission of the group for shutdown and halt so they could execute it.

So chmod g+x whatever or chown root:power something.

Last edited by lymphatik (2010-05-22 20:09:11)

Offline

#4 2010-05-22 20:37:46

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: shutdown without sudo as normal user

sudo visudo

Offline

#5 2010-05-22 20:48:03

SiegeMachine
Member
Registered: 2009-03-26
Posts: 157

Re: shutdown without sudo as normal user

%sleep ALL=NOPASSWD: /sbin/reboot
%sleep ALL=NOPASSWD: /sbin/halt

Thats what I did, and I made the group %sleep and added any users to that group and then they can sudo halt and the computer will shutdown but then their sudo wont work for anything else

Offline

#6 2010-05-22 21:24:40

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: shutdown without sudo as normal user

Hello guys,

so when using a seperate power group and chown /sbin/shutdown to it then I could also directly chmod it isn't it?

chmod u+s /sbin/shutdown

Is there any disadvantage by doing this?

EDIT:

I tried also the power group method, added my user to power and then chowned via "chown root:power /sbin/shutdown", logged in again, but I still get the message that I have to be root.

What's wrong?

Do I have to change file permissions?

-rwxr-xr-x 1 root power   23840  1. Mai 2009  shutdown

Last edited by orschiro (2010-05-22 21:58:19)

Offline

#7 2010-05-23 05:40:53

SiegeMachine
Member
Registered: 2009-03-26
Posts: 157

Re: shutdown without sudo as normal user

Are you in the power group? I know its a dumb question but you never know.

Offline

#8 2010-05-23 05:50:19

cesura
Package Maintainer (PM)
From: Tallinn, Estonia
Registered: 2010-01-23
Posts: 1,867

Re: shutdown without sudo as normal user

I just hold mine down to power off. I would never dare set it to shut down just from a single press for the fear of someone coming up from behind and pressing it as a joke.

Offline

#9 2010-05-23 05:58:22

measure
Member
Registered: 2009-07-17
Posts: 62

Re: shutdown without sudo as normal user

You should look into changing the acpi behavior.  Specifically, look at /etc/acpi/handler.sh

This is how I handle sleeping when the lid closes.  This is most likely how you should be handling the behavior you want.  This is also probably a bit smarter, in that you don't need to open up any privileges to non-root users.

For example, for sleeping I added /etc/acpi/sleep.sh to the button/lid) section.

button/lid)
    /etc/acpi/sleep.sh

sleep.sh contains

#!/bin/sh
sleep 1
if grep -q open /proc/acpi/button/lid/LID/state; then 
    exit 0; 
fi
s2ram -f

And this is I THINK the correct way to handle such things.

So you should add a line to

button/power)

which if you just want to shutdown could be "halt" (this is the same as shutdown -h now)

Hopefuly that is somewhat helpful.

Offline

#10 2010-05-23 06:16:37

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,774

Re: shutdown without sudo as normal user

itsbrad212 wrote:

I just hold mine down to power off.

You do know that is exactly how you force the power supply to shut down regardless of whether the operating system is ready or not? 

Pushing it once is a request, in response the OS should initiate a shutdown sequence which ends with all of the disks left in a clean state.  After it is ready, the OS sends a message to the power supply that it may now remove power.  This is the process eloquently described by measure.

Pushing and holding is used for when the OS has gone Tango-Uniform and won't or can't initiate the shutdown.  This is equivalent to just pulling the plug, and is likely to result in corrupted file systems.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#11 2010-05-23 09:35:15

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: shutdown without sudo as normal user

Hello guys,

I looked a bit deeper into acpid and it really seems the recommended way to handle those tasks.

I configured it and it's running fine now.

Nevertheless one daemon more that has to run.  hmm

Offline

Board footer

Powered by FluxBB