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 > > smtp: 0x271c2c0: <<< EHLO localhost > mproc: pony -> lka : 49 IMSG_REPORT_SMTP_PROTOCOL_CLIENT > mproc: pony -> lka : 50 IMSG_??? (129) > smtp: 0x271c2c0: STATE_CONNECTED -> STATE_HELO > smtp: 0x271c2c0: >>> 250-host.domain.com Hello localhost [local], pleased to > meet you > mproc: pony -> lka : 102 IMSG_REPORT_SMTP_PROTOCOL_SERVER > smtp: 0x271c2c0: >>> 250-8BITMIME > mproc: pony -> lka : 47 IMSG_REPORT_SMTP_PROTOCOL_SERVER > smtp: 0x271c2c0: >>> 250-ENHANCEDSTATUSCODES > mproc: pony -> lka : 58 IMSG_REPORT_SMTP_PROTOCOL_SERVER > smtp: 0x271c2c0: >>> 250-SIZE 104857600 > mproc: pony -> lka : 53 IMSG_REPORT_SMTP_PROTOCOL_SERVER > smtp: 0x271c2c0: >>> 250 HELP > mproc: pony -> lka : 43 IMSG_REPORT_SMTP_PROTOCOL_SERVER > smtp: 0x271c2c0: IO_LOWAT <io:0x271aa40 fd=16 to=300000 fl=W ib=0 ob=0> > smtp: 0x271c2c0: IO_DATAIN <io:0x271aa40 fd=16 to=300000 fl=R ib=38 ob=0> > smtp: 0x271c2c0: <<< MAIL FROM:<u...@host.domain.com> > mproc: pony -> lka : 72 IMSG_REPORT_SMTP_PROTOCOL_CLIENT > mproc: pony -> queue : 8 IMSG_SMTP_MESSAGE_CREATE > imsg: queue <- pony: IMSG_SMTP_MESSAGE_CREATE (len=8) > queue-backend: queue_message_create() -> 1 (df19e22a) > mproc: queue -> pony : 16 IMSG_SMTP_MESSAGE_CREATE > imsg: pony <- queue: IMSG_SMTP_MESSAGE_CREATE (len=16) > mproc: pony -> lka : 37 IMSG_REPORT_SMTP_TX_BEGIN > smtp: 0x271c2c0: >>> 250 2.0.0 Ok > mproc: pony -> lka : 70 IMSG_??? (134) > mproc: pony -> lka : 47 IMSG_REPORT_SMTP_PROTOCOL_SERVER > smtp: 0x271c2c0: IO_LOWAT <io:0x271aa40 fd=16 to=300000 fl=W ib=0 ob=0> > smtp: 0x271c2c0: IO_DATAIN <io:0x271aa40 fd=16 to=300000 fl=R ib=29 ob=0> > smtp: 0x271c2c0: <<< RCPT TO:<u...@domain.com> > mproc: pony -> lka : 63 IMSG_REPORT_SMTP_PROTOCOL_CLIENT > 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.