LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Using JAAS's UnixLoginModule to login as root (https://www.linuxquestions.org/questions/programming-9/using-jaass-unixloginmodule-to-login-as-root-332440/)

Streagan2 06-11-2005 06:56 AM

Using JAAS's UnixLoginModule to login as root
 
I am running an app on a Linux box where I am already logged in. In Java I want to spawn a process that needs to run as root. I have tried to use JAAS's UnixLoginModule to login as root :
Code:

        Subject subject = new Subject();
        subject.getPrincipals().add(new UnixPrincipal("root"));
        LoginContext loginContext = new LoginContext("Login", subject, new MyHandler());
        loginContext.login();

but my callback handler that would supply the password is never called and I don't appear to be logged in as root. It looks like UnixLoginModule simply returns data about the current user which is a fat lot of good. Does anyone know what I can do to make this thing do what it is supposed to do and allow me to perform a login? If JAAS is inadequate is there another way to acheive this? Essentially I want to be able to login programatically.

Regards,

--------------------

Matthew

Surrey, England
My env: j2sdk1.4.2_06 running on Linux 2.6.11-1.27_FC3 running on Intel Pentium 4E Prescott 3.0GHz FSB800 1MB Cache on a ASUS P4S800 SiS648FX Socket 478 800FSB 3DDR 400 ATA133 motherboard


All times are GMT -5. The time now is 02:51 AM.