8066709: Make some JDK system properties read only

Reviewed-by: lancea, sundar, bchristi, weijun, mchung, alanb, mullan
This commit is contained in:
Roger Riggs 2018-06-27 09:36:34 -04:00
parent cad47f4a03
commit 4098f2560a
25 changed files with 215 additions and 46 deletions

View file

@ -24,6 +24,8 @@
*/
package sun.net.www;
import jdk.internal.util.StaticProperty;
import java.io.*;
import java.net.FileNameMap;
import java.util.Hashtable;
@ -53,7 +55,7 @@ public class MimeTable implements FileNameMap {
mailcapLocations = new String[] {
System.getProperty("user.mailcap"),
System.getProperty("user.home") + "/.mailcap",
StaticProperty.userHome() + "/.mailcap",
"/etc/mailcap",
"/usr/etc/mailcap",
"/usr/local/etc/mailcap",
@ -384,7 +386,12 @@ public class MimeTable implements FileNameMap {
Properties properties = getAsProperties();
properties.put("temp.file.template", tempFileTemplate);
String tag;
String user = System.getProperty("user.name");
// Perform the property security check for user.name
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPropertyAccess("user.name");
}
String user = StaticProperty.userName();
if (user != null) {
tag = "; customized for " + user;
properties.store(os, filePreamble + tag);

View file

@ -30,6 +30,8 @@ import java.net.InetAddress;
import java.net.SocketPermission;
import java.io.*;
import java.security.Permission;
import jdk.internal.util.StaticProperty;
import sun.net.www.*;
import sun.net.smtp.SmtpClient;
import sun.net.www.ParseUtil;
@ -65,7 +67,12 @@ public class MailToURLConnection extends URLConnection {
String getFromAddress() {
String str = System.getProperty("user.fromaddr");
if (str == null) {
str = System.getProperty("user.name");
// Perform the property security check for user.name
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPropertyAccess("user.name");
}
str = StaticProperty.userName();
if (str != null) {
String host = System.getProperty("mail.host");
if (host == null) {