db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r597125 - /db/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java
Date Wed, 21 Nov 2007 16:02:30 GMT
Author: rhillegas
Date: Wed Nov 21 08:02:30 2007
New Revision: 597125

URL: http://svn.apache.org/viewvc?rev=597125&view=rev
Log:
DERBY-3083: To fix regression introduced by DERBY-2196, do not fail server startup if derbynet.jar
cannot be found.

Modified:
    db/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java

Modified: db/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java?rev=597125&r1=597124&r2=597125&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java Wed Nov
21 08:02:30 2007
@@ -545,6 +545,7 @@
      * <li>The command must be "start".</li>
      * <li>The customer didn't specify the -noSecurityManager flag on the startup command
      * line.</li>
+     * <li>Classes live in the jar files which we expect..</li>
      * </ul>
      */
     private static  boolean needsSecurityManager( NetworkServerControlImpl server, int command
)
@@ -554,10 +555,28 @@
             (
              (System.getSecurityManager() == null) &&
              (command == NetworkServerControlImpl.COMMAND_START) &&
-             (!server.runningUnsecure())
+             (!server.runningUnsecure()) &&
+             (packagingLooksGood())
              );
    }
     
+    /**
+     * Return true if the server lives in the expected jar file. This
+     * is meant to address DERBY-3083. We expect that the URL of
+     * the jar which contains NetworkServerControl will end with the
+     * string "derbynet.jar". If this is true, then getCodeSourcePrefix()
+     * will return a prefix which can be substituted into the default
+     * server policy file and so end up granting permissions to the server jar file.
+     */
+    private static  boolean packagingLooksGood()
+        throws Exception
+    {
+        String      derbyNetURL = NetworkServerControl.class.getProtectionDomain().getCodeSource().getLocation().toExternalForm();
+
+        return derbyNetURL.endsWith( DERBYNET_JAR );
+    }
+
+
     /**
      * Verify that all prerequisites are met before bringing up a security
      * manager. See DERBY-2196. If prerequisites aren't met, raise an



Mime
View raw message