summaryrefslogtreecommitdiff
path: root/contrib/bind9/lib/bind/resolv
diff options
context:
space:
mode:
authorDoug Barton <dougb@FreeBSD.org>2006-01-14 10:13:50 +0000
committerDoug Barton <dougb@FreeBSD.org>2006-01-14 10:13:50 +0000
commit41ecb87b06112f5c5ec1c81deb735501a6e8133e (patch)
tree11bb34523fd3b455d9fe361e25c35b83173e7000 /contrib/bind9/lib/bind/resolv
parent958288d0218912ac8c29b001f2992a68ae2180c6 (diff)
Notes
Diffstat (limited to 'contrib/bind9/lib/bind/resolv')
-rw-r--r--contrib/bind9/lib/bind/resolv/Makefile.in8
-rw-r--r--contrib/bind9/lib/bind/resolv/res_comp.c14
-rw-r--r--contrib/bind9/lib/bind/resolv/res_debug.c16
-rw-r--r--contrib/bind9/lib/bind/resolv/res_findzonecut.c6
-rw-r--r--contrib/bind9/lib/bind/resolv/res_init.c69
-rw-r--r--contrib/bind9/lib/bind/resolv/res_mkupdate.c11
-rw-r--r--contrib/bind9/lib/bind/resolv/res_send.c46
-rw-r--r--contrib/bind9/lib/bind/resolv/res_sendsigned.c12
8 files changed, 146 insertions, 36 deletions
diff --git a/contrib/bind9/lib/bind/resolv/Makefile.in b/contrib/bind9/lib/bind/resolv/Makefile.in
index 74a20e74fe3c..a235fbc7a5e3 100644
--- a/contrib/bind9/lib/bind/resolv/Makefile.in
+++ b/contrib/bind9/lib/bind/resolv/Makefile.in
@@ -1,4 +1,4 @@
-# Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
+# Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
# Copyright (C) 2001 Internet Software Consortium.
#
# Permission to use, copy, modify, and distribute this software for any
@@ -13,16 +13,16 @@
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
-# $Id: Makefile.in,v 1.3.206.1 2004/03/15 01:02:54 marka Exp $
+# $Id: Makefile.in,v 1.3.206.3 2005/07/29 00:13:09 marka Exp $
srcdir= @srcdir@
VPATH = @srcdir@
-OBJS= herror.@O@ res_comp.@O@ res_data.@O@ res_debug.@O@ \
+OBJS= herror.@O@ mtctxres.@O@ res_comp.@O@ res_data.@O@ res_debug.@O@ \
res_findzonecut.@O@ res_init.@O@ res_mkquery.@O@ res_mkupdate.@O@ \
res_query.@O@ res_send.@O@ res_sendsigned.@O@ res_update.@O@
-SRCS= herror.c res_comp.c res_data.c res_debug.c \
+SRCS= herror.c mtctxres.c res_comp.c res_data.c res_debug.c \
res_findzonecut.c res_init.c res_mkquery.c res_mkupdate.c \
res_query.c res_send.c res_sendsigned.c res_update.c
diff --git a/contrib/bind9/lib/bind/resolv/res_comp.c b/contrib/bind9/lib/bind/resolv/res_comp.c
index 6468dbc22183..8cc99a762884 100644
--- a/contrib/bind9/lib/bind/resolv/res_comp.c
+++ b/contrib/bind9/lib/bind/resolv/res_comp.c
@@ -70,7 +70,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_comp.c 8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_comp.c,v 1.1.2.1.4.1 2004/03/09 08:33:54 marka Exp $";
+static const char rcsid[] = "$Id: res_comp.c,v 1.1.2.1.4.2 2005/07/28 07:43:22 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
@@ -242,6 +242,18 @@ res_dnok(const char *dn) {
* __getshort
* Note that one _ comes from C and the others come from us.
*/
+
+#ifdef SOLARIS2
+#ifdef __putlong
+#undef __putlong
+#endif
+#ifdef __putshort
+#undef __putshort
+#endif
+#pragma weak putlong = __putlong
+#pragma weak putshort = __putshort
+#endif /* SOLARIS2 */
+
void __putlong(u_int32_t src, u_char *dst) { ns_put32(src, dst); }
void __putshort(u_int16_t src, u_char *dst) { ns_put16(src, dst); }
#ifndef __ultrix__
diff --git a/contrib/bind9/lib/bind/resolv/res_debug.c b/contrib/bind9/lib/bind/resolv/res_debug.c
index 1e228be5e62b..8dda12c5e81c 100644
--- a/contrib/bind9/lib/bind/resolv/res_debug.c
+++ b/contrib/bind9/lib/bind/resolv/res_debug.c
@@ -95,7 +95,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_debug.c,v 1.3.2.5.4.5 2004/07/28 20:16:46 marka Exp $";
+static const char rcsid[] = "$Id: res_debug.c,v 1.3.2.5.4.6 2005/07/28 07:43:22 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
@@ -113,6 +113,7 @@ static const char rcsid[] = "$Id: res_debug.c,v 1.3.2.5.4.5 2004/07/28 20:16:46
#include <math.h>
#include <netdb.h>
#include <resolv.h>
+#include <resolv_mt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -504,7 +505,7 @@ sym_ston(const struct res_sym *syms, const char *name, int *success) {
const char *
sym_ntos(const struct res_sym *syms, int number, int *success) {
- static char unname[20];
+ char *unname = sym_ntos_unname;
for ((void)NULL; syms->name != 0; syms++) {
if (number == syms->number) {
@@ -522,7 +523,7 @@ sym_ntos(const struct res_sym *syms, int number, int *success) {
const char *
sym_ntop(const struct res_sym *syms, int number, int *success) {
- static char unname[20];
+ char *unname = sym_ntop_unname;
for ((void)NULL; syms->name != 0; syms++) {
if (number == syms->number) {
@@ -596,7 +597,7 @@ p_class(int class) {
*/
const char *
p_option(u_long option) {
- static char nbuf[40];
+ char *nbuf = p_option_nbuf;
switch (option) {
case RES_INIT: return "init";
@@ -639,7 +640,7 @@ p_option(u_long option) {
*/
const char *
p_time(u_int32_t value) {
- static char nbuf[40]; /* XXX nonreentrant */
+ char *nbuf = p_time_nbuf;
if (ns_format_ttl(value, nbuf, sizeof nbuf) < 0)
sprintf(nbuf, "%u", value);
@@ -695,7 +696,7 @@ static const char *
precsize_ntoa(prec)
u_int8_t prec;
{
- static char retbuf[sizeof "90000000.00"]; /* XXX nonreentrant */
+ char *retbuf = precsize_ntoa_retbuf;
unsigned long val;
int mantissa, exponent;
@@ -1097,8 +1098,7 @@ dn_count_labels(const char *name) {
*/
char *
p_secstodate (u_long secs) {
- /* XXX nonreentrant */
- static char output[15]; /* YYYYMMDDHHMMSS and null */
+ char *output = p_secstodate_output;
time_t clock = secs;
struct tm *time;
#ifdef HAVE_TIME_R
diff --git a/contrib/bind9/lib/bind/resolv/res_findzonecut.c b/contrib/bind9/lib/bind/resolv/res_findzonecut.c
index 154babde22b5..804beb647464 100644
--- a/contrib/bind9/lib/bind/resolv/res_findzonecut.c
+++ b/contrib/bind9/lib/bind/resolv/res_findzonecut.c
@@ -1,5 +1,5 @@
#if !defined(lint) && !defined(SABER)
-static const char rcsid[] = "$Id: res_findzonecut.c,v 1.2.2.3.4.3 2004/09/16 07:06:11 marka Exp $";
+static const char rcsid[] = "$Id: res_findzonecut.c,v 1.2.2.3.4.4 2005/10/11 00:48:16 marka Exp $";
#endif /* not lint */
/*
@@ -319,7 +319,6 @@ get_soa(res_state statp, const char *dname, ns_class class, int opts,
for (i = 0; i < n; i++) {
const char *t;
const u_char *rdata;
- int rdlen;
ns_rr rr;
if (ns_parserr(&msg, sect, i, &rr) < 0) {
@@ -368,7 +367,6 @@ get_soa(res_state statp, const char *dname, ns_class class, int opts,
}
strcpy(zname, t);
rdata = ns_rr_rdata(rr);
- rdlen = ns_rr_rdlen(rr);
if (ns_name_uncompress(resp, ns_msg_end(msg), rdata,
mname, msize) < 0) {
DPRINTF(("get_soa: ns_name_uncompress failed")
@@ -526,7 +524,6 @@ save_ns(res_state statp, ns_msg *msg, ns_sect sect,
const u_char *rdata;
rr_ns *nsrr;
ns_rr rr;
- int rdlen;
if (ns_parserr(msg, sect, i, &rr) < 0) {
DPRINTF(("save_ns: ns_parserr(%s, %d) failed",
@@ -545,7 +542,6 @@ save_ns(res_state statp, ns_msg *msg, ns_sect sect,
return (-1);
}
rdata = ns_rr_rdata(rr);
- rdlen = ns_rr_rdlen(rr);
if (ns_name_uncompress(ns_msg_base(*msg),
ns_msg_end(*msg), rdata,
tname, sizeof tname) < 0) {
diff --git a/contrib/bind9/lib/bind/resolv/res_init.c b/contrib/bind9/lib/bind/resolv/res_init.c
index 241f5f7cbf3f..28a3ebd088e9 100644
--- a/contrib/bind9/lib/bind/resolv/res_init.c
+++ b/contrib/bind9/lib/bind/resolv/res_init.c
@@ -70,7 +70,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93";
-static const char rcsid[] = "$Id: res_init.c,v 1.9.2.5.4.2 2004/03/16 12:34:18 marka Exp $";
+static const char rcsid[] = "$Id: res_init.c,v 1.9.2.5.4.5 2005/11/03 00:00:52 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include "port_before.h"
@@ -102,6 +102,10 @@ static const char rcsid[] = "$Id: res_init.c,v 1.9.2.5.4.2 2004/03/16 12:34:18 m
#define RESOLVSORT
#define DEBUG
+#ifdef SOLARIS2
+#include <sys/systeminfo.h>
+#endif
+
static void res_setoptions __P((res_state, const char *, const char *));
#ifdef RESOLVSORT
@@ -163,6 +167,9 @@ __res_vinit(res_state statp, int preinit) {
int dots;
union res_sockaddr_union u[2];
+ if (statp->_u._ext.ext != NULL)
+ res_ndestroy(statp);
+
if (!preinit) {
statp->retrans = RES_TIMEOUT;
statp->retry = RES_DFLRETRY;
@@ -170,9 +177,6 @@ __res_vinit(res_state statp, int preinit) {
statp->id = res_randomid();
}
- if ((statp->options & RES_INIT) != 0U)
- res_ndestroy(statp);
-
memset(u, 0, sizeof(u));
#ifdef USELOOPBACK
u[nserv].sin.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1);
@@ -212,12 +216,42 @@ __res_vinit(res_state statp, int preinit) {
statp->_u._ext.ext->nsaddrs[0].sin = statp->nsaddr;
strcpy(statp->_u._ext.ext->nsuffix, "ip6.arpa");
strcpy(statp->_u._ext.ext->nsuffix2, "ip6.int");
- }
+ } else
+ return (-1);
#ifdef RESOLVSORT
statp->nsort = 0;
#endif
res_setservers(statp, u, nserv);
+#ifdef SOLARIS2
+ /*
+ * The old libresolv derived the defaultdomain from NIS/NIS+.
+ * We want to keep this behaviour
+ */
+ {
+ char buf[sizeof(statp->defdname)], *cp;
+ int ret;
+
+ if ((ret = sysinfo(SI_SRPC_DOMAIN, buf, sizeof(buf))) > 0 &&
+ (unsigned int)ret <= sizeof(buf)) {
+ if (buf[0] == '+')
+ buf[0] = '.';
+ cp = strchr(buf, '.');
+ if (cp == NULL) {
+ if (strlcpy(statp->defdname, buf,
+ sizeof(statp->defdname))
+ >= sizeof(statp->defdname))
+ goto freedata;
+ } else {
+ if (strlcpy(statp->defdname, cp+1,
+ sizeof(statp->defdname))
+ >= sizeof(statp->defdname))
+ goto freedata;
+ }
+ }
+ }
+#endif /* SOLARIS2 */
+
/* Allow user to override the local domain definition */
if ((cp = getenv("LOCALDOMAIN")) != NULL) {
(void)strncpy(statp->defdname, cp, sizeof(statp->defdname) - 1);
@@ -456,6 +490,15 @@ __res_vinit(res_state statp, int preinit) {
res_setoptions(statp, cp, "env");
statp->options |= RES_INIT;
return (0);
+
+#ifdef SOLARIS2
+ freedata:
+ if (statp->_u._ext.ext != NULL) {
+ free(statp->_u._ext.ext);
+ statp->_u._ext.ext = NULL;
+ }
+ return (-1);
+#endif
}
static void
@@ -495,6 +538,22 @@ res_setoptions(res_state statp, const char *options, const char *source)
if (statp->options & RES_DEBUG)
printf(";;\ttimeout=%d\n", statp->retrans);
#endif
+#ifdef SOLARIS2
+ } else if (!strncmp(cp, "retrans:", sizeof("retrans:") - 1)) {
+ /*
+ * For backward compatibility, 'retrans' is
+ * supported as an alias for 'timeout', though
+ * without an imposed maximum.
+ */
+ statp->retrans = atoi(cp + sizeof("retrans:") - 1);
+ } else if (!strncmp(cp, "retry:", sizeof("retry:") - 1)){
+ /*
+ * For backward compatibility, 'retry' is
+ * supported as an alias for 'attempts', though
+ * without an imposed maximum.
+ */
+ statp->retry = atoi(cp + sizeof("retry:") - 1);
+#endif /* SOLARIS2 */
} else if (!strncmp(cp, "attempts:", sizeof("attempts:") - 1)){
i = atoi(cp + sizeof("attempts:") - 1);
if (i <= RES_MAXRETRY)
diff --git a/contrib/bind9/lib/bind/resolv/res_mkupdate.c b/contrib/bind9/lib/bind/resolv/res_mkupdate.c
index aac95e5907ef..01078f1a51a6 100644
--- a/contrib/bind9/lib/bind/resolv/res_mkupdate.c
+++ b/contrib/bind9/lib/bind/resolv/res_mkupdate.c
@@ -21,7 +21,7 @@
*/
#if !defined(lint) && !defined(SABER)
-static const char rcsid[] = "$Id: res_mkupdate.c,v 1.1.2.1.4.3 2004/06/03 04:44:48 marka Exp $";
+static const char rcsid[] = "$Id: res_mkupdate.c,v 1.1.2.1.4.5 2005/10/14 05:43:47 marka Exp $";
#endif /* not lint */
#include "port_before.h"
@@ -78,7 +78,7 @@ int
res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) {
ns_updrec *rrecp_start = rrecp_in;
HEADER *hp;
- u_char *cp, *sp1, *sp2, *startp, *endp;
+ u_char *cp, *sp2, *startp, *endp;
int n, i, soanum, multiline;
ns_updrec *rrecp;
struct in_addr ina;
@@ -101,7 +101,6 @@ res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) {
hp->id = htons(++statp->id);
hp->opcode = ns_o_update;
hp->rcode = NOERROR;
- sp1 = buf + 2*INT16SZ; /* save pointer to zocount */
cp = buf + HFIXEDSZ;
buflen -= HFIXEDSZ;
dpp = dnptrs;
@@ -922,10 +921,10 @@ res_mkupdrec(int section, const char *dname,
}
INIT_LINK(rrecp, r_link);
INIT_LINK(rrecp, r_glink);
- rrecp->r_class = class;
- rrecp->r_type = type;
+ rrecp->r_class = (ns_class)class;
+ rrecp->r_type = (ns_type)type;
rrecp->r_ttl = ttl;
- rrecp->r_section = section;
+ rrecp->r_section = (ns_sect)section;
return (rrecp);
}
diff --git a/contrib/bind9/lib/bind/resolv/res_send.c b/contrib/bind9/lib/bind/resolv/res_send.c
index 81c24258920f..5be248932596 100644
--- a/contrib/bind9/lib/bind/resolv/res_send.c
+++ b/contrib/bind9/lib/bind/resolv/res_send.c
@@ -52,7 +52,7 @@
*/
/*
- * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2005 by Internet Systems Consortium, Inc. ("ISC")
* Portions Copyright (c) 1996-1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
@@ -70,7 +70,7 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_send.c,v 1.5.2.2.4.5 2004/08/10 02:19:56 marka Exp $";
+static const char rcsid[] = "$Id: res_send.c,v 1.5.2.2.4.7 2005/08/15 02:04:41 marka Exp $";
#endif /* LIBC_SCCS and not lint */
/*
@@ -103,6 +103,13 @@ static const char rcsid[] = "$Id: res_send.c,v 1.5.2.2.4.5 2004/08/10 02:19:56 m
#include "port_after.h"
+#ifdef USE_POLL
+#ifdef HAVE_STROPTS_H
+#include <stropts.h>
+#endif
+#include <poll.h>
+#endif /* USE_POLL */
+
/* Options. Leave them on. */
#define DEBUG
#include "res_debug.h"
@@ -110,7 +117,11 @@ static const char rcsid[] = "$Id: res_send.c,v 1.5.2.2.4.5 2004/08/10 02:19:56 m
#define EXT(res) ((res)->_u._ext)
+#ifndef USE_POLL
static const int highestFD = FD_SETSIZE - 1;
+#else
+static int highestFD = 0;
+#endif
/* Forward. */
@@ -125,7 +136,7 @@ static void Aerror(const res_state, FILE *, const char *, int,
const struct sockaddr *, int);
static void Perror(const res_state, FILE *, const char *, int);
static int sock_eq(struct sockaddr *, struct sockaddr *);
-#ifdef NEED_PSELECT
+#if defined(NEED_PSELECT) && !defined(USE_POLL)
static int pselect(int, void *, void *, void *,
struct timespec *,
const sigset_t *);
@@ -280,6 +291,10 @@ res_nsend(res_state statp,
int gotsomewhere, terrno, try, v_circuit, resplen, ns, n;
char abuf[NI_MAXHOST];
+#ifdef USE_POLL
+ highestFD = sysconf(_SC_OPEN_MAX) - 1;
+#endif
+
if (statp->nscount == 0) {
errno = ESRCH;
return (-1);
@@ -760,10 +775,15 @@ send_dg(res_state statp,
const struct sockaddr *nsap;
int nsaplen;
struct timespec now, timeout, finish;
- fd_set dsmask;
struct sockaddr_storage from;
ISC_SOCKLEN_T fromlen;
int resplen, seconds, n, s;
+#ifdef USE_POLL
+ int polltimeout;
+ struct pollfd pollfd;
+#else
+ fd_set dsmask;
+#endif
nsap = get_nsaddr(statp, ns);
nsaplen = get_salen(nsap);
@@ -841,6 +861,7 @@ send_dg(res_state statp,
wait:
now = evNowTime();
nonow:
+#ifndef USE_POLL
FD_ZERO(&dsmask);
FD_SET(s, &dsmask);
if (evCmpTime(finish, now) > 0)
@@ -848,6 +869,17 @@ send_dg(res_state statp,
else
timeout = evConsTime(0, 0);
n = pselect(s + 1, &dsmask, NULL, NULL, &timeout, NULL);
+#else
+ timeout = evSubTime(finish, now);
+ if (timeout.tv_sec < 0)
+ timeout = evConsTime(0, 0);
+ polltimeout = 1000*timeout.tv_sec +
+ timeout.tv_nsec/1000000;
+ pollfd.fd = s;
+ pollfd.events = POLLRDNORM;
+ n = poll(&pollfd, 1, polltimeout);
+#endif /* USE_POLL */
+
if (n == 0) {
Dprint(statp->options & RES_DEBUG, (stdout, ";; timeout\n"));
*gotsomewhere = 1;
@@ -856,7 +888,11 @@ send_dg(res_state statp,
if (n < 0) {
if (errno == EINTR)
goto wait;
+#ifndef USE_POLL
Perror(statp, stderr, "select", errno);
+#else
+ Perror(statp, stderr, "poll", errno);
+#endif /* USE_POLL */
res_nclose(statp);
return (0);
}
@@ -1025,7 +1061,7 @@ sock_eq(struct sockaddr *a, struct sockaddr *b) {
}
}
-#ifdef NEED_PSELECT
+#if defined(NEED_PSELECT) && !defined(USE_POLL)
/* XXX needs to move to the porting library. */
static int
pselect(int nfds, void *rfds, void *wfds, void *efds,
diff --git a/contrib/bind9/lib/bind/resolv/res_sendsigned.c b/contrib/bind9/lib/bind/resolv/res_sendsigned.c
index 1984377ab124..d1d227457566 100644
--- a/contrib/bind9/lib/bind/resolv/res_sendsigned.c
+++ b/contrib/bind9/lib/bind/resolv/res_sendsigned.c
@@ -122,8 +122,16 @@ retry:
(stdout, "%s", ""),
answer, (anslen > len) ? len : anslen);
- Dprint(statp->pfcode & RES_PRF_REPLY,
- (stdout, ";; TSIG invalid (%s)\n", p_rcode(ret)));
+ if (ret > 0) {
+ Dprint(statp->pfcode & RES_PRF_REPLY,
+ (stdout, ";; server rejected TSIG (%s)\n",
+ p_rcode(ret)));
+ } else {
+ Dprint(statp->pfcode & RES_PRF_REPLY,
+ (stdout, ";; TSIG invalid (%s)\n",
+ p_rcode(-ret)));
+ }
+
free (nstatp);
free (newmsg);
dst_free_key(dstkey);