https://qmail-spp.sourceforge.net/plugins/details/?id=38
強力なツールで、sppにはふさわしくないかも。
勉強材料としては面白い。-- ToshinoriMaeno 2022-03-28 02:12:20
必要になるほどのspamは来ない。
https://github.com/piwai/qmail-spp-filter
/* This program enables qmail-spp commands to be issued based on matches of TCPREMOTEIP, SMTPMAILFROM or SMTPRCPTTO with records in text files. The TinyCDB library (http://www.corpit.ru/mjt/tinycdb.html) is used. Or if is not available, the standard CDB library is used (http://cr.yp.to/cdb/install.html). Compile plugin using something like this for TinyCDB: gcc -g -Wall qmail-spp-filter.c -o qmail-spp-filter -lcdb Or this for standard CDB: gcc -g -Wall qmail-spp-filter.c -o qmail-spp-filter /usr/lib/cdb.a \ /usr/lib/unix.a /usr/lib/buffer.a /usr/lib/alloc.a /usr/lib/byte.a Put qmail-spp-filter in the qmail plugins directory (ex. "/var/qmail/plugins") and add to smtpplugins file (ex. "/var/qmail/control/smtpplugins") after [rcpt] section: [rcpt] ` plugins/qmail-spp-filter If the "RELAYCLIENT" environment variable (envar) is set, this module exits without doing anything, since the client has permission to relay. IPv6 is supported if TCPREMOTEIP contains an IPv6 address or if TCP6REMOTEIP envar is set.
1. filters
Filters are specified by setting the following envars.
SPP_FILTER_#_DEF SPP_FILTER_#_CMD
Separate commands are separated by a comma or a carriage return. Be careful not to include a comma for any other reason.
Once a match is found and a CMD is processed, the plugin exits.
An optional SPP_FILTER_NOMATCH_CMD envar can be set if you want the program to issue a qmail-spp command (or commands) if there is a failure to find any match. Except for the SPP_FILTER_NOMATCH_CMD envar, if any CMDs include the special string "send-filter-def" then "send-filter-def" will be replaced by the content of the SPP_FILTER_#_DEF envar that matched.
Example envars:
SPP_FILTER_1_DEF="ip:/var/qmail/control/whitelist_ips" SPP_FILTER_1_CMD="A,SSPP_FILTER_WHITELISTEDIP_MATCHED=1" SPP_FILTER_2_DEF="regexrcpt:/var/qmail/control/whitelist_regex_rcpts" SPP_FILTER_2_CMD="A,HSPP-Filter-Match: send-filter-def" SPP_FILTER_3_DEF="regexfrom:/var/qmail/control/blacklist_regex_senders" SPP_FILTER_3_CMD="E550 Blacklisted!" SPP_FILTER_4_DEF="rcpt:/var/qmail/control/whitelist_rcpts" SPP_FILTER_4_CMD="A" SPP_FILTER_5_DEF="from:/var/qmail/control/whitelist_senders" SPP_FILTER_5_CMD="A" SPP_FILTER_6_DEF="from:/var/qmail/control/blacklist_senders" SPP_FILTER_6_CMD="E550 Blacklisted!" SPP_FILTER_NOMATCH_CMD="SSPP_FILTER_FOUND_NO_MATCH=1"