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

PostfixMilterConf constructor accepts the milter spec rather than always using unix:/var/snf-milter/socket.


git-svn-id: https://svn.microneil.com/svn/SNFUtility/trunk@54 aa37657e-1934-4a5f-aa6d-2d8eab27ff7c
master
adeniz пре 11 година
родитељ
комит
06cc2e3f80

+ 16
- 9
SNFMilterConfig/PostfixIntegrate.cpp Прегледај датотеку

// Configuration. //////////////////////////////////////////////////////////////////////////////////////// // Configuration. ////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////
const std::string SnfMilterMainCfSearchString("unix:/var/snf-milter/socket");
const std::string SnfMilterMainCfMilterSpec("unix:/var/snf-milter/socket");
////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////
// End of configuration. ///////////////////////////////////////////////////////////////////////////////// // End of configuration. /////////////////////////////////////////////////////////////////////////////////
if ("OpenBSD" == OperatingSystemType) { if ("OpenBSD" == OperatingSystemType) {
PostfixDefaultIsChrooted = true;
PostfixSocketSpec = "unix:/snf-milter/socket";
PostfixMainCfPath = "/etc/postfix/main.cf"; PostfixMainCfPath = "/etc/postfix/main.cf";
PostfixMasterCfPath = "/etc/postfix/master.cf"; PostfixMasterCfPath = "/etc/postfix/master.cf";
ReloadMtaCommand = "/usr/local/sbin/postfix reload"; ReloadMtaCommand = "/usr/local/sbin/postfix reload";
} else if ("FreeBSD" == OperatingSystemType) { } else if ("FreeBSD" == OperatingSystemType) {
PostfixDefaultIsChrooted = false;
PostfixSocketSpec = "unix:/var/snf-milter/socket";
PostfixMainCfPath = "/usr/local/etc/postfix/main.cf"; PostfixMainCfPath = "/usr/local/etc/postfix/main.cf";
PostfixMasterCfPath = "/usr/local/etc/postfix/master.cf"; PostfixMasterCfPath = "/usr/local/etc/postfix/master.cf";
ReloadMtaCommand = "/usr/local/sbin/postfix reload"; ReloadMtaCommand = "/usr/local/sbin/postfix reload";
} else if ("Ubuntu" == OperatingSystemType) { } else if ("Ubuntu" == OperatingSystemType) {
PostfixDefaultIsChrooted = true;
PostfixSocketSpec = "unix:/snf-milter/socket";
PostfixMainCfPath = "/etc/postfix/main.cf"; PostfixMainCfPath = "/etc/postfix/main.cf";
PostfixMasterCfPath = "/etc/postfix/master.cf"; PostfixMasterCfPath = "/etc/postfix/master.cf";
ReloadMtaCommand = "/usr/sbin/postfix reload"; ReloadMtaCommand = "/usr/sbin/postfix reload";
} else if ("RedHat" == OperatingSystemType) { } else if ("RedHat" == OperatingSystemType) {
PostfixDefaultIsChrooted = false;
PostfixSocketSpec = "unix:/var/snf-milter/socket";
PostfixMainCfPath = "/etc/postfix/main.cf"; PostfixMainCfPath = "/etc/postfix/main.cf";
PostfixMasterCfPath = "/etc/postfix/master.cf"; PostfixMasterCfPath = "/etc/postfix/master.cf";
ReloadMtaCommand = "/usr/sbin/postfix reload"; ReloadMtaCommand = "/usr/sbin/postfix reload";
} else if ("Suse" == OperatingSystemType) { } else if ("Suse" == OperatingSystemType) {
PostfixDefaultIsChrooted = false;
PostfixSocketSpec = "unix:/var/snf-milter/socket";
PostfixMainCfPath = "/etc/postfix/main.cf"; PostfixMainCfPath = "/etc/postfix/main.cf";
PostfixMasterCfPath = "/etc/postfix/master.cf"; PostfixMasterCfPath = "/etc/postfix/master.cf";
ReloadMtaCommand = "/usr/sbin/postfix reload"; ReloadMtaCommand = "/usr/sbin/postfix reload";
std::string Line; std::string Line;
bool ModifiedLine = false; bool ModifiedLine = false;
PostfixMilterConf MilterConf; // Object to update the config line.
PostfixMilterConf MilterConf(PostfixSocketSpec); // Object to update the config line.
while (getline(Input, Line)) { while (getline(Input, Line)) {
std::string Content; std::string Content;
std::string Line; std::string Line;
PostfixMilterConf MilterConf; // Object to update the config line.
PostfixMilterConf MilterConf(PostfixSocketSpec); // Object to update the config line.
while (getline(Input, Line)) { while (getline(Input, Line)) {
MilterConf.ConfLine(Line); // Load the object with the line.
MilterConf.ConfLine(Line); // Load the object with the line.
if (MilterConf.IsIntegrated()) { // Check for integration.
if (MilterConf.IsIntegrated()) { // Check for integration.
MilterConf.RemoveIntegration(); // Integrated. Remove the milter spec.
MilterConf.RemoveIntegration(); // Integrated. Remove the milter spec.
if (Verbose()) { if (Verbose()) {
throw std::runtime_error(Temp); throw std::runtime_error(Temp);
} }
PostfixMilterConf MilterConf; // Object to update the config line.
PostfixMilterConf MilterConf(PostfixSocketSpec); // Object to update the config line.
std::string Line; std::string Line;
while (getline(Input, Line)) { while (getline(Input, Line)) {

+ 6
- 0
SNFMilterConfig/PostfixIntegrate.hpp Прегледај датотеку

/// Postfix master.cf file path. /// Postfix master.cf file path.
std::string PostfixMasterCfPath; std::string PostfixMasterCfPath;
/// Value of smtpd_milters keyword.
std::string PostfixSocketSpec;
/// True if postfix runs chrooted by default.
bool PostfixDefaultIsChrooted;
/// Command to determine whether postfix is running. /// Command to determine whether postfix is running.
std::string MtaIsRunningCommand; std::string MtaIsRunningCommand;

+ 5
- 3
SNFMilterConfig/PostfixMilterConf.cpp Прегледај датотеку

// Configuration. //////////////////////////////////////////////////////////////////////////////////////// // Configuration. ////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////
/// SNFMilter socket specification.
const std::string SnfMilterSocketSpec("unix:/var/snf-milter/socket");
/// Milter keyword in the postfix main.cf file. /// Milter keyword in the postfix main.cf file.
const std::string SmtpdMilterKeyword("smtpd_milters"); const std::string SmtpdMilterKeyword("smtpd_milters");
// End of configuration. ///////////////////////////////////////////////////////////////////////////////// // End of configuration. /////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////
PostfixMilterConf::PostfixMilterConf(std::string SocketSpec) :
SnfMilterSocketSpec(SocketSpec) {
}
void void
PostfixMilterConf::ConfLine(std::string Line) { PostfixMilterConf::ConfLine(std::string Line) {

+ 11
- 0
SNFMilterConfig/PostfixMilterConf.hpp Прегледај датотеку

public: public:
/// Constructor.
//
// \param[in] SocketSpeck specifies the value of the smtpd_milters
// keyword in main.cf.
//
PostfixMilterConf(std::string SocketSpec);
/// Load a new configuration line. /// Load a new configuration line.
void ConfLine(std::string Line); void ConfLine(std::string Line);
/// Configuration line. /// Configuration line.
std::string ConfigurationLine; std::string ConfigurationLine;
/// SNFMilter socket specification.
std::string SnfMilterSocketSpec;
}; };
#endif #endif

+ 4
- 4
SNFMilterConfigTests/TestPostfixMilterConf.cpp Прегледај датотеку

TestIsIntegrated() { TestIsIntegrated() {
// Object under test. // Object under test.
PostfixMilterConf TestObj;
PostfixMilterConf TestObj("unix:/var/snf-milter/socket");
// Container of test lines. // Container of test lines.
std::vector<std::string> TestInput; std::vector<std::string> TestInput;
TestIsMilterLine() { TestIsMilterLine() {
// Object under test. // Object under test.
PostfixMilterConf TestObj;
PostfixMilterConf TestObj("unix:/var/snf-milter/socket");
// Container of test lines. // Container of test lines.
std::vector<std::string> TestInput; std::vector<std::string> TestInput;
TestAddIntegration() { TestAddIntegration() {
// Object under test. // Object under test.
PostfixMilterConf TestObj;
PostfixMilterConf TestObj("unix:/var/snf-milter/socket");
// Container of test lines. // Container of test lines.
std::vector<std::string> TestInput; std::vector<std::string> TestInput;
TestRemoveIntegration() { TestRemoveIntegration() {
// Object under test. // Object under test.
PostfixMilterConf TestObj;
PostfixMilterConf TestObj("unix:/var/snf-milter/socket");
// Container of test lines. // Container of test lines.
std::vector<std::string> TestInput; std::vector<std::string> TestInput;

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