Commit Diff
Diff:
a042435d6c61780f70670dd56d06f8a7cccdd5d7
4cc84fc52a3567bfe7142fcc259d74fd4f0cc45b
Commit:
4cc84fc52a3567bfe7142fcc259d74fd4f0cc45b
Tree:
660c903f218b4c68b4e48a3ccebcffefcb5a0f09
Author:
pbug <pbug@delphinusdns.org>
Committer:
pbug <pbug@delphinusdns.org>
Date:
Fri Mar 19 17:21:00 2010 UTC
Message:
* nameserver delegations revisited, apparently I didn't do enough, hopefully this big patch will make it work.
blob - 88f0cac8892da9b97f1510fbf86e85bb4831ae3f
blob + 46795f80b97f50bf57ddd448df1c625b9e8039da
--- main.c
+++ main.c
@@ -103,7 +103,7 @@ struct tcps {
} *tn1, *tn2, *tnp;
-static const char rcsid[] = "$Id: main.c,v 1.40 2010/03/19 11:36:52 pbug Exp $";
+static const char rcsid[] = "$Id: main.c,v 1.41 2010/03/19 17:21:00 pbug Exp $";
/*
* MAIN - set up arguments, set up database, set up sockets, call mainloop
@@ -890,6 +890,7 @@ lookup_zone(DB *db, struct question *question, struct
int plen, onemore = 0;
int ret = 0;
int returnval;
+ int wildcarding = 0;
char *wildlookup = "*";
char *p;
@@ -933,8 +934,7 @@ lookup_zone(DB *db, struct question *question, struct
*/
if (Wflag) {
- *lzerrno = ERR_NXDOMAIN;
- return -1;
+ wildcarding = 1;
}
/* next label */
@@ -957,7 +957,21 @@ lookup_zone(DB *db, struct question *question, struct
memcpy((char *)sd, (char *)data.data, data.size);
snprintf(replystring, DNS_MAXNAME, "%s", sd->zonename);
+ if (Wflag) {
+ if (wildcarding && !sd->ns_delegate) {
+ *lzerrno = ERR_NXDOMAIN;
+ return -1;
+ }
+ }
+ if (sd->ns_delegate == 1) {
+ syslog(LOG_INFO, "boo\n");
+ returnval = DNS_TYPE_NS;
+ *lzerrno = ERR_NOERROR;
+ goto out;
+ }
+
+
switch (ntohs(question->hdr->qtype)) {
case DNS_TYPE_A:
if ((sd->flags & DOMAIN_HAVE_A) ==
@@ -1071,6 +1085,10 @@ lookup_zone(DB *db, struct question *question, struct
memcpy((char *)sd, (char *)data.data, data.size);
+ if (sd->ns_delegate) {
+ returnval = DNS_TYPE_NS;
+ goto out;
+ }
switch (ntohs(question->hdr->qtype)) {
case DNS_TYPE_A:
@@ -1155,6 +1173,7 @@ lookup_zone(DB *db, struct question *question, struct
snprintf(replystring, DNS_MAXNAME, "*");
}
+out:
return returnval;
}
@@ -1583,6 +1602,7 @@ mainloop(int *udp, int *tcp, int sockcount, char **ide
fakequestion = NULL;
if ((type0 = lookup_zone(db, question, &sd0, &lzerrno, (char *)&replystring)) < 0) {
+
switch (lzerrno) {
default:
syslog(LOG_INFO, "invalid lzerrno! dropping");
@@ -1616,7 +1636,6 @@ mainloop(int *udp, int *tcp, int sockcount, char **ide
}
}
-
switch (type0) {
case 0:
/*
@@ -1679,6 +1698,11 @@ tcpnxdomain:
fromlen, &sd0, ((type1 > 0) ? &sd1 : NULL), \
tnp->region, istcp);
reply_cname(&sreply);
+ } else if (type0 == DNS_TYPE_NS) {
+ BUILD_REPLY(sreply, so, pbuf, len, question, from, \
+ fromlen, &sd0, NULL, tnp->region, istcp);
+ reply_ns(&sreply, db);
+ break;
} else if (type0 == DNS_TYPE_A) {
BUILD_REPLY(sreply, so, pbuf, len, question, from, \
fromlen, &sd0, NULL, tnp->region, istcp);
@@ -1694,6 +1718,11 @@ tcpnxdomain:
fromlen, &sd0, ((type1 > 0) ? &sd1 : NULL), \
tnp->region, istcp);
reply_cname(&sreply);
+ } else if (type0 == DNS_TYPE_NS) {
+ BUILD_REPLY(sreply, so, pbuf, len, question, from, \
+ fromlen, &sd0, NULL, tnp->region, istcp);
+ reply_ns(&sreply, db);
+ break;
} else if (type0 == DNS_TYPE_AAAA) {
BUILD_REPLY(sreply, so, pbuf, len, question, from,
fromlen, &sd0, NULL, tnp->region, istcp);
@@ -1709,6 +1738,11 @@ tcpnxdomain:
fromlen, &sd0, ((type1 > 0) ? &sd1 : NULL), \
tnp->region, istcp);
reply_cname(&sreply);
+ } else if (type0 == DNS_TYPE_NS) {
+ BUILD_REPLY(sreply, so, pbuf, len, question, from, \
+ fromlen, &sd0, NULL, tnp->region, istcp);
+ reply_ns(&sreply, db);
+ break;
} else if (type0 == DNS_TYPE_MX) {
BUILD_REPLY(sreply, so, pbuf, len, question, from, \
fromlen, &sd0, NULL, tnp->region, istcp);
@@ -1722,6 +1756,11 @@ tcpnxdomain:
BUILD_REPLY(sreply, so, pbuf, len, question, from, \
fromlen, &sd0, NULL, tnp->region, istcp);
reply_soa(&sreply);
+ } else if (type0 == DNS_TYPE_NS) {
+ BUILD_REPLY(sreply, so, pbuf, len, question, from, \
+ fromlen, &sd0, NULL, tnp->region, istcp);
+ reply_ns(&sreply, db);
+ break;
}
break;
case DNS_TYPE_NS:
@@ -1738,6 +1777,11 @@ tcpnxdomain:
BUILD_REPLY(sreply, so, pbuf, len, question, from, \
fromlen, &sd0, NULL, tnp->region, istcp);
reply_cname(&sreply);
+ } else if (type0 == DNS_TYPE_NS) {
+ BUILD_REPLY(sreply, so, pbuf, len, question, from, \
+ fromlen, &sd0, NULL, tnp->region, istcp);
+ reply_ns(&sreply, db);
+ break;
}
break;
@@ -1747,6 +1791,11 @@ tcpnxdomain:
fromlen, &sd0, ((type1 > 0) ? &sd1 : NULL) \
, tnp->region, istcp);
reply_cname(&sreply);
+ } else if (type0 == DNS_TYPE_NS) {
+ BUILD_REPLY(sreply, so, pbuf, len, question, from, \
+ fromlen, &sd0, NULL, tnp->region, istcp);
+ reply_ns(&sreply, db);
+ break;
} else if (type0 == DNS_TYPE_PTR) {
BUILD_REPLY(sreply, so, pbuf, len, question, from,
fromlen, &sd0, NULL, tnp->region, istcp);
@@ -1758,13 +1807,25 @@ tcpnxdomain:
default:
/*
- * ANY unkown RR TYPE gets a NOTIMPL
+ * ANY unknown RR TYPE gets a NOTIMPL
*/
- BUILD_REPLY(sreply, so, pbuf, len, question, from, \
+ /*
+ * except for delegations
+ */
+
+ if (type0 == DNS_TYPE_NS) {
+ BUILD_REPLY(sreply, so, pbuf, len, question, from, \
+ fromlen, &sd0, NULL, aregion, istcp);
+ reply_ns(&sreply, db);
+ } else {
+
+ BUILD_REPLY(sreply, so, pbuf, len, question, from, \
fromlen, NULL, NULL, tnp->region, istcp);
- reply_notimpl(&sreply);
- snprintf(replystring, DNS_MAXNAME, "NOTIMPL");
+
+ reply_notimpl(&sreply);
+ snprintf(replystring, DNS_MAXNAME, "NOTIMPL");
+ }
break;
}
@@ -1894,6 +1955,7 @@ tcpnxdomain:
fakequestion = NULL;
if ((type0 = lookup_zone(db, question, &sd0, &lzerrno, (char *)&replystring)) < 0) {
+ syslog(LOG_INFO, "boo5");
switch (lzerrno) {
default:
syslog(LOG_INFO, "invalid lzerrno! dropping");
@@ -1927,7 +1989,7 @@ tcpnxdomain:
}
}
-
+ syslog(LOG_INFO, "boo6");
switch (type0) {
case 0:
/*
@@ -1990,6 +2052,11 @@ udpnxdomain:
fromlen, &sd0, ((type1 > 0) ? &sd1 : NULL), \
aregion, istcp);
reply_cname(&sreply);
+ } else if (type0 == DNS_TYPE_NS) {
+ BUILD_REPLY(sreply, so, buf, len, question, from, \
+ fromlen, &sd0, NULL, aregion, istcp);
+ reply_ns(&sreply, db);
+ break;
} else if (type0 == DNS_TYPE_A) {
BUILD_REPLY(sreply, so, buf, len, question, from, \
fromlen, &sd0, NULL, aregion, istcp);
@@ -2005,6 +2072,11 @@ udpnxdomain:
fromlen, &sd0, ((type1 > 0) ? &sd1 : NULL), \
aregion, istcp);
reply_cname(&sreply);
+ } else if (type0 == DNS_TYPE_NS) {
+ BUILD_REPLY(sreply, so, buf, len, question, from, \
+ fromlen, &sd0, NULL, aregion, istcp);
+ reply_ns(&sreply, db);
+ break;
} else if (type0 == DNS_TYPE_AAAA) {
BUILD_REPLY(sreply, so, buf, len, question, from,
fromlen, &sd0, NULL, aregion, istcp);
@@ -2020,6 +2092,11 @@ udpnxdomain:
fromlen, &sd0, ((type1 > 0) ? &sd1 : NULL), \
aregion, istcp);
reply_cname(&sreply);
+ } else if (type0 == DNS_TYPE_NS) {
+ BUILD_REPLY(sreply, so, buf, len, question, from, \
+ fromlen, &sd0, NULL, aregion, istcp);
+ reply_ns(&sreply, db);
+ break;
} else if (type0 == DNS_TYPE_MX) {
BUILD_REPLY(sreply, so, buf, len, question, from, \
fromlen, &sd0, NULL, aregion, istcp);
@@ -2033,6 +2110,11 @@ udpnxdomain:
BUILD_REPLY(sreply, so, buf, len, question, from, \
fromlen, &sd0, NULL, aregion, istcp);
reply_soa(&sreply);
+ } else if (type0 == DNS_TYPE_NS) {
+ BUILD_REPLY(sreply, so, buf, len, question, from, \
+ fromlen, &sd0, NULL, aregion, istcp);
+ reply_ns(&sreply, db);
+ break;
}
break;
case DNS_TYPE_NS:
@@ -2049,6 +2131,11 @@ udpnxdomain:
BUILD_REPLY(sreply, so, buf, len, question, from, \
fromlen, &sd0, NULL, aregion, istcp);
reply_cname(&sreply);
+ } else if (type0 == DNS_TYPE_NS) {
+ BUILD_REPLY(sreply, so, buf, len, question, from, \
+ fromlen, &sd0, NULL, aregion, istcp);
+ reply_ns(&sreply, db);
+ break;
}
break;
@@ -2058,6 +2145,11 @@ udpnxdomain:
fromlen, &sd0, ((type1 > 0) ? &sd1 : NULL) \
, aregion, istcp);
reply_cname(&sreply);
+ } else if (type0 == DNS_TYPE_NS) {
+ BUILD_REPLY(sreply, so, buf, len, question, from, \
+ fromlen, &sd0, NULL, aregion, istcp);
+ reply_ns(&sreply, db);
+ break;
} else if (type0 == DNS_TYPE_PTR) {
BUILD_REPLY(sreply, so, buf, len, question, from,
fromlen, &sd0, NULL, aregion, istcp);
@@ -2071,11 +2163,22 @@ udpnxdomain:
/*
* ANY unkown RR TYPE gets a NOTIMPL
*/
+ /*
+ * except for delegations
+ */
+
+ if (type0 == DNS_TYPE_NS) {
+ BUILD_REPLY(sreply, so, buf, len, question, from, \
+ fromlen, &sd0, NULL, aregion, istcp);
+ reply_ns(&sreply, db);
+ } else {
- BUILD_REPLY(sreply, so, buf, len, question, from, \
- fromlen, NULL, NULL, aregion, istcp);
- reply_notimpl(&sreply);
- snprintf(replystring, DNS_MAXNAME, "NOTIMPL");
+
+ BUILD_REPLY(sreply, so, buf, len, question, from, \
+ fromlen, NULL, NULL, aregion, istcp);
+ reply_notimpl(&sreply);
+ snprintf(replystring, DNS_MAXNAME, "NOTIMPL");
+ }
break;
}
blob - abf0ad2f156b6f6576291151181384e0447ec3e3
blob + 11d5c9bab30105fe17b7b66e6b5f875084b368e5
--- reply.c
+++ reply.c
@@ -67,7 +67,7 @@ struct collects {
} *cn1, *cn2, *cnp;
-static const char rcsid[] = "$Id: reply.c,v 1.17 2010/03/19 11:36:52 pbug Exp $";
+static const char rcsid[] = "$Id: reply.c,v 1.18 2010/03/19 17:21:01 pbug Exp $";
/*
* REPLY_A() - replies a DNS question (*q) on socket (so)
@@ -624,7 +624,7 @@ reply_ns(struct sreply *sreply, DB *db)
do {
answer->name[0] = 0xc0;
answer->name[1] = 0x0c;
- answer->type = q->hdr->qtype;
+ answer->type = htons(DNS_TYPE_NS);
answer->class = q->hdr->qclass;
answer->ttl = htonl(sd->ttl);
repomaster@centroid.eu