Browse Source

Tested SetupRepair() functionality.


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

+ 18
- 13
Common/UtilityConfig.cpp View File

@@ -454,9 +454,9 @@ UtilityConfig::SetupRepairRulebaseScript() {
void
UtilityConfig::SetupRepairIgnoreListFile() {
string IgnoreListFile = GetIgnoreListFileName();
string File = GetIgnoreListFileName();
if (!FileExists(IgnoreListFile)) {
if (!FileExists(File)) {
if (!Explain()) {
@@ -464,12 +464,12 @@ UtilityConfig::SetupRepairIgnoreListFile() {
}
Copy(SampleIgnoreListFile, IgnoreListFile);
Copy(SampleIgnoreListFile, File);
}
SetMode(IgnoreListFile, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); // Set permissions.
SetOwnerGroup(IgnoreListFile); // Set to sniffer user.
SetMode(File, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); // Set permissions.
SetOwnerGroup(File); // Set to sniffer user.
}
@@ -490,7 +490,7 @@ UtilityConfig::SetupRepairLogDir() {
}
void
SNFMilterConfig::SetupRepair(std::string SampleIdentityFile) {
UtilityConfig::SetupRepair(const std::string SampleIdentityFile) {
SetupRepairIdentityFile(SampleIdentityFile);
SetupRepairRulebaseScript();
@@ -802,18 +802,19 @@ UtilityConfig::UpdateIdentityFile() {
throw runtime_error(Temp);
}
string Content = InputContent.str();
string Content = InputContents.str();
try {
ReplaceXmlAttribute(&Content, IdentityElementName, LicenseAttributeName, LicenseId);
ReplaceXmlAttribute(&Content, IdentityElementName, AuthenticationAtributeName, Authentication);
ReplaceXmlAttribute(&Content, IdentityElementName, AuthenticationAttributeName, Authentication);
} catch (std::exception &e) {
std::string Temp;
Temp = "Error updating credentials for identity file " + File;
Temp += ": " + e.what();
Temp += ": ";
Temp += e.what();
throw runtime_error(Temp);
}
@@ -1052,13 +1053,17 @@ UtilityConfig::HelpDescription(std::string ExclusiveCommandsHelp) {
std::string Desc;
Desc = "creates the configuration files (snf-config-file and the\n";
Desc += "ignore list file), the rulebase download script (default: getRulebase) if\n";
Desc += "they don't exist, and also the identity file.\n\n";
Desc = "creates and updates the configuration files (snf-config-file and\n";
Desc += "the ignore list file), the rulebase download script (default: getRulebase),\n";
Desc += "and the identity file if they don't exist.\n\n";
Desc += " -setup Perform initial setup/replace missing files\n";
Desc += " -repair Perform initial setup/replace missing files\n";
Desc += ExclusiveCommandsHelp;
Desc += " -config=snf-config-file Specifies the configuration file\n";
Desc += " -id=licenseid Specifies the license ID\n";
Desc += " -auth=authentication Specifies the Authentication\n";
Desc += " -start Start the sniffer\n";
Desc += " -stop Stop the sniffer\n";
Desc += " -config=snf-config-file Specifies the configuration file\n";
Desc += " -v Provide verbose output\n";
Desc += " -explain Provide an explaination of the actions\n";
Desc += " without executing any commands\n";

+ 18
- 0
Common/UtilityConfig.hpp View File

@@ -167,6 +167,24 @@ public:
/// Directory containing the Sniffer start script.
std::string SnifferStartScriptDir;
/// Setup/repair the configuration.
//
// Copy the following files from the sample files if they don't
// exist:
//
// <ol>
// <li> Identity file. </li>
// <li> Ignore list file. </li>
// <li> Rulebase script. </li>
// </ol>
//
// Set the owner/group of each of the above files.
//
// Make sure that the log directory exists and has the correct
// owner and permissions.
//
void SetupRepair(const std::string SampleIdentityFile);
/// Update the rulebase script credentials.
//
// This method updates the rulebase with the credentials specified

+ 6
- 9
SNFMilterConfig/SNFMilterConfig.cpp View File

@@ -81,8 +81,8 @@ SNFMilterConfig::DisplayHelp(std::string Version) {
ExclusiveCommands += IntegrateWithSendmailKey + " | ";
ExclusiveCommands += IntegrateWithNoneKey;
ExclusiveCommandsHelp = " -mta=postfix Integrate with postfix\n";
ExclusiveCommandsHelp += " -mta=sendmail Integrate with sendmail\n";
ExclusiveCommandsHelp = " -mta=postfix Integrate with postfix and start/reload postfix\n";
ExclusiveCommandsHelp += " -mta=sendmail Integrate with sendmail and start/reload sendmail\n";
ExclusiveCommandsHelp += " -mta=none Remove any integration with all supported MTAs\n";
cout
@@ -97,7 +97,9 @@ SNFMilterConfig::DisplayHelp(std::string Version) {
<< " " << DefaultConfigFile << "\n\n"
<< "If snf-config-file is not specified and the above file doesn't exist, then it is\n"
<< "copied from the following file:\n\n"
<< " " << SampleConfigFile << "\n\n";
<< " " << SampleConfigFile << "\n\n"
<< "If integration with an MTA is specified, that MTA is started if it isn't running,\n"
<< "or the MTA's configuration is reloaded if it is running.\n\n";
};
@@ -229,16 +231,13 @@ SNFMilterConfig::ExecuteCommand() {
#if 0
SnifferRunningStatue RunningStatus;
#endif
SnfMilterConfig.CreateLoadConfig(); // Save config file state and load config.
// Load the default if necessary.
#if 0
SnfMilterConfig.SaveFileState(); // Save state of all other files.
RunningStatus = SnfMilterConfig.GetSnifferRunningStatus(); // Get state before changing anything.
#endif
SnfMilterConfig.UpdateConfigFiles(); // Create/update config files
@@ -251,7 +250,6 @@ SNFMilterConfig::ExecuteCommand() {
SnfMilterConfig.DoIntegrationCommand(); // Integrate/unintegrate.
#if 0
if (SnifferIsStopped == RunningStatus) {
SnfMilterConfig.StartSniffer();
@@ -262,8 +260,7 @@ SNFMilterConfig::ExecuteCommand() {
<< "Please start SNFMilter if it isn't running.\n";
}
#else
SnfMilterConfig.StartSniffer("snf-milter");
#endif
}

+ 5
- 19
SNFMilterConfig/SNFMilterConfig.hpp View File

@@ -81,24 +81,6 @@ public:
//
void SaveFileState(void); // OBSOLETE.
/// Setup/repair the configuration.
//
// Copy the following files from the sample files if they don't
// exist:
//
// <ol>
// <li> Identity file. </li>
// <li> Ignore list file. </li>
// <li> Rulebase script. </li>
// </ol>
//
// Set the owner/group of each of the above files.
//
// Make sure that the log directory exists and has the correct
// owner and permissions.
//
void SetupRepair();
/// Execute the command to integrate/unintegrate with the MTAs.
void DoIntegrationCommand();
@@ -108,7 +90,11 @@ private:
/// of the loaded config file.
void LoadSocketInfo();
void CreateSocketDir();
/// Setup/repair the directory containing the milter socket.
//
// This method ensures that the directore to contain the milter
// socket exists and has the correct owner and permissions.
void SetupRepairSocketDir();
PostfixIntegrate Postfix; ///< Postfix integration object.

Loading…
Cancel
Save