db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r592111 - in /db/derby/code/trunk/java: drda/org/apache/derby/impl/drda/ drda/org/apache/derby/loc/drda/ testing/org/apache/derbyTesting/functionTests/tests/derbynet/
Date Mon, 05 Nov 2007 18:05:18 GMT
Author: kmarsden
Date: Mon Nov  5 10:05:09 2007
New Revision: 592111

URL: http://svn.apache.org/viewvc?rev=592111&view=rev
Log:
DERBY-3110 server hangs after trace on command fails
If there is an error in turning on tracing for any of the sessions, we fail to turn global
tracing on and return an error to the client. The change also wraps the tracing in a privilege
block.  


Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.policy
  (with props)
Modified:
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DssTrace.java
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
    db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/Session.java
    db/derby/code/trunk/java/drda/org/apache/derby/loc/drda/messages_en.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/_Suite.java

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DssTrace.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DssTrace.java?rev=592111&r1=592110&r2=592111&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DssTrace.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/DssTrace.java Mon Nov  5 10:05:09
2007
@@ -20,6 +20,13 @@
  */
 package org.apache.derby.impl.drda;
 
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+
 // Generic process and error tracing encapsulation.
 // This class also traces a DRDA communications buffer.
 // The value of the hex bytes are traced along with
@@ -97,7 +104,7 @@
 
 
   // An array of characters representing hex numbers.
-  private static final char hexDigit [] = {
+ private static final char hexDigit [] = {
     '0','1','2','3','4','5','6','7',
     '8','9','A','B','C','D','E','F'
   };
@@ -160,14 +167,28 @@
   // Start the communications buffer trace.
   // The name of the file to place the trace is passed to this method.
   // After calling this method, calls to isComBufferTraceOn() will return true.
-  protected void startComBufferTrace (String fileName)
+  protected void startComBufferTrace (final String fileName) throws IOException 
   {
     synchronized (comBufferSync) {
-      try {
         // Only start the trace if it is off.
         if (comBufferTraceOn == false) {
           // The writer will be buffered for effeciency.
-          comBufferWriter = new java.io.PrintWriter (new java.io.BufferedWriter (new java.io.FileWriter
(fileName), 4096));
+            try {
+                
+                comBufferWriter =  ((PrintWriter)AccessController.doPrivileged(
+                            new PrivilegedExceptionAction() {
+                                public Object run() throws SecurityException, IOException
{
+                                    return new  PrintWriter (new java.io.BufferedWriter (new
java.io.FileWriter (fileName), 4096));
+                                }
+                            }));
+            } catch (PrivilegedActionException pae) {
+               Exception e = pae.getException();
+               if (e instanceof SecurityException)
+                   throw (SecurityException)pae.getException();
+               else
+                   throw (IOException) pae.getException();
+            }
+          
           // Turn on the trace flag.
           comBufferTraceOn = true;
           // initialize the codepoint name table if it is null.
@@ -181,11 +202,8 @@
           }
         }
       }
-      catch (java.io.IOException e) {
-        // The IOException is currently ignored.  Handling should be added.
-      }
     }
-  }
+  
 
   // Stop the communications buffer trace.
   // The trace file is flushed and closed.  After calling this method,
@@ -198,8 +216,11 @@
         // Turn of the trace flag.
         comBufferTraceOn = false;
         // Flush and close the writer used for tracing.
-        comBufferWriter.flush();
-        comBufferWriter.close();
+        if (comBufferWriter != null)
+        {
+            comBufferWriter.flush();
+            comBufferWriter.close();
+        }
       }
     }
   }

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java?rev=592111&r1=592110&r2=592111&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
(original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
Mon Nov  5 10:05:09 2007
@@ -1425,10 +1425,14 @@
 					}
 					else
 					{
-						sendMessage(writer, ERROR,  
-							localizeMessage("DRDA_SessionNotFound.U", 
-							(session.langUtil == null) ? langUtil : session.langUtil,
-							new String [] {new Integer(sessionArg).toString()}));
+					    if (sessionArg != 0)
+							sendMessage(writer, ERROR,  
+							    localizeMessage("DRDA_SessionNotFound.U", 
+									    (session.langUtil == null) ? langUtil : session.langUtil,
+									    new String [] {new Integer(sessionArg).toString()}));
+					    else
+							sendMessage(writer, ERROR,  
+										localizeMessage("DRDA_ErrorStartingTracing.S",null));          
 					}
 					break;
 				case COMMAND_TRACEDIRECTORY:
