Package hudson.os
Class SU
java.lang.Object
hudson.os.SU
Executes
Callable
as the super user, by forking a new process and executing the closure in there
if necessary.
A best effort is made to execute the closure as root, but we may still end up executing the closure in the non-root privilege, so the closure should expect that and handle it gracefully.
Still very much experimental. Subject to change. Don't use it.
- Author:
- Kohsuke Kawaguchi
-
Method Summary
Modifier and TypeMethodDescriptionstatic <V,
T extends Throwable>
Vexecute
(TaskListener listener, String rootUsername, String rootPassword, hudson.remoting.Callable<V, T> closure) Starts a new privilege-escalated environment, execute a closure, and shut it down.static hudson.remoting.VirtualChannel
start
(TaskListener listener, String rootUsername, String rootPassword) Returns aVirtualChannel
that's connected to the privilege-escalated environment.
-
Method Details
-
start
public static hudson.remoting.VirtualChannel start(TaskListener listener, String rootUsername, String rootPassword) throws IOException, InterruptedException Returns aVirtualChannel
that's connected to the privilege-escalated environment.- Parameters:
listener
- What this method is doing (such as what process it's invoking) will be sent here.- Returns:
- Never null. This may represent a channel to a separate JVM, or just
LocalChannel
. Close this channel and the SU environment will be shut down. - Throws:
IOException
InterruptedException
-
execute
public static <V,T extends Throwable> V execute(TaskListener listener, String rootUsername, String rootPassword, hudson.remoting.Callable<V, T> closure) throws T, IOException, InterruptedExceptionStarts a new privilege-escalated environment, execute a closure, and shut it down.- Throws:
T extends Throwable
IOException
InterruptedException
-