From caab1df1118cc26a83d617aa6e0fd0f8478cdbd4 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Tue, 14 Jul 2015 15:42:21 -0400 Subject: [PATCH] more fine-grained jython hack that also plays with java 9 --- .../bootstrap/BootstrapForTesting.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/core/src/test/java/org/elasticsearch/bootstrap/BootstrapForTesting.java b/core/src/test/java/org/elasticsearch/bootstrap/BootstrapForTesting.java index 4b072489f32..0106f2a103d 100644 --- a/core/src/test/java/org/elasticsearch/bootstrap/BootstrapForTesting.java +++ b/core/src/test/java/org/elasticsearch/bootstrap/BootstrapForTesting.java @@ -88,14 +88,16 @@ public class BootstrapForTesting { // add permissions to everything in classpath for (URL url : ((URLClassLoader)BootstrapForTesting.class.getClassLoader()).getURLs()) { Path path = PathUtils.get(url.toURI()); - if (path.toString().endsWith(".jar")) { - // jar itself - perms.add(new FilePermission(path.toString(), "read,readlink")); - // crazy jython... - Security.addPath(perms, path.getParent().resolve("Lib"), "read,readlink"); - } else { - // classes - Security.addPath(perms, path, "read,readlink"); + // resource itself + perms.add(new FilePermission(path.toString(), "read,readlink")); + // classes underneath + perms.add(new FilePermission(path.toString() + path.getFileSystem().getSeparator() + "-", "read,readlink")); + + // crazy jython... + String filename = path.getFileName().toString(); + if (filename.contains("jython") && filename.endsWith(".jar")) { + // just enough so it won't fail when it does not exist + perms.add(new FilePermission(path.getParent().resolve("Lib").toString(), "read,readlink")); } } // java.io.tmpdir