cleanup and ban temp files going to jvm default location
This commit is contained in:
parent
51c71c235b
commit
38cccfb057
|
@ -41,3 +41,7 @@ org.apache.lucene.search.PrefixFilter
|
||||||
|
|
||||||
java.nio.file.Paths @ Use PathUtils.get instead.
|
java.nio.file.Paths @ Use PathUtils.get instead.
|
||||||
java.nio.file.FileSystems#getDefault() @ use PathUtils.getDefault instead.
|
java.nio.file.FileSystems#getDefault() @ use PathUtils.getDefault instead.
|
||||||
|
|
||||||
|
@defaultMessage Specify a location for the temp file/directory instead.
|
||||||
|
java.nio.file.Files#createTempDirectory(java.lang.String,java.nio.file.attribute.FileAttribute[])
|
||||||
|
java.nio.file.Files#createTempFile(java.lang.String,java.lang.String,java.nio.file.attribute.FileAttribute[])
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package org.elasticsearch.bootstrap;
|
package org.elasticsearch.bootstrap;
|
||||||
|
|
||||||
|
import org.elasticsearch.common.SuppressForbidden;
|
||||||
import org.elasticsearch.env.Environment;
|
import org.elasticsearch.env.Environment;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
@ -82,6 +83,7 @@ public class Security {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Simple checks that everything is ok */
|
/** Simple checks that everything is ok */
|
||||||
|
@SuppressForbidden(reason = "accesses jvm default tempdir as a self-test")
|
||||||
public static void selfTest() {
|
public static void selfTest() {
|
||||||
// check we can manipulate temporary files
|
// check we can manipulate temporary files
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -21,11 +21,8 @@ package org.elasticsearch.http;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
import org.elasticsearch.ElasticsearchException;
|
|
||||||
import org.elasticsearch.common.component.AbstractLifecycleComponent;
|
import org.elasticsearch.common.component.AbstractLifecycleComponent;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.common.io.FileSystemUtils;
|
|
||||||
import org.elasticsearch.common.io.PathUtils;
|
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.env.Environment;
|
import org.elasticsearch.env.Environment;
|
||||||
import org.elasticsearch.node.service.NodeService;
|
import org.elasticsearch.node.service.NodeService;
|
||||||
|
@ -172,7 +169,8 @@ public class HttpServer extends AbstractLifecycleComponent<HttpServer> {
|
||||||
if (sitePath.length() == 0) {
|
if (sitePath.length() == 0) {
|
||||||
sitePath = "index.html";
|
sitePath = "index.html";
|
||||||
} else {
|
} else {
|
||||||
while (sitePath.charAt(0) == '/') {
|
// remove extraneous leading slashes, its not an absolute path.
|
||||||
|
while (sitePath.length() > 0 && sitePath.charAt(0) == '/') {
|
||||||
sitePath = sitePath.substring(1);
|
sitePath = sitePath.substring(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,8 +43,8 @@ public class SecurityTests extends ElasticsearchTestCase {
|
||||||
String realTmpDir = System.getProperty("java.io.tmpdir");
|
String realTmpDir = System.getProperty("java.io.tmpdir");
|
||||||
Permissions permissions;
|
Permissions permissions;
|
||||||
try {
|
try {
|
||||||
Environment environment = new Environment(settings);
|
|
||||||
System.setProperty("java.io.tmpdir", fakeTmpDir.toString());
|
System.setProperty("java.io.tmpdir", fakeTmpDir.toString());
|
||||||
|
Environment environment = new Environment(settings);
|
||||||
permissions = Security.createPermissions(environment);
|
permissions = Security.createPermissions(environment);
|
||||||
} finally {
|
} finally {
|
||||||
System.setProperty("java.io.tmpdir", realTmpDir);
|
System.setProperty("java.io.tmpdir", realTmpDir);
|
||||||
|
@ -76,9 +76,10 @@ public class SecurityTests extends ElasticsearchTestCase {
|
||||||
Path fakeTmpDir = createTempDir();
|
Path fakeTmpDir = createTempDir();
|
||||||
String realTmpDir = System.getProperty("java.io.tmpdir");
|
String realTmpDir = System.getProperty("java.io.tmpdir");
|
||||||
Permissions permissions;
|
Permissions permissions;
|
||||||
|
Environment environment;
|
||||||
try {
|
try {
|
||||||
Environment environment = new Environment(settings);
|
|
||||||
System.setProperty("java.io.tmpdir", fakeTmpDir.toString());
|
System.setProperty("java.io.tmpdir", fakeTmpDir.toString());
|
||||||
|
environment = new Environment(settings);
|
||||||
permissions = Security.createPermissions(environment);
|
permissions = Security.createPermissions(environment);
|
||||||
} finally {
|
} finally {
|
||||||
System.setProperty("java.io.tmpdir", realTmpDir);
|
System.setProperty("java.io.tmpdir", realTmpDir);
|
||||||
|
|
Loading…
Reference in New Issue