This is an automated email from the ASF dual-hosted git repository. jaikiran pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/ant.git
The following commit(s) were added to refs/heads/master by this push: new ecfca50b0 Consider VM-configuration when determining if SecurityManager may be set (#216) ecfca50b0 is described below commit ecfca50b0133c576021dd088f855ee878a6b8e66 Author: Hannes Wellmann <wellmann.hann...@gmx.net> AuthorDate: Wed Feb 5 06:15:04 2025 +0100 Consider VM-configuration when determining if SecurityManager may be set (#216) Do not set the SecurityManager if java.security.manager system property is set to "disallow" --- src/main/org/apache/tools/ant/util/SecurityManagerUtil.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/org/apache/tools/ant/util/SecurityManagerUtil.java b/src/main/org/apache/tools/ant/util/SecurityManagerUtil.java index 836a7b872..70eb85421 100644 --- a/src/main/org/apache/tools/ant/util/SecurityManagerUtil.java +++ b/src/main/org/apache/tools/ant/util/SecurityManagerUtil.java @@ -25,7 +25,12 @@ import org.apache.tools.ant.Project; */ public final class SecurityManagerUtil { - private static final boolean isJava18OrHigher = JavaEnvUtils.isAtLeastJavaVersion("18"); + // Ant will not set the SecurityManager if Java version is 18 or higher. + // For versions lower than Java 18, Ant will not set the SecurityManager + // if the "java.security.manager" system property is set to "disallow". + private static final boolean IS_SET_SECURITYMANAGER_ALLOWED = !JavaEnvUtils.isAtLeastJavaVersion("18") + && !"disallow".equals(System.getProperty("java.security.manager")); + private static final boolean sysPropWarnOnSecMgrUsage = Boolean.getBoolean(MagicNames.WARN_SECURITY_MANAGER_USAGE); @@ -34,10 +39,7 @@ public final class SecurityManagerUtil { * otherwise} */ public static boolean isSetSecurityManagerAllowed() { - if (isJava18OrHigher) { - return false; - } - return true; + return IS_SET_SECURITYMANAGER_ALLOWED; } /**