hudson.os
Class SU

java.lang.Object
  extended by hudson.os.SU

public abstract class SU
extends Object

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
static
<V,T extends Throwable>
V
execute(TaskListener listener, String rootUsername, String rootPassword, hudson.remoting.Callable<V,T> closure)
          Starts a new priviledge-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 priviledge-escalated environment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

start

public static hudson.remoting.VirtualChannel start(TaskListener listener,
                                                   String rootUsername,
                                                   String rootPassword)
                                            throws IOException,
                                                   InterruptedException
Returns a VirtualChannel that's connected to the priviledge-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 priviledge-escalated environment, execute a closure, and shut it down.

Throws:
T extends Throwable
IOException
InterruptedException


Copyright © 2004-2013. All Rights Reserved.