You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Stephane Bailliez <sb...@imediation.com> on 2001/12/14 09:42:09 UTC

Security Manager and System.exit

A while ago the SecurityManager was replaced when running Ant so that non
forked tasks do not terminate Ant when they contain a System.exit (typically
a non-forked Java command line).

[ there is some code remaining in Main and the Java task) ]

It has been removed immediately because (from the comments) it did not work
with JDK 1.1.

So is there any issue if we use a System manager for JDK 1.2+ (see below) ?

SecurityManager oldSm = null;
if (jdk1.2+){
  oldSm = System.getSecurityManager();
  System.setSecurityManager( new NoExitSecurityManager() );
}
try  {
  ....
} finally {
  if (oldSm != null){
     System.setSecurityManager( oldSm );
  }
}

-- 
 Stéphane Bailliez 
 Software Engineer, Paris - France 
 iMediation - http://www.imediation.com 
 Disclaimer: All the opinions expressed above are mine and not those from my
company. 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Security Manager and System.exit

Posted by Peter Donald <pe...@apache.org>.
On Fri, 14 Dec 2001 19:42, Stephane Bailliez wrote:
> A while ago the SecurityManager was replaced when running Ant so that non
> forked tasks do not terminate Ant when they contain a System.exit
> (typically a non-forked Java command line).
>
> [ there is some code remaining in Main and the Java task) ]
>
> It has been removed immediately because (from the comments) it did not work
> with JDK 1.1.
>
> So is there any issue if we use a System manager for JDK 1.2+ (see below) ?

yep - it has side-effects on other tasks and can lead to race like conditions 
and differences in behaviour depending on where the task is defined (via ant 
home or via some created ClassLoader). 

-- 
Cheers,

Pete

-------------------------
  All things considered, 
 insanity may be the only 
  reasonable alternative.
-------------------------

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Security Manager and System.exit

Posted by Stefan Bodewig <bo...@apache.org>.
On Fri, 14 Dec 2001, Conor MacNeill <co...@cortexebusiness.com.au>
wrote:

> Yes I put it in and took it out since it was not 1.1 compatabile. It
> can be reintroduced by reflection I believe. It was a matter of time
> that I did not already do that.

System.setSecurityManager is JDK 1.1 according to my Javadocs.

> It is set up in Main which, IMHO, we should have complete control to
> setup the environment including SecurityManagers.

+1

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Security Manager and System.exit

Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
Stefan Bodewig wrote:

> On Fri, 14 Dec 2001, Stephane Bailliez <sb...@imediation.com>
> wrote:
> 
> 
>>It has been removed immediately because (from the comments) it did
>>not work with JDK 1.1.
>>
> 
> I can't recall the details.  Conor?


Yes I put it in and took it out since it was not 1.1 compatabile. It can 
be reintroduced by reflection I believe. It was a matter of time that I 
did not already do that.


> 
> 
>>So is there any issue if we use a System manager for JDK 1.2+ (see
>>below) ?
>>
> 
> We may not want to blindly replace an existing SecurityManager.  I
> believe NetBeans installs its own and it wouldn't be nice to disable
> it for example.


It is set up in Main which, IMHO, we should have complete control to 
setup the environment including SecurityManagers. The integration point 
for external tools is Project. At least this is the principle although 
it is a bit rough around the edges :-)


Conor



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Security Manager and System.exit

Posted by Stefan Bodewig <bo...@apache.org>.
On Fri, 14 Dec 2001, Stephane Bailliez <sb...@imediation.com>
wrote:

> It has been removed immediately because (from the comments) it did
> not work with JDK 1.1.

I can't recall the details.  Conor?

> So is there any issue if we use a System manager for JDK 1.2+ (see
> below) ?

We may not want to blindly replace an existing SecurityManager.  I
believe NetBeans installs its own and it wouldn't be nice to disable
it for example.

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>