HSAdmin Backend Domains, E-Mail, Datenbanken
Peter Hormanns
2017-11-09 f4139407a840d3b128bcd22b1840f3ba75abf8b2
remove wildcard in relayrecipients only if no wildcard emailaddr exists
1 files modified
21 ■■■■■ changed files
hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java 21 ●●●●● patch | view | raw | blame | history
hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java
@@ -135,14 +135,19 @@
            new ShellProcessor("postmap -r -i /etc/postfix-mailin/relaydomains || true", 
                        dom.getName() + " anything\n" +
                        "." + dom.getName() + " anything\n"));
        final Query query = em.createQuery("SELECT d FROM Domains d WHERE d.domainoptions.name = :option AND d.name = :domname");
        query.setParameter("domname", dom.getName());
        query.setParameter("option", "backupmxforexternalmx");
        if (query.getResultList().isEmpty()) {
            cp.appendProcessor(
                    new ShellProcessor("postmap -d - /etc/postfix-mailin/relayrecipients || true",
                            "@" + dom.getName() + "\n")
                    );
        final Query domainBackupMXQuery = em.createQuery("SELECT d FROM Domains d WHERE d.domainoptions.name = :option AND d.name = :domname");
        domainBackupMXQuery.setParameter("domname", dom.getName());
        domainBackupMXQuery.setParameter("option", "backupmxforexternalmx");
        if (domainBackupMXQuery.getResultList().isEmpty()) {
            final Query wildcardAddressQuery = em.createQuery("SELECT addr FROM EMailAddresses addr "
                    + "WHERE addr.localpart = '' AND addr.domain.name = :domname AND (addr.subdomain IS NULL OR addr.subdomain = '')");
            wildcardAddressQuery.setParameter("domname", dom.getName());
            if (wildcardAddressQuery.getResultList().isEmpty()) {
                cp.appendProcessor(
                        new ShellProcessor("postmap -d - /etc/postfix-mailin/relayrecipients || true",
                                "@" + dom.getName() + "\n")
                        );
            }
            cp.appendProcessor(
                    new ShellProcessor("postmap -r -i /etc/postfix-mailin/transport || true", 
                            dom.getName() + " smtp:" + inetAddr + ":225\n" +