db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r381389 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/reference/ engine/org/apache/derby/impl/services/monitor/ engine/org/apache/derby/impl/store/raw/ engine/org/apache/derby/loc/ testing/org/apache/derbyTesting/functionTest...
Date Mon, 27 Feb 2006 17:19:07 GMT
Author: mikem
Date: Mon Feb 27 09:19:02 2006
New Revision: 381389

URL: http://svn.apache.org/viewcvs?rev=381389&view=rev
Log:
DERBY-709, committing on behalf of Suresh Thalamati

-- Removed the requirement for read permission on "user.dir" for backup to
run under security manager. Absolute Path were used only to log into backup
history file. Changed it to log canonical paths only if it can be obtainer
,otherwise only relative paths are written to the backup history file.

-- Added a missing privileged blocks to the save service.properties file into 
the backup.

-- Added privileged blocks for test util file functions that are called
through SQL functions/procedures.

-- Enabled some of the tests which were not running under security manager
earlier because of this bug to run by default with security manager.

Backup tests that test backup with jar Operations still can not be run under 
security manager due to bug DERBY-537.


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/MessageId.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java
    db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BackupPathTests_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OnlineBackupTest1_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OnlineBackupTest3_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/RecoveryAfterBackupSetup_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/RecoveryAfterBackup_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/backupRestore1_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/backupRestore_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/encryptionKey_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/logDevice_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest2_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest4_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/rollForwardBackup_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/rollForwardRecovery_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/st_1_app.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/FTFileUtil.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/MessageId.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/MessageId.java?rev=381389&r1=381388&r2=381389&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/MessageId.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/reference/MessageId.java Mon Feb
27 09:19:02 2006
@@ -71,7 +71,7 @@
     String STORE_SHUTDOWN_MSG               = "D002";
     String STORE_BACKUP_STARTED             = "D004";
     String STORE_MOVED_BACKUP               = "D005";
-    String STORE_COPIED_DB_DIR              = "D006";
+    String STORE_DATA_SEG_BACKUP_COMPLETED  = "D006";
     String STORE_EDITED_SERVICEPROPS        = "D007";
     String STORE_ERROR_EDIT_SERVICEPROPS    = "D008";
     String STORE_COPIED_LOG                 = "D009";

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java?rev=381389&r1=381388&r2=381389&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/monitor/StorageFactoryService.java
Mon Feb 27 09:19:02 2006
@@ -401,69 +401,83 @@
 		@exception StandardException Properties cannot be saved.
 	*/
 
