Skip to content

Commit 1f385ab

Browse files
committed
check link for toRealPath using readSymbolicLink
1 parent 0df0776 commit 1f385ab

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,10 +1375,6 @@ public void checkType(Class<?> callerClass, FileStore that) {
13751375

13761376
@Override
13771377
public void checkPathToRealPath(Class<?> callerClass, Path that, LinkOption... options) {
1378-
if (EntitlementChecker.class.isAssignableFrom(callerClass)) {
1379-
return;
1380-
}
1381-
13821378
boolean followLinks = true;
13831379
for (LinkOption option : options) {
13841380
if (option == LinkOption.NOFOLLOW_LINKS) {
@@ -1387,8 +1383,11 @@ public void checkPathToRealPath(Class<?> callerClass, Path that, LinkOption... o
13871383
}
13881384
if (followLinks) {
13891385
try {
1390-
policyManager.checkFileRead(callerClass, that.toRealPath());
1391-
} catch (IOException e) {}
1386+
FileSystemProvider provider = that.getFileSystem().provider();
1387+
policyManager.checkFileRead(callerClass, provider.readSymbolicLink(that));
1388+
} catch (IOException | UnsupportedOperationException e) {
1389+
// that is not a link, or unrelated IOException or unsupported
1390+
}
13921391
}
13931392
policyManager.checkFileRead(callerClass, that);
13941393
}

0 commit comments

Comments
 (0)