Explorar el Código

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 hace 11 años
padre
commit
06cc2e3f80

+ 16
- 9
SNFMilterConfig/PostfixIntegrate.cpp Ver fichero

@@ -26,9 +26,6 @@
// Configuration. ////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
const std::string SnfMilterMainCfSearchString("unix:/var/snf-milter/socket");
const std::string SnfMilterMainCfMilterSpec("unix:/var/snf-milter/socket");
//////////////////////////////////////////////////////////////////////////////////////////////////////////
// End of configuration. /////////////////////////////////////////////////////////////////////////////////
@@ -41,30 +38,40 @@ PostfixIntegrate::SetOperatingSystem(std::string OperatingSystemType) {
if ("OpenBSD" == OperatingSystemType) {
PostfixDefaultIsChrooted = true;
PostfixSocketSpec = "unix:/snf-milter/socket";
PostfixMainCfPath = "/etc/postfix/main.cf";
PostfixMasterCfPath = "/etc/postfix/master.cf";
ReloadMtaCommand = "/usr/local/sbin/postfix reload";
} else if ("FreeBSD" == OperatingSystemType) {
PostfixDefaultIsChrooted = false;
PostfixSocketSpec = "unix:/var/snf-milter/socket";
PostfixMainCfPath = "/usr/local/etc/postfix/main.cf";
PostfixMasterCfPath = "/usr/local/etc/postfix/master.cf";
ReloadMtaCommand = "/usr/local/sbin/postfix reload";
} else if ("Ubuntu" == OperatingSystemType) {
PostfixDefaultIsChrooted = true;
PostfixSocketSpec = "unix:/snf-milter/socket";
PostfixMainCfPath = "/etc/postfix/main.cf";
PostfixMasterCfPath = "/etc/postfix/master.cf";
ReloadMtaCommand = "/usr/sbin/postfix reload";
} else if ("RedHat" == OperatingSystemType) {
PostfixDefaultIsChrooted = false;
PostfixSocketSpec = "unix:/var/snf-milter/socket";
PostfixMainCfPath = "/etc/postfix/main.cf";
PostfixMasterCfPath = "/etc/postfix/master.cf";
ReloadMtaCommand = "/usr/sbin/postfix reload";
} else if ("Suse" == OperatingSystemType) {
PostfixDefaultIsChrooted = false;
PostfixSocketSpec = "unix:/var/snf-milter/socket";
PostfixMainCfPath = "/etc/postfix/main.cf";
PostfixMasterCfPath = "/etc/postfix/master.cf";
ReloadMtaCommand = "/usr/sbin/postfix reload";
@@ -117,7 +124,7 @@ PostfixIntegrate::Integrate(FileBackup *SaveFile) {
std::string Line;
bool ModifiedLine = false;
PostfixMilterConf MilterConf; // Object to update the config line.
PostfixMilterConf MilterConf(PostfixSocketSpec); // Object to update the config line.
while (getline(Input, Line)) {
@@ -260,15 +267,15 @@ PostfixIntegrate::Unintegrate(FileBackup *SaveFile) {
std::string Content;
std::string Line;
PostfixMilterConf MilterConf; // Object to update the config line.
PostfixMilterConf MilterConf(PostfixSocketSpec); // Object to update the config 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()) {
@@ -457,7 +464,7 @@ PostfixIntegrate::IsIntegrated() {
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;
while (getline(Input, Line)) {

+ 6
- 0
SNFMilterConfig/PostfixIntegrate.hpp Ver fichero

@@ -43,6 +43,12 @@ private:
/// Postfix master.cf file path.
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.
std::string MtaIsRunningCommand;

+ 5
- 3
SNFMilterConfig/PostfixMilterConf.cpp Ver fichero

@@ -20,9 +20,6 @@
// Configuration. ////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// SNFMilter socket specification.
const std::string SnfMilterSocketSpec("unix:/var/snf-milter/socket");
/// Milter keyword in the postfix main.cf file.
const std::string SmtpdMilterKeyword("smtpd_milters");
@@ -32,6 +29,11 @@ const std::string Whitespace(", \t");
// End of configuration. /////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
PostfixMilterConf::PostfixMilterConf(std::string SocketSpec) :
SnfMilterSocketSpec(SocketSpec) {
}
void
PostfixMilterConf::ConfLine(std::string Line) {

+ 11
- 0
SNFMilterConfig/PostfixMilterConf.hpp Ver fichero

@@ -21,6 +21,13 @@ class PostfixMilterConf {
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.
void ConfLine(std::string Line);
@@ -58,6 +65,10 @@ private:
/// Configuration line.
std::string ConfigurationLine;
/// SNFMilter socket specification.
std::string SnfMilterSocketSpec;
};
#endif

+ 4
- 4
SNFMilterConfigTests/TestPostfixMilterConf.cpp Ver fichero

@@ -37,7 +37,7 @@ bool
TestIsIntegrated() {
// Object under test.
PostfixMilterConf TestObj;
PostfixMilterConf TestObj("unix:/var/snf-milter/socket");
// Container of test lines.
std::vector<std::string> TestInput;
@@ -157,7 +157,7 @@ bool
TestIsMilterLine() {
// Object under test.
PostfixMilterConf TestObj;
PostfixMilterConf TestObj("unix:/var/snf-milter/socket");
// Container of test lines.
std::vector<std::string> TestInput;
@@ -239,7 +239,7 @@ bool
TestAddIntegration() {
// Object under test.
PostfixMilterConf TestObj;
PostfixMilterConf TestObj("unix:/var/snf-milter/socket");
// Container of test lines.
std::vector<std::string> TestInput;
@@ -343,7 +343,7 @@ bool
TestRemoveIntegration() {
// Object under test.
PostfixMilterConf TestObj;
PostfixMilterConf TestObj("unix:/var/snf-milter/socket");
// Container of test lines.
std::vector<std::string> TestInput;

Cargando…
Cancelar
Guardar