From derby-commits-return-11654-apmail-db-derby-commits-archive=db.apache.org@db.apache.org Thu Jun 25 17:04:32 2009 Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 1466 invoked from network); 25 Jun 2009 17:04:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 25 Jun 2009 17:04:32 -0000 Received: (qmail 82540 invoked by uid 500); 25 Jun 2009 17:04:42 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 82474 invoked by uid 500); 25 Jun 2009 17:04:42 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 82465 invoked by uid 99); 25 Jun 2009 17:04:42 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Jun 2009 17:04:42 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Jun 2009 17:04:40 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 39DA82388908; Thu, 25 Jun 2009 17:04:20 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r788436 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode: BCClass.java GClass.java Date: Thu, 25 Jun 2009 17:04:20 -0000 To: derby-commits@db.apache.org From: kmarsden@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090625170420.39DA82388908@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kmarsden Date: Thu Jun 25 17:04:19 2009 New Revision: 788436 URL: http://svn.apache.org/viewvc?rev=788436&view=rev Log: DERBY-4287 call to System.getProperty in BCClass.java is not wrapped in a priv block so may fail when running under SecurityManager Also wraps call to FileOutputStream Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/BCClass.java db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/GClass.java Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/BCClass.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/BCClass.java?rev=788436&r1=788435&r2=788436&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/BCClass.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/BCClass.java Thu Jun 25 17:04:19 2009 @@ -40,6 +40,7 @@ import org.apache.derby.iapi.services.classfile.VMOpcode; import java.lang.reflect.Modifier; +import java.security.AccessController; import org.apache.derby.iapi.services.sanity.SanityManager; import org.apache.derby.iapi.services.classfile.VMDescriptor; @@ -149,7 +150,15 @@ if (SanityManager.DEBUG) { if (SanityManager.DEBUG_ON("DumpClassFile")) { /* Dump the file in derby.system.home */ - String systemHome = System.getProperty(Property.SYSTEM_HOME_PROPERTY,"."); + String systemHome = (String )AccessController.doPrivileged + (new java.security.PrivilegedAction(){ + + public Object run(){ + return System.getProperty(Property.SYSTEM_HOME_PROPERTY,"."); + + } + } + ); writeClassFile(systemHome,false,null); } } Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/GClass.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/GClass.java?rev=788436&r1=788435&r2=788436&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/GClass.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/bytecode/GClass.java Thu Jun 25 17:04:19 2009 @@ -32,8 +32,12 @@ import org.apache.derby.iapi.util.ByteArray; import java.io.File; +import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +import java.security.AccessController; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; /** * This is a common superclass for the various impls. @@ -72,20 +76,30 @@ filename = filename + ".class"; - File classFile = new File(dir,filename); + final File classFile = new File(dir,filename); // find the error stream HeaderPrintWriter errorStream = Monitor.getStream(); - + FileOutputStream fos = null; try { - FileOutputStream fis = new FileOutputStream(classFile); - fis.write(bytecode.getArray(), + try { + fos = (FileOutputStream)AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public Object run() + throws FileNotFoundException { + return new FileOutputStream(classFile); + } + }); + } catch (PrivilegedActionException pae) { + throw (FileNotFoundException)pae.getCause(); + } + fos.write(bytecode.getArray(), bytecode.getOffset(), bytecode.getLength()); - fis.flush(); + fos.flush(); if (logMessage) { errorStream.printlnWithHeader("Wrote class "+getFullName()+" to file "+classFile.toString()+". Please provide support with the file and the following exception message: "+t); } - fis.close(); + fos.close(); } catch (IOException e) { if (SanityManager.DEBUG) SanityManager.THROWASSERT("Unable to write .class file", e);