I have a fairly complicated process that I'm trying to develop in java
(and it has to be in java so switching to C where switching thread user
identity is easy and pain free is not an option)
The server runs on unix under a user with special permissions however
that user is not and cannot be root. So my program needs to be able to
reboot the system if given a specific argument.
right now running rt.exec("reboot") will give me a permissions error
If I know the root password how can I procedurally reboot the system
with exec ?
Oliver Wong - 16 Oct 2006 22:17 GMT
>I have a fairly complicated process that I'm trying to develop in java
> (and it has to be in java so switching to C where switching thread user
[quoted text clipped - 8 lines]
> If I know the root password how can I procedurally reboot the system
> with exec ?
Not sure what the security implications of this might be, but can't you
do a "sudo reboot", or something similar?
- Oliver
steve - 17 Oct 2006 23:38 GMT
>> I have a fairly complicated process that I'm trying to develop in java
>> (and it has to be in java so switching to C where switching thread user
[quoted text clipped - 13 lines]
>
> - Oliver
only root can.
After all you don't want little johnny rebooting your system , just because
he happens to be a user on your system.
to be honest you should not be trying to do any "reboot" commands from java.
steve
steve - 16 Oct 2006 22:42 GMT
> I have a fairly complicated process that I'm trying to develop in java
> (and it has to be in java so switching to C where switching thread user
[quoted text clipped - 8 lines]
> If I know the root password how can I procedurally reboot the system
> with exec ?
you will need a script file.
pass in the password via a parameter ( same way you pass params via linux)
then execute the script file from java, instead of running the commands
directly.
you will not be able to do it in separate calls.
or you could do it via a telnet/SSH session from your java app. !!
http://linuxmafia.com/ssh/java.html
Chris Uppal - 17 Oct 2006 11:08 GMT
> The server runs on unix under a user with special permissions however
> that user is not and cannot be root. So my program needs to be able to
> reboot the system if given a specific argument.
I don't think putting the root password into the application -- or putting it
anywhere the application can read it -- is a very good idea. In security terms
it is the equivalent of making the app run as root.
What I would do is create a SUID executable which (a) is only executable by the
application's special user, and (b) reboots the machine (and nothing else!).
It might even (c) do some extra checking to ensure that it is running as the
"right" user, and so on, before rebooting.
-- chris