Переглянути джерело

Tested integration/unintegration with postfix on Ubuntu.


git-svn-id: https://svn.microneil.com/svn/SNFUtility/trunk@29 aa37657e-1934-4a5f-aa6d-2d8eab27ff7c
master
adeniz 12 роки тому
джерело
коміт
b025efa67d

+ 34
- 18
SNFMilterConfig/PostfixIntegrate.cpp Переглянути файл

@@ -36,7 +36,7 @@ const std::string SnfMilterMainCfIntegrationString("smtpd_milters = unix:/var/sn
void
PostfixIntegrate::SetOperatingSystem(std::string OperatingSystemType) {
MtaIsRunningCommand = "ps -axl root | grep -v grep | grep -q 'postfix/master'";
MtaIsRunningCommand = "ps axl | grep -v grep | grep -q 'postfix/master'";
if ("OpenBSD" == OperatingSystemType) {
@@ -133,6 +133,12 @@ PostfixIntegrate::Integrate(FileBackup *SaveFile) {
throw std::runtime_error(Temp);
}
}
OutputVerboseEnd();
if (!Explain()) {
if (MtaIsRunningDetected()) {
ReloadMta();
@@ -141,9 +147,6 @@ PostfixIntegrate::Integrate(FileBackup *SaveFile) {
}
OutputVerboseEnd();
}
void
@@ -252,6 +255,12 @@ PostfixIntegrate::Unintegrate(FileBackup *SaveFile) {
}
}
OutputVerboseEnd();
if (!Explain()) {
if (MtaIsRunningDetected()) {
ReloadMta();
@@ -260,8 +269,6 @@ PostfixIntegrate::Unintegrate(FileBackup *SaveFile) {
}
OutputVerboseEnd();
}
bool
@@ -279,7 +286,7 @@ PostfixIntegrate::MtaIsRunningDetected() {
if (Verbose()) {
std::cout << (IsRunningDetected ? "yes" : "no");
std::cout << (IsRunningDetected ? "yes..." : "no...");
}
@@ -294,19 +301,20 @@ PostfixIntegrate::ReloadMta() {
if (Verbose()) {
std::cout << "Reloading postfix...";
std::cout << "Reloading postfix...\n";
std::cout.flush();
}
bool Failed;
bool Succeeded;
if (!Explain()) {
Failed = (std::system(ReloadMtaCommand.c_str()) == 0);
Succeeded = (std::system(ReloadMtaCommand.c_str()) == 0);
if (Verbose()) {
std::cout << (Failed ? "failed..." : "succeeded...");
std::cout << (Succeeded ? "succeeded..." : "failed...");
}
@@ -314,7 +322,7 @@ PostfixIntegrate::ReloadMta() {
OutputVerboseEnd();
return !Failed;
return Succeeded;
}
@@ -363,12 +371,6 @@ PostfixIntegrate::IsIntegrated() {
Integrated = true; // Found it.
if (Verbose()) {
std::cout << "found '" << Line << "'...";
}
break;
}
@@ -385,6 +387,20 @@ PostfixIntegrate::IsIntegrated() {
throw std::runtime_error(Temp);
}
if (Verbose()) {
if (Integrated) {
std::cout << "found '" << Line << "'...";
} else {
std::cout << "none found...";
}
}
OutputVerboseEnd();
return Integrated;

+ 29
- 27
SNFMilterConfig/SNFMilterConfig.cpp Переглянути файл

@@ -61,9 +61,9 @@ const std::string SNFMilterConfig::SampleIdentityFile("");
const string SNFMilterConfig::ApplicationName("SNFMilter");
const string IntegrateWithNoneKey("-mta=none");
const string IntegrateWithPostfixKey("-mta=postfix");
const string IntegrateWithSendmailKey("-mta=sendmail");
const string IntegrateWithNoneKey("-with=none");
const string IntegrateWithPostfixKey("-with=postfix");
const string IntegrateWithSendmailKey("-with=sendmail");
const string SnfMilterMainCfSearchString("Added by SNFMilterConfig");
@@ -83,9 +83,9 @@ SNFMilterConfig::DisplayHelp(std::string Version) {
ExclusiveCommands += IntegrateWithSendmailKey + " | ";
ExclusiveCommands += IntegrateWithNoneKey;
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";
ExclusiveCommandsHelp = " -with=postfix Integrate with postfix and start/reload postfix\n";
ExclusiveCommandsHelp += " -with=sendmail Integrate with sendmail and start/reload sendmail\n";
ExclusiveCommandsHelp += " -with=none Remove any integration with all supported MTAs\n";
cout
<< Version << endl
@@ -181,16 +181,32 @@ SNFMilterConfig::GetCommandLineInput(int argc, char* argv[]) {
void
SNFMilterConfig::ExecuteCommand() {
switch (Command) {
Postfix.SetOperatingSystem(GetOperatingSystemType());
Postfix.SetVerbose(Verbose());
Postfix.SetExplain(Explain());
case SetupRepairCommand:
#if 0
Sendmail.SetOperatingSystem(GetOperatingSystemType());
Sendmail.SetVerbose(Verbose());
Sendmail.SetExplain(Explain());
#endif
SetConfigFileName(DefaultConfigFile);
if (SetupRepairCommand == Command) {
SetConfigFileName(DefaultConfigFile);
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.
}
LoadConfig();
LoadInfo(); // Load the file paths.
LoadSocketInfo(); // Load the socket path.
switch (Command) {
case SetupRepairCommand:
SetupRepair(SampleIdentityFile);
SetupRepairSocketDir();
@@ -199,15 +215,8 @@ SNFMilterConfig::ExecuteCommand() {
case UpdateCredentialsCommand:
SetConfigFileName(DefaultConfigFile);
LoadConfig();
LoadInfo(); // Load the file paths.
LoadSocketInfo(); // Load the socket path.
UpdateRulebaseScriptCredentials();
DownloadRulebase();
UpdateIdentityFile();
break;
@@ -215,6 +224,7 @@ SNFMilterConfig::ExecuteCommand() {
case IntegrateWithPostfixCommand:
UnintegrateWithAllExcept("postfix");
Postfix.Integrate(&SaveFile);
break;
@@ -231,10 +241,6 @@ SNFMilterConfig::ExecuteCommand() {
case StartSnifferCommand:
SetConfigFileName(DefaultConfigFile);
LoadConfig();
LoadInfo();
LoadSocketInfo();
LoadCredentials();
StartSniffer("snf-milter start", ApplicationName);
@@ -242,10 +248,6 @@ SNFMilterConfig::ExecuteCommand() {
case StopSnifferCommand:
SetConfigFileName(DefaultConfigFile);
LoadConfig();
LoadInfo();
LoadSocketInfo();
LoadCredentials();
StopSniffer("snf-milter stop", ApplicationName);

+ 51
- 8
SNFMilterConfig/SNFMilterConfigTests.txt Переглянути файл

@@ -373,7 +373,7 @@ gmtime(). In each step, verify that the datestamp is the local date.
Integration with postfix
------------------------

POSTFIX-01: Set up the environment as follows:
POSTFIX-01: On Ubuntu, set up the environment as follows:

1) Default configuration files for SNFMilter.

@@ -403,11 +403,11 @@ Do the following:
postfix configuration files are not updated, and that both
postfix and SNFMilter are stopped.

Result:
Result: Pass.

POSTFIX-02: Repeat POSTFIX-01 but without "-v".

Result:
Result: Pass.

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

@@ -419,9 +419,20 @@ POSTFIX-03: Configure as for POSTFIX-01, and do the following:
output, and that SNFMilterConfig doesn't update the postfix
configuration files or reload any MTA.

Result:
3) Run SNFMilterConfig with "-with=postfix". Verify correct output,
and that SNFMilterConfig updates the postfix configuration files.

POSTFIX-04: Set up the environment as follows:
4) Run SNFMilterConfig with "-with=postfix -explain". Verify
correct output, and that SNFMilterConfig doesn't update the
postfix configuration files or reload any MTA.

5) Run SNFMilterConfig with "-with=none -explain". Verify correct
output, and that SNFMilterConfig doesn't update the postfix
configuration files or reload any MTA.

Result: Pass

POSTFIX-04: On Ubuntu, set up the environment as follows:

1) Default configuration files for SNFMilter.

@@ -451,11 +462,11 @@ Do the following:
postfix configuration files are not updated, and that SNFMilter
is not running and that postfix is running and was not reloaded.

Result:
Result: Pass.

POSTFIX-05: Repeat POSTFIX-04 but without "-v".

Result:
Result: Pass.

POSTFIX-06: Configure as for POSTFIX-04, and do the following:

@@ -467,5 +478,37 @@ POSTFIX-06: Configure as for POSTFIX-04, and do the following:
output, and that SNFMilterConfig doesn't update the postfix
configuration files or reload any MTA.

Result:
3) Run SNFMilterConfig with "-with=postfix". Verify correct output,
and that SNFMilterConfig updates the postfix configuration files
and reloads the MTA.

4) Run SNFMilterConfig with "-with=postfix -explain". Verify
correct output, and that SNFMilterConfig doesn't update the
postfix configuration files or reload any MTA.

5) Run SNFMilterConfig with "-with=none -explain". Verify correct
output, and that SNFMilterConfig doesn't update the postfix
configuration files or reload any MTA.

Result: Pass.

POSTFIX-07: Repeat POSTFIX-01 thru POSTFIX-07 on Fedora.

Result:

POSTFIX-08: Repeat POSTFIX-01 thru POSTFIX-07 on OpenSuse.

Result:

POSTFIX-09: Repeat POSTFIX-01 thru POSTFIX-07 on CentOS.

Result:

POSTFIX-10: Repeat POSTFIX-01 thru POSTFIX-07 on OpenBSD.

Result:

POSTFIX-11: Repeat POSTFIX-01 thru POSTFIX-07 on FreeBSD.

Result:


Завантаження…
Відмінити
Зберегти