Blame SOURCES/pr3695-toggle_system_crypto_policy.patch

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