From 9db504a0c567acd318d9db9a8ea2ec7e4cd299f2 Mon Sep 17 00:00:00 2001 From: christos Date: Thu, 1 Feb 2018 03:29:41 +0000 Subject: Add support for blacklistd. --- external/ibm-public/postfix/dist/src/smtpd/pfilter.c | 19 +++++++++++++++++++ external/ibm-public/postfix/dist/src/smtpd/pfilter.h | 2 ++ external/ibm-public/postfix/dist/src/smtpd/smtpd.c | 5 ++++- external/ibm-public/postfix/libexec/smtpd/Makefile | 7 +++++-- 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 external/ibm-public/postfix/dist/src/smtpd/pfilter.c create mode 100644 external/ibm-public/postfix/dist/src/smtpd/pfilter.h (limited to 'external/ibm-public') diff --git a/external/ibm-public/postfix/dist/src/smtpd/pfilter.c b/external/ibm-public/postfix/dist/src/smtpd/pfilter.c new file mode 100644 index 00000000000..6d36cceb34c --- /dev/null +++ b/external/ibm-public/postfix/dist/src/smtpd/pfilter.c @@ -0,0 +1,19 @@ +#include "pfilter.h" +#include /* for NULL */ +#include + +static struct blacklist *blstate; + +void +pfilter_notify(int a, int fd) +{ + if (blstate == NULL) + blstate = blacklist_open(); + if (blstate == NULL) + return; + (void)blacklist_r(blstate, a, fd, "smtpd"); + if (a == 0) { + blacklist_close(blstate); + blstate = NULL; + } +} diff --git a/external/ibm-public/postfix/dist/src/smtpd/pfilter.h b/external/ibm-public/postfix/dist/src/smtpd/pfilter.h new file mode 100644 index 00000000000..782fb6205cd --- /dev/null +++ b/external/ibm-public/postfix/dist/src/smtpd/pfilter.h @@ -0,0 +1,2 @@ + +void pfilter_notify(int, int); diff --git a/external/ibm-public/postfix/dist/src/smtpd/smtpd.c b/external/ibm-public/postfix/dist/src/smtpd/smtpd.c index 3a22125ca73..2e969c1d37a 100644 --- a/external/ibm-public/postfix/dist/src/smtpd/smtpd.c +++ b/external/ibm-public/postfix/dist/src/smtpd/smtpd.c @@ -1,4 +1,4 @@ -/* $NetBSD: smtpd.c,v 1.14 2017/02/14 01:16:48 christos Exp $ */ +/* $NetBSD: smtpd.c,v 1.15 2018/02/01 03:29:41 christos Exp $ */ /*++ /* NAME @@ -1197,6 +1197,8 @@ #include #include +#include "pfilter.h" + /* * Tunable parameters. Make sure that there is some bound on the length of * an SMTP command, so that the mail system stays in control even when a @@ -5048,6 +5050,7 @@ static void smtpd_proto(SMTPD_STATE *state) if (state->error_count >= var_smtpd_hard_erlim) { state->reason = REASON_ERROR_LIMIT; state->error_mask |= MAIL_ERROR_PROTOCOL; + pfilter_notify(1, vstream_fileno(state->client)); smtpd_chat_reply(state, "421 4.7.0 %s Error: too many errors", var_myhostname); break; diff --git a/external/ibm-public/postfix/libexec/smtpd/Makefile b/external/ibm-public/postfix/libexec/smtpd/Makefile index d38f6fc98ea..2569cd0fbcd 100644 --- a/external/ibm-public/postfix/libexec/smtpd/Makefile +++ b/external/ibm-public/postfix/libexec/smtpd/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.6 2017/05/21 15:28:40 riastradh Exp $ +# $NetBSD: Makefile,v 1.7 2018/02/01 03:29:41 christos Exp $ NOMAN= # defined @@ -13,11 +13,14 @@ DIST=${TOP}/src/${PROG} SRCS= smtpd.c smtpd_token.c smtpd_check.c smtpd_chat.c smtpd_state.c \ smtpd_peer.c smtpd_sasl_proto.c smtpd_sasl_glue.c smtpd_proxy.c \ smtpd_xforward.c smtpd_dsn_fix.c smtpd_milter.c smtpd_resolve.c \ - smtpd_expand.c smtpd_haproxy.c + smtpd_expand.c smtpd_haproxy.c pfilter.c DPADD+= ${LIBPMASTER} ${LIBPMILTER} ${LIBPGLOBAL} ${LIBPDNS} ${LIBPXSASL} LDADD+= ${LIBPMASTER} ${LIBPMILTER} ${LIBPGLOBAL} ${LIBPDNS} ${LIBPXSASL} +DPADD+= ${LIBBLACKLIST} +LDADD+= -lblacklist + DPADD+= ${LIBPTLS} ${LIBSSL} ${LIBCRYPTO} LDADD+= ${LIBPTLS} -lssl -lcrypto -- cgit