Permission Analysis Report
Analysis of: org.eclipse.core.runtime
Detail
Class: org.eclipse.core.internal.preferences.InstancePreferences (Application)
DoPrivileged location: Line# 109 void loadLegacy( )
Permission: java.io.FilePermission "???file???", "read"
Primordial/boolean java.io.File.exists( )
CODE
/**
* Load the Eclipse 2.1 preferences for the given bundle. If a file
* doesn't exist then assume that conversion has already occurred
* and do nothing.
*/
protected void loadLegacy() {
IPath path = new Path(absolutePath());
if (path.segmentCount() != 2)
return;
// If we are running with -data=@none we won't have an instance location.
if (Platform.getInstanceLocation() == null) {
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("Cannot load Legacy plug-in preferences since instance location is not set."); //$NON-NLS-1$
return;
}
String bundleName = path.segment(1);
// the preferences file is located in the plug-in's state area at a well-known name
// don't need to create the directory if there are no preferences to load
File prefFile = null;
Location instanceLocation = Platform.getInstanceLocation();
if (instanceLocation != null && instanceLocation.isSet())
prefFile = InternalPlatform.getDefault().getMetaArea().getPreferenceLocation(bundleName, false).toFile();
if (prefFile == null) {
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("Cannot load legacy values because instance location is not set."); //$NON-NLS-1$
return;
}
if (!prefFile.exists()) {
// no preference file - that's fine
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("Legacy plug-in preference file not found: " + prefFile); //$NON-NLS-1$
return;
}
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("Loading legacy preferences from " + prefFile); //$NON-NLS-1$
// load preferences from file
InputStream input = null;
Properties values = new Properties();
try {
input = new BufferedInputStream(new FileInputStream(prefFile));
values.load(input);
} catch (IOException e) {
// problems loading preference store - quietly ignore
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("IOException encountered loading legacy preference file " + prefFile); //$NON-NLS-1$
return;
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
// ignore problems with close
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL) {
Policy.debug("IOException encountered closing legacy preference file " + prefFile); //$NON-NLS-1$
e.printStackTrace();
}
}
}
}
// Store values in the preferences object
for (Iterator i = values.keySet().iterator(); i.hasNext();) {
String key = (String) i.next();
String value = values.getProperty(key);
// value shouldn't be null but check just in case...
if (value != null) {
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("Loaded legacy preference: " + key + " -> " + value); //$NON-NLS-1$ //$NON-NLS-2$
// call these 2 methods rather than #put() so we don't send out unnecessary notification
Object oldValue = internalPut(key, value);
if (!value.equals(oldValue))
makeDirty();
}
}
// Delete the old file so we don't try and load it next time.
if (!prefFile.delete())
//Only print out message in failure case if we are debugging.
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("Unable to delete legacy preferences file: " + prefFile); //$NON-NLS-1$
}
Tainted variable reference trace:
Permission Requirements:
- permission java.io.FilePermission "???file???", "read";
Conclusion:
By default, each plug-in should have the read or write permission to the meta area dir, by adding the read/write permission to the meta dir for each plug-in.
This can be accomplished by modifying the create protection domain when loading bundles as shown in the following:
protected BundleProtectionDomain createProtectionDomain(AbstractBundle bundle) {
BundlePermissionCollection implied = getImpliedPermissions(bundle);
// find out the data directory and grant each plug-in w/ all rights on the directory
Location loc = LocationManager.getInstanceLocation();
if(loc != null) {
implied.add(new FilePermission(new File(loc.getURL().getFile()) + File.separator + "-", "read,write,delete"));
}
BundleCombinedPermissions combined = new BundleCombinedPermissions(implied);
BundlePermissionCollection assigned = getAssignedPermissions(bundle);
combined.setAssignedPermissions(assigned, assigned == defaultAssignedPermissions);
combined.setConditionalPermissions(new ConditionalPermissions(bundle, framework.condPermAdmin));
/* now process the permissions.perm file, if it exists, and build the
* restrictedPermissions using it. */
URL u = bundle.getEntry("OSGI-INF/permissions.perm"); //$NON-NLS-1$
if (u != null) {
try {
DataInputStream dis = new DataInputStream(u.openStream());
String line;
Vector piList = new Vector();
while ((line = dis.readLine()) != null) {
line = line.trim();
if (line.startsWith("#") || line.startsWith("//") || line.length() == 0) //$NON-NLS-1$//$NON-NLS-2$
continue;
try {
PermissionInfo pi = new PermissionInfo(line);
piList.add(pi);
} catch (Exception e) {
// Right now we just eat any exception that happens when
// parsing the PermissionInfo
framework.publishFrameworkEvent(FrameworkEvent.ERROR, bundle, e);
}
}
ConditionalPermissionInfoImpl cpiArray[] = new ConditionalPermissionInfoImpl[1];
cpiArray[0] = new ConditionalPermissionInfoImpl(null, new ConditionInfo[0], (PermissionInfo[]) piList.toArray(new PermissionInfo[0]));
ConditionalPermissionSet cps = new ConditionalPermissionSet(cpiArray, new Condition[0]);
combined.setRestrictedPermissions(cps);
} catch (IOException e) {
// TODO What do we do here? The fact that we got the URL indicates that
// the file exists, but now we can't read it for some reason...
framework.publishFrameworkEvent(FrameworkEvent.ERROR, bundle, e);
}
}
return new BundleProtectionDomainImpl(bundle, combined);
}
DoPrivileged location: Line# 123 void loadLegacy( )
Permission: java.io.FilePermission "???file???", "read"
Primordial/void java.io.FileInputStream.FileInputStream( java.io.File )
CODE
/**
* Load the Eclipse 2.1 preferences for the given bundle. If a file
* doesn't exist then assume that conversion has already occurred
* and do nothing.
*/
protected void loadLegacy() {
IPath path = new Path(absolutePath());
if (path.segmentCount() != 2)
return;
// If we are running with -data=@none we won't have an instance location.
if (Platform.getInstanceLocation() == null) {
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("Cannot load Legacy plug-in preferences since instance location is not set."); //$NON-NLS-1$
return;
}
String bundleName = path.segment(1);
// the preferences file is located in the plug-in's state area at a well-known name
// don't need to create the directory if there are no preferences to load
File prefFile = null;
Location instanceLocation = Platform.getInstanceLocation();
if (instanceLocation != null && instanceLocation.isSet())
prefFile = InternalPlatform.getDefault().getMetaArea().getPreferenceLocation(bundleName, false).toFile();
if (prefFile == null) {
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("Cannot load legacy values because instance location is not set."); //$NON-NLS-1$
return;
}
if (!prefFile.exists()) {
// no preference file - that's fine
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("Legacy plug-in preference file not found: " + prefFile); //$NON-NLS-1$
return;
}
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("Loading legacy preferences from " + prefFile); //$NON-NLS-1$
// load preferences from file
InputStream input = null;
Properties values = new Properties();
try {
input = new BufferedInputStream(new FileInputStream(prefFile));
values.load(input);
} catch (IOException e) {
// problems loading preference store - quietly ignore
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("IOException encountered loading legacy preference file " + prefFile); //$NON-NLS-1$
return;
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
// ignore problems with close
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL) {
Policy.debug("IOException encountered closing legacy preference file " + prefFile); //$NON-NLS-1$
e.printStackTrace();
}
}
}
}
// Store values in the preferences object
for (Iterator i = values.keySet().iterator(); i.hasNext();) {
String key = (String) i.next();
String value = values.getProperty(key);
// value shouldn't be null but check just in case...
if (value != null) {
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("Loaded legacy preference: " + key + " -> " + value); //$NON-NLS-1$ //$NON-NLS-2$
// call these 2 methods rather than #put() so we don't send out unnecessary notification
Object oldValue = internalPut(key, value);
if (!value.equals(oldValue))
makeDirty();
}
}
// Delete the old file so we don't try and load it next time.
if (!prefFile.delete())
//Only print out message in failure case if we are debugging.
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("Unable to delete legacy preferences file: " + prefFile); //$NON-NLS-1$
}
Tainted variable reference trace:
Permission Requirements:
- permission java.io.FilePermission "???file???", "read";
Conclusion:
See prior conclusion.
DoPrivileged location: Line# 124 void loadLegacy( )
Permission: java.util.PropertyPermission "java.vendor.url.bug", "read"
Primordial/void java.util.Properties.load( java.io.InputStream )
CODE
/**
* Load the Eclipse 2.1 preferences for the given bundle. If a file
* doesn't exist then assume that conversion has already occurred
* and do nothing.
*/
protected void loadLegacy() {
IPath path = new Path(absolutePath());
if (path.segmentCount() != 2)
return;
// If we are running with -data=@none we won't have an instance location.
if (Platform.getInstanceLocation() == null) {
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("Cannot load Legacy plug-in preferences since instance location is not set."); //$NON-NLS-1$
return;
}
String bundleName = path.segment(1);
// the preferences file is located in the plug-in's state area at a well-known name
// don't need to create the directory if there are no preferences to load
File prefFile = null;
Location instanceLocation = Platform.getInstanceLocation();
if (instanceLocation != null && instanceLocation.isSet())
prefFile = InternalPlatform.getDefault().getMetaArea().getPreferenceLocation(bundleName, false).toFile();
if (prefFile == null) {
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("Cannot load legacy values because instance location is not set."); //$NON-NLS-1$
return;
}
if (!prefFile.exists()) {
// no preference file - that's fine
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("Legacy plug-in preference file not found: " + prefFile); //$NON-NLS-1$
return;
}
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("Loading legacy preferences from " + prefFile); //$NON-NLS-1$
// load preferences from file
InputStream input = null;
Properties values = new Properties();
try {
input = new BufferedInputStream(new FileInputStream(prefFile));
values.load(input);
} catch (IOException e) {
// problems loading preference store - quietly ignore
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("IOException encountered loading legacy preference file " + prefFile); //$NON-NLS-1$
return;
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
// ignore problems with close
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL) {
Policy.debug("IOException encountered closing legacy preference file " + prefFile); //$NON-NLS-1$
e.printStackTrace();
}
}
}
}
// Store values in the preferences object
for (Iterator i = values.keySet().iterator(); i.hasNext();) {
String key = (String) i.next();
String value = values.getProperty(key);
// value shouldn't be null but check just in case...
if (value != null) {
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("Loaded legacy preference: " + key + " -> " + value); //$NON-NLS-1$ //$NON-NLS-2$
// call these 2 methods rather than #put() so we don't send out unnecessary notification
Object oldValue = internalPut(key, value);
if (!value.equals(oldValue))
makeDirty();
}
}
// Delete the old file so we don't try and load it next time.
if (!prefFile.delete())
//Only print out message in failure case if we are debugging.
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("Unable to delete legacy preferences file: " + prefFile); //$NON-NLS-1$
}
Tainted variable reference trace:
Permission Requirements:
- permission java.util.PropertyPermission "java.vendor.url.bug", "read";
Conclusion:
See prior conclusion.
DoPrivileged location: Line# 160 void loadLegacy( )
Permission: java.io.FilePermission "???file???", "delete"
Primordial/boolean java.io.File.delete( )
CODE
/**
* Load the Eclipse 2.1 preferences for the given bundle. If a file
* doesn't exist then assume that conversion has already occurred
* and do nothing.
*/
protected void loadLegacy() {
IPath path = new Path(absolutePath());
if (path.segmentCount() != 2)
return;
// If we are running with -data=@none we won't have an instance location.
if (Platform.getInstanceLocation() == null) {
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("Cannot load Legacy plug-in preferences since instance location is not set."); //$NON-NLS-1$
return;
}
String bundleName = path.segment(1);
// the preferences file is located in the plug-in's state area at a well-known name
// don't need to create the directory if there are no preferences to load
File prefFile = null;
Location instanceLocation = Platform.getInstanceLocation();
if (instanceLocation != null && instanceLocation.isSet())
prefFile = InternalPlatform.getDefault().getMetaArea().getPreferenceLocation(bundleName, false).toFile();
if (prefFile == null) {
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("Cannot load legacy values because instance location is not set."); //$NON-NLS-1$
return;
}
if (!prefFile.exists()) {
// no preference file - that's fine
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("Legacy plug-in preference file not found: " + prefFile); //$NON-NLS-1$
return;
}
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("Loading legacy preferences from " + prefFile); //$NON-NLS-1$
// load preferences from file
InputStream input = null;
Properties values = new Properties();
try {
input = new BufferedInputStream(new FileInputStream(prefFile));
values.load(input);
} catch (IOException e) {
// problems loading preference store - quietly ignore
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("IOException encountered loading legacy preference file " + prefFile); //$NON-NLS-1$
return;
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
// ignore problems with close
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL) {
Policy.debug("IOException encountered closing legacy preference file " + prefFile); //$NON-NLS-1$
e.printStackTrace();
}
}
}
}
// Store values in the preferences object
for (Iterator i = values.keySet().iterator(); i.hasNext();) {
String key = (String) i.next();
String value = values.getProperty(key);
// value shouldn't be null but check just in case...
if (value != null) {
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("Loaded legacy preference: " + key + " -> " + value); //$NON-NLS-1$ //$NON-NLS-2$
// call these 2 methods rather than #put() so we don't send out unnecessary notification
Object oldValue = internalPut(key, value);
if (!value.equals(oldValue))
makeDirty();
}
}
// Delete the old file so we don't try and load it next time.
if (!prefFile.delete())
//Only print out message in failure case if we are debugging.
if (InternalPlatform.DEBUG_PREFERENCE_GENERAL)
Policy.debug("Unable to delete legacy preferences file: " + prefFile); //$NON-NLS-1$
}
Tainted variable reference trace:
Permission Requirements:
- permission java.io.FilePermission "???file???", "delete";
Conclusion:
See prior conclusion.