Blame SOURCES/pr3695-toggle_system_crypto_policy.patch

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