Index: admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java =================================================================== --- admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java (revision 43670) +++ admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java (working copy) @@ -51,6 +51,7 @@ import com.sun.enterprise.universal.process.ProcessStreamDrainer; import com.sun.enterprise.universal.xml.MiniXmlParserException; import com.sun.enterprise.util.OS; +import com.sun.enterprise.util.io.FileUtils; import com.sun.enterprise.util.net.NetUtils; import com.sun.enterprise.universal.glassfish.ASenvPropertyReader; import com.sun.enterprise.universal.xml.MiniXmlParser; @@ -156,6 +157,7 @@ info.setAdminAddresses(parser.getAdminAddresses()); javaConfig = new JavaConfig(parser.getJavaConfig()); setupProfilerAndJvmOptions(parser); + setupUpgradeSecurity(); setupMonitoring(parser); sysPropsFromXml = parser.getSystemProperties(); asenvProps.put(INSTANCE_ROOT_PROPERTY, getInfo().getInstanceRootDir().getPath()); @@ -666,6 +668,29 @@ jvmOptions = new JvmOptions(rawJvmOptions); } + private void setupUpgradeSecurity() throws GFLauncherException { + // If this is an upgrade and the security manager is on, + // copy the current server.policy file to the domain + // before the upgrade. + if (info.isUpgrade() && + jvmOptions.sysProps.containsKey("java.security.manager")) { + + GFLauncherLogger.info(strings.get("copy_server_policy")); + + File source = new File(new File(new File(info.installDir, "lib"), + "templates"), "server.policy"); + File target = new File(info.getConfigDir(), "server.policy"); + + try { + FileUtils.copyFile(source, target); + } catch (IOException ioe) { + // just in case. if source is missing for some reason, + // an illegal arg exception will be thrown. + throw new GFLauncherException("copy_server_policy_error"); + } + } + } + private void setupMonitoring(MiniXmlParser parser) throws GFLauncherException { // As usual we have to be very careful. Index: admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/LocalStrings.properties =================================================================== --- admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/LocalStrings.properties (revision 43670) +++ admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/LocalStrings.properties (working copy) @@ -80,4 +80,7 @@ #'ssh' message from Sathyan Catari see IT 13862 October 19, 2010 ssh=Attempting to start {0}.... Please look at the server log for more details..... - +# issue 11665 +copy_server_policy=Will copy glassfish/lib/templates/server.policy file to domain before upgrading. +copy_server_policy_error=Could not copy server.policy to domain. You may need to turn off the \ + security manager before upgrading.