|
|
@@ -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;
|
|
|
|
|
|
|
|
}
|