-	public void saveServiceProperties(String serviceName, Properties properties, boolean replace)
+	public void saveServiceProperties(final String serviceName, 
+                                      final Properties properties, 
+                                      final boolean replace)
 		throws StandardException {
-		File backupFile = null;
 
-		File servicePropertiesFile = new File(serviceName, PersistentService.PROPERTIES_NAME);
-		
-		if (replace) {
-			backupFile = new File(serviceName, PersistentService.PROPERTIES_NAME.concat("old"));
-
-			try {
-				if(!servicePropertiesFile.renameTo(backupFile)) {
-					throw StandardException.newException(SQLState.UNABLE_TO_RENAME_FILE, servicePropertiesFile,
backupFile);
-				}
-			} catch (SecurityException se) {
-				throw Monitor.exceptionStartingModule(se);
-			}
-		}
-
-		FileOutputStream fos = null;
-		try {
-
-			fos = new FileOutputStream(servicePropertiesFile);
-			properties.store(fos, serviceName + MessageService.getTextMessage(MessageId.SERVICE_PROPERTIES_DONT_EDIT));
-			fos.getFD().sync();
-			fos.close();
-			fos = null;
-
-			replace = false;
-
-
-		} catch (IOException ioe) {
-
-			if (fos != null) {
-				try {
-					fos.close();
-				} catch (IOException ioe2) {
-				}
-				fos = null;
-			}
-
-			if (backupFile != null) {
-				// need to re-name the old properties file back again
-				try {
-					servicePropertiesFile.delete();
-					backupFile.renameTo(servicePropertiesFile);
-				} catch (SecurityException se) {
-				}
-			}
-			throw Monitor.exceptionStartingModule(ioe);
-		}
+        try
+        {
+            AccessController.doPrivileged(
+                new PrivilegedExceptionAction()
+                {
+                    File backupFile = null;
+                    public Object run() throws StandardException
+                    {
+
+                        File servicePropertiesFile = 
+                            new File(serviceName, PersistentService.PROPERTIES_NAME);
+                        if (replace) {
+                            backupFile = 
+                                new File(serviceName, PersistentService.PROPERTIES_NAME.concat("old"));
+                            try {
+                                if(!servicePropertiesFile.renameTo(backupFile)) {
+                                    throw StandardException.newException(
+                                     SQLState.UNABLE_TO_RENAME_FILE, servicePropertiesFile,
backupFile);
+                                }
+                            } catch (SecurityException se) {
+                                throw Monitor.exceptionStartingModule(se);
+                            }
+                        }
+
+                        FileOutputStream fos = null;
+                        try {
+
+                            fos = new FileOutputStream(servicePropertiesFile);
+                            properties.store(fos, 
+                                             serviceName + 
+                                             MessageService.getTextMessage(
+                                                  MessageId.SERVICE_PROPERTIES_DONT_EDIT));
+                            fos.getFD().sync();
+                            fos.close();
+                            fos = null;
+                        } catch (IOException ioe) {
+
+                            if (fos != null) {
+                                try {
+                                    fos.close();
+                                } catch (IOException ioe2) {
+                                }
+                                fos = null;
+                            }
+
+                            if (backupFile != null) {
+                                // need to re-name the old properties file back again
+                                try {
+                                    servicePropertiesFile.delete();
+                                    backupFile.renameTo(servicePropertiesFile);
+                                } catch (SecurityException se) {
+                                }
+                            }
+                            throw Monitor.exceptionStartingModule(ioe);
+                        }
 		
 		
-		if (backupFile != null) {
-			try {
-				backupFile.delete();
-				backupFile = null;
-			} catch (SecurityException se) {
-				// do nothing
-			}
-		}
-
-	}
-
+                        if (backupFile != null) {
+                            try {
+                                backupFile.delete();
+                                backupFile = null;
+                            } catch (SecurityException se) {
+                                // do nothing
+                            }
+                        }
+                        return null;
+                    }
+                }
+                );
+        }catch( PrivilegedActionException pae) { throw (StandardException) pae.getException();}
+    }
+                
     /*
 	**Recreates service root if required depending on which of the following
 	**attribute is specified on the conection URL:

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java?rev=381389&r1=381388&r2=381389&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/RawStore.java Mon Feb
27 09:19:02 2006
@@ -140,6 +140,8 @@
     private static final int REGULAR_FILE_LIST_DIRECTORY_ACTION = 12;
     private static final int STORAGE_FILE_LIST_DIRECTORY_ACTION = 13;
     private static final int COPY_STORAGE_FILE_TO_REGULAR_ACTION = 14;
+    private static final int REGULAR_FILE_GET_CANONICALPATH_ACTION = 15;
+    private static final int STORAGE_FILE_GET_CANONICALPATH_ACTION = 16;
 
 	public RawStore() {
 	}
@@ -592,8 +594,10 @@
 		File oldbackup = null;
 		File backupcopy = null;
 		OutputStreamWriter historyFile = null;
+        StorageFile dbHistoryFile = null;
+        File backupHistoryFile = null;
 		LogInstant backupInstant = logFactory.getFirstUnflushedInstant();
-
+        
 		try
 		{
 			// first figure out our name
@@ -604,14 +608,17 @@
 
 			// append to end of history file
 			historyFile = privFileWriter( storageFactory.newStorageFile( BACKUP_HISTORY), true);
+            
+			backupcopy = new File(backupDir, dbname);
 
 			logHistory(historyFile,
                         MessageService.getTextMessage(
-                            MessageId.STORE_BACKUP_STARTED, canonicalDbName));
-
-			// if a backup copy of this database already exists,
-			backupcopy = new File(backupDir, dbname);
+                            MessageId.STORE_BACKUP_STARTED, 
+                            canonicalDbName, 
+                            getFilePath(backupcopy)));
 
+            
+            // check if a backup copy of this database already exists,
             if (privExists(backupcopy))
 			{
 				// first make a backup of the backup
@@ -637,8 +644,8 @@
                         historyFile,
                         MessageService.getTextMessage(
                             MessageId.STORE_MOVED_BACKUP,
-                            backupcopy.getCanonicalPath(),
-                            oldbackup.getCanonicalPath()));
+                            getFilePath(backupcopy),
+                            getFilePath(oldbackup)));
 					renamed = true;
 				}
 			}
@@ -651,6 +658,15 @@
                     (File) backupcopy);
             }
 
+            dbHistoryFile = storageFactory.newStorageFile(BACKUP_HISTORY);
+            backupHistoryFile = new File(backupcopy, BACKUP_HISTORY); 
+            // copy the history file into the backup. 
+            if(!privCopyFile(dbHistoryFile, backupHistoryFile))
+                throw StandardException. 
+                    newException(SQLState.RAWSTORE_ERROR_COPYING_FILE,
+                                 dbHistoryFile, backupHistoryFile);  
+
+
             // if they are any jar file stored in the database, copy them into
             // the backup. 
             StorageFile jarDir = 
@@ -780,13 +796,12 @@
 			// backup all the information in the data segment.
 			dataFactory.backupDataFiles(t, segBackup);
 
-			logHistory(historyFile,
-                MessageService.getTextMessage(
-                    MessageId.STORE_COPIED_DB_DIR,
-                    canonicalDbName,
-                    backupcopy.getCanonicalPath()));
+            logHistory(historyFile,
+                   MessageService.getTextMessage(
+                   MessageId.STORE_DATA_SEG_BACKUP_COMPLETED,
+                   getFilePath(segBackup)));
+
 
-		
             // copy the log that got generated after the backup started to
 			// backup location and tell the logfactory that backup has come to end.
 			logFactory.endLogBackup(logBackup);
@@ -794,8 +809,8 @@
 			logHistory(historyFile,
                 MessageService.getTextMessage(
                     MessageId.STORE_COPIED_LOG,
-                    logdir.getCanonicalPath(),
-                    logBackup.getCanonicalPath()));
+                    getFilePath(logdir),
+                    getFilePath(logBackup)));
 
 			error = false;
 		}
@@ -841,13 +856,19 @@
 						logHistory(historyFile,
                             MessageService.getTextMessage(
                                 MessageId.STORE_REMOVED_BACKUP,
-                                oldbackup.getCanonicalPath()));
+                                getFilePath(oldbackup)));
  					}
 					logHistory(historyFile,
                         MessageService.getTextMessage(
                             MessageId.STORE_BACKUP_COMPLETED,
                             backupInstant));
 
+                    // copy the updated version of history file with current
+                    // backup information into the backup.
+                    if(!privCopyFile(dbHistoryFile, backupHistoryFile))
+                        throw StandardException. 
+                            newException(SQLState.RAWSTORE_ERROR_COPYING_FILE,
+                                         dbHistoryFile, backupHistoryFile);  
 				}
 
 				historyFile.close();
@@ -1172,6 +1193,48 @@
 		historyFile.flush();
 	}
 
+    /*
+     * Get the file path. If the canonical path can be obtained then return the 
+     * canonical path, otherwise just return the abstract path. Typically if
+     * there are no permission to read user.dir when  running under security
+     * manager canonical path can not be obtained.
+     *
+     * This method is used to a write path name to error/status log file, where it
+     * would be nice to print full paths but not esstential that the user 
+     * grant permissions to read user.dir property.
+     */
+    private String getFilePath(StorageFile file) {
+        String path = privGetCanonicalPath(file);
+        if(path != null ) {
+            return path;
+        }else {
+            //can not get the canoncal path, 
+            // return the abstract path
+            return file.getPath();
+        }
+    }
+
+    /*
+     * Get the file path.  If the canonical path can be obtained then return the 
+     * canonical path, otherwise just return the abstract path. Typically if
+     * there are no permission to read user.dir when  running under security
+     * manager canonical path can not be obtained.
+     *
+     * This method is used to a write a file path name to error/status log file, 
+     * where it would be nice to print full paths but not esstential that the user
+     * grant permissions to read user.dir property.
+     *
+     */
+    private String getFilePath(File file) {
+        String path = privGetCanonicalPath(file);
+        if(path != null ) {
+            return path;
+        }else {
+            // can not get the canoncal path, 
+            // return the abstract path
+            return file.getPath();
+        }
+    }
 
 	protected boolean privCopyDirectory(StorageFile from, File to)
 	{
@@ -1472,7 +1535,41 @@
             actionStorageFile = null;
         }
     }
-    
+
+
+    private synchronized String privGetCanonicalPath(final StorageFile file)
+    {
+        actionCode = STORAGE_FILE_GET_CANONICALPATH_ACTION;
+        actionStorageFile = file;
+
+        try
+        {
+            return (String) AccessController.doPrivileged( this);
+        }
+        catch( PrivilegedActionException pae) { return null;} // does not throw an exception
+        finally
+        {
+            actionStorageFile = null;
+        }
+    }
+
+
+    private synchronized String privGetCanonicalPath(final File file)
+    {
+        actionCode = REGULAR_FILE_GET_CANONICALPATH_ACTION;
+        actionRegularFile = file;
+
+        try
+        {
+            return (String) AccessController.doPrivileged( this);
+        }
+        catch( PrivilegedActionException pae) { return null;} // does not throw an exception
+        finally
+        {
+            actionRegularFile = null;
+        }
+    }
+
 
     // PrivilegedExceptionAction method
     public final Object run() throws IOException
@@ -1545,8 +1642,14 @@
                                            (WritableStorageFactory) storageFactory,
                                            actionStorageFile,
                                            actionRegularFile));
-
-
+            
+        case REGULAR_FILE_GET_CANONICALPATH_ACTION:
+            // SECURITY PERMISSION - MP1
+            return (String)(actionRegularFile.getCanonicalPath());
+            
+        case STORAGE_FILE_GET_CANONICALPATH_ACTION:
+            // SECURITY PERMISSION - MP1
+            return (String)(actionStorageFile.getCanonicalPath());
         }
         return null;
     } // end of run

Modified: db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties?rev=381389&r1=381388&r2=381389&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties Mon Feb 27
09:19:02 2006
@@ -1209,9 +1209,9 @@
 
 D001=:\n Booting Derby version {0}: instance {1}\non database directory {2} {3} \n
 D002=:\nShutting down instance {0}
-D004=Backup started for database located at {0}
+D004=Backup started for database located at {0} to {1}.
 D005=moved old backup copy from {0} to {1}
-D006=copied database directory from {0} to {1}
+D006=Backup of data segment to {0} completed. 
 D007=edited database service.properties to use default log device
 D008=error editing database service.properties, backup aborted: {0}
 D009=copied log directory from {0} to {1}

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BackupPathTests_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BackupPathTests_app.properties?rev=381389&r1=381388&r2=381389&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BackupPathTests_app.properties
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/BackupPathTests_app.properties
Mon Feb 27 09:19:02 2006
@@ -18,5 +18,6 @@
 #Exclude for J2ME/Foundation - test uses procedure with server-side JDBC
 runwithfoundation=false
 
-#exclude with SecurityManager DERBY-709
+# Test fails with security manager due to bug DEBRY-537
 noSecurityManager=true
+

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OnlineBackupTest1_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OnlineBackupTest1_app.properties?rev=381389&r1=381388&r2=381389&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OnlineBackupTest1_app.properties
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OnlineBackupTest1_app.properties
Mon Feb 27 09:19:02 2006
@@ -10,9 +10,6 @@
 #
 #
 
-#database=jdbc:derby:wombat;create=true;logDevice=extinout/br1logDir
 usedefaults=true
 useextdirs=true
 
-#exclude with SecurityManager DERBY-709
-noSecurityManager=true

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OnlineBackupTest3_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OnlineBackupTest3_app.properties?rev=381389&r1=381388&r2=381389&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OnlineBackupTest3_app.properties
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/OnlineBackupTest3_app.properties
Mon Feb 27 09:19:02 2006
@@ -18,5 +18,5 @@
 #Exclude for J2ME/Foundation - test uses procedure with server-side JDBC
 runwithfoundation=false
 
-#exclude with SecurityManager DERBY-709
+# Test fails with security manager due to bug DEBRY-537
 noSecurityManager=true

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/RecoveryAfterBackupSetup_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/RecoveryAfterBackupSetup_app.properties?rev=381389&r1=381388&r2=381389&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/RecoveryAfterBackupSetup_app.properties
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/RecoveryAfterBackupSetup_app.properties
Mon Feb 27 09:19:02 2006
@@ -7,8 +7,6 @@
 
 ij.defaultResourcePackage=/org/apache/derbyTesting/functionTests/tests/store/
 
