Sfoglia il codice sorgente

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 12 anni fa
parent
commit
8199d3ad78

+ 25
- 5
SNFMilterConfig/PostfixIntegrate.cpp Vedi File

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";
AddPostfixToSnfuserGroupCommand = "/usr/sbin/usermod -G snfuser _postfix";
} else if ("FreeBSD" == OperatingSystemType) { } else if ("FreeBSD" == OperatingSystemType) {
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";
AddPostfixToSnfuserGroupCommand = "/usr/sbin/pw mod group -n snfuser -m postfix";
} else if ("Ubuntu" == OperatingSystemType) { } else if ("Ubuntu" == OperatingSystemType) {
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";
AddPostfixToSnfuserGroupCommand = "/usr/sbin/usermod -G snfuser postfix";
} else if ("RedHat" == OperatingSystemType) { } else if ("RedHat" == OperatingSystemType) {
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";
AddPostfixToSnfuserGroupCommand = "/usr/sbin/usermod -G snfuser postfix";
} else if ("Suse" == OperatingSystemType) { } else if ("Suse" == OperatingSystemType) {
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";
AddPostfixToSnfuserGroupCommand = "/usr/sbin/usermod -G snfuser postfix";
} else { } else {
if (Verbose()) { if (Verbose()) {
std::cout << "Integrate with postfix...\n";
std::cout << "Integrate with postfix...add postfix user to snfuser group...\n";
} }
bool Succeeded;
if (!Explain()) { 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. SaveFile->CreateBackupFile(PostfixMainCfPath); // Save any existing file.
Input.open(PostfixMainCfPath.c_str()); // Read the contents. Input.open(PostfixMainCfPath.c_str()); // Read the contents.
std::string Line; std::string Line;
bool ModifiedLine = false; 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. // Ignore subsequence integration lines.
MilterConf.AddIntegration(); // Found milter line. Add integration. MilterConf.AddIntegration(); // Found milter line. Add integration.

+ 3
- 0
SNFMilterConfig/PostfixIntegrate.hpp Vedi File

/// True if postfix runs chrooted by default. /// True if postfix runs chrooted by default.
bool PostfixDefaultIsChrooted; bool PostfixDefaultIsChrooted;
/// Command to add the postfix user to the snfuser group.
std::string AddPostfixToSnfuserGroupCommand;
}; };
#endif #endif

Loading…
Annulla
Salva