Merge pull request elastic/elasticsearch#378 from rmuir/home_file_cleanup
switch over uses of homeFile() to binFile().getParent(). Original commit: elastic/x-pack-elasticsearch@83f229934a
This commit is contained in:
commit
06862df7dd
|
@ -607,7 +607,7 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail {
|
||||||
final TransportClient transportClient = TransportClient.builder()
|
final TransportClient transportClient = TransportClient.builder()
|
||||||
.settings(Settings.builder()
|
.settings(Settings.builder()
|
||||||
.put("name", DEFAULT_CLIENT_NAME + "-" + settings.get("name"))
|
.put("name", DEFAULT_CLIENT_NAME + "-" + settings.get("name"))
|
||||||
.put("path.home", environment.homeFile())
|
.put("path.home", environment.binFile().getParent())
|
||||||
.putArray("plugin.types", ShieldPlugin.class.getName())
|
.putArray("plugin.types", ShieldPlugin.class.getName())
|
||||||
.put(clientSettings))
|
.put(clientSettings))
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class FileUserPasswdStore {
|
||||||
if (location == null) {
|
if (location == null) {
|
||||||
return ShieldPlugin.resolveConfigFile(env, "users");
|
return ShieldPlugin.resolveConfigFile(env, "users");
|
||||||
}
|
}
|
||||||
return env.homeFile().resolve(location);
|
return env.binFile().getParent().resolve(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class FileUserRolesStore {
|
||||||
if (location == null) {
|
if (location == null) {
|
||||||
return ShieldPlugin.resolveConfigFile(env, "users_roles");
|
return ShieldPlugin.resolveConfigFile(env, "users_roles");
|
||||||
}
|
}
|
||||||
return env.homeFile().resolve(location);
|
return env.binFile().getParent().resolve(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -148,7 +148,7 @@ public class PkiRealm extends Realm<X509AuthenticationToken> {
|
||||||
|
|
||||||
String trustStoreAlgorithm = settings.get("truststore.algorithm", System.getProperty("ssl.TrustManagerFactory.algorithm", TrustManagerFactory.getDefaultAlgorithm()));
|
String trustStoreAlgorithm = settings.get("truststore.algorithm", System.getProperty("ssl.TrustManagerFactory.algorithm", TrustManagerFactory.getDefaultAlgorithm()));
|
||||||
TrustManager[] trustManagers;
|
TrustManager[] trustManagers;
|
||||||
try (InputStream in = Files.newInputStream(env.homeFile().resolve(truststorePath))) {
|
try (InputStream in = Files.newInputStream(env.binFile().getParent().resolve(truststorePath))) {
|
||||||
// Load TrustStore
|
// Load TrustStore
|
||||||
KeyStore ks = KeyStore.getInstance("jks");
|
KeyStore ks = KeyStore.getInstance("jks");
|
||||||
ks.load(in, password.toCharArray());
|
ks.load(in, password.toCharArray());
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class DnRoleMapper {
|
||||||
if (location == null) {
|
if (location == null) {
|
||||||
return ShieldPlugin.resolveConfigFile(env, DEFAULT_FILE_NAME);
|
return ShieldPlugin.resolveConfigFile(env, DEFAULT_FILE_NAME);
|
||||||
}
|
}
|
||||||
return env.homeFile().resolve(location);
|
return env.binFile().getParent().resolve(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class FileRolesStore extends AbstractLifecycleComponent<RolesStore> imple
|
||||||
return ShieldPlugin.resolveConfigFile(env, "roles.yml");
|
return ShieldPlugin.resolveConfigFile(env, "roles.yml");
|
||||||
}
|
}
|
||||||
|
|
||||||
return env.homeFile().resolve(location);
|
return env.binFile().getParent().resolve(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ImmutableSet<String> parseFileForRoleNames(Path path, ESLogger logger) {
|
public static ImmutableSet<String> parseFileForRoleNames(Path path, ESLogger logger) {
|
||||||
|
|
|
@ -123,7 +123,7 @@ public class InternalCryptoService extends AbstractLifecycleComponent<InternalCr
|
||||||
if (location == null) {
|
if (location == null) {
|
||||||
return ShieldPlugin.resolveConfigFile(env, FILE_NAME);
|
return ShieldPlugin.resolveConfigFile(env, FILE_NAME);
|
||||||
}
|
}
|
||||||
return env.homeFile().resolve(location);
|
return env.binFile().getParent().resolve(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SecretKey readSystemKey(Path file) {
|
static SecretKey readSystemKey(Path file) {
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class SystemKeyTool extends CliTool {
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
return exitCmd(ExitStatus.USAGE, terminal, "Too many arguments");
|
return exitCmd(ExitStatus.USAGE, terminal, "Too many arguments");
|
||||||
}
|
}
|
||||||
Path path = args.length != 0 ? env.homeFile().resolve(args[0]) : null;
|
Path path = args.length != 0 ? env.binFile().getParent().resolve(args[0]) : null;
|
||||||
return new Generate(terminal, path);
|
return new Generate(terminal, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -238,7 +238,7 @@ public abstract class AbstractSSLService extends AbstractComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
private KeyStore readKeystore(String path, String password) throws Exception {
|
private KeyStore readKeystore(String path, String password) throws Exception {
|
||||||
try (InputStream in = Files.newInputStream(env.homeFile().resolve(path))) {
|
try (InputStream in = Files.newInputStream(env.binFile().getParent().resolve(path))) {
|
||||||
// Load TrustStore
|
// Load TrustStore
|
||||||
KeyStore ks = KeyStore.getInstance("jks");
|
KeyStore ks = KeyStore.getInstance("jks");
|
||||||
assert password != null;
|
assert password != null;
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class DnRoleMapperTests extends ElasticsearchTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testMapper_AutoReload() throws Exception {
|
public void testMapper_AutoReload() throws Exception {
|
||||||
Path roleMappingFile = getDataPath("role_mapping.yml");
|
Path roleMappingFile = getDataPath("role_mapping.yml");
|
||||||
Path file = env.homeFile().resolve("test_role_mapping.yml");
|
Path file = env.binFile().getParent().resolve("test_role_mapping.yml");
|
||||||
Files.copy(roleMappingFile, file, StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(roleMappingFile, file, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
@ -125,7 +125,7 @@ public class DnRoleMapperTests extends ElasticsearchTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testMapper_AutoReload_WithParseFailures() throws Exception {
|
public void testMapper_AutoReload_WithParseFailures() throws Exception {
|
||||||
Path roleMappingFile = getDataPath("role_mapping.yml");
|
Path roleMappingFile = getDataPath("role_mapping.yml");
|
||||||
Path file = env.homeFile().resolve("test_role_mapping.yml");
|
Path file = env.binFile().getParent().resolve("test_role_mapping.yml");
|
||||||
Files.copy(roleMappingFile, file, StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(roleMappingFile, file, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
|
|
@ -38,7 +38,8 @@ public class SystemKeyToolTests extends CliToolTestCase {
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
terminal = mock(Terminal.class);
|
terminal = mock(Terminal.class);
|
||||||
env = mock(Environment.class);
|
env = mock(Environment.class);
|
||||||
when(env.homeFile()).thenReturn(createTempDir());
|
Path tmpDir = createTempDir();
|
||||||
|
when(env.binFile()).thenReturn(tmpDir.resolve("bin"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -226,7 +226,7 @@ public class HttpClient extends AbstractLifecycleComponent<HttpClient> {
|
||||||
if (keyStore == null) {
|
if (keyStore == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Path path = env.homeFile().resolve(keyStore);
|
Path path = env.binFile().getParent().resolve(keyStore);
|
||||||
if (Files.notExists(path)) {
|
if (Files.notExists(path)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,7 @@ public class HttpClient extends AbstractLifecycleComponent<HttpClient> {
|
||||||
// Load TrustStore
|
// Load TrustStore
|
||||||
KeyStore ks = null;
|
KeyStore ks = null;
|
||||||
if (trustStore != null) {
|
if (trustStore != null) {
|
||||||
Path trustStorePath = env.homeFile().resolve(trustStore);
|
Path trustStorePath = env.binFile().getParent().resolve(trustStore);
|
||||||
if (Files.exists(trustStorePath)) {
|
if (Files.exists(trustStorePath)) {
|
||||||
ks = readKeystore(trustStorePath, trustStorePassword);
|
ks = readKeystore(trustStorePath, trustStorePassword);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue