Skip to content

Commit c81d28d

Browse files
committed
Workaround to always allow named pipes on windows
1 parent 8030d86 commit c81d28d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,9 +1118,19 @@ public void checkSelectorProviderInheritedChannel(Class<?> callerClass, Selector
11181118
policyManager.checkFileWrite(callerClass, file);
11191119
}
11201120

1121+
private static final boolean IS_WINDOWS = System.getProperty("os.name", "").startsWith("Windows");
1122+
1123+
private static boolean isNamedPipe(String fileName) {
1124+
return IS_WINDOWS && fileName.startsWith("\\\\.\\pipe\\");
1125+
}
1126+
11211127
@Override
11221128
public void check$java_io_FileInputStream$(Class<?> callerClass, File file) {
1129+
if (isNamedPipe(file.getAbsolutePath())) {
1130+
return;
1131+
}
11231132
policyManager.checkFileRead(callerClass, file);
1133+
11241134
}
11251135

11261136
@Override
@@ -1130,26 +1140,41 @@ public void checkSelectorProviderInheritedChannel(Class<?> callerClass, Selector
11301140

11311141
@Override
11321142
public void check$java_io_FileInputStream$(Class<?> callerClass, String name) {
1143+
if (isNamedPipe(name)) {
1144+
return;
1145+
}
11331146
policyManager.checkFileRead(callerClass, new File(name));
11341147
}
11351148

11361149
@Override
11371150
public void check$java_io_FileOutputStream$(Class<?> callerClass, String name) {
1151+
if (isNamedPipe(name)) {
1152+
return;
1153+
}
11381154
policyManager.checkFileWrite(callerClass, new File(name));
11391155
}
11401156

11411157
@Override
11421158
public void check$java_io_FileOutputStream$(Class<?> callerClass, String name, boolean append) {
1159+
if (isNamedPipe(name)) {
1160+
return;
1161+
}
11431162
policyManager.checkFileWrite(callerClass, new File(name));
11441163
}
11451164

11461165
@Override
11471166
public void check$java_io_FileOutputStream$(Class<?> callerClass, File file) {
1167+
if (isNamedPipe(file.getAbsolutePath())) {
1168+
return;
1169+
}
11481170
policyManager.checkFileWrite(callerClass, file);
11491171
}
11501172

11511173
@Override
11521174
public void check$java_io_FileOutputStream$(Class<?> callerClass, File file, boolean append) {
1175+
if (isNamedPipe(file.getAbsolutePath())) {
1176+
return;
1177+
}
11531178
policyManager.checkFileWrite(callerClass, file);
11541179
}
11551180

0 commit comments

Comments
 (0)