pkgsrc/mail/smtpfeed/patches/patch-ae
taca eb4e3f21ac Add patches for reduce/resolve compile problem with gcc-4, especially
on NetBSD/powerpc reported by Makoto Fujiwara.

These patches are slightly aggressive adding most of proto type.
So, please report me if there is any problem.

No PKGREVISION bump since it should change nothing for binary package.
2006-07-23 15:00:41 +00:00

1089 lines
28 KiB
Text

$NetBSD: patch-ae,v 1.1 2006/07/23 15:00:41 taca Exp $
--- dns.c.orig 2002-03-15 11:03:39.000000000 +0900
+++ dns.c
@@ -79,6 +79,19 @@
# define RES_INSECURE1 0x00000400 /* type 1 security disabled */
#endif
+static int query_domain P((char *, int));
+static int process_query P((int));
+static int make_query P((struct dns_stat *, int));
+#if INET6
+static int whichserver P((const SockAddr *));
+#else
+static int whichserver P((const struct sockaddr_in *));
+#endif
+static void got_answer P((struct query_chain *, u_char *, int));
+static void remove_query P((struct query_chain *));
+static struct mx* newmx P((char *, int, int, struct domain *, long));
+static void show_query P((u_char *, u_char *, u_char *));
+
int
pregetmx(dl)
struct domain *dl;
@@ -87,7 +100,6 @@
char **map_arg;
long stime, etime;
int n;
- static int query_domain(), process_query();
#ifdef INET6
SockAddr dsin; /* dummy */
#endif
@@ -109,7 +121,7 @@
}
}
- log(LOG_DEBUG, "start getting MXRRs with caching");
+ mylog(LOG_DEBUG, "start getting MXRRs with caching");
n = 0;
stime = time(NULL);
if (env.queueid != NULL)
@@ -120,7 +132,7 @@
if (cnf.pgateway != NULL)
{
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "pregetting A of protocol gateway: %s",
+ mylog(LOG_DEBUG, "pregetting A of protocol gateway: %s",
cnf.pgateway);
#ifdef INET6
if (cnf.inetdom & SMTP_V4)
@@ -144,7 +156,7 @@
if (cnf.fallbackmx != NULL)
{
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "pregetting A of fallbackmx: %s",
+ mylog(LOG_DEBUG, "pregetting A of fallbackmx: %s",
cnf.fallbackmx);
#ifdef INET6
if (cnf.inetdom & SMTP_V4)
@@ -185,7 +197,7 @@
#endif
{
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG,
+ mylog(LOG_DEBUG,
"pregetting A of sourceIP: %s", p);
#ifdef INET6
if (cnf.inetdom & SMTP_V4)
@@ -243,7 +255,7 @@
|| (strcasecmp(*map_arg, "MX?") == 0))
{
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "pregetting MX: %s", dp->name);
+ mylog(LOG_DEBUG, "pregetting MX: %s", dp->name);
if (query_domain(dp->name, T_MX) < 0)
return -1;
n++;
@@ -251,7 +263,7 @@
else if (strcasecmp(*map_arg, "A") == 0)
{
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "pregetting A: %s", dp->name);
+ mylog(LOG_DEBUG, "pregetting A: %s", dp->name);
#ifdef INET6
if (cnf.inetdom & SMTP_V4)
{
@@ -272,7 +284,7 @@
else if (**map_arg != '[')
{
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "pregetting MX: %s", *map_arg);
+ mylog(LOG_DEBUG, "pregetting MX: %s", *map_arg);
if (query_domain(*map_arg, T_MX) < 0)
return -1;
n++;
@@ -291,7 +303,7 @@
goto skip_preget_a;
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG,
+ mylog(LOG_DEBUG,
"pregetting A of sourceIP: %s",
(*map_arg) + 1);
#ifdef INET6
@@ -333,16 +345,16 @@
else
setproctitle("syncing MX: %d", n);
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "syncing responses of MXRRs");
+ mylog(LOG_DEBUG, "syncing responses of MXRRs");
if (process_query(1) < 0) /* sync */
return -1;
etime = time(NULL);
- log(LOG_DEBUG, "got MXRRs: %d MXs in %d seconds",
+ mylog(LOG_DEBUG, "got MXRRs: %d MXs in %d seconds",
n, etime - stime);
}
else
{
- log(LOG_DEBUG, "no MXRRs to sync");
+ mylog(LOG_DEBUG, "no MXRRs to sync");
}
return 0;
}
@@ -353,7 +365,6 @@
int type;
{
struct dns_stat *qrp, **hashp;
- static int make_query();
qrp = hash_query_lookup(name, &hashp);
if (qrp == NULL) {
@@ -361,7 +372,7 @@
bzero(qrp, sizeof(struct dns_stat));
if (qrp == NULL)
{
- log(LOG_NOTICE, "out of memory (dns_query)");
+ mylog(LOG_NOTICE, "out of memory (dns_query)");
return -1;
}
qrp->name = newstr(name);
@@ -375,7 +386,7 @@
case T_AAAA:
break;
default:
- log(LOG_NOTICE, "query_domain: unknown query type: %d", type);
+ mylog(LOG_NOTICE, "query_domain: unknown query type: %d", type);
return 0;
}
@@ -396,7 +407,6 @@
u_char buf[MAXPACKET];
int n;
struct query_chain *qchain;
- static int process_query();
switch (type) {
case T_MX:
@@ -419,7 +429,7 @@
{
/* already got */
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "ignore request n=%s t=%d",
+ mylog(LOG_DEBUG, "ignore request n=%s t=%d",
qrp->name, type);
return 0;
}
@@ -439,18 +449,18 @@
{
/* already in processing */
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "skip request n=%s t=%d", qrp->name, type);
+ mylog(LOG_DEBUG, "skip request n=%s t=%d", qrp->name, type);
return 0;
}
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "res_mkquery n=%s t=%d", qrp->name, type);
+ mylog(LOG_DEBUG, "res_mkquery n=%s t=%d", qrp->name, type);
n = res_mkquery(QUERY, qrp->name, C_IN, type, NULL, 0, NULL,
buf, sizeof(buf));
if (n <= 0)
{
/* error */
- log(LOG_NOTICE, "res_mkquery failed for %s type %d",
+ mylog(LOG_NOTICE, "res_mkquery failed for %s type %d",
qrp->name, type);
return -1;
}
@@ -459,7 +469,7 @@
if (qchain == NULL)
{
/* error */
- log(LOG_NOTICE, "out of memory (make_query)");
+ mylog(LOG_NOTICE, "out of memory (make_query)");
return -1;
}
bzero(qchain, sizeof(struct query_chain));
@@ -469,7 +479,7 @@
if (qchain->request == NULL)
{
/* error */
- log(LOG_NOTICE, "out of memory (make_query)");
+ mylog(LOG_NOTICE, "out of memory (make_query)");
return -1;
}
bcopy(buf, qchain->request, n);
@@ -492,7 +502,7 @@
qchain->prev = NULL;
query_chain_count++;
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: query concurrency = %d", query_chain_count);
+ mylog(LOG_DEBUG, "DNS: query concurrency = %d", query_chain_count);
if (sti.maxcquery < query_chain_count)
sti.maxcquery = query_chain_count;
@@ -501,10 +511,10 @@
{
struct query_chain *qcp;
- log(LOG_DEBUG, "Chain after linked:");
+ mylog(LOG_DEBUG, "Chain after linked:");
for (qcp = QueryChain; qcp != NULL; qcp = qcp->next)
{
- log(LOG_DEBUG, " %s", qcp->stat->name);
+ mylog(LOG_DEBUG, " %s", qcp->stat->name);
}
}
#endif
@@ -514,7 +524,7 @@
return 0;
}
-int
+static int
whichserver(inp)
#if INET6
const SockAddr *inp;
@@ -591,14 +601,12 @@
char nbuf[MAXDNAME+1];
struct dns_stat *qrp;
int pending;
- static void got_answer();
- static void remove_query();
if (sync == 0 && cnf.cquery_max != 0
&& query_chain_count >= cnf.cquery_max)
{
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "reached to max concurrency (%d)....syncing",
+ mylog(LOG_DEBUG, "reached to max concurrency (%d)....syncing",
query_chain_count);
sync = -1;
}
@@ -612,7 +620,7 @@
s = socket(AF_INET, SOCK_DGRAM, PF_UNSPEC);
if (s < 0) {
/* error */
- log(LOG_NOTICE,
+ mylog(LOG_NOTICE,
"socket failed (process_query)");
return -1;
}
@@ -622,7 +630,7 @@
s6 = socket(AF_INET6, SOCK_DGRAM, PF_UNSPEC);
if (s6 < 0) {
/* error */
- log(LOG_NOTICE,
+ mylog(LOG_NOTICE,
"socket(INET6) failed (process_query)");
return -1;
}
@@ -633,7 +641,7 @@
s = socket(AF_INET, SOCK_DGRAM, PF_UNSPEC);
if (s < 0) {
/* error */
- log(LOG_NOTICE, "socket failed (process_query)");
+ mylog(LOG_NOTICE, "socket failed (process_query)");
return -1;
}
}
@@ -663,14 +671,14 @@
nextqcp = qcp->next;
remove_query(qcp);
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: no valid ns, removing %s type %d",
+ mylog(LOG_DEBUG, "DNS: no valid ns, removing %s type %d",
qcp->stat->name, qcp->type);
qcp = nextqcp;
continue;
}
qcp->try++;
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: retry count=%d", qcp->try);
+ mylog(LOG_DEBUG, "DNS: retry count=%d", qcp->try);
}
}
if (qcp->try >= (u_char)_res.retry)
@@ -680,7 +688,7 @@
nextqcp = qcp->next;
remove_query(qcp);
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: no valid ns, removing %s type %d",
+ mylog(LOG_DEBUG, "DNS: no valid ns, removing %s type %d",
qcp->stat->name, qcp->type);
qcp = nextqcp;
continue;
@@ -689,7 +697,7 @@
{
itvl = _res.retrans << qcp->try;
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: waiting %d sec.", itvl);
+ mylog(LOG_DEBUG, "DNS: waiting %d sec.", itvl);
if (qcp->try > 0)
itvl /= _res.nscount;
if (itvl <= 0)
@@ -700,7 +708,7 @@
if (nsap->in.sin_family == AF_INET)
{
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "send query n=%s t=%d (s=%s)",
+ mylog(LOG_DEBUG, "send query n=%s t=%d (s=%s)",
qcp->stat->name, qcp->type,
inet_ntoa(nsap->in.sin_addr));
@@ -711,7 +719,7 @@
{
qcp->badns |= 1<<qcp->ns;
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "sendto failed: invalid ns (%s)", strerror(errno));
+ mylog(LOG_DEBUG, "sendto failed: invalid ns (%s)", strerror(errno));
}
}
if (nsap->in6.sin6_family == AF_INET6)
@@ -722,7 +730,7 @@
{
inet_ntop(AF_INET6, &nsap->in6.sin6_addr,
buf, sizeof(buf));
- log(LOG_DEBUG, "send query n=%s t=%d (s=%s)",
+ mylog(LOG_DEBUG, "send query n=%s t=%d (s=%s)",
qcp->stat->name, qcp->type, buf);
}
@@ -733,13 +741,13 @@
{
qcp->badns |= 1<<qcp->ns;
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "sendto failed: invalid ns (%s)", strerror(errno));
+ mylog(LOG_DEBUG, "sendto failed: invalid ns (%s)", strerror(errno));
}
}
#else
nsap = &NSADDR_LIST(qcp->ns);
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "send query n=%s t=%d (s=%s)",
+ mylog(LOG_DEBUG, "send query n=%s t=%d (s=%s)",
qcp->stat->name, qcp->type,
inet_ntoa(nsap->sin_addr));
@@ -749,7 +757,7 @@
{
qcp->badns |= 1<<qcp->ns;
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "sendto failed: invalid ns");
+ mylog(LOG_DEBUG, "sendto failed: invalid ns");
}
#endif
sti.nqueries++;
@@ -793,7 +801,7 @@
timeout.tv_usec = 0;
}
if ((cnf.debug & DEBUG_DNS) && (timeout.tv_sec > 0))
- log(LOG_DEBUG, "DNS: waiting %d sec in %s mode",
+ mylog(LOG_DEBUG, "DNS: waiting %d sec in %s mode",
timeout.tv_sec, sync?"sync":"nosync");
FD_ZERO(&dsmask);
#if INET6
@@ -825,7 +833,7 @@
resplen = recvfrom(s, &answer, anssiz, 0,
(struct sockaddr *)&from, &fromlen);
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: got answer from %s",
+ mylog(LOG_DEBUG, "DNS: got answer from %s",
inet_ntoa(from.in.sin_addr));
}
else if (s6 >= 0 && FD_ISSET(s6, &dsmask))
@@ -838,7 +846,7 @@
{
inet_ntop(AF_INET6, &from.in6.sin6_addr,
buf, sizeof(buf));
- log(LOG_DEBUG,
+ mylog(LOG_DEBUG,
"DNS: got answer from %s", buf);
}
}
@@ -846,19 +854,20 @@
resplen = recvfrom(s, &answer, anssiz, 0,
(struct sockaddr *)&from, &fromlen);
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: got answer from %s",
+ mylog(LOG_DEBUG, "DNS: got answer from %s",
inet_ntoa(from.sin_addr));
#endif
if (0) {
show_query("DNS: answer received",
- &answer, &answer+resplen);
+ (u_char *)&answer,
+ (u_char *)&answer+resplen);
}
now = time(NULL);
if (resplen <= 0) {
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: bad anssiz %d",
+ mylog(LOG_DEBUG, "DNS: bad anssiz %d",
resplen);
continue; /* error */
}
@@ -870,7 +879,7 @@
if (!(_res.options & RES_INSECURE1))
{
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG,
+ mylog(LOG_DEBUG,
"DNS: not from our server");
continue;
}
@@ -888,14 +897,15 @@
GETSHORT(class, ap);
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: got answer for %s type %d",
+ mylog(LOG_DEBUG, "DNS: got answer for %s type %d",
nbuf, type);
qrp = hash_query_lookup(nbuf, NULL);
if (qrp == NULL)
{
show_query("DNS: no associated query sent",
- &answer, &answer+resplen);
+ (u_char *)&answer,
+ (u_char *)&answer+resplen);
continue; /* no associated request */
}
qcp = qrp->requests;
@@ -904,7 +914,8 @@
if (qcp == NULL)
{
show_query("DNS: no associated query",
- &answer, &answer+resplen);
+ (u_char *)&answer,
+ (u_char *)&answer+resplen);
continue; /* no associated request */
}
@@ -915,7 +926,7 @@
{
qcp->badns |= (1<<ns);
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: badnsF rcode=%d %x/%x",
+ mylog(LOG_DEBUG, "DNS: badnsF rcode=%d %x/%x",
hp->rcode,
qcp->badns, (1<<_res.nscount)-1);
if (qcp->badns != (1<<_res.nscount)-1)
@@ -924,7 +935,7 @@
qrp->rr_timeout |= qcp->need;
remove_query(qcp);
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: TCP requested, removing %s type %d",
+ mylog(LOG_DEBUG, "DNS: TCP requested, removing %s type %d",
qcp->stat->name, qcp->type);
continue;
}
@@ -933,7 +944,7 @@
qrp->rr_timeout |= qcp->need;
remove_query(qcp);
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: TCP requested, removing %s type %d",
+ mylog(LOG_DEBUG, "DNS: TCP requested, removing %s type %d",
qcp->stat->name, qcp->type);
continue;
}
@@ -952,7 +963,7 @@
if (sync != 0) {
pending = 0;
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: sync: get nearest timeout from %d", now);
+ mylog(LOG_DEBUG, "DNS: sync: get nearest timeout from %d", now);
for (qcp = QueryChain; qcp != NULL;)
{
if (qcp->try >= (u_char)_res.retry)
@@ -962,7 +973,7 @@
nextqcp = qcp->next;
remove_query(qcp);
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: sync timeout (n=%s, t=%d)",
+ mylog(LOG_DEBUG, "DNS: sync timeout (n=%s, t=%d)",
qcp->stat->name, qcp->type);
qcp = nextqcp;
continue;
@@ -970,7 +981,7 @@
pending++;
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: event timeout=%d", qcp->time);
+ mylog(LOG_DEBUG, "DNS: event timeout=%d", qcp->time);
qcp = qcp->next;
}
if (sync < 0)
@@ -978,7 +989,7 @@
if (pending)
{
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: retry in sync mode");
+ mylog(LOG_DEBUG, "DNS: retry in sync mode");
/* sleep(1); * XXX */
goto again;
}
@@ -989,12 +1000,12 @@
nextqcp = qcp->next;
remove_query(qcp);
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: final timeout (n=%s, t=%d)",
+ mylog(LOG_DEBUG, "DNS: final timeout (n=%s, t=%d)",
qcp->stat->name, qcp->type);
qcp = nextqcp;
}
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: closing socket");
+ mylog(LOG_DEBUG, "DNS: closing socket");
#if INET6
if (s >= 0)
{
@@ -1038,10 +1049,10 @@
#if 0
if (cnf.debug & DEBUG_DNS)
{
- log(LOG_DEBUG, "Chain after removed:");
+ mylog(LOG_DEBUG, "Chain after removed:");
for (qcp = QueryChain; qcp != NULL; qcp = qcp->next)
{
- log(LOG_DEBUG, " %s", qcp->stat->name);
+ mylog(LOG_DEBUG, " %s", qcp->stat->name);
}
}
#endif
@@ -1070,7 +1081,7 @@
remove_query(qcp);
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: got answer, removing %s type %d",
+ mylog(LOG_DEBUG, "DNS: got answer, removing %s type %d",
qcp->stat->name, qcp->type);
b = (u_char *) answer;
@@ -1087,7 +1098,7 @@
if (hp->aa == 0 && hp->ra == 0) {
/* this nameserver does not support recursion */
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "non recursive ns=%d", qcp->ns);
+ mylog(LOG_DEBUG, "non recursive ns=%d", qcp->ns);
qcp->badns |= 1<<qcp->ns;
return;
}
@@ -1097,7 +1108,7 @@
{
/* host not found */
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: host (any other data) not found");
+ mylog(LOG_DEBUG, "DNS: host (any other data) not found");
qcp->stat->rr_noex = RR_ALL;
return;
@@ -1108,7 +1119,7 @@
{
/* no data, other data exist */
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: no data for %d", qcp->type);
+ mylog(LOG_DEBUG, "DNS: no data for %d", qcp->type);
if (qcp->type == T_ANY)
{
@@ -1152,7 +1163,7 @@
}
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: valid data");
+ mylog(LOG_DEBUG, "DNS: valid data");
while (qdcount--)
{
@@ -1160,7 +1171,7 @@
ap += n;
if (ap + INT16SZ*2 > eom)
{
- /* log(LOG_NOTICE, "corrupt DNS answer"); */
+ /* mylog(LOG_NOTICE, "corrupt DNS answer"); */
return;
}
GETSHORT(type, ap);
@@ -1180,7 +1191,7 @@
ap += n;
if (ap + INT16SZ*3 + INT32SZ > eom)
{
- /* log(LOG_NOTICE, "corrupt DNS answer"); */
+ /* mylog(LOG_NOTICE, "corrupt DNS answer"); */
return;
}
GETSHORT(type, ap);
@@ -1189,13 +1200,13 @@
GETSHORT(n, ap);
if (ap + n > eom)
{
- /* log(LOG_NOTICE, "corrupt DNS answer"); */
+ /* mylog(LOG_NOTICE, "corrupt DNS answer"); */
return;
}
if (class != C_IN)
{
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: unexpected class %d in an", class);
+ mylog(LOG_DEBUG, "DNS: unexpected class %d in an", class);
ap += n;
continue;
}
@@ -1229,7 +1240,7 @@
return;
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: got MX for %s, %s p=%d",
+ mylog(LOG_DEBUG, "DNS: got MX for %s, %s p=%d",
nbuf, nbuf2, pref);
qrp->rr_got |= RR_MX;
@@ -1268,7 +1279,7 @@
{
addr_found = 1;
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: got AAAA for %s",
+ mylog(LOG_DEBUG, "DNS: got AAAA for %s",
qcp->stat->name);
qcp->stat->rr_got |= RR_AAAA;
@@ -1278,7 +1289,7 @@
/* may be address for an alias */
cname_found = 0;
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: got aliased (%s) AAAA for %s",
+ mylog(LOG_DEBUG, "DNS: got aliased (%s) AAAA for %s",
nbuf, qcp->stat->name);
qrp = hash_query_lookup(nbuf, NULL);
if (qrp == NULL)
@@ -1309,7 +1320,7 @@
{
addr_found = 1;
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: got A for %s",
+ mylog(LOG_DEBUG, "DNS: got A for %s",
qcp->stat->name);
qcp->stat->rr_got |= RR_A;
@@ -1319,7 +1330,7 @@
cname_found = 0;
/* may be address for an alias */
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: got aliased (%s) A for %s",
+ mylog(LOG_DEBUG, "DNS: got aliased (%s) A for %s",
nbuf, qcp->stat->name);
qrp = hash_query_lookup(nbuf, NULL);
if (qrp == NULL)
@@ -1342,13 +1353,13 @@
return;
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: got CNAME %s for %s",
+ mylog(LOG_DEBUG, "DNS: got CNAME %s for %s",
nbuf2, nbuf);
if (strcasecmp(nbuf, nbuf2) == 0)
{
/* CNAME points back itself, ignore it */
- log(LOG_INFO,
+ mylog(LOG_INFO,
"CNAME %s points back itself (q=%d)",
nbuf, qcp->type);
return;
@@ -1376,7 +1387,7 @@
bzero(qrp2, sizeof(struct dns_stat));
if (qrp2 == NULL)
{
- log(LOG_NOTICE,
+ mylog(LOG_NOTICE,
"out of memory (dns_query)");
return;
}
@@ -1441,13 +1452,13 @@
ap += INT16SZ + INT16SZ + INT32SZ;
if (ap + INT16SZ > eom)
{
- /* log(LOG_NOTICE, "corrupt DNS answer"); */
+ /* mylog(LOG_NOTICE, "corrupt DNS answer"); */
return;
}
GETSHORT(n, ap);
if (ap + n > eom)
{
- /* log(LOG_NOTICE, "corrupt DNS answer"); */
+ /* mylog(LOG_NOTICE, "corrupt DNS answer"); */
return;
}
ap += n;
@@ -1460,13 +1471,13 @@
ap += INT16SZ + INT16SZ + INT32SZ;
if (ap + INT16SZ > eom)
{
- /* log(LOG_NOTICE, "corrupt DNS answer"); */
+ /* mylog(LOG_NOTICE, "corrupt DNS answer"); */
return;
}
GETSHORT(n, ap);
if (ap + n > eom)
{
- /* log(LOG_NOTICE, "corrupt DNS answer"); */
+ /* mylog(LOG_NOTICE, "corrupt DNS answer"); */
return;
}
ap += n;
@@ -1481,7 +1492,7 @@
ap += n;
if (ap + INT16SZ*3 + INT32SZ > eom)
{
- /* log(LOG_NOTICE, "corrupt DNS answer"); */
+ /* mylog(LOG_NOTICE, "corrupt DNS answer"); */
return;
}
GETSHORT(type, ap);
@@ -1490,13 +1501,13 @@
GETSHORT(addrsize, ap);
if (ap + addrsize > eom)
{
- /* log(LOG_NOTICE, "corrupt DNS answer"); */
+ /* mylog(LOG_NOTICE, "corrupt DNS answer"); */
return;
}
if (class != C_IN)
{
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: unexpected class %d in ar", class);
+ mylog(LOG_DEBUG, "DNS: unexpected class %d in ar", class);
ap += addrsize;
continue;
}
@@ -1529,7 +1540,7 @@
}
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: got additional Address RR for %s type=%d",
+ mylog(LOG_DEBUG, "DNS: got additional Address RR for %s type=%d",
nbuf, type);
#if FAKE_AR_CHECK
@@ -1545,7 +1556,7 @@
if (!found)
{
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: ignoring additional Address RR");
+ mylog(LOG_DEBUG, "DNS: ignoring additional Address RR");
ap += addrsize;
continue;
}
@@ -1558,7 +1569,7 @@
bzero(qrp, sizeof(struct dns_stat));
if (qrp == NULL)
{
- log(LOG_NOTICE, "out of memory (dns_query)");
+ mylog(LOG_NOTICE, "out of memory (dns_query)");
return;
}
qrp->name = newstr(nbuf);
@@ -1592,7 +1603,7 @@
bzero(qrp, sizeof(struct dns_stat));
if (qrp == NULL)
{
- log(LOG_NOTICE,
+ mylog(LOG_NOTICE,
"out of memory (dns_query)");
return;
}
@@ -1605,20 +1616,20 @@
if (cnf.inetdom & SMTP_V6 || cnf.v4v6fallback)
{
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: getting AAAA RR for %s",
+ mylog(LOG_DEBUG, "DNS: getting AAAA RR for %s",
mxp->name);
make_query(qrp, T_AAAA);
}
if (cnf.inetdom & SMTP_V4 || cnf.v4v6fallback)
{
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: getting A RR for %s",
+ mylog(LOG_DEBUG, "DNS: getting A RR for %s",
mxp->name);
make_query(qrp, T_A);
}
#else
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: getting A RR for %s",
+ mylog(LOG_DEBUG, "DNS: getting A RR for %s",
mxp->name);
make_query(qrp, T_A);
if (cnf.v4v6fallback)
@@ -1653,7 +1664,7 @@
continue;
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "getting MX for %s", dp->name);
+ mylog(LOG_DEBUG, "getting MX for %s", dp->name);
offset = 0;
needfindaddr = 0;
@@ -1701,15 +1712,15 @@
{
struct mx *mxp;
- log(LOG_DEBUG, "final MX list for %s", dp->name);
+ mylog(LOG_DEBUG, "final MX list for %s", dp->name);
mxp = dp->firstmx;
if (mxp == NULL)
{
- log(LOG_DEBUG, " NO MX!");
+ mylog(LOG_DEBUG, " NO MX!");
}
while (mxp != NULL)
{
- log(LOG_DEBUG, " %s(%d, %d)", mxp->name,
+ mylog(LOG_DEBUG, " %s(%d, %d)", mxp->name,
mxp->pref, mxp->weight);
mxp = mxp->next;
}
@@ -1733,12 +1744,12 @@
int found = 0;
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "protocol gateway checking for %s",
+ mylog(LOG_DEBUG, "protocol gateway checking for %s",
dp->name);
for (mxp = dp->firstmx; mxp != NULL; mxp = mxp->next)
{
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "checking MX: %s", mxp->name);
+ mylog(LOG_DEBUG, "checking MX: %s", mxp->name);
if (mxp->host == NULL)
{
/* no hosts, try next MX */
@@ -1750,7 +1761,7 @@
{
/*
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "proto: %d",
+ mylog(LOG_DEBUG, "proto: %d",
addrp->domain);
*/
#ifdef INET6
@@ -1763,10 +1774,9 @@
#endif
{
struct mx *gwmxp;
- static struct mx* newmx();
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "setting protocol gateway as first MX");
+ mylog(LOG_DEBUG, "setting protocol gateway as first MX");
if ((gwmxp = newmx(cnf.pgateway,
-2, 0, dp, 0))
== NULL)
@@ -1817,7 +1827,7 @@
if (mxpp == NULL)
{
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "linking MX %s(%d) at the top",
+ mylog(LOG_DEBUG, "linking MX %s(%d) at the top",
newmxp->name, newmxp->pref);
domp->firstmx = newmxp;
@@ -1825,7 +1835,7 @@
else
{
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "linking MX %s(%d) after MX %s(%d)",
+ mylog(LOG_DEBUG, "linking MX %s(%d) after MX %s(%d)",
newmxp->name, newmxp->pref,
mxpp->name, mxpp->pref);
@@ -1856,14 +1866,14 @@
{
/* already registered, drop lower one */
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "duplicated MX %s(%d) found",
+ mylog(LOG_DEBUG, "duplicated MX %s(%d) found",
mxp->name, mxp->pref);
if (mxp->pref > pref
|| (mxp->pref == pref && mxp->weight > weight))
{
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "remove it and reuse");
+ mylog(LOG_DEBUG, "remove it and reuse");
if (mxp == dp->firstmx)
dp->firstmx = mxp->next;
@@ -1873,7 +1883,7 @@
else
{
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "leave it and ignore newer");
+ mylog(LOG_DEBUG, "leave it and ignore newer");
return mxp; /* do nothing */
}
@@ -1885,7 +1895,7 @@
mxp = (struct mx*)MALLOC(sizeof(struct mx));
if (mxp == NULL)
{
- log(LOG_NOTICE, "out of memory (newmx)");
+ mylog(LOG_NOTICE, "out of memory (newmx)");
return NULL;
}
bzero(mxp, sizeof(struct mx));
@@ -1922,7 +1932,7 @@
char msgbuf[MAXLINE], *mxname;
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "getmxrr(%s, %s) offset=%d opt=%x",
+ mylog(LOG_DEBUG, "getmxrr(%s, %s) offset=%d opt=%x",
name, dp->name, offset, opt);
if (!query_mx)
@@ -1961,7 +1971,7 @@
if (mxp == NULL)
return -1;
addinetaddress(mxp, AF_INET, sizeof(nsin.in.sin_addr),
- &nsin.in.sin_addr);
+ (u_char *)&nsin.in.sin_addr);
}
#ifdef INET6
else if (inet_pton(INET6, name + 1, &nsin.in6.sin6_addr) > 0)
@@ -1973,7 +1983,7 @@
return -1;
addinetaddress(mxp, AF_INET6,
sizeof(nsin.in6.sin6_addr),
- &nsin.in6.sin6_addr);
+ (u_char *)&nsin.in6.sin6_addr);
}
#endif
else
@@ -1999,7 +2009,7 @@
qrp = qrp->cname;
if (cnf.debug & DEBUG_DNS && cnamechain > 0)
- log(LOG_DEBUG, "CNAME traced: %s", qrp->name);
+ mylog(LOG_DEBUG, "CNAME traced: %s", qrp->name);
if (cnamechain >= CNAMELOOPMAX)
{
@@ -2009,7 +2019,7 @@
}
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "%s: timeout=%x noex=%x got=%x",
+ mylog(LOG_DEBUG, "%s: timeout=%x noex=%x got=%x",
qrp->name, qrp->rr_timeout, qrp->rr_noex, qrp->rr_got);
if (qrp == NULL || qrp->rr_timeout & RR_MX) {
@@ -2044,7 +2054,7 @@
return -1;
}
else
- log(LOG_INFO, "No MX/A on %s for %s; ignored",
+ mylog(LOG_INFO, "No MX/A on %s for %s; ignored",
name, dp->name);
return 0;
}
@@ -2089,12 +2099,12 @@
mxname = cmxp->name;
#if 0
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "mx=%s pref=%d", mxname, cmxp->pref);
+ mylog(LOG_DEBUG, "mx=%s pref=%d", mxname, cmxp->pref);
#endif
if (isamyalias(mxname))
{
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "found localhost (%s) in MX list",
+ mylog(LOG_DEBUG, "found localhost (%s) in MX list",
mxname);
if (!seenlocal || cmxp->pref < localpref)
localpref = cmxp->pref;
@@ -2136,13 +2146,13 @@
/* already registered, drop lower one */
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "duplicated MX %s(%d) found",
+ mylog(LOG_DEBUG, "duplicated MX %s(%d) found",
mxp->name, mxp->pref);
if (mxp->pref > offset + cmxp->pref)
{
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "remove it for re-link");
+ mylog(LOG_DEBUG, "remove it for re-link");
mxp->pref = offset + cmxp->pref;
if (mxp == dp->firstmx)
dp->firstmx = mxp->next;
@@ -2220,6 +2230,7 @@
return 0;
}
+static void
show_query(t, b, e)
u_char *t, *b, *e;
{
@@ -2246,13 +2257,13 @@
ap += n;
if (ap + INT16SZ*2 > eom)
{
- /* log(LOG_NOTICE, "corrupt DNS answer"); */
+ /* mylog(LOG_NOTICE, "corrupt DNS answer"); */
return;
}
GETSHORT(class, ap);
GETSHORT(type, ap);
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "%s: %s(%d,%d), rcode=%d",
+ mylog(LOG_DEBUG, "%s: %s(%d,%d), rcode=%d",
t, nbuf, class, type, ntohs(hp->rcode));
}
@@ -2267,7 +2278,7 @@
ap += n;
if (ap + INT16SZ*3 + INT32SZ > eom)
{
- /* log(LOG_NOTICE, "corrupt DNS answer"); */
+ /* mylog(LOG_NOTICE, "corrupt DNS answer"); */
return;
}
GETSHORT(class, ap);
@@ -2276,13 +2287,13 @@
GETSHORT(n, ap);
if (ap + n > eom)
{
- /* log(LOG_NOTICE, "corrupt DNS answer"); */
+ /* mylog(LOG_NOTICE, "corrupt DNS answer"); */
return;
}
if (class != C_IN)
{
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "DNS: unexpected class %d in an", class);
+ mylog(LOG_DEBUG, "DNS: unexpected class %d in an", class);
ap += n;
continue;
}
@@ -2293,20 +2304,20 @@
break;
ap += n;
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "got MX pref=%d,host=(%s)", pref, nbuf);
+ mylog(LOG_DEBUG, "got MX pref=%d,host=(%s)", pref, nbuf);
#if 0 /* for debug */
hep = gethostbyname(nbuf);
if (hep == NULL) {
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "get A -- h_errno=%d", h_errno);
+ mylog(LOG_DEBUG, "get A -- h_errno=%d", h_errno);
} else {
if (cnf.debug & DEBUG_DNS)
- log(LOG_DEBUG, "get A -- OK");
+ mylog(LOG_DEBUG, "get A -- OK");
}
#endif
} else {
ap += n;
- /* log(LOG_DEBUG, "unexpected answer type: %d", type); */
+ /* mylog(LOG_DEBUG, "unexpected answer type: %d", type); */
}
}
}