mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-09-13 08:29:32 +02:00
* fwbedit.cpp (main): added command line switch "-d" to function
"import" in fwbedit. This switch activates object deduplication on import.
This commit is contained in:
@@ -7,7 +7,7 @@ FWB_MICRO_VERSION=0
|
|||||||
# build number is like "nano" version number. I am incrementing build
|
# build number is like "nano" version number. I am incrementing build
|
||||||
# number during development cycle
|
# number during development cycle
|
||||||
#
|
#
|
||||||
BUILD_NUM="3527"
|
BUILD_NUM="3528"
|
||||||
|
|
||||||
VERSION="$FWB_MAJOR_VERSION.$FWB_MINOR_VERSION.$FWB_MICRO_VERSION.$BUILD_NUM"
|
VERSION="$FWB_MAJOR_VERSION.$FWB_MINOR_VERSION.$FWB_MICRO_VERSION.$BUILD_NUM"
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
#define VERSION "4.2.0.3527"
|
#define VERSION "4.2.0.3528"
|
||||||
#define GENERATION "4.2"
|
#define GENERATION "4.2"
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
2011-04-17 vadim <vadim@netcitadel.com>
|
||||||
|
|
||||||
|
* fwbedit.cpp (main): added command line switch "-d" to function
|
||||||
|
"import" in fwbedit. This switch activates object deduplication
|
||||||
|
on import.
|
||||||
|
|
||||||
2011-04-15 vadim <vadim@netcitadel.com>
|
2011-04-15 vadim <vadim@netcitadel.com>
|
||||||
|
|
||||||
* fwbedit.cpp (main): see #2328 "Add ability to run firewall import
|
* fwbedit.cpp (main): see #2328 "Add ability to run firewall import
|
||||||
|
|||||||
+31
-28
@@ -31,9 +31,9 @@ below).
|
|||||||
|
|
||||||
Creates new object.
|
Creates new object.
|
||||||
|
|
||||||
-f file.fwb: data file
|
-f file.fwb data file
|
||||||
-t objtype: create new object of this type
|
-t objtype create new object of this type
|
||||||
-p parent: create new object as a child of this object.
|
-p parent create new object as a child of this object.
|
||||||
This parameter is mandatory. If you are adding an address
|
This parameter is mandatory. If you are adding an address
|
||||||
to an interface, corresponding interface onkect must be
|
to an interface, corresponding interface onkect must be
|
||||||
specified as the parent. Similarly if you need to add an
|
specified as the parent. Similarly if you need to add an
|
||||||
@@ -42,8 +42,8 @@ Creates new object.
|
|||||||
object to one of the standard folders, the parent is the
|
object to one of the standard folders, the parent is the
|
||||||
library you want to add the object to or correct full
|
library you want to add the object to or correct full
|
||||||
path to the folder in the tree.
|
path to the folder in the tree.
|
||||||
-n name: the name of the new object
|
-n name the name of the new object
|
||||||
-c txt: specify comment for the new object
|
-c txt specify comment for the new object
|
||||||
-a attribute1[,attribute2...] : specify attributes that
|
-a attribute1[,attribute2...] : specify attributes that
|
||||||
define parameters of the new object (see below)
|
define parameters of the new object (see below)
|
||||||
|
|
||||||
@@ -52,8 +52,8 @@ Creates new object.
|
|||||||
|
|
||||||
Deletes object specified by its full path in the tree or object ID.
|
Deletes object specified by its full path in the tree or object ID.
|
||||||
|
|
||||||
-f file.fwb: data file
|
-f file.fwb data file
|
||||||
-o object: object to be deleted, full path or ID
|
-o object object to be deleted, full path or ID
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -62,9 +62,9 @@ Deletes object specified by its full path in the tree or object ID.
|
|||||||
Modifies object specified by its full path in the tree or object ID.
|
Modifies object specified by its full path in the tree or object ID.
|
||||||
Object can not be renamed using this operation.
|
Object can not be renamed using this operation.
|
||||||
|
|
||||||
-f file.fwb: data file
|
-f file.fwb data file
|
||||||
-o object: object to be deleted, full path or ID
|
-o object object to be deleted, full path or ID
|
||||||
-c txt: specify comment for the new object
|
-c txt specify comment for the new object
|
||||||
-a attribute1[,attribute2...] : specify attributes that
|
-a attribute1[,attribute2...] : specify attributes that
|
||||||
define parameters of the new object (see below)
|
define parameters of the new object (see below)
|
||||||
|
|
||||||
@@ -74,8 +74,8 @@ Object can not be renamed using this operation.
|
|||||||
|
|
||||||
Prints name and ID of an object.
|
Prints name and ID of an object.
|
||||||
|
|
||||||
-f file.fwb: data file
|
-f file.fwb data file
|
||||||
-o object: object to print, full path or ID
|
-o object object to print, full path or ID
|
||||||
-r print specified object and all objects under it in the tree
|
-r print specified object and all objects under it in the tree
|
||||||
-c print only children objects of the given object but do not
|
-c print only children objects of the given object but do not
|
||||||
print the object itself.
|
print the object itself.
|
||||||
@@ -101,10 +101,10 @@ Prints name and ID of an object.
|
|||||||
Adds object specified by path or ID to a group, also specified by its
|
Adds object specified by path or ID to a group, also specified by its
|
||||||
path or ID.
|
path or ID.
|
||||||
|
|
||||||
-f file.fwb: data file
|
-f file.fwb data file
|
||||||
-g group: group the object should be added to,
|
-g group group the object should be added to,
|
||||||
full path or ID
|
full path or ID
|
||||||
-o object: object to be deleted, full path or ID
|
-o object object to be deleted, full path or ID
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -112,17 +112,17 @@ path or ID.
|
|||||||
|
|
||||||
Removes object from a group.
|
Removes object from a group.
|
||||||
|
|
||||||
-f file.fwb: data file
|
-f file.fwb data file
|
||||||
-g group: group the object should be removed from,
|
-g group group the object should be removed from,
|
||||||
full path or ID
|
full path or ID
|
||||||
-o object: object to be deleted, full path or ID
|
-o object object to be deleted, full path or ID
|
||||||
|
|
||||||
|
|
||||||
.B upgrade -f file.fwb
|
.B upgrade -f file.fwb
|
||||||
|
|
||||||
Upgrades data file to the latest data format version.
|
Upgrades data file to the latest data format version.
|
||||||
|
|
||||||
-f file.fwb: data file
|
-f file.fwb data file
|
||||||
|
|
||||||
|
|
||||||
.B checktree -f file.fwb
|
.B checktree -f file.fwb
|
||||||
@@ -130,7 +130,7 @@ Upgrades data file to the latest data format version.
|
|||||||
Checks consistency and correctness of the object tree in the given
|
Checks consistency and correctness of the object tree in the given
|
||||||
data file and repairs it if necessary.
|
data file and repairs it if necessary.
|
||||||
|
|
||||||
-f file.fwb: data file
|
-f file.fwb data file
|
||||||
|
|
||||||
|
|
||||||
.B merge -f file1.fwb -i file2.fwb
|
.B merge -f file1.fwb -i file2.fwb
|
||||||
@@ -138,21 +138,24 @@ data file and repairs it if necessary.
|
|||||||
Objects from the file2.fwb are merged with objects in file1 and
|
Objects from the file2.fwb are merged with objects in file1 and
|
||||||
combined object tree saved in file1.fwb
|
combined object tree saved in file1.fwb
|
||||||
|
|
||||||
-f file.fwb: data file #1
|
-f file.fwb data file #1
|
||||||
-i file.fwb: data file #2
|
-i file.fwb data file #2
|
||||||
|
|
||||||
|
|
||||||
.B import -f file1.fwb -i firewall_config.txt -o path_to_firewall_object
|
.B import -f file1.fwb -i firewall_config.txt -o path_to_firewall_object [-d]
|
||||||
|
|
||||||
Firewall configuration from file firewall_config.txt is parsed and
|
Firewall configuration from file firewall_config.txt is parsed and
|
||||||
imported into data file file1.fwb. The program creates new firewall
|
imported into data file file1.fwb. The program creates new firewall
|
||||||
object located in the library and with the name defined by its path
|
object located in the library and with the name defined by its path
|
||||||
path_to_firewall_object. This has to be full path, beginning with the
|
path_to_firewall_object.
|
||||||
library name, such as "/User/Firewalls/my_new_firewall"
|
|
||||||
|
|
||||||
-f file.fwb: data file #1
|
-f file.fwb data file #1
|
||||||
-i config.txt: firewall configuration file
|
-i config.txt firewall configuration file
|
||||||
-o object_path
|
-o object_path full path to the firewall object that will be
|
||||||
|
created. This has to be full path, beginning
|
||||||
|
with the library name, such as
|
||||||
|
"/User/Firewalls/my_new_firewall"
|
||||||
|
-d avoid creating duplicate objects on import
|
||||||
|
|
||||||
currently (as of v4.2.0) fwbuilder supports import of iptables
|
currently (as of v4.2.0) fwbuilder supports import of iptables
|
||||||
configuration saved with iptables-save command, as well as import of
|
configuration saved with iptables-save command, as well as import of
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
|
|
||||||
%define name fwbuilder
|
%define name fwbuilder
|
||||||
%define version 4.2.0.3527
|
%define version 4.2.0.3528
|
||||||
%define release 1
|
%define release 1
|
||||||
|
|
||||||
%if "%_vendor" == "MandrakeSoft"
|
%if "%_vendor" == "MandrakeSoft"
|
||||||
|
|||||||
@@ -4,6 +4,6 @@ Replaces: fwbuilder (<=4.1.1-1), fwbuilder-common, fwbuilder-bsd, fwbuilder-linu
|
|||||||
Priority: extra
|
Priority: extra
|
||||||
Section: checkinstall
|
Section: checkinstall
|
||||||
Maintainer: vadim@fwbuilder.org
|
Maintainer: vadim@fwbuilder.org
|
||||||
Version: 4.2.0.3527-1
|
Version: 4.2.0.3528-1
|
||||||
Depends: libqt4-gui (>= 4.3.0), libxml2, libxslt1.1, libsnmp | libsnmp15
|
Depends: libqt4-gui (>= 4.3.0), libxml2, libxslt1.1, libsnmp | libsnmp15
|
||||||
Description: Firewall Builder GUI and policy compilers
|
Description: Firewall Builder GUI and policy compilers
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
%define name fwbuilder
|
%define name fwbuilder
|
||||||
%define version 4.2.0.3527
|
%define version 4.2.0.3528
|
||||||
%define release 1
|
%define release 1
|
||||||
|
|
||||||
%if "%_vendor" == "MandrakeSoft"
|
%if "%_vendor" == "MandrakeSoft"
|
||||||
|
|||||||
+16
-4
@@ -340,14 +340,16 @@ void usage_merge()
|
|||||||
void usage_import()
|
void usage_import()
|
||||||
{
|
{
|
||||||
cout <<
|
cout <<
|
||||||
" import -f file1.fwb -i firewall_config.txt -o firewall_object_path\n"
|
" import -f file1.fwb -i firewall_config.txt -o firewall_object_path [-d]\n"
|
||||||
"\n"
|
"\n"
|
||||||
" -f file1.fwb: data file #1\n"
|
" -f file1.fwb: data file #1\n"
|
||||||
" -i firewall_config.txt: firewall configuration file that\n"
|
" -i firewall_config.txt: firewall configuration file that\n"
|
||||||
" should be imported #2\n"
|
" should be imported #2\n"
|
||||||
" -o firewall_object_path: a full path to the firewall object\n"
|
" -o firewall_object_path: a full path to the firewall object\n"
|
||||||
" to be created, e.g. '/User/Firewalls/my_new_firewall'\n"
|
" to be created, e.g. '/User/Firewalls/my_new_firewall'\n"
|
||||||
" Note that path must start with the library name\n";
|
" Note that path must start with the library name\n"
|
||||||
|
" -d reuse address and service objects created in the process\n"
|
||||||
|
" of import\n";
|
||||||
cout << endl;
|
cout << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -452,6 +454,7 @@ int main(int argc, char * const *argv)
|
|||||||
string list_format = "%path%";
|
string list_format = "%path%";
|
||||||
bool full_dump = false;
|
bool full_dump = false;
|
||||||
string import_config;
|
string import_config;
|
||||||
|
bool deduplicate = false;
|
||||||
|
|
||||||
if (argc<=1)
|
if (argc<=1)
|
||||||
{
|
{
|
||||||
@@ -676,13 +679,14 @@ int main(int argc, char * const *argv)
|
|||||||
|
|
||||||
case IMPORT:
|
case IMPORT:
|
||||||
// -f file.fwb -i config.txt -o /User/Firewalls/new_firewall
|
// -f file.fwb -i config.txt -o /User/Firewalls/new_firewall
|
||||||
while( (opt=getopt(argc, args, "f:i:o:")) != EOF )
|
while( (opt=getopt(argc, args, "f:i:o:d")) != EOF )
|
||||||
{
|
{
|
||||||
switch(opt)
|
switch(opt)
|
||||||
{
|
{
|
||||||
case 'f': filename = optarg; break;
|
case 'f': filename = optarg; break;
|
||||||
case 'i': import_config = optarg; break;
|
case 'i': import_config = optarg; break;
|
||||||
case 'o': object = optarg; break;
|
case 'o': object = optarg; break;
|
||||||
|
case 'd': deduplicate = true; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -729,6 +733,7 @@ int main(int argc, char * const *argv)
|
|||||||
}
|
}
|
||||||
mergeTree(objdb, filemerge, conflict_res);
|
mergeTree(objdb, filemerge, conflict_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (cmd == IMPORT)
|
else if (cmd == IMPORT)
|
||||||
{
|
{
|
||||||
if (import_config.empty() || object.empty())
|
if (import_config.empty() || object.empty())
|
||||||
@@ -774,35 +779,42 @@ int main(int argc, char * const *argv)
|
|||||||
<< "'"
|
<< "'"
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
importConfig(objdb, import_config, library, fw_name);
|
importConfig(import_config, library, fw_name, deduplicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (cmd == STRUCT)
|
else if (cmd == STRUCT)
|
||||||
{
|
{
|
||||||
checkAndRepairTree(objdb);
|
checkAndRepairTree(objdb);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (cmd == LIST)
|
else if (cmd == LIST)
|
||||||
{
|
{
|
||||||
listObject(objdb, object, list_children, recursive,
|
listObject(objdb, object, list_children, recursive,
|
||||||
list_format, full_dump);
|
list_format, full_dump);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (cmd == UPGRADE)
|
else if (cmd == UPGRADE)
|
||||||
{
|
{
|
||||||
cout << "File upgraded; current data format version: "
|
cout << "File upgraded; current data format version: "
|
||||||
<< libfwbuilder::Constants::getDataFormatVersion() << endl;
|
<< libfwbuilder::Constants::getDataFormatVersion() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (cmd == NEWOBJECT)
|
else if (cmd == NEWOBJECT)
|
||||||
{
|
{
|
||||||
newObject(objdb, objtype, name, comment_txt, parent, ops);
|
newObject(objdb, objtype, name, comment_txt, parent, ops);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (cmd == DELOBJECT)
|
else if (cmd == DELOBJECT)
|
||||||
{
|
{
|
||||||
delObject(objdb, object);
|
delObject(objdb, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (cmd == MODOBJECT)
|
else if (cmd == MODOBJECT)
|
||||||
{
|
{
|
||||||
modObject(objdb, object, comment_txt, ops);
|
modObject(objdb, object, comment_txt, ops);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -72,10 +72,10 @@ extern void checkAndRepairTree(libfwbuilder::FWObjectDatabase *objdb);
|
|||||||
extern void mergeTree(libfwbuilder::FWObjectDatabase *objdb,
|
extern void mergeTree(libfwbuilder::FWObjectDatabase *objdb,
|
||||||
const std::string &mergefile, int conflict_res);
|
const std::string &mergefile, int conflict_res);
|
||||||
|
|
||||||
extern void importConfig(libfwbuilder::FWObjectDatabase *objdb,
|
extern void importConfig(const std::string &import_config,
|
||||||
const std::string &import_config,
|
|
||||||
libfwbuilder::FWObject *library,
|
libfwbuilder::FWObject *library,
|
||||||
const std::string &fw_name);
|
const std::string &fw_name,
|
||||||
|
bool deduplicate);
|
||||||
|
|
||||||
extern int splitStr(char ch,std::string s, operands * ops);
|
extern int splitStr(char ch,std::string s, operands * ops);
|
||||||
extern std::string getNextOpt(operands &ops);
|
extern std::string getNextOpt(operands &ops);
|
||||||
|
|||||||
+22
-5
@@ -42,10 +42,16 @@ using namespace libfwbuilder;
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
void importConfig(FWObjectDatabase *objdb,
|
Logger& operator<<(Logger &logger, const QString &str)
|
||||||
const string &import_config,
|
{
|
||||||
|
logger << str.toUtf8().constData();
|
||||||
|
return logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
void importConfig(const string &import_config,
|
||||||
FWObject *library,
|
FWObject *library,
|
||||||
const string &fw_name)
|
const string &fw_name,
|
||||||
|
bool deduplicate)
|
||||||
{
|
{
|
||||||
QFile f(QString::fromUtf8(import_config.c_str()));
|
QFile f(QString::fromUtf8(import_config.c_str()));
|
||||||
f.open(QFile::ReadOnly);
|
f.open(QFile::ReadOnly);
|
||||||
@@ -91,9 +97,20 @@ void importConfig(FWObjectDatabase *objdb,
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
imp->run();
|
if (deduplicate) imp->prepareForDeduplication();
|
||||||
imp->finalize();
|
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
imp->run();
|
||||||
|
} catch(ImporterException &e)
|
||||||
|
{
|
||||||
|
*logger << e.toString() << "\n";
|
||||||
|
} catch(ObjectMakerException &e)
|
||||||
|
{
|
||||||
|
*logger << e.toString() << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
imp->finalize();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user