Skip to content

Commit 8cc0a71

Browse files
committed
simplify toRealPath
1 parent 8fb836f commit 8cc0a71

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

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

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import org.elasticsearch.entitlement.runtime.policy.PolicyManager;
1515

1616
import java.io.File;
17-
import java.io.IOException;
1817
import java.io.InputStream;
1918
import java.io.PrintStream;
2019
import java.io.PrintWriter;
@@ -1375,21 +1374,8 @@ public void checkType(Class<?> callerClass, FileStore that) {
13751374

13761375
@Override
13771376
public void checkPathToRealPath(Class<?> callerClass, Path that, LinkOption... options) {
1378-
if (EntitlementChecker.class.isAssignableFrom(callerClass)) {
1379-
return;
1380-
}
1381-
1382-
boolean followLinks = true;
1383-
for (LinkOption option : options) {
1384-
if (option == LinkOption.NOFOLLOW_LINKS) {
1385-
followLinks = false;
1386-
}
1387-
}
1388-
if (followLinks) {
1389-
try {
1390-
policyManager.checkFileRead(callerClass, that.toRealPath());
1391-
} catch (IOException e) {}
1392-
}
1377+
// We deliberately don't check read permissions on the returned read path if following links.
1378+
// While this allows for an "exists" check on the real target, any file operation still require adequate read permissions.
13931379
policyManager.checkFileRead(callerClass, that);
13941380
}
13951381

0 commit comments

Comments
 (0)