Blame SOURCES/pr3695-toggle_system_crypto_policy.patch

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