|
@@ -15,7 +15,7 @@ import org.elasticsearch.cli.ProcessInfo;
|
|
|
import org.elasticsearch.cli.Terminal;
|
|
|
import org.elasticsearch.cli.UserException;
|
|
|
import org.elasticsearch.common.io.stream.OutputStreamStreamOutput;
|
|
|
-import org.elasticsearch.common.settings.KeyStoreWrapper;
|
|
|
+import org.elasticsearch.common.settings.SecureSettings;
|
|
|
import org.elasticsearch.core.IOUtils;
|
|
|
import org.elasticsearch.core.PathUtils;
|
|
|
import org.elasticsearch.core.SuppressForbidden;
|
|
@@ -37,7 +37,7 @@ import static org.elasticsearch.server.cli.ProcessUtil.nonInterruptible;
|
|
|
/**
|
|
|
* A helper to control a {@link Process} running the main Elasticsearch server.
|
|
|
*
|
|
|
- * <p> The process can be started by calling {@link #start(Terminal, ProcessInfo, ServerArgs, KeyStoreWrapper)}.
|
|
|
+ * <p> The process can be started by calling {@link #start(Terminal, ProcessInfo, ServerArgs, SecureSettings)}.
|
|
|
* The process is controlled by internally sending arguments and control signals on stdin,
|
|
|
* and receiving control signals on stderr. The start method does not return until the
|
|
|
* server is ready to process requests and has exited the bootstrap thread.
|
|
@@ -67,7 +67,7 @@ public class ServerProcess {
|
|
|
|
|
|
// this allows mocking the process building by tests
|
|
|
interface OptionsBuilder {
|
|
|
- List<String> getJvmOptions(ServerArgs args, KeyStoreWrapper keyStoreWrapper, Path configDir, Path tmpDir, String envOptions)
|
|
|
+ List<String> getJvmOptions(ServerArgs args, SecureSettings secrets, Path configDir, Path tmpDir, String envOptions)
|
|
|
throws InterruptedException, IOException, UserException;
|
|
|
}
|
|
|
|
|
@@ -82,13 +82,13 @@ public class ServerProcess {
|
|
|
* @param terminal A terminal to connect the standard inputs and outputs to for the new process.
|
|
|
* @param processInfo Info about the current process, for passing through to the subprocess.
|
|
|
* @param args Arguments to the server process.
|
|
|
- * @param keystore A keystore for accessing secrets.
|
|
|
+ * @param secrets A secrets for accessing secrets.
|
|
|
* @return A running server process that is ready for requests
|
|
|
* @throws UserException If the process failed during bootstrap
|
|
|
*/
|
|
|
- public static ServerProcess start(Terminal terminal, ProcessInfo processInfo, ServerArgs args, KeyStoreWrapper keystore)
|
|
|
+ public static ServerProcess start(Terminal terminal, ProcessInfo processInfo, ServerArgs args, SecureSettings secrets)
|
|
|
throws UserException {
|
|
|
- return start(terminal, processInfo, args, keystore, JvmOptionsParser::determineJvmOptions, ProcessBuilder::start);
|
|
|
+ return start(terminal, processInfo, args, secrets, JvmOptionsParser::determineJvmOptions, ProcessBuilder::start);
|
|
|
}
|
|
|
|
|
|
// package private so tests can mock options building and process starting
|
|
@@ -96,7 +96,7 @@ public class ServerProcess {
|
|
|
Terminal terminal,
|
|
|
ProcessInfo processInfo,
|
|
|
ServerArgs args,
|
|
|
- KeyStoreWrapper keystore,
|
|
|
+ SecureSettings secrets,
|
|
|
OptionsBuilder optionsBuilder,
|
|
|
ProcessStarter processStarter
|
|
|
) throws UserException {
|
|
@@ -105,7 +105,7 @@ public class ServerProcess {
|
|
|
|
|
|
boolean success = false;
|
|
|
try {
|
|
|
- jvmProcess = createProcess(args, keystore, processInfo, args.configDir(), optionsBuilder, processStarter);
|
|
|
+ jvmProcess = createProcess(args, secrets, processInfo, args.configDir(), optionsBuilder, processStarter);
|
|
|
errorPump = new ErrorPumpThread(terminal.getErrorWriter(), jvmProcess.getErrorStream());
|
|
|
errorPump.start();
|
|
|
sendArgs(args, jvmProcess.getOutputStream());
|
|
@@ -199,7 +199,7 @@ public class ServerProcess {
|
|
|
|
|
|
private static Process createProcess(
|
|
|
ServerArgs args,
|
|
|
- KeyStoreWrapper keystore,
|
|
|
+ SecureSettings secrets,
|
|
|
ProcessInfo processInfo,
|
|
|
Path configDir,
|
|
|
OptionsBuilder optionsBuilder,
|
|
@@ -211,7 +211,7 @@ public class ServerProcess {
|
|
|
envVars.put("LIBFFI_TMPDIR", tempDir.toString());
|
|
|
}
|
|
|
|
|
|
- List<String> jvmOptions = optionsBuilder.getJvmOptions(args, keystore, configDir, tempDir, envVars.remove("ES_JAVA_OPTS"));
|
|
|
+ List<String> jvmOptions = optionsBuilder.getJvmOptions(args, secrets, configDir, tempDir, envVars.remove("ES_JAVA_OPTS"));
|
|
|
// also pass through distribution type
|
|
|
jvmOptions.add("-Des.distribution.type=" + processInfo.sysprops().get("es.distribution.type"));
|
|
|
|