diff options
-rw-r--r-- | usr.sbin/smtpd/dns.c | 20 | ||||
-rw-r--r-- | usr.sbin/smtpd/lka.c | 11 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.h | 4 |
3 files changed, 26 insertions, 9 deletions
diff --git a/usr.sbin/smtpd/dns.c b/usr.sbin/smtpd/dns.c index d0a933b7d9e..05af9ae1ca0 100644 --- a/usr.sbin/smtpd/dns.c +++ b/usr.sbin/smtpd/dns.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dns.c,v 1.8 2009/02/15 09:58:31 jacekm Exp $ */ +/* $OpenBSD: dns.c,v 1.9 2009/02/15 13:12:19 jacekm Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -26,6 +26,7 @@ #include <arpa/nameser.h> #include <event.h> +#include <netdb.h> #include <resolv.h> #include <stdio.h> #include <stdlib.h> @@ -57,7 +58,7 @@ mxsort(struct mxrecord *array, size_t len) } } -size_t +int getmxbyname(char *name, char ***result) { union { @@ -80,8 +81,19 @@ getmxbyname(char *name, char ***result) ret = res_query(name, C_IN, T_MX, (u_int8_t *)&answer.bytes, sizeof answer); - if (ret == -1) - return 0; + if (ret == -1) { + switch (h_errno) { + case TRY_AGAIN: + return (EAI_AGAIN); + case NO_RECOVERY: + return (EAI_FAIL); + case HOST_NOT_FOUND: + return (EAI_NONAME); + case NO_DATA: + return (0); + } + fatal("getmxbyname: res_query"); + } /* sp stores start of dns packet, * endp stores end of dns packet, diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c index 85daaa577aa..b3701172ab2 100644 --- a/usr.sbin/smtpd/lka.c +++ b/usr.sbin/smtpd/lka.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lka.c,v 1.21 2009/02/15 10:32:23 jacekm Exp $ */ +/* $OpenBSD: lka.c,v 1.22 2009/02/15 13:12:19 jacekm Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -50,7 +50,6 @@ int lka_verify_mail(struct smtpd *, struct path *); int lka_resolve_mail(struct smtpd *, struct rule *, struct path *); int lka_resolve_rcpt(struct smtpd *, struct rule *, struct path *); int lka_forward_file(struct passwd *); -size_t getmxbyname(char *, char ***); int lka_expand(char *, size_t, struct path *); int aliases_exist(struct smtpd *, char *); int aliases_get(struct smtpd *, struct aliaseslist *, char *); @@ -424,7 +423,7 @@ lka_dispatch_runner(int sig, short event, void *p) struct addrinfo hints, *res, *resp; char **mx = NULL; char *lmx[1]; - size_t len, i, j; + int len, i, j; int error; u_int16_t port = htons(25); @@ -436,6 +435,12 @@ lka_dispatch_runner(int sig, short event, void *p) if (batchp->rule.r_action == A_RELAY) { log_debug("attempting to resolve %s", batchp->hostname); len = getmxbyname(batchp->hostname, &mx); + if (len < 0) { + batchp->getaddrinfo_error = len; + imsg_compose(ibuf, IMSG_LKA_MX, 0, 0, -1, + batchp, sizeof(*batchp)); + break; + } if (len == 0) { lmx[0] = batchp->hostname; mx = lmx; diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index 07e20c2468c..29f6754345a 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.70 2009/02/15 10:32:23 jacekm Exp $ */ +/* $OpenBSD: smtpd.h,v 1.71 2009/02/15 13:12:19 jacekm Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -741,7 +741,7 @@ int msgbuf_write(struct msgbuf *); /* dns.c */ -size_t getmxbyname(char *, char ***); +int getmxbyname(char *, char ***); /* forward.c */ |