@@ -3355,18 +3359,27 @@
 	 */
 	private boolean setTrace(boolean on)
 	{
+        boolean setTraceSuccessful = true;
 		if (sessionArg == 0)
 		{
-			setTraceAll(on);
 			synchronized(sessionTable) {
 				for (Enumeration e = sessionTable.elements(); e.hasMoreElements(); )
-				{	
-					Session session = (Session) e.nextElement();
+				{
+                   
+				    Session session = (Session) e.nextElement();
 					if (on)
-						session.setTraceOn(traceDirectory);
+						try {
+							session.setTraceOn(traceDirectory);
+						} catch (Exception te ) {
+							consoleExceptionPrintTrace(te);
+							setTraceSuccessful = false;
+							session.setTraceOff();
+						}
 					else
 						session.setTraceOff();
 				}
+				if (setTraceSuccessful)
+					setTraceAll(on);
 			}
 		}
 		else
@@ -3375,14 +3388,20 @@
 			if (session != null)
 			{	
 				if (on)
-					session.setTraceOn(traceDirectory);
+					try {                         
+						session.setTraceOn(traceDirectory);
+					}catch (Exception te) {
+						consoleExceptionPrintTrace(te);
+						setTraceSuccessful = false;
+						session.setTraceOff();
+					}
 				else
 					session.setTraceOff();
 			}
 			else
 				return false;
 		}
-		return true;
+		return setTraceSuccessful;
 	}
 
 

Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/Session.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/Session.java?rev=592111&r1=592110&r2=592111&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/Session.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/Session.java Mon Nov  5 10:05:09
2007
@@ -123,31 +123,35 @@
 	 * initialize a server trace for the DRDA protocol
 	 * 
 	 * @param traceDirectory - directory for trace file
+	 * @throws IOException 
 	 */
-	protected void initTrace(String traceDirectory)
+	protected void initTrace(String traceDirectory) throws IOException 
 	{
 		if (traceDirectory != null)
 			traceFileName = traceDirectory + "/" + TRACENAME_PREFIX+
 				connNum+ TRACENAME_SUFFIX;
 		else
 			traceFileName = TRACENAME_PREFIX +connNum+ TRACENAME_SUFFIX;
-		traceOn = true;
+		
 		if (dssTrace == null)
 			dssTrace = new DssTrace();
 		dssTrace.startComBufferTrace (traceFileName);
+		traceOn = true;
 	}
 
 	/**
 	 * Set tracing on
 	 * 
 	 * @param traceDirectory 	directory for trace files
+	 * @throws IOException 
 	 */
-	protected void setTraceOn(String traceDirectory)
+	protected void setTraceOn(String traceDirectory) throws IOException
 	{
 		if (traceOn)
 			return;
-		initTrace(traceDirectory);
+		initTrace(traceDirectory);    
 	}
