Browse Source

Tested functionality: Help, Conflict detection, Setup/repair,

Credential, Start/stop with XCI.


git-svn-id: https://svn.microneil.com/svn/SNFUtility/trunk@20 aa37657e-1934-4a5f-aa6d-2d8eab27ff7c
master
adeniz 12 years ago
parent
commit
f12f035337

+ 3
- 9
Common/Utility.cpp View File

@@ -39,19 +39,15 @@ const string SNFGroupName = "snfuser";
// End of configuration. /////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
Utility::Utility() {
Utility::Utility() :
DebugRequested(false), VerboseRequested(false), ExplainRequested(false), HelpRequested(false)
{
}
bool
Utility::FileExists(const std::string File) {
if (Verbose()) {
cout << "Check whether " << File << " exists...";
}
bool Exists;
std::ifstream Input;
@@ -70,8 +66,6 @@ Utility::FileExists(const std::string File) {
Input.close();
OutputVerboseEnd();
return Exists;
}

+ 163
- 174
Common/UtilityConfig.cpp View File

@@ -153,64 +153,17 @@ UtilityConfig::UtilityConfig() :
}
void
UtilityConfig::CheckAndSetConfigFileName(const std::string DefaultFile[], int NumDefaultFiles) {
UtilityConfig::CheckAndSetConfigFileName(const std::string DefaultFile) {
string ProvisionalConfigFile = ConfigFileName;
string SpecifiedConfigFile = GetConfigFileName();
if (ProvisionalConfigFile.length() == 0) {
if (SpecifiedConfigFile.length() > 0) {
int i;
vector<string> FoundFile;
for (i = 0; i < NumDefaultFiles; i++) {
if (!FileExists(DefaultFile[i])) {
continue; // File doesn't exist.
}
FoundFile.push_back(DefaultFile[i]); // Update list of found files.
ProvisionalConfigFile = DefaultFile[i]; // Found configuration file.
}
if (0 == FoundFile.size()) { // No default file found.
if (NumDefaultFiles > 0) {
ProvisionalConfigFile = DefaultFile[0]; // Use the first default file.
} else { // No default config file was specified.
ostringstream Temp;
Temp << "Internal error: NumDefaultFiles <= 0 at " << __FILE__ << ":" << __LINE__;
throw std::runtime_error(Temp.str());
}
} else if (FoundFile.size() > 1) { // Multiple default files found.
string Temp;
Temp = "Configuration file was not specified, and more than one default configuration file was found::\n\n";
for (i = 0; i < FoundFile.size(); i++) {
Temp += " ";
Temp += FoundFile[i] + "\n";
}
throw std::runtime_error(Temp);
}
return;
}
SetConfigFileName(ProvisionalConfigFile);
SetConfigFileName(DefaultFile);
}
@@ -440,85 +393,6 @@ UtilityConfig::LoadInfo(){
}
void
UtilityConfig::SetupRepairIdentityFile(std::string SampleIdentityFile) {
std::string File = GetIdentityFileName();
if (!FileExists(File)) {
if (!Explain()) {
SaveFile.CreateBackupFile(File);
}
// Create the config file.
Copy(SampleIdentityFile, File);
}
}
void
UtilityConfig::SetupRepairRulebaseScript() {
std::string File = GetRulebaseScriptName();
if (!FileExists(File)) {
if (!Explain()) {
SaveFile.CreateBackupFile(File);
}
Copy(SampleRulebaseScriptFile, File); // Copy if !Explain().
}
SetMode(File, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); // Set permissions.
}
void
UtilityConfig::SetupRepairIgnoreListFile() {
string File = GetIgnoreListFileName();
if (!FileExists(File)) {
if (!Explain()) {
SaveFile.CreateBackupFile(File);
}
Copy(SampleIgnoreListFile, File);
}
SetMode(File, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); // Set permissions.
SetOwnerGroup(File); // Set to sniffer user.
}
void
UtilityConfig::SetupRepairLogDir() {
string LogDir = GetLogPath();
if (!FileExists(LogDir)) {
MkDir(LogDir);
}
SetMode(LogDir, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
SetOwnerGroup(LogDir);
}
UtilityConfig::StatusCheckMethod
UtilityConfig::GetPreferredStatusCheckMethod(void) {
@@ -590,7 +464,8 @@ UtilityConfig::GetReportViaXci() {
if (Verbose()) {
cout << "Getting Sniffer status report via XCI...";
std::cout << "Getting Sniffer status report via XCI...";
std::cout.flush();
}
@@ -665,7 +540,7 @@ UtilityConfig::GetReportViaXci() {
if (Verbose()) {
cout << "no response...";
std::cout << "no response...";
}
@@ -693,7 +568,11 @@ UtilityConfig::GetReportViaXci() {
}
OutputVerboseEnd();
if (Verbose()) {
std::cout << "response received...";
}
return Reader.report_response;
@@ -705,6 +584,7 @@ UtilityConfig::GetReportViaLogFile(std::string LogFileName, int SleepTime_msec)
if (Verbose()) {
cout << "Getting Sniffer status report via log file " << LogFileName << "...";
std::cout.flush();
}
@@ -747,7 +627,7 @@ UtilityConfig::CheckSnifferStatusReport(std::string StatusReport, std::string Ap
}
ConfigurationElement MyCFGReader("stats"); // Object to parse the XML.
ConfigurationData MyCFGData(StatusReport); // Object that contains the XML.
ConfigurationData MyCFGData(StatusReport.c_str(), StatusReport.length()); // Object that contains the XML.
std::string PlatformContent;
@@ -787,11 +667,14 @@ UtilityConfig::GetRunningState(std::string ApplicationName) {
if (Verbose()) {
cout << "Checking whether " << ApplicationName << " is running...";
cout.flush();
}
std::string StatusReport = GetSnifferStatusReport();
OutputVerboseEnd();
if (StatusReport.length() == 0) {
return SnifferIsStopped;
@@ -800,8 +683,6 @@ UtilityConfig::GetRunningState(std::string ApplicationName) {
CheckSnifferStatusReport(StatusReport, ApplicationName);
OutputVerboseEnd();
return SnifferIsRunning;
}
@@ -809,10 +690,109 @@ UtilityConfig::GetRunningState(std::string ApplicationName) {
void
UtilityConfig::SetupRepair(const std::string SampleIdentityFile) {
SetupRepairIdentityFile(SampleIdentityFile);
SetupRepairRulebaseScript();
SetupRepairIgnoreListFile();
SetupRepairLogDir();
RestoreMissingConfigFiles(SampleIdentityFile);
SetOwnerPermissionsOfConfigFiles();
}
void
UtilityConfig::RestoreMissingConfigFiles(std::string SampleIdentityFile) {
std::string File;
File = GetIdentityFileName();
if (!FileExists(File)) {
if (!Explain()) {
SaveFile.CreateBackupFile(File);
}
// Create the config file.
Copy(SampleIdentityFile, File);
}
File = GetRulebaseScriptName();
if (!FileExists(File)) {
if (!Explain()) {
SaveFile.CreateBackupFile(File);
}
Copy(SampleRulebaseScriptFile, File); // Copy if !Explain().
}
File = GetIgnoreListFileName();
if (!FileExists(File)) {
if (!Explain()) {
SaveFile.CreateBackupFile(File);
}
Copy(SampleIgnoreListFile, File);
}
std::string LogDir = GetLogPath();
if (!FileExists(LogDir)) {
MkDir(LogDir);
}
}
void
UtilityConfig::SetOwnerPermissionsOfConfigFiles() {
std::string File;
File = GetIdentityFileName();
if (FileExists(File)) {
SetMode(File, S_IRUSR | S_IWUSR | S_IRGRP);
SetOwnerGroup(File);
}
File = GetRulebaseScriptName();
if (FileExists(File)) {
SetMode(File, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
}
File = GetIgnoreListFileName();
if (FileExists(File)) {
SetMode(File, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
SetOwnerGroup(File);
}
std::string LogDir = GetLogPath();
if (FileExists(LogDir)) {
SetMode(LogDir, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
SetOwnerGroup(LogDir);
}
}
@@ -1243,6 +1223,13 @@ UtilityConfig::UpdateIdentityFileOld() {
void
UtilityConfig::StartSniffer(std::string ScriptAndArgs, std::string ApplicationName) {
if (SnifferIsRunning == GetRunningState(ApplicationName)) {
std::cout << ApplicationName << " is already running.\n";
return;
}
std::string Command;
Command = SnifferStartScriptDir + ScriptAndArgs;
@@ -1250,14 +1237,7 @@ UtilityConfig::StartSniffer(std::string ScriptAndArgs, std::string ApplicationNa
if (Verbose()) {
cout << "Starting Sniffer with the command '" << Command << "'...";
}
if (SnifferIsRunning == GetRunningState(ApplicationName)) {
std::cout << ApplicationName << " is already running.\n";
OutputVerboseEnd();
return;
cout.flush();
}
@@ -1273,23 +1253,34 @@ UtilityConfig::StartSniffer(std::string ScriptAndArgs, std::string ApplicationNa
}
}
OutputVerboseEnd();
if (SnifferIsRunning != GetRunningState(ApplicationName)) {
std::string Temp;
if (SnifferIsRunning != GetRunningState(ApplicationName)) {
std::string Temp;
Temp = "Unable to start " + ApplicationName;
throw std::runtime_error(Temp);
Temp = "Unable to start " + ApplicationName;
throw std::runtime_error(Temp);
}
}
OutputVerboseEnd();
} else {
OutputVerboseEnd();
}
}
void
UtilityConfig::StopSniffer(std::string ScriptAndArgs, std::string ApplicationName) {
if (SnifferIsStopped == GetRunningState(ApplicationName)) {
std::cout << ApplicationName << " is already not running.\n";
return;
}
std::string Command;
Command = SnifferStartScriptDir + ScriptAndArgs;
@@ -1297,14 +1288,7 @@ UtilityConfig::StopSniffer(std::string ScriptAndArgs, std::string ApplicationNam
if (Verbose()) {
cout << "Stopping Sniffer with the command '" << Command << "'...";
}
if (SnifferIsStopped == GetRunningState(ApplicationName)) {
std::cout << ApplicationName << " is already not running.\n";
OutputVerboseEnd();
return;
cout.flush();
}
@@ -1320,17 +1304,21 @@ UtilityConfig::StopSniffer(std::string ScriptAndArgs, std::string ApplicationNam
}
}
OutputVerboseEnd();
if (SnifferIsStopped != GetRunningState(ApplicationName)) {
std::string Temp;
if (SnifferIsStopped != GetRunningState(ApplicationName)) {
std::string Temp;
Temp = "Unable to sto " + ApplicationName;
throw std::runtime_error(Temp);
Temp = "Unable to stop " + ApplicationName;
throw std::runtime_error(Temp);
}
}
OutputVerboseEnd();
} else {
OutputVerboseEnd();
}
}
@@ -1368,9 +1356,10 @@ UtilityConfig::ProcessCommandLineItem(std::string OneInput) {
SetStopSniffer(true);
} else if (OneInput == ConfigFileKey) {
SetConfigFileName(OneInput.substr(ConfigFileKey.length()));
} else if (0 == OneInput.find(ConfigFileKey)) {
TempString = Trim(OneInput.substr(ConfigFileKey.length())); // Copy only if not null after trimming.
SetConfigFileName(TempString);
} else if (0 == OneInput.find(LicenseIdKey)) {

+ 32
- 58
Common/UtilityConfig.hpp View File

@@ -40,18 +40,14 @@ public:
//
// If the configuration file wasn't specified by
// SetConfigFileName() on the command line, then this method sets
// the config file to the default. The default is the unique file
// that exists in the specified list. If more than one file in
// the specified list exists, an exception is thrown.
// the config file to the specified default.
//
// If the configuration file was specified by SetConfigFileName()
// or on the command line, then this method does nothing.
//
// \param[in] DefaultFile is the list of default locations of the file.
// \param[in] DefaultFile is the default file name.
//
// \param[in] NumDefaultFiles is the number of defaultlocations.
//
void CheckAndSetConfigFileName(const std::string DefaultFile[], int NumDefaultFiles);
void CheckAndSetConfigFileName(const std::string DefaultFile);
/// If the configuration file doesn't exist, create it from the
/// sample file. In any case, set the owner and mode.
@@ -192,8 +188,37 @@ public:
// Make sure that the log directory exists and has the correct
// owner and permissions.
//
// \param[in] SampleIdentityFile is the name of the sample identity file.
//
// \note The configuration information must be loaded before calling this method.
//
// \see CheckAndSetConfigFileName.
//
// \see CreateDefaultConfigFile.
//
// \see LoadConfig.
//
// \see LoadInfo.
//
void SetupRepair(const std::string SampleIdentityFile);
/// Restore any missing configuration files.
//
// Restore missing configuration files from the sample files. The
// files restored are the ones restored by SetupRepair.
//
// \param[in] SampleIdentityFile is the name of the sample identity file.
//
void RestoreMissingConfigFiles(const std::string SampleIdentityFile);
/// Set the owner, group, and permissions of the configuration
/// files and directories.
//
// This method sets the ownership, group, and permissions of all
// the configuration files.
//
void SetOwnerPermissionsOfConfigFiles(void);
/// Update the rulebase script credentials.
//
// This method updates the rulebase with the credentials specified
@@ -353,57 +378,6 @@ private:
StatusCheckNotAvailable ///< No method for checking is available.
};
/// Setup/repair the identity file.
//
// If the identity file doesn't exist, create it from the sample
// file.
//
// In any case, set the owner and permissions of the identity
// file.
//
// \param[in] SampleIdentityFile is the name of the sample
// identity file.
//
// \note The configuration information must be loaded before calling this method.
//
// \see CheckAndSetConfigFileName.
//
// \see CreateDefaultConfigFile.
//
// \see LoadConfig.
//
// \see LoadInfo.
//
void SetupRepairIdentityFile(std::string SampleIdentityFile);
/// Setup/repair the rulebase script.
//
// If the rulebase script doesn't exist, this method creates the
// rulebase script from the sample rulebase script.
//
// In any case, set the owner and permissions of the rulebase
// script.
//
void SetupRepairRulebaseScript(void);
/// Setup/repair the ignore list file.
//
// The ignore list file is created if it dosn't exist. In any
// case, the owner/group is changed by SetOwnerGroup(), and the
// permissions are changed to readonly for everyone, and
// read/write for the owner.
//
void SetupRepairIgnoreListFile(void);
/// Setup/repair the log directory.
//
// The log directory is created if it dosn't exist. In any case,
// the owner/group is changed by SetOwnerGroup(), and the
// permissions are changed to r-x for everyone, and rwx for the
// owner.
//
void SetupRepairLogDir(void);
/// Determine the mode for checking the status of Sniffer.
//
// This method determines how the status of the sniffer should be

+ 22
- 17
SNFMilterConfig/SNFMilterConfig.cpp View File

@@ -186,8 +186,12 @@ SNFMilterConfig::ExecuteCommand() {
case SetupRepairCommand:
CreateLoadConfig(); // Save config file state create default
// config if necessary, and load config.
CheckAndSetConfigFileName(DefaultConfigFile); // Load the config file name if not specified.
CreateDefaultConfigFile(SampleConfigFile); // Create the file if it doesn't exist,
// Set owner and mode in any case.
LoadConfig();
LoadInfo(); // Load the file paths.
LoadSocketInfo(); // Load the socket path.
SetupRepair(SampleIdentityFile);
SetupRepairSocketDir();
@@ -196,7 +200,12 @@ SNFMilterConfig::ExecuteCommand() {
case UpdateCredentialsCommand:
UpdateRulebaseScriptCredentials();
CheckAndSetConfigFileName(DefaultConfigFile); // Load the config file name if not specified.
LoadConfig();
LoadInfo(); // Load the file paths.
LoadSocketInfo(); // Load the socket path.
UpdateRulebaseScriptCredentials();
DownloadRulebase();
@@ -218,11 +227,21 @@ SNFMilterConfig::ExecuteCommand() {
case StartSnifferCommand:
CheckAndSetConfigFileName(DefaultConfigFile);
LoadConfig();
LoadInfo();
LoadSocketInfo();
StartSniffer("snf-milter start", ApplicationName);
break;
case StopSnifferCommand:
CheckAndSetConfigFileName(DefaultConfigFile);
LoadConfig();
LoadInfo();
LoadSocketInfo();
StopSniffer("snf-milter stop", ApplicationName);
break;
@@ -285,20 +304,6 @@ SNFMilterConfig::SetupRepairSocketDir() {
}
void
SNFMilterConfig::CreateLoadConfig() {
CheckAndSetConfigFileName(&DefaultConfigFile, 1); // Load the config file name.
CreateDefaultConfigFile(SampleConfigFile); // Create the file if it doesn't exist,
// Set owner and mode in any case.
LoadConfig();
LoadInfo(); // Load the file paths.
LoadSocketInfo(); // Load the socket path.
}
void
SNFMilterConfig::SaveFileState() {

+ 0
- 14
SNFMilterConfig/SNFMilterConfig.hpp View File

@@ -58,20 +58,6 @@ public:
//
bool GetCommandLineInput(int argc, char* argv[]);
/// Load the configuration, creating default configuration if necessary.
//
// This method load the configuration specified in the command
// line, or the default config file. If the config file to load
// doesn't exit, the config file is created by copying from the
// sample config file.
//
// Side effect: The state of the config file is saved.
//
// Side effect: If the config file doesn't exist, a new config
// file is created.
//
void CreateLoadConfig(void);
/// Execute the command specified by the command-line parameters.
//
void ExecuteCommand(void);

+ 187
- 39
SNFMilterConfig/SNFMilterConfigTests.txt View File

@@ -4,70 +4,218 @@ $Id$

SNFUtility revision 9

Help functionality--
Help functionality
------------------

HELP-01: SNFMilterConfig without any command options outputs a help
message.

Credentials functionality--
Result: Pass.

CRED-01: Start with no identity.xml and no getRulebase. Verify that
when the valid credentials are specified on the command line:

1) getRulebase is created,
Conflict detection
------------------

2) The rulebase is downloaded,
CONFLICT-01: Run with -setup, -id, and -auth. Verify that help
message is output, and that SNFMilterConfig takes no action.

3) The identity.xml file is created.
Result: Pass.

Repeat with -mta=none, -mta=postfix, and -mta=sendmail.
CONFLICT-02: Run with -setup and -start. Verify that help message is
output, and that SNFMilterConfig takes no action.

CRED-02: After the previous test, specify incorrect credentials.
Verify:
Result: Pass.

1) getRulebase is not updated,
CONFLICT-03: Run with -setup and -stop. Verify that help message is
output, and that SNFMilterConfig takes no action.

Result: Pass.

CONFLICT-04: Run with -setup and -mta=XXX, where XXX is postfix,
sendmail, and none. Verify that help message is output, and that
SNFMilterConfig takes no action.

Result: Pass.

Setup/Repair functionality
--------------------------

SETUP-01: Start with no configuration files installed (SNFMilter.xml,
identity.xml GBUdbIgnoreList.txt, and getRulebase). Verify that
either "-setup" or "-repair" creates these files with the default
credentials.

Result: Pass.

SETUP-02: Repeat SETUP-01 with -v and verify that files are created.

Result: Pass.

SETUP-03: Repeat SETUP-01 with -explain and verify that files are not created.

Result: Pass? Exception thrown (as expected) when attempting to read
configuration file that doesn't exist.

Config file specification
-------------------------

CONF-01: Start with no configuration files, and copy the sample
configuration file to test.xml. Run with "-setup -config=test.xml",
and verify that all configuration files except
/etc/snf-milter/SNFMilter.xml are created.

Result: Pass.

CONF-02: Repeat with -v and verify the same behavior.

Result: Pass.

CONF-03: Repeat with -explain.

Result: Pass.

Credential Functionality
------------------------

CRED-01: Configure, and run "-id=xxx -auth=yyy" with specification of
incorrect credentials. Verify:

1) getRulebase is not updated, and getRulebase.failed file is
created.,

2) The rulebase downloaded fails, and an error message is output,

3) The identity.xml file is not created.
3) The identity.xml file is not changed.

Result: Pass.

CRED-02: Repeat CRED-01 with -v and verify correct operation.

Result: Pass.

CRED-03: Repeat CRED-01 with -explain and verify correct operation.

Result: Pass.

CRED-04: Install default configuration files. Modify identity.xml as
follows:

1) Change the license ID to "XXX" and authentication to "YYY".

2) Add a comment.

Then run with "-id=testmode -auth=setuptestingonly". Verify:

1) getRulebase is updated, and the new rulebase is downloaded.

2) identity.xml has only the license ID and authentication updated.

Result: Pass.

CRED-05: Repeat CRED-04 with -v and verify correct operation.

Result: Pass.

CRED-05: Repeat CRED-04 with -explain and verify correct operation.

Result: Pass

Start/stop functionality with XCI enabled
-----------------------------------------

START_STOP_XCI-01: Install default configuration files, and ensure
that SNFMilter is stoped. Create a configuration file
SNFMilter_xci.xml as follows:

1) Enable XCI.

2) Enable status.second logging, with no append.

3) Enable status.minute logging, with append.

Do the following, specifying the configuration file SNFMilter_xci.xml:

1) Run SNFMilterConfig with "-start", and verify that SNFMilter starts.

