[Iscs-developers] ISCS/SPM/src so.cpp,1.14,1.15 so.h,1.14,1.15 spmmainform.ui.h,1.26,1.27 spmthreads
Status: Beta
Brought to you by:
jsulliva
From: <jsu...@us...> - 2003-08-22 03:20:21
|
Update of /cvsroot/iscs/ISCS/SPM/src In directory sc8-pr-cvs1:/tmp/cvs-serv32179/SPM/src Modified Files: so.cpp so.h spmmainform.ui.h spmthreads.cpp Log Message: Major but not complete debugging of thread code Updates now work rudimentarily Index: so.cpp =================================================================== RCS file: /cvsroot/iscs/ISCS/SPM/src/so.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** so.cpp 21 Aug 2003 02:07:10 -0000 1.14 --- so.cpp 21 Aug 2003 05:29:04 -0000 1.15 *************** *** 54,57 **** --- 54,58 ---- LSDB = "ls"; DIRDELIMDB = "/"; + MKDIRDB = "mkdir -p"; RENAMEDB = "mv"; RMDB = "rm"; *************** *** 62,65 **** --- 63,67 ---- LSDB = "dir"; DIRDELIMDB ="\\"; + MKDIRDB = "mkdir"; RENAMEDB = "ren"; RMDB = "del"; Index: so.h =================================================================== RCS file: /cvsroot/iscs/ISCS/SPM/src/so.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** so.h 21 Aug 2003 02:07:10 -0000 1.14 --- so.h 21 Aug 2003 05:29:04 -0000 1.15 *************** *** 78,81 **** --- 78,82 ---- QString LS; QString LSDB; + QString MKDIRDB; QString NEWLINE; QString PATHDELIM; Index: spmmainform.ui.h =================================================================== RCS file: /cvsroot/iscs/ISCS/SPM/src/spmmainform.ui.h,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** spmmainform.ui.h 21 Aug 2003 02:07:10 -0000 1.26 --- spmmainform.ui.h 21 Aug 2003 05:29:04 -0000 1.27 *************** *** 627,630 **** --- 627,633 ---- bool SPMMainForm::checkPreviousDb() { + if ( so->DbVersion == 1 ) { // i.e., this is the first database so there will be no previousDbChanges file + return true; + } QString Path = so->SPMDbDataRoot + "data" + so->DIRDELIMDB + QString::number(so->DbVersion - 1); if ( so->LocalDB ) { *************** *** 967,996 **** void SPMMainForm::exitSPM() { ! if (! so->DbChanges.isEmpty()) { // i.e., we have uncommitted changes ! if (! handleUncommittedChanges()) { // i.e., the user's choice does not imply that we stop this process ! return; } - } /* We should check for the running update before checking for uncommitted changes but let's first be sure that launching commitChanges() from an exit does not make the SPM exit before the changes are finished applying */ // Check to see if an update is running ! if (! so->LocalDB) { // then we need to ssh ! SBLabel->setText(tr("Checking if it is safe to exit.")); ! } ! if (updateInProcess()) { // i.e., there is a lock on the update process ! QMessageBox::warning(this, tr("SPM - Update Still in Process"), tr("An update is currently in process. You must wait until it is finished before exiting or you will leave your security in an indeterminate state!")); ! SBLabel->setText(SBLabelMsg); ! raisePEPUpdateProgress(); // Show update progress dialog box ! return; ! } ! if (so->DbEdit->isOpen() ) { ! so->DbEdit->close(); ! } ! if (so->DbProd->isOpen() && (! so->SQProd->exec("drop database " + so->DbName + Now))) { // drop the Edit Database - we need to check if the Database is open in case we never opened it or we closed it by logging out before exiting ! QMessageBox::warning(this, tr("SPM - Database Warning"), tr("Failed to drop the edit database %1\nPlease carefully note the name (including all the numbers)\nand give the information to your SPM database\nadministrator so they can manually delete the database\nand recover the disk space.\nSPM Error Code: L105\n\nDatabase Error: %2\nDriver error: %3").arg(so->DbName + Now).arg(so->DbProd->lastError().databaseText()).arg(so->DbProd->lastError().driverText())); ! } ! if (so->DbProd->isOpen() ) { ! so->DbProd->close(); } qApp->quit(); --- 970,1003 ---- void SPMMainForm::exitSPM() { ! // We only need to do these checks if we have logged in ! if ( so->DbEdit->isOpen() || so->DbProd->isOpen() ) { ! ! if (! so->DbChanges.isEmpty()) { // i.e., we have uncommitted changes ! if (! handleUncommittedChanges()) { // i.e., the user's choice does not imply that we stop this process ! return; ! } } /* We should check for the running update before checking for uncommitted changes but let's first be sure that launching commitChanges() from an exit does not make the SPM exit before the changes are finished applying */ // Check to see if an update is running ! if (! so->LocalDB) { // then we need to ssh ! SBLabel->setText(tr("Checking if it is safe to exit.")); ! } ! if (updateInProcess()) { // i.e., there is a lock on the update process ! QMessageBox::warning(this, tr("SPM - Update Still in Process"), tr("An update is currently in process. You must wait until it is finished before exiting or you will leave your security in an indeterminate state!")); ! SBLabel->setText(SBLabelMsg); ! raisePEPUpdateProgress(); // Show update progress dialog box ! return; ! } ! if (so->DbEdit->isOpen() ) { ! so->DbEdit->close(); ! } ! if (so->DbProd->isOpen() && (! so->SQProd->exec("drop database " + so->DbName + Now))) { // drop the Edit Database - we need to check if the Database is open in case we never opened it or we closed it by logging out before exiting ! QMessageBox::warning(this, tr("SPM - Database Warning"), tr("Failed to drop the edit database %1\nPlease carefully note the name (including all the numbers)\nand give the information to your SPM database\nadministrator so they can manually delete the database\nand recover the disk space.\nSPM Error Code: L105\n\nDatabase Error: %2\nDriver error: %3").arg(so->DbName + Now).arg(so->DbProd->lastError().databaseText()).arg(so->DbProd->lastError().driverText())); ! } ! if (so->DbProd->isOpen() ) { ! so->DbProd->close(); ! } } qApp->quit(); Index: spmthreads.cpp =================================================================== RCS file: /cvsroot/iscs/ISCS/SPM/src/spmthreads.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** spmthreads.cpp 21 Aug 2003 02:07:10 -0000 1.19 --- spmthreads.cpp 21 Aug 2003 05:29:04 -0000 1.20 *************** *** 119,130 **** Stream << "for f in resolv ntp dhcp ipsec\ndo\n"; Stream << "\tif [ -f /etc/$f.conf ]; then\n\t\tcp /etc/$f.conf /etc/PEPBackup/ 2>/dev/null\n"; ! Stream << "\t\tif [ $? -ne 0 ]; then\n\t\t\techo " << PUError << " Could not backup up PEP configuration files > &2\n\t\t\texit 1\n\t\tfi\n\tfi\n"; Stream << "done\n"; Stream << "if [ -f /etc/ipsec.secrets ]; then\n\tcp /etc/ipsec.secrets /etc/PEPBackup/ 2>/dev/null\n"; ! Stream << "\tif [ $? -ne 0 ]; then\n\t\techo " << PUError << " Could not backup up PEP configuration files > &2\n\t\texit 1\n\tfi\nfi\n"; Stream << "for d in PEP ipsec.d\ndo\n"; Stream << "\tif [ -d /etc/$d ]; then\n"; Stream << "\t\tcp -R /etc/$d /etc/PEPBackup/ 2>/dev/null\n"; ! Stream << "\t\tif [ $? -ne 0 ]; then\n\t\t\techo " << PUError << " Could not backup up PEP configuration files > &2\n\t\t\texit 1\n\t\tfi\n"; Stream << "\tfi\n"; Stream << "done\n"; --- 119,130 ---- Stream << "for f in resolv ntp dhcp ipsec\ndo\n"; Stream << "\tif [ -f /etc/$f.conf ]; then\n\t\tcp /etc/$f.conf /etc/PEPBackup/ 2>/dev/null\n"; ! Stream << "\t\tif [ $? -ne 0 ]; then\n\t\t\techo " << PUError << " Could not backup up PEP configuration files >&2\n\t\t\texit 1\n\t\tfi\n\tfi\n"; Stream << "done\n"; Stream << "if [ -f /etc/ipsec.secrets ]; then\n\tcp /etc/ipsec.secrets /etc/PEPBackup/ 2>/dev/null\n"; ! Stream << "\tif [ $? -ne 0 ]; then\n\t\techo " << PUError << " Could not backup up PEP configuration files >&2\n\t\texit 1\n\tfi\nfi\n"; Stream << "for d in PEP ipsec.d\ndo\n"; Stream << "\tif [ -d /etc/$d ]; then\n"; Stream << "\t\tcp -R /etc/$d /etc/PEPBackup/ 2>/dev/null\n"; ! Stream << "\t\tif [ $? -ne 0 ]; then\n\t\t\techo " << PUError << " Could not backup up PEP configuration files >&2\n\t\t\texit 1\n\t\tfi\n"; Stream << "\tfi\n"; Stream << "done\n"; *************** *** 145,149 **** // Copy the needed files ! QString Path = so->SPMDbDataRoot + "PEPfiles" + so->DIRDELIMDB + PEP + so->DIRDELIMDB + TargetDb + so->DIRDELIMDB + "*"; sh->prepProc(); if (! so->LocalDB ) { --- 145,149 ---- // Copy the needed files ! QString Path = so->SPMDbDataRoot + "PEPfiles" + so->DIRDELIMDB + PEP + so->DIRDELIMDB + TargetDb + so->DIRDELIMDB + "PEPTemp"; sh->prepProc(); if (! so->LocalDB ) { *************** *** 153,157 **** sh->Proc->addArgument("-r"); sh->Proc->addArgument(Path); ! sh->Proc->addArgument(so->SPMDistID + "@" + PEPIP + ":/etc/PEPTemp/"); sh->launchProc(); if (! sh->Proc->normalExit()) { // we connected via scp but did not successfully copy the files --- 153,157 ---- sh->Proc->addArgument("-r"); sh->Proc->addArgument(Path); ! sh->Proc->addArgument(so->SPMDistID + "@" + PEPIP + ":/etc/"); sh->launchProc(); if (! sh->Proc->normalExit()) { // we connected via scp but did not successfully copy the files *************** *** 259,263 **** sh->Proc->addArgument(so->SPMDistID + "@" + PEPIP); sh->Proc->addArgument("rm -Rf"); ! sh->Proc->addArgument("/etc/PEPTemp/*"); sh->launchProc(); // do not sh->prepProc() because we need the Stderr string --- 259,263 ---- sh->Proc->addArgument(so->SPMDistID + "@" + PEPIP); sh->Proc->addArgument("rm -Rf"); ! sh->Proc->addArgument("/etc/PEPTemp"); sh->launchProc(); // do not sh->prepProc() because we need the Stderr string *************** *** 434,438 **** } Stream.setDevice(File); ! Stream << (*it).right((*it).length() - Name.length() -1); File->close(); } --- 434,438 ---- } Stream.setDevice(File); ! Stream << (*it).right((*it).length() - Name.length() -1) << "\n"; File->close(); } *************** *** 450,456 **** // enable the script to handle any errors - attempt to backout Error = sh->tr("Failed to update DNS!!!"); ! Stream << "if [$? -ne 0 ]; then\n\techo " << PUError << " " << Error << " > &2\n"; Error = sh->tr("PANIC!! Failed to back out failed changes!!!"); ! Stream << "\t.\\backout 2>/dev/null\n\tif [$? -ne 0 ]; then\n\t\techo " << PUPanic << " " << Error << " >&2\n\tfi\n\texit 1\nfi\n"; File->close(); } --- 450,456 ---- // enable the script to handle any errors - attempt to backout Error = sh->tr("Failed to update DNS!!!"); ! Stream << "if [ $? -ne 0 ]; then\n\techo " << PUError << " " << Error << " >&2\n"; Error = sh->tr("PANIC!! Failed to back out failed changes!!!"); ! Stream << "\t.\\backout 2>/dev/null\n\tif [ $? -ne 0 ]; then\n\t\techo " << PUPanic << " " << Error << " >&2\n\tfi\n\texit 1\nfi\n"; File->close(); } *************** *** 475,478 **** --- 475,482 ---- Dir->mkdir(Dir->path()); } + Dir->setPath(Dir->path() + "/PEPTemp"); // Since we cannot use shell expansion in a QProcess, i.e., we cannot copy TargetDb/*, we need to create a complete directory that we can copy to the PEP + if (! Dir->exists()) { + Dir->mkdir(Dir->path()); + } if ( ! Dir->exists() ) { // i.e., we could not create the needed directories ErrorCode = sh->tr("Could not create update files on local computer in %1 - U106", "The parameter is the storage area for the PEP update files on the computer running the GUI").arg(Dir->path()); *************** *** 494,497 **** --- 498,502 ---- if (! addBackup() ) { // adds the section of activate which backs up the configuration files before making changes Dir->cdUp(); + Dir->cdUp(); delLocalTempFiles(); // so they don't interfere with any future attempts return false; *************** *** 500,503 **** --- 505,509 ---- if (! prepDNS(DNSList)) { Dir->cdUp(); + Dir->cdUp(); delLocalTempFiles(); // so they don't interfere with any future attempts return false; *************** *** 513,526 **** Stream.setDevice(File); Stream << "echo " << TargetDb << " > /etc/PEP/dbversion\n"; ! Stream << "cd /etc" << "rm -Rf /etc/PEPTemp/* 2>/dev/null\n"; File->close(); // if we are not running the SPM on the database server, we need to copy the update files to the database server and delete them from the local file store if (! so->LocalDB) { sh->prepProc(); sh->Proc->addArgument("scp"); sh->Proc->addArgument("-r " + Dir->path() ); ! sh->Proc->addArgument(so->DbServer + ":" + so->SPMDbDataRoot + "PEPfiles" + so->DIRDELIMDB + PEP + so->DIRDELIMDB); sh->launchProc(); // delete local files --- 519,545 ---- Stream.setDevice(File); Stream << "echo " << TargetDb << " > /etc/PEP/dbversion\n"; ! Stream << "cd /etc\n" << "rm -Rf /etc/PEPBackup/* 2>/dev/null\n" << "rm -Rf /etc/PEPTemp/* 2>/dev/null\n"; File->close(); // if we are not running the SPM on the database server, we need to copy the update files to the database server and delete them from the local file store if (! so->LocalDB) { + // create the directory + sh->prepProc(); + sh->prepProcRemote(); + sh->Proc->addArgument(so->MKDIRDB); + sh->Proc->addArgument(so->SPMDbDataRoot + "PEPfiles" + so->DIRDELIMDB + PEP + so->DIRDELIMDB + TargetDb); + sh->launchProc(); + //copy over the files sh->prepProc(); sh->Proc->addArgument("scp"); sh->Proc->addArgument("-r " + Dir->path() ); ! sh->Proc->addArgument(so->DbServer + ":" + so->SPMDbDataRoot + "PEPfiles" + so->DIRDELIMDB + PEP + so->DIRDELIMDB + TargetDb + so->DIRDELIMDB); sh->launchProc(); + if (! sh->Proc->normalExit()) { // we connected via scp but did not successfully copy the files + ErrorCode = "Could not copy update files to DBD - U108"; + sh->prepProc(); + return false; + } + sh->prepProc(); // delete local files |