-#exclude with SecurityManager
-noSecurityManager=true
 
 # DataSource properties, only used if ij.dataSource is set
 ij.dataSource.databaseName=hairynosedwombat

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/RecoveryAfterBackup_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/RecoveryAfterBackup_app.properties?rev=381389&r1=381388&r2=381389&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/RecoveryAfterBackup_app.properties
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/RecoveryAfterBackup_app.properties
Mon Feb 27 09:19:02 2006
@@ -6,8 +6,6 @@
 
 ij.defaultResourcePackage=/org/apache/derbyTesting/functionTests/tests/store/
 
-#exclude with SecurityManager
-noSecurityManager=true
 
 # DataSource properties, only used if ij.dataSource is set
 ij.dataSource.databaseName=hairynosedwombat

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/backupRestore1_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/backupRestore1_app.properties?rev=381389&r1=381388&r2=381389&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/backupRestore1_app.properties
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/backupRestore1_app.properties
Mon Feb 27 09:19:02 2006
@@ -14,5 +14,3 @@
 usedefaults=true
 useextdirs=true
 
-#exclude with SecurityManager DERBY-709
-noSecurityManager=true

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/backupRestore_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/backupRestore_app.properties?rev=381389&r1=381388&r2=381389&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/backupRestore_app.properties
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/backupRestore_app.properties
Mon Feb 27 09:19:02 2006
@@ -2,5 +2,6 @@
 usedefaults=true
 useextdirs=true
 
-#exclude with SecurityManager DERBY-709
+# Test fails with security manager due to bug DEBRY-537
 noSecurityManager=true
+

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/encryptionKey_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/encryptionKey_app.properties?rev=381389&r1=381388&r2=381389&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/encryptionKey_app.properties
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/encryptionKey_app.properties
Mon Feb 27 09:19:02 2006
@@ -7,6 +7,4 @@
 ij.showNoCountForSelect=true
 runwithjdk13=false
 
-#exclude with SecurityManager DERBY-709
-noSecurityManager=true
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/logDevice_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/logDevice_app.properties?rev=381389&r1=381388&r2=381389&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/logDevice_app.properties
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/logDevice_app.properties
Mon Feb 27 09:19:02 2006
@@ -20,6 +20,4 @@
 ij.dataSource.createDatabase=create
 ij.dataSource.connectionAttributes=logDevice=extinout/wierdlog
 
-#exclude with SecurityManager DERBY-709
-noSecurityManager=true
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest2_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest2_app.properties?rev=381389&r1=381388&r2=381389&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest2_app.properties
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest2_app.properties
Mon Feb 27 09:19:02 2006
@@ -1,5 +1,2 @@
 usedefaults=true
 useextdirs=true
-
-#exclude with SecurityManager DERBY-709
-noSecurityManager=true

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest4_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest4_app.properties?rev=381389&r1=381388&r2=381389&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest4_app.properties
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/onlineBackupTest4_app.properties
Mon Feb 27 09:19:02 2006
@@ -1,5 +1,2 @@
 usedefaults=true
 useextdirs=true
-
-#exclude with SecurityManager DERBY-709
-noSecurityManager=true

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/rollForwardBackup_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/rollForwardBackup_app.properties?rev=381389&r1=381388&r2=381389&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/rollForwardBackup_app.properties
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/rollForwardBackup_app.properties
Mon Feb 27 09:19:02 2006
@@ -12,6 +12,3 @@
 
 useextdirs=true
 usedefaults=true
-
-#exclude with SecurityManager DERBY-709
-noSecurityManager=true

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/rollForwardRecovery_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/rollForwardRecovery_app.properties?rev=381389&r1=381388&r2=381389&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/rollForwardRecovery_app.properties
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/rollForwardRecovery_app.properties
Mon Feb 27 09:19:02 2006
@@ -12,6 +12,3 @@
 
 useextdirs=true
 usedefaults=true
-
-#exclude with SecurityManager DERBY-709
-noSecurityManager=true

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/st_1_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/st_1_app.properties?rev=381389&r1=381388&r2=381389&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/st_1_app.properties
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/storetests/st_1_app.properties
Mon Feb 27 09:19:02 2006
@@ -1,5 +1,3 @@
 usedefaults=true
 
