The "filter" API is clearly sophisticated, but seems to be more of an
RPC-like "plugin" API.
Most of my uses need something akin to a simple filter.
Here's an example: I would like our outbound SMTP servers to strip
"Received" headers, to avoid exposing some gnarly details of our internal
network (eg. prototype script below)
There needs quite a lot of code to sit between smtpd and this script.
I could write that code, but probably error-prone. Even if I avoid bugs,
there's the need to handle concurrency and buffer messages to temp files.
Whereas smtpd is well positioned to do something like:
listen on 0.0.0.0 filter "/etc/mail/filter-cloak.awk"
or at other stages in smtpd processing, eg.:
action "outbound" filter "/etc/mail/filter-cloak.awk" relay
The process would be forked per message; not dissimilar to the existing
"mda" directive, but the message stays within the pipeline.
Return codes could reject or error, covering even more uses cases. And the
separate process per-message offers protections such as ulimit or setuid.
--
Mark
#!/usr/bin/awk -f
#
# Filter email message to remove 'Received' headers
#
BEGIN {
headers = 1
skip = 0
}
headers && /^$/ {
headers = 0
}
headers {
if (/^[ \t]/) {
if (skip)
next
}
skip = tolower($0) ~ /^received:/
if (skip)
next
}
{
print
}