Blame SOURCES/pr3695-toggle_system_crypto_policy.patch

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