add modules/ infra (but no loading via pluginservice yet)

This commit is contained in:
Robert Muir 2015-12-03 22:34:24 -05:00
parent caf77f7eea
commit da8fe687fc
2 changed files with 43 additions and 21 deletions

View File

@ -131,9 +131,24 @@ final class Security {
@SuppressForbidden(reason = "proper use of URL") @SuppressForbidden(reason = "proper use of URL")
static Map<String,Policy> getPluginPermissions(Environment environment) throws IOException, NoSuchAlgorithmException { static Map<String,Policy> getPluginPermissions(Environment environment) throws IOException, NoSuchAlgorithmException {
Map<String,Policy> map = new HashMap<>(); Map<String,Policy> map = new HashMap<>();
// collect up lists of plugins and modules
List<Path> pluginsAndModules = new ArrayList<>();
if (Files.exists(environment.pluginsFile())) { if (Files.exists(environment.pluginsFile())) {
try (DirectoryStream<Path> stream = Files.newDirectoryStream(environment.pluginsFile())) { try (DirectoryStream<Path> stream = Files.newDirectoryStream(environment.pluginsFile())) {
for (Path plugin : stream) { for (Path plugin : stream) {
pluginsAndModules.add(plugin);
}
}
}
if (Files.exists(environment.modulesFile())) {
try (DirectoryStream<Path> stream = Files.newDirectoryStream(environment.modulesFile())) {
for (Path plugin : stream) {
pluginsAndModules.add(plugin);
}
}
}
// now process each one
for (Path plugin : pluginsAndModules) {
Path policyFile = plugin.resolve(PluginInfo.ES_PLUGIN_POLICY); Path policyFile = plugin.resolve(PluginInfo.ES_PLUGIN_POLICY);
if (Files.exists(policyFile)) { if (Files.exists(policyFile)) {
// first get a list of URLs for the plugins' jars: // first get a list of URLs for the plugins' jars:
@ -157,8 +172,7 @@ final class Security {
} }
} }
} }
}
}
return Collections.unmodifiableMap(map); return Collections.unmodifiableMap(map);
} }
@ -228,6 +242,7 @@ final class Security {
// read-only dirs // read-only dirs
addPath(policy, "path.home", environment.binFile(), "read,readlink"); addPath(policy, "path.home", environment.binFile(), "read,readlink");
addPath(policy, "path.home", environment.libFile(), "read,readlink"); addPath(policy, "path.home", environment.libFile(), "read,readlink");
addPath(policy, "path.home", environment.modulesFile(), "read,readlink");
addPath(policy, "path.plugins", environment.pluginsFile(), "read,readlink"); addPath(policy, "path.plugins", environment.pluginsFile(), "read,readlink");
addPath(policy, "path.conf", environment.configFile(), "read,readlink"); addPath(policy, "path.conf", environment.configFile(), "read,readlink");
addPath(policy, "path.scripts", environment.scriptsFile(), "read,readlink"); addPath(policy, "path.scripts", environment.scriptsFile(), "read,readlink");

View File

@ -58,6 +58,8 @@ public class Environment {
private final Path pluginsFile; private final Path pluginsFile;
private final Path modulesFile;
private final Path sharedDataFile; private final Path sharedDataFile;
/** location of bin/, used by plugin manager */ /** location of bin/, used by plugin manager */
@ -157,6 +159,7 @@ public class Environment {
binFile = homeFile.resolve("bin"); binFile = homeFile.resolve("bin");
libFile = homeFile.resolve("lib"); libFile = homeFile.resolve("lib");
modulesFile = homeFile.resolve("modules");
} }
/** /**
@ -275,6 +278,10 @@ public class Environment {
return libFile; return libFile;
} }
public Path modulesFile() {
return modulesFile;
}
public Path logsFile() { public Path logsFile() {
return logsFile; return logsFile;
} }