diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2018-12-09 17:37:16 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2018-12-09 17:37:16 +0000 |
commit | 1429d738385fce1e90018ea123bffe0650ab3a54 (patch) | |
tree | 8ec5df20aff948bace270a814b32d8aca3ec7847 /usr.sbin | |
parent | 79501c15c4def84b9eaa8589fa3abe6f3ae6daa1 (diff) |
no longer pass rdns in all filtering requests, they can be retrieved from
the filter session.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/smtpd/lka.c | 6 | ||||
-rw-r--r-- | usr.sbin/smtpd/lka_filter.c | 46 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtp_session.c | 3 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.h | 4 |
4 files changed, 30 insertions, 29 deletions
diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c index a06d07f9ad6..f8fc643bd2e 100644 --- a/usr.sbin/smtpd/lka.c +++ b/usr.sbin/smtpd/lka.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lka.c,v 1.220 2018/12/09 16:37:51 gilles Exp $ */ +/* $OpenBSD: lka.c,v 1.221 2018/12/09 17:37:15 gilles Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -86,7 +86,6 @@ lka_imsg(struct mproc *p, struct imsg *imsg) const char *rdns; const char *command, *response; const char *ciphers; - const char *hostname; const char *address; struct sockaddr_storage ss_src, ss_dest; int filter_phase; @@ -660,11 +659,10 @@ lka_imsg(struct mproc *p, struct imsg *imsg) m_msg(&m, imsg); m_get_id(&m, &reqid); m_get_int(&m, &filter_phase); - m_get_string(&m, &hostname); m_get_string(&m, &filter_param); m_end(&m); - lka_filter_protocol(reqid, filter_phase, hostname, filter_param); + lka_filter_protocol(reqid, filter_phase, filter_param); return; case IMSG_SMTP_FILTER_BEGIN: diff --git a/usr.sbin/smtpd/lka_filter.c b/usr.sbin/smtpd/lka_filter.c index e4f9bf0e866..2015265a80b 100644 --- a/usr.sbin/smtpd/lka_filter.c +++ b/usr.sbin/smtpd/lka_filter.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lka_filter.c,v 1.9 2018/12/09 17:20:19 gilles Exp $ */ +/* $OpenBSD: lka_filter.c,v 1.10 2018/12/09 17:37:15 gilles Exp $ */ /* * Copyright (c) 2018 Gilles Chehade <gilles@poolp.org> @@ -42,14 +42,14 @@ static void filter_disconnect(uint64_t, const char *); static void filter_data(uint64_t reqid, const char *line); -static void filter_write(const char *, uint64_t, const char *, const char *, const char *); +static void filter_write(const char *, uint64_t, const char *, const char *); static void filter_write_dataline(const char *, uint64_t, const char *); -static int filter_exec_notimpl(uint64_t, struct filter_rule *, const char *, const char *); -static int filter_exec_connected(uint64_t, struct filter_rule *, const char *, const char *); -static int filter_exec_helo(uint64_t, struct filter_rule *, const char *, const char *); -static int filter_exec_mail_from(uint64_t, struct filter_rule *, const char *, const char *); -static int filter_exec_rcpt_to(uint64_t, struct filter_rule *, const char *, const char *); +static int filter_exec_notimpl(uint64_t, struct filter_rule *, const char *); +static int filter_exec_connected(uint64_t, struct filter_rule *, const char *); +static int filter_exec_helo(uint64_t, struct filter_rule *, const char *); +static int filter_exec_mail_from(uint64_t, struct filter_rule *, const char *); +static int filter_exec_rcpt_to(uint64_t, struct filter_rule *, const char *); static void filter_session_io(struct io *, int, void *); int lka_filter_process_response(const char *, const char *); @@ -60,7 +60,7 @@ static void filter_data_next(uint64_t, const char *, const char *); static struct filter_exec { enum filter_phase phase; const char *phase_name; - int (*func)(uint64_t, struct filter_rule *, const char *, const char *); + int (*func)(uint64_t, struct filter_rule *, const char *); } filter_execs[] = { { FILTER_AUTH, "auth", filter_exec_notimpl }, { FILTER_CONNECTED, "connected", filter_exec_connected }, @@ -241,7 +241,7 @@ lka_filter_process_response(const char *name, const char *line) } void -lka_filter_protocol(uint64_t reqid, enum filter_phase phase, const char *hostname, const char *param) +lka_filter_protocol(uint64_t reqid, enum filter_phase phase, const char *param) { struct filter_rule *rule; uint8_t i; @@ -255,11 +255,11 @@ lka_filter_protocol(uint64_t reqid, enum filter_phase phase, const char *hostnam TAILQ_FOREACH(rule, &env->sc_filter_rules[phase], entry) { if (rule->proc) { filter_write(rule->proc, reqid, - filter_execs[i].phase_name, hostname, param); + filter_execs[i].phase_name, param); return; /* deferred */ } - if (filter_execs[i].func(reqid, rule, hostname, param)) { + if (filter_execs[i].func(reqid, rule, param)) { if (rule->rewrite) filter_rewrite(reqid, rule->rewrite); else if (rule->disconnect) @@ -323,11 +323,13 @@ lka_filter_response(uint64_t reqid, const char *response, const char *param) } static void -filter_write(const char *name, uint64_t reqid, const char *phase, const char *hostname, const char *param) +filter_write(const char *name, uint64_t reqid, const char *phase, const char *param) { int n; time_t tm; + struct filter_session *fs; + fs = tree_xget(&sessions, reqid); time(&tm); if (strcmp(phase, "connected") == 0 || strcmp(phase, "helo") == 0 || @@ -336,7 +338,7 @@ filter_write(const char *name, uint64_t reqid, const char *phase, const char *ho "filter|%d|%zd|smtp-in|%s|%016"PRIx64"|%s|%s\n", PROTOCOL_VERSION, tm, - phase, reqid, hostname, param); + phase, reqid, fs->rdns, param); else n = io_printf(lka_proc_get_io(name), "filter|%d|%zd|smtp-in|%s|%016"PRIx64"|%s\n", @@ -463,37 +465,39 @@ filter_check_rdns_helo(struct filter_rule *rule, const char *hostname, const cha } static int -filter_exec_notimpl(uint64_t reqid, struct filter_rule *rule, const char *hostname, const char *param) +filter_exec_notimpl(uint64_t reqid, struct filter_rule *rule, const char *param) { return 0; } static int -filter_exec_connected(uint64_t reqid, struct filter_rule *rule, const char *hostname, const char *param) +filter_exec_connected(uint64_t reqid, struct filter_rule *rule, const char *param) { struct filter_session *fs; fs = tree_xget(&sessions, reqid); - if (filter_check_table(rule, K_NETADDR, param) || filter_check_regex(rule, param) || - filter_check_rdns_connected(rule, hostname)) + filter_check_rdns_connected(rule, fs->rdns)) return 1; return 0; } static int -filter_exec_helo(uint64_t reqid, struct filter_rule *rule, const char *hostname, const char *param) +filter_exec_helo(uint64_t reqid, struct filter_rule *rule, const char *param) { + struct filter_session *fs; + + fs = tree_xget(&sessions, reqid); if (filter_check_table(rule, K_DOMAIN, param) || filter_check_regex(rule, param) || - filter_check_rdns_helo(rule, hostname, param)) + filter_check_rdns_helo(rule, fs->rdns, param)) return 1; return 0; } static int -filter_exec_mail_from(uint64_t reqid, struct filter_rule *rule, const char *hostname, const char *param) +filter_exec_mail_from(uint64_t reqid, struct filter_rule *rule, const char *param) { char buffer[SMTPD_MAXMAILADDRSIZE]; @@ -508,7 +512,7 @@ filter_exec_mail_from(uint64_t reqid, struct filter_rule *rule, const char *host } static int -filter_exec_rcpt_to(uint64_t reqid, struct filter_rule *rule, const char *hostname, const char *param) +filter_exec_rcpt_to(uint64_t reqid, struct filter_rule *rule, const char *param) { char buffer[SMTPD_MAXMAILADDRSIZE]; diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c index 39bb4a03481..ac8b590a1ed 100644 --- a/usr.sbin/smtpd/smtp_session.c +++ b/usr.sbin/smtpd/smtp_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp_session.c,v 1.365 2018/12/09 17:08:52 gilles Exp $ */ +/* $OpenBSD: smtp_session.c,v 1.366 2018/12/09 17:37:15 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -1580,7 +1580,6 @@ smtp_query_filters(enum filter_phase phase, struct smtp_session *s, const char * m_create(p_lka, IMSG_SMTP_FILTER_PROTOCOL, 0, 0, -1); m_add_id(p_lka, s->id); m_add_int(p_lka, phase); - m_add_string(p_lka, s->hostname); m_add_string(p_lka, args); m_close(p_lka); tree_xset(&wait_filters, s->id, s); diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index 1c87484dfd3..38475ffb290 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.583 2018/12/09 16:37:51 gilles Exp $ */ +/* $OpenBSD: smtpd.h,v 1.584 2018/12/09 17:37:15 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -1346,7 +1346,7 @@ void lka_report_smtp_protocol_server(const char *, time_t, uint64_t, const char /* lka_filter.c */ void lka_filter_begin(uint64_t, const struct sockaddr_storage *, const struct sockaddr_storage *, const char *, int); void lka_filter_end(uint64_t); -void lka_filter_protocol(uint64_t, enum filter_phase, const char *, const char *); +void lka_filter_protocol(uint64_t, enum filter_phase, const char *); void lka_filter_data_begin(uint64_t); void lka_filter_data_end(uint64_t); int lka_filter_response(uint64_t, const char *, const char *); |