소스 검색

Make postfix a member of the snfuser group upon integration with postfix.


git-svn-id: https://svn.microneil.com/svn/SNFUtility/trunk@59 aa37657e-1934-4a5f-aa6d-2d8eab27ff7c
master
adeniz 11 년 전
부모
커밋
8199d3ad78
2개의 변경된 파일28개의 추가작업 그리고 5개의 파일을 삭제
  1. 25
    5
      SNFMilterConfig/PostfixIntegrate.cpp
  2. 3
    0
      SNFMilterConfig/PostfixIntegrate.hpp

+ 25
- 5
SNFMilterConfig/PostfixIntegrate.cpp 파일 보기

@@ -43,6 +43,7 @@ PostfixIntegrate::SetOperatingSystem(std::string OperatingSystemType) {
PostfixMainCfPath = "/etc/postfix/main.cf";
PostfixMasterCfPath = "/etc/postfix/master.cf";
ReloadMtaCommand = "/usr/local/sbin/postfix reload";
AddPostfixToSnfuserGroupCommand = "/usr/sbin/usermod -G snfuser _postfix";
} else if ("FreeBSD" == OperatingSystemType) {
@@ -51,6 +52,7 @@ PostfixIntegrate::SetOperatingSystem(std::string OperatingSystemType) {
PostfixMainCfPath = "/usr/local/etc/postfix/main.cf";
PostfixMasterCfPath = "/usr/local/etc/postfix/master.cf";
ReloadMtaCommand = "/usr/local/sbin/postfix reload";
AddPostfixToSnfuserGroupCommand = "/usr/sbin/pw mod group -n snfuser -m postfix";
} else if ("Ubuntu" == OperatingSystemType) {
@@ -59,6 +61,7 @@ PostfixIntegrate::SetOperatingSystem(std::string OperatingSystemType) {
PostfixMainCfPath = "/etc/postfix/main.cf";
PostfixMasterCfPath = "/etc/postfix/master.cf";
ReloadMtaCommand = "/usr/sbin/postfix reload";
AddPostfixToSnfuserGroupCommand = "/usr/sbin/usermod -G snfuser postfix";
} else if ("RedHat" == OperatingSystemType) {
@@ -67,6 +70,7 @@ PostfixIntegrate::SetOperatingSystem(std::string OperatingSystemType) {
PostfixMainCfPath = "/etc/postfix/main.cf";
PostfixMasterCfPath = "/etc/postfix/master.cf";
ReloadMtaCommand = "/usr/sbin/postfix reload";
AddPostfixToSnfuserGroupCommand = "/usr/sbin/usermod -G snfuser postfix";
} else if ("Suse" == OperatingSystemType) {
@@ -75,6 +79,7 @@ PostfixIntegrate::SetOperatingSystem(std::string OperatingSystemType) {
PostfixMainCfPath = "/etc/postfix/main.cf";
PostfixMasterCfPath = "/etc/postfix/master.cf";
ReloadMtaCommand = "/usr/sbin/postfix reload";
AddPostfixToSnfuserGroupCommand = "/usr/sbin/usermod -G snfuser postfix";
} else {
@@ -122,12 +127,27 @@ PostfixIntegrate::Integrate(FileBackup *SaveFile) {
if (Verbose()) {
std::cout << "Integrate with postfix...\n";
std::cout << "Integrate with postfix...add postfix user to snfuser group...\n";
}
bool Succeeded;
if (!Explain()) {
Succeeded = (std::system(AddPostfixToSnfuserGroupCommand.c_str()) == 0);
if (!Succeeded) {
std::string Temp;
Temp = "Error adding the postfix user to the snfuser group with the command '";
Temp += AddPostfixToSnfuserGroupCommand;
Temp += "': ";
Temp += strerror(errno);
throw std::runtime_error(Temp);
}
SaveFile->CreateBackupFile(PostfixMainCfPath); // Save any existing file.
Input.open(PostfixMainCfPath.c_str()); // Read the contents.
@@ -144,13 +164,13 @@ PostfixIntegrate::Integrate(FileBackup *SaveFile) {
std::string Line;
bool ModifiedLine = false;
PostfixMilterConf MilterConf(PostfixSocketSpec); // 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.IsMilterLine() && !ModifiedLine) { // Check for milter integration line.
if (MilterConf.IsMilterLine() && !ModifiedLine) { // Check for milter integration line.
// Ignore subsequence integration lines.
MilterConf.AddIntegration(); // Found milter line. Add integration.

+ 3
- 0
SNFMilterConfig/PostfixIntegrate.hpp 파일 보기

@@ -64,6 +64,9 @@ private:
/// True if postfix runs chrooted by default.
bool PostfixDefaultIsChrooted;
/// Command to add the postfix user to the snfuser group.
std::string AddPostfixToSnfuserGroupCommand;
};
#endif

Loading…
취소
저장