-# BUG - fails with security manager due to DERBY-709
-noSecurityManager=true
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/FTFileUtil.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/FTFileUtil.java?rev=381389&r1=381388&r2=381389&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/FTFileUtil.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/FTFileUtil.java
Mon Feb 27 09:19:02 2006
@@ -22,6 +22,11 @@
 
 import java.io.FileWriter;
 import java.io.File;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
 /**
   Convience functions for performing file manipulations
   in ij scripts.
@@ -50,40 +55,71 @@
 	}
 
 	/**
-	   rename a file
-	   @param location location of the file
-	   @param name the file's name
-	   @param newName the file's new name
+     * rename a file. 
+     * This method is  called by some tests through a SQL procedure:
+     * RENAME_FILE(LOCATION VARCHAR(32000), NAME VARCHAR(32000), 
+     *                                 NEW_NAME  VARCHAR(32000))
+     * @param location location of the file
+     * @param name the file's name
+	 * @param newName the file's new name
 	*/
-	public static void renameFile(String location, String name , String newName) throws Exception
+	public static void renameFile(String location, String name , 
+                                  String newName) throws Exception
 	{
-		File src = new File(location, name);
-		File dst = new File(location, newName);
-		if(!src.renameTo(dst))
-		{
-			throw new Exception("unable to rename File: " +
-								src.getAbsolutePath() +
-							    " To: " + dst.getAbsolutePath());
-		}
-	}
+		final File src = new File(location, name);
+		final File dst = new File(location, newName);
+        
+        // needs to run in a privileged block as it will be
+		// called through a SQL statement and thus a generated
+		// class. The generated class on the stack has no permissions
+		// granted to it.
+        AccessController.doPrivileged(new PrivilegedExceptionAction() {
+                public Object run() throws Exception {
+                    if(!src.renameTo(dst))
+                    {
+                        throw new Exception("unable to rename File: " +
+                                            src.getAbsolutePath() +
+                                            " To: " + dst.getAbsolutePath());
+                    }
+                    
+                    return null; // nothing to return
+                }
+            });
+    }
 
 
     /**
      * Check if a file exists ?
      *
+     * This method is  called by some tests through a SQL function:
+     * fileExists(fileName varchar(128))returns VARCHAR(100)
+     *
      * @param name the file's name.
      * @return     <tt>"true"</tt> if the given file exists 
      *             <tt>"false"</tt> otherwise.
      * @exception Exception if any exception occurs 
      */
-    public static String fileExists(String fileName) throws Exception
+    public static String fileExists(String fileName) 
+        throws PrivilegedActionException
     {
-        File fl = new File(fileName);
-        if(fl.exists()) {
-            return "true";
-        }else {
-            return "false";
-        }
+        final File fl = new File(fileName);
+                
+        // needs to run in a privileged block as it will be
+		// called through a SQL statement and thus a generated
+		// class. The generated class on the stack has no permissions
+		// granted to it.
+
+        return (String) 
+            AccessController.doPrivileged(new PrivilegedExceptionAction() {
+                public Object run()
+                {
+                    if(fl.exists()) {
+                        return "true";
+                    }else {
+                        return "false";
+                    }
+                }
+            });
     }
 
 
@@ -128,17 +164,32 @@
 	}
 
     /**
-     *	Remove a directory and all of its contents.
+     * Remove a directory and all of its contents.
+     * This method is  called by some tests through a SQL function:
+     * removeDirectory(fileName varchar(128)) returns VARCHAR(100)
      *   
-     *  @param name the file's name.
+     * @param name the file's name.
      * @return     <tt>"true"</tt> if the omplete directory was removed
      *             <tt>"false"</tt> otherwise.f false is returned then some of

      *              the files in the directory may have been removed.
      */
 
-	public static String removeDirectory(String directory)
+	public static String removeDirectory(final String directory)
+        throws PrivilegedActionException
 	{
-	    return (removeDirectory(new File(directory)) ? "true" : "false");
+        // needs to run in a privileged block as it will be
+		// called through a SQL statement and thus a generated
+		// class. The generated class on the stack has no permissions
+		// granted to it.
+
+        return (String) 
+            AccessController.doPrivileged(new PrivilegedExceptionAction() {
+                    public Object run()
+                    {
+                        return (removeDirectory(
+                               new File(directory)) ? "true" : "false");
+                    }
+                });
 	}
     
 }



Mime
View raw message