59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
# File 'manifests/mc/milter.pp', line 59
define sendmail::mc::milter (
Enum['local','unix','inet','inet6'] $socket_type,
String $socket_spec,
Enum['R','T','4',''] $flags = 'T',
Optional[Sendmail::Timeout] $send_timeout = undef,
Optional[Sendmail::Timeout] $receive_timeout = undef,
Optional[Sendmail::Timeout] $eom_timeout = undef,
Optional[Sendmail::Timeout] $connect_timeout = undef,
String $order = '00',
String $milter_name = $name,
Boolean $enable = true,
) {
include sendmail::mc::milter_section
#
# Socket parameter
#
case $socket_type {
/^(local|unix)$/: { assert_type(Stdlib::Absolutepath, $socket_spec) }
/^inet6?$/: { assert_type(Pattern[/^[0-9]+@./], $socket_spec) }
default: { fail('Invalid socket type') }
}
#
# Timout parameter
#
$sparse_timeouts = {
'S' => $send_timeout,
'R' => $receive_timeout,
'E' => $eom_timeout,
'C' => $connect_timeout,
}
$real_timeouts = $sparse_timeouts.filter |$key,$val| { $val != undef }
$opt_timeouts = empty($real_timeouts) ? {
true => undef,
default => join(join_keys_to_values($real_timeouts, ':'), ';'),
}
#
# Put everything together
#
$sparse_opts_all = {
'S' => "${socket_type}:${socket_spec}",
'F' => $flags,
'T' => $opt_timeouts,
}
$real_opts_all = $sparse_opts_all.filter |$key,$val| { $val != undef }
$opts = join(join_keys_to_values($real_opts_all, '='), ', ')
#
# Decide which macro to use
#
$macro_name = bool2str($enable, 'INPUT_MAIL_FILTER', 'MAIL_FILTER')
concat::fragment { "sendmail_mc-milter-${milter_name}":
target => 'sendmail.mc',
order => "56-${order}",
content => "${macro_name}(`${milter_name}', `${opts}')dnl\n",
}
}
|