You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Kathey Marsden (JIRA)" <ji...@apache.org> on 2009/06/23 19:54:07 UTC

[jira] Created: (DERBY-4287) call to System.getProperty in BCClass.java is not wrapped in a priv block so may fail when running under SecurityManager

call to System.getProperty in BCClass.java is not wrapped in a priv block so may fail when running under SecurityManager
------------------------------------------------------------------------------------------------------------------------

                 Key: DERBY-4287
                 URL: https://issues.apache.org/jira/browse/DERBY-4287
             Project: Derby
          Issue Type: Bug
          Components: Services
    Affects Versions: 10.5.1.1, 10.4.2.0, 10.3.3.0, 10.2.2.0, 10.1.3.1, 10.6.0.0
            Reporter: Kathey Marsden
            Priority: Minor


I noticed in org.apache.derby.impl.services.bytecode.BCClass.java we have this code:

			String systemHome = System.getProperty(Property.SYSTEM_HOME_PROPERTY,".");
				writeClassFile(systemHome,false,null);


which will fail when run under security manager because we have no privilege block.



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-4287) call to System.getProperty in BCClass.java is not wrapped in a priv block so may fail when running under SecurityManager

Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4287?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12723382#action_12723382 ] 

Kathey Marsden commented on DERBY-4287:
---------------------------------------

confirmed the problem by starting network server with the default security manager and running
ij> connect 'jdbc:derby://localhost:1527/wombat';
ij> select count(*) from sys.systables;

Trace in the derby.log is:
NID = 1), (DATABASE = wombat), (DRDAID = NF000001.GA72-580400156173718907{1}), Failed Statement is: select count(*) from sys.systables

java.security.AccessControlException: Access denied (java.util.PropertyPermission derby.system.home read)

	at java.security.AccessControlException.<init>(AccessControlException.java:62)

	at java.security.AccessController.checkPermission(AccessController.java:68)

	at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)

	at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1285)

	at java.lang.System.getProperty(System.java:378)

	at org.apache.derby.impl.services.bytecode.BCClass.getClassBytecode(BCClass.java:152)

	at org.apache.derby.impl.services.bytecode.GClass.getGeneratedClass(GClass.java:59)

	at org.apache.derby.impl.sql.compile.ExpressionClassBuilder.getGeneratedClass(ExpressionClassBuilder.java:849)

	at org.apache.derby.impl.sql.compile.StatementNode.generate(StatementNode.java:390)

	at org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java:449)

	at org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java:88)

	at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(GenericLanguageConnectionContext.java:822)

	at org.apache.derby.impl.jdbc.EmbedPreparedStatement.<init>(EmbedPreparedStatement.java:121)

	at org.apache.derby.jdbc.Driver40.newEmbedPreparedStatement(Driver40.java:105)

	at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(EmbedConnection.java:1542)

	at org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(EmbedConnection.java:1423)

	at org.apache.derby.impl.drda.DRDAStatement.prepare(DRDAStatement.java:635)

	at org.apache.derby.impl.drda.DRDAStatement.explicitPrepare(DRDAStatement.java:596)

	at org.apache.derby.impl.drda.DRDAConnThread.parsePRPSQLSTT(DRDAConnThread.java:3701)

	at org.apache.derby.impl.drda.DRDAConnThread.processCommands(DRDAConnThread.java:801)

	at org.apache.derby.impl.drda.DRDAConnThread.run(DRDAConnThread.java:290)


> call to System.getProperty in BCClass.java is not wrapped in a priv block so may fail when running under SecurityManager
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-4287
>                 URL: https://issues.apache.org/jira/browse/DERBY-4287
>             Project: Derby
>          Issue Type: Bug
>          Components: Services
>    Affects Versions: 10.1.3.1, 10.2.2.0, 10.3.3.0, 10.4.2.0, 10.5.1.1, 10.6.0.0
>            Reporter: Kathey Marsden
>            Assignee: Kathey Marsden
>            Priority: Minor
>
> I noticed in org.apache.derby.impl.services.bytecode.BCClass.java we have this code:
> 			String systemHome = System.getProperty(Property.SYSTEM_HOME_PROPERTY,".");
> 				writeClassFile(systemHome,false,null);
> which will fail when run under security manager because we have no privilege block.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-4287) call to System.getProperty in BCClass.java is not wrapped in a priv block so may fail when running under SecurityManager

Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-4287?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kathey Marsden updated DERBY-4287:
----------------------------------

    Derby Info: [Patch Available]

