Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMykola Nikishov2019-05-13 09:43:21 +0000
committerMykola Nikishov2019-05-14 16:58:56 +0000
commit79b28df3f0c7b68970e2fe6bc9eddddab436df4f (patch)
tree5a33d6f3546b5f115ace8819c836046147257896
parentad50f2e8ccbef7ce82fe7ed343d2ae194575f687 (diff)
downloadrt.equinox.framework-79b28df3f0c7b68970e2fe6bc9eddddab436df4f.tar.gz
rt.equinox.framework-79b28df3f0c7b68970e2fe6bc9eddddab436df4f.tar.xz
rt.equinox.framework-79b28df3f0c7b68970e2fe6bc9eddddab436df4f.zip
Bug 547265 - Fine-grained merging properties in launcher's MainI20190515-0205
Merging configuration and extension properties with system properties in mergeProperties uses System's getProperties and requires ("java.util.PropertyPermission" "*" "read,write") permission even if we are not actually going to modify any of these. Instead, use more fine-grained approach and set individual properties explicitly with System's setProperty. If/when AccessControlException occurs, it would provide more specific error message like: java.security.AccessControlException: access denied ("java.util.PropertyPermission" "eclipse.exitcode" "write") Also rename mergeProperties to mergeWithSystemProperties. Change-Id: I46bb6d539c58cc3dcff3a70dc2dc8544fc0ea7db Signed-off-by: Mykola Nikishov <mn@mn.com.ua>
-rw-r--r--bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java26
1 files changed, 13 insertions, 13 deletions
diff --git a/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java b/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java
index b1661f82a..22b0bd520 100644
--- a/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java
+++ b/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java
@@ -867,7 +867,7 @@ public class Main {
for (int j = 0; j < entries.length; j++)
qualifiedPath += ", " + FILE_SCHEME + path + entries[j]; //$NON-NLS-1$
extensionProperties.put(PROP_CLASSPATH, qualifiedPath);
- mergeProperties(System.getProperties(), extensionProperties, null);
+ mergeWithSystemProperties(extensionProperties, null);
if (inDevelopmentMode) {
String name = extensions[i];
if (name.startsWith(REFERENCE_SCHEME)) {
@@ -1840,7 +1840,7 @@ public class Main {
if (configuration != null && "false".equalsIgnoreCase(configuration.getProperty(PROP_CONFIG_CASCADED))) { //$NON-NLS-1$
System.clearProperty(PROP_SHARED_CONFIG_AREA);
configuration.remove(PROP_SHARED_CONFIG_AREA);
- mergeProperties(System.getProperties(), configuration, null);
+ mergeWithSystemProperties(configuration, null);
} else {
ensureAbsolute(PROP_SHARED_CONFIG_AREA);
URL sharedConfigURL = buildLocation(PROP_SHARED_CONFIG_AREA, null, ""); //$NON-NLS-1$
@@ -1858,7 +1858,7 @@ public class Main {
// - remove the property to show that we do not have a parent
// - merge configuration with the system properties
System.clearProperty(PROP_SHARED_CONFIG_AREA);
- mergeProperties(System.getProperties(), configuration, null);
+ mergeWithSystemProperties(configuration, null);
} else {
// if the parent we are about to read is the same as the base config we read above,
// just reuse the base
@@ -1873,14 +1873,14 @@ public class Main {
//merge user configuration since the base has not changed.
if (lastKnownBaseTimestamp == sharedConfigTimestamp || lastKnownBaseTimestamp == NO_TIMESTAMP) {
- mergeProperties(System.getProperties(), configuration, null);
+ mergeWithSystemProperties(configuration, null);
} else {
configuration = null;
System.setProperty(PROP_IGNORE_USER_CONFIGURATION, Boolean.TRUE.toString());
}
//now merge the base configuration
- mergeProperties(System.getProperties(), sharedConfiguration, configuration);
+ mergeWithSystemProperties(sharedConfiguration, configuration);
System.setProperty(PROP_SHARED_CONFIG_AREA, sharedConfigURL.toExternalForm());
if (debug)
System.out.println("Shared configuration location:\n " + sharedConfigURL.toExternalForm()); //$NON-NLS-1$
@@ -2524,20 +2524,20 @@ public class Main {
}
}
- private void mergeProperties(Properties destination, Properties source, Properties userConfiguration) {
+ private void mergeWithSystemProperties(Properties source, Properties userConfiguration) {
final String EXT_OVERRIDE_USER = ".override.user"; //$NON-NLS-1$
- if (destination == null || source == null)
+ if (source == null)
return;
for (Enumeration<?> e = source.keys(); e.hasMoreElements();) {
String key = (String) e.nextElement();
if (key.equals(PROP_CLASSPATH)) {
- String destinationClasspath = destination.getProperty(PROP_CLASSPATH);
+ String destinationClasspath = System.getProperty(PROP_CLASSPATH);
String sourceClasspath = source.getProperty(PROP_CLASSPATH);
if (destinationClasspath == null)
destinationClasspath = sourceClasspath;
else
destinationClasspath = destinationClasspath + sourceClasspath;
- destination.put(PROP_CLASSPATH, destinationClasspath);
+ System.setProperty(PROP_CLASSPATH, destinationClasspath);
continue;
}
String value = source.getProperty(key);
@@ -2548,18 +2548,18 @@ public class Main {
if (userConfiguration != null && !key.endsWith(EXT_OVERRIDE_USER)) {
// check all levels to see if the "override" property was set
final String overrideKey = key + EXT_OVERRIDE_USER;
- boolean shouldOverride = destination.getProperty(overrideKey) != null || source.getProperty(overrideKey) != null;
+ boolean shouldOverride = System.getProperty(overrideKey) != null || source.getProperty(overrideKey) != null;
// only set the value if the user specified the override property and if the
// original property wasn't set by a commad-line arg
if (shouldOverride && !userConfiguration.contains(key)) {
- destination.put(key, value);
+ System.setProperty(key, value);
continue;
}
}
// only set the value if it doesn't already exist to preserve ordering (command-line, user config, shared config)
- if (destination.getProperty(key) == null)
- destination.put(key, value);
+ if (System.getProperty(key) == null)
+ System.setProperty(key, value);
}
}

Back to the top