2) Run SNFMilterConfig with "-start" again and verify that SNFMilter
is not started again.

3) Run SNFMitlerConfig with "-stop" and verify that SNFMilter stops.

4) Run SNFMitlerConfig with "-stop" again and verify that SNFMilter
is not stopped again.

Result: Pass

START_STOP_XCI-02: Repeat START_STOP_XCI-01 but with "-v" in the command-line.

Result: Pass

START_STOP_XCI-03: Configure as for START_STOP_XCI-01, and do the following:

1) Run SNFMilterConfig with "-start -explain". Verify correct
output, and that SNFMilterConfig doesn't start SNFMilter.

2) Run SNFMilterConfig with "-stop -explain". Verify correct
output, and that SNFMilterConfig doesn't stop SNFMilter.

3) Start SNFMilter.

4) Run SNFMilterConfig with "-start -explain". Verify correct
output, and that SNFMilterConfig doesn't start SNFMilter.

5) Run SNFMilterConfig with "-stop -explain". Verify correct
output, and that SNFMilterConfig doesn't stop SNFMilter.

Result: Pass

Start/stop functionality with XCI disabled, status.second enabled
-----------------------------------------------------------------

START_STOP_SEC-01: Install default configuration files, and ensure
that SNFMilter is stoped. Create a configuration file
SNFMilter_second.xml as follows:

