Bug 41776 - java task not honoring AllPermission
Summary: java task not honoring AllPermission
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.7.0
Hardware: Other other
: P3 normal (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-06 20:12 UTC by Jing Xue
Modified: 2008-03-11 11:29 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jing Xue 2007-03-06 20:12:49 UTC
The following throws an "exitVM disallowed" error in 1.7.0 due to the related
bug fix:
  <target name="usage" description="This usage help">
    <java classname="org.apache.tools.ant.launch.Launcher">
      <arg value="-projecthelp"/>
    </java>
  </target> 

Strangely the following doesn't work either, by complaining not having
permission for "java.util.PropertyException ant.home read".
  <target name="usage" description="This usage help">
    <java classname="org.apache.tools.ant.launch.Launcher">
      <arg value="-projecthelp"/>
      <grant class="java.lang.AllPermission"/>
      <grant class="java.lang.RuntimePermission" name="exitVM.*"/>
    </java>
  </target> 

I changed the default constructor of types.Permissions to set delegateToOldSM to
true, that seems to have solved the problem. Unfortunately there isn't anyway
(that I can find) to set delegateToOldSM from an ant script. Is it possible to
expose it as an attribute on <permissions>? Or at least change its default value
to true?
Comment 1 Jing Xue 2007-03-06 20:14:25 UTC
(In reply to comment #0)
>   <target name="usage" description="This usage help">
>     <java classname="org.apache.tools.ant.launch.Launcher">
>       <arg value="-projecthelp"/>
>       <grant class="java.lang.AllPermission"/>
>       <grant class="java.lang.RuntimePermission" name="exitVM.*"/>

One more thing - that above line is for JDK 1.6. For JDK 1.5, it should be:
       <grant class="java.lang.RuntimePermission" name="exitVM"/>

>     </java>
>   </target> 
Comment 2 J.M. (Martijn) Kruithof 2007-04-23 14:49:56 UTC
Thanks for the report.

Fixed in head

At least in java 1.5 it is java.security.AllPermission, not java.lang.
The grants must be in the <permissions> part.
For some reason the AllPermission is not resolved in later stages.

Comment 3 Eric Bloch 2008-03-11 11:29:16 UTC
I'm hitting this in 1.7.0 and can't take HEAD.

Is there a way to workaround this bug in 1.7.0 without patching?

That is, can I easily override something in a subclass of Java.java?

Thanks,
Eric