Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 92396 invoked from network); 19 Jan 2006 21:49:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 19 Jan 2006 21:49:20 -0000 Received: (qmail 98970 invoked by uid 500); 19 Jan 2006 21:49:06 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 98821 invoked by uid 500); 19 Jan 2006 21:49:05 -0000 Mailing-List: contact harmony-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-dev@incubator.apache.org Received: (qmail 98724 invoked by uid 99); 19 Jan 2006 21:49:04 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Jan 2006 13:49:04 -0800 Received: from ajax.apache.org (ajax.apache.org [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id 4A57CE0 for ; Thu, 19 Jan 2006 22:48:43 +0100 (CET) Message-ID: <2018231854.1137707323301.JavaMail.jira@ajax.apache.org> Date: Thu, 19 Jan 2006 22:48:43 +0100 (CET) From: "George Harley (JIRA)" To: harmony-dev@incubator.apache.org Subject: [jira] Created: (HARMONY-35) Harmony ignores java.security.policy property MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Harmony ignores java.security.policy property --------------------------------------------- Key: HARMONY-35 URL: http://issues.apache.org/jira/browse/HARMONY-35 Project: Harmony Type: Bug Components: Classlib Environment: Win32 and Linux Reporter: George Harley Here is the complete contents of a Java security policy file called "mysecurity.policy" that can be used to specify additional permissions to a JRE... ---------snip---------- grant { // so we can remove the security manager permission java.lang.RuntimePermission "setSecurityManager"; }; ---------snip---------- If its location is passed in the Java launch arguments with the java.security.policy property as below then the permissions are added to the default set of permissions that the JRE runs with ... -Djava.security.policy=c:\path\to\mysecurity.policy If the following unit test is run against a sandbox build of the classlibs under SVN trunk on the IBM Apache Harmony VME with the java.security.policy set (as above) so that the "setSecurityManager" runtime permission is added, then a pass should result. It doesn't. -----------snip-------------- package foo; import java.security.AccessControlException; import junit.framework.TestCase; public class SecurityPolicyTest extends TestCase { public void testPermissions() { try { System.out .println("Trying to set the security manager the first time..."); System.setSecurityManager(new SecurityManager()); System.out.println("Trying to set the security manager to null..."); System.setSecurityManager(null); assertEquals(null, System.getSecurityManager()); } catch (AccessControlException e) { fail("Caught AccessControlException : " + e.getMessage()); } } } -----------snip-------------- The failure occurs because an AccessControlException is thrown on the second call to System.setSecurityManager() when the test tries to pass a null argument. The problem is that after the first call to System.setSecurityManager() has installed a security manager, there is no runtime permission to enable the security manager to be set again. This is despite the fact that when running the test we set the java.security.policy property to point to a file that grants this very permission ! The reason for this buggy behaviour is the incomplete implementation of com.ibm.oti.util.DefaultPolicy in the luni component. The readPolicy() method needs work to actually fulfill its contract as laid out in the Javadoc comments. George -- 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