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 43636) +++ admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/GFLauncher.java (working copy) @@ -156,6 +156,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 +667,48 @@ 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")); + + StringBuilder sb = new StringBuilder( + info.installDir.getAbsolutePath()); + sb.append(File.separator).append("lib"); + sb.append(File.separator).append("templates"); + sb.append(File.separator).append("server.policy"); + File source = new File(sb.toString()); + File target = new File(info.getConfigDir(), "server.policy"); + + // if there's already a utility for this, use it + FileInputStream from = null; + FileOutputStream to = null; + try { + from = new FileInputStream(source); + to = new FileOutputStream(target); + byte[] buffer = new byte[1024]; + int bytesRead; + while ((bytesRead = from.read(buffer)) != -1) { + to.write(buffer, 0, bytesRead); // write + } + } catch (IOException ex) { + // just in case + throw new GFLauncherException("copy_server_policy_error"); + } finally { + try { + from.close(); + to.close(); + } catch (Exception e) { + // they'll close soon enough + } + } + } + } + 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 43636) +++ admin/launcher/src/main/java/com/sun/enterprise/admin/launcher/LocalStrings.properties (working copy) @@ -80,4 +80,8 @@ #'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 newer server.policy file to domain before upgrading. +copy_server_policy_error=Could not copy current server.policy file to domain's config directory. \ +You may need to turn off the security manager before upgrading.