1
0
mirror of https://github.com/fwbuilder/fwbuilder synced 2026-05-02 15:17:28 +02:00

refs #405 : remove code that was used to call policy compiler fwb_pix as external process

This commit is contained in:
Vadim Kurland 2009-09-25 22:16:38 +00:00
parent e2d4204cd6
commit d4b28ca4ab
4 changed files with 11 additions and 177 deletions

View File

@ -1 +1 @@
#define BUILD_NUM 1504
#define BUILD_NUM 1505

View File

@ -55,13 +55,10 @@
#include <qtabwidget.h>
#include <qlistwidget.h>
#include <qlabel.h>
#include <qprocess.h>
#include <qfile.h>
#include <iostream>
#include <sstream>
#include <libxml/xmlmemory.h>
using namespace std;
using namespace libfwbuilder;
@ -76,46 +73,6 @@ pixAdvancedDialog::pixAdvancedDialog(QWidget*, FWObject *o)//(parent)
Firewall *fw=Firewall::cast(obj);
FWOptions *fwopt=fw->getOptionsObject();
string compiler=fwopt->getStr("compiler");
if (compiler=="")
{
compiler=Resources::platform_res[fw->getStr("platform")]->getCompiler();
}
/*
* On Unix compilers are installed in the standard place and are
* accessible via PATH. On Windows and Mac they get installed in
* unpredictable directories and need to be found
*
* first, check if user specified an absolute path for the compiler,
* then check if compiler is registsred in preferences, and if not,
* look for it in appRootDir and if it is not there, rely on PATH
*/
#if defined(Q_OS_WIN32) || defined(Q_OS_MACX)
if ( ! QFile::exists( compiler.c_str() ) )
{
string ts = string("Compilers/")+compiler;
QString cmppath = st->getStr( ts.c_str() );
if (!cmppath.isEmpty()) compiler=cmppath.toLatin1().constData();
else
{
/* try to find compiler in appRootDir. */
string ts = getPathToBinary(compiler);
if ( QFile::exists( ts.c_str() ) )
compiler = ts;
}
}
#endif
fwb_pix_proc = new QProcess();
connect(fwb_pix_proc, SIGNAL(readyReadStandardOutput()), this, SLOT(readFromStdout() ) );
connect(fwb_pix_proc, SIGNAL(readyReadStandardError()), this, SLOT(readFromStderr() ) );
connect(fwb_pix_proc, SIGNAL(stateChanged( QProcess::ProcessState )), this, SLOT(fwb_pix_Finished( QProcess::ProcessState ) ) );
connect(fwb_pix_proc, SIGNAL(bytesWritten(qint64)), this, SLOT(allXMLSent() ) );
compilerPath = compiler.c_str();
argumentList << "-f" << "-" << "-I" << fw->getName().c_str();
string vers="version_"+obj->getStr("version");
string platform = obj->getStr("platform"); // could be 'pix' or 'fwsm'
@ -210,9 +167,7 @@ pixAdvancedDialog::pixAdvancedDialog(QWidget*, FWObject *o)//(parent)
syslogFacilityMapping.push_back("LOCAL7");
syslogFacilityMapping.push_back("23");
FWOptions *fwoptions=(Firewall::cast(obj))->getOptionsObject();
FWOptions *fwoptions = (Firewall::cast(obj))->getOptionsObject();
assert(fwoptions!=NULL);
bool f1=fwoptions->getBool("pix_acl_basic");
@ -239,7 +194,8 @@ pixAdvancedDialog::pixAdvancedDialog(QWidget*, FWObject *o)//(parent)
/* Page "Compiler Options" */
bool outboundACLSupported= (Resources::platform_res[platform]->getResourceBool(
"/FWBuilderResources/Target/options/"+vers+"/pix_outbound_acl_supported") );
"/FWBuilderResources/Target/options/" +
vers + "/pix_outbound_acl_supported"));
if (outboundACLSupported)
m_dialog->pix_emulate_out_acl->hide();
@ -247,8 +203,9 @@ pixAdvancedDialog::pixAdvancedDialog(QWidget*, FWObject *o)//(parent)
m_dialog->pix_generate_out_acl->hide();
m_dialog->tabWidget->setTabEnabled(8,false); //Disable tab
data.registerOption(m_dialog->ipv4before_2, fwoptions, "ipv4_6_order", QStringList() << "IPv4 before IPv6" <<"ipv4_first" << "IPv6 before IPv4" << "ipv6_first");
data.registerOption(m_dialog->ipv4before_2, fwoptions,
"ipv4_6_order",
QStringList() << "IPv4 before IPv6" <<"ipv4_first" << "IPv6 before IPv4" << "ipv6_first");
data.registerOption( m_dialog->outputFileName, fwoptions,
"output_file");
@ -795,63 +752,11 @@ void pixAdvancedDialog::displayCommands()
driver.setTargetId(FWObjectDatabase::getStringId(obj->getId()));
string inspectors = driver.protocolInspectorCommands();
m_dialog->pix_generated_fixup->setText(inspectors.c_str());
#if CALL_COMPILER_AS_EXT_PROCESS
xmlChar *buffer;
int bufsize;
obj->getRoot()->saveToBuffer(&buffer, &bufsize);
proc_buffer = (char*)buffer;
FREEXMLBUFF(buffer);
fwb_pix_proc->start(compilerPath, argumentList);
if ( !fwb_pix_proc->waitForStarted() )
{
m_dialog->pix_generated_fixup->append(
tr("Error: Policy compiler for PIX is not installed") );
}
fwb_pix_proc->write(proc_buffer.toAscii());
#endif
}
void pixAdvancedDialog::allXMLSent()
{
fwb_pix_proc->closeWriteChannel();
}
void pixAdvancedDialog::readFromStdout()
{
m_dialog->pix_generated_fixup->append( QString( fwb_pix_proc->readAllStandardOutput() ) );
}
void pixAdvancedDialog::readFromStderr()
{
m_dialog->pix_generated_fixup->append( QString( fwb_pix_proc->readAllStandardError() ) );
}
void pixAdvancedDialog::fwb_pix_Finished( QProcess::ProcessState newState )
{
if (newState != QProcess::NotRunning) return;
if (fwb_pix_proc->exitStatus() != QProcess::NormalExit)
m_dialog->pix_generated_fixup->append( tr("Compiler error") );
}
void pixAdvancedDialog::updateFixupCommandsDisplay()
{
m_dialog->pix_generated_fixup->setText("");
return;
QString stdoutBuffer;
fwb_pix_proc->start(compilerPath, argumentList);
if ( !fwb_pix_proc->waitForStarted() )
{
m_dialog->pix_generated_fixup->append( tr("Error: Policy compiler for PIX is not installed") );
}
return;
displayCommands();
}
void pixAdvancedDialog::fixupCmdChanged()