> call to System.getProperty in BCClass.java is not wrapped in a priv block so may fail when running under SecurityManager
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-4287
>                 URL: https://issues.apache.org/jira/browse/DERBY-4287
>             Project: Derby
>          Issue Type: Bug
>          Components: Services
>    Affects Versions: 10.1.3.1, 10.2.2.0, 10.3.3.0, 10.4.2.0, 10.5.1.1, 10.6.0.0
>            Reporter: Kathey Marsden
>            Assignee: Kathey Marsden
>            Priority: Minor
>         Attachments: derby-4287_diff.txt
>
>
> I noticed in org.apache.derby.impl.services.bytecode.BCClass.java we have this code:
> 			String systemHome = System.getProperty(Property.SYSTEM_HOME_PROPERTY,".");
> 				writeClassFile(systemHome,false,null);
> which will fail when run under security manager because we have no privilege block.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-4287) call to System.getProperty in BCClass.java is not wrapped in a priv block so may fail when running under SecurityManager

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4287?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12723798#action_12723798 ] 

Knut Anders Hatlen commented on DERBY-4287:
-------------------------------------------

The default policy grants some file permissions to derbynet.jar. Could that be why it doesn't choke on the FileOutputStream?

> call to System.getProperty in BCClass.java is not wrapped in a priv block so may fail when running under SecurityManager
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-4287
>                 URL: https://issues.apache.org/jira/browse/DERBY-4287
>             Project: Derby
>          Issue Type: Bug
>          Components: Services
>    Affects Versions: 10.1.3.1, 10.2.2.0, 10.3.3.0, 10.4.2.0, 10.5.1.1, 10.6.0.0
>            Reporter: Kathey Marsden
>            Assignee: Kathey Marsden
>            Priority: Minor
>         Attachments: derby-4287_diff.txt
>
>
> I noticed in org.apache.derby.impl.services.bytecode.BCClass.java we have this code:
> 			String systemHome = System.getProperty(Property.SYSTEM_HOME_PROPERTY,".");
> 				writeClassFile(systemHome,false,null);
> which will fail when run under security manager because we have no privilege block.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (DERBY-4287) call to System.getProperty in BCClass.java is not wrapped in a priv block so may fail when running under SecurityManager

Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-4287?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kathey Marsden reassigned DERBY-4287:
-------------------------------------

    Assignee: Kathey Marsden

> call to System.getProperty in BCClass.java is not wrapped in a priv block so may fail when running under SecurityManager
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-4287
>                 URL: https://issues.apache.org/jira/browse/DERBY-4287
>             Project: Derby
>          Issue Type: Bug
>          Components: Services
>    Affects Versions: 10.1.3.1, 10.2.2.0, 10.3.3.0, 10.4.2.0, 10.5.1.1, 10.6.0.0
>            Reporter: Kathey Marsden
>            Assignee: Kathey Marsden
>            Priority: Minor
>
> I noticed in org.apache.derby.impl.services.bytecode.BCClass.java we have this code:
> 			String systemHome = System.getProperty(Property.SYSTEM_HOME_PROPERTY,".");
> 				writeClassFile(systemHome,false,null);
> which will fail when run under security manager because we have no privilege block.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-4287) call to System.getProperty in BCClass.java is not wrapped in a priv block so may fail when running under SecurityManager

Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-4287?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kathey Marsden updated DERBY-4287:
----------------------------------

    Attachment: fost.zip

I think perhaps the behavior I was seeing where  an unwrapped FileOutputStream creation failed to throw an exception is an IBM 1.6 bug.  The attached program (in fost.zip) does not throw an exception with IBM 1.6, but does with Sun 1.6 and  IBM 1.5.

To run change the script runfost.sh to have the class/policy file location for fostloc and run the script ./runfost.sh

IBM 1.6 will complete and create the file myfile.out. Other jvms throw an Exception:
Exception in thread "main" java.security.AccessControlException: access denied (java.io.FilePermission myfile.out write)

        at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
        at java.security.AccessController.checkPermission(AccessController.java:546)
        at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
        at java.lang.SecurityManager.checkWrite(SecurityManager.java:962)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:169)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
        at FileOutputStreamTest.main(FileOutputStreamTest.java:29)

(You can also run with the "withdopriv" option to wrap the call correctly) 
I will try to find some documentation that the doPrivileged should be  required when running under security manager.



