Skip to content

Commit 5028b07

Browse files
committed
Grant read access to the config dir
This matches what Security Manager permissions Elasticsearch had for all plugins.
1 parent 7ad7e60 commit 5028b07

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/policy/FileAccessTree.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,9 @@ private FileAccessTree(
138138
});
139139
}
140140

141-
// everything has access to the temp dir and the jdk
141+
// everything has access to the temp dir, config dir and the jdk
142142
addPathAndMaybeLink.accept(pathLookup.tempDir(), Mode.READ_WRITE);
143+
addPathAndMaybeLink.accept(pathLookup.configDir(), Mode.READ);
143144

144145
// TODO: watcher uses javax.activation which looks for known mime types configuration, should this be global or explicit in watcher?
145146
Path jdk = Paths.get(System.getProperty("java.home"));

libs/entitlement/src/test/java/org/elasticsearch/entitlement/runtime/policy/FileAccessTreeTests.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,12 @@ public void testTempDirAccess() {
289289
assertThat(tree.canWrite(TEST_PATH_LOOKUP.tempDir()), is(true));
290290
}
291291

292+
public void testConfigDirAccess() {
293+
var tree = FileAccessTree.of("test-component", "test-module", FilesEntitlement.EMPTY, TEST_PATH_LOOKUP, List.of());
294+
assertThat(tree.canRead(TEST_PATH_LOOKUP.configDir()), is(true));
295+
assertThat(tree.canWrite(TEST_PATH_LOOKUP.configDir()), is(false));
296+
}
297+
292298
public void testBasicExclusiveAccess() {
293299
var tree = accessTree(entitlement("foo", "read"), exclusivePaths("test-component", "test-module", "foo"));
294300
assertThat(tree.canRead(path("foo")), is(true));

0 commit comments

Comments
 (0)