db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r1177718 - /db/derby/code/trunk/java/drda/org/apache/derby/drda/NetworkServerControl.java
Date Fri, 30 Sep 2011 16:12:59 GMT
Author: dag
Date: Fri Sep 30 16:12:58 2011
New Revision: 1177718

URL: http://svn.apache.org/viewvc?rev=1177718&view=rev
Log:
DERBY-5363 Tighten default permissions of DB files with >= JDK6

Patch derby-5363-followup, which adds a missing accessController block
around setting the system property
SERVER_STARTED_FROM_CMD_LINE. Without the patch, this would fail if
running with a security manager specified on the command
line. 

If the property permission is missing, the error is printed
unconditionally and exit(1) from main is taken. Cf. DERBY-5413 which
tried another (aborted) approach to make sure it got printed.


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=1177718&r1=1177717&r2=1177718&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 Fri Sep
30 16:12:58 2011
@@ -25,6 +25,8 @@ import java.io.PrintWriter;
 import java.net.InetAddress;
 import java.net.Inet6Address;
 import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
 import java.util.Properties;
 import org.apache.derby.iapi.reference.Property;
 import org.apache.derby.iapi.services.property.PropertyUtil;
@@ -303,8 +305,18 @@ public class NetworkServerControl{
             int     command = server.parseArgs( args );
 
             if (command == NetworkServerControlImpl.COMMAND_START) {
-                System.setProperty(Property.SERVER_STARTED_FROM_CMD_LINE,
-                                   "true");
+                try {
+                    AccessController.doPrivileged(new PrivilegedExceptionAction() {
+                            public Object run() throws Exception {
+                                System.setProperty(
+                                    Property.SERVER_STARTED_FROM_CMD_LINE,
+                                    "true");
+                                return null;
+                            }});
+                } catch (Exception e) {
+                    server.consoleExceptionPrintTrace(e);
+                    System.exit(1);
+                }
             }
 
             //



Mime
View raw message