|
|
@@ -38,7 +38,7 @@ PostfixIntegrate::SetOperatingSystem(std::string OperatingSystemType) { |
|
|
|
|
|
|
|
if ("OpenBSD" == OperatingSystemType) {
|
|
|
|
|
|
|
|
PostfixDefaultIsChrooted = true;
|
|
|
|
PostfixDefaultIsChrooted = true;
|
|
|
|
PostfixSocketSpec = "unix:/snf-milter/socket";
|
|
|
|
PostfixMainCfPath = "/etc/postfix/main.cf";
|
|
|
|
PostfixMasterCfPath = "/etc/postfix/master.cf";
|
|
|
@@ -46,7 +46,7 @@ PostfixIntegrate::SetOperatingSystem(std::string OperatingSystemType) { |
|
|
|
|
|
|
|
} else if ("FreeBSD" == OperatingSystemType) {
|
|
|
|
|
|
|
|
PostfixDefaultIsChrooted = false;
|
|
|
|
PostfixDefaultIsChrooted = false;
|
|
|
|
PostfixSocketSpec = "unix:/var/snf-milter/socket";
|
|
|
|
PostfixMainCfPath = "/usr/local/etc/postfix/main.cf";
|
|
|
|
PostfixMasterCfPath = "/usr/local/etc/postfix/master.cf";
|
|
|
@@ -54,7 +54,7 @@ PostfixIntegrate::SetOperatingSystem(std::string OperatingSystemType) { |
|
|
|
|
|
|
|
} else if ("Ubuntu" == OperatingSystemType) {
|
|
|
|
|
|
|
|
PostfixDefaultIsChrooted = true;
|
|
|
|
PostfixDefaultIsChrooted = true;
|
|
|
|
PostfixSocketSpec = "unix:/snf-milter/socket";
|
|
|
|
PostfixMainCfPath = "/etc/postfix/main.cf";
|
|
|
|
PostfixMasterCfPath = "/etc/postfix/master.cf";
|
|
|
@@ -62,7 +62,7 @@ PostfixIntegrate::SetOperatingSystem(std::string OperatingSystemType) { |
|
|
|
|
|
|
|
} else if ("RedHat" == OperatingSystemType) {
|
|
|
|
|
|
|
|
PostfixDefaultIsChrooted = false;
|
|
|
|
PostfixDefaultIsChrooted = false;
|
|
|
|
PostfixSocketSpec = "unix:/var/snf-milter/socket";
|
|
|
|
PostfixMainCfPath = "/etc/postfix/main.cf";
|
|
|
|
PostfixMasterCfPath = "/etc/postfix/master.cf";
|
|
|
@@ -70,7 +70,7 @@ PostfixIntegrate::SetOperatingSystem(std::string OperatingSystemType) { |
|
|
|
|
|
|
|
} else if ("Suse" == OperatingSystemType) {
|
|
|
|
|
|
|
|
PostfixDefaultIsChrooted = false;
|
|
|
|
PostfixDefaultIsChrooted = false;
|
|
|
|
PostfixSocketSpec = "unix:/var/snf-milter/socket";
|
|
|
|
PostfixMainCfPath = "/etc/postfix/main.cf";
|
|
|
|
PostfixMasterCfPath = "/etc/postfix/master.cf";
|
|
|
@@ -98,6 +98,28 @@ PostfixIntegrate::Integrate(FileBackup *SaveFile) { |
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether the chroot configuration is as expected.
|
|
|
|
bool IsChrooted;
|
|
|
|
|
|
|
|
IsChrooted = MtaConfigurationIsChrooted();
|
|
|
|
|
|
|
|
std::cout << "IsChrooted: " << IsChrooted << "\n";
|
|
|
|
|
|
|
|
if (IsChrooted != PostfixDefaultIsChrooted) {
|
|
|
|
|
|
|
|
std::string Temp;
|
|
|
|
|
|
|
|
Temp = "Error--postfix must be configured to run ";
|
|
|
|
Temp += (PostfixDefaultIsChrooted ? "" : "not ");
|
|
|
|
Temp += "chrooted, which is the default for this operating system. ";
|
|
|
|
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()) {
|
|
|
@@ -510,3 +532,78 @@ PostfixIntegrate::IsIntegrated() { |
|
|
|
return Integrated;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PostfixIntegrate::DefaultIsChrooted() {
|
|
|
|
|
|
|
|
return PostfixDefaultIsChrooted;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PostfixIntegrate::MtaConfigurationIsChrooted() {
|
|
|
|
|
|
|
|
std::string File;
|
|
|
|
std::ifstream Input;
|
|
|
|
|
|
|
|
File = PostfixMasterCfPath;
|
|
|
|
|
|
|
|
Input.open(File.c_str());
|
|
|
|
if (!Input) {
|
|
|
|
std::string Temp;
|
|
|
|
|
|
|
|
Temp = "Error opening postfix configuration file " + File;
|
|
|
|
Temp += " for reading: ";
|
|
|
|
Temp += strerror(errno);
|
|
|
|
throw std::runtime_error(Temp);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string Line;
|
|
|
|
|
|
|
|
bool ConfigurationIsChrooted = false;
|
|
|
|
|
|
|
|
while (getline(Input, Line)) {
|
|
|
|
|
|
|
|
if (CheckForString(Line, "smtp")) { // Check for smtp line.
|
|
|
|
|
|
|
|
std::istringstream Buffer(Line); // Parse buffer line.
|
|
|
|
std::string Token[8];
|
|
|
|
|
|
|
|
for (unsigned int iToken = 0; iToken < 8; iToken++) {
|
|
|
|
|
|
|
|
Buffer >> Token[iToken];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Input.close();
|
|
|
|
if (Input.bad()) {
|
|
|
|
std::string Temp;
|
|
|
|
|
|
|
|
Temp = "Error closing the rulebase download script file " + File;
|
|
|
|
Temp += " after reading: ";
|
|
|
|
Temp += strerror(errno);
|
|
|
|
throw std::runtime_error(Temp);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|