mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8066709: Make some JDK system properties read only
Reviewed-by: lancea, sundar, bchristi, weijun, mchung, alanb, mullan
This commit is contained in:
parent
cad47f4a03
commit
4098f2560a
25 changed files with 215 additions and 46 deletions
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue