Blame SOURCES/pr3655-toggle_system_crypto_policy.patch

ecab97
# HG changeset patch
ecab97
# User andrew
ecab97
# Date 1545198926 0
ecab97
#      Wed Dec 19 05:55:26 2018 +0000
ecab97
# Node ID f2cbd688824c128db7fa848c8732fb0ab3507776
ecab97
# Parent  81f07f6d1f8b7b51b136d3974c61bc8bb513770c
ecab97
PR3655: Allow use of system crypto policy to be disabled by the user
ecab97
Summary: Read user overrides first so security.useSystemPropertiesFile can be disabled and add -Djava.security.disableSystemPropertiesFile
ecab97
ecab97
diff --git a/src/share/classes/javopenjdk.orig/jdk/security/Security.java openjdk/jdk/src/share/classes/java/security/Security.java
ecab97
--- openjdk.orig/jdk/src/share/classes/java/security/Security.java
ecab97
+++ openjdk/jdk/src/share/classes/java/security/Security.java
ecab97
@@ -122,31 +122,6 @@
ecab97
         }
ecab97
 
ecab97
         if ("true".equalsIgnoreCase(props.getProperty
ecab97
-                ("security.useSystemPropertiesFile"))) {
ecab97
-
ecab97
-            // now load the system file, if it exists, so its values
ecab97
-            // will win if they conflict with the earlier values
ecab97
-            try (BufferedInputStream bis =
ecab97
-                 new BufferedInputStream(new FileInputStream(SYSTEM_PROPERTIES))) {
ecab97
-                props.load(bis);
ecab97
-                loadedProps = true;
ecab97
-
ecab97
-                if (sdebug != null) {
ecab97
-                    sdebug.println("reading system security properties file " +
ecab97
-                                   SYSTEM_PROPERTIES);
ecab97
-                    sdebug.println(props.toString());
ecab97
-                }
ecab97
-            } catch (IOException e) {
ecab97
-                if (sdebug != null) {
ecab97
-                    sdebug.println
ecab97
-                        ("unable to load security properties from " +
ecab97
-                         SYSTEM_PROPERTIES);
ecab97
-                    e.printStackTrace();
ecab97
-                }
ecab97
-            }
ecab97
-        }
ecab97
-
ecab97
-        if ("true".equalsIgnoreCase(props.getProperty
ecab97
                 ("security.overridePropertiesFile"))) {
ecab97
 
ecab97
             String extraPropFile = System.getProperty
ecab97
@@ -212,6 +187,33 @@
ecab97
             }
ecab97
         }
ecab97
 
ecab97
+        String disableSystemProps = System.getProperty("java.security.disableSystemPropertiesFile");
ecab97
+        if (disableSystemProps == null &&
ecab97
+            "true".equalsIgnoreCase(props.getProperty
ecab97
+                ("security.useSystemPropertiesFile"))) {
ecab97
+
ecab97
+            // now load the system file, if it exists, so its values
ecab97
+            // will win if they conflict with the earlier values
ecab97
+            try (BufferedInputStream bis =
ecab97
+                 new BufferedInputStream(new FileInputStream(SYSTEM_PROPERTIES))) {
ecab97
+                props.load(bis);
ecab97
+                loadedProps = true;
ecab97
+
ecab97
+                if (sdebug != null) {
ecab97
+                    sdebug.println("reading system security properties file " +
ecab97
+                                   SYSTEM_PROPERTIES);
ecab97
+                    sdebug.println(props.toString());
ecab97
+                }
ecab97
+            } catch (IOException e) {
ecab97
+                if (sdebug != null) {
ecab97
+                    sdebug.println
ecab97
+                        ("unable to load security properties from " +
ecab97
+                         SYSTEM_PROPERTIES);
ecab97
+                    e.printStackTrace();
ecab97
+                }
ecab97
+            }
ecab97
+        }
ecab97
+
ecab97
         if (!loadedProps) {
ecab97
             initializeStatic();
ecab97
             if (sdebug != null) {