+
 	/**
 	 * Get whether tracing is on 
 	 *

Modified: db/derby/code/trunk/java/drda/org/apache/derby/loc/drda/messages_en.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/loc/drda/messages_en.properties?rev=592111&r1=592110&r2=592111&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/loc/drda/messages_en.properties (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/loc/drda/messages_en.properties Mon Nov
 5 10:05:09 2007
@@ -76,7 +76,8 @@
 DRDA_SQLWarning.I={0}
 DRDA_MissingValue.U=Missing required value for {0}.
 DRDA_InvalidPropVal.S=Invalid value for property, {0}, value: {1}.
-DRDA_SessionNotFound.U=Session, {0}, not found.
+DRDA_SessionNotFound.U=Session, {0}, not found or other error occurred starting tracing.
Check runtimeinfo for valid session numbers and derby error log for possible permission errors
or IO errors accesing the trace file.
+DRDA_ErrorStartingTracing.S=Error starting tracing. This can be caused by permission errors
or IO error accessing the trace directory. Check derby error log for details.
 DRDA_MaxThreadsChange.I=Max threads changed to {0}.
 DRDA_TimeSliceChange.I=Time slice changed to {0}.
 DRDA_InvalidValue.U=Invalid value, {0}, for {1}.

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java?rev=592111&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java
Mon Nov  5 10:05:09 2007
@@ -0,0 +1,173 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.functionTests.tests.derbynet.NetworkServerControlApiTest
+
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derbyTesting.functionTests.tests.derbynet;
+
+import org.apache.derby.drda.NetworkServerControl;
+import org.apache.derbyTesting.functionTests.tests.lang.SecurityPolicyReloadingTest;
+import org.apache.derbyTesting.functionTests.tests.lang.SimpleTest;
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.Derby;
+import org.apache.derbyTesting.junit.SecurityManagerSetup;
+import org.apache.derbyTesting.junit.SupportFilesSetup;
+import org.apache.derbyTesting.junit.TestConfiguration;
+
+import java.io.File;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class NetworkServerControlApiTest extends BaseJDBCTestCase {
+
+    private static String POLICY_FILE_NAME="functionTests/tests/derbynet/NetworkServerControlApiTest.policy";
+    private static String TARGET_POLICY_FILE_NAME="server.policy";
+    
+    public NetworkServerControlApiTest(String name) {
+        super(name);
+       
+    }
+
+    /** Test NetworkServerControl API.
+     *  Right now it tests only the trace command for DERBY-3110.
+     *  TODO: Add tests for other API calls.
+     */
+    
+    
+     /** 
+     * @throws Exception
+     */
+    public void testTraceCommands() throws Exception
+    {
+        NetworkServerControl nsctrl = new NetworkServerControl();
+        String derbySystemHome = getSystemProperty("derby.system.home");
+        nsctrl.setTraceDirectory(derbySystemHome);
+        nsctrl.trace(true);
+        nsctrl.ping();
+        assertTrue(fileExists(derbySystemHome+"/Server3.trace"));
+        nsctrl.trace(false);
+        
+        // now try on a directory where we don't have permission
+        // this won't actually cause a failure until we turn on tracing.
+        // assume we don't have permission to write to root.
+        nsctrl.setTraceDirectory("/");
+        
+        // attempt to turn on tracing to location where we don't have permisson
+        try {
+            nsctrl.trace(true);
+            fail("Should have gotten an exception turning on tracing");
+        } catch (Exception e) {
+            // expected exception
+        }
+        // make sure we can still ping
+        nsctrl.ping();
+    
+                        
+    }
+
+    private boolean fileExists(String filename) {
+        final File file = new File(filename);
+        try {
+            return ((Boolean)AccessController.doPrivileged(
+                new PrivilegedExceptionAction() {
+                    public Object run() throws SecurityException {
+                        return new Boolean(file.exists());
+                    }
+                })).booleanValue();
+        } catch (PrivilegedActionException pae) {
+            throw (SecurityException)pae.getException();
+        }
+        
+    }
+    
+    /**
+     * Construct the name of the server policy file.
+     */
+    private String makeServerPolicyName()
+    {
+        try {
+            String  userDir = getSystemProperty( "user.dir" );
+            String  fileName = userDir + File.separator + SupportFilesSetup.EXTINOUT + File.separator
+ TARGET_POLICY_FILE_NAME;
+            File      file = new File( fileName );
+            String  urlString = file.toURL().toExternalForm();
+
+            return urlString;
+        }
+        catch (Exception e)
+        {
+            System.out.println( "Unexpected exception caught by makeServerPolicyName(): "
+ e );
+
+            return null;
+        }
+    }
+    
+    
+    /**
+     * Add decorators to a test run. Context is established in the reverse order
+     * that decorators are declared here. That is, decorators compose in reverse
+     * order. The order of the setup methods is:
+     *
+     * <ul>
+     * <li>Copy security policy to visible location.</li>
+     * <li>Install a security manager.</li>
+     * <li>Run the tests.</li>
+     * </ul>
+     */
+    private static Test decorateTest()
+    {
+        
+        String serverPolicyName = new NetworkServerControlApiTest("test").makeServerPolicyName();
+        Test test = TestConfiguration.clientServerSuite(NetworkServerControlApiTest.class);
+        //
+        // Install a security manager using the initial policy file.
+        //
+        test = new SecurityManagerSetup( test,serverPolicyName );
+        
+        
+        //
+        // Copy over the policy file we want to use.
+        //
+        test = new SupportFilesSetup
+            (
+             test,
+             null,
+             new String[] { POLICY_FILE_NAME },
+             null,
+             new String[] { TARGET_POLICY_FILE_NAME}
+             );
+
+        return test;
+    }
+    
+    public static Test suite()
+    {
+        
+        TestSuite suite = new TestSuite("NetworkServerControlApiTest");
+        
+        // Need derbynet.jar in the classpath!
+        if (!Derby.hasServer())
+            return suite;
+        
+        return decorateTest();
+    }
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.policy
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.policy?rev=592111&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.policy
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.policy
Mon Nov  5 10:05:09 2007
@@ -0,0 +1,242 @@
+//
+// *  Derby - Class org.apache.derbyTesting.functionTests.tests.lang.SimpleTest
+// *  
+// * Licensed to the Apache Software Foundation (ASF) under one
+// * or more contributor license agreements.  See the NOTICE file
+// * distributed with this work for additional information
+// * regarding copyright ownership.  The ASF licenses this file
+// * to you under the Apache License, Version 2.0 (the
+// * "License"); you may not use this file except in compliance
+// * with the License.  You may obtain a copy of the License at
+// *
+// *   http://www.apache.org/licenses/LICENSE-2.0
+// *
+// * Unless required by applicable law or agreed to in writing,
+// * software distributed under the License is distributed on an
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// * KIND, either express or implied.  See the License for the
+// * specific language governing permissions and limitations
+// * under the License.
+// *
+
+//
+// Policy file with minimal set of permissions to run derby's
+// functional tests.
+//
+// The test harness sets up four variables used by this policy file
+//
+// derbyTesting.codejar - URL to the jar files when they are in the classpath
+// derbyTesting.codeclasses - URL to the classes directory when it is in the classpath
+//
+// Only one of derbyTesting.codejar and derbyTesting.codeclasses will be valid, the
+// other will be set to a bogus URL like file://unused
+//
+// derbyTesting.codedir - File location of either derbyTesting.codejar or derbyTesting.codeclasses.
+// Only required due to a BUG (see below for more info).
+//
+// derbyTesting.jaxpjar - URL to the jar file containing the JAXP implementation
+//     for XML-based tests (ex. lang/XMLBindingTest.java).
+//
+// derbyTesting.serverhost - Host name or ip where network server is started 
+// derbyTesting.clienthost - specifies the clients ip address/hostName. 
+//     when testing with networkserver on a remote host, this needs to be passed in 
+//     with the NetworkServerControl start command
+
+//
+// Permissions for the embedded engine (derby.jar)
+//
+grant codeBase "${derbyTesting.codejar}derby.jar" {
+  permission java.util.PropertyPermission "derby.*", "read";
+permission java.util.PropertyPermission "derby.storage.jvmInstanceId", 
+      "write"; 
+  permission java.util.PropertyPermission "java.class.path", "read";//sysinfo
+  
+  // unit tests (e.g. store/T_RecoverFullLog) set this property 
+  // (called from derbyTesting.jar through code in derby.jar)
+  permission java.util.PropertyPermission "derbyTesting.unittest.*", "write";
+
+  permission java.lang.RuntimePermission "createClassLoader";
+  permission java.security.SecurityPermission "getPolicy";
+  
+  permission java.io.FilePermission "${derby.system.home}${/}derby.properties", "read";
+  permission java.io.FilePermission "${derby.system.home}${/}derby.log", "read, write, delete";
+  // [DERBY-2000] The write permission was added to allow creation of the
+  // derby.system.home directory when running tests under a security manager.
+  permission java.io.FilePermission "${derby.system.home}", "read, write";
+  
+  // all databases under derby.system.home 
+  permission java.io.FilePermission "${derby.system.home}${/}-", "read, write, delete";
+
+  // Import/export and other support files from these locations in tests
+  permission java.io.FilePermission "${user.dir}${/}extin${/}-", "read";
+  permission java.io.FilePermission "${user.dir}${/}extinout${/}-", "read,  write, delete";
+  permission java.io.FilePermission "${user.dir}${/}extout${/}-", "read,write";
+  permission java.io.FilePermission "${user.dir}${/}extinout", "read,write";
+  
+  // These permissions are needed to load the JCE for encryption with Sun and IBM JDK131.
+  // JDK14 has the JCE  preloaded
+  permission java.security.SecurityPermission "insertProvider.SunJCE";
+  permission java.security.SecurityPermission "insertProvider.IBMJCE";
+ 
+};
+
+//
+// Permissions for the network server (derbynet.jar)
+//
+grant codeBase "${derbyTesting.codejar}derbynet.jar" {
+  permission java.util.PropertyPermission "java.class.path", "read";//sysinfo
+  
+  // accept is needed for the server accepting connections
+  // connect is needed for ping command (which is in the server jar)
+  permission java.net.SocketPermission "127.0.0.1", "accept,connect";
+  permission java.net.SocketPermission "localhost", "accept,connect";
+  permission java.net.SocketPermission "${derbyTesting.clienthost}", "accept,connect";
+  permission java.net.SocketPermission "${derbyTesting.serverhost}", "accept,connect";
+    //tracing testing. NetworkServerControlApiTest
+    permission java.io.FilePermission "${derby.system.home}", "write"; 
+    permission java.io.FilePermission "${derby.system.home}/-", "write"; 
+};
+
+//
+// Permissions for the network client (derbyclient.jar)
+//
+grant codeBase "${derbyTesting.clientjar}derbyclient.jar" {
+  permission java.net.SocketPermission "127.0.0.1", "connect,resolve";
+  permission java.net.SocketPermission "localhost", "connect,resolve";
+  permission java.net.SocketPermission "${derbyTesting.serverhost}", "connect,resolve";
+
+  // DERBY-1883: Since some classes that are included in both derby.jar and
+  // derbyclient.jar read properties, derbyclient.jar needs permission to read
+  // derby.* properties to avoid failures when it is listed before derby.jar in
+  // the classpath.
+  permission java.util.PropertyPermission "derby.*", "read";
+
+  // DERBY-2302: derbyclient.jar needs to be able to read the user.dir property in order
to
+  // do tracing in that directory. Also, it needs read/write permissions in user.dir in order
+  // to create the trace files in that directory.
+  permission java.util.PropertyPermission "user.dir", "read";
+  permission java.io.FilePermission "${user.dir}${/}-", "read, write"; 
+
+};
+
+//
+// Permissions for the tools (derbytools.jar)
+// Ideally this would be more secure, for now the
+// focus is on getting the engine & network server secure.
+//
+grant codeBase "${derbyTesting.codejar}derbytools.jar" {
+  // Access all properties using System.getProperties -
+  // ij enumerates the properties in order to open connections
+  // for any property set in ij.connection.* and set protocols
+  // for any property in ij.protocol.*
+  permission java.util.PropertyPermission "*", "read, write";
+  
+  // Read all files under ${user.dir}
+  permission java.io.FilePermission "${user.dir}${/}-", "read";
+  
+  // IjTestCases read, write, and delete ij's output in the extinout dir
+  permission java.io.FilePermission "${user.dir}${/}extinout${/}-", "read, write, delete";
+ 
+  // ij needs permission to read the sql files in this jar
+  permission java.io.FilePermission "${derbyTesting.testjarpath}", "read";
+  
+};
+
+//
+// Permissions for the tests (derbyTesting.jar)
+// We are liberal here, it's not a goal to make the test harness
+// or tests secure.
+//
+grant codeBase "${derbyTesting.testjar}derbyTesting.jar" {
+  // Access all properties using System.getProperties
+  permission java.util.PropertyPermission "*", "read, write";
+  
+  // Access all files under ${user.dir}to write the test directory structure
+  permission java.io.FilePermission "${user.dir}${/}-", "read,write,delete"; 
+
+  // When running with useprocess=false need to install and uninstall
+  // the security manager and allow setIO to change the system err and out
+  // streams. Currently the nist suite runs with useprocess=false.
+  permission java.lang.RuntimePermission "setSecurityManager";
+  permission java.lang.RuntimePermission "setIO"; 
+};
+
+//
+// super-set of the jar permissions for running out of the classes directory
+//
+grant codeBase "${derbyTesting.codeclasses}" {
+  // Access all properties using System.getProperties
+  permission java.util.PropertyPermission "*", "read, write";
+  
+  permission java.util.PropertyPermission "derby.*", "read";
+  permission java.lang.RuntimePermission "createClassLoader";
+  permission java.security.SecurityPermission "getPolicy";
+   
+  permission java.io.FilePermission "${derby.system.home}${/}derby.properties", "read";
+  permission java.io.FilePermission "${derby.system.home}${/}derby.log", "read, write, delete";
+  permission java.io.FilePermission "${derby.system.home}", "read";
+  permission java.io.FilePermission "${derby.system.home}${/}-", "read, write, delete";
+
+  // combination of client and server side.
+  permission java.net.SocketPermission "127.0.0.1", "accept,connect,resolve";
+  permission java.net.SocketPermission "localhost", "accept,connect,resolve";
+  permission java.net.SocketPermission "${derbyTesting.clienthost}", "accept,connect";
+  permission java.net.SocketPermission "${derbyTesting.serverhost}", "connect,resolve";
+  
+  // Access all files under ${user.dir}to write the test directory structure
+  // Also covers extin, extout and extinout locations
+  permission java.io.FilePermission "${user.dir}${/}-", "read,write,delete"; 
+    
+  // These permissions are needed to load the JCE for encryption with Sun and IBM JDK131.
+  // JDK14 has the JCE  preloaded
+  permission java.security.SecurityPermission "insertProvider.SunJCE";
+  permission java.security.SecurityPermission "insertProvider.IBMJCE";
+
+  // When running with useprocess=false need to install and uninstall
+  // the security manager and allow setIO to change the system err and out
+  // streams. Currently the nist suite runs with useprocess=false.
+  permission java.lang.RuntimePermission "setSecurityManager";
+  permission java.lang.RuntimePermission "setIO"; 
+};
+
+// JUnit jar file tries to read junit.properties in the user's
+// home directory and seems to require permission to read the
+// property user.home as well.
+// junit.swingui.TestRunner writes to .junitsession on exit.
+grant codeBase "${derbyTesting.junit}" {
+    permission java.util.PropertyPermission "user.home", "read";
+    permission java.io.FilePermission "${user.home}${/}junit.properties", "read";
+    permission java.io.FilePermission "${user.home}${/}.junitsession", "write";
+};
+
+// Due to a problem running tests/derbynet/CompatibilityTest in the old test
+// harness, permission to read junit.properties is granted to all. This can be 
+// removed when CompatibilityTest is rewritten to conform to our current Junit
+// usage. See DERBY-2076.
+grant {
+    permission java.io.FilePermission "${user.home}${/}junit.properties", "read";
+};
+
+// Ant's junit runner requires setOut to redirect the System output streams
+// to the forked JVM used when running junit tests inside Ant. Ant requires
+// forking the JVM if you want to run tests in a different directory than the
+// current one.
+grant codeBase "${derbyTesting.antjunit}" {
+    permission java.lang.RuntimePermission "setIO";
+};
+
+// functionTests.tests.lang.RoutineSecurityTest requires this grant
+// to check to see if permissions are granted through generated code
+// through this mechanism.
+grant {
+    permission java.util.PropertyPermission "derbyRoutineSecurityTest.yes", "read";
+};
+
+// When inserting XML values that use external DTD's, the JAXP parser
+// needs permission to read the DTD files.  We assume that all DTD
+// files will be copied to extin/ by whichever tests need them.  So
+// grant the JAXP parser permissions to read that directory.
+grant codeBase "${derbyTesting.jaxpjar}" {
+  permission java.io.FilePermission "${user.dir}${/}extin${/}-", "read";
+};
+

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.policy
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/_Suite.java?rev=592111&r1=592110&r2=592111&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/_Suite.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/_Suite.java
Mon Nov  5 10:05:09 2007
@@ -45,7 +45,8 @@
     public static Test suite() {
 
         TestSuite suite = new TestSuite("derbynet");
-             
+        
+        suite.addTest(NetworkServerControlApiTest.suite());     
         suite.addTest(PrepareStatementTest.suite());
         suite.addTest(ShutDownDBWhenNSShutsDownTest.suite());
         suite.addTest(DRDAProtocolTest.suite());
@@ -55,6 +56,7 @@
         suite.addTest(SecureServerTest.suite());
         suite.addTest(SSLTest.suite());
         suite.addTest(NetIjTest.suite());
+        
         
         // Disabled due to "java.sql.SQLSyntaxErrorException: The class
         // 'org.apache.derbyTesting.functionTests.tests.derbynet.checkSecMgr'



Mime
View raw message