Java Exec (SU) + Reboot on Unix

M

MMilkin

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 ?
 
O

Oliver Wong

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 ?

Not sure what the security implications of this might be, but can't you
do a "sudo reboot", or something similar?

- Oliver
 
S

steve

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 ?

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
 
C

Chris Uppal

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
 
S

steve

Not sure what the security implications of this might be, but can't you
do a "sudo reboot", or something similar?

- 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top