mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-03-19 09:47:20 +01:00
see #2047
Do not pass full path to the output file as an argument of the "-o" option when the GUI launches policy compiler. Since the "-d" option passes directory path where files sould be saved, actual file names do not need to be absolute path, except if the user entered absolute path for the output file name in the firewall settings dialog.
This commit is contained in:
parent
5b3160267d
commit
98a2f51d52
@ -1,5 +1,14 @@
|
|||||||
2011-02-24 Vadim Kurland <vadim@netcitadel.com>
|
2011-02-24 Vadim Kurland <vadim@netcitadel.com>
|
||||||
|
|
||||||
|
* FirewallInstaller.cpp (getGeneratedFileName): see #2047 "Inspect
|
||||||
|
generated files button shows different path information". Do not
|
||||||
|
pass full path to the output file as an argument of the "-o"
|
||||||
|
option when the GUI launches policy compiler. Since the "-d"
|
||||||
|
option passes directory path where files sould be saved, actual
|
||||||
|
file names do not need to be absolute path, except if the user
|
||||||
|
entered absolute path for the output file name in the firewall
|
||||||
|
settings dialog.
|
||||||
|
|
||||||
* configlets/freebsd/installer_commands_root: see #2143 "installer
|
* configlets/freebsd/installer_commands_root: see #2143 "installer
|
||||||
should run /etc/rc.d/pf script to reload PF rules on FreeBSD when
|
should run /etc/rc.d/pf script to reload PF rules on FreeBSD when
|
||||||
generated script is in rc.conf format"
|
generated script is in rc.conf format"
|
||||||
|
|||||||
@ -130,8 +130,12 @@ void CompilerDriver::determineOutputFileNames(Cluster *cluster,
|
|||||||
QString::fromUtf8(options->getStr(
|
QString::fromUtf8(options->getStr(
|
||||||
opt_name.arg(i).toStdString()).c_str());
|
opt_name.arg(i).toStdString()).c_str());
|
||||||
|
|
||||||
if (!name_from_option.isEmpty()) file_names[i] = name_from_option;
|
if (!name_from_option.isEmpty())
|
||||||
else
|
{
|
||||||
|
// user provided a name for the conf1 file in the
|
||||||
|
// firewall settings dialog.
|
||||||
|
file_names[i] = name_from_option;
|
||||||
|
} else
|
||||||
{
|
{
|
||||||
// special-case file names for the 2-d and subsequent conf
|
// special-case file names for the 2-d and subsequent conf
|
||||||
// files: if we have the name for the first conf file from
|
// files: if we have the name for the first conf file from
|
||||||
|
|||||||
@ -805,6 +805,18 @@ QString FirewallInstaller::getGeneratedFileFullPath(Firewall *fw)
|
|||||||
* setting that user enters in the "Compiler" tab of fw advanced
|
* setting that user enters in the "Compiler" tab of fw advanced
|
||||||
* dialog can be either local or absolute path.
|
* dialog can be either local or absolute path.
|
||||||
*/
|
*/
|
||||||
|
QString generated_file = getGeneratedFileName(fw);
|
||||||
|
QFileInfo gen_file_info(generated_file);
|
||||||
|
if (!gen_file_info.isAbsolute())
|
||||||
|
{
|
||||||
|
QFileInfo fwb_file_info = QFileInfo(mw->getRCS()->getFileName());
|
||||||
|
generated_file = fwb_file_info.dir().path() + "/" + generated_file;
|
||||||
|
}
|
||||||
|
return QDir::toNativeSeparators(generated_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString FirewallInstaller::getGeneratedFileName(Firewall *fw)
|
||||||
|
{
|
||||||
FWOptions *fwopt = fw->getOptionsObject();
|
FWOptions *fwopt = fw->getOptionsObject();
|
||||||
QString generated_file;
|
QString generated_file;
|
||||||
QString ofname = QString::fromUtf8(fwopt->getStr("output_file").c_str());
|
QString ofname = QString::fromUtf8(fwopt->getStr("output_file").c_str());
|
||||||
@ -813,14 +825,7 @@ QString FirewallInstaller::getGeneratedFileFullPath(Firewall *fw)
|
|||||||
generated_file = ofname;
|
generated_file = ofname;
|
||||||
} else
|
} else
|
||||||
generated_file = QString::fromUtf8(fw->getName().c_str()) + ".fw";
|
generated_file = QString::fromUtf8(fw->getName().c_str()) + ".fw";
|
||||||
|
return generated_file;
|
||||||
QFileInfo gen_file_info(generated_file);
|
|
||||||
if (!gen_file_info.isAbsolute())
|
|
||||||
{
|
|
||||||
QFileInfo fwb_file_info = QFileInfo(mw->getRCS()->getFileName());
|
|
||||||
generated_file = fwb_file_info.dir().path() + "/" + generated_file;
|
|
||||||
}
|
|
||||||
return QDir::toNativeSeparators(generated_file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FirewallInstaller::terminate()
|
void FirewallInstaller::terminate()
|
||||||
|
|||||||
@ -114,6 +114,7 @@ public:
|
|||||||
virtual void activatePolicy(const QString &script, const QString &args);
|
virtual void activatePolicy(const QString &script, const QString &args);
|
||||||
|
|
||||||
static QString getGeneratedFileFullPath(libfwbuilder::Firewall *fw);
|
static QString getGeneratedFileFullPath(libfwbuilder::Firewall *fw);
|
||||||
|
static QString getGeneratedFileName(libfwbuilder::Firewall *fw);
|
||||||
virtual bool readManifest(const QString &conffie,
|
virtual bool readManifest(const QString &conffie,
|
||||||
QMap<QString, QString> *all_files);
|
QMap<QString, QString> *all_files);
|
||||||
|
|
||||||
|
|||||||
@ -921,7 +921,18 @@ void ProjectPanel::inspect(set<Firewall *> fws)
|
|||||||
foreach(Firewall *fw, fws)
|
foreach(Firewall *fw, fws)
|
||||||
{
|
{
|
||||||
if (first_fw == NULL) first_fw = fw;
|
if (first_fw == NULL) first_fw = fw;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* get full path to the generated file. The path is built from
|
||||||
|
* the file name returned by
|
||||||
|
* FirewallInstaller::getGeneratedFileName() and directory
|
||||||
|
* path from the .fwb file. Note that we use the same
|
||||||
|
* algorithm when GUI launches policy compiler, except there
|
||||||
|
* the path is passed to it via "-d" command line option.
|
||||||
|
*/
|
||||||
QString mainFile = FirewallInstaller::getGeneratedFileFullPath(fw);
|
QString mainFile = FirewallInstaller::getGeneratedFileFullPath(fw);
|
||||||
|
// QString mainFile = FirewallInstaller::getGeneratedFileName(fw);
|
||||||
|
|
||||||
if (QFile::exists(mainFile))
|
if (QFile::exists(mainFile))
|
||||||
{
|
{
|
||||||
instConf cnf;
|
instConf cnf;
|
||||||
|
|||||||
@ -597,7 +597,17 @@ int instDialog::findFilesToInspect(QStringList &files)
|
|||||||
|
|
||||||
foreach(Firewall *f, fwlist)
|
foreach(Firewall *f, fwlist)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* get full path to the generated file. The path is built from
|
||||||
|
* the file name returned by
|
||||||
|
* FirewallInstaller::getGeneratedFileName() and directory
|
||||||
|
* path from the .fwb file. Note that we use the same
|
||||||
|
* algorithm when GUI launches policy compiler, except there
|
||||||
|
* the path is passed to it via "-d" command line option.
|
||||||
|
*/
|
||||||
QString mainFile = FirewallInstaller::getGeneratedFileFullPath(f);
|
QString mainFile = FirewallInstaller::getGeneratedFileFullPath(f);
|
||||||
|
// QString mainFile = FirewallInstaller::getGeneratedFileName(f);
|
||||||
|
|
||||||
if (!QFile::exists(mainFile)) continue;
|
if (!QFile::exists(mainFile)) continue;
|
||||||
instConf cnf;
|
instConf cnf;
|
||||||
cnf.fwobj = f;
|
cnf.fwobj = f;
|
||||||
|
|||||||
@ -242,16 +242,19 @@ Can't compile firewall policy."),
|
|||||||
for (list<Firewall*>::iterator it=members.begin(); it!=members.end(); ++it)
|
for (list<Firewall*>::iterator it=members.begin(); it!=members.end(); ++it)
|
||||||
{
|
{
|
||||||
QString fw_id = project->db()->getStringId((*it)->getId()).c_str();
|
QString fw_id = project->db()->getStringId((*it)->getId()).c_str();
|
||||||
|
// name_pairs.push_back(
|
||||||
|
// fw_id + "," + FirewallInstaller::getGeneratedFileFullPath(*it)
|
||||||
|
// );
|
||||||
name_pairs.push_back(
|
name_pairs.push_back(
|
||||||
fw_id + "," + FirewallInstaller::getGeneratedFileFullPath(*it)
|
fw_id + "," + FirewallInstaller::getGeneratedFileName(*it)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
args.push_back(name_pairs.join(","));
|
args.push_back(name_pairs.join(","));
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
args.push_back("-o");
|
args.push_back("-o");
|
||||||
args.push_back(
|
// args.push_back(FirewallInstaller::getGeneratedFileFullPath(fw));
|
||||||
FirewallInstaller::getGeneratedFileFullPath(fw));
|
args.push_back(FirewallInstaller::getGeneratedFileName(fw));
|
||||||
}
|
}
|
||||||
|
|
||||||
args.push_back("-i");
|
args.push_back("-i");
|
||||||
|
|||||||
@ -1230,7 +1230,13 @@ void instDialog::readInstallerOptionsFromFirewallObject(Firewall *fw)
|
|||||||
|
|
||||||
cnf.fwdir = s;
|
cnf.fwdir = s;
|
||||||
|
|
||||||
cnf.script = FirewallInstaller::getGeneratedFileFullPath(fw);
|
/*
|
||||||
|
* Generated files should be saved in the same directory where
|
||||||
|
* the .fwb file is located, except if user specified full path
|
||||||
|
* in the advaced settings dialog.
|
||||||
|
*/
|
||||||
|
// cnf.script = FirewallInstaller::getGeneratedFileFullPath(fw);
|
||||||
|
cnf.script = FirewallInstaller::getGeneratedFileName(fw);
|
||||||
cnf.remote_script = ""; // filled in FirewallInstaller::readManifest()
|
cnf.remote_script = ""; // filled in FirewallInstaller::readManifest()
|
||||||
cnf.fwbfile = project->db()->getFileName().c_str();
|
cnf.fwbfile = project->db()->getFileName().c_str();
|
||||||
cnf.wdir = getFileDir( project->getRCS()->getFileName() );
|
cnf.wdir = getFileDir( project->getRCS()->getFileName() );
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user