Resolve conflicts.
This commit is contained in:
parent
6be735eb30
commit
a63f91247a
@ -131,7 +131,7 @@ char copyright[] =
|
|||||||
|
|
||||||
#if !defined(lint) && !defined(SABER)
|
#if !defined(lint) && !defined(SABER)
|
||||||
static const char sccsid[] = "@(#)named-xfer.c 4.18 (Berkeley) 3/7/91";
|
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 */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "port_before.h"
|
#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 MAX_XFER_RESTARTS 2
|
||||||
|
|
||||||
#define ENABLE_IXFR 0
|
#define ENABLE_IXFR 1
|
||||||
|
|
||||||
# ifdef SHORT_FNAMES
|
# ifdef SHORT_FNAMES
|
||||||
extern long pathconf __P((const char *path, int name)); /* XXX */
|
extern long pathconf __P((const char *path, int name)); /* XXX */
|
||||||
@ -192,7 +192,7 @@ static char *ddtfilename = NULL,
|
|||||||
*ddtfile = NULL;
|
*ddtfile = NULL;
|
||||||
|
|
||||||
static char *tmpname = 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 */
|
*domain; /* domain being xfered */
|
||||||
|
|
||||||
static int quiet = 0,
|
static int quiet = 0,
|
||||||
@ -210,12 +210,12 @@ static void usage(const char *),
|
|||||||
tsig_init(const char *);
|
tsig_init(const char *);
|
||||||
static int getzone(struct zoneinfo *, u_int32_t, int),
|
static int getzone(struct zoneinfo *, u_int32_t, int),
|
||||||
print_output(struct zoneinfo *, u_int32_t,
|
print_output(struct zoneinfo *, u_int32_t,
|
||||||
u_char *, int, u_char *),
|
u_char *, int, u_char *, int),
|
||||||
netread(int, char *, int, int),
|
netread(int, char *, int, int),
|
||||||
writemsg(int, const u_char *, 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,
|
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 read_alarm(void);
|
||||||
static SIG_FN term_handler(void);
|
static SIG_FN term_handler(void);
|
||||||
static const char *soa_zinfo(struct zoneinfo *, u_char *, u_char*),
|
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 restarts = 0;
|
||||||
static int check_serial = 0;
|
static int check_serial = 0;
|
||||||
static int xfr_qtype = T_AXFR;
|
static int xfr_qtype = T_AXFR;
|
||||||
static u_int32_t old_serial;
|
|
||||||
|
|
||||||
FILE *ddt = NULL;
|
FILE *ddt = NULL;
|
||||||
int servermethode[NSMAX];
|
int servermethode[NSMAX];
|
||||||
@ -693,8 +692,8 @@ main(int argc, char *argv[]) {
|
|||||||
if (movefile(tmpname, ixfrfile) == -1) {
|
if (movefile(tmpname, ixfrfile) == -1) {
|
||||||
perror("movefile");
|
perror("movefile");
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (debug)
|
if (debug)
|
||||||
(void) unlink(ddtfile);
|
(void) unlink(ddtfile);
|
||||||
#endif
|
#endif
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
syslog(LOG_ERR,
|
syslog(LOG_ERR,
|
||||||
@ -834,7 +833,6 @@ int soa_cnt = 0, scdsoa = 0, methode = ISNOTIXFR;
|
|||||||
int delete_soa = 1;
|
int delete_soa = 1;
|
||||||
u_int32_t final_serial = 0;
|
u_int32_t final_serial = 0;
|
||||||
int ixfr_soa = 0;
|
int ixfr_soa = 0;
|
||||||
int firstsoa = 1;
|
|
||||||
int ns_cnt = 0;
|
int ns_cnt = 0;
|
||||||
int query_type = 0;
|
int query_type = 0;
|
||||||
int prev_comment = 0; /* was previous record a comment? */
|
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_int cnt;
|
||||||
u_char *cp, *nmp, *eom, *tmp ;
|
u_char *cp, *nmp, *eom, *tmp ;
|
||||||
u_char *buf = NULL, *cpp = NULL;
|
u_char *buf = NULL, *cpp = NULL;
|
||||||
|
u_char *bp;
|
||||||
u_int bufsize = 0;
|
u_int bufsize = 0;
|
||||||
char name[MAXDNAME], name2[MAXDNAME];
|
char name[MAXDNAME], name2[MAXDNAME];
|
||||||
struct sockaddr_in sin;
|
struct sockaddr_in sin;
|
||||||
@ -864,6 +863,7 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
|
|||||||
struct sigvec sv, osv;
|
struct sigvec sv, osv;
|
||||||
#endif
|
#endif
|
||||||
int qdcount, ancount, aucount, arcount, class, type;
|
int qdcount, ancount, aucount, arcount, class, type;
|
||||||
|
int first_serial;
|
||||||
const char *badsoa_msg = "Nil";
|
const char *badsoa_msg = "Nil";
|
||||||
struct sockaddr_in my_addr;
|
struct sockaddr_in my_addr;
|
||||||
char my_addr_text[30];
|
char my_addr_text[30];
|
||||||
@ -874,7 +874,9 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
|
|||||||
u_char sig[64];
|
u_char sig[64];
|
||||||
int siglen;
|
int siglen;
|
||||||
int ixfr_first = 1;
|
int ixfr_first = 1;
|
||||||
|
int loop_cnt = 0;
|
||||||
time_t timesigned;
|
time_t timesigned;
|
||||||
|
u_int32_t query_serial = serial_no;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (debug) {
|
if (debug) {
|
||||||
@ -983,7 +985,7 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
|
|||||||
(void) my_close(s);
|
(void) my_close(s);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (methode == ISIXFR) {
|
if (methode == ISIXFR && was_ixfr == 0) {
|
||||||
hp = (HEADER *) buf;
|
hp = (HEADER *) buf;
|
||||||
cpp = buf;
|
cpp = buf;
|
||||||
n = res_nmkquery(&res, QUERY, zp->z_origin, curclass,
|
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
|
* Get out your butterfly net and catch the SOA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (netread(s, (char *)buf, INT16SZ, XFER_TIMER) < 0) {
|
if (netread(s, (char *)buf, INT16SZ,
|
||||||
error++;
|
(soa_cnt == 0) ?400 :XFER_TIMER) < 0) {
|
||||||
(void) my_close(s);
|
(void) my_close(s);
|
||||||
|
error++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ((len = ns_get16(buf)) == 0) {
|
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);
|
res_pquery(&res, buf, len, ddt);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if ((methode == ISIXFR) && (ixfp == NULL)) {
|
if (((methode == ISIXFR) && (ixfp == NULL)) && was_ixfr == 0) {
|
||||||
delete_soa = 1;
|
delete_soa = 1;
|
||||||
firstsoa = 1;
|
|
||||||
ixfr_soa = 0;
|
ixfr_soa = 0;
|
||||||
old_serial = serial_no;
|
if ((ixfp = fopen(tmpiname, "w+")) == NULL) {
|
||||||
if (ixfp != NULL) {
|
|
||||||
fflush(ixfp);
|
|
||||||
/* XXX error */
|
|
||||||
ftruncate(fileno(ixfp), 0);
|
|
||||||
} else if ((ixfp = fopen(tmpiname, "w+")) == NULL) {
|
|
||||||
perror(tmpiname);
|
perror(tmpiname);
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
syslog(LOG_ERR,
|
syslog(LOG_ERR,
|
||||||
@ -1142,7 +1139,6 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
|
|||||||
ancount = ntohs(hp->ancount);
|
ancount = ntohs(hp->ancount);
|
||||||
aucount = ntohs(hp->nscount);
|
aucount = ntohs(hp->nscount);
|
||||||
arcount = ntohs(hp->arcount);
|
arcount = ntohs(hp->arcount);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* close socket if any of these apply:
|
* close socket if any of these apply:
|
||||||
* 1) rcode != NOERROR
|
* 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 ||
|
if (hp->rcode != NOERROR || !hp->aa || qdcount != 1 ||
|
||||||
(ancount < 1 && aucount < 1)) {
|
(ancount < 1 && aucount < 1)) {
|
||||||
#ifndef ultrix /*XXX*/
|
#ifndef SYSLOG_42BSD
|
||||||
syslog(LOG_NOTICE,
|
syslog(LOG_NOTICE,
|
||||||
"[%s] %s for %s, SOA query got rcode %d, aa %d, ancount %d, aucount %d",
|
"[%s] %s for %s, SOA query got rcode %d, aa %d, ancount %d, aucount %d",
|
||||||
inet_ntoa(sin.sin_addr),
|
inet_ntoa(sin.sin_addr),
|
||||||
@ -1184,6 +1180,12 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
|
|||||||
tmp = buf + HFIXEDSZ;
|
tmp = buf + HFIXEDSZ;
|
||||||
eom = buf + len;
|
eom = buf + len;
|
||||||
/* Query Section. */
|
/* 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);
|
n = dn_expand(buf, eom, tmp, name2, sizeof name2);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
badsoa_msg = "qname error";
|
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(type, tmp);
|
||||||
NS_GET16(class, tmp);
|
NS_GET16(class, tmp);
|
||||||
if (class != curclass || ((type != T_SOA) && type != T_IXFR) ||
|
if (class != curclass ||
|
||||||
ns_samename(zp->z_origin, name2) != 1) {
|
((type != T_SOA) && (type != T_IXFR) && (type != T_AXFR)) ||
|
||||||
|
ns_samename(zp->z_origin, name2) != 1)
|
||||||
|
{
|
||||||
syslog(LOG_INFO,
|
syslog(LOG_INFO,
|
||||||
"wrong query in resp from [%s], zone %s: [%s %s %s]\n",
|
"wrong query in resp from [%s], zone %s: [%s %s %s]\n",
|
||||||
inet_ntoa(sin.sin_addr), zp->z_origin,
|
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);
|
(void) my_close(s);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
no_question:
|
||||||
/* ... Answer Section.
|
/* ... Answer Section.
|
||||||
* We may have to loop a little, to bypass SIG SOA's in
|
* We may have to loop a little, to bypass SIG SOA's in
|
||||||
* the response.
|
* the response.
|
||||||
*/
|
*/
|
||||||
|
loop_cnt = 0;
|
||||||
do {
|
do {
|
||||||
u_char *cp4;
|
u_char *cp4;
|
||||||
u_short type, class, dlen;
|
u_short type, class, dlen;
|
||||||
u_int32_t ttl;
|
u_int32_t ttl;
|
||||||
|
|
||||||
n = dn_expand(buf, eom, tmp, name2, sizeof name2);
|
n = dn_expand(buf, eom, tmp, name2, sizeof name2);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
badsoa_msg = "aname error";
|
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";
|
badsoa_msg = "zinfo dlen too big";
|
||||||
goto badsoa;
|
goto badsoa;
|
||||||
}
|
}
|
||||||
if (type == T_SOA)
|
if (type == T_SOA) {
|
||||||
|
if (was_ixfr) {
|
||||||
|
methode = ISNOTIXFR;
|
||||||
break;
|
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. */
|
/* Skip to next record, if any. */
|
||||||
dprintf(1, "skipping %s %s RR in response\n",
|
dprintf(1, "skipping %s %s RR in response\n",
|
||||||
name2, p_type(type));
|
name2, p_type(type));
|
||||||
tmp = cp4 + dlen;
|
tmp = cp4 + dlen;
|
||||||
|
loop_cnt++;
|
||||||
|
if (loop_cnt >= ancount) {
|
||||||
|
tmp = bp;
|
||||||
|
check_serial = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
if (ns_samename(zp->z_origin, name2) != 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);
|
badsoa_msg = soa_zinfo(&zp_start, tmp, eom);
|
||||||
if (badsoa_msg)
|
if (badsoa_msg)
|
||||||
goto badsoa;
|
goto badsoa;
|
||||||
|
if (methode == ISNOTIXFR) {
|
||||||
if (SEQ_GT(zp_start.z_serial, serial_no) || !check_serial) {
|
if (SEQ_GT(zp_start.z_serial, serial_no) || !check_serial) {
|
||||||
const char *l, *nl, *t;
|
const char *l, *nl, *t;
|
||||||
|
|
||||||
|
if (soa_cnt) {
|
||||||
|
goto axfr_response;
|
||||||
|
}
|
||||||
dprintf(1, "need update, serial %u\n",
|
dprintf(1, "need update, serial %u\n",
|
||||||
zp_start.z_serial);
|
zp_start.z_serial);
|
||||||
|
soa_cnt = 0;
|
||||||
hp = (HEADER *) buf;
|
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;
|
ns_cnt = 0;
|
||||||
gettime(&tt);
|
gettime(&tt);
|
||||||
locallen = sizeof local;
|
locallen = sizeof local;
|
||||||
@ -1394,7 +1429,7 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*XXX ZXFR*/
|
/*XXX ZXFR*/
|
||||||
if (methode == ISNOTIXFR && !was_ixfr) {
|
receive:
|
||||||
/*
|
/*
|
||||||
* Receive length & response
|
* Receive length & response
|
||||||
*/
|
*/
|
||||||
@ -1426,7 +1461,6 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
|
|||||||
error++;
|
error++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (debug >= 3) {
|
if (debug >= 3) {
|
||||||
(void)fprintf(ddt,"len = %d\n", len);
|
(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) {
|
if (len < HFIXEDSZ) {
|
||||||
|
badrec:
|
||||||
badrec:
|
|
||||||
error++;
|
error++;
|
||||||
alen = sizeof my_addr;
|
alen = sizeof my_addr;
|
||||||
if (getsockname(s, (struct sockaddr *)
|
if (getsockname(s, (struct sockaddr *)
|
||||||
@ -1487,6 +1520,7 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
axfr_response:
|
||||||
if (query_type == T_IXFR)
|
if (query_type == T_IXFR)
|
||||||
if (hp->rcode != NOERROR) {
|
if (hp->rcode != NOERROR) {
|
||||||
dprintf(1,
|
dprintf(1,
|
||||||
@ -1508,156 +1542,360 @@ getzone(struct zoneinfo *zp, u_int32_t serial_no, int port) {
|
|||||||
((n + QFIXEDSZ) >= (eom - cp)))
|
((n + QFIXEDSZ) >= (eom - cp)))
|
||||||
goto badrec;
|
goto badrec;
|
||||||
cp += n + QFIXEDSZ;
|
cp += n + QFIXEDSZ;
|
||||||
} else {
|
|
||||||
if (methode == ISIXFR && ixfp)
|
|
||||||
ixfr_log(buf, len, &delete_soa, ixfp,
|
|
||||||
&sin, domain, serial_no,
|
|
||||||
&ixfr_first);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
nmp = cp;
|
nmp = cp;
|
||||||
if ((n = dn_skipname(cp, eom)) == -1)
|
if ((n = dn_skipname(cp, eom)) == -1)
|
||||||
goto badrec;
|
goto badrec;
|
||||||
tmp = cp + n;
|
tmp = cp + n;
|
||||||
if (zp->z_type == Z_STUB) {
|
if (zp->z_type == Z_STUB) {
|
||||||
ancount = ntohs(hp->ancount);
|
ancount = ntohs(hp->ancount);
|
||||||
n = 0;
|
n = 0;
|
||||||
for (cnt = 0; cnt < (u_int)ancount; cnt++) {
|
|
||||||
n = print_output(zp, serial_no, buf,
|
|
||||||
len, cp);
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
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;
|
for (cnt = 0;
|
||||||
cnt < (u_int)ancount;
|
cnt < (u_int)ancount;
|
||||||
cnt++) {
|
cnt++) {
|
||||||
n = print_output(zp, serial_no,
|
n = print_output(zp,
|
||||||
buf, len,
|
serial_no,
|
||||||
cp);
|
buf, len, cp,
|
||||||
|
was_ixfr);
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
break;
|
break;
|
||||||
cp += n;
|
cp += n;
|
||||||
}
|
}
|
||||||
}
|
/*
|
||||||
ancount = ntohs(hp->arcount);
|
* If we've processed the answer
|
||||||
for (cnt = 0;
|
* section and didn't get any useful
|
||||||
n > 0 && cnt < (u_int)ancount;
|
* answers, bail out.
|
||||||
cnt++) {
|
*/
|
||||||
n = print_output(zp, serial_no, buf,
|
if (query_type == T_SOA &&
|
||||||
len, cp);
|
soa_cnt == 0) {
|
||||||
cp += n;
|
syslog(LOG_ERR,
|
||||||
}
|
"stubs: no SOA in answer");
|
||||||
if (n < 0) {
|
error++;
|
||||||
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)
|
|
||||||
break;
|
break;
|
||||||
cp += n;
|
}
|
||||||
}
|
if (query_type == T_NS &&
|
||||||
if (n < 0) {
|
ns_cnt == 0) {
|
||||||
syslog(LOG_INFO,
|
syslog(LOG_ERR,
|
||||||
"print_output: unparseable answer (%d), zone %s",
|
"stubs: no NS in answer");
|
||||||
hp->rcode, zp->z_origin);
|
error++;
|
||||||
error++;
|
break;
|
||||||
break;
|
}
|
||||||
}
|
if (n >= 0 && hp->nscount) {
|
||||||
if (cp != eom) {
|
ancount = ntohs(hp->nscount);
|
||||||
syslog(LOG_INFO,
|
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",
|
"print_output: short answer (%d, %d), zone %s",
|
||||||
cp - buf, eom - buf,
|
cp - buf, eom - buf,
|
||||||
zp->z_origin);
|
zp->z_origin);
|
||||||
error++;
|
error++;
|
||||||
break;
|
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,
|
||||||
|
was_ixfr);
|
||||||
|
if (n < 0)
|
||||||
|
break;
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if ((soa_cnt >= 2) && (methode == ISNOTIXFR))
|
||||||
|
break;
|
||||||
|
if ((soa_cnt == -1) && (methode == ISIXFR))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
(void) my_close(s);
|
||||||
if ((soa_cnt >= 2) && (methode == ISNOTIXFR))
|
if (error == 0) {
|
||||||
break;
|
|
||||||
if ((soa_cnt == -1) && (methode == ISIXFR))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
(void) my_close(s);
|
|
||||||
if (error == 0) {
|
|
||||||
#ifdef POSIX_SIGNALS
|
#ifdef POSIX_SIGNALS
|
||||||
(void) sigaction(SIGALRM, &osv,
|
(void) sigaction(SIGALRM, &osv,
|
||||||
(struct sigaction *)0);
|
(struct sigaction *)0);
|
||||||
#else
|
#else
|
||||||
(void) sigvec(SIGALRM, &osv, (struct sigvec *)0);
|
(void) sigvec(SIGALRM, &osv,
|
||||||
|
(struct sigvec *)0);
|
||||||
#endif
|
#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) {
|
if (ixfp) {
|
||||||
(void) fclose(ixfp);
|
(void) fclose(ixfp);
|
||||||
ixfp = NULL;
|
ixfp = NULL;
|
||||||
}
|
}
|
||||||
return (XFER_SUCCESSAXFR);
|
return (XFER_SUCCESSAXFR);
|
||||||
}
|
}
|
||||||
}
|
if (ixfp) {
|
||||||
if (ixfp) {
|
(void) fclose(ixfp);
|
||||||
(void) fclose(ixfp);
|
ixfp = NULL;
|
||||||
ixfp = NULL;
|
}
|
||||||
}
|
dprintf(2, "error receiving zone transfer\n");
|
||||||
dprintf(2, "error receiving zone transfer\n");
|
} else if (zp_start.z_serial == serial_no) {
|
||||||
} else if (zp_start.z_serial == serial_no) {
|
|
||||||
(void) my_close(s);
|
(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) {
|
if (ixfp) {
|
||||||
(void) unlink (tmpiname);
|
(void) unlink (tmpiname);
|
||||||
(void) fclose(ixfp);
|
(void) fclose(ixfp);
|
||||||
ixfp = NULL;
|
ixfp = NULL;
|
||||||
}
|
}
|
||||||
return (XFER_UPTODATE);
|
return (XFER_UPTODATE);
|
||||||
} else {
|
} else {
|
||||||
(void) my_close(s);
|
(void) my_close(s);
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
syslog(LOG_NOTICE,
|
syslog(LOG_NOTICE,
|
||||||
"serial from [%s], zone %s: %u lower than current: %u\n",
|
"serial from [%s], zone %s: %u lower than current: %u\n",
|
||||||
inet_ntoa(sin.sin_addr), zp->z_origin,
|
inet_ntoa(sin.sin_addr), zp->z_origin,
|
||||||
zp_start.z_serial, serial_no);
|
zp_start.z_serial, serial_no);
|
||||||
return (XFER_FAIL);
|
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
|
#ifdef POSIX_SIGNALS
|
||||||
(void) sigaction(SIGALRM, &osv, (struct sigaction *)0);
|
(void) sigaction(SIGALRM, &osv, (struct sigaction *)0);
|
||||||
@ -1703,10 +1941,12 @@ netread(int fd, char *buf, int len, int timeout) {
|
|||||||
ival = zeroival;
|
ival = zeroival;
|
||||||
ival.it_value.tv_sec = timeout;
|
ival.it_value.tv_sec = timeout;
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
|
#ifndef WINNT
|
||||||
if (setitimer(ITIMER_REAL, &ival, NULL) < 0) {
|
if (setitimer(ITIMER_REAL, &ival, NULL) < 0) {
|
||||||
syslog(LOG_INFO, setitimerStr);
|
syslog(LOG_INFO, setitimerStr);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
errno = 0;
|
errno = 0;
|
||||||
salen = sizeof sa;
|
salen = sizeof sa;
|
||||||
n = recvfrom(fd, buf, len, 0, (struct sockaddr *)&sa, &salen);
|
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;
|
buf += n;
|
||||||
len -= n;
|
len -= n;
|
||||||
}
|
}
|
||||||
|
#ifndef WINNT
|
||||||
if (setitimer(ITIMER_REAL, &zeroival, NULL) < 0) {
|
if (setitimer(ITIMER_REAL, &zeroival, NULL) < 0) {
|
||||||
syslog(LOG_INFO, setitimerStr);
|
syslog(LOG_INFO, setitimerStr);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1826,7 +2068,7 @@ soa_zinfo(struct zoneinfo *zp, u_char *cp, u_char *eom) {
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
print_output(struct zoneinfo *zp, u_int32_t serial_no, u_char *msg,
|
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;
|
u_char *cp;
|
||||||
HEADER *hp = (HEADER *) msg;
|
HEADER *hp = (HEADER *) msg;
|
||||||
u_int32_t addr, ttl, tmpnum;
|
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);
|
zp->z_origin, zp_finish.z_serial);
|
||||||
}
|
}
|
||||||
soa_cnt++;
|
soa_cnt++;
|
||||||
if ((methode == ISIXFR) || (soa_cnt >= 2)) {
|
if (methode == ISIXFR)
|
||||||
return (result);
|
return (result);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
badsoa_msg = soa_zinfo(&zp_finish, rr_type_ptr, eom);
|
badsoa_msg = soa_zinfo(&zp_finish, rr_type_ptr, eom);
|
||||||
if (badsoa_msg) {
|
if (badsoa_msg) {
|
||||||
@ -2256,6 +2497,9 @@ print_output(struct zoneinfo *zp, u_int32_t serial_no, u_char *msg,
|
|||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ((soa_cnt == 2) && (was_ixfr == 0))
|
||||||
|
return (result);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zp->z_type == Z_STUB) {
|
if (zp->z_type == Z_STUB) {
|
||||||
@ -2758,7 +3002,7 @@ tsig_key_from_addr(struct in_addr addr) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static u_int32_t
|
||||||
do_section(ns_msg *handle, ns_sect section, int pflag, FILE *file, int *delete) {
|
do_section(ns_msg *handle, ns_sect section, int pflag, FILE *file, int *delete) {
|
||||||
int n, sflag, rrnum;
|
int n, sflag, rrnum;
|
||||||
char buf[2048]; /* XXX need to malloc */
|
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);
|
sflag = (_res.pfcode & pflag);
|
||||||
if (_res.pfcode && !sflag)
|
if (_res.pfcode && !sflag)
|
||||||
return;
|
return (-1);
|
||||||
|
|
||||||
opcode = (ns_opcode)ns_msg_getflag(*handle, ns_f_opcode);
|
opcode = (ns_opcode)ns_msg_getflag(*handle, ns_f_opcode);
|
||||||
rrnum = 0;
|
rrnum = 0;
|
||||||
|
serial = -1;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (ns_parserr(handle, section, rrnum, &rr)) {
|
if (ns_parserr(handle, section, rrnum, &rr)) {
|
||||||
if (errno != ENODEV)
|
if (errno != ENODEV) {
|
||||||
fprintf(file, ";; ns_parserr: %s\n",
|
fprintf(file, ";; ns_parserr: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
else if (rrnum > 0 && sflag != 0 &&
|
return (-1);
|
||||||
|
} else if (rrnum > 0 && sflag != 0 &&
|
||||||
(_res.pfcode & RES_PRF_HEAD1))
|
(_res.pfcode & RES_PRF_HEAD1))
|
||||||
putc('\n', file);
|
putc('\n', file);
|
||||||
return;
|
return (serial);
|
||||||
}
|
}
|
||||||
if (rrnum == 0 && sflag != 0 && (_res.pfcode & RES_PRF_HEAD1))
|
if (rrnum == 0 && sflag != 0 && (_res.pfcode & RES_PRF_HEAD1))
|
||||||
fprintf(file, ";; %s SECTION:\n",
|
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;
|
cp += n;
|
||||||
NS_GET32(serial, cp);
|
NS_GET32(serial, cp);
|
||||||
if (*delete && serial != old_serial)
|
|
||||||
/*XXX*/;
|
|
||||||
old_serial = serial;
|
|
||||||
switch (++ixfr_soa) {
|
switch (++ixfr_soa) {
|
||||||
case 1:
|
case 1:
|
||||||
final_serial = serial;
|
final_serial = serial;
|
||||||
if (soa_buf == NULL) {
|
if (soa_buf == NULL) {
|
||||||
if ((soa_buf = (char *)malloc(2 * PACKETSZ)) == NULL) {
|
if ((soa_buf = (char *)malloc(2 * PACKETSZ)) == NULL) {
|
||||||
syslog(LOG_INFO, "malloc(%u) failed", 2 * PACKETSZ);
|
syslog(LOG_INFO, "malloc(%u) failed", 2 * PACKETSZ);
|
||||||
return;
|
return(-1);
|
||||||
}
|
}
|
||||||
n = ns_sprintrr(handle, &rr, NULL, NULL,
|
n = ns_sprintrr(handle, &rr, NULL, NULL,
|
||||||
soa_buf, 2*PACKETSZ);
|
soa_buf, 2*PACKETSZ);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
fprintf(file, ";; ns_sprintrr: %s\n",
|
fprintf(file, ";; ns_sprintrr: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
return;
|
return (-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print_record = 0;
|
print_record = 0;
|
||||||
break;
|
break;
|
||||||
@ -2862,7 +3105,7 @@ do_section(ns_msg *handle, ns_sect section, int pflag, FILE *file, int *delete)
|
|||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
fprintf(file, ";; ns_sprintrr: %s\n",
|
fprintf(file, ";; ns_sprintrr: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
return;
|
return(-1);
|
||||||
}
|
}
|
||||||
fputs(buf, file);
|
fputs(buf, file);
|
||||||
fputc('\n', file);
|
fputc('\n', file);
|
||||||
@ -2872,11 +3115,12 @@ do_section(ns_msg *handle, ns_sect section, int pflag, FILE *file, int *delete)
|
|||||||
}
|
}
|
||||||
rrnum++;
|
rrnum++;
|
||||||
}
|
}
|
||||||
|
return (serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static int
|
||||||
ixfr_log(const u_char *msg, int len, int *delete, FILE *file,
|
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)
|
int *first_rr)
|
||||||
{
|
{
|
||||||
ns_msg handle;
|
ns_msg handle;
|
||||||
@ -2885,17 +3129,20 @@ ixfr_log(const u_char *msg, int len, int *delete, FILE *file,
|
|||||||
ns_opcode opcode;
|
ns_opcode opcode;
|
||||||
ns_rcode rcode;
|
ns_rcode rcode;
|
||||||
u_int id, n;
|
u_int id, n;
|
||||||
char time[25];
|
char time[25];
|
||||||
ns_rr rr;
|
ns_rr rr;
|
||||||
char *cp;
|
char *cp;
|
||||||
HEADER *hp;
|
HEADER *hp;
|
||||||
|
|
||||||
if ((_res.options & RES_INIT) == 0 && res_init() == -1)
|
if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
|
||||||
return;
|
dprintf(1, "ixfr_log() failed\n");
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
if (ns_initparse(msg, len, &handle) < 0) {
|
if (ns_initparse(msg, len, &handle) < 0) {
|
||||||
fprintf(file, ";; ns_initparse: %s\n", strerror(errno));
|
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);
|
opcode = (ns_opcode) ns_msg_getflag(handle, ns_f_opcode);
|
||||||
rcode = (ns_rcode) ns_msg_getflag(handle, ns_f_rcode);
|
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");
|
(void) fprintf(file,"ns_parserr() failed");
|
||||||
return;
|
dprintf(1, "ixfr_log() failed\n");
|
||||||
|
return (-1);
|
||||||
}
|
}
|
||||||
type = (ns_type)rr.type;
|
type = (ns_type)rr.type;
|
||||||
class = (ns_class)rr.rr_class;
|
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);
|
(void) fprintf(file,"%s", LogSignature);
|
||||||
sprintf(time, "at %lu", (u_long)tt.tv_sec);
|
sprintf(time, "at %lu", (u_long)tt.tv_sec);
|
||||||
fprintf(file,
|
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),
|
id, inet_ntoa(sin->sin_addr),
|
||||||
ntohs(sin->sin_port), time, (long)getpid());
|
ntohs(sin->sin_port), time, (long)getpid());
|
||||||
(*first_rr)++;
|
(*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 *
|
static const char *
|
||||||
@ -2944,3 +3193,4 @@ tsig_rcode(int rcode) {
|
|||||||
}
|
}
|
||||||
return ("FORMERR");
|
return ("FORMERR");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
## Permission to use, copy, modify, and distribute this software for any
|
||||||
## purpose with or without fee is hereby granted, provided that the above
|
## 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
|
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||||
## SOFTWARE.
|
## 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$
|
# $FreeBSD$
|
||||||
|
|
||||||
DESTDIR=
|
DESTDIR=
|
||||||
@ -87,7 +87,7 @@ tmp_version.c: version.c Makefile ../Makefile ${SRCS} ${HDRS}
|
|||||||
(u=$${USER-root} d=`pwd` h=`${HOSTNAMECMD}` t=`date`; \
|
(u=$${USER-root} d=`pwd` h=`${HOSTNAMECMD}` t=`date`; \
|
||||||
sed -e "s|%WHEN%|$${t}|" -e "s|%VERSION%|"${VER}"|" \
|
sed -e "s|%WHEN%|$${t}|" -e "s|%VERSION%|"${VER}"|" \
|
||||||
-e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \
|
-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
|
pathnames.h: ${TOP}/.settings Makefile pathtemplate.h
|
||||||
rm -f pathnames.h
|
rm -f pathnames.h
|
||||||
|
@ -159,7 +159,7 @@ nslookup_yy_input(buf, result, max_size, intr)
|
|||||||
%}
|
%}
|
||||||
WS [ \t]
|
WS [ \t]
|
||||||
FLET [A-Za-z0-9.*\\_]
|
FLET [A-Za-z0-9.*\\_]
|
||||||
LET [A-Za-z0-9.*]
|
LET [A-Za-z0-9.*_]
|
||||||
NAME [A-Za-z0-9.*=_/-]
|
NAME [A-Za-z0-9.*=_/-]
|
||||||
%%
|
%%
|
||||||
^{WS}*server{WS}+{LET}{NAME}*{WS}*$ {
|
^{WS}*server{WS}+{LET}{NAME}*{WS}*$ {
|
||||||
@ -196,10 +196,6 @@ NAME [A-Za-z0-9.*=_/-]
|
|||||||
Finger(yytext, 0);
|
Finger(yytext, 0);
|
||||||
return(1);
|
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}*$ {
|
^{WS}*ls{WS}+(("-a"|"-d"|"-h"|"-m"|"-s"){WS}+)?{LET}{NAME}*{WS}+>>?{WS}+{NAME}+{WS}*$ {
|
||||||
/*
|
/*
|
||||||
* 2nd arg.
|
* 2nd arg.
|
||||||
|
@ -78,7 +78,7 @@ char copyright[] =
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static const char sccsid[] = "@(#)main.c 5.42 (Berkeley) 3/3/91";
|
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 */
|
#endif /* not lint */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -172,7 +172,7 @@ jmp_buf env;
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Browser command for help and view.
|
* Browser command for help.
|
||||||
*/
|
*/
|
||||||
char *pager;
|
char *pager;
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
/* $FreeBSD$ */
|
/* $FreeBSD$ */
|
||||||
#ifndef PORT_AFTER_H
|
#ifndef PORT_AFTER_H
|
||||||
#define PORT_AFTER_H
|
#define PORT_AFTER_H
|
||||||
#define CAN_RECONNECT
|
|
||||||
#define USE_POSIX
|
#define USE_POSIX
|
||||||
#define POSIX_SIGNALS
|
#define POSIX_SIGNALS
|
||||||
#define USE_UTIME
|
#define USE_UTIME
|
||||||
|
Loading…
x
Reference in New Issue
Block a user