Skip to content
Snippets Groups Projects
Commit 50505215 authored by Thomas Bellman's avatar Thomas Bellman
Browse files

Support mail input filters in Sendmail configs.

This adds a parameter 'milters' to the sendmail::configure defintion,
which should be a hash specifying what mail input filters Sendmail
should apply.  Role classes are then passed a new 'milters' parameter,
and similarly to the 'localdomains' and 'defines' parameters, it will
receive a simple string with the proper INPUT_MAIL_FILTER() calls.

Role classes and their ERB templates are updated to handle the new
parameter, and insert it into the generated M4 files.
parent 95db4c14
No related branches found
No related tags found
No related merge requests found
# Copyright © 2014-2020 National Supercomputer Centre,
# Copyright © 2014-2022 National Supercomputer Centre,
# Linköping University, Sweden
# Licensed under the GNU LGPL v3+; see the README file for more information.
......@@ -66,6 +66,23 @@
* Hash of macro definitions to put into sendmail.mc, if one needs to
* set e.g. confMAX_MESSAGE_SIZE or confDEF_USER_ID.
*
* - milters:
* Hash of mail input filter ("milter") specifications. The values
* of the hash must in turn be hashes, acting as records, with the
* following fields:
* · 'socket' (mandatory)
* Socket the milter daemon listens to. If this starts with a
* slash ("/"), it is taken to be an AF_UNIX socket; otherwise it
* must start with a protocol identifier ("local:", "inet:",
* "inet6:") followed by the socket address.
* · 'flags' (optional)
* Sets the "F" parameter to the filter declaration.
* · 'timeouts' (optional)
* Sets the "T" parameter to the filter declaration.
* Milters will be configured, and thus executed, in lexographical
* order, so currently the only way to specify the order betwen
* milters is via the milter name.
*
* - params:
* Hash of extra, role-specific, parameters for the Sendmail config.
* See the documentation of each role for what parameters it supports.
......@@ -88,7 +105,7 @@
* Has the file generated by $aliases prepended, if that parameter is
* non-empty. Use the function 'sendmail_aliasfiles_define()' to get
* the correct line to put in sendmail.mc.
* - $localdomains, $defines:
* - $localdomains, $defines, $milters:
* Becomes lines defining the local domains and macros, respectively,
* for direct insertion into sendmail.mc.
*/
......@@ -97,7 +114,8 @@ define sendmail::configure(
$role='',
$mailhub='', $localdomains=[],
$aliasfiles=[], $aliases={},
$defines={}, $params={},
$defines={}, $milters={},
$params={},
)
{
include sendmail
......@@ -136,12 +154,25 @@ define sendmail::configure(
$x_defines = inline_template(
"<%= @defines.collect { |n,v| \"define(`\"+n+\"', `\"+v.to_s+\"')\\n\" }.sort.join \"\" %>"
)
$x_milters = inline_template(
"<%= @milters.sort.collect { |n,p|
sockaddr = p.fetch('socket')
sockaddr = 'local:'+sockaddr if sockaddr.start_with?('/')
params = [ 'S='+sockaddr ]
params << 'F='+p['flags'] if p['flags']
params << 'T='+p['timeouts'] if p['timeouts']
\"INPUT_MAIL_FILTER(`\"+n+\"', `\"+params.join(', ')+\"')\\n\"
}.join()
%>"
)
class {
$roleclass:
mailhub => $x_mailhub,
localdomains => $x_localdomains,
aliasfiles => $x_aliasfiles,
defines => $x_defines,
milters => $x_milters,
params => $params;
}
}
# Copyright © 2014-2020 National Supercomputer Centre,
# Copyright © 2014-2022 National Supercomputer Centre,
# Linköping University, Sweden
# Licensed under the GNU LGPL v3+; see the README file for more information.
......@@ -19,7 +19,7 @@
*/
class sendmail::role::nullclient(
$mailhub, $localdomains, $aliasfiles,
$defines, $params)
$defines, $milters, $params)
{
if ($mailhub == '') {
fail("${title}: mailhub not specified")
......
# Copyright © 2014-2020 National Supercomputer Centre,
# Copyright © 2014-2022 National Supercomputer Centre,
# Linköping University, Sweden
# Licensed under the GNU LGPL v3+; see the README file for more information.
......@@ -23,7 +23,7 @@
*/
class sendmail::role::nullrelay(
$mailhub, $localdomains, $aliasfiles,
$defines, $params)
$defines, $milters, $params)
{
if ($mailhub == '') {
fail("${title}: mailhub not specified")
......
# Copyright © 2014-2020 National Supercomputer Centre,
# Copyright © 2014-2022 National Supercomputer Centre,
# Linköping University, Sweden
# Licensed under the GNU LGPL v3+; see the README file for more information.
......@@ -15,7 +15,7 @@
*/
class sendmail::role::simpleclient(
$mailhub, $localdomains, $aliasfiles,
$defines, $params)
$defines, $milters, $params)
{
if ($mailhub == '') {
fail("${title}: mailhub not specified")
......
# Copyright © 2014-2020 National Supercomputer Centre,
# Copyright © 2014-2022 National Supercomputer Centre,
# Linköping University, Sweden
# Licensed under the GNU LGPL v3+; see the README file for more information.
......@@ -30,7 +30,7 @@
*/
class sendmail::role::subserver(
$mailhub, $localdomains, $aliasfiles,
$defines, $params)
$defines, $milters, $params)
{
include sendmail
......
......@@ -8,6 +8,7 @@ DAEMON_OPTIONS(`Name=MSA6, Family=inet6, Address=::1, Port=587, M=E')
dnl Local settings
<%= @defines -%>
<%= @localdomains -%>
<%= @milters -%>
dnl Add our FQDN to domainless addresses, not MAIL_HUB
FEATURE(`stickyhost')
......
......@@ -6,6 +6,7 @@ DAEMON_OPTIONS(`Name=MTA, Family=inet6, Port=smtp')
dnl Local settings
<%= @defines -%>
<%= @localdomains -%>
<%= @milters -%>
dnl Add our FQDN to domainless addresses, not MAIL_HUB
FEATURE(`stickyhost')
......
......@@ -16,6 +16,7 @@ define(`SMART_HOST', `esmtp:<%= @mailhub %>')
dnl Local settings
<%= @defines -%>
<%= @localdomains -%>
<%= @milters -%>
MAILER(`smtp')
......
......@@ -22,6 +22,7 @@ define(`confMAX_HOP', `50')
dnl Local settings
<%= @defines -%>
<%= @localdomains -%>
<%= @milters -%>
dnl Mail to us that are not caught by the alias file go to the mail hub.
define(`MAIL_HUB', `hubrelay:<%= @mailhub %>')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment