public abstract class SU extends Object
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.
| Modifier and Type | Method and Description |
|---|---|
static <V,T extends Throwable> |
execute(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 a
VirtualChannel that's connected to the privilege-escalated environment. |
public static hudson.remoting.VirtualChannel start(TaskListener listener, String rootUsername, String rootPassword) throws IOException, InterruptedException
VirtualChannel that's connected to the privilege-escalated environment.listener - What this method is doing (such as what process it's invoking) will be sent here.LocalChannel.
Close this channel and the SU environment will be shut down.IOExceptionInterruptedExceptionpublic static <V,T extends Throwable> V execute(TaskListener listener, String rootUsername, String rootPassword, hudson.remoting.Callable<V,T> closure) throws T extends Throwable, IOException, InterruptedException
T extends ThrowableIOExceptionInterruptedExceptionCopyright © 2019. All rights reserved.