1) Disable XCI.

2) Enable status.second logging, with no append.

3) Enable status.minute logging, with append.

Do the following, specifying the configuration file SNFMilter_second.xml:

Repeat with -mta=none, -mta=postfix, and -mta=sendmail.
1) Run SNFMilterConfig with "-start", and verify that SNFMilter starts.

CRED-03: Start with no identity.xml and no getRulebase. Verify that
when no credentials are specified on the command line:
2) Run SNFMilterConfig with "-start" again and verify that SNFMilter
is not started again.

1) getRulebase is created with the default credentials,
3) Run SNFMitlerConfig with "-stop" and verify that SNFMilter stops.

2) The rulebase is not downloaded,
4) Run SNFMitlerConfig with "-stop" again and verify that SNFMilter
is not stopped again.

3) The identity.xml file is created with the default credentials..
Result:

Repeat with -mta=none, -mta=postfix, and -mta=sendmail.
START_STOP_SEC-02: Repeat START_STOP_SEC-01 but with "-v" in the
command-line.

Default config file functionality--
Result:

CONF-01: Starting with no configuration (no SNFMilter.xml,
identity.xml, getRulebase, rulebase file (but the default rulebase
file is present), or GBUdbIgnore.txt), run with the following
command-line parameters:
START_STOP_SEC-03: Configure as for START_STOP_SEC-01, and do the
following:

