View previous topic :: View next topic |
Author |
Message |
belzather n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 22 Sep 2004 Posts: 24
|
Posted: Mon May 30, 2005 1:31 pm Post subject: How to use "shutdown -h" with a non-root user? |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
nixnut Bodhisattva
![Bodhisattva Bodhisattva](/images/ranks/rank-bodhisattva.gif)
![](images/avatars/29856733845fd04c0f3d8c.gif)
Joined: 09 Apr 2004 Posts: 10974 Location: the dutch mountains
|
Posted: Mon May 30, 2005 1:44 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
Minot Tux's lil' helper
![Tux's lil' helper Tux's lil' helper](/images/ranks/rank_rect_1.gif)
![](images/avatars/1287847180406f8811035ef.jpg)
Joined: 01 Apr 2004 Posts: 86 Location: Colorado
|
Posted: Mon May 30, 2005 4:09 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
pogi Tux's lil' helper
![Tux's lil' helper Tux's lil' helper](/images/ranks/rank_rect_1.gif)
Joined: 13 May 2005 Posts: 124 Location: Hungary
|
Posted: Mon May 30, 2005 4:16 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
NetTrodon n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 12 Dec 2004 Posts: 19
|
Posted: Mon Jun 06, 2005 11:33 pm Post subject: Another solution |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
rutski89 Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/74264610439b156f51c4d.png)
Joined: 14 Mar 2005 Posts: 468 Location: United States N.Y.
|
Posted: Tue Jun 07, 2005 12:08 am Post subject: |
|
|
Push ctrl+alt+delete _________________ << ^ | ~ >> |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
killfire l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
![](images/avatars/7602108584138b0fd53719.jpg)
Joined: 04 Oct 2003 Posts: 618
|
Posted: Tue Jun 07, 2005 1:36 am Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
lightvhawk0 Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/12186210684bcd47116b689.jpg)
Joined: 07 Nov 2003 Posts: 388
|
Posted: Tue Jun 07, 2005 2:38 am Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
|