Skip to content

Commit 8638837

Browse files
authored
Add missing permissions to CustomSecurityManager needed for IBM JVMs (#7513)
* Adding missing permissions needed for IBM JVMs * Adding more properties needed by IBM JVMs * Grant setIO by default, so IBM will pass * Adding in access IBM properties * Unblocking IBM Java 8 * Adding file properties * Adding access to JAVABIDI * Adding IBM specific properties to isIbmProperty * Adding bugLevel used by IBM * Adding IBM shutdown timeout to minimal * Adding another IBM property * Adding access to IBM tools file
1 parent 445bbe4 commit 8638837

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

dd-java-agent/src/test/java/jvmbootstraptest/CustomSecurityManager.java

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ final boolean checkRuntimePermission(RuntimePermission perm, Object ctx, String
101101

102102
case "enableContextClassLoaderOverride":
103103
return checkRuntimeContextClassLoader(perm, ctx);
104+
105+
case "setIO":
106+
return checkRuntimeSetIO(perm, ctx);
104107
}
105108

106109
if (name.startsWith("accessClassInPackage.")) {
@@ -295,6 +298,14 @@ protected final boolean defaultCheckRuntimeContextClassLoader(
295298
return false;
296299
}
297300

301+
protected boolean checkRuntimeSetIO(RuntimePermission perm, Object ctx) {
302+
return defaultCheckRuntimeSetIO(perm, ctx);
303+
}
304+
305+
protected final boolean defaultCheckRuntimeSetIO(RuntimePermission perm, Object ctx) {
306+
return true;
307+
}
308+
298309
protected boolean checkOtherRuntimePermission(
299310
RuntimePermission perm, Object ctx, String permName) {
300311
return defaultOtherRuntimePermission(perm, ctx, permName);
@@ -346,7 +357,8 @@ protected final boolean defaultCheckFileReadPermission(
346357
|| isDevFile(filePath)
347358
|| isEtcFile(filePath)
348359
|| isTimeZoneDb(filePath)
349-
|| isNetProperties(filePath);
360+
|| isNetProperties(filePath)
361+
|| isIbmFile(filePath);
350362
}
351363

352364
protected boolean checkFileWritePermission(FilePermission perm, Object ctx, String filePath) {
@@ -375,6 +387,10 @@ protected static final boolean isClassFile(String filePath) {
375387
return filePath.endsWith(".class");
376388
}
377389

390+
protected static final boolean isIbmFile(String filePath) {
391+
return filePath.endsWith("/tmp/.com_ibm_tools_attach");
392+
}
393+
378394
protected static final boolean isLibraryFile(String filePath) {
379395
return filePath.endsWith(".dylib") || filePath.endsWith(".so") || filePath.endsWith(".dll");
380396
}
@@ -518,6 +534,9 @@ protected final boolean minimalCheckPropertyReadPermission(
518534
PropertyPermission perm, Object ctx, String property) {
519535
switch (property) {
520536
case "sun.boot.class.path":
537+
case "sun.reflect.noInflation":
538+
case "sun.reflect.inflationThreshold":
539+
case "sun.nio.cs.bugLevel":
521540
case "java.system.class.loader":
522541
case "java.protocol.handler.pkgs":
523542
case "java.vm.specification.version":
@@ -533,6 +552,7 @@ protected final boolean minimalCheckPropertyReadPermission(
533552
case "java.ext.dirs":
534553
case "java.version":
535554
case "java.home":
555+
case "file.encoding":
536556
case "sun.boot.library.path":
537557
case "sun.jnu.encoding":
538558
case "jdk.module.main":
@@ -543,6 +563,12 @@ protected final boolean minimalCheckPropertyReadPermission(
543563
case "jdk.jar.maxSignatureFileSize":
544564
case "jdk.util.zip.disableZip64ExtraFieldValidation":
545565
case "user.dir":
566+
case "ibm.java9.forceCommonCleanerShutdown":
567+
case "com.ibm.dbgmalloc":
568+
case "com.ibm.tools.attach.shutdown_timeout":
569+
case "ibm.system.encoding":
570+
case "os.name":
571+
case "JAVABIDI":
546572
return true;
547573
}
548574

@@ -579,9 +605,11 @@ protected static final boolean isBuiltinProperty(String propertyName) {
579605
|| isUserLocaleProperty(propertyName)
580606
|| isGraalProperty(propertyName)
581607
|| isAzulProperty(propertyName)
608+
|| isIbmProperty(propertyName)
582609
|| isProxyProperty(propertyName)
583610
|| isReflectProperty(propertyName)
584-
|| isAppleProperty(propertyName);
611+
|| isAppleProperty(propertyName)
612+
|| isFileProperty(propertyName);
585613
}
586614

587615
protected static final boolean isSunProperty(String propertyName) {
@@ -604,6 +632,10 @@ protected static final boolean isOsProperty(String propertyName) {
604632
return propertyName.startsWith("os.") || propertyName.equals("path.separator");
605633
}
606634

635+
protected static final boolean isFileProperty(String propertyName) {
636+
return propertyName.startsWith("file.");
637+
}
638+
607639
protected static final boolean isUserLocaleProperty(String propertyName) {
608640
return propertyName.startsWith("user.");
609641
}
@@ -616,6 +648,16 @@ protected static final boolean isAzulProperty(String propertyName) {
616648
return propertyName.startsWith("com.azul.");
617649
}
618650

651+
protected static final boolean isIbmProperty(String propertyName) {
652+
// IBM specific properties w/o IBM in the name
653+
switch (propertyName) {
654+
case "file.encoding":
655+
case "JAVABIDI":
656+
return true;
657+
}
658+
return propertyName.startsWith("ibm.") || propertyName.startsWith("com.ibm.");
659+
}
660+
619661
protected static final boolean isAppleProperty(String propertyName) {
620662
return propertyName.startsWith("apple.");
621663
}

0 commit comments

Comments
 (0)