dev@glassfish.java.net

asadmin vs security manager during an upgrade

From: Bobby Bissett <bobby.bissett_at_oracle.com>
Date: Wed, 31 Mar 2010 15:16:13 -0400

Hi all,

If a v2 domain had the security manager enabled, running a v3 upgrade
on it throws an AccesControlException when the System.getEnv() call is
made in ASMain#whichPlatform:

--- begin ---
     private static String whichPlatform() {
         String platform = Constants.Platform.Felix.toString(); //
default is Felix


         // first check the system props
         String temp =
System.getProperty(Constants.PLATFORM_PROPERTY_KEY);
         if (temp == null || temp.trim().length() <= 0) {
             // not in sys props -- check environment
             temp = System.getenv(Constants.PLATFORM_PROPERTY_KEY);
         }

         if (temp != null && temp.trim().length() != 0) {
             platform = temp.trim();
         }
         return platform;
     }
--- end ---

Stack trace is, well, obvious:

Exception in thread "main" java.security.AccessControlException:
access denied (java.lang.RuntimePermission getenv.GlassFish_Platform)
        at
java
.security
.AccessControlContext.checkPermission(AccessControlContext.java:323)
        at
java.security.AccessController.checkPermission(AccessController.java:
546)
        at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
        at java.lang.System.getenv(System.java:844)
        at
com
.sun.enterprise.glassfish.bootstrap.ASMain.whichPlatform(ASMain.java:
117)
        at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:61)

My question: is this something we want to deal with, or should we just
document that the security manager must be turned off during an upgrade?

Thanks,
Bobby