gksudo disable elevation persistence

Fabio A. Miranda fabio.a.miranda at gmail.com
Fri Jan 15 19:14:16 UTC 2010


Hello,

I am coding a Java application that executes via ProcessBuilder some
taks as root.

As the application is GUI, I use gksudo and it works perfect. The
problem is that, afeter a successful elevation as root, the Java process
remains elevated and such situation is impacting the flow of the
application after the invocation of gksudo.

The code snippet:

            pb = new ProcessBuilder();
            pb.redirectErrorStream(true);
            fullComando = "/usr/bin/gksudo '/usr/bin/dpkg -R -i " +
constantesUTIL.getInstallTempDirectory() + "DEBS'";
            pb.command("/bin/bash", "-c", fullComando);

Hoe can I tell gksudo to just execute the command as root and return
back without leaving the Java process elevated ?

The behavoir in command line:
fabio at catullus:~$ gksudo id
---- PASSWORD IS REQUESTED via GUI ----
uid=0(root) gid=0(root) groups=0(root)
fabio at catullus:~$ gksudo id
---- NOTHING IS REQUESTED, current PID is elevated ----
uid=0(root) gid=0(root) groups=0(root)
fabio at catullus:~$ 


I need gksudo to always ask for password, limiting itself to elevate the
just fork'ed process and that is.

Thanks in advance,



-- 
Fabio A. Miranda
Enterprise Software
http://www.grupocesa.com/






More information about the ubuntu-users mailing list