You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Oliver Deakin (JIRA)" <ji...@apache.org> on 2006/11/07 18:10:53 UTC

[jira] Commented: (HARMONY-1596) AccessController.doPrivileged(PrivilegedAction,AccessControllerContext) does not use the passed in AccessControllerContext

    [ http://issues.apache.org/jira/browse/HARMONY-1596?page=comments#action_12447860 ] 
            
Oliver Deakin commented on HARMONY-1596:
----------------------------------------

The test method described above is bogus, because it does not take into account the ProtectionDomain for the frame running the test code.

Running this test with an implementation of MyCustomProtectionDomain that has an implies() method that always returns true gives the following result on the RI:

Exception in thread "main" java.security.AccessControlException: access denied (java.io.FilePermission \tmp read)
	at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
	at java.security.AccessController.checkPermission(AccessController.java:427)
	at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
	at java.lang.SecurityManager.checkRead(SecurityManager.java:871)
	at java.io.File.exists(File.java:700)
	at JIRA1596$1.run(JIRA1596.java:16)
	at java.security.AccessController.doPrivileged(Native Method)
	at JIRA1596.main(JIRA1596.java:20)

And when running on Harmony + IBM VME:

K0319java.security.AccessControlException: Access denied (java.io.FilePermission \tmp read)
	at java.security.AccessController.checkPermission(AccessController.java:94)
	at java.lang.SecurityManager.checkPermission(SecurityManager.java:739)
	at java.lang.SecurityManager.checkRead(SecurityManager.java:399)
	at java.io.File.exists(File.java:445)
	at JIRA1596$1.run(JIRA1596.java:16)
	at java.security.AccessController.doPrivileged(AccessController.java:21)
	at JIRA1596.main(JIRA1596.java:20)
FAILED to invoke JVM.

So I see no difference in behavious. As far as I can see this is not a bug.

> AccessController.doPrivileged(PrivilegedAction,AccessControllerContext) does not use the passed in AccessControllerContext
> --------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-1596
>                 URL: http://issues.apache.org/jira/browse/HARMONY-1596
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>         Environment: Linux
>            Reporter: James M Snell
>
> When calling doPrivleged with a provided AccessControllerContext, the passed in context is never used to check permissions against. 
> There is a simple way to test.
> System.setSecurityManager(new SecurityManager());
> ProtectionDomain domain = new MyCustomProtectionDomain(); // programmed to always return true
> AccessControlContext acc = new AccessControlContext(new ProtectionDomain[] {domain});
> PrivilegedAction action = new PrivilegedAction() {
>   public Object run() {
>     File file = new File("/tmp");
>     file.exists();
>   }
> }
> AccessController.doPrivileged(action, acc);
> The passed in acc will never be used

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira