summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorEric Faurot <eric@cvs.openbsd.org>2011-03-29 20:43:52 +0000
committerEric Faurot <eric@cvs.openbsd.org>2011-03-29 20:43:52 +0000
commitd3e3f5e30aca1e3e97a151969adc42eed77f5ef4 (patch)
treec1348a0c6abd19ab6c2d6866039f55f2904534e5 /usr.sbin
parent768a148e6177a9e5863caebc5574bfd7b72e8382 (diff)
remove unused code now that reverse lookups are done through asr.
ok gilles@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/smtpd/dns.c115
-rw-r--r--usr.sbin/smtpd/smtpd.h3
-rw-r--r--usr.sbin/smtpd/util.c72
3 files changed, 44 insertions, 146 deletions
diff --git a/usr.sbin/smtpd/dns.c b/usr.sbin/smtpd/dns.c
index d86a02a0c74..f5079c73ab1 100644
--- a/usr.sbin/smtpd/dns.c
+++ b/usr.sbin/smtpd/dns.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dns.c,v 1.36 2011/03/29 08:14:12 eric Exp $ */
+/* $OpenBSD: dns.c,v 1.37 2011/03/29 20:43:51 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -172,9 +172,9 @@ dns_asr_handler(int fd, short event, void *arg)
struct header h;
struct query q;
struct rr rr;
+ struct mx mx;
struct asr_result ar;
char *p;
- int cnt;
int ret;
if (dnssession->query.type == IMSG_DNS_PTR) {
@@ -218,99 +218,68 @@ dns_asr_handler(int fd, short event, void *arg)
return;
}
+ /* MX */
packed_init(&pack, ar.ar_data, ar.ar_datalen);
if (unpack_header(&pack, &h) < 0 || unpack_query(&pack, &q) < 0)
goto err;
if (h.ancount == 0) {
- if (query->type == IMSG_DNS_MX) {
- /* we were looking for MX and got no answer,
- * fallback to host.
- */
- query->type = IMSG_DNS_HOST;
- dnssession->aq = asr_query_host(asr, query->host,
- AF_UNSPEC);
- if (dnssession->aq == NULL)
- goto err;
- dns_asr_handler(-1, -1, dnssession);
- return;
- }
- query->error = EAI_NONAME;
- goto err;
+ /* we were looking for MX and got no answer,
+ * fallback to host.
+ */
+ query->type = IMSG_DNS_HOST;
+ dnssession->aq = asr_query_host(asr, query->host,
+ AF_UNSPEC);
+ if (dnssession->aq == NULL)
+ goto err;
+ dns_asr_handler(-1, -1, dnssession);
+ return;
}
- if (query->type == IMSG_DNS_PTR) {
- if (h.ancount > 1) {
- log_debug("dns_asr_handler: PTR query returned several answers.");
- log_debug("dns_asr_handler: keeping only first result.");
- }
+ for (; h.ancount; h.ancount--) {
if (unpack_rr(&pack, &rr) < 0)
goto err;
- print_dname(rr.rr.ptr.ptrname, query->host, sizeof (query->host));
- if ((p = strrchr(query->host, '.')) != NULL)
+ print_dname(rr.rr.mx.exchange, mx.host, sizeof (mx.host));
+ if ((p = strrchr(mx.host, '.')) != NULL)
*p = '\0';
- free(ar.ar_data);
-
- query->error = 0;
- imsg_compose_event(query->asker, IMSG_DNS_PTR, 0, 0, -1, query,
- sizeof(*query));
- dnssession_destroy(env, dnssession);
- return;
- }
+ mx.prio = rr.rr.mx.preference;
- if (query->type == IMSG_DNS_MX) {
- struct mx mx;
-
- cnt = h.ancount;
- for (; cnt; cnt--) {
- if (unpack_rr(&pack, &rr) < 0)
- goto err;
-
- print_dname(rr.rr.mx.exchange, mx.host, sizeof (mx.host));
- if ((p = strrchr(mx.host, '.')) != NULL)
- *p = '\0';
- mx.prio = rr.rr.mx.preference;
-
- /* sorted insert that will not overflow MAX_MX_COUNT */
- dnssession_mx_insert(dnssession, &mx);
- }
- free(ar.ar_data);
- ar.ar_data = NULL;
-
- /* The T_MX scenario is a bit trickier than T_PTR and T_A lookups.
- * Rather than forwarding the answers to the process that queried,
- * we retrieve a set of MX hosts ... that need to be resolved. The
- * loop above sorts them by priority, all we have left to do is to
- * perform T_A lookups on all of them sequentially and provide the
- * process that queried with the answers.
- *
- * To make it easier, we do this in another handler.
- *
- * -- gilles@
- */
- dnssession->mxfound = 0;
- dnssession->mxcurrent = 0;
- dnssession->aq = asr_query_host(asr,
- dnssession->mxarray[dnssession->mxcurrent].host, AF_UNSPEC);
- if (dnssession->aq == NULL)
- goto err;
-
- dns_asr_mx_handler(-1, -1, dnssession);
- return;
+ /* sorted insert that will not overflow MAX_MX_COUNT */
+ dnssession_mx_insert(dnssession, &mx);
}
+ free(ar.ar_data);
+ ar.ar_data = NULL;
+
+ /* The T_MX scenario is a bit tricky.
+ * Rather than forwarding the answers to the process that queried,
+ * we retrieve a set of MX hosts ... that need to be resolved. The
+ * loop above sorts them by priority, all we have left to do is to
+ * perform T_A lookups on all of them sequentially and provide the
+ * process that queried with the answers.
+ *
+ * To make it easier, we do this in another handler.
+ *
+ * -- gilles@
+ */
+ dnssession->mxfound = 0;
+ dnssession->mxcurrent = 0;
+ dnssession->aq = asr_query_host(asr,
+ dnssession->mxarray[dnssession->mxcurrent].host, AF_UNSPEC);
+ if (dnssession->aq == NULL)
+ goto err;
+
+ dns_asr_mx_handler(-1, -1, dnssession);
return;
err:
free(ar.ar_data);
- if (query->type != IMSG_DNS_PTR)
- query->type = IMSG_DNS_HOST_END;
+ query->type = IMSG_DNS_HOST_END;
imsg_compose_event(query->asker, query->type, 0, 0, -1, query,
sizeof(*query));
dnssession_destroy(env, dnssession);
}
-
/* only handle MX requests */
void
dns_asr_mx_handler(int fd, short event, void *arg)
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index 453904f1139..f2c037dda77 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.205 2011/03/26 21:41:31 eric Exp $ */
+/* $OpenBSD: smtpd.h,v 1.206 2011/03/29 20:43:51 eric Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -1096,7 +1096,6 @@ int recipient_to_path(struct path *, char *);
int valid_localpart(char *);
int valid_domainpart(char *);
char *ss_to_text(struct sockaddr_storage *);
-char *ss_to_ptr(struct sockaddr_storage *);
int valid_message_id(char *);
int valid_message_uid(char *);
char *time_to_text(time_t);
diff --git a/usr.sbin/smtpd/util.c b/usr.sbin/smtpd/util.c
index d18b734da6c..db841e2754c 100644
--- a/usr.sbin/smtpd/util.c
+++ b/usr.sbin/smtpd/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.39 2011/03/03 08:09:14 gilles Exp $ */
+/* $OpenBSD: util.c,v 1.40 2011/03/29 20:43:51 eric Exp $ */
/*
* Copyright (c) 2000,2001 Markus Friedl. All rights reserved.
@@ -221,76 +221,6 @@ ss_to_text(struct sockaddr_storage *ss)
return (buf);
}
-char *
-ss_to_ptr(struct sockaddr_storage *ss)
-{
- static char buffer[1024];
-
- /* we need to construct a PTR query */
- switch (ss->ss_family) {
- case AF_INET: {
- in_addr_t addr;
-
- addr = ((struct sockaddr_in *)ss)->sin_addr.s_addr;
- addr = ntohl(addr);
- bsnprintf(buffer, sizeof (buffer),
- "%d.%d.%d.%d.in-addr.arpa",
- addr & 0xff,
- (addr >> 8) & 0xff,
- (addr >> 16) & 0xff,
- (addr >> 24) & 0xff);
- break;
- }
- case AF_INET6: {
- struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)ss;
- struct in6_addr *in6_addr;
-
- in6_addr = &in6->sin6_addr;
- bsnprintf(buffer, sizeof (buffer),
- "%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d."
- "%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d.%d."
- "ip6.arpa",
- in6_addr->s6_addr[15] & 0xf,
- (in6_addr->s6_addr[15] >> 4) & 0xf,
- in6_addr->s6_addr[14] & 0xf,
- (in6_addr->s6_addr[14] >> 4) & 0xf,
- in6_addr->s6_addr[13] & 0xf,
- (in6_addr->s6_addr[13] >> 4) & 0xf,
- in6_addr->s6_addr[12] & 0xf,
- (in6_addr->s6_addr[12] >> 4) & 0xf,
- in6_addr->s6_addr[11] & 0xf,
- (in6_addr->s6_addr[11] >> 4) & 0xf,
- in6_addr->s6_addr[10] & 0xf,
- (in6_addr->s6_addr[10] >> 4) & 0xf,
- in6_addr->s6_addr[9] & 0xf,
- (in6_addr->s6_addr[9] >> 4) & 0xf,
- in6_addr->s6_addr[8] & 0xf,
- (in6_addr->s6_addr[8] >> 4) & 0xf,
- in6_addr->s6_addr[7] & 0xf,
- (in6_addr->s6_addr[7] >> 4) & 0xf,
- in6_addr->s6_addr[6] & 0xf,
- (in6_addr->s6_addr[6] >> 4) & 0xf,
- in6_addr->s6_addr[5] & 0xf,
- (in6_addr->s6_addr[5] >> 4) & 0xf,
- in6_addr->s6_addr[4] & 0xf,
- (in6_addr->s6_addr[4] >> 4) & 0xf,
- in6_addr->s6_addr[3] & 0xf,
- (in6_addr->s6_addr[3] >> 4) & 0xf,
- in6_addr->s6_addr[2] & 0xf,
- (in6_addr->s6_addr[2] >> 4) & 0xf,
- in6_addr->s6_addr[1] & 0xf,
- (in6_addr->s6_addr[1] >> 4) & 0xf,
- in6_addr->s6_addr[0] & 0xf,
- (in6_addr->s6_addr[0] >> 4) & 0xf);
- break;
- }
- default:
- fatalx("dns_query_ptr");
- }
-
- return buffer;
-}
-
int
valid_message_id(char *mid)
{