implement greylisting domain option

This commit is contained in:
Purodha Blissenbach 2012-08-16 14:43:24 +02:00
parent 3da879a57d
commit a1d97ed10f
3 changed files with 27 additions and 4 deletions

View File

@ -155,6 +155,6 @@ INSERT INTO unixuser (name, comment, shell, homedir, locked, packet_id, userid)
-- table: domain_option
--
INSERT INTO domain_option (domain_option_name)
VALUES ('greylisting');
VALUES ('nogreylisting');
INSERT INTO domain_option (domain_option_name)
VALUES ('htdocsfallback');
VALUES ('nohtdocsfallback');

View File

@ -1,5 +1,6 @@
package de.hsadmin.mods.dom;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -53,7 +54,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
mainProcessor.appendProcessor(queueName, createDNSServerSetupProcessor(domName, hiveInetAddr), queueName + ".hostsharing.net");
}
for (String queueName : config.getProperty("queues.mail").split(",")) {
mainProcessor.appendProcessor(queueName, createMailinSetupProcessor(domName, pac), queueName + ".hostsharing.net");
mainProcessor.appendProcessor(queueName, createMailinSetupProcessor(em, domName, pac), queueName + ".hostsharing.net");
}
templateVars = new HashMap<String, String>();
templateVars.put("PAC", pacName);
@ -162,8 +163,19 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
" && invoke-rc.d bind9 reload");
}
private Processor createMailinSetupProcessor(String domName, Pac pac) {
private Processor createMailinSetupProcessor(EntityManager em, String domName, Pac pac) throws ProcessorException {
ArrayList<Map<String, String>> domsMaps = new ArrayList<Map<String, String>>();
Query query = em.createQuery("SELECT d FROM Domains d WHERE d.domainoptions.name = :option");
query.setParameter("option", "nogreylisting");
List<Domain> result = query.getResultList();
for (Domain dom : result) {
HashMap<String, String> hashMap = new HashMap<String, String>();
domsMaps.add(hashMap);
}
return new CompoundProcessor(
new TemplateProcessor("/de/hdsadmin/mods/dom/postgrey-whitelist-recipients.jtpl",
hashMap, domsMaps.iterator(), "/etc/postgeay/whitelist_recipients", true),
new ShellProcessor("invoke-rc.d postgrey reload"),
new ShellProcessor("postmap -r -i /etc/postfix-mailin/relaydomains",
domName + " anything\n" +
"." + domName + " anything\n"),

View File

@ -0,0 +1,11 @@
<!-- BEGIN: main -->### Do not edit this file manually
### Generated by HSAdmin Queue Server
abuse@
postmaster@
################################################################################
<!-- BEGIN: iterate -->{DOM}
<!-- END: iterate -->
<!-- END: main -->