Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

puppet: Restrict postfix incoming addresses to postmaster and zulip.

Alex Vandiver1c17583ad5b2
diff --git a/puppet/zulip/files/postfix/access b/puppet/zulip/files/postfix/access
new file mode 100644
index 00000000000..265bcf70cee
--- /dev/null
+++ b/puppet/zulip/files/postfix/access
@@ -0,0 +1,9 @@
+# This is the list of email addresses that are accepted via SMTP;
+# these consist of only the addresses in `virtual`, as well as the
+# RFC822-specified postmaster.
+
+/\+.*@/ OK
+/\..*@/ OK
+/^mm/ OK
+
+/^postmaster@/ OK
diff --git a/puppet/zulip/files/postfix/virtual b/puppet/zulip/files/postfix/virtual
index 86624fae98a..96e1a9bfcd2 100644
--- a/puppet/zulip/files/postfix/virtual
+++ b/puppet/zulip/files/postfix/virtual
@@ -1,3 +1,6 @@
-/\+.*@/ zulip@localhost
-/\..*@/ zulip@localhost
-/^mm/ zulip@localhost
+# Changes to this list require a corresponding change to `access` as
+# well.
+
+/\+.*@/ zulip@localhost
+/\..*@/ zulip@localhost
+/^mm/ zulip@localhost
diff --git a/puppet/zulip/manifests/postfix_localmail.pp b/puppet/zulip/manifests/postfix_localmail.pp
index 345ab310f2e..737a4a4961a 100644
--- a/puppet/zulip/manifests/postfix_localmail.pp
+++ b/puppet/zulip/manifests/postfix_localmail.pp
@@ -67,4 +67,12 @@ class zulip::postfix_localmail {
],
}
+ file {'/etc/postfix/access':
+ ensure => file,
+ mode => '0644',
+ owner => root,
+ group => root,
+ source => 'puppet:///modules/zulip/postfix/access',
+ require => Package[postfix],
+ }
}
diff --git a/puppet/zulip/templates/postfix/main.cf.erb b/puppet/zulip/templates/postfix/main.cf.erb
index e51e021fc55..13eac5e062c 100644
--- a/puppet/zulip/templates/postfix/main.cf.erb
+++ b/puppet/zulip/templates/postfix/main.cf.erb
@@ -16,6 +16,7 @@ smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination
+smtpd_recipient_restrictions = check_recipient_access regexp:/etc/postfix/access, reject
myhostname = <%= @fqdn %>
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases