harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail Markov (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-2955) [classlib][luni]File.deleteOnExit should implement with doPrivileged
Date Wed, 10 Jan 2007 07:23:27 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-2955?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12463482
] 

Mikhail Markov commented on HARMONY-2955:
-----------------------------------------

I've further investigated the problem and found that the testcase below produces the output
below.
It seems that 3 different VMs checks different permissions first:
RI: java.security.SecurityPermission getProperty.networkaddress.cache.ttl (fails)
DRLVM: java.security.SecurityPermission getProperty.package.access (successfully)
IBM VME: java.security.SecurityPermission getProperty.package.access (fails)


------------- output ---------------

RI:
Checking permission: (java.security.SecurityPermission getProperty.networkaddress.cache.ttl)
java.lang.ExceptionInInitializerError
        at java.lang.System.setSecurityManager0(System.java:275)
        at java.lang.System.setSecurityManager(System.java:244)
        at Test.main(Test.java:8)
Caused by: java.security.AccessControlException: access denied (java.security.SecurityPermission
getProperty.networkaddress.cache.ttl)
        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 MySecurityManager.checkPermission(Test.java:24)
        at java.security.Security.getProperty(Security.java:724)
        at sun.net.InetAddressCachePolicy$1.run(InetAddressCachePolicy.java:81)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.net.InetAddressCachePolicy.<clinit>(InetAddressCachePolicy.java:77)
        ... 3 more
Checking permission: (java.lang.RuntimePermission setSecurityManager)
Exception in thread "main" java.lang.NoClassDefFoundError
        at java.lang.System.setSecurityManager0(System.java:275)
        at java.lang.System.setSecurityManager(System.java:244)
        at Test.main(Test.java:12)

Harmony with DRLVM:
Checking permission: (java.security.SecurityPermission getProperty.package.access)
Checking permission: (java.lang.RuntimePermission setSecurityManager)

Harmony with IBM VME:
(VM crashes with the following output):
Checking permission: (java.security.SecurityPermission getProperty.package.access)
Exception in thread "main" java.security.AccessControlException: Access denied (java.security.SecurityPermission
getProperty.package.access)
        at java.security.AccessController.checkPermission(AccessController.java:94)
        at java.lang.SecurityManager.checkPermission(SecurityManager.java:746)
        at MySecurityManager.checkPermission(Test.java:24)
        at java.lang.SecurityManager.checkSecurityAccess(SecurityManager.java:422)
        at java.security.Security.getProperty(Security.java:360)
        at org.apache.harmony.luni.util.PriviAction.run(PriviAction.java:131)
        at java.security.AccessController.doPrivileged(AccessController.java:179)
        at java.lang.SecurityManager.checkPackageProperty(SecurityManager.java:333)
        at java.lang.SecurityManager.checkPackageAccess(SecurityManager.java:34)
        at com.ibm.oti.vm.URLSystemClassLoader.loadClass(URLSystemClassLoader.java:54)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:620)
        at com.ibm.oti.vm.URLSystemClassLoader.loadClass(URLSystemClassLoader.java:60)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:594)
        at MySecurityManager.checkPermission(Test.java:19)
        at java.lang.SecurityManager.checkSecurityAccess(SecurityManager.java:422)
        at java.security.Security.getProperty(Security.java:360)
        at org.apache.harmony.luni.util.PriviAction.run(PriviAction.java:131)
        at java.security.AccessController.doPrivileged(AccessController.java:179)
        at java.lang.SecurityManager.checkPackageProperty(SecurityManager.java:333)
        at java.lang.SecurityManager.checkPackageAccess(SecurityManager.java:34)
        at com.ibm.oti.vm.URLSystemClassLoader.loadClass(URLSystemClassLoader.java:54)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:594)
        at MySecurityManager.checkPermission(Test.java:19)
        at java.lang.System.setSecurityManager(System.java:838)
        at Test.main(Test.java:12)
Checking permission: (java.lang.RuntimePermission modifyThreadGroup)

--------- Test.java ------------
import java.security.Permission;

public class Test {
    public static void main(String[] args) {
        SecurityManager backup = System.getSecurityManager();

        try {
            System.setSecurityManager(new MySecurityManager());
        } catch (Throwable t) {
            t.printStackTrace();
        } finally {
            System.setSecurityManager(backup);
        }
    }
}

class MySecurityManager extends SecurityManager {
    public void checkPermission(Permission perm) {
        System.out.println("Checking permission: " + perm);

        if ("setSecurityManager".equals(perm.getName())) {
            return;
        }
        super.checkPermission(perm);
    }
}
-----------------------------

> [classlib][luni]File.deleteOnExit should implement with doPrivileged
> --------------------------------------------------------------------
>
>                 Key: HARMONY-2955
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2955
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Tony Wu
>
> As title, following testcase passes on RI whereas throws "AccessControlException:Access
denied" on Harmony
>     public void test() throws IOException {
>         File dir = File.createTempFile("hytemp", "");
>         dir.deleteOnExit();
>         SecurityManager backup = System.getSecurityManager();
>         try {
>             System.setSecurityManager(new MySecurityManager());
>         } finally {
>             System.setSecurityManager(backup);
>         }
>     }
>     class MySecurityManager extends SecurityManager {
>         public void checkPermission(Permission perm) {
>             if ("setSecurityManager".equals(perm.getName())) {
>                 return;
>             }
>             super.checkPermission(perm);
>         }
>     }

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

        

Mime
View raw message