Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration of (enhanced) DNS black list #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ Parameters
* **aliases**: hash of aliases. Example: { 'user' => 'email' }
* **generics_domains**: list of domains to serve. Example: [ 'domain1.com', 'domain2.com' }
* **generics_table**: hash of user email addresses for multiple domains. Example: { 'user', 'email' }

* **is_relay**: bool, set to 1 if you want the server to be a relay
* **relay-domains**: list of domains to relay for. Example: { 'example.com', 'example2.co.uk' }
* **listen_ip**: Single IP address that the server should listen on. Example: 127.0.0.1

Usage
-----
Expand All @@ -48,6 +50,11 @@ Contributors
Release Notes
-------------

**0.1.3**

* Added relayer functionality
* Added listen_ip setting

**0.1.2**

* Template fix
Expand Down
37 changes: 35 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@
# [*generics_table*]
# Hash of user email addresses for multiple domains. Example: { 'user', 'email' }
#
# [*listen_ip*]
# Specifies if sendmail should listen on an ip other than localhost. Example: 127.0.0.1
#
# [*is_relay*]
# Specifies if sendmail should relay email from other servers. Boolean
#
# [*relay_domains*]
# List of domains to relay email for. Example: ['example.com','example2.co.uk']
#
# [*dnsbl*]
# Hash of DNS black list. Example: { 'blackholes.mail-abuse.org' => '"550 Mail from " $&{client_addr} " rejected, see http://mail-abuse.org/cgi-bin/lookup?" $&{client_addr}' }
#
# [*enhdnsbl*]
# Hash of enhanced DNS black list. Example: { 'bl.spamcop.net' => '$&{client_addr} rejected (Relays, Dialups, Spam Sources) - see http://bl.spamcop.net' }
#
# === Examples
#
# class { sendmail:
Expand All @@ -69,6 +84,11 @@
$aliases = undef,
$generics_domains = undef,
$generics_table = undef,
$listen_ip = '127.0.0.1',
$is_relay = undef,
$relay_domains = $sendmail::params::relay_domains,
$dnsbl = {},
$enhdnsbl = {}
) inherits sendmail::params {
package { $sendmail::params::sendmail_pkgs: ensure => latest }

Expand All @@ -78,7 +98,7 @@
mode => '0644',
content => template($sendmail::params::sendmail_mc_tmpl),
require => Package[$sendmail::params::sendmail_pkgs],
notify => Exec ["make_sendmail_config"],
notify => Exec["make_sendmail_config"],
}

if ($aliases) {
Expand All @@ -93,7 +113,20 @@
} else {
file { $sendmail::params::aliases_path: ensure => absent, notify => Service[$sendmail::service_name] }
}


if ($is_relay) {
file { $sendmail::params::relay_domains_path:
owner => 'root',
group => 'root',
mode => '0644',
content => template($sendmail::params::relay_domains_tmpl),
require => Package[$sendmail::params::sendmail_pkgs],
notify => Service[$sendmail::service_name],
}
} else {
file { $sendmail::params::relay_domains_path: ensure => absent, notify => Service[$sendmail::service_name] }
}

if ($generics_domains) {
file { $sendmail::params::generics_domains_path:
owner => 'root',
Expand Down
5 changes: 5 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@
$sendmail_mc_tmpl = 'sendmail/sendmail.mc.erb'
$aliases_path = '/etc/mail/aliases'
$aliases_tmpl = 'sendmail/aliases.erb'
$relay_domains_path = '/etc/mail/relay-domains'
$relay_domains_tmpl = 'sendmail/relay-domains.erb'
$is_relay = 'sendmail/relay-domains.erb'
$relay_domains = ['example.com', 'example.co.uk']
$generics_domains_path = '/etc/mail/generics-domains'
$generics_domains_tmpl = 'sendmail/generics-domains.erb'
$generics_table_path = '/etc/mail/genericstable'
$generics_table_tmpl = 'sendmail/genericstable.erb'
$service_name = 'sendmail'
$listen_ip = '127.0.0.1'
}
3 changes: 3 additions & 0 deletions templates/relay-domains.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<% scope.lookupvar('sendmail::relay_domains').each do |relaydomain| -%>
<%= relaydomain %>
<% end -%>
8 changes: 7 additions & 1 deletion templates/sendmail.mc.erb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ dnl # The following causes sendmail to only listen on the IPv4 loopback address
dnl # 127.0.0.1 and not on any other network devices. Remove the loopback
dnl # address restriction to accept email from the internet or intranet.
dnl #
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
DAEMON_OPTIONS(`Port=smtp,Addr=<%= scope.lookupvar('sendmail::listen_ip') %>, Name=MTA')dnl
dnl #
dnl # The following causes sendmail to additionally listen to port 587 for
dnl # mail from MUAs that authenticate. Roaming users who can't reach their
Expand Down Expand Up @@ -159,6 +159,12 @@ dnl #
FEATURE(`accept_unresolvable_domains')dnl
dnl #
dnl FEATURE(`relay_based_on_MX')dnl
<% scope.lookupvar('sendmail::dnsbl').each do |dnsbl,msg| -%>
FEATURE(dnsbl, `<%= dnsbl %>', `<%= msg %>')dnl
<% end -%>
<% scope.lookupvar('sendmail::enhdnsbl').each do |enhdnsbl,msg| -%>
FEATURE(enhdnsbl, `<%= enhdnsbl %>', `<%= msg %>', `t')dnl
<% end -%>
dnl #
dnl # Also accept email sent to "localhost.localdomain" as local email.
dnl #
Expand Down