Blame SOURCES/pr3695-toggle_system_crypto_policy.patch

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