Blame SOURCES/pr3695-toggle_system_crypto_policy.patch

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