You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Andrew Cornwall <an...@gmail.com> on 2008/08/06 22:59:56 UTC
doPrivileged needed on many loadLibrary calls?
I've been looking through the Harmony code and have run into a number of
cases where loadLibrary() is called without recourse to an
AccessController.doPrivileged() operation. It seems as if a number of places
just get lucky with the security manager. Is there any reason not to
replace:
static {
System.loadLibrary("hyfoo"); //$NON-NLS-1$
}
with:
static {
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
System.loadLibrary("hyfoo"); //$NON-NLS-1$
return null;
}
});
}
Some of the files are in java.* packages, so they have to be on the bootpath
- which means wrapping them might not make sense. But others (like
PSPrinterJob and RandomBitsSupplier) are in org.apache.harmony.*, and might
not necessarily be on the bootpath for all consumers of Harmony classes.
Any thoughts?
Andrew Jr.
Re: doPrivileged needed on many loadLibrary calls?
Posted by Nathan Beyer <nd...@apache.org>.
Seems reasonable, especially for the non-'java.*' code. I'd replace the
PrivilegedAction type variable 'Object' with 'Void'.
Post some patches to JIRA.
-Nathan
On Wed, Aug 6, 2008 at 3:59 PM, Andrew Cornwall <an...@gmail.com>wrote:
> I've been looking through the Harmony code and have run into a number of
> cases where loadLibrary() is called without recourse to an
> AccessController.doPrivileged() operation. It seems as if a number of
> places
> just get lucky with the security manager. Is there any reason not to
> replace:
>
> static {
> System.loadLibrary("hyfoo"); //$NON-NLS-1$
> }
>
> with:
>
> static {
> AccessController.doPrivileged(new PrivilegedAction<Object>() {
> public Object run() {
> System.loadLibrary("hyfoo"); //$NON-NLS-1$
> return null;
> }
> });
> }
>
> Some of the files are in java.* packages, so they have to be on the
> bootpath
> - which means wrapping them might not make sense. But others (like
> PSPrinterJob and RandomBitsSupplier) are in org.apache.harmony.*, and might
> not necessarily be on the bootpath for all consumers of Harmony classes.
>
> Any thoughts?
>
> Andrew Jr.
>