Package hudson.os
Class SU
- java.lang.Object
-
- hudson.os.SU
-
public abstract class SU extends Object
ExecutesCallable
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
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <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 Detail
-
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 extends Throwable, IOException, InterruptedException
Starts a new privilege-escalated environment, execute a closure, and shut it down.- Throws:
T extends Throwable
IOException
InterruptedException
-
-