View File

@ -30,7 +30,6 @@
#include <ui_pixadvanceddialog_q.h>
#include "DialogData.h"
#include <qprocess.h>
#include <string>
@ -38,7 +37,6 @@ class QWidget;
class QSpinBox;
class QComboBox;
class QCheckBox;
class QProcess;
namespace libfwbuilder {
class FWObject;
@ -74,10 +72,6 @@ class pixAdvancedDialog : public QDialog
DialogData data;
std::list<struct fixupControl> allFixups;
bool syslogDeviceIdSupported;
QProcess *fwb_pix_proc;
QString proc_buffer;
QStringList argumentList;
QString compilerPath;
Ui::pixAdvancedDialog_q *m_dialog;
@ -111,11 +105,6 @@ protected slots:
virtual void scriptACLModeChanged();
virtual void displayCommands();
public slots:
virtual void readFromStdout();
virtual void readFromStderr();
virtual void fwb_pix_Finished( QProcess::ProcessState );
virtual void allXMLSent();
};
#endif // __PIXADVANCEDDIALOG_H

View File

@ -85,7 +85,7 @@
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex" >
<number>0</number>
<number>4</number>
</property>
<property name="usesScrollButtons" >
<bool>true</bool>
@ -1380,7 +1380,7 @@ workstation with this address:</string>
</attribute>
<layout class="QGridLayout" >
<property name="verticalSpacing" >
<number>20</number>
<number>6</number>
</property>
<property name="margin" >
<number>6</number>
@ -1401,7 +1401,7 @@ workstation with this address:</string>
</property>
</widget>
</item>
<item row="5" column="0" >
<item row="4" column="0" >
<widget class="QTextEdit" name="pix_generated_fixup" >
<property name="verticalScrollBarPolicy" >
<enum>Qt::ScrollBarAlwaysOn</enum>
@ -1468,49 +1468,6 @@ workstation with this address:</string>
</item>
</layout>
</item>
<item row="4" column="0" >
<layout class="QHBoxLayout" >
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>170</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="displayCommandsButton" >
<property name="text" >
<string>Display generated commands</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="0" >
<widget class="QTabWidget" name="fixup_notebook" >
<property name="sizePolicy" >
@ -4406,7 +4363,6 @@ the packet should go to, and which is the next hop
<tabstop>syslog_host</tabstop>
<tabstop>syslog_queue_size</tabstop>
<tabstop>syslog_facility</tabstop>
<tabstop>displayCommandsButton</tabstop>
<tabstop>ipv4before_2</tabstop>
</tabstops>
<resources/>
@ -4571,21 +4527,5 @@ the packet should go to, and which is the next hop
</hint>
</hints>
</connection>
<connection>
<sender>displayCommandsButton</sender>
<signal>clicked()</signal>
<receiver>pixAdvancedDialog_q</receiver>
<slot>displayCommands()</slot>
<hints>
<hint type="sourcelabel" >
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>