Преглед изворни кода

Added check that the LDA is procmail.


git-svn-id: https://svn.microneil.com/svn/PKG-SNF-CS-NIX/trunk@71 233e721a-07f6-49eb-a7da-05e0e16828fc
master
adeniz пре 12 година
родитељ
комит
61a4c6e64a

+ 15
- 16
SNF_CS_Developer_Package/SNFUtility/SNFServerConfig/PostfixIntegrate.cpp Прегледај датотеку

@@ -1,6 +1,6 @@
// /file PostfixIntegrate.cpp
//
// Copyright (C) 2012, ARM Research Labs, LLC.
// Copyright (C) 2013, ARM Research Labs, LLC.
// See www.armresearch.com for the copyright terms.
//
// This file contains the functions for PostfixIntegrate.
@@ -93,6 +93,14 @@ PostfixIntegrate::SetOperatingSystem(std::string OperatingSystemType) {
PostfixMasterCfPath = "/etc/postfix/master.cf";
ReloadMtaCommand = "/usr/sbin/postfix reload";
} else if ("ArchLinux" == OperatingSystemType) {
ContentFilterSpec += " flags=Rq user=snfuser argv=/usr/sbin/snfSniffer\n";
PostfixMainCfPath = "/etc/postfix/main.cf";
PostfixMasterCfPath = "/etc/postfix/master.cf";
ReloadMtaCommand = "/usr/sbin/postfix reload";
} else {
std::ostringstream Temp;
@@ -132,13 +140,10 @@ PostfixIntegrate::Integrate(FileBackup *SaveFile) {
Temp += "postfix was detected to be configured to run ";
Temp += (IsChrooted ? "" : "not ");
Temp += "chrooted.";
Temp += strerror(errno);
throw std::runtime_error(Temp);
}
std::ifstream Input;
if (Verbose()) {
std::cout << "Integrate with postfix...\n";
@@ -171,6 +176,8 @@ PostfixIntegrate::Integrate(FileBackup *SaveFile) {
SaveFile->CreateBackupFile(PostfixMasterCfPath);
std::ifstream Input;
Input.open(PostfixMasterCfPath.c_str()); // Read the contents.
if (!Input) {
std::string Temp;
@@ -596,16 +603,8 @@ PostfixIntegrate::MtaConfigurationIsChrooted() {
if ( ("y" == Token[4]) || ("-" == Token[4]) ) {
Input.close();
if (Input.bad()) {
std::string Temp;
Temp = "Error closing the postfix configuration file " + File;
Temp += " after reading: ";
Temp += strerror(errno);
throw std::runtime_error(Temp);
}
return true;
ConfigurationIsChrooted = true;
break;
}
@@ -617,12 +616,12 @@ PostfixIntegrate::MtaConfigurationIsChrooted() {
if (Input.bad()) {
std::string Temp;
Temp = "Error closing the rulebase download script file " + File;
Temp = "Error closing the postfix configuration file " + File;
Temp += " after reading: ";
Temp += strerror(errno);
throw std::runtime_error(Temp);
}
return false;
return ConfigurationIsChrooted;
}

+ 117
- 1
SNF_CS_Developer_Package/SNFUtility/SNFServerConfig/SendmailIntegrate.cpp Прегледај датотеку

@@ -1,6 +1,6 @@
// /file SendmailIntegrate.cpp
//
// Copyright (C) 2012, ARM Research Labs, LLC.
// Copyright (C) 2013, ARM Research Labs, LLC.
// See www.armresearch.com for the copyright terms.
//
// This file contains the functions for SendmailIntegrate.
@@ -25,6 +25,8 @@
// Configuration. ////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
const std::string SendmailLdaKey("FEATURE(`local_procmail'"); ///< Line in sendmail.cf that specifies the LDA.
const std::string MtaIsRunningCommand("ps axl | grep -v grep | grep -q ' sendmail: '");
//////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -123,6 +125,16 @@ SendmailIntegrate::Integrate(FileBackup *SaveFile) {
}
// Check whether the configuration has procmail as the LDA.
if (!MtaConfigurationHasProcmailForLda()) {
std::string Temp;
Temp = "Error--sendmail must be configured to use procmail as the LDA.";
throw std::runtime_error(Temp);
}
if (Verbose()) {
std::cout << "Create " << SnfSnifferFileName << " if it doesn't exist...";
@@ -506,3 +518,107 @@ SendmailIntegrate::IsIntegrated() {
return Integrated;
}
bool
SendmailIntegrate::MtaConfigurationHasProcmailForLda() {
std::string File;
std::ifstream Input;
File = SendmailSendmailMcPath;
if (Verbose()) {
std::cout << "Checking sendmail configuraton file " + File
<< " to verify that procmail is the Local Delivery Agent.\n";
}
Input.open(File.c_str());
if (!Input) {
std::string Temp;
Temp = "Error opening sendmail configuration file " + File;
Temp += " for reading: ";
Temp += strerror(errno);
throw std::runtime_error(Temp);
}
std::string Line;
bool LdaIsProcmail = true;
bool FoundLdaLine = false;
while (getline(Input, Line)) {
if (Line.substr(0, SendmailLdaKey.length()) == SendmailLdaKey) { // Check for LDA line.
FoundLdaLine = true;
if (Line.find(",", SendmailLdaKey.length()) != std::string::npos) { // Additional arguments?
if (Line.find("procmail", SendmailLdaKey.length()) == std::string::npos) { // Yes.
LdaIsProcmail = false; // procmail not specified in the config line.
if (Verbose()) {
std::cout << "The following line indicates that the sendmail LDA is not procmail:\n\n"
<< Line << "\n";
}
break;
} else { // procmail is specified in the config line.
if (Verbose()) {
std::cout << "The following line indicates that the sendmail LDA is procmail, "
<< "as required to integrate with SNFServer:\n\n"
<< Line << "\n\n";
}
break;
}
} else { // LDA line uses default, which is procmail.
if (Verbose()) {
std::cout << "The following line indicates that the sendmail LDA is procmail, "
<< "as required to integrate with SNFServer:\n\n"
<< Line << "\n\n";
}
break;
}
}
}
Input.close();
if (Input.bad()) {
std::string Temp;
Temp = "Error closing the sendmail configuration file " + File;
Temp += " after reading: ";
Temp += strerror(errno);
throw std::runtime_error(Temp);
}
if (Verbose() && !FoundLdaLine) {
std::cout << "The absence of \"" << SendmailLdaKey << "\" indicates that the LDA is procmail, "
<< "as required to integrate with SNFServer.\n";
}
return LdaIsProcmail;
}

+ 2
- 0
SNF_CS_Developer_Package/SNFUtility/SNFServerConfig/SendmailIntegrate.hpp Прегледај датотеку

@@ -39,6 +39,8 @@ private:
virtual bool IsIntegrated();
bool MtaConfigurationHasProcmailForLda();
/// Directory containing the snfSniffer script.
std::string SnfSnifferDirName;

Loading…
Откажи
Сачувај