ln -s zdkimfilter other-name; filterctl ("start" | "stop") other-name
/local/libexec/usr/path/filters/zdkimfilter OPTION
The second form is for running multiple filters. See ``MULTIPLE FILTERS'' below.
The third form is used for scripting or testing. See ``COMMAND LINE OPTIONS'' below.
A DKIM signature on a message associates a domain with the message, thereby allowing domain owners to claim some responsibility for the messages.
For SMTP authentication, the domain name is determined after the user id, if it contains an "@" or from default_domain.
For non-empty RELAYCLIENT variable, typically set in smtpaccess files, zdkimfilter signs only if the value of RELAYCLIENT starts with "@". In that case, the domain name is the rest of the string. The local part of the user id is set to ``postmaster'' (e.g. for db_sql_check_user). CAUTION: this setting may conflict with Courier appending the value of RELAYCLIENT to message recipient(s). That is meant to force the message through local delivery, possibly using percentrelay. The filter removes the appended values as long as it is installed. To prevent that behavior set let_relayclient_alone. At any rate, when a client uses SMTP authentication, any RELAYCLIENT content is reset.
In any case, the domain name can be obtained from a suitable header field of the message, such as "From:". Use the key_choice_header configuration option to specify that.
The domain name is then looked up in the domain_keys directory. It should be a soft link to the actual key. The basename of the linked-to file contains the selector. See examples in zdkimgenkey(8). If the file is not a soft link, zdkimfilter will use a default selector "s=s", configurable with ``selector'' in zdkimfilter.conf.
The user-id used for SMTP authentication is also reported in Courier's "Received:" header field. If the redact_received_auth configuration option is set, zdkimfilter obscures it. See redact(1).
After signing an outgoing message, zdkimfilter logs to the database the list of domains that appeared in any RCPT command. The database can be used for whitelisting and for rate-limiting users. See zfilter_db(1) for more details.
Messages can be rejected or dropped according to DMARC, ADSP, and NXDOMAIN configurations, summarized below, and also according to an action_header (see zdkimfilter.conf(5)) or the shoot_on_sight feature (see whitelisted in zfilter_db(1)). The decision to reject or drop a message can be revoked after DNSWL (see dnswl_worthiness_pass and whitelisted_pass in zdkimfilter.conf(5)). So, if a domain is tagged shoot_on_sight, but the message is authenticated by a domain which is whitelisted or DNSWL-worth, the latter wins and the message is not rejected. However, if the sender is DNSWL-worth but tagged shoot_on_sight, it worthiness is discarded and the message is rejected.
By default, zdkimfilter adds an "Authentication-Results:" (A-R) header field only when there are noticeable results to report. It uses the host name that Courier uses in its "Received:" field. Other A-R fields with that same name get zapped from the message, if found.
While per-domain flags (whitelisted, do_dmarc, do_adsp) are read during the verification process, the resulting data is logged to the database after handing the message back to Courier. Those results are used to send aggregate reports, and in general can contribute some insight on the email traffic. See zfilter_db(1) for the details.
Options honor_dmarc and honor_author_domain set to 0 or 1 the corresponding flags. Then a query db_sql_domain_flags can increase or decrease those values. A DMARC record is looked up unless DMARC flag is less than ADSP's. If no record is found, an ADSP record is looked up unless ADSP flag is less than DMARC's. Thus, if the flags are equal an ADSP record is looked up for domains that still don't have DMARC. Then, if its flag is greater than 0, the policy is honored. However, if an authenticated domain is whitelisted or DNSWL allowed, the message is delivered even though the policy failed.
DMARC record lookup is done through a Tree Walk procedure. This is the new method specified in the upcoming specification, replacing the use of the Public Suffix List (PSL). Its implementation here comprises querying a suite of TXT records in parallel (up to 8) in order to determine the organizational domain of the "From:" domain. The query parameters, hosts, timeout and number of attempts are read from resolv.conf, see resolv.conf(5). The PSL file should still be available and configured in publicsuffix in order to produce aggregate records. See zaggregate(1) and zdkimfilter.conf(5).
A DMARC policy can ask to quarantine a message. If DMARC is honored, the filter just adds an A-R field contains a "(QUARANTINE)" comment right after "dmarc=fail" and the message is delivered normally. This can be dealt with on delivery, for example like so:
if (/^Authentication-Results:.*dmarc=fail..QUARANTINE/:H) { KEYWORDS='$Junk'; }
Unless this feature is disabled by setting disable_experimental, such fields are saved on signing and checked on verifiying. For signatures recovered by undoing transformations, a "reason=" tag is added in A-R. In case the "From:" field was changed by the MLM and recovered, the reason mentions "Original-From:". The value can be restored on delivery, for example like so:
if (/^Authentication-Results:.*dkim=pass reason="Original-From/:H) { xfilter "reformail -R From: Munged-From: | reformail -R Original-From: From:" }
Note: The value of "From:" must be restored after any external forwarding, otherwise an external DMARC filter might reject the message, thereby vanishing the reason why MLM munged "From:" in the first place.
DMARC requires SPF, besides DKIM. To enable SPF checking in bofh see courier(8). The result of Courier's SPF check is read from Received-SPF header fields in the message. If SPF is not configured in Courier, turn off this behavior with no_spf, to avoid spurious authentications.
A filter copy can use the same configuration file or a different one. As courierfilter does not pass arguments, the alternative filename is embedded in the other-name of the symbolic link: if the name includes the sequence "-f_" (hyphen, 'f', underscore, alluding to the -f command line option), the name formed by the characters after the sequence, in the /local/courier/etc/path/filters directory, will be used as configuration filename. If no characters follow the "-f_" sequence, then the whole basename is used to form the name of the configuration file. The extension ".conf" is added to the filename if not already present.
A different behavior can be obtained also using the same configuration file by using option ``split_verify'' in zdkimfilter.conf.
An alternative way to indicate a different filename is described above under ``MULTIPLE FILTERS''. In that case, the file will be searched in /local/courier/etc/path/filters.
If given, the -f option overrides any config-filename embedded in the program name.
This option is used by zdkimverify's -o option.
If the executable is compiled with debugging support, this option dumps the canonicalization results to files named "dkim.*.*".
All files are created in the /tmp directory, possibly overridden by the corresponding configuration parameter.
If x starts with "zdkim", then configuration parameter split_verify is discarded. That's the mode used by zdkimsign.
Upon receiving the signal, zdkimfilter reads its configuration file and opens new connections to OpenDKIM library and (possibly) to the database. If no error occurs, it then cleans up the old area, closing old connections, and writes LOG_INFO if verbosity is 2 or higher.
Copyright © 2012-2024 Alessandro Vesely