On 05/09/2019 13:32, Martijn van Duren wrote:
On 9/5/19 11:55 AM, Reio Remma wrote:
On 05/09/2019 11:33, gil...@poolp.org wrote:
Yes, see the smtpd.conf(5) man page:

filter myreporter proc-exec "/tmp/reporting.sh"

listen on [...] filter myreporter
mproc: pony -> lka : 291 IMSG_SMTP_EXPAND_RCPT

SMTPD seems to get stuck here with no errors. This is with the simple:

filter reporter proc-exec "/etc/opensmtpd/reporter.sh"

#!/bin/sh
while read line; do
     echo $line >> /var/log/opensmtpd.log
done

Reio

You need to register what events you want to receive and finish up with
register|ready.

$ cat test.sh
#!/bin/sh

while read line; do
         echo $line >&2
         if [ "${line%%\|*}" == "config" ]; then
                 if [ "${line#*\|}" == "ready" ]; then
                         echo "register|report|smtp-in|link-connect"
                         echo "register|ready"
                 fi
                 continue
         fi
done

Possible values for report are (from lka_report.c):
static struct smtp_events {
         const char     *event;
} smtp_events[] = {
         { "link-connect" },
         { "link-disconnect" },
         { "link-greeting" },
         { "link-identify" },
         { "link-tls" },
         { "link-auth" },

         { "tx-reset" },
         { "tx-begin" },
         { "tx-mail" },
         { "tx-rcpt" },
         { "tx-envelope" },
         { "tx-data" },
         { "tx-commit" },
         { "tx-rollback" },

         { "protocol-client" },
         { "protocol-server" },

         { "filter-response" },

         { "timeout" },
};

Possible values for filter are:
static struct filter_exec {
         enum filter_phase       phase;
         const char             *phase_name;
         int                    (*func)(struct filter_session *, struct filter 
*, uint64_t, const char *);
} filter_execs[FILTER_PHASES_COUNT] = {
         { FILTER_CONNECT,       "connect",      filter_builtins_connect },
         { FILTER_HELO,          "helo",         filter_builtins_helo },
         { FILTER_EHLO,          "ehlo",         filter_builtins_helo },
         { FILTER_STARTTLS,      "starttls",     filter_builtins_notimpl },
         { FILTER_AUTH,          "auth",         filter_builtins_notimpl },
         { FILTER_MAIL_FROM,     "mail-from",    filter_builtins_mail_from },
         { FILTER_RCPT_TO,       "rcpt-to",      filter_builtins_rcpt_to },
         { FILTER_DATA,          "data",         filter_builtins_notimpl },
         { FILTER_DATA_LINE,     "data-line",    filter_builtins_notimpl },
         { FILTER_RSET,          "rset",         filter_builtins_notimpl },
         { FILTER_QUIT,          "quit",         filter_builtins_notimpl },
         { FILTER_NOOP,          "noop",         filter_builtins_notimpl },
         { FILTER_HELP,          "help",         filter_builtins_notimpl },
         { FILTER_WIZ,           "wiz",          filter_builtins_notimpl },
         { FILTER_COMMIT,        "commit",       filter_builtins_notimpl },
};

reports come in in the format:
report|<version>|<time>|<direction>|<phase>|<reqid>|<parameters>

filters come in in the format:
filter|<version>|<time>|<direction>|<phase>|<reqid>|<token>|<parameter>

Note that filters require a proceed, rewrite, reject, or disconnect
reply in the form:

filter-result|<token>|<reqid>|proceed
filter-result|<token>|<reqid>|reject|<reason>
filter-result|<token>|<reqid>|disconnect|<reason>
filter-result|<token>|<reqid>|rewrite|<value>

Note that this is mostly stable, but some changes may occur, so
keep track of the version. Minor versions are backwards compatible,
major versions are not.


Thanks! I'll keep digging. :)

Reio

Reply via email to