LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-21-2005, 08:47 PM   #1
servnov
Member
 
Registered: Sep 2004
Distribution: Slackware 10.2
Posts: 276

Rep: Reputation: 30
How to use 'poweroff' without being root?


I have multiple users on a desktop system and want them to be able to shutdown the machine. I can't get sudo working, and even that would be overkill; i just want users to be able to shutdown the machine.

Can I somehow change the permissions on /sbin/poweroff to something everyone can use? It's already chmod 777...

Thanks.
 
Old 08-21-2005, 09:01 PM   #2
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: McCalla, AL
Distribution: Funtoo
Posts: 6,926

Rep: Reputation: 128Reputation: 128
I'll take a gander...what if you add these users to the bin group?
As root issue "vigr" and add whichever users to bin, because of:
Code:
mingdao@james:~$ ls -al /sbin/poweroff        
lrwxrwxrwx  1 root root 4 2005-07-21 21:28 /sbin/poweroff -> halt*
mingdao@james:~$ ls -al /sbin/halt     
-rwxr-xr-x  1 root bin 8844 2005-07-18 07:48 /sbin/halt*
/sbin/poweroff being a symlink to /sbin/halt.
 
Old 08-22-2005, 04:35 AM   #3
imitheos
Member
 
Registered: May 2005
Location: Greece
Posts: 420

Rep: Reputation: 90
Quote:
Originally posted by servnov

I have multiple users on a desktop system and want them to be able to shutdown the machine. I can't get sudo working, and even that would be overkill; i just want users to be able to shutdown the machine.

Can I somehow change the permissions on /sbin/poweroff to something everyone can use? It's already chmod 777...
poweroff is a symlink to halt that is why you see 777. the real permissions are the ones of halt


Quote:
Originally posted by Chinaman
I'll take a gander...what if you add these users to the bin group?
As root issue "vigr" and add whichever users to bin, because of:
Code:
mingdao@james:~$ ls -al /sbin/poweroff        
lrwxrwxrwx  1 root root 4 2005-07-21 21:28 /sbin/poweroff -> halt*
mingdao@james:~$ ls -al /sbin/halt     
-rwxr-xr-x  1 root bin 8844 2005-07-18 07:48 /sbin/halt*
/sbin/poweroff being a symlink to /sbin/halt.
As you can see from the permissions "others" have "r-x" permissions, so everyone can execute it.
Adding the users to the "bin" group would do good if the permissions were "-rwxr-x---", so it will do no good.

If you run KDM/GDM (graphical login) you can easily setup the login manager so that any local user can reboot/shutdown the pc.
If you run console logins and then startx, then i guess sudo would be a way.

if you read the manpage of "halt" you will see that it runs "shutdown".
in the "shutdown" manpage it is mentioned that it was not written so that it would be run setuid so that every user can run it.

So, i guess the quickest way is sudo, unless i forget something.
 
Old 08-22-2005, 05:27 AM   #4
oneandoneis2
Senior Member
 
Registered: Nov 2003
Location: London, England
Distribution: Ubuntu
Posts: 1,460

Rep: Reputation: 47
I cheated and put a "Shutdown" button on my XDM login screen. Since all apps on the login screen are run as root, this works perfectly without any need for sudo-ing, passwords, chmod-ing or anything else. . .

Here's a Wish script (requires TCL & TK) that I use:
Code:
#!/usr/bin/wish


proc restartf {} {
exec /sbin/shutdown -r now
}

proc shutdownf {} {
exec /sbin/shutdown -h now
}

proc syncf {} {
exec /usr/bin/emerge --sync
}

button .restart -text "Reboot" \
-background white \
-activebackground orange \
-relief groove \
-command restartf

button .shutdown -text "Shutdown" \
-background white \
-activebackground red \
-relief groove \
-command shutdownf

button .sync -text "Sync" \
-background white \
-activebackground cyan \
-relief groove \
-command syncf

pack .shutdown .restart .sync -fill x -side bottom
 
Old 08-22-2005, 05:31 AM   #5
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: McCalla, AL
Distribution: Funtoo
Posts: 6,926

Rep: Reputation: 128Reputation: 128
I don't personally run KDE, but am building a box for someone today with it.
I installed Slackware -current and using KDE with runlevel 4 gives 3 choices:
End Current Session
Turn Off Computer
Restart Computer
They all work fine for all users. You might need to enable either APM or ACPI
in the kernel to get the box to actually shut down, rather than hanging at
Power off. I don't know with KDE, because it changes many things "behind
the scenes." I know you do with Fluxbox, the window manager I use on my
workstation. But I compiled a new kernel already for the box, so can't say
how that behavior will work with KDE and a default kernel.
 
Old 08-22-2005, 07:10 AM   #6
chandru.in
Member
 
Registered: Jun 2005
Posts: 167

Rep: Reputation: 30
Hey,

I did this to get it working, as root type what is below,

cd /sbin
chmod 4777 halt
chmod 4777 shutdown
 
Old 08-22-2005, 09:16 AM   #7
imitheos
Member
 
Registered: May 2005
Location: Greece
Posts: 420

Rep: Reputation: 90
Quote:
Originally posted by chandru.in
Hey,

I did this to get it working, as root type what is below,

cd /sbin
chmod 4777 halt
chmod 4777 shutdown
yes. and a user does "cat /bin/bash > /sbin/shutdown"
Instant suid shell (i know that the suid bit is supposed to be turned off but it doesn't happen all the time)

Even if this scheme was a good solution the right command would be
"chmod 4755"

But, let me say again.

"Shutdown wasn't designed to be run setuid."
(From the shutdown manpage)
It doesn't mean that it won't work. It will work ok, but the author mentions that shutdown has not been written with the thought
that it would be run setuid, so they didn't take the measures that are needed from security point of view.
If you don't care about security or you have few/trusted users or whatever then do it.

"cd /sbin
chmod 4755 halt shutdown"

But, I (and the author whose opinion has more weight than mine) don't recommend it.
 
Old 08-23-2005, 07:12 AM   #8
servnov
Member
 
Registered: Sep 2004
Distribution: Slackware 10.2
Posts: 276

Original Poster
Rep: Reputation: 30
The chmod 4777 or chmod 4755 worked! Thanks guys.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Root partition doesn't unmount on poweroff akudewan Ubuntu 7 10-23-2005 04:56 AM
poweroff Poszukiwacz Ubuntu 2 08-17-2005 05:10 AM
how to poweroff ?? perdesiz Linux - Laptop and Netbook 5 12-29-2004 03:31 AM
Halt, but no poweroff frzburn Slackware 4 02-19-2004 06:58 PM
poweroff praveen_2003 Linux - Software 1 07-13-2003 01:31 PM


All times are GMT -5. The time now is 08:16 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration