LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   prompt for root password and passing to a program (https://www.linuxquestions.org/questions/programming-9/prompt-for-root-password-and-passing-to-a-program-221152/)

ludeKing 08-22-2004 11:54 PM

prompt for root password and passing to a program
 
Hi all,
I am creating a script that will automatically install some source code and hence, requires the root password to be used. This program will be written in Java. Basically I need to program to be able to accept the root password as a variable then use it when the 'make install' stage comes around.

Alternatively, I would like to become the superuser automatically, ie switch to root PID.

The other uglier way to run this is that you must be root so the password is not needed. Hmm.

Any help on this?

DanTheKiwi 08-23-2004 12:35 AM

why not just run 'su -' from your program? If your program is graphical I'm sure there are some X varients of SU (like the one used in gnome for instance).

ludeKing 08-23-2004 06:12 AM

Yeah it is graphical. I'll keep looking, might have to have the prog check if the user that runs the prog is PID 0.... how could I do this in Java. I know how to in Perl!

Also, do you think it would be easier to have a Perl script as the guts of the installing etc and Java as the GUI. Although anyone could mess with the perl script. Unless I md5sum it and md5sum check it each time the GUI calls it?

Hmm, so many ideas!

chrism01 08-23-2004 08:13 AM

Another option, if install is a regular occurence, is to create a user that only does installs (and similar) and then set the account up to use the sudo tool.

ludeKing 08-23-2004 08:55 PM

Don't know if that is a possibility. What i am making is a program that hopefully will be good enough to be included with a distro, that handles compileing and installing source code and packages, as a GUI, like Windows Installshield.....
might just have to ensure its run as root (PID 0).

how could I do this in Java?


All times are GMT -5. The time now is 07:58 AM.