Blame SOURCES/pr3695-toggle_system_crypto_policy.patch

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