[sudo-workers] Problems with persistent elevation with gksudo

Fabio A. Miranda fabio.a.miranda at gmail.com
Fri Jan 15 17:09:53 EST 2010

I hope someone in the list can help me with a indirect issue related to

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();
            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
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

More information about the sudo-workers mailing list