1) "-mta=none" installs all files with testmode credentials,
downloads rulebase, starts SNFMilter.
1) Run SNFMilterConfig with "-start -explain". Verify correct
output, and that SNFMilterConfig doesn't start SNFMilter.

2) "-mta=none -auth=xxx, id=yyy" where xxx/yyy is a valid auth/id
pair, installs all files with xxx/yyy credentials, downloads
rulebase, starts SNFMilter.
2) Run SNFMilterConfig with "-stop -explain". Verify correct
output, and that SNFMilterConfig doesn't stop SNFMilter.

3) "-mta=postfix" installs all files with testmode credentials,
downloads rulebase, starts SNFMilter, restarts postfix.
3) Start SNFMilter.

4) "-mta=postfix -auth=xxx, id=yyy" where xxx/yyy is a valid auth/id
pair, installs all files with xxx/yyy credentials, downloads
rulebase, starts SNFMilter, restarts postfix.
4) Run SNFMilterConfig with "-start -explain". Verify correct
output, and that SNFMilterConfig doesn't start SNFMilter.

5) "-mta=none -config=/etc/snf-milter/test.xml" installs all files
in the default locations except the configuration file is
test.xml, downloads rulebase, starts SNFMilter. Starting
SNFMilter should fail because there is no configuration file
test.xml. Verify that the configuration files are not present.
5) Run SNFMilterConfig with "-stop -explain". Verify correct
output, and that SNFMilterConfig doesn't stop SNFMilter.

Result:

+ 7
- 1
SNFMilterConfig/main.cpp View File

@@ -46,8 +46,14 @@ void RestoreFiles(SNFMilterConfig *Config) {
try {
cerr << "Restoring all configuration files...";
Config->SaveFile.RestoreAllFilesFromBackup();
cerr << "done.\n";
Config->SetOwnerPermissionsOfConfigFiles();
cerr << "done.\n\n"
<< "Configuration files that resulted in this error are saved with a suffix \""
<< Config->SaveFile.GetFailedFileName("") << "\".\n";
}
catch(exception& e) {

Loading…
Cancel
Save