summaryrefslogtreecommitdiffstats
path: root/contrib/bind
diff options
context:
space:
mode:
authorasmodai <asmodai@FreeBSD.org>2000-05-26 07:24:14 +0000
committerasmodai <asmodai@FreeBSD.org>2000-05-26 07:24:14 +0000
commitc49f469710fb9a3ac60881b71c7013fb4197bf45 (patch)
tree805b88494ed8300bbdb523cf7fcbc6d1df1df944 /contrib/bind
parent5ebe58808117d06535d3a3d3ad1de3245fd51505 (diff)
downloadFreeBSD-src-c49f469710fb9a3ac60881b71c7013fb4197bf45.zip
FreeBSD-src-c49f469710fb9a3ac60881b71c7013fb4197bf45.tar.gz
Resolve conflicts.
Diffstat (limited to 'contrib/bind')
-rw-r--r--contrib/bind/bin/named-xfer/named-xfer.c612
-rw-r--r--contrib/bind/bin/named/Makefile6
-rw-r--r--contrib/bind/bin/nslookup/commands.l6
-rw-r--r--contrib/bind/bin/nslookup/main.c4
-rw-r--r--contrib/bind/port/freebsd/include/port_after.h1
5 files changed, 437 insertions, 192 deletions
diff --git a/contrib/bind/bin/named-xfer/named-xfer.c b/contrib/bind/bin/named-xfer/named-xfer.c
index d7db886..dd70d7b 100644
--- a/contrib/bind/bin/named-xfer/named-xfer.c
+++ b/contrib/bind/bin/named-xfer/named-xfer.c
@@ -131,7 +131,7 @@ char copyright[] =
#if !defined(lint) && !defined(SABER)
static const char sccsid[] = "@(#)named-xfer.c 4.18 (Berkeley) 3/7/91";
-static const char rcsid[] = "$Id: named-xfer.c,v 8.89 1999/11/09 20:36:54 marka Exp $";
+static const char rcsid[] = "$Id: named-xfer.c,v 8.93 2000/04/20 07:33:47 vixie Exp $";
#endif /* not lint */
#include "port_before.h"
@@ -179,7 +179,7 @@ static const char rcsid[] = "$Id: named-xfer.c,v 8.89 1999/11/09 20:36:54 marka
#define MAX_XFER_RESTARTS 2
-#define ENABLE_IXFR 0
+#define ENABLE_IXFR 1
# ifdef SHORT_FNAMES
extern long pathconf __P((const char *path, int name)); /* XXX */
@@ -192,7 +192,7 @@ static char *ddtfilename = NULL,
*ddtfile = NULL;
static char *tmpname = NULL,
- *tmpiname = NULL, /* temporary file name for ixfr transaction file */
+ *tmpiname = NULL, /* temporary file name for ixfr transaction file */
*domain; /* domain being xfered */
static int quiet = 0,
@@ -210,12 +210,12 @@ static void usage(const char *),
tsig_init(const char *);
static int getzone(struct zoneinfo *, u_int32_t, int),
print_output(struct zoneinfo *, u_int32_t,
- u_char *, int, u_char *),
+ u_char *, int, u_char *, int),
netread(int, char *, int, int),
writemsg(int, const u_char *, int);
-static void ixfr_log(const u_char *msg, int len, int *delete,
+static int ixfr_log(const u_char *msg, int len, int *delete,
FILE *file, struct sockaddr_in *sin,
- char *domain, u_int32_t serial_no, int *);
+ char *domain, u_int32_t *serial_no, int *);
static SIG_FN read_alarm(void);
static SIG_FN term_handler(void);
static const char *soa_zinfo(struct zoneinfo *, u_char *, u_char*),
@@ -226,7 +226,6 @@ struct zoneinfo zp_start, zp_finish;
static int restarts = 0;
static int check_serial = 0;
static int xfr_qtype = T_AXFR;
-static u_int32_t old_serial;
FILE *ddt = NULL;
int servermethode[NSMAX];
@@ -693,8 +692,8 @@ main(int argc, char *argv[]) {
if (movefile(tmpname, ixfrfile) == -1) {
perror("movefile");
#ifdef DEBUG
- if (debug)
- (void) unlink(ddtfile);
+ if (debug)
+ (void) unlink(ddtfile);
#endif
if (!quiet)
syslog(LOG_ERR,
@@ -834,7 +833,6 @@ int soa_cnt = 0, scdsoa = 0, methode = ISNOTIXFR;
int delete_soa = 1;
u_int32_t final_serial = 0;
int ixfr_soa = 0;
-int firstsoa = 1;
int ns_cnt = 0;
int query_type = 0;
int prev_comment = 0; /* was previous record a comment? */
@@ -853,6 +851,7 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
u_int cnt;
u_char *cp, *nmp, *eom, *tmp ;
u_char *buf = NULL, *cpp = NULL;
+ u_char *bp;
u_int bufsize = 0;
char name[MAXDNAME], name2[MAXDNAME];
struct sockaddr_in sin;
@@ -864,6 +863,7 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
struct sigvec sv, osv;
#endif
int qdcount, ancount, aucount, arcount, class, type;
+ int first_serial;
const char *badsoa_msg = "Nil";
struct sockaddr_in my_addr;
char my_addr_text[30];
@@ -874,7 +874,9 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
u_char sig[64];
int siglen;
int ixfr_first = 1;
+ int loop_cnt = 0;
time_t timesigned;
+ u_int32_t query_serial = serial_no;
#ifdef DEBUG
if (debug) {
@@ -983,7 +985,7 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
(void) my_close(s);
continue;
}
- if (methode == ISIXFR) {
+ if (methode == ISIXFR && was_ixfr == 0) {
hp = (HEADER *) buf;
cpp = buf;
n = res_nmkquery(&res, QUERY, zp->z_origin, curclass,
@@ -1070,9 +1072,10 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
* Get out your butterfly net and catch the SOA
*/
- if (netread(s, (char *)buf, INT16SZ, XFER_TIMER) < 0) {
- error++;
+ if (netread(s, (char *)buf, INT16SZ,
+ (soa_cnt == 0) ?400 :XFER_TIMER) < 0) {
(void) my_close(s);
+ error++;
continue;
}
if ((len = ns_get16(buf)) == 0) {
@@ -1118,16 +1121,10 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
res_pquery(&res, buf, len, ddt);
}
#endif
- if ((methode == ISIXFR) && (ixfp == NULL)) {
+ if (((methode == ISIXFR) && (ixfp == NULL)) && was_ixfr == 0) {
delete_soa = 1;
- firstsoa = 1;
ixfr_soa = 0;
- old_serial = serial_no;
- if (ixfp != NULL) {
- fflush(ixfp);
- /* XXX error */
- ftruncate(fileno(ixfp), 0);
- } else if ((ixfp = fopen(tmpiname, "w+")) == NULL) {
+ if ((ixfp = fopen(tmpiname, "w+")) == NULL) {
perror(tmpiname);
if (!quiet)
syslog(LOG_ERR,
@@ -1142,7 +1139,6 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
ancount = ntohs(hp->ancount);
aucount = ntohs(hp->nscount);
arcount = ntohs(hp->arcount);
-
/*
* close socket if any of these apply:
* 1) rcode != NOERROR
@@ -1152,7 +1148,7 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
*/
if (hp->rcode != NOERROR || !hp->aa || qdcount != 1 ||
(ancount < 1 && aucount < 1)) {
-#ifndef ultrix /*XXX*/
+#ifndef SYSLOG_42BSD
syslog(LOG_NOTICE,
"[%s] %s for %s, SOA query got rcode %d, aa %d, ancount %d, aucount %d",
inet_ntoa(sin.sin_addr),
@@ -1184,6 +1180,12 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
tmp = buf + HFIXEDSZ;
eom = buf + len;
/* Query Section. */
+ if (qdcount > 1) {
+ badsoa_msg = "question error";
+ goto badsoa;
+ }
+ if (qdcount < 1)
+ goto no_question;
n = dn_expand(buf, eom, tmp, name2, sizeof name2);
if (n < 0) {
badsoa_msg = "qname error";
@@ -1196,8 +1198,10 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
}
NS_GET16(type, tmp);
NS_GET16(class, tmp);
- if (class != curclass || ((type != T_SOA) && type != T_IXFR) ||
- ns_samename(zp->z_origin, name2) != 1) {
+ if (class != curclass ||
+ ((type != T_SOA) && (type != T_IXFR) && (type != T_AXFR)) ||
+ ns_samename(zp->z_origin, name2) != 1)
+ {
syslog(LOG_INFO,
"wrong query in resp from [%s], zone %s: [%s %s %s]\n",
inet_ntoa(sin.sin_addr), zp->z_origin,
@@ -1206,15 +1210,16 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
(void) my_close(s);
continue;
}
+ no_question:
/* ... Answer Section.
* We may have to loop a little, to bypass SIG SOA's in
* the response.
*/
+ loop_cnt = 0;
do {
u_char *cp4;
u_short type, class, dlen;
u_int32_t ttl;
-
n = dn_expand(buf, eom, tmp, name2, sizeof name2);
if (n < 0) {
badsoa_msg = "aname error";
@@ -1236,12 +1241,53 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
badsoa_msg = "zinfo dlen too big";
goto badsoa;
}
- if (type == T_SOA)
+ if (type == T_SOA) {
+ if (was_ixfr) {
+ methode = ISNOTIXFR;
+ break;
+ }
+ if ((methode == ISIXFR) && (loop_cnt == 0)) {
+ bp = tmp;
+ soa_cnt++;
+ badsoa_msg = soa_zinfo(&zp_finish, tmp, eom);
+ if (badsoa_msg)
+ goto badsoa;
+ if (ixfp)
+ if (ixfr_log(buf, len, &delete_soa, ixfp,
+ &sin, domain, &serial_no,
+ &ixfr_first) < 0) {
+ error++;
+ break;
+ }
+ } else {
+ if (methode == ISIXFR) {
+ check_serial = 0;
+ soa_cnt++;
+ break;
+ }
+ break;
+ }
+ }
+ if ((loop_cnt >= 1) && (soa_cnt < 2)) {
+ dprintf(1,
+ "server %s %d rejected IXFR and responded with AXFR\n",
+ inet_ntoa(sin.sin_addr), soa_cnt);
+ methode = ISNOTIXFR;
+ check_serial = 0;
+ was_ixfr++;
+ tmp = bp;
break;
+ }
/* Skip to next record, if any. */
dprintf(1, "skipping %s %s RR in response\n",
name2, p_type(type));
tmp = cp4 + dlen;
+ loop_cnt++;
+ if (loop_cnt >= ancount) {
+ tmp = bp;
+ check_serial = 0;
+ break;
+ }
} while (1);
if (ns_samename(zp->z_origin, name2) != 1) {
@@ -1256,28 +1302,17 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
badsoa_msg = soa_zinfo(&zp_start, tmp, eom);
if (badsoa_msg)
goto badsoa;
+ if (methode == ISNOTIXFR) {
if (SEQ_GT(zp_start.z_serial, serial_no) || !check_serial) {
const char *l, *nl, *t;
+ if (soa_cnt) {
+ goto axfr_response;
+ }
dprintf(1, "need update, serial %u\n",
zp_start.z_serial);
+ soa_cnt = 0;
hp = (HEADER *) buf;
- if ((methode == ISIXFR) && (soa_cnt == 0)) {
- if (type == T_IXFR) {
- if (ixfp)
- ixfr_log(buf, len, &delete_soa, ixfp,
- &sin, domain, serial_no,
- &ixfr_first);
- soa_cnt = 2;
- } else {
- dprintf(1,
- "server %s rejected IXFR and responded with AXFR\n",
- inet_ntoa(sin.sin_addr));
- methode = ISNOTIXFR;
- was_ixfr++;
- soa_cnt++;
- }
- }
ns_cnt = 0;
gettime(&tt);
locallen = sizeof local;
@@ -1394,7 +1429,7 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
}
}
/*XXX ZXFR*/
- if (methode == ISNOTIXFR && !was_ixfr) {
+receive:
/*
* Receive length & response
*/
@@ -1426,7 +1461,6 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
error++;
break;
}
- }
#ifdef DEBUG
if (debug >= 3) {
(void)fprintf(ddt,"len = %d\n", len);
@@ -1456,8 +1490,7 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
}
}
if (len < HFIXEDSZ) {
-
- badrec:
+ badrec:
error++;
alen = sizeof my_addr;
if (getsockname(s, (struct sockaddr *)
@@ -1487,6 +1520,7 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
}
break;
}
+axfr_response:
if (query_type == T_IXFR)
if (hp->rcode != NOERROR) {
dprintf(1,
@@ -1508,156 +1542,360 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
((n + QFIXEDSZ) >= (eom - cp)))
goto badrec;
cp += n + QFIXEDSZ;
- } else {
- if (methode == ISIXFR && ixfp)
- ixfr_log(buf, len, &delete_soa, ixfp,
- &sin, domain, serial_no,
- &ixfr_first);
-
}
nmp = cp;
if ((n = dn_skipname(cp, eom)) == -1)
goto badrec;
tmp = cp + n;
- if (zp->z_type == Z_STUB) {
- ancount = ntohs(hp->ancount);
- n = 0;
- for (cnt = 0; cnt < (u_int)ancount; cnt++) {
- n = print_output(zp, serial_no, buf,
- len, cp);
- if (n < 0)
+ if (zp->z_type == Z_STUB) {
+ ancount = ntohs(hp->ancount);
+ n = 0;
+ for (cnt = 0;
+ cnt < (u_int)ancount;
+ cnt++) {
+ n = print_output(zp,
+ serial_no,
+ buf, len, cp,
+ was_ixfr);
+ if (n < 0)
+ break;
+ cp += n;
+ }
+ /*
+ * If we've processed the answer
+ * section and didn't get any useful
+ * answers, bail out.
+ */
+ if (query_type == T_SOA &&
+ soa_cnt == 0) {
+ syslog(LOG_ERR,
+ "stubs: no SOA in answer");
+ error++;
break;
- cp += n;
- }
- /*
- * If we've processed the answer section and
- * didn't get any useful answers, bail out.
- */
- if (query_type == T_SOA && soa_cnt == 0) {
- syslog(LOG_ERR,
- "stubs: no SOA in answer");
- error++;
- break;
- }
- if (query_type == T_NS && ns_cnt == 0) {
- syslog(LOG_ERR,
- "stubs: no NS in answer");
- error++;
- break;
- }
- if (n >= 0 && hp->nscount) {
- ancount = ntohs(hp->nscount);
+ }
+ if (query_type == T_NS &&
+ ns_cnt == 0) {
+ syslog(LOG_ERR,
+ "stubs: no NS in answer");
+ error++;
+ break;
+ }
+ if (n >= 0 && hp->nscount) {
+ ancount = ntohs(hp->nscount);
+ for (cnt = 0;
+ cnt < (u_int)ancount;
+ cnt++) {
+ n = print_output(zp,
+ serial_no,
+ buf,
+ len,
+ cp,
+ was_ixfr);
+ if (n < 0)
+ break;
+ cp += n;
+ }
+ }
+ ancount = ntohs(hp->arcount);
for (cnt = 0;
+ n > 0 && cnt < (u_int)ancount;
+ cnt++) {
+ n = print_output(zp, serial_no,
+ buf, len, cp,
+ was_ixfr);
+ cp += n;
+ }
+ if (n < 0) {
+ syslog(LOG_INFO,
+ "print_output: unparseable answer (%d), zone %s",
+ hp->rcode,
+ zp->z_origin);
+ error++;
+ break;
+ }
+ if (cp != eom) {
+ syslog(LOG_INFO,
+ "print_output: short answer (%d, %d), zone %s",
+ cp - buf, eom - buf,
+ zp->z_origin);
+ error++;
+ break;
+ }
+ } else {
+ ancount = ntohs(hp->ancount);
+ if (query_type == T_IXFR &&
+ methode == ISIXFR) {
+ if (ixfr_log(buf, len,
+ &delete_soa, ixfp,
+ &sin, domain,
+ &serial_no,
+ &ixfr_first) < 0){
+ error++;
+ break;
+ }
+ }
+ for (n = cnt = 0;
cnt < (u_int)ancount;
cnt++) {
n = print_output(zp, serial_no,
- buf, len,
- cp);
+ buf, len, cp,
+ was_ixfr);
if (n < 0)
break;
cp += n;
}
- }
- ancount = ntohs(hp->arcount);
- for (cnt = 0;
- n > 0 && cnt < (u_int)ancount;
- cnt++) {
- n = print_output(zp, serial_no, buf,
- len, cp);
- cp += n;
- }
- if (n < 0) {
- syslog(LOG_INFO,
- "print_output: unparseable answer (%d), zone %s",
- hp->rcode, zp->z_origin);
- error++;
- break;
- }
- if (cp != eom) {
- syslog(LOG_INFO,
+ if (n < 0) {
+ syslog(LOG_INFO,
+ "print_output: unparseable answer (%d), zone %s",
+ hp->rcode,
+ zp->z_origin);
+ error++;
+ break;
+ }
+ if (cp != eom) {
+ syslog(LOG_INFO,
"print_output: short answer (%d, %d), zone %s",
- cp - buf, eom - buf,
- zp->z_origin);
- error++;
- break;
- }
- } else {
- ancount = ntohs(hp->ancount);
- for (n = cnt = 0; cnt < (u_int)ancount; cnt++) {
- n = print_output(zp, serial_no, buf,
- len, cp);
- if (n < 0)
+ cp - buf, eom - buf,
+ zp->z_origin);
+ error++;
break;
- cp += n;
+ }
}
- if (n < 0) {
- syslog(LOG_INFO,
- "print_output: unparseable answer (%d), zone %s",
- hp->rcode, zp->z_origin);
- error++;
+ if ((soa_cnt >= 2) && (methode == ISNOTIXFR))
break;
- }
- if (cp != eom) {
- syslog(LOG_INFO,
- "print_output: short answer (%d, %d), zone %s",
- cp - buf, eom - buf,
- zp->z_origin);
- error++;
+ if ((soa_cnt == -1) && (methode == ISIXFR))
break;
- }
}
-
- if ((soa_cnt >= 2) && (methode == ISNOTIXFR))
- break;
- if ((soa_cnt == -1) && (methode == ISIXFR))
- break;
- }
- (void) my_close(s);
- if (error == 0) {
+ (void) my_close(s);
+ if (error == 0) {
#ifdef POSIX_SIGNALS
- (void) sigaction(SIGALRM, &osv,
- (struct sigaction *)0);
+ (void) sigaction(SIGALRM, &osv,
+ (struct sigaction *)0);
#else
- (void) sigvec(SIGALRM, &osv, (struct sigvec *)0);
+ (void) sigvec(SIGALRM, &osv,
+ (struct sigvec *)0);
#endif
- if (methode == ISIXFR) {
- fprintf(ixfp, "update:\t{add} ");
- if (soa_buf)
- fputs(soa_buf, ixfp);
- fprintf(ixfp, "[END_DELTA]\n");
- (void) my_close(s);
- return (XFER_SUCCESSIXFR);
- } else {
if (ixfp) {
(void) fclose(ixfp);
ixfp = NULL;
}
return (XFER_SUCCESSAXFR);
}
- }
- if (ixfp) {
- (void) fclose(ixfp);
- ixfp = NULL;
- }
- dprintf(2, "error receiving zone transfer\n");
- } else if (zp_start.z_serial == serial_no) {
+ if (ixfp) {
+ (void) fclose(ixfp);
+ ixfp = NULL;
+ }
+ dprintf(2, "error receiving zone transfer\n");
+ } else if (zp_start.z_serial == serial_no) {
(void) my_close(s);
- dprintf(1, "zone up-to-date, serial %u\n", zp_start.z_serial);
+ dprintf(1, "zone up-to-date, serial %u\n",
+ zp_start.z_serial);
if (ixfp) {
(void) unlink (tmpiname);
(void) fclose(ixfp);
ixfp = NULL;
}
return (XFER_UPTODATE);
- } else {
+ } else {
(void) my_close(s);
if (!quiet)
- syslog(LOG_NOTICE,
+ syslog(LOG_NOTICE,
"serial from [%s], zone %s: %u lower than current: %u\n",
- inet_ntoa(sin.sin_addr), zp->z_origin,
- zp_start.z_serial, serial_no);
+ inet_ntoa(sin.sin_addr), zp->z_origin,
+ zp_start.z_serial, serial_no);
return (XFER_FAIL);
- }
+ }
+ } else {
+ if (zp_finish.z_serial == query_serial) {
+ (void) my_close(s);
+ dprintf(1, "zone up-to-date, serial %u\n",
+ zp_start.z_serial);
+ if (ixfp) {
+ (void) unlink (tmpiname);
+ (void) fclose(ixfp);
+ ixfp = NULL;
+ }
+ return (XFER_UPTODATE);
+ }
+ if (SEQ_GT(query_serial, zp_finish.z_serial)) {
+ if (!quiet)
+ syslog(LOG_NOTICE,
+ "serial from [%s], zone %s: %u lower than current: %u\n",
+ inet_ntoa(sin.sin_addr), zp->z_origin,
+ zp_finish.z_serial, query_serial);
+ dprintf(1,
+ "serial from [%s], zone %s: %u lower than current: %u\n",
+ inet_ntoa(sin.sin_addr), zp->z_origin,
+ zp_finish.z_serial, query_serial);
+ if (ixfp) {
+ (void) fclose(ixfp);
+ ixfp = NULL;
+ (void) unlink (tmpiname);
+ }
+ if (was_ixfr == 0) {
+ was_ixfr++;
+ n = res_nmkquery(&res, QUERY,
+ zp->z_origin,
+ curclass, T_AXFR,
+ NULL, 0,
+ NULL, buf, bufsize);
+ if (n < 0) {
+ if (!quiet)
+ syslog(LOG_INFO,
+ "zone %s: res_nmkquery T_SOA failed",
+ zp->z_origin);
+ (void) my_close(s);
+#ifdef POSIX_SIGNALS
+ (void) sigaction(SIGALRM, &osv,
+ (struct sigaction *)0);
+#else
+ (void) sigvec(SIGALRM, &osv,
+ (struct sigvec *)0);
+#endif
+ return (XFER_FAIL);
+ }
+ /*
+ * Append TSIG to SOA query if desired
+ */
+ tsig_key = tsig_key_from_addr(sin.sin_addr);
+ if (tsig_key != NULL) {
+ siglen = sizeof(sig);
+ ret = ns_sign(buf, &n, bufsize,
+ NOERROR,
+ tsig_key, NULL,
+ 0, sig, &siglen,
+ timesigned);
+ if (ret == 0)
+ tsig_signed = 1;
+ }
+
+ /*
+ * Send length & message for AXFR query
+ */
+ if (writemsg(s, buf, n) < 0)
+ syslog(LOG_INFO,
+ "writemsg: %m");
+ else {
+ methode = ISNOTIXFR;
+ check_serial = 0;
+ soa_cnt = 0;
+ was_ixfr = 0;
+ goto receive;
+ }
+ }
+ (void) my_close(s);
+ return (XFER_FAIL);
+ }
+ if (ancount == 1) {
+ methode = ISNOTIXFR;
+ check_serial = 0;
+ soa_cnt = 0;
+ goto axfr_response;
+ }
+ dprintf(1, "We have an IXFR\n");
+ while (SEQ_GT(zp_finish.z_serial, serial_no)) {
+ /*
+ * Receive length & response
+ */
+ if (netread(s, (char *)buf, INT16SZ,
+ (soa_cnt == 0) ?300 :XFER_TIMER)
+ < 0) {
+ error++;
+ break;
+ }
+ if ((len = ns_get16(buf)) == 0)
+ break;
+ if (len > bufsize) {
+ buf = (u_char *)realloc(buf, len);
+ if (buf == NULL) {
+ syslog(LOG_INFO,
+ "malloc(%u) failed for packet from server [%s], zone %s\n",
+ len,
+ inet_ntoa(sin.sin_addr),
+ zp->z_origin);
+ error++;
+ break;
+ }
+ bufsize = len;
+ }
+ hp = (HEADER *)buf;
+ eom = buf + len;
+ if (netread(s, (char *)buf, len, XFER_TIMER)
+ < 0) {
+ error++;
+ break;
+ }
+#ifdef DEBUG
+ if (debug >= 3) {
+ (void)fprintf(ddt,"len = %d\n", len);
+ res_pquery(&res, buf, len, ddt);
+ }
+ if (fp)
+ res_pquery(&res, buf, len, fp);
+#endif
+ /*
+ * Verify the TSIG if expected
+ */
+ if (tsig_signed != 0) {
+ tsig_req = (soa_cnt == 0);
+ ret = ns_verify_tcp(buf, (int *)&len,
+ &tsig_state,
+ tsig_req);
+ eom = buf + len;
+
+ if (ret != 0) {
+ syslog(LOG_NOTICE,
+ "TSIG verification from server [%s], zone %s: %s (%d)\n",
+ inet_ntoa(sin.sin_addr),
+ zp->z_origin,
+ tsig_rcode(ret), ret);
+ error++;
+ break;
+ }
+ }
+ if (len < HFIXEDSZ) {
+ error++;
+ alen = sizeof my_addr;
+ if (getsockname(s, (struct sockaddr *)
+ &my_addr, &alen) < 0)
+ sprintf(my_addr_text, "[errno %d]", errno);
+ else
+ sprintf(my_addr_text, "[%s].%u",
+ inet_ntoa(my_addr. sin_addr),
+ ntohs(my_addr.sin_port));
+ if ((hp->rcode == REFUSED) &&
+ (len >= HFIXEDSZ)) {
+ syslog(LOG_INFO,
+ "[%s] transfer refused from [%s], zone %s\n",
+ my_addr_text,
+ inet_ntoa(sin.sin_addr),
+ zp->z_origin);
+ } else {
+ syslog(LOG_INFO,
+ "[%s] record too short from [%s], zone %s\n",
+ my_addr_text,
+ inet_ntoa(sin.sin_addr),
+ zp->z_origin);
+ }
+ break;
+ }
+ if (ixfp)
+ if (ixfr_log(buf, len, &delete_soa, ixfp,
+ &sin, domain, &serial_no,
+ &ixfr_first) < 0) {
+ error++;
+ break;
+ }
+ }
+ (void) my_close(s);
+ if (!error) {
+ fprintf(ixfp, "update:\t{add} ");
+ if (soa_buf)
+ fputs(soa_buf, ixfp);
+ fprintf(ixfp, "[END_DELTA]\n");
+ return (XFER_SUCCESSIXFR);
+ }
+ }
}
#ifdef POSIX_SIGNALS
(void) sigaction(SIGALRM, &osv, (struct sigaction *)0);
@@ -1703,10 +1941,12 @@ netread(int fd, char *buf, int len, int timeout) {
ival = zeroival;
ival.it_value.tv_sec = timeout;
while (len > 0) {
+#ifndef WINNT
if (setitimer(ITIMER_REAL, &ival, NULL) < 0) {
syslog(LOG_INFO, setitimerStr);
return (-1);
}
+#endif
errno = 0;
salen = sizeof sa;
n = recvfrom(fd, buf, len, 0, (struct sockaddr *)&sa, &salen);
@@ -1743,10 +1983,12 @@ netread(int fd, char *buf, int len, int timeout) {
buf += n;
len -= n;
}
+#ifndef WINNT
if (setitimer(ITIMER_REAL, &zeroival, NULL) < 0) {
syslog(LOG_INFO, setitimerStr);
return (-1);
}
+#endif
return (0);
}
@@ -1826,7 +2068,7 @@ soa_zinfo(struct zoneinfo *zp, u_char *cp, u_char *eom) {
*/
static int
print_output(struct zoneinfo *zp, u_int32_t serial_no, u_char *msg,
- int msglen, u_char *rrp) {
+ int msglen, u_char *rrp, int was_ixfr) {
u_char *cp;
HEADER *hp = (HEADER *) msg;
u_int32_t addr, ttl, tmpnum;
@@ -2196,9 +2438,8 @@ print_output(struct zoneinfo *zp, u_int32_t serial_no, u_char *msg,
zp->z_origin, zp_finish.z_serial);
}
soa_cnt++;
- if ((methode == ISIXFR) || (soa_cnt >= 2)) {
+ if (methode == ISIXFR)
return (result);
- }
} else {
badsoa_msg = soa_zinfo(&zp_finish, rr_type_ptr, eom);
if (badsoa_msg) {
@@ -2256,6 +2497,9 @@ print_output(struct zoneinfo *zp, u_int32_t serial_no, u_char *msg,
return (result);
}
}
+ if ((soa_cnt == 2) && (was_ixfr == 0))
+ return (result);
+
}
if (zp->z_type == Z_STUB) {
@@ -2758,7 +3002,7 @@ tsig_key_from_addr(struct in_addr addr) {
return NULL;
}
-static void
+static u_int32_t
do_section(ns_msg *handle, ns_sect section, int pflag, FILE *file, int *delete) {
int n, sflag, rrnum;
char buf[2048]; /* XXX need to malloc */
@@ -2776,19 +3020,21 @@ do_section(ns_msg *handle, ns_sect section, int pflag, FILE *file, int *delete)
*/
sflag = (_res.pfcode & pflag);
if (_res.pfcode && !sflag)
- return;
+ return (-1);
opcode = (ns_opcode)ns_msg_getflag(*handle, ns_f_opcode);
rrnum = 0;
+ serial = -1;
for (;;) {
if (ns_parserr(handle, section, rrnum, &rr)) {
- if (errno != ENODEV)
+ if (errno != ENODEV) {
fprintf(file, ";; ns_parserr: %s\n",
strerror(errno));
- else if (rrnum > 0 && sflag != 0 &&
+ return (-1);
+ } else if (rrnum > 0 && sflag != 0 &&
(_res.pfcode & RES_PRF_HEAD1))
putc('\n', file);
- return;
+ return (serial);
}
if (rrnum == 0 && sflag != 0 && (_res.pfcode & RES_PRF_HEAD1))
fprintf(file, ";; %s SECTION:\n",
@@ -2816,24 +3062,21 @@ do_section(ns_msg *handle, ns_sect section, int pflag, FILE *file, int *delete)
}
cp += n;
NS_GET32(serial, cp);
- if (*delete && serial != old_serial)
- /*XXX*/;
- old_serial = serial;
switch (++ixfr_soa) {
case 1:
final_serial = serial;
if (soa_buf == NULL) {
if ((soa_buf = (char *)malloc(2 * PACKETSZ)) == NULL) {
syslog(LOG_INFO, "malloc(%u) failed", 2 * PACKETSZ);
- return;
+ return(-1);
}
n = ns_sprintrr(handle, &rr, NULL, NULL,
soa_buf, 2*PACKETSZ);
if (n < 0) {
fprintf(file, ";; ns_sprintrr: %s\n",
strerror(errno));
- return;
- }
+ return (-1);
+ }
}
print_record = 0;
break;
@@ -2862,7 +3105,7 @@ do_section(ns_msg *handle, ns_sect section, int pflag, FILE *file, int *delete)
if (n < 0) {
fprintf(file, ";; ns_sprintrr: %s\n",
strerror(errno));
- return;
+ return(-1);
}
fputs(buf, file);
fputc('\n', file);
@@ -2872,11 +3115,12 @@ do_section(ns_msg *handle, ns_sect section, int pflag, FILE *file, int *delete)
}
rrnum++;
}
+ return (serial);
}
-static void
+static int
ixfr_log(const u_char *msg, int len, int *delete, FILE *file,
- struct sockaddr_in *sin, char *domain, u_int32_t serial_no,
+ struct sockaddr_in *sin, char *domain, u_int32_t *serial_no,
int *first_rr)
{
ns_msg handle;
@@ -2885,17 +3129,20 @@ ixfr_log(const u_char *msg, int len, int *delete, FILE *file,
ns_opcode opcode;
ns_rcode rcode;
u_int id, n;
- char time[25];
+ char time[25];
ns_rr rr;
char *cp;
HEADER *hp;
- if ((_res.options & RES_INIT) == 0 && res_init() == -1)
- return;
+ if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
+ dprintf(1, "ixfr_log() failed\n");
+ return (-1);
+ }
if (ns_initparse(msg, len, &handle) < 0) {
fprintf(file, ";; ns_initparse: %s\n", strerror(errno));
- return;
+ dprintf(1, "ixfr_log() failed\n");
+ return (-1);
}
opcode = (ns_opcode) ns_msg_getflag(handle, ns_f_opcode);
rcode = (ns_rcode) ns_msg_getflag(handle, ns_f_rcode);
@@ -2905,7 +3152,8 @@ ixfr_log(const u_char *msg, int len, int *delete, FILE *file,
{
(void) fprintf(file,"ns_parserr() failed");
- return;
+ dprintf(1, "ixfr_log() failed\n");
+ return (-1);
}
type = (ns_type)rr.type;
class = (ns_class)rr.rr_class;
@@ -2915,12 +3163,13 @@ ixfr_log(const u_char *msg, int len, int *delete, FILE *file,
(void) fprintf(file,"%s", LogSignature);
sprintf(time, "at %lu", (u_long)tt.tv_sec);
fprintf(file,
- "[IXFR_UPDATE] id %u from [%s].%d %s (named-xfr pid %ld):\n",
+ "[IXFR_UPDATE] id %u from [%s].%d %s (named-xfer pid %ld):\n",
id, inet_ntoa(sin->sin_addr),
ntohs(sin->sin_port), time, (long)getpid());
(*first_rr)++;
}
- do_section(&handle, ns_s_an, RES_PRF_ANS, file, delete);
+ *serial_no = do_section(&handle, ns_s_an, RES_PRF_ANS, file, delete);
+ return (1);
}
static const char *
@@ -2944,3 +3193,4 @@ tsig_rcode(int rcode) {
}
return ("FORMERR");
}
+
diff --git a/contrib/bind/bin/named/Makefile b/contrib/bind/bin/named/Makefile
index 96a3927..f6ad6d0 100644
--- a/contrib/bind/bin/named/Makefile
+++ b/contrib/bind/bin/named/Makefile
@@ -1,4 +1,4 @@
-## Copyright (c) 1996-1999 by Internet Software Consortium
+## Copyright (c) 1996-2000 by Internet Software Consortium
##
## Permission to use, copy, modify, and distribute this software for any
## purpose with or without fee is hereby granted, provided that the above
@@ -13,7 +13,7 @@
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
## SOFTWARE.
-# $Id: Makefile,v 8.47 1999/08/26 18:42:31 vixie Exp $
+# $Id: Makefile,v 8.49 2000/05/09 07:02:22 vixie Exp $
# $FreeBSD$
DESTDIR=
@@ -87,7 +87,7 @@ tmp_version.c: version.c Makefile ../Makefile ${SRCS} ${HDRS}
(u=$${USER-root} d=`pwd` h=`${HOSTNAMECMD}` t=`date`; \
sed -e "s|%WHEN%|$${t}|" -e "s|%VERSION%|"${VER}"|" \
-e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \
- < version.c > tmp_version.c)
+ < version.c > tmp_version.c); sleep 1
pathnames.h: ${TOP}/.settings Makefile pathtemplate.h
rm -f pathnames.h
diff --git a/contrib/bind/bin/nslookup/commands.l b/contrib/bind/bin/nslookup/commands.l
index c480d46..991ed66 100644
--- a/contrib/bind/bin/nslookup/commands.l
+++ b/contrib/bind/bin/nslookup/commands.l
@@ -159,7 +159,7 @@ nslookup_yy_input(buf, result, max_size, intr)
%}
WS [ \t]
FLET [A-Za-z0-9.*\\_]
-LET [A-Za-z0-9.*]
+LET [A-Za-z0-9.*_]
NAME [A-Za-z0-9.*=_/-]
%%
^{WS}*server{WS}+{LET}{NAME}*{WS}*$ {
@@ -196,10 +196,6 @@ NAME [A-Za-z0-9.*=_/-]
Finger(yytext, 0);
return(1);
}
-^{WS}*view{WS}+{NAME}+{WS}*$ {
- ViewList((char *)yytext);
- return(1);
- }
^{WS}*ls{WS}+(("-a"|"-d"|"-h"|"-m"|"-s"){WS}+)?{LET}{NAME}*{WS}+>>?{WS}+{NAME}+{WS}*$ {
/*
* 2nd arg.
diff --git a/contrib/bind/bin/nslookup/main.c b/contrib/bind/bin/nslookup/main.c
index 454fe12..c5ae700 100644
--- a/contrib/bind/bin/nslookup/main.c
+++ b/contrib/bind/bin/nslookup/main.c
@@ -78,7 +78,7 @@ char copyright[] =
#ifndef lint
static const char sccsid[] = "@(#)main.c 5.42 (Berkeley) 3/3/91";
-static const char rcsid[] = "$Id: main.c,v 8.13 1999/10/13 16:39:19 vixie Exp $";
+static const char rcsid[] = "$Id: main.c,v 8.14 2000/03/30 23:25:34 vixie Exp $";
#endif /* not lint */
/*
@@ -172,7 +172,7 @@ jmp_buf env;
/*
- * Browser command for help and view.
+ * Browser command for help.
*/
char *pager;
diff --git a/contrib/bind/port/freebsd/include/port_after.h b/contrib/bind/port/freebsd/include/port_after.h
index f6490ba..5203050 100644
--- a/contrib/bind/port/freebsd/include/port_after.h
+++ b/contrib/bind/port/freebsd/include/port_after.h
@@ -1,7 +1,6 @@
/* $FreeBSD$ */
#ifndef PORT_AFTER_H
#define PORT_AFTER_H
-#define CAN_RECONNECT
#define USE_POSIX
#define POSIX_SIGNALS
#define USE_UTIME
OpenPOWER on IntegriCloud