/** * Creates a ZFS file system to migrate the data to. * * <p> * This has to be done while we still have an interactive access with the user, since it involves the password. * * <p> * An exception will be thrown if the operation fails. A normal completion means a success. * * @return * The ZFS dataset name to migrate the data to. */ private String createZfsFileSystem(final TaskListener listener, String rootUsername, String rootPassword) throws IOException, InterruptedException, ZFSException { // capture the UID that Hudson runs under // so that we can allow this user to do everything on this new partition final int uid = LIBC.geteuid(); final int gid = LIBC.getegid(); passwd pwd = LIBC.getpwuid(uid); if(pwd==null) throw new IOException("Failed to obtain the current user information for "+uid); final String userName = pwd.pw_name; final File home = Jenkins.getInstance().getRootDir(); // this is the actual creation of the file system. // return true indicating a success return SU.execute(listener, rootUsername, rootPassword, new Create(listener, home, uid, gid, userName)); } private static class Create extends MasterToSlaveCallable<String, IOException> {
return newLocalChannel(); // TODO: perhaps use RunAs to run as an Administrator? return newLocalChannel();
/** * Starts a new privilege-escalated environment, execute a closure, and shut it down. */ public static <V,T extends Throwable> V execute(TaskListener listener, String rootUsername, String rootPassword, final Callable<V, T> closure) throws T, IOException, InterruptedException { VirtualChannel ch = start(listener, rootUsername, rootPassword); try { return ch.call(closure); } finally { ch.close(); ch.join(3000); // give some time for orderly shutdown, but don't block forever. } }
return SU.execute(listener, rootUsername, rootPassword, new Callable<String, IOException>() {
/** * Starts a new privilege-escalated environment, execute a closure, and shut it down. */ public static <V,T extends Throwable> V execute(TaskListener listener, String rootUsername, String rootPassword, final Callable<V, T> closure) throws T, IOException, InterruptedException { VirtualChannel ch = start(listener, rootUsername, rootPassword); try { return ch.call(closure); } finally { ch.close(); ch.join(3000); // give some time for orderly shutdown, but don't block forever. } }
return newLocalChannel(); // TODO: perhaps use RunAs to run as an Administrator? return newLocalChannel();
return SU.execute(listener, rootUsername, rootPassword, new Callable<String, IOException>() { public String call() throws IOException { NativeZfsFileSystem hudson = null;
/** * Starts a new priviledge-escalated environment, execute a closure, and * shut it down. */ public static <V, T extends Throwable> V execute(TaskListener listener, String rootUsername, String rootPassword, final Callable<V, T> closure) throws T, IOException, InterruptedException { VirtualChannel ch = start(listener, rootUsername, rootPassword); try { return ch.call(closure); } finally { ch.close(); ch.join(3000); // give some time for orderly shutdown, but don't block forever. } }
return newLocalChannel(); // TODO: perhaps use RunAs to run as an Administrator? return newLocalChannel();
String rootPassword = prompter.promptPassword("Specify your password for sudo (or empty if you can sudo without password)"); SU.execute(listener, rootUser, rootPassword, new Callable<Void, IOException>() { public Void call() throws IOException { try {
/** * Starts a new priviledge-escalated environment, execute a closure, and shut it down. */ public static <V,T extends Throwable> V execute(TaskListener listener, String rootUsername, String rootPassword, final Callable<V, T> closure) throws T, IOException, InterruptedException { VirtualChannel ch = start(listener, rootUsername, rootPassword); try { return ch.call(closure); } finally { ch.close(); ch.join(3000); // give some time for orderly shutdown, but don't block forever. } }
return newLocalChannel(); // TODO: perhaps use RunAs to run as an Administrator? return newLocalChannel();
return SU.execute(listener, rootUsername, rootPassword, new MasterToSlaveCallable<String,IOException>() { private static final long serialVersionUID = 7731167233498214301L;
/** * Starts a new priviledge-escalated environment, execute a closure, and shut it down. */ public static <V,T extends Throwable> V execute(TaskListener listener, String rootUsername, String rootPassword, final Callable<V, T> closure) throws T, IOException, InterruptedException { VirtualChannel ch = start(listener, rootUsername, rootPassword); try { return ch.call(closure); } finally { ch.close(); ch.join(3000); // give some time for orderly shutdown, but don't block forever. } }
return newLocalChannel(); // TODO: perhaps use RunAs to run as an Administrator? return newLocalChannel();
return SU.execute(listener, rootUsername, rootPassword, new Callable<String,IOException>() { public String call() throws IOException { PrintStream out = listener.getLogger();
/** * Starts a new priviledge-escalated environment, execute a closure, and shut it down. */ public static <V,T extends Throwable> V execute(TaskListener listener, String rootUsername, String rootPassword, final Callable<V, T> closure) throws T, IOException, InterruptedException { VirtualChannel ch = start(listener, rootUsername, rootPassword); try { return ch.call(closure); } finally { ch.close(); ch.join(3000); // give some time for orderly shutdown, but don't block forever. } }
return newLocalChannel(); // TODO: perhaps use RunAs to run as an Administrator? return newLocalChannel();
return SU.execute(listener, rootUsername, rootPassword, new Callable<String,IOException>() { public String call() throws IOException { PrintStream out = listener.getLogger();