commit 09816288b5a67c9634654778c4daa4eaba330116 from: Martijn van Duren date: Thu Aug 22 08:15:35 2019 UTC Make need a single-parameter function commit - 4c34777d2e8ec7fe0fac9bf056f7d43c77335605 commit + 09816288b5a67c9634654778c4daa4eaba330116 blob - ece7d37a4bbabfcfb5ba830b198e87a30f45be3e blob + 987c4fa26dde288291979cc7eab9f7fc4ab53f63 --- opensmtpd.c +++ opensmtpd.c @@ -96,7 +96,6 @@ static int osmtpd_session_cmp(struct osmtpd_session *, static void *(*oncreatecb)(struct osmtpd_ctx *) = NULL; static void (*ondeletecb)(struct osmtpd_ctx *, void *) = NULL; - static struct osmtpd_callback osmtpd_callbacks[] = { { OSMTPD_TYPE_FILTER, @@ -506,6 +505,7 @@ static struct osmtpd_callback osmtpd_callbacks[] = { }; static struct io *io_stdout; +static int needs; static int ready = 0; /* Default from smtpd */ static int session_timeout = 300; @@ -805,10 +805,16 @@ osmtpd_localdata(void *(*oncreate)(struct osmtpd_ctx * } void -osmtpd_need(int incoming, int needs) +osmtpd_need(int lneeds) { + needs |= lneeds; +} + +static void +osmtpd_register_need(int incoming) +{ if (needs & (OSMTPD_NEED_SRC | OSMTPD_NEED_DST | OSMTPD_NEED_RDNS | - OSMTPD_NEED_FRDNS)) + OSMTPD_NEED_FCRDNS)) osmtpd_register(OSMTPD_TYPE_FILTER, OSMTPD_PHASE_LINK_CONNECT, incoming, 1, NULL); if (needs & OSMTPD_NEED_IDENTITY) @@ -877,6 +883,10 @@ osmtpd_run(void) io_set_write(io_stdout); for (i = 0; i < NITEMS(osmtpd_callbacks); i++) { + if (osmtpd_callbacks[i].doregister) + osmtpd_register_need(osmtpd_callbacks[i].incoming); + } + for (i = 0; i < NITEMS(osmtpd_callbacks); i++) { if (osmtpd_callbacks[i].doregister) { if (osmtpd_callbacks[i].cb != NULL) registered = 1; blob - b62c247303e5ceef945633360f7c1d12fc247189 blob + c8a65bc02bddd5c5a622a14548d60f190ab90df0 --- opensmtpd.h +++ opensmtpd.h @@ -140,7 +140,7 @@ void osmtpd_register_report_response(int, void (*)(str void osmtpd_register_report_timeout(int, void (*)(struct osmtpd_ctx *)); void osmtpd_localdata(void *(*)(struct osmtpd_ctx *), void (*)(struct osmtpd_ctx *, void *)); -void osmtpd_need(int, int); +void osmtpd_need(int); void osmtpd_filter_proceed(struct osmtpd_ctx *); void osmtpd_filter_reject(struct osmtpd_ctx *, int, const char *, ...)