LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Poweroff computer as normal user (https://www.linuxquestions.org/questions/linux-general-1/poweroff-computer-as-normal-user-602408/)

ladio 11-26-2007 03:26 AM

Poweroff computer as normal user
 
Greetings,

I have an application which has two buttons to shutdown and restart the machine. This application will run as a user with very few privileges (user nobody). The command "poweroff" and "reboot" won't work:
when command 'reboot' is run i get the message: reboot: must be a superuser
when command 'poweroff' is run i get the message: poweroff: No.

I tried to change the permission for: /sbin/halt, /sbin/reboot, /sbin/shutdown, /sbin/poweroff as follows:
chmod u+s /sbin/halt
chmod u+s /sbin/shutdown
chmod u+s /sbin/reboot
chmod u+s /sbin/poweroff

when i try to run 'poweroff' command after that as user 'nobody' i get the same error as without changing the permissions.
when i try to run 'reboot' i get an error smth like, operation not allowed and then the pc restarts.

Actually, i'm doing this in a thin client and i don't have sudo.

Anyone has any idea?

Thanks in advance
Ladio

matthewg42 11-26-2007 03:42 AM

I was going to suggest sudo until three lines from the bottom of your post... :(

The setuid bit means the effective user id is taken from the owner of the file. You should verify that the owner of these files is indeed root, and not bin or some other user.

I was always a little fuzzy on the particulars of setuid because it varies slightly on different unixes. I seem to recall reading that on Linux setuid does nothing if the file is a script (as opposed to a binary). On most distros I think these files are regular binaries, but I could imagine some customised distro replacing them with a script... Check they are actually binaries.

One other thing to check... that the filesystem where /sbin is stored doesn't have the nosuid mount flag set, or one of the other mount options which implies it.

If you're sure the programs are running as root, I'm not sure what is going on.


All times are GMT -5. The time now is 03:33 PM.