> call to System.getProperty in BCClass.java is not wrapped in a priv block so may fail when running under SecurityManager
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-4287
>                 URL: https://issues.apache.org/jira/browse/DERBY-4287
>             Project: Derby
>          Issue Type: Bug
>          Components: Services
>    Affects Versions: 10.1.3.1, 10.2.2.0, 10.3.3.0, 10.4.2.0, 10.5.1.1, 10.6.0.0
>            Reporter: Kathey Marsden
>            Assignee: Kathey Marsden
>            Priority: Minor
>         Attachments: derby-4287_diff.txt, fost.zip
>
>
> I noticed in org.apache.derby.impl.services.bytecode.BCClass.java we have this code:
> 			String systemHome = System.getProperty(Property.SYSTEM_HOME_PROPERTY,".");
> 				writeClassFile(systemHome,false,null);
> which will fail when run under security manager because we have no privilege block.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (DERBY-4287) call to System.getProperty in BCClass.java is not wrapped in a priv block so may fail when running under SecurityManager

Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-4287?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kathey Marsden resolved DERBY-4287.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: 10.6.0.0
                   10.5.1.2
                   10.4.2.1
                   10.3.3.1
                   10.2.2.1
                   10.1.3.3

Checked in the fix and backported back to 10.1. When testing the 10..1 fix I encountered DERBY-1537 which was never backported to 10.1.  I reversed my classpath order to correct that problem and adjusted the affects version for DERBY-1537


> call to System.getProperty in BCClass.java is not wrapped in a priv block so may fail when running under SecurityManager
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-4287
>                 URL: https://issues.apache.org/jira/browse/DERBY-4287
>             Project: Derby
>          Issue Type: Bug
>          Components: Services
>    Affects Versions: 10.1.3.1, 10.2.2.0, 10.3.3.0, 10.4.2.0, 10.5.1.1, 10.6.0.0
>            Reporter: Kathey Marsden
>            Assignee: Kathey Marsden
>            Priority: Minor
>             Fix For: 10.1.3.3, 10.2.2.1, 10.3.3.1, 10.4.2.1, 10.5.1.2, 10.6.0.0
>
>         Attachments: derby-4287_diff.txt, fost.zip
>
>
> I noticed in org.apache.derby.impl.services.bytecode.BCClass.java we have this code:
> 			String systemHome = System.getProperty(Property.SYSTEM_HOME_PROPERTY,".");
> 				writeClassFile(systemHome,false,null);
> which will fail when run under security manager because we have no privilege block.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-4287) call to System.getProperty in BCClass.java is not wrapped in a priv block so may fail when running under SecurityManager

Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-4287?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12724081#action_12724081 ] 

Kathey Marsden commented on DERBY-4287:
---------------------------------------

Thank you Knut, I think that must be the reason.  If I try with ij and the derby_tests.policy file with just the property part of the change. I can get an error on creation of the FileOutputStream.  With the full change the class file is created properly.

This makes me  wonder if in general, liberal permissions in derbyTesting.jar might be masking security manager issues in the product.





> call to System.getProperty in BCClass.java is not wrapped in a priv block so may fail when running under SecurityManager
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-4287
>                 URL: https://issues.apache.org/jira/browse/DERBY-4287
>             Project: Derby
>          Issue Type: Bug
>          Components: Services
>    Affects Versions: 10.1.3.1, 10.2.2.0, 10.3.3.0, 10.4.2.0, 10.5.1.1, 10.6.0.0
>            Reporter: Kathey Marsden
>            Assignee: Kathey Marsden
>            Priority: Minor
>         Attachments: derby-4287_diff.txt
>
>
> I noticed in org.apache.derby.impl.services.bytecode.BCClass.java we have this code:
> 			String systemHome = System.getProperty(Property.SYSTEM_HOME_PROPERTY,".");
> 				writeClassFile(systemHome,false,null);
> which will fail when run under security manager because we have no privilege block.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-4287) call to System.getProperty in BCClass.java is not wrapped in a priv block so may fail when running under SecurityManager

Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-4287?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kathey Marsden updated DERBY-4287:
----------------------------------

    Attachment: derby-4287_diff.txt

Attached is a patch for this issue.  There was also a call to new FileOuputStream which needed wrapping as well, so I did that. I was, however,  a bit perplexed that the creation of the class file still seemed to happen even without the FileOutputStream change.


> call to System.getProperty in BCClass.java is not wrapped in a priv block so may fail when running under SecurityManager
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-4287
>                 URL: https://issues.apache.org/jira/browse/DERBY-4287
>             Project: Derby
>          Issue Type: Bug
>          Components: Services
>    Affects Versions: 10.1.3.1, 10.2.2.0, 10.3.3.0, 10.4.2.0, 10.5.1.1, 10.6.0.0
>            Reporter: Kathey Marsden
>            Assignee: Kathey Marsden
>            Priority: Minor
>         Attachments: derby-4287_diff.txt
>
>
> I noticed in org.apache.derby.impl.services.bytecode.BCClass.java we have this code:
> 			String systemHome = System.getProperty(Property.SYSTEM_HOME_PROPERTY,".");
> 				writeClassFile(systemHome,false,null);
> which will fail when run under security manager because we have no privilege block.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.