Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How to use "shutdown -h" with a non-root user?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
belzather
n00b
n00b


Joined: 22 Sep 2004
Posts: 24

PostPosted: Mon May 30, 2005 1:31 pm    Post subject: How to use "shutdown -h" with a non-root user? Reply with quote

I have a user named sleep. When I login to fluxbox with my sleep user i want it to start xmms and put som nice sleep tunes on. But I also want the computer to turn off after about an hour, so i wanna use the shutdown -h command, the problem is I get this message:

shutdown: you must be root to do that!

Is there a way to use shutdown if you aren't root?
Back to top
View user's profile Send private message
nixnut
Bodhisattva
Bodhisattva


Joined: 09 Apr 2004
Posts: 10974
Location: the dutch mountains

PostPosted: Mon May 30, 2005 1:44 pm    Post subject: Reply with quote

sudo. Edit /etc/sudoers:
Code:
# Uncomment to allow people in group wheel to run all commands
 %wheel   ALL=(ALL)   ALL

then any user that is a member of the wheel group can shut down the machine with sudo /sbin/shutdown -h now after supplying his password.
_________________
Please add [solved] to the initial post's subject line if you feel your problem is resolved. Help answer the unanswered

talk is cheap. supply exceeds demand
Back to top
View user's profile Send private message
Minot
Tux's lil' helper
Tux's lil' helper


Joined: 01 Apr 2004
Posts: 86
Location: Colorado

PostPosted: Mon May 30, 2005 4:09 pm    Post subject: Reply with quote

Is this generally a safe thing to do? Haven't you now opened up the computer to let others change configuration settings? Are will those still be protected because they are not the root user and owner of those config files?

-MINOT-
Back to top
View user's profile Send private message
pogi
Tux's lil' helper
Tux's lil' helper


Joined: 13 May 2005
Posts: 124
Location: Hungary

PostPosted: Mon May 30, 2005 4:16 pm    Post subject: Reply with quote

Quote:
Is this generally a safe thing to do?

well, you shoudn't add anybody to group 'wheel' who you dont trust.

anyway, there's an example especially for this case in /etc/sudoers
Code:

# Samples
# %users  localhost=/sbin/shutdown -h now


you should add NOPASSWD to the line to make the command runnable without the need of typing the password in.

pogi
_________________
Free! Tibet
Back to top
View user's profile Send private message
NetTrodon
n00b
n00b


Joined: 12 Dec 2004
Posts: 19

PostPosted: Mon Jun 06, 2005 11:33 pm    Post subject: Another solution Reply with quote

Set the SUID bit with chmod 4750. All user executin that command will have root id only for that command. This is the output for my halt command
Code:
nettrodon-linux sbin # ls -l halt
-rwsr-x---  1 root halters 8704 Oct 27  2004 halt
nettrodon-linux sbin #

Explication: only root have ability to read (r), write (w) and execute(s) the file, all member of group halters have the ability to (r)ead and e(x)ecute, but with the (s)uid bit, will have root id for this command only for execution. The unverse, u others, don't have anything (---).
Back to top
View user's profile Send private message
rutski89
Guru
Guru


Joined: 14 Mar 2005
Posts: 468
Location: United States N.Y.

PostPosted: Tue Jun 07, 2005 12:08 am    Post subject: Reply with quote

Push ctrl+alt+delete
_________________
<< ^ | ~ >>
Back to top
View user's profile Send private message
killfire
l33t
l33t


Joined: 04 Oct 2003
Posts: 618

PostPosted: Tue Jun 07, 2005 1:36 am    Post subject: Reply with quote

rutski89 wrote:
Push ctrl+alt+delete


read the post... he wants it to happen automatically...
_________________
my website, built in HAppS: http://dbpatterson.com
an art (oil painting) website I built a pure python backend for: http://www.lydiajohnston.com
Back to top
View user's profile Send private message
lightvhawk0
Guru
Guru


Joined: 07 Nov 2003
Posts: 388

PostPosted: Tue Jun 07, 2005 2:38 am    Post subject: Reply with quote

cat xinitrc
exec xmms --play

cat shutdown.sh
sleep 1h
kill -9 -1
sudo init 0

cat bashrc
shutdown.sh&
xinit

I think that would work

the only thing you'd have to do at first would be to edit sudoers and thats already in here and set up xmms to play those selected songs.......
_________________
If God has made us in his image, we have returned him the favor. - Voltaire
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum