diff --git a/doc/getting_started/plugins.rst b/doc/getting_started/plugins.rst index 2b47858e7..6f70f0d57 100644 --- a/doc/getting_started/plugins.rst +++ b/doc/getting_started/plugins.rst @@ -46,7 +46,7 @@ listing page: *relay domain* and *relay domain alias*. The extension is compatible with the *amavis* and *limits* ones. Resellers will be able to create both new objects. -To tell Postfix this feature exists, you must generate two new map +Replace by the name of the database you use.To tell Postfix this feature exists, you must generate two new map files and then update your configuration. To generate the map files, run the following command:: @@ -55,7 +55,24 @@ To generate the map files, run the following command:: Replace values between ``<>`` by yours. -Edit the :file:`/etc/postfix/main.cf` file. +Edit the :file:`/etc/postfix/main.cf` file and copy the following +lines inside:: + + relay_domains = :/etc/postfix/maps/sql-relaydomains.cf + transport_maps = + :/etc/postfix/maps/sql-relaydomains-transport.cf + :/etc/postfix/maps/sql-relaydomain-aliases-transport.cf + +Replace ```` by the name of the database you use. + +Ensure that ``smtpd_recipient_restrictions`` contains at least the +following options:: + + smtpd_recipient_restrictions = + permit_mynetworks + reject_unauth_destination + +Reload postfix. .. _amavis_frontend: @@ -311,12 +328,11 @@ configuration files as follows: ``/etc/postfix/main.cf``:: - transport_maps = mysql:/etc/postfix/maps/sql-transport.cf - virtual_alias_maps = mysql:/etc/postfix/maps/sql-aliases.cf - mysql:/etc/postfix/mapfiles/sql-domain-aliases-mailboxes.cf, - mysql:/etc/postfix/mapfiles/sql-email2email.cf, - mysql:/etc/postfix/maps/sql-autoreplies.cf, - mysql:/etc/postfix/mapfiles/sql-catchall-aliases.cf + transport_maps = mysql:/etc/postfix/maps/sql-autoreplies-transport.cf + virtual_alias_maps = :/etc/postfix/maps/sql-aliases.cf + :/etc/postfix/mapfiles/sql-domain-aliases-mailboxes.cf, + :/etc/postfix/maps/sql-autoreplies.cf, + :/etc/postfix/mapfiles/sql-catchall-aliases.cf .. note:: @@ -327,7 +343,8 @@ configuration files as follows: autoreply unix - n n - - pipe flags= user=vmail: argv=/manage.py autoreply $sender $mailbox -```` is the path of your Modoboa instance. +Replace ```` by the name of the database you +use. ```` is the path of your Modoboa instance. Then, create the requested map files:: diff --git a/doc/getting_started/upgrade.rst b/doc/getting_started/upgrade.rst index 013e9fb56..6fec4120c 100644 --- a/doc/getting_started/upgrade.rst +++ b/doc/getting_started/upgrade.rst @@ -50,8 +50,8 @@ Finally, follow the common procedure:: .. _1.1.0: -1.1.0: FIXME -============ +1.1.0: relay domains and better passwords encryption +==================================================== Due to code refactoring, some modifications need to be done into :file:`settings.py`: diff --git a/doc/integration/imap_and_smtp.rst b/doc/integration/imap_and_smtp.rst index 5c66009fa..7b9d0aa9f 100644 --- a/doc/integration/imap_and_smtp.rst +++ b/doc/integration/imap_and_smtp.rst @@ -443,15 +443,9 @@ Use the following configuration in the :file:`/etc/postfix/main.cf` file virtual_transport = dovecot dovecot_destination_recipient_limit = 1 - virtual_minimum_uid = - virtual_gid_maps = static: - virtual_uid_maps = static: - virtual_mailbox_base = /var/vmail - relay_domains = virtual_mailbox_domains = :/etc/postfix/sql-domains.cf virtual_alias_domains = :/etc/postfix/sql-domain-aliases.cf - virtual_mailbox_maps = :/etc/postfix/sql-mailboxes.cf virtual_alias_maps = :/etc/postfix/sql-aliases.cf, :/etc/postfix/sql-domain-aliases-mailboxes.cf, :/etc/postfix/sql-catchall-aliases.cf diff --git a/modoboa/core/commands/postfix_maps.py b/modoboa/core/commands/postfix_maps.py index d37fb1dbb..d5f4968af 100644 --- a/modoboa/core/commands/postfix_maps.py +++ b/modoboa/core/commands/postfix_maps.py @@ -104,13 +104,6 @@ class DomainsAliasesMap(MapFile): sqlite = "SELECT dom.name FROM admin_domain dom INNER JOIN admin_domainalias domal ON dom.id=domal.target_id WHERE domal.name='%s' AND domal.enabled=1 AND dom.enabled=1" -class MailboxesMap(MapFile): - filename = 'sql-mailboxes.cf' - mysql = "SELECT 1 FROM admin_mailbox mb INNER JOIN admin_domain dom ON mb.domain_id=dom.id INNER JOIN core_user user ON mb.user_id=user.id WHERE dom.enabled=1 AND dom.name='%d' AND user.is_active=1 AND mb.address='%u'" - postgres = "SELECT 1 FROM admin_mailbox mb INNER JOIN admin_domain dom ON mb.domain_id=dom.id INNER JOIN core_user u ON mb.user_id=u.id WHERE dom.enabled AND dom.name='%d' AND u.is_active AND mb.address='%u'" - sqlite = "SELECT 1 FROM admin_mailbox mb INNER JOIN admin_domain dom ON mb.domain_id=dom.id INNER JOIN core_user user ON mb.user_id=user.id WHERE dom.enabled=1 AND dom.name='%d' AND user.is_active=1 AND mb.address='%u'" - - class AliasesMap(MapFile): filename = 'sql-aliases.cf' mysql = "(SELECT concat(mb.address, '@', dom.name) FROM admin_mailbox mb INNER JOIN admin_domain dom ON mb.domain_id=dom.id WHERE mb.id IN (SELECT al_mb.mailbox_id FROM admin_alias_mboxes al_mb INNER JOIN admin_alias al ON al_mb.alias_id=al.id INNER JOIN admin_domain dom ON al.domain_id=dom.id WHERE dom.name='%d' AND dom.enabled=1 AND al.address='%u' AND al.enabled=1)) UNION (SELECT concat(al.address, '@', dom.name) FROM admin_alias al INNER JOIN admin_domain dom ON al.domain_id=dom.id WHERE al.id IN (SELECT al_al.to_alias_id FROM admin_alias_aliases al_al INNER JOIN admin_alias al ON al_al.from_alias_id=al.id INNER JOIN admin_domain dom ON al.domain_id=dom.id WHERE dom.name='%d' AND dom.enabled=1 AND al.address='%u' AND al.enabled=1)) UNION (SELECT al.extmboxes FROM admin_alias al INNER JOIN admin_domain dom ON al.domain_id=dom.id WHERE dom.name='%d' AND dom.enabled=1 AND al.address='%u' AND al.enabled=1 AND al.extmboxes<>'')" @@ -141,7 +134,7 @@ class MaintainMap(MapFile): class TransportMap(MapFile): category = "autoreply" - filename = 'sql-transport.cf' + filename = 'sql-autoreplies-transport.cf' mysql = "SELECT method FROM postfix_autoreply_transport WHERE domain='%s'" postgres = "SELECT method FROM postfix_autoreply_transport WHERE domain='%s'" sqlite = "SELECT method FROM postfix_autoreply_transport WHERE domain='%s'" @@ -155,20 +148,28 @@ class AutoRepliesMap(MapFile): sqlite = "SELECT full_address, autoreply_address FROM postfix_autoreply_alias WHERE full_address='%s'" +class RelayDomainsMap(MapFile): + category = "relaydomains" + filename = "sql-relaydomains.cf" + mysql = "SELECT name FROM postfix_relay_domains_domain WHERE name='%s' AND enabled=1" + postgres = "SELECT name FROM postfix_relay_domains_domain WHERE name='%s' AND enabled" + sqlite = "SELECT name FROM postfix_relay_domains_domain WHERE name='%s' AND enabled=1" + + class RelayDomainsTransportMap(MapFile): category = "relaydomains" filename = "sql-relaydomains-transport.cf" - mysql = "SELECT CONCAT(srv.name, ':') FROM postfix_relay_domains_service AS srv INNER JOIN postfix_relay_domains_relaydomain AS rdom ON rdom.service_id=srv.id WHERE rdom.enabled=1 AND rdom.name='%s'" - postgres = "SELECT srv.name || ':' FROM postfix_relay_domains_service AS srv INNER JOIN postfix_relay_domains_relaydomain AS rdom ON rdom.service_id=srv.id WHERE rdom.enabled AND rdom.name='%s'" - sqlite = "SELECT srv.name || ':' FROM postfix_relay_domains_service AS srv INNER JOIN postfix_relay_domains_relaydomain AS rdom ON rdom.service_id=srv.id WHERE rdom.enabled=1 AND rdom.name='%s'" + mysql = "SELECT CONCAT(srv.name, ':[', rdom.target_host, ']') FROM postfix_relay_domains_service AS srv INNER JOIN postfix_relay_domains_relaydomain AS rdom ON rdom.service_id=srv.id WHERE rdom.enabled=1 AND rdom.name='%s'" + postgres = "SELECT srv.name || ':[' || rdom.target_host || ']' FROM postfix_relay_domains_service AS srv INNER JOIN postfix_relay_domains_relaydomain AS rdom ON rdom.service_id=srv.id WHERE rdom.enabled AND rdom.name='%s'" + sqlite = "SELECT srv.name || ':[' || rdom.target_host || ']' FROM postfix_relay_domains_service AS srv INNER JOIN postfix_relay_domains_relaydomain AS rdom ON rdom.service_id=srv.id WHERE rdom.enabled=1 AND rdom.name='%s'" class RelayDomainAliasesTransportMap(MapFile): category = "relaydomains" filename = "sql-relaydomain-aliases-transport.cf" - mysql = "SELECT CONCAT(srv.name, ':') FROM postfix_relay_domains_service AS srv INNER JOIN postfix_relay_domains_relaydomain AS rdom ON rdom.service_id=srv.id INNER JOIN postfix_relay_domains_relaydomainalias AS rdomalias ON rdom.id=rdomalias.target_id WHERE rdom.enabled=1 AND rdomalias.enabled=1 AND rdomalias.name='%s'" - postgres = "SELECT srv.name || ':' FROM postfix_relay_domains_service AS srv INNER JOIN postfix_relay_domains_relaydomain AS rdom ON rdom.service_id=srv.id INNER JOIN postfix_relay_domains_relaydomainalias AS rdomalias ON rdom.id=rdomalias.target_id WHERE rdom.enabled AND rdomalias.enabled AND rdomalias.name='%s'" - sqlite = "SELECT srv.name || ':' FROM postfix_relay_domains_service AS srv INNER JOIN postfix_relay_domains_relaydomain AS rdom ON rdom.service_id=srv.id INNER JOIN postfix_relay_domains_relaydomainalias AS rdomalias ON rdom.id=rdomalias.target_id WHERE rdom.enabled=1 AND rdomalias.enabled=1 AND rdomalias.name='%s'" + mysql = "SELECT CONCAT(srv.name, ':[', rdom.target_host, ']') FROM postfix_relay_domains_service AS srv INNER JOIN postfix_relay_domains_relaydomain AS rdom ON rdom.service_id=srv.id INNER JOIN postfix_relay_domains_relaydomainalias AS rdomalias ON rdom.id=rdomalias.target_id WHERE rdom.enabled=1 AND rdomalias.enabled=1 AND rdomalias.name='%s'" + postgres = "SELECT srv.name || ':[' || rdom.target_host || ']' FROM postfix_relay_domains_service AS srv INNER JOIN postfix_relay_domains_relaydomain AS rdom ON rdom.service_id=srv.id INNER JOIN postfix_relay_domains_relaydomainalias AS rdomalias ON rdom.id=rdomalias.target_id WHERE rdom.enabled AND rdomalias.enabled AND rdomalias.name='%s'" + sqlite = "SELECT srv.name || ':[' || rdom.target_host || ']' FROM postfix_relay_domains_service AS srv INNER JOIN postfix_relay_domains_relaydomain AS rdom ON rdom.service_id=srv.id INNER JOIN postfix_relay_domains_relaydomainalias AS rdomalias ON rdom.id=rdomalias.target_id WHERE rdom.enabled=1 AND rdomalias.enabled=1 AND rdomalias.name='%s'" class PostfixMapsCommand(Command):