Blame SOURCES/pr3695-toggle_system_crypto_policy.patch

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