Blame SOURCES/pr3695-toggle_system_crypto_policy.patch

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