From 00d1562d36c9e77f4676cb689ace7171e19e3be1 Mon Sep 17 00:00:00 2001 From: Vadim Kurland Date: Wed, 6 May 2009 23:42:33 +0000 Subject: [PATCH] merging -r887:HEAD from branch v3 --- autogen.sh | 27 ++++++---- build_num | 2 +- doc/ChangeLog | 11 ++++ src/gui/FirewallInstaller.cpp | 47 ++++++++++++++++- src/gui/FirewallInstaller.h | 4 +- src/gui/FirewallInstallerCisco.cpp | 11 ++++ src/gui/FirewallInstallerUnx.cpp | 82 ------------------------------ src/gui/FirewallInstallerUnx.h | 6 --- src/gui/instDialog.cpp | 60 ++++++++++++++++++++-- src/gui/instDialog.h | 6 ++- src/gui/instDialog_compile.cpp | 16 +----- src/gui/instDialog_installer.cpp | 8 ++- 12 files changed, 157 insertions(+), 123 deletions(-) diff --git a/autogen.sh b/autogen.sh index 154ceed98..6d8c49690 100755 --- a/autogen.sh +++ b/autogen.sh @@ -7,10 +7,10 @@ if test ! -x "$MAKE" ; then MAKE=`which make` ; fi HAVE_GNU_MAKE=`$MAKE --version|grep -c "Free Software Foundation"` if test "$HAVE_GNU_MAKE" != "1"; then - echo "Could not find GNU make on this system, can not proceed with build." + echo Could not find GNU make on this system, can not proceed with build. exit 1 else - echo "Found GNU Make at $MAKE ... good." + echo Found GNU Make at $MAKE ... good. fi if test ! -x "`which aclocal`" @@ -20,25 +20,32 @@ then exit 1 fi -if test ! -x "`which libtoolize`" +if test -x "`which libtoolize`" then - if test ! -x "`which glibtoolize`" + LIBTOOLIZE="libtoolize" +else + if test -x "`which glibtoolize`" then + LIBTOOLIZE="glibtoolize" + else echo "You need libtoolize to generate autoconf and libtool scripts." echo "Please install libtool package." exit 1 fi fi -echo "This script runs configure ..." +$LIBTOOLIZE --dry-run --install > /dev/null 2>&1 && { + LIBTOOLIZE_ARGS="--force --copy --install" +} || { + LIBTOOLIZE_ARGS="--force --copy" +} -ACLOCALARG="" -test -d /sw/share/ && ACLOCALARG=" -I /sw/share/aclocal" +echo This script runs configure ... + +$LIBTOOLIZE $LIBTOOLIZE_ARGS -which libtoolize >/dev/null 2>&1 && libtoolize --force --copy -which glibtoolize >/dev/null 2>&1 && glibtoolize --force --copy which acinclude >/dev/null 2>&1 && acinclude -which aclocal >/dev/null 2>&1 && aclocal ${ACLOCALARG} +which aclocal >/dev/null 2>&1 && aclocal autoconf ./configure ${CFGARGS} $* diff --git a/build_num b/build_num index a07005579..3e633a0de 100644 --- a/build_num +++ b/build_num @@ -1 +1 @@ -#define BUILD_NUM 869 +#define BUILD_NUM 888 diff --git a/doc/ChangeLog b/doc/ChangeLog index 6283dd70d..f30608e13 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,14 @@ +2009-05-06 vadim + + * FirewallInstallerCisco.cpp (FirewallInstallerCisco::activatePolicy): + fixed bug #2787932 "External install script is not supported for + PIX". + + * fixed bug #2787857: "b847 crashes on Start". v3.0.5 build 847 + links with QtDBus framework as part of the future development but + the framework file was not included in the bundle. This caused + crash on Mac OS X. + 2009-05-02 vadim * DiscoveryDruid.cpp (DiscoveryDruid::DiscoveryDruid): fixed bug diff --git a/src/gui/FirewallInstaller.cpp b/src/gui/FirewallInstaller.cpp index a68d78397..949df29bd 100644 --- a/src/gui/FirewallInstaller.cpp +++ b/src/gui/FirewallInstaller.cpp @@ -221,9 +221,54 @@ void FirewallInstaller::copyFile(const QString &file_name) { } +void FirewallInstaller::executeInstallScript() +{ + Management *mgmt = cnf->fwobj->getManagementObject(); + assert(mgmt!=NULL); + PolicyInstallScript *pis = mgmt->getPolicyInstallScript(); + QString command = pis->getCommand().c_str(); + QString wdir = getFileDir( mw->getRCS()->getFileName() ); + QStringList args; + //args.push_back(command.trimmed()); + + QString qs = pis->getArguments().c_str(); + args += qs.trimmed().split(" ", QString::SkipEmptyParts); + + args.push_back("-f"); + args.push_back(mw->db()->getFileName().c_str()); + + if (wdir!="") + { + args.push_back("-d"); + args.push_back(wdir); + } + args.push_back(cnf->fwobj->getName().c_str()); + + if (cnf->verbose) inst_dlg->displayCommand(args); + qApp->processEvents(); + + inst_dlg->setUpProcessToInstall(); + if (!inst_dlg->executeCommand(command.trimmed(), args)) + QTimer::singleShot( 0, this, SLOT(mainLoopInstall())); +} + void FirewallInstaller::executeCommand(const QString &cmd) { -} + QStringList args; + packSSHArgs(args); + args.push_back( cmd ); + if (cnf->verbose) inst_dlg->displayCommand(args); + qApp->processEvents(); + + QString path = args.at(0); + args.pop_front(); + + inst_dlg->setUpProcessToInstall(); + if (!inst_dlg->executeCommand(path, args)) + QTimer::singleShot( 0, this, SLOT(mainLoopInstall())); +} + +// ************************************************************************ void FirewallInstaller::activatePolicy() { diff --git a/src/gui/FirewallInstaller.h b/src/gui/FirewallInstaller.h index 21927c427..418507d9f 100644 --- a/src/gui/FirewallInstaller.h +++ b/src/gui/FirewallInstaller.h @@ -71,7 +71,8 @@ protected: instDialog *inst_dlg; instConf *cnf; - // session is used when e run built-in installer + QProcess proc; + // session is used when we run built-in installer SSHSession *session; std::list job_list; QString fwb_prompt; @@ -79,6 +80,7 @@ protected: void runSSHSession(SSHSession *s, bool intermediate=false); QString getFullPath(const QString &file ); + void executeInstallScript(); public: diff --git a/src/gui/FirewallInstallerCisco.cpp b/src/gui/FirewallInstallerCisco.cpp index 30f758ed5..a06b8484b 100644 --- a/src/gui/FirewallInstallerCisco.cpp +++ b/src/gui/FirewallInstallerCisco.cpp @@ -62,6 +62,17 @@ bool FirewallInstallerCisco::packInstallJobsList(Firewall*) void FirewallInstallerCisco::activatePolicy() { + // Someone may have external expect script to talk to PIX or a router + // Let them run it too. + Management *mgmt = cnf->fwobj->getManagementObject(); + assert(mgmt!=NULL); + PolicyInstallScript *pis = mgmt->getPolicyInstallScript(); + if (pis->getCommand()!="" ) + { + executeInstallScript(); + return; + } + QStringList args; packSSHArgs(args); diff --git a/src/gui/FirewallInstallerUnx.cpp b/src/gui/FirewallInstallerUnx.cpp index afc358ffe..4bd20f161 100644 --- a/src/gui/FirewallInstallerUnx.cpp +++ b/src/gui/FirewallInstallerUnx.cpp @@ -165,35 +165,6 @@ void FirewallInstallerUnx::activatePolicy() executeInstallScript(); } -void FirewallInstallerUnx::executeInstallScript() -{ - Management *mgmt = cnf->fwobj->getManagementObject(); - assert(mgmt!=NULL); - PolicyInstallScript *pis = mgmt->getPolicyInstallScript(); - QString command = pis->getCommand().c_str(); - QString wdir = getFileDir( mw->getRCS()->getFileName() ); - QStringList args; - args.push_back(command.trimmed()); - - QString qs = pis->getArguments().c_str(); - args += qs.trimmed().split(" ", QString::SkipEmptyParts); - - args.push_back("-f"); - args.push_back(mw->db()->getFileName().c_str()); - - if (wdir!="") - { - args.push_back("-d"); - args.push_back(wdir); - } - args.push_back(cnf->fwobj->getName().c_str()); - - if (cnf->verbose) inst_dlg->displayCommand(args); - qApp->processEvents(); - - executeCommand(args); -} - void FirewallInstallerUnx::executeSession(const QString &cmd) { QStringList args; @@ -243,56 +214,3 @@ void FirewallInstallerUnx::copyFile(const QString &file_name) // ************************************************************************ -void FirewallInstallerUnx::executeCommand(const QString &cmd) -{ - QStringList args; - packSSHArgs(args); - args.push_back( cmd ); - if (cnf->verbose) inst_dlg->displayCommand(args); - qApp->processEvents(); - - executeCommand(args); -} - -// ************************************************************************ - -/* - * All other methods operate with SSHSession objects because they are - * interactive (even if only to enter password). We do not need - * interactivity to run single command so here we use QProcess instead - * of SSHSession. - */ -void FirewallInstallerUnx::executeCommand(QStringList &args) -{ - connect(&proc, SIGNAL(readyReadStandardOutput()), - inst_dlg, SLOT(readFromStdout()) ); - - // even though we set channel mode to "merged", QProcess - // seems to not merge them on windows. - proc.setProcessChannelMode(QProcess::MergedChannels); - - // set codecs so that command line parameters can be encoded - QTextCodec::setCodecForCStrings(QTextCodec::codecForName("Utf8")); - QTextCodec::setCodecForLocale(QTextCodec::codecForName("Utf8")); - - QString path = args.at(0); - args.pop_front(); - - proc.disconnect(SIGNAL(finished(int,QProcess::ExitStatus))); - connect(&proc, SIGNAL(finished(int,QProcess::ExitStatus)), - inst_dlg, SLOT(installerFinished(int,QProcess::ExitStatus)) ); - inst_dlg->enableStopButton(); - - proc.start(path, args); - - if ( !proc.waitForStarted() ) - { - inst_dlg->addToLog(tr("Error: Failed to start program:")); - inst_dlg->addToLog(path); - inst_dlg->opError(cnf->fwobj); - QTimer::singleShot( 0, inst_dlg, SLOT(mainLoopInstall())); - return; - } - args.push_front(path); -} - diff --git a/src/gui/FirewallInstallerUnx.h b/src/gui/FirewallInstallerUnx.h index e97f39208..765f8d46b 100644 --- a/src/gui/FirewallInstallerUnx.h +++ b/src/gui/FirewallInstallerUnx.h @@ -34,7 +34,6 @@ #include #include -#include #include namespace libfwbuilder @@ -46,11 +45,7 @@ class FirewallInstallerUnx : public FirewallInstaller { Q_OBJECT - QProcess proc; - - void executeInstallScript(); void executeSession(const QString &cmd); - void executeCommand(QStringList &args); public: @@ -59,7 +54,6 @@ public: virtual bool packInstallJobsList(libfwbuilder::Firewall*); virtual void copyFile(const QString &file_name); - virtual void executeCommand(const QString &cmd); virtual void activatePolicy(); diff --git a/src/gui/instDialog.cpp b/src/gui/instDialog.cpp index cad2546c2..5df5195a0 100644 --- a/src/gui/instDialog.cpp +++ b/src/gui/instDialog.cpp @@ -99,7 +99,7 @@ instDialog::instDialog(QWidget* p, installer = NULL; - page_1_op = COMPILE; + page_1_op = INST_DLG_COMPILE; showSelectedFlag = false; rejectDialogFlag = false; @@ -218,7 +218,7 @@ void instDialog::mainLoopCompile() fillInstallOpList(); if (install_fw_list.size() > 0) { - page_1_op = INSTALL; + page_1_op = INST_DLG_INSTALL; setNextEnabled(1, true); } } @@ -294,7 +294,7 @@ void instDialog::showPage(const int page) // controlled by flag page_1_op switch (page_1_op) { - case COMPILE: + case INST_DLG_COMPILE: { if (fwbdebug) qDebug("Page 1 compile"); if (compile_fw_list.size()==0) @@ -304,7 +304,7 @@ void instDialog::showPage(const int page) showPage(0); return; } - page_1_op = INSTALL; + page_1_op = INST_DLG_INSTALL; showPage(1); return; } @@ -320,7 +320,7 @@ void instDialog::showPage(const int page) break; } - case INSTALL: + case INST_DLG_INSTALL: { if (fwbdebug) qDebug("Page 1 install"); if (install_fw_list.size() > 0) @@ -438,3 +438,53 @@ void instDialog::blockInstallForFirewall(Firewall *fw) installMapping[fw]->setCheckState(Qt::Unchecked); } +void instDialog::setUpProcessToCompile() +{ + connect(&proc, SIGNAL(readyReadStandardOutput()), + this, SLOT(readFromStdout()) ); + + // even though we set channel mode to "merged", QProcess + // seems to not merge them on windows. + proc.setProcessChannelMode(QProcess::MergedChannels); + + proc.disconnect(SIGNAL(finished(int,QProcess::ExitStatus))); + connect(&proc, SIGNAL(finished(int,QProcess::ExitStatus)), + this, SLOT(compilerFinished(int,QProcess::ExitStatus)) ); +} + +void instDialog::setUpProcessToInstall() +{ + connect(&proc, SIGNAL(readyReadStandardOutput()), + this, SLOT(readFromStdout()) ); + + // even though we set channel mode to "merged", QProcess + // seems to not merge them on windows. + proc.setProcessChannelMode(QProcess::MergedChannels); + + proc.disconnect(SIGNAL(finished(int,QProcess::ExitStatus))); + connect(&proc, SIGNAL(finished(int,QProcess::ExitStatus)), + this, SLOT(installerFinished(int,QProcess::ExitStatus)) ); +} + +/* + * This method is used to launch compiler AND user-defined external + * installation script. + */ +bool instDialog::executeCommand(const QString &path, QStringList &args) +{ + // set codecs so that command line parameters can be encoded + QTextCodec::setCodecForCStrings(QTextCodec::codecForName("Utf8")); + QTextCodec::setCodecForLocale(QTextCodec::codecForName("Utf8")); + enableStopButton(); + proc.start(path, args); + if ( !proc.waitForStarted() ) + { + opError(cnf.fwobj); + addToLog( tr("Error: Failed to start program") ); + addToLog(path); + //blockInstallForFirewall(cnf.fwobj); + return false; + } + return true; +} + diff --git a/src/gui/instDialog.h b/src/gui/instDialog.h index 1c64739d2..9597be998 100644 --- a/src/gui/instDialog.h +++ b/src/gui/instDialog.h @@ -63,7 +63,7 @@ namespace libfwbuilder } enum BatchOperation {BATCH_INSTALL, BATCH_COMPILE} ; -enum Page1Operation {COMPILE, INSTALL}; +enum Page1Operation {INST_DLG_COMPILE, INST_DLG_INSTALL}; typedef std::map t_tableMap; typedef std::list t_fwList; @@ -171,9 +171,11 @@ class instDialog : public QDialog, public FakeWizard void enableStopButton(); void disableStopButton(); + void setUpProcessToCompile(); + void setUpProcessToInstall(); + bool executeCommand(const QString &path, QStringList &args); protected: - void executeCommand(QStringList &args); virtual void showEvent( QShowEvent *ev); virtual void hideEvent( QHideEvent *ev); diff --git a/src/gui/instDialog_compile.cpp b/src/gui/instDialog_compile.cpp index 25b4bc000..733b926b8 100644 --- a/src/gui/instDialog_compile.cpp +++ b/src/gui/instDialog_compile.cpp @@ -109,24 +109,12 @@ bool instDialog::runCompiler(Firewall *fw) connect(currentStopButton, SIGNAL(clicked()), this, SLOT(stopCompile())); - proc.disconnect(SIGNAL(finished(int,QProcess::ExitStatus))); - connect(&proc, SIGNAL(finished(int,QProcess::ExitStatus)), - this, SLOT(compilerFinished(int,QProcess::ExitStatus)) ); - - proc.start(path, args); - currentStopButton->setText(tr("Stop")); currentStopButton->setEnabled(true); - if ( !proc.waitForStarted() ) - { - opError(cnf.fwobj); - addToLog( tr("Error: Failed to start program") ); - blockInstallForFirewall(cnf.fwobj); + setUpProcessToCompile(); + if (!executeCommand(path, args)) QTimer::singleShot( 0, this, SLOT(mainLoopCompile())); - return false; - } - args.push_front(path); return true; } diff --git a/src/gui/instDialog_installer.cpp b/src/gui/instDialog_installer.cpp index b325177c8..d7f563a74 100644 --- a/src/gui/instDialog_installer.cpp +++ b/src/gui/instDialog_installer.cpp @@ -169,7 +169,13 @@ void instDialog::installerFinished(int ret_code, QProcess::ExitStatus status) if( fwbdebug) qDebug("instDialog::installerFinished " "exit code = %d exit_status=%d", ret_code, status); - + // run readFromStdout() and processEvents() to make sure all + // events that pass output from the external installer script have + // been processed. Otherwise the output from the next installer + // pass in batch install mixes with the tail of the output from + // the previous one. + readFromStdout(); + qApp->processEvents(); if (ret_code==0 && status==QProcess::NormalExit) installerSuccess(); else