From 24dee2cc65e38a2cdb5fa2303c83f92d8b607961 Mon Sep 17 00:00:00 2001 From: tomas Date: Thu, 19 May 2005 14:28:07 +0000 Subject: [PATCH] Minor exception checking and safer path handling added. --- .../modules/storageServer/bin/import.sh | 19 +++++++++++-------- .../modules/storageServer/bin/php/import.php | 3 ++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/livesupport/modules/storageServer/bin/import.sh b/livesupport/modules/storageServer/bin/import.sh index f65a3d8ab..90fe0d14c 100755 --- a/livesupport/modules/storageServer/bin/import.sh +++ b/livesupport/modules/storageServer/bin/import.sh @@ -22,7 +22,7 @@ # # # Author : $Author: tomas $ -# Version : $Revision: 1.1 $ +# Version : $Revision: 1.2 $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/bin/Attic/import.sh,v $ #------------------------------------------------------------------------------- #------------------------------------------------------------------------------- @@ -70,12 +70,13 @@ while true; do case "$1" in -d|--directory) srcdir=$2; + srcabsdir=`cd "$srcdir"; pwd` shift; shift;; -l|--list) filelist=$2; - filelistbasename=`basename $filelist` - filelistdir=`dirname $filelist` - filelistabsdir=`cd $filelistdir; pwd` + filelistbasename=`basename "$filelist"` + filelistdir=`dirname "$filelist"` + filelistabsdir=`cd "$filelistdir"; pwd` filelistpathname=$filelistabsdir/$filelistbasename shift; shift;; -h|--help) @@ -91,7 +92,7 @@ while true; do esac done -if [ "x$srcdir" == "x" -a "x$filelist" == "x" ]; then +if [ "x$srcabsdir" == "x" -a "x$filelist" == "x" ]; then echo "Directory or filelist option required."; printUsage; exit 1; @@ -104,11 +105,13 @@ fi cd $phpdir if [ -f "$filelistpathname" ]; then - cat $filelistpathname | php -q import.php || exit 1 + cat "$filelistpathname" | php -q import.php || exit 1 fi -if [ -d "$srcdir" ]; then - find "$srcdir" -type f | php -q import.php || exit 1 +if [ -d "$srcabsdir" ]; then + find "$srcabsdir" -type f | php -q import.php || exit 1 +else + echo "Warning: not a directory: $srcabsdir" fi #------------------------------------------------------------------------------- diff --git a/livesupport/modules/storageServer/bin/php/import.php b/livesupport/modules/storageServer/bin/php/import.php index 060de9d28..6c084176c 100644 --- a/livesupport/modules/storageServer/bin/php/import.php +++ b/livesupport/modules/storageServer/bin/php/import.php @@ -23,7 +23,7 @@ Author : $Author: tomas $ - Version : $Revision: 1.1 $ + Version : $Revision: 1.2 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/bin/php/Attic/import.php,v $ ------------------------------------------------------------------------------*/ @@ -39,6 +39,7 @@ require_once '../../var/GreenBox.php'; #PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s
\n"); PEAR::setErrorHandling(PEAR_ERROR_RETURN); $dbc = DB::connect($config['dsn'], TRUE); +if(PEAR::isError($dbc)){ echo "ERROR: ".$dbc->getMessage()." ".$dbc->getUserInfo()."\n"; exit(1); } $dbc->setFetchMode(DB_FETCHMODE_ASSOC); $gb = &new GreenBox($dbc, $config);