Skip to content

Commit 5426cd9

Browse files
authored
[8.x][Entitlements] Add file read entitlement check to library load functions #122494 (#122624)
* [Entitlements] Add file read entitlement check to library load functions #122494 * Missing variant
1 parent 13c511c commit 5426cd9

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

libs/entitlement/qa/entitlement-test-plugin/src/main/java/org/elasticsearch/entitlement/qa/test/LoadNativeLibrariesCheckActions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
class LoadNativeLibrariesCheckActions {
1313
static void runtimeLoad() {
1414
try {
15-
Runtime.getRuntime().load("libSomeLibFile.so");
15+
Runtime.getRuntime().load(FileCheckActions.readDir().resolve("libSomeLibFile.so").toString());
1616
} catch (UnsatisfiedLinkError ignored) {
1717
// The library does not exist, so we expect to fail loading it
1818
}
1919
}
2020

2121
static void systemLoad() {
2222
try {
23-
System.load("libSomeLibFile.so");
23+
System.load(FileCheckActions.readDir().resolve("libSomeLibFile.so").toString());
2424
} catch (UnsatisfiedLinkError ignored) {
2525
// The library does not exist, so we expect to fail loading it
2626
}

libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/api/ElasticsearchEntitlementChecker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ public void checkSelectorProviderInheritedChannel(Class<?> callerClass, Selector
828828

829829
@Override
830830
public void check$java_lang_Runtime$load(Class<?> callerClass, Runtime that, String filename) {
831-
// TODO: check filesystem entitlement READ
831+
policyManager.checkFileRead(callerClass, Path.of(filename));
832832
policyManager.checkLoadingNativeLibraries(callerClass);
833833
}
834834

@@ -839,7 +839,7 @@ public void checkSelectorProviderInheritedChannel(Class<?> callerClass, Selector
839839

840840
@Override
841841
public void check$java_lang_System$$load(Class<?> callerClass, String filename) {
842-
// TODO: check filesystem entitlement READ
842+
policyManager.checkFileRead(callerClass, Path.of(filename));
843843
policyManager.checkLoadingNativeLibraries(callerClass);
844844
}
845845

libs/entitlement/src/main19/java/org/elasticsearch/entitlement/runtime/api/Java19ElasticsearchEntitlementChecker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public Java19ElasticsearchEntitlementChecker(PolicyManager policyManager) {
7373

7474
@Override
7575
public void check$java_lang_foreign_SymbolLookup$$libraryLookup(Class<?> callerClass, Path path, MemorySession session) {
76-
// TODO: check filesystem entitlement READ
76+
policyManager.checkFileRead(callerClass, path);
7777
policyManager.checkLoadingNativeLibraries(callerClass);
7878
}
7979
}

0 commit comments

Comments
 (0)