Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 36503 invoked from network); 1 Apr 2005 20:17:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 1 Apr 2005 20:17:41 -0000 Received: (qmail 89668 invoked by uid 500); 1 Apr 2005 20:17:40 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 89634 invoked by uid 500); 1 Apr 2005 20:17:39 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 89619 invoked by uid 99); 1 Apr 2005 20:17:39 -0000 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from ajax-1.apache.org (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.28) with ESMTP; Fri, 01 Apr 2005 12:17:38 -0800 Received: by ajax.apache.org (Postfix, from userid 99) id B5C5E2A4; Fri, 1 Apr 2005 22:17:35 +0200 (CEST) From: bugzilla@apache.org To: dev@ant.apache.org Subject: DO NOT REPLY [Bug 34229] - Need ability to intercept calls to System.setSecurityManager() from embedded environment X-Bugzilla-Reason: CC Message-Id: <20050401201735.B5C5E2A4@ajax.apache.org> Date: Fri, 1 Apr 2005 22:17:35 +0200 (CEST) X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG� RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT . ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND� INSERTED IN THE BUG DATABASE. http://issues.apache.org/bugzilla/show_bug.cgi?id=34229 ------- Additional Comments From jglick@netbeans.org 2005-04-01 22:17 ------- Not sure yet. Maybe in Permissions: public class Permissions { // ... /** * For containers which wish to intercept * {@link System.setSecurityManager} safely. */ public interface SecurityManagerDelegator { void registerSecurityManager(SecurityManager); void unregisterSecurityManager(); } public static void installSecurityManagerDelegator(SecurityManagerDelegator) {...} } If P.iSMD were not called, Ant would do what it does now. If it were called, Permissions.{set,restore}SecurityManager would delegate to the new interface. This would - I hope - permit a container to manage Ant's SM implementation intelligently, say by having the real global SM delegate to Ant's SM according to the current thread group. But I would need to try writing a real P.SMD implementation, say for NetBeans, to confirm that it can really work. Note that the current code in Ant is not actually correct to begin with. You might expect that the following script: public class Pause { public static void main(String[] args) throws Exception { int status = Integer.parseInt(args[0]); System.out.println("Will pause... (status: " + status + ")"); Thread.sleep(2000); System.out.println("Done. (status: " + status + ")"); System.exit(status); } } OK?? would when run from the command line (Ant 1.6.2) print Will pause... (status: 0) Will pause... (status: 1) Done. (status: 0) Done. (status: 1) BUILD FAILED /tmp/build.xml:24: Java returned: 1 since the second process finishes second and with a nonzero error code which should throw a BuildException. Instead, it prints only Will pause... (status: 0) Will pause... (status: 1) Done. (status: 0) Done. (status: 1) and then exits *Ant's* VM abruptly (with code 1). That is because the sequence of events is - System.sSM(MySM) for process #0 before it starts - System.sSM(MySM) for process #1 (overwriting #0's!) before it starts - System.exit(0) from #0, which is trapped and causes to finish - System.sSM(null) (as stored by Permissions #0) after #0 finishes - System.exit(1) from #1, which is not trapped since there is no SM A contrived case, perhaps, but it shows that the logic in Permissions is wrong already - it should be installing a multiplexing SM itself, and perhaps checking the Thread of the caller. Switching to forked mode as an option of last resort might be an option; perhaps it would be a reasonable hot fix for Ant 1.6.3 until we can do better. I guess ExecuteJava would need to catch SecurityException from Permissions.sSM and switch to calling Java.fork(...) or something like that, and a similar fix for JUnitTestRunner. The main problem is that running the app forked is not completely transparent to the user; besides a performance hit, there might be some specific behavior which the user needs unforked mode for, and it might be confusing to magically switch to forked mode in some environments. -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org