Blame SOURCES/pr3695-toggle_system_crypto_policy.patch

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