1
0
mirror of https://github.com/fwbuilder/fwbuilder synced 2026-03-19 01:37:17 +01:00
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:
Vadim Kurland 2011-02-24 18:55:55 -08:00
parent 5b3160267d
commit 98a2f51d52
8 changed files with 63 additions and 14 deletions

View File

@ -1,5 +1,14 @@
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
should run /etc/rc.d/pf script to reload PF rules on FreeBSD when
generated script is in rc.conf format"

View File

@ -130,8 +130,12 @@ void CompilerDriver::determineOutputFileNames(Cluster *cluster,
QString::fromUtf8(options->getStr(
opt_name.arg(i).toStdString()).c_str());
if (!name_from_option.isEmpty()) file_names[i] = name_from_option;
else
if (!name_from_option.isEmpty())
{
// 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
// files: if we have the name for the first conf file from

View File

@ -805,6 +805,18 @@ QString FirewallInstaller::getGeneratedFileFullPath(Firewall *fw)
* setting that user enters in the "Compiler" tab of fw advanced
* 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();
QString generated_file;
QString ofname = QString::fromUtf8(fwopt->getStr("output_file").c_str());
@ -813,14 +825,7 @@ QString FirewallInstaller::getGeneratedFileFullPath(Firewall *fw)
generated_file = ofname;
} else
generated_file = QString::fromUtf8(fw->getName().c_str()) + ".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);
return generated_file;
}
void FirewallInstaller::terminate()

View File

@ -114,6 +114,7 @@ public:
virtual void activatePolicy(const QString &script, const QString &args);
static QString getGeneratedFileFullPath(libfwbuilder::Firewall *fw);
static QString getGeneratedFileName(libfwbuilder::Firewall *fw);
virtual bool readManifest(const QString &conffie,
QMap<QString, QString> *all_files);

View File

@ -921,7 +921,18 @@ void ProjectPanel::inspect(set<Firewall *> fws)
foreach(Firewall *fw, fws)
{
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::getGeneratedFileName(fw);
if (QFile::exists(mainFile))
{
instConf cnf;

View File

@ -597,7 +597,17 @@ int instDialog::findFilesToInspect(QStringList &files)
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::getGeneratedFileName(f);
if (!QFile::exists(mainFile)) continue;
instConf cnf;
cnf.fwobj = f;

View File

@ -242,16 +242,19 @@ Can't compile firewall policy."),
for (list<Firewall*>::iterator it=members.begin(); it!=members.end(); ++it)
{
QString fw_id = project->db()->getStringId((*it)->getId()).c_str();
// name_pairs.push_back(
// fw_id + "," + FirewallInstaller::getGeneratedFileFullPath(*it)
// );
name_pairs.push_back(
fw_id + "," + FirewallInstaller::getGeneratedFileFullPath(*it)
fw_id + "," + FirewallInstaller::getGeneratedFileName(*it)
);
}
args.push_back(name_pairs.join(","));
} else
{
args.push_back("-o");
args.push_back(
FirewallInstaller::getGeneratedFileFullPath(fw));
// args.push_back(FirewallInstaller::getGeneratedFileFullPath(fw));
args.push_back(FirewallInstaller::getGeneratedFileName(fw));
}
args.push_back("-i");

View File

@ -1230,7 +1230,13 @@ void instDialog::readInstallerOptionsFromFirewallObject(Firewall *fw)
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.fwbfile = project->db()->getFileName().c_str();
cnf.wdir = getFileDir( project->getRCS()->getFileName() );