FIXSMTPIO(8)

NAME
fixsmtpio - filter SMTP I/O and exit status

SYNOPSIS
fixsmtpio prog

DESCRIPTION
fixsmtpio is a proxy for changing how an SMTP service behaves without changing its code. By default, with no configuration, it changes almost no observable behavior.

In a typical configuration, fixsmtpio enables TLS for qmail-smtpd, modernizes responses from ofmipd, and makes both programs behave as though they were designed to run under authup(8). fixsmtpio accomplishes this by adjusting certain client requests, server responses, and exit codes. The EXIT CODES section is important enough to be all the way up here:

EXIT CODES
fixsmtpio exits 18 when control/fixsmtpio exists and fails to parse.

Part of fixsmtpio's job is to return distinct exit codes for distinct conditions. For instance, authup needs to distinguish checkpassword exiting 1 (to reject a password) from ofmipd or qmail-smtpd exiting 1 (on any error). When running under authup, fixsmtpio can and should be configured to exit uniquely for each SMTP condition:

14  when the server greeting code starts with 4 (temporary failure),

15  when the server greeting code starts with 5 (permanent failure),

16  when the server times out, and

0   when the server receives EOF from the client.

ENVIRONMENT VARIABLES
When running under sslserver -n or s6-ucspitlsd, fixsmtpio can offer TLS. Set UCSPITLS to the empty string to permit peers to negotiate TLS before transferring messages. If the peer has negotiated TLS, FIXSMTPIOTLS will be set for use by filter rules.

When running under authup, AUTHUP_USER will be set for use by filter rules (such as those recommended in EXIT CODES).

If DISABLETLS is set, the presence and value of UCSPITLS will be ignored.

If NOFIXSMTPIO is set, fixsmtpio will simply replace itself with prog.

If FIXSMTPIODEBUG is set, fixsmtpio will show its work. Lines are prefixed like so:

1: Request received from client

2: Request sent to server

3: Response received from server

4: Response sent to client

D: DATA received from client and sent to server as is

FILTER RULES
Filter rules follow the format:

[env]:event:[request-prepend]:response-line-glob:[exitcode]:[response]

(Values other than response may not contain ":", the field separator.)

env
    (optional) Environment variable which must be present for the rule to apply. If empty, none is required.

event
    (required) SMTP verb (or "clienteof", "greeting", or "timeout") to which the rule applies. This field is matched case-insensitively.

request-prepend
    (optional) String to prepend to the request before passing it to the server. "NOOP " (with trailing space) causes the server to trivially accept a request, performing no action. If empty, the request is sent as is.

response-line-glob
    (required) fnmatch(3)-style glob pattern, with no special options set. Each line of the response is compared against this glob.

exitcode
    (optional) Numeric code with which fixsmtpio is to exit immediately. If empty, it will exit whenever it normally would. If there are no rules specifying a value for this field, fixsmtpio will always exit with the same code as its child prog.

response
    (optional) String that replaces every matching line of the server response. If empty, matching lines are removed. Strings starting with "&fixsmtpio" are reserved for special handling. "&fixsmtpio_noop" causes the response to be sent as is. "&fixsmtpio_fixup" computes the replacement string via an event-specific internal routine. (If no corresponding routine exists, fixsmtpio Routines exist for

HELP:
    Prepend this program's home page, in an attempt to direct support requests to AUTHOR. Please enable it!

greeting,
    EHLO, HELO, and QUIT:
    Include smtpgreeting in the response. This is harmless with qmail-smtpd, which already does so, and brings ofmipd's behavior up to par.

Rules are applied in the order written. For instance, if two rules
    match, the later rule re-modifies the response returned by the earlier rule. If multiple matching rules for an event set exitcode, the last one wins.

Not all rules (alone or in combination) make practical sense. An earlier rule can cause a later one to start or stop matching. Keep your configuration as simple as possible, and test it well.

CONTROL FILES

fixsmtpio
    Filter rules as described in FILTER RULES. Default: none.

smtpgreeting
    SMTP greeting message. Default: me, if that is supplied; otherwise fixsmtpio will refuse to run. The first word of smtpgreeting should be the current host's name.

COMPATIBILITY
fixsmtpio must terminate TLS in order to observe and modify requests and responses. If you rely on qmail-smtpd being patched to support STARTTLS directly, please share your use case with the author.

EXAMPLES
See https://schmonz.com/qmail/acceptutils.

AUTHOR
Amitai Schleier <schmonz-web-acceptutils@schmonz.com>

SEE ALSO
authup(8), sslserver(1), s6-ucspitlsd, ucspi-tls(2), checkpassword(8), checknotroot(8), qmail-smtpd(8), ofmipd(8), qmail-qfilter-queue(8), fnmatch(3), fixcrio(1), spamdyke.