Upgrade to 9.3.2rc1

This commit is contained in:
jvdias 2005-12-03 00:10:48 +00:00
parent 4330327e1c
commit 207484f5d4
4 changed files with 1591 additions and 0 deletions

313
bind-9.3.2b1-PIE.patch Normal file
View File

@ -0,0 +1,313 @@
--- bind-9.3.2b1/make/rules.in.PIE 2005-05-12 17:36:17.000000000 -0400
+++ bind-9.3.2b1/make/rules.in 2005-10-06 20:04:36.000000000 -0400
@@ -118,6 +118,9 @@
.c.@O@:
${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} -c $<
+.c.o:
+ ${CC} ${ALL_CFLAGS} -c $<
+
SHELL = @SHELL@
LIBTOOL = @LIBTOOL@
LIBTOOL_MODE_COMPILE = ${LIBTOOL} @LIBTOOL_MODE_COMPILE@
--- bind-9.3.2b1/bin/dnssec/Makefile.in.PIE 2005-05-01 20:25:54.000000000 -0400
+++ bind-9.3.2b1/bin/dnssec/Makefile.in 2005-10-06 20:04:36.000000000 -0400
@@ -41,7 +41,7 @@
# Alphabetically
TARGETS = dnssec-keygen@EXEEXT@ dnssec-signzone@EXEEXT@
-OBJS = dnssectool.@O@
+OBJS = dnssectool.o
SRCS = dnssec-keygen.c dnssec-signzone.c dnssectool.c
@@ -51,19 +51,25 @@
MANOBJS = ${MANPAGES} ${HTMLPAGES}
+EXT_CFLAGS = -fPIE
+
@BIND9_MAKE_RULES@
-dnssec-keygen@EXEEXT@: dnssec-keygen.@O@ ${OBJS} ${DEPLIBS}
+LDFLAGS += -pie -Wl,-z,relro,-z,now,-z,nodlopen,-z,noexecstack
+
+.SUFFIXES: .c .o
+
+dnssec-keygen@EXEEXT@: dnssec-keygen.o ${OBJS} ${DEPLIBS}
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
- dnssec-keygen.@O@ ${OBJS} ${LIBS}
+ dnssec-keygen.o ${OBJS} ${LIBS}
-dnssec-signzone.@O@: dnssec-signzone.c
- ${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} -DVERSION=\"${VERSION}\" \
+dnssec-signzone.o: dnssec-signzone.c
+ ${CC} ${ALL_CFLAGS} -DVERSION=\"${VERSION}\" \
-c ${srcdir}/dnssec-signzone.c
-dnssec-signzone@EXEEXT@: dnssec-signzone.@O@ ${OBJS} ${DEPLIBS}
+dnssec-signzone@EXEEXT@: dnssec-signzone.o ${OBJS} ${DEPLIBS}
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
- dnssec-signzone.@O@ ${OBJS} ${LIBS}
+ dnssec-signzone.o ${OBJS} ${LIBS}
doc man:: ${MANOBJS}
--- bind-9.3.2b1/bin/named/Makefile.in.PIE 2004-09-06 17:47:25.000000000 -0400
+++ bind-9.3.2b1/bin/named/Makefile.in 2005-10-06 20:04:36.000000000 -0400
@@ -63,17 +63,17 @@
TARGETS = named@EXEEXT@ lwresd@EXEEXT@
-OBJS = aclconf.@O@ builtin.@O@ client.@O@ config.@O@ control.@O@ \
- controlconf.@O@ interfacemgr.@O@ \
- listenlist.@O@ log.@O@ logconf.@O@ main.@O@ notify.@O@ \
- query.@O@ server.@O@ sortlist.@O@ \
- tkeyconf.@O@ tsigconf.@O@ update.@O@ xfrout.@O@ \
- zoneconf.@O@ \
- lwaddr.@O@ lwresd.@O@ lwdclient.@O@ lwderror.@O@ lwdgabn.@O@ \
- lwdgnba.@O@ lwdgrbn.@O@ lwdnoop.@O@ lwsearch.@O@ \
+OBJS = aclconf.o builtin.o client.o config.o control.o \
+ controlconf.o interfacemgr.o \
+ listenlist.o log.o logconf.o main.o notify.o \
+ query.o server.o sortlist.o \
+ tkeyconf.o tsigconf.o update.o xfrout.o \
+ zoneconf.o \
+ lwaddr.o lwresd.o lwdclient.o lwderror.o lwdgabn.o \
+ lwdgnba.o lwdgrbn.o lwdnoop.o lwsearch.o \
$(DBDRIVER_OBJS)
-UOBJS = unix/os.@O@
+UOBJS = unix/os.o
SRCS = aclconf.c builtin.c client.c config.c control.c \
controlconf.c interfacemgr.c \
@@ -91,16 +91,22 @@
MANOBJS = ${MANPAGES} ${HTMLPAGES}
+EXT_CFLAGS = -fPIE
+
@BIND9_MAKE_RULES@
-main.@O@: main.c
- ${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} \
+LDFLAGS += -pie -Wl,-z,relro,-z,now,-z,nodlopen,-z,noexecstack
+
+.SUFFIXES: .c .o
+
+main.o: main.c
+ ${CC} ${ALL_CFLAGS} \
-DVERSION=\"${VERSION}\" \
-DNS_LOCALSTATEDIR=\"${localstatedir}\" \
-DNS_SYSCONFDIR=\"${sysconfdir}\" -c ${srcdir}/main.c
-config.@O@: config.c
- ${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} \
+config.o: config.c
+ ${CC} ${ALL_CFLAGS} \
-DVERSION=\"${VERSION}\" \
-DNS_LOCALSTATEDIR=\"${localstatedir}\" \
-c ${srcdir}/config.c
--- bind-9.3.2b1/bin/named/unix/Makefile.in.PIE 2004-03-08 04:04:15.000000000 -0500
+++ bind-9.3.2b1/bin/named/unix/Makefile.in 2005-10-06 20:04:36.000000000 -0400
@@ -27,10 +27,14 @@
CDEFINES =
CWARNINGS =
-OBJS = os.@O@
+OBJS = os.o
SRCS = os.c
TARGETS = ${OBJS}
+EXT_CFLAGS = -fPIE
+
@BIND9_MAKE_RULES@
+
+.SUFFIXES: .c .o
\ No newline at end of file
--- bind-9.3.2b1/bin/check/Makefile.in.PIE 2004-07-20 03:01:48.000000000 -0400
+++ bind-9.3.2b1/bin/check/Makefile.in 2005-10-06 20:04:36.000000000 -0400
@@ -55,27 +55,33 @@
MANOBJS = ${MANPAGES} ${HTMLPAGES}
+EXT_CFLAGS = -fPIE
+
@BIND9_MAKE_RULES@
-named-checkconf.@O@: named-checkconf.c
- ${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} \
+LDFLAGS += -pie -Wl,-z,relro,-z,now,-z,nodlopen,-z,noexecstack
+
+.SUFFIXES: .c .o
+
+named-checkconf.o: named-checkconf.c
+ ${CC} ${ALL_CFLAGS} \
-DVERSION=\"${VERSION}\" \
-c ${srcdir}/named-checkconf.c
-named-checkzone.@O@: named-checkzone.c
- ${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} \
+named-checkzone.o: named-checkzone.c
+ ${CC} ${ALL_CFLAGS} \
-DVERSION=\"${VERSION}\" \
-c ${srcdir}/named-checkzone.c
-named-checkconf@EXEEXT@: named-checkconf.@O@ check-tool.@O@ ${ISCDEPLIBS} \
+named-checkconf@EXEEXT@: named-checkconf.o check-tool.o ${ISCDEPLIBS} \
${ISCCFGDEPLIBS} ${BIND9DEPLIBS}
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
- named-checkconf.@O@ check-tool.@O@ ${BIND9LIBS} ${ISCCFGLIBS} \
+ named-checkconf.o check-tool.o ${BIND9LIBS} ${ISCCFGLIBS} \
${DNSLIBS} ${ISCLIBS} ${LIBS}
-named-checkzone@EXEEXT@: named-checkzone.@O@ check-tool.@O@ ${ISCDEPLIBS} ${DNSDEPLIBS}
+named-checkzone@EXEEXT@: named-checkzone.o check-tool.o ${ISCDEPLIBS} ${DNSDEPLIBS}
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
- named-checkzone.@O@ check-tool.@O@ ${DNSLIBS} ${ISCLIBS} ${LIBS}
+ named-checkzone.o check-tool.o ${DNSLIBS} ${ISCLIBS} ${LIBS}
doc man:: ${MANOBJS}
--- bind-9.3.2b1/bin/nsupdate/Makefile.in.PIE 2004-07-20 03:01:49.000000000 -0400
+++ bind-9.3.2b1/bin/nsupdate/Makefile.in 2005-10-06 20:04:36.000000000 -0400
@@ -49,7 +49,7 @@
TARGETS = nsupdate@EXEEXT@
-OBJS = nsupdate.@O@
+OBJS = nsupdate.o
UOBJS =
@@ -61,10 +61,16 @@
MANOBJS = ${MANPAGES} ${HTMLPAGES}
+EXT_CFLAGS = -fPIE
+
@BIND9_MAKE_RULES@
-nsupdate@EXEEXT@: nsupdate.@O@ ${UOBJS} ${DEPLIBS}
- ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ nsupdate.@O@ ${UOBJS} ${LIBS}
+LDFLAGS += -pie -Wl,-z,relro,-z,now,-z,nodlopen,-z,noexecstack
+
+.SUFFIXES: .c .o
+
+nsupdate@EXEEXT@: nsupdate.o ${UOBJS} ${DEPLIBS}
+ ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ nsupdate.o ${UOBJS} ${LIBS}
doc man:: ${MANOBJS}
--- bind-9.3.2b1/bin/rndc/Makefile.in.PIE 2004-07-20 03:01:50.000000000 -0400
+++ bind-9.3.2b1/bin/rndc/Makefile.in 2005-10-06 20:05:10.000000000 -0400
@@ -57,28 +57,34 @@
MANOBJS = ${MANPAGES} ${HTMLPAGES}
-UOBJS = unix/os.@O@
+UOBJS = unix/os.o
+
+EXT_CFLAGS = -fPIE
@BIND9_MAKE_RULES@
-rndc.@O@: rndc.c
- ${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} \
+LDFLAGS += -pie -Wl,-z,relro,-z,now,-z,nodlopen,-z,noexecstack
+
+.SUFFIXES: .c .o
+
+rndc.o: rndc.c
+ ${CC} ${ALL_CFLAGS} \
-DVERSION=\"${VERSION}\" \
-DRNDC_CONFFILE=\"${sysconfdir}/rndc.conf\" \
-DRNDC_KEYFILE=\"${sysconfdir}/rndc.key\" \
-c ${srcdir}/rndc.c
-rndc-confgen.@O@: rndc-confgen.c
- ${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} \
+rndc-confgen.o: rndc-confgen.c
+ ${CC} ${ALL_CFLAGS} \
-DRNDC_KEYFILE=\"${sysconfdir}/rndc.key\" \
-c ${srcdir}/rndc-confgen.c
-rndc@EXEEXT@: rndc.@O@ util.@O@ ${RNDCDEPLIBS}
- ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ rndc.@O@ util.@O@ \
+rndc@EXEEXT@: rndc.o util.o ${RNDCDEPLIBS}
+ ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ rndc.o util.o \
${RNDCLIBS}
-rndc-confgen@EXEEXT@: rndc-confgen.@O@ util.@O@ ${UOBJS} ${CONFDEPLIBS}
- ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ rndc-confgen.@O@ util.@O@ \
+rndc-confgen@EXEEXT@: rndc-confgen.o util.o ${UOBJS} ${CONFDEPLIBS}
+ ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ rndc-confgen.o util.o \
${UOBJS} ${CONFLIBS}
doc man:: ${MANOBJS}
--- bind-9.3.2b1/bin/rndc/unix/Makefile.in.PIE 2004-03-07 23:04:24.000000000 -0500
+++ bind-9.3.2b1/bin/rndc/unix/Makefile.in 2005-10-06 20:04:36.000000000 -0400
@@ -27,10 +27,16 @@
CDEFINES =
CWARNINGS =
-OBJS = os.@O@
+OBJS = os.o
SRCS = os.c
TARGETS = ${OBJS}
+EXT_CFLAGS = -fPIE
+
@BIND9_MAKE_RULES@
+
+LDFLAGS += -pie -Wl,-z,relro,-z,now,-z,nodlopen,-z,noexecstack
+
+.SUFFIXES: .c .o
--- bind-9.3.2b1/bin/dig/Makefile.in.PIE 2004-08-18 19:25:57.000000000 -0400
+++ bind-9.3.2b1/bin/dig/Makefile.in 2005-10-06 20:04:36.000000000 -0400
@@ -51,7 +51,7 @@
TARGETS = dig@EXEEXT@ host@EXEEXT@ nslookup@EXEEXT@
-OBJS = dig.@O@ dighost.@O@ host.@O@ nslookup.@O@
+OBJS = dig.o dighost.o host.o nslookup.o
UOBJS =
@@ -63,19 +63,25 @@
MANOBJS = ${MANPAGES} ${HTMLPAGES}
+EXT_CFLAGS = -fPIE
+
@BIND9_MAKE_RULES@
-dig@EXEEXT@: dig.@O@ dighost.@O@ ${UOBJS} ${DEPLIBS}
+LDFLAGS += -pie -Wl,-z,relro,-z,now,-z,nodlopen,-z,noexecstack
+
+.SUFFIXES: .c .o
+
+dig@EXEEXT@: dig.o dighost.o ${UOBJS} ${DEPLIBS}
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
- dig.@O@ dighost.@O@ ${UOBJS} ${LIBS}
+ dig.o dighost.o ${UOBJS} ${LIBS}
-host@EXEEXT@: host.@O@ dighost.@O@ ${UOBJS} ${DEPLIBS}
+host@EXEEXT@: host.o dighost.o ${UOBJS} ${DEPLIBS}
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
- host.@O@ dighost.@O@ ${UOBJS} ${LIBS}
+ host.o dighost.o ${UOBJS} ${LIBS}
-nslookup@EXEEXT@: nslookup.@O@ dighost.@O@ ${UOBJS} ${DEPLIBS}
+nslookup@EXEEXT@: nslookup.o dighost.o ${UOBJS} ${DEPLIBS}
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ \
- nslookup.@O@ dighost.@O@ ${UOBJS} ${LIBS}
+ nslookup.o dighost.o ${UOBJS} ${LIBS}
doc man:: ${MANOBJS}

View File

@ -0,0 +1,922 @@
--- /dev/null 2005-10-06 11:34:58.093275500 -0400
+++ bind-9.3.2b1/bin/sdb_tools/ldap2zone.c 2005-10-06 18:57:32.000000000 -0400
@@ -0,0 +1,397 @@
+/*
+ * Copyright (C) 2004, 2005 Stig Venaas <venaas@uninett.no>
+ * $Id: ldap2zone.c,v 0.1 2005/04/23 21:30:12 venaas Exp $
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+
+#include <ldap.h>
+
+struct string {
+ void *data;
+ size_t len;
+};
+
+struct assstack_entry {
+ struct string key;
+ struct string val;
+ struct assstack_entry *next;
+};
+
+struct assstack_entry *assstack_find(struct assstack_entry *stack, struct string *key) {
+ for (; stack; stack = stack->next)
+ if (stack->key.len == key->len && !memcmp(stack->key.data, key->data, key->len))
+ return stack;
+ return NULL;
+}
+
+void assstack_push(struct assstack_entry **stack, struct assstack_entry *item) {
+ item->next = *stack;
+ *stack = item;
+}
+
+void assstack_insertbottom(struct assstack_entry **stack, struct assstack_entry *item) {
+ struct assstack_entry *p;
+
+ item->next = NULL;
+ if (!*stack) {
+ *stack = item;
+ return;
+ }
+ /* find end, should keep track of end somewhere */
+ /* really a queue, not a stack */
+ p = *stack;
+ while (p->next)
+ p = p->next;
+ p->next = item;
+}
+
+void printsoa(struct string *soa) {
+ char *s;
+ int i;
+
+ s = (char *)soa->data;
+ i = 0;
+ while (i < soa->len) {
+ putchar(s[i]);
+ if (s[i++] == ' ')
+ break;
+ }
+ while (i < soa->len) {
+ putchar(s[i]);
+ if (s[i++] == ' ')
+ break;
+ }
+ printf("(\n\t\t\t\t");
+ while (i < soa->len) {
+ putchar(s[i]);
+ if (s[i++] == ' ')
+ break;
+ }
+ printf("; Serialnumber\n\t\t\t\t");
+ while (i < soa->len) {
+ if (s[i] == ' ')
+ break;
+ putchar(s[i++]);
+ }
+ i++;
+ printf("\t; Refresh\n\t\t\t\t");
+ while (i < soa->len) {
+ if (s[i] == ' ')
+ break;
+ putchar(s[i++]);
+ }
+ i++;
+ printf("\t; Retry\n\t\t\t\t");
+ while (i < soa->len) {
+ if (s[i] == ' ')
+ break;
+ putchar(s[i++]);
+ }
+ i++;
+ printf("\t; Expire\n\t\t\t\t");
+ while (i < soa->len) {
+ putchar(s[i++]);
+ }
+ printf(" )\t; Minimum TTL\n");
+}
+
+void printrrs(char *defaultttl, struct assstack_entry *item) {
+ struct assstack_entry *stack;
+ char *s;
+ int first;
+ int i;
+ char *ttl, *type;
+ int top;
+
+ s = (char *)item->key.data;
+
+ if (item->key.len == 1 && *s == '@') {
+ top = 1;
+ printf("@\t");
+ } else {
+ top = 0;
+ for (i = 0; i < item->key.len; i++)
+ putchar(s[i]);
+ if (item->key.len < 8)
+ putchar('\t');
+ putchar('\t');
+ }
+
+ first = 1;
+ for (stack = (struct assstack_entry *) item->val.data; stack; stack = stack->next) {
+ ttl = (char *)stack->key.data;
+ s = strchr(ttl, ' ');
+ *s++ = '\0';
+ type = s;
+
+ if (first)
+ first = 0;
+ else
+ printf("\t\t");
+
+ if (strcmp(defaultttl, ttl))
+ printf("%s", ttl);
+ putchar('\t');
+
+ if (top) {
+ top = 0;
+ printf("IN\t%s\t", type);
+ /* Should always be SOA here */
+ if (!strcmp(type, "SOA")) {
+ printsoa(&stack->val);
+ continue;
+ }
+ } else
+ printf("%s\t", type);
+
+ s = (char *)stack->val.data;
+ for (i = 0; i < stack->val.len; i++)
+ putchar(s[i]);
+ putchar('\n');
+ }
+}
+
+void print_zone(char *defaultttl, struct assstack_entry *stack) {
+ printf("$TTL %s\n", defaultttl);
+ for (; stack; stack = stack->next)
+ printrrs(defaultttl, stack);
+};
+
+void usage(char *name) {
+ fprintf(stderr, "Usage:%s zone-name LDAP-URL default-ttl [serial]\n", name);
+ exit(1);
+};
+
+void err(char *name, char *msg) {
+ fprintf(stderr, "%s: %s\n", name, msg);
+ exit(1);
+};
+
+int putrr(struct assstack_entry **stack, struct berval *name, char *type, char *ttl, struct berval *val) {
+ struct string key;
+ struct assstack_entry *rr, *rrdata;
+
+ /* Do nothing if name or value have 0 length */
+ if (!name->bv_len || !val->bv_len)
+ return 0;
+
+ /* see if already have an entry for this name */
+ key.len = name->bv_len;
+ key.data = name->bv_val;
+
+ rr = assstack_find(*stack, &key);
+ if (!rr) {
+ /* Not found, create and push new entry */
+ rr = (struct assstack_entry *) malloc(sizeof(struct assstack_entry));
+ if (!rr)
+ return -1;
+ rr->key.len = name->bv_len;
+ rr->key.data = (void *) malloc(rr->key.len);
+ if (!rr->key.data) {
+ free(rr);
+ return -1;
+ }
+ memcpy(rr->key.data, name->bv_val, name->bv_len);
+ rr->val.len = sizeof(void *);
+ rr->val.data = NULL;
+ if (name->bv_len == 1 && *(char *)name->bv_val == '@')
+ assstack_push(stack, rr);
+ else
+ assstack_insertbottom(stack, rr);
+ }
+
+ rrdata = (struct assstack_entry *) malloc(sizeof(struct assstack_entry));
+ if (!rrdata) {
+ free(rr->key.data);
+ free(rr);
+ return -1;
+ }
+ rrdata->key.len = strlen(type) + strlen(ttl) + 1;
+ rrdata->key.data = (void *) malloc(rrdata->key.len);
+ if (!rrdata->key.data) {
+ free(rrdata);
+ free(rr->key.data);
+ free(rr);
+ return -1;
+ }
+ sprintf((char *)rrdata->key.data, "%s %s", ttl, type);
+
+ rrdata->val.len = val->bv_len;
+ rrdata->val.data = (void *) malloc(val->bv_len);
+ if (!rrdata->val.data) {
+ free(rrdata->key.data);
+ free(rrdata);
+ free(rr->key.data);
+ free(rr);
+ return -1;
+ }
+ memcpy(rrdata->val.data, val->bv_val, val->bv_len);
+
+ if (!strcmp(type, "SOA"))
+ assstack_push((struct assstack_entry **) &(rr->val.data), rrdata);
+ else
+ assstack_insertbottom((struct assstack_entry **) &(rr->val.data), rrdata);
+ return 0;
+}
+
+int main(int argc, char **argv) {
+ char *s, *hostporturl, *base = NULL;
+ char *ttl, *defaultttl;
+ LDAP *ld;
+ char *fltr = NULL;
+ LDAPMessage *res, *e;
+ char *a, **ttlvals, **soavals, *serial;
+ struct berval **vals, **names;
+ char type[64];
+ BerElement *ptr;
+ int i, j, rc, msgid;
+ struct assstack_entry *zone = NULL;
+
+ if (argc < 4 || argc > 5)
+ usage(argv[0]);
+
+ hostporturl = argv[2];
+
+ if (hostporturl != strstr( hostporturl, "ldap"))
+ err(argv[0], "Not an LDAP URL");
+
+ s = strchr(hostporturl, ':');
+
+ if (!s || strlen(s) < 3 || s[1] != '/' || s[2] != '/')
+ err(argv[0], "Not an LDAP URL");
+
+ s = strchr(s+3, '/');
+ if (s) {
+ *s++ = '\0';
+ base = s;
+ s = strchr(base, '?');
+ if (s)
+ err(argv[0], "LDAP URL can only contain host, port and base");
+ }
+
+ defaultttl = argv[3];
+
+ rc = ldap_initialize(&ld, hostporturl);
+ if (rc != LDAP_SUCCESS)
+ err(argv[0], "ldap_initialize() failed");
+
+ if (argc == 5) {
+ /* serial number specified, check if different from one in SOA */
+ fltr = (char *)malloc(strlen(argv[1]) + strlen("(&(relativeDomainName=@)(zoneName=))") + 1);
+ sprintf(fltr, "(&(relativeDomainName=@)(zoneName=%s))", argv[1]);
+ msgid = ldap_search(ld, base, LDAP_SCOPE_SUBTREE, fltr, NULL, 0);
+ if (msgid == -1)
+ err(argv[0], "ldap_search() failed");
+
+ while ((rc = ldap_result(ld, msgid, 0, NULL, &res)) != LDAP_RES_SEARCH_RESULT ) {
+ /* not supporting continuation references at present */
+ if (rc != LDAP_RES_SEARCH_ENTRY)
+ err(argv[0], "ldap_result() returned cont.ref? Exiting");
+
+ /* only one entry per result message */
+ e = ldap_first_entry(ld, res);
+ if (e == NULL) {
+ ldap_msgfree(res);
+ err(argv[0], "ldap_first_entry() failed");
+ }
+
+ soavals = ldap_get_values(ld, e, "SOARecord");
+ if (soavals)
+ break;
+ }
+
+ ldap_msgfree(res);
+ if (!soavals) {
+ err(argv[0], "No SOA Record found");
+ }
+
+ /* We have a SOA, compare serial numbers */
+ /* Only checkinf first value, should be only one */
+ s = strchr(soavals[0], ' ');
+ s++;
+ s = strchr(s, ' ');
+ s++;
+ serial = s;
+ s = strchr(s, ' ');
+ *s = '\0';
+ if (!strcmp(serial, argv[4])) {
+ ldap_value_free(soavals);
+ err(argv[0], "serial numbers match");
+ }
+ ldap_value_free(soavals);
+ }
+
+ if (!fltr)
+ fltr = (char *)malloc(strlen(argv[1]) + strlen("(zoneName=)") + 1);
+ if (!fltr)
+ err(argv[0], "Malloc failed");
+ sprintf(fltr, "(zoneName=%s)", argv[1]);
+
+ msgid = ldap_search(ld, base, LDAP_SCOPE_SUBTREE, fltr, NULL, 0);
+ if (msgid == -1)
+ err(argv[0], "ldap_search() failed");
+
+ while ((rc = ldap_result(ld, msgid, 0, NULL, &res)) != LDAP_RES_SEARCH_RESULT ) {
+ /* not supporting continuation references at present */
+ if (rc != LDAP_RES_SEARCH_ENTRY)
+ err(argv[0], "ldap_result() returned cont.ref? Exiting");
+
+ /* only one entry per result message */
+ e = ldap_first_entry(ld, res);
+ if (e == NULL) {
+ ldap_msgfree(res);
+ err(argv[0], "ldap_first_entry() failed");
+ }
+
+ names = ldap_get_values_len(ld, e, "relativeDomainName");
+ if (!names)
+ continue;
+
+ ttlvals = ldap_get_values(ld, e, "dNSTTL");
+ ttl = ttlvals ? ttlvals[0] : defaultttl;
+
+ for (a = ldap_first_attribute(ld, e, &ptr); a != NULL; a = ldap_next_attribute(ld, e, ptr)) {
+ char *s;
+
+ for (s = a; *s; s++)
+ *s = toupper(*s);
+ s = strstr(a, "RECORD");
+ if ((s == NULL) || (s == a) || (s - a >= (signed int)sizeof(type))) {
+ ldap_memfree(a);
+ continue;
+ }
+
+ strncpy(type, a, s - a);
+ type[s - a] = '\0';
+ vals = ldap_get_values_len(ld, e, a);
+ if (vals) {
+ for (i = 0; vals[i]; i++)
+ for (j = 0; names[j]; j++)
+ if (putrr(&zone, names[j], type, ttl, vals[i]))
+ err(argv[0], "malloc failed");
+ ldap_value_free_len(vals);
+ }
+ ldap_memfree(a);
+ }
+
+ if (ptr)
+ ber_free(ptr, 0);
+ if (ttlvals)
+ ldap_value_free(ttlvals);
+ ldap_value_free_len(names);
+ /* free this result */
+ ldap_msgfree(res);
+ }
+
+ /* free final result */
+ ldap_msgfree(res);
+
+ print_zone(defaultttl, zone);
+ return 0;
+}
--- bind-9.3.2b1/bin/sdb_tools/Makefile.in.fix_sdb_ldap 2005-02-17 01:43:28.000000000 -0500
+++ bind-9.3.2b1/bin/sdb_tools/Makefile.in 2005-10-06 18:57:32.000000000 -0400
@@ -30,11 +30,11 @@
LIBS = ${LWRESLIBS} ${DNSLIBS} ${BIND9LIBS} \
${ISCCFGLIBS} ${ISCCCLIBS} ${ISCLIBS} ${DBDRIVER_LIBS} @LIBS@
-TARGETS = zone2ldap@EXEEXT@ zonetodb@EXEEXT@
+TARGETS = zone2ldap@EXEEXT@ ldap2zone@EXEEXT@ zonetodb@EXEEXT@
-OBJS = zone2ldap.o zonetodb.o
+OBJS = zone2ldap.o ldap2zone.o zonetodb.o
-SRCS = zone2ldap.c zonetodb.c
+SRCS = zone2ldap.c ldap2zone.c zonetodb.c
MANPAGES = zone2ldap.1
@@ -54,6 +54,9 @@
zonetodb: zonetodb.o ${DEPLIBS}
${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ zonetodb.o -lpq ${LIBS}
+ldap2zone: ldap2zone.o ${DEPLIBS}
+ ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ ldap2zone.o -lldap -llber ${LIBS}
+
clean distclean manclean maintainer-clean::
rm -f ${TARGETS} ${OBJS}
@@ -63,5 +66,6 @@
install:: ${TARGETS} installdirs
${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} zone2ldap ${DESTDIR}${sbindir}
+ ${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} ldap2zone ${DESTDIR}${sbindir}
${LIBTOOL_MODE_INSTALL} ${INSTALL_PROGRAM} zonetodb ${DESTDIR}${sbindir}
${INSTALL_DATA} ${srcdir}/zone2ldap.1 ${DESTDIR}${mandir}/man1/zone2ldap.1
--- bind-9.3.2b1/bin/sdb_tools/zone2ldap.c.fix_sdb_ldap 2005-10-06 18:57:32.000000000 -0400
+++ bind-9.3.2b1/bin/sdb_tools/zone2ldap.c 2005-10-06 18:57:32.000000000 -0400
@@ -24,6 +24,7 @@
#include <isc/hash.h>
#include <isc/mem.h>
#include <isc/print.h>
+#include <isc/hash.h>
#include <isc/result.h>
#include <dns/db.h>
@@ -61,6 +62,9 @@
/* usage Info */
void usage (void);
+/* Check for existence of (and possibly add) containing dNSZone objects */
+int lookup_dns_zones( ldap_info *ldinfo);
+
/* Add to the ldap dit */
void add_ldap_values (ldap_info * ldinfo);
@@ -77,7 +81,7 @@
int get_attr_list_size (char **tmp);
/* Get a DN */
-char *build_dn_from_dc_list (char **dc_list, unsigned int ttl, int flag);
+char *build_dn_from_dc_list (char **dc_list, unsigned int ttl, int flag, char *zone);
/* Add to RR list */
void add_to_rr_list (char *dn, char *name, char *type, char *data,
@@ -99,11 +103,27 @@
init_ldap_conn ();
void usage();
-char *argzone, *ldapbase, *binddn, *bindpw = NULL;
-const char *ldapsystem = "localhost";
-static const char *objectClasses[] =
- { "top", "dNSZone", NULL };
-static const char *topObjectClasses[] = { "top", NULL };
+static char *argzone, *ldapbase, *binddn, *bindpw = NULL;
+
+/* these are needed to placate gcc4's const-ness const-ernations : */
+static char localhost[] = "localhost";
+static char *ldapsystem=&(localhost[0]);
+/* dnszone schema class names: */
+static char topClass [] ="top";
+static char dNSZoneClass[] ="dNSZone";
+static char objectClass [] ="objectClass";
+static char dcObjectClass[]="dcObject";
+/* dnszone schema attribute names: */
+static char relativeDomainName[]="relativeDomainName";
+static char dNSTTL []="dNSTTL";
+static char zoneName []="zoneName";
+static char dc []="dc";
+static char sameZone []="@";
+/* LDAPMod mod_values: */
+static char *objectClasses []= { &(topClass[0]), &(dNSZoneClass[0]), NULL };
+static char *topObjectClasses []= { &(topClass[0]), &(dcObjectClass[0]), &(dNSZoneClass[0]), NULL };
+static char *dn_buffer [64]={NULL};
+
LDAP *conn;
unsigned int debug = 0;
@@ -119,12 +139,12 @@
isc_result_t result;
char *basedn;
ldap_info *tmp;
- LDAPMod *base_attrs[2];
- LDAPMod base;
+ LDAPMod *base_attrs[5];
+ LDAPMod base, dcBase, znBase, rdnBase;
isc_buffer_t buff;
char *zonefile=0L;
char fullbasedn[1024];
- char *ctmp;
+ char *ctmp, *zn, *dcp[2], *znp[2], *rdn[2];
dns_fixedname_t fixedzone, fixedname;
dns_rdataset_t rdataset;
char **dc_list;
@@ -137,7 +157,7 @@
extern char *optarg;
extern int optind, opterr, optopt;
int create_base = 0;
- int topt;
+ int topt, dcn, zdn, znlen;
if ((int) argc < 2)
{
@@ -145,7 +165,7 @@
exit (-1);
}
- while ((topt = getopt ((int) argc, argv, "D:w:b:z:f:h:?dcv")) != -1)
+ while ((topt = getopt ((int) argc, argv, "D:Ww:b:z:f:h:?dcv")) != -1)
{
switch (topt)
{
@@ -164,8 +184,11 @@
case 'w':
bindpw = strdup (optarg);
break;
+ case 'W':
+ bindpw = getpass("Enter LDAP Password: ");
+ break;
case 'b':
- ldapbase = strdup (optarg);
+ ldapbase = strdup (optarg);
break;
case 'z':
argzone = strdup (optarg);
@@ -277,27 +300,62 @@
{
if (debug)
printf ("Creating base zone DN %s\n", argzone);
-
+
dc_list = hostname_to_dn_list (argzone, argzone, DNS_TOP);
- basedn = build_dn_from_dc_list (dc_list, 0, NO_SPEC);
- for (ctmp = &basedn[strlen (basedn)]; ctmp >= &basedn[0]; ctmp--)
+ basedn = build_dn_from_dc_list (dc_list, 0, NO_SPEC, argzone);
+ if (debug)
+ printf ("base DN %s\n", basedn);
+
+ for (ctmp = &basedn[strlen (basedn)], dcn=0; ctmp >= &basedn[0]; ctmp--)
{
- if ((*ctmp == ',') || (ctmp == &basedn[0]))
+ if ((*ctmp == ',') || (ctmp == &basedn[0]))
{
+
base.mod_op = LDAP_MOD_ADD;
- base.mod_type = (char*)"objectClass";
- base.mod_values = (char**)topObjectClasses;
+ base.mod_type = objectClass;
+ base.mod_values = topObjectClasses;
base_attrs[0] = (void*)&base;
- base_attrs[1] = NULL;
-
+
+ dcBase.mod_op = LDAP_MOD_ADD;
+ dcBase.mod_type = dc;
+ dcp[0]=dc_list[dcn];
+ dcp[1]=0L;
+ dcBase.mod_values=dcp;
+ base_attrs[1] = (void*)&dcBase;
+
+ znBase.mod_op = LDAP_MOD_ADD;
+ znBase.mod_type = zoneName;
+ for( zdn = dcn, znlen = 0; zdn >= 0; zdn-- )
+ znlen += strlen(dc_list[zdn])+1;
+ znp[0] = (char*)malloc(znlen+1);
+ znp[1] = 0L;
+ for( zdn = dcn, zn=znp[0]; zdn >= 0; zdn-- )
+ zn+=sprintf(zn,"%s%s",dc_list[zdn],
+ ((zdn > 0) && (*(dc_list[zdn-1])!='.')) ? "." : ""
+ );
+
+ znBase.mod_values = znp;
+ base_attrs[2] = (void*)&znBase;
+
+ rdnBase.mod_op = LDAP_MOD_ADD;
+ rdnBase.mod_type = relativeDomainName;
+ rdn[0] = strdup(sameZone);
+ rdn[1] = 0L;
+ rdnBase.mod_values = rdn;
+ base_attrs[3] = (void*)&rdnBase;
+
+ dcn++;
+
+ base.mod_values = topObjectClasses;
+ base_attrs[4] = NULL;
+
if (ldapbase)
{
if (ctmp != &basedn[0])
sprintf (fullbasedn, "%s,%s", ctmp + 1, ldapbase);
else
- sprintf (fullbasedn, "%s,%s", ctmp, ldapbase);
-
+ sprintf (fullbasedn, "%s,%s", ctmp, ldapbase);
}
else
{
@@ -306,8 +364,13 @@
else
sprintf (fullbasedn, "%s", ctmp);
}
+
+ if( debug )
+ printf("Full base dn: %s\n", fullbasedn);
+
result = ldap_add_s (conn, fullbasedn, base_attrs);
ldap_result_check ("intial ldap_add_s", fullbasedn, result);
+
}
}
@@ -383,14 +446,14 @@
isc_result_check (result, "dns_rdata_totext");
data[isc_buffer_usedlength (&buff)] = 0;
- dc_list = hostname_to_dn_list (name, argzone, DNS_OBJECT);
+ dc_list = hostname_to_dn_list ((char*)name, argzone, DNS_OBJECT);
len = (get_attr_list_size (dc_list) - 2);
- dn = build_dn_from_dc_list (dc_list, ttl, WI_SPEC);
+ dn = build_dn_from_dc_list (dc_list, ttl, WI_SPEC, argzone);
if (debug)
printf ("Adding %s (%s %s) to run queue list.\n", dn, type, data);
- add_to_rr_list (dn, dc_list[len], type, data, ttl, DNS_OBJECT);
+ add_to_rr_list (dn, dc_list[len], (char*)type, (char*)data, ttl, DNS_OBJECT);
}
@@ -430,7 +493,8 @@
int attrlist;
char ldap_type_buffer[128];
char charttl[64];
-
+ char *zn;
+ int znlen;
if ((tmp = locate_by_dn (dn)) == NULL)
{
@@ -465,13 +529,13 @@
}
}
tmp->attrs[0]->mod_op = LDAP_MOD_ADD;
- tmp->attrs[0]->mod_type = (char*)"objectClass";
+ tmp->attrs[0]->mod_type = objectClass;
if (flags == DNS_OBJECT)
- tmp->attrs[0]->mod_values = (char**)objectClasses;
+ tmp->attrs[0]->mod_values = objectClasses;
else
{
- tmp->attrs[0]->mod_values = (char**)topObjectClasses;
+ tmp->attrs[0]->mod_values =topObjectClasses;
tmp->attrs[1] = NULL;
tmp->attrcnt = 2;
tmp->next = ldap_info_base;
@@ -480,7 +544,7 @@
}
tmp->attrs[1]->mod_op = LDAP_MOD_ADD;
- tmp->attrs[1]->mod_type = (char*)"relativeDomainName";
+ tmp->attrs[1]->mod_type = relativeDomainName;
tmp->attrs[1]->mod_values = (char **) calloc (sizeof (char *), 2);
if (tmp->attrs[1]->mod_values == (char **)NULL)
@@ -502,7 +566,7 @@
tmp->attrs[2]->mod_values[1] = NULL;
tmp->attrs[3]->mod_op = LDAP_MOD_ADD;
- tmp->attrs[3]->mod_type = (char*)"dNSTTL";
+ tmp->attrs[3]->mod_type = dNSTTL;
tmp->attrs[3]->mod_values = (char **) calloc (sizeof (char *), 2);
if (tmp->attrs[3]->mod_values == (char **)NULL)
@@ -512,10 +576,21 @@
tmp->attrs[3]->mod_values[0] = strdup (charttl);
tmp->attrs[3]->mod_values[1] = NULL;
+ znlen=strlen(gbl_zone);
+ if ( *(gbl_zone + (znlen-1)) == '.' )
+ { /* ldapdb MUST search by relative zone name */
+ zn = (char*)malloc(znlen);
+ strncpy(zn,gbl_zone,znlen-1);
+ *(zn + (znlen-1))='\0';
+ }else
+ {
+ zn = gbl_zone;
+ }
+
tmp->attrs[4]->mod_op = LDAP_MOD_ADD;
- tmp->attrs[4]->mod_type = (char*)"zoneName";
+ tmp->attrs[4]->mod_type = zoneName;
tmp->attrs[4]->mod_values = (char **)calloc(sizeof(char *), 2);
- tmp->attrs[4]->mod_values[0] = gbl_zone;
+ tmp->attrs[4]->mod_values[0] = zn;
tmp->attrs[4]->mod_values[1] = NULL;
tmp->attrs[5] = NULL;
@@ -526,7 +601,7 @@
else
{
- for (i = 0; tmp->attrs[i] != NULL; i++)
+ for (i = 0; tmp->attrs[i] != NULL; i++)
{
sprintf (ldap_type_buffer, "%sRecord", type);
if (!strncmp
@@ -595,69 +670,105 @@
hostname_to_dn_list (char *hostname, char *zone, unsigned int flags)
{
char *tmp;
- static char *dn_buffer[64];
int i = 0;
- char *zname;
- char *hnamebuff;
-
- zname = strdup (hostname);
-
- if (flags == DNS_OBJECT)
- {
+ char *hname=0L, *last=0L;
+ int hlen=strlen(hostname), zlen=(strlen(zone));
- if (strlen (zname) != strlen (zone))
- {
- tmp = &zname[strlen (zname) - strlen (zone)];
- *--tmp = '\0';
- hnamebuff = strdup (zname);
- zname = ++tmp;
- }
- else
- hnamebuff = (char*)"@";
- }
- else
- {
- zname = zone;
- hnamebuff = NULL;
- }
-
- for (tmp = strrchr (zname, '.'); tmp != (char *) 0;
- tmp = strrchr (zname, '.'))
- {
- *tmp++ = '\0';
- dn_buffer[i++] = tmp;
- }
- dn_buffer[i++] = zname;
- dn_buffer[i++] = hnamebuff;
+/* printf("hostname: %s zone: %s\n",hostname, zone); */
+ hname=0L;
+ if(flags == DNS_OBJECT)
+ {
+ if( (zone[ zlen - 1 ] == '.') && (hostname[hlen - 1] != '.') )
+ {
+ hname=(char*)malloc(hlen + 1);
+ hlen += 1;
+ sprintf(hname, "%s.", hostname);
+ hostname = hname;
+ }
+ if(strcmp(hostname, zone) == 0)
+ {
+ if( hname == 0 )
+ hname=strdup(hostname);
+ last = strdup(sameZone);
+ }else
+ {
+ if( (hlen < zlen)
+ ||( strcmp( hostname + (hlen - zlen), zone ) != 0)
+ )
+ {
+ if( hname != 0 )
+ free(hname);
+ hname=(char*)malloc( hlen + zlen + 1);
+ if( *zone == '.' )
+ sprintf(hname, "%s%s", hostname, zone);
+ else
+ sprintf(hname,"%s",zone);
+ }else
+ {
+ if( hname == 0 )
+ hname = strdup(hostname);
+ }
+ last = hname;
+ }
+ }else
+ { /* flags == DNS_TOP */
+ hname = strdup(zone);
+ last = hname;
+ }
+
+ for (tmp = strrchr (hname, '.'); tmp != (char *) 0;
+ tmp = strrchr (hname, '.'))
+ {
+ if( *( tmp + 1 ) != '\0' )
+ {
+ *tmp = '\0';
+ dn_buffer[i++] = ++tmp;
+ }else
+ { /* trailing '.' ! */
+ dn_buffer[i++] = strdup(".");
+ *tmp = '\0';
+ if( tmp == hname )
+ break;
+ }
+ }
+ if( ( last != hname ) && (tmp != hname) )
+ dn_buffer[i++] = hname;
+ dn_buffer[i++] = last;
dn_buffer[i] = NULL;
-
return dn_buffer;
}
-
/* build an sdb compatible LDAP DN from a "dc_list" (char **).
* will append dNSTTL information to each RR Record, with the
* exception of "@"/SOA. */
char *
-build_dn_from_dc_list (char **dc_list, unsigned int ttl, int flag)
+build_dn_from_dc_list (char **dc_list, unsigned int ttl, int flag, char *zone)
{
int size;
- int x;
+ int x, znlen;
static char dn[1024];
char tmp[128];
+ char zn[DNS_NAME_MAXTEXT+1];
bzero (tmp, sizeof (tmp));
bzero (dn, sizeof (dn));
size = get_attr_list_size (dc_list);
+ znlen = strlen(zone);
+ if ( *(zone + (znlen-1)) == '.' )
+ { /* ldapdb MUST search by relative zone name */
+ memcpy(&(zn[0]),zone,znlen-1);
+ *(zn + (znlen-1))='\0';
+ zone = zn;
+ }
for (x = size - 2; x > 0; x--)
{
if (flag == WI_SPEC)
{
if (x == (size - 2) && (strncmp (dc_list[x], "@", 1) == 0) && (ttl))
- sprintf (tmp, "relativeDomainName=%s + dNSTTL=%d,", dc_list[x], ttl);
+ sprintf (tmp, "zoneName=%s + relativeDomainName=%s,", zone, dc_list[x]);
else if (x == (size - 2))
- sprintf(tmp, "relativeDomainName=%s,",dc_list[x]);
+ sprintf(tmp, "zoneName=%s + relativeDomainName=%s,", zone, dc_list[x]);
else
sprintf(tmp,"dc=%s,", dc_list[x]);
}
@@ -683,6 +794,7 @@
init_ldap_conn ()
{
int result;
+ char ldb_tag[]="LDAP Bind";
conn = ldap_open (ldapsystem, LDAP_PORT);
if (conn == NULL)
{
@@ -692,7 +804,7 @@
}
result = ldap_simple_bind_s (conn, binddn, bindpw);
- ldap_result_check ("ldap_simple_bind_s", (char*)"LDAP Bind", result);
+ ldap_result_check ("ldap_simple_bind_s", ldb_tag , result);
}
/* Like isc_result_check, only for LDAP */
@@ -709,8 +821,6 @@
}
}
-
-
/* For running the ldap_info run queue. */
void
add_ldap_values (ldap_info * ldinfo)
@@ -718,14 +828,14 @@
int result;
char dnbuffer[1024];
-
if (ldapbase != NULL)
sprintf (dnbuffer, "%s,%s", ldinfo->dn, ldapbase);
else
sprintf (dnbuffer, "%s", ldinfo->dn);
result = ldap_add_s (conn, dnbuffer, ldinfo->attrs);
- ldap_result_check ("ldap_add_s", dnbuffer, result);
+ ldap_result_check ("ldap_add_s", dnbuffer, result);
+
}
@@ -736,7 +846,7 @@
usage ()
{
fprintf (stderr,
- "zone2ldap -D [BIND DN] -w [BIND PASSWORD] -b [BASE DN] -z [ZONE] -f [ZONE FILE] -h [LDAP HOST]\n"
+ "zone2ldap -D [BIND DN] [-w BIND PASSWORD | -W:prompt] -b [BASE DN] -z [ZONE] -f [ZONE FILE] -h [LDAP HOST]\n"
"\t[-c Create LDAP Base structure][-d Debug Output (lots !)]\n "
);
}

View File

@ -0,0 +1,104 @@
--- bind-9.3.2b2/bin/dig/host.1.no_servfail_stops 2005-10-12 22:33:43.000000000 -0400
+++ bind-9.3.2b2/bin/dig/host.1 2005-11-15 12:51:26.000000000 -0500
@@ -30,7 +30,7 @@
host \- DNS lookup utility
.SH "SYNOPSIS"
.HP 5
-\fBhost\fR [\fB\-aCdlnrTwv\fR] [\fB\-c\ \fR\fB\fIclass\fR\fR] [\fB\-N\ \fR\fB\fIndots\fR\fR] [\fB\-R\ \fR\fB\fInumber\fR\fR] [\fB\-t\ \fR\fB\fItype\fR\fR] [\fB\-W\ \fR\fB\fIwait\fR\fR] [\fB\-4\fR] [\fB\-6\fR] {name} [server]
+\fBhost\fR [\fB\-aCdlnrTwv\fR] [\fB\-c\ \fR\fB\fIclass\fR\fR] [\fB\-N\ \fR\fB\fIndots\fR\fR] [\fB\-R\ \fR\fB\fInumber\fR\fR] [\fB\-t\ \fR\fB\fItype\fR\fR] [\fB\-W\ \fR\fB\fIwait\fR\fR] [\fB\-4\fR] [\fB\-6\fR] [ \fB\-s\fR ] {name} [server]
.SH "DESCRIPTION"
.PP
\fBhost\fR
@@ -176,6 +176,11 @@
option is used,
\fBhost\fR
will effectively wait forever for a reply. The time to wait for a response will be set to the number of seconds given by the hardware's maximum value for an integer quantity.
+.PP
+The \fB-s\fR option tells \fBhost\fR NOT to send the query to the next nameserver if any
+server responds with a SERVFAIL response, which is the reverse of normal stub resolver
+behaviour.
+.PP
.SH "FILES"
.PP
\fI/etc/resolv.conf\fR
--- bind-9.3.2b2/bin/dig/nslookup.c.no_servfail_stops 2005-07-12 01:47:42.000000000 -0400
+++ bind-9.3.2b2/bin/dig/nslookup.c 2005-11-15 12:49:55.000000000 -0500
@@ -50,7 +50,8 @@
comments = ISC_TRUE, section_question = ISC_TRUE,
section_answer = ISC_TRUE, section_authority = ISC_TRUE,
section_additional = ISC_TRUE, recurse = ISC_TRUE,
- aaonly = ISC_FALSE;
+ aaonly = ISC_FALSE, nofail=ISC_TRUE;
+
static isc_boolean_t in_use = ISC_FALSE;
static char defclass[MXRD] = "IN";
static char deftype[MXRD] = "A";
@@ -631,6 +632,10 @@
usesearch = ISC_FALSE;
} else if (strncasecmp(opt, "sil", 3) == 0) {
/* deprecation_msg = ISC_FALSE; */
+ } else if (strncasecmp(opt, "fail", 3) == 0) {
+ nofail=ISC_FALSE;
+ } else if (strncasecmp(opt, "nofail", 3) == 0) {
+ nofail=ISC_TRUE;
} else {
printf("*** Invalid option: %s\n", opt);
}
@@ -689,6 +694,8 @@
lookup->section_authority = section_authority;
lookup->section_additional = section_additional;
lookup->new_search = ISC_TRUE;
+ if ( nofail )
+ lookup->servfail_stops = ISC_FALSE;
ISC_LIST_INIT(lookup->q);
ISC_LINK_INIT(lookup, link);
ISC_LIST_APPEND(lookup_list, lookup, link);
--- bind-9.3.2b2/bin/dig/nslookup.1.no_servfail_stops 2005-10-12 22:33:43.000000000 -0400
+++ bind-9.3.2b2/bin/dig/nslookup.1 2005-11-15 12:49:55.000000000 -0500
@@ -166,6 +166,12 @@
Always use a virtual circuit when sending requests to the server.
.sp
(Default = novc)
+.TP
+\fB[no]fail\R
+Try the next nameserver if a nameserver responds with SERVFAIL or
+a referral (nofail) or terminate query (fail) on such a response.
+
+(Default = nofail)
.RE
.IP
.SH "FILES"
--- bind-9.3.2b2/bin/dig/host.c.no_servfail_stops 2005-07-03 23:29:45.000000000 -0400
+++ bind-9.3.2b2/bin/dig/host.c 2005-11-15 12:49:55.000000000 -0500
@@ -128,7 +128,8 @@
" -w specifies to wait forever for a reply\n"
" -W specifies how long to wait for a reply\n"
" -4 use IPv4 query transport only\n"
-" -6 use IPv6 query transport only\n", stderr);
+" -6 use IPv6 query transport only\n"
+" -s a SERVFAIL response should stop query\n", stderr);
exit(1);
}
@@ -538,7 +539,10 @@
lookup = make_empty_lookup();
- while ((c = isc_commandline_parse(argc, argv, "lvwrdt:c:aTCN:R:W:Dni46"))
+ lookup->servfail_stops = ISC_FALSE;
+ lookup->comments = ISC_FALSE;
+
+ while ((c = isc_commandline_parse(argc, argv, "lvwrdt:c:aTCN:R:W:Dni46s"))
!= EOF) {
switch (c) {
case 'l':
@@ -676,6 +680,9 @@
} else
fatal("can't find IPv6 networking");
break;
+ case 's':
+ lookup->servfail_stops = ISC_TRUE;
+ break;
}
}

252
bind-9.3.2b2-sdbsrc.patch Normal file
View File

@ -0,0 +1,252 @@
--- bind-9.3.2b2/contrib/sdb/ldap/zone2ldap.c.sdbsrc 2005-08-16 00:43:03.000000000 -0400
+++ bind-9.3.2b2/contrib/sdb/ldap/zone2ldap.c 2005-11-15 12:57:44.000000000 -0500
@@ -59,16 +59,16 @@
ldap_info;
/* usage Info */
-void usage ();
+void usage (void);
/* Add to the ldap dit */
void add_ldap_values (ldap_info * ldinfo);
/* Init an ldap connection */
-void init_ldap_conn ();
+void init_ldap_conn (void);
/* Ldap error checking */
-void ldap_result_check (char *msg, char *dn, int err);
+void ldap_result_check (const char *msg, char *dn, int err);
/* Put a hostname into a char ** array */
char **hostname_to_dn_list (char *hostname, char *zone, unsigned int flags);
@@ -84,7 +84,7 @@
unsigned int ttl, unsigned int flags);
/* Error checking */
-void isc_result_check (isc_result_t res, char *errorstr);
+void isc_result_check (isc_result_t res, const char *errorstr);
/* Generate LDIF Format files */
void generate_ldap (dns_name_t * dnsname, dns_rdata_t * rdata,
@@ -93,11 +93,17 @@
/* head pointer to the list */
ldap_info *ldap_info_base = NULL;
+ldap_info *
+locate_by_dn (char *dn);
+void
+init_ldap_conn ();
+void usage();
+
char *argzone, *ldapbase, *binddn, *bindpw = NULL;
-char *ldapsystem = "localhost";
-static char *objectClasses[] =
+const char *ldapsystem = "localhost";
+static const char *objectClasses[] =
{ "top", "dNSZone", NULL };
-static char *topObjectClasses[] = { "top", NULL };
+static const char *topObjectClasses[] = { "top", NULL };
LDAP *conn;
unsigned int debug = 0;
@@ -106,7 +112,7 @@
#endif
int
-main (int *argc, char **argv)
+main (int argc, char **argv)
{
isc_mem_t *mctx = NULL;
isc_entropy_t *ectx = NULL;
@@ -116,7 +122,7 @@
LDAPMod *base_attrs[2];
LDAPMod base;
isc_buffer_t buff;
- char *zonefile;
+ char *zonefile=0L;
char fullbasedn[1024];
char *ctmp;
dns_fixedname_t fixedzone, fixedname;
@@ -280,9 +286,9 @@
if ((*ctmp == ',') || (ctmp == &basedn[0]))
{
base.mod_op = LDAP_MOD_ADD;
- base.mod_type = "objectClass";
- base.mod_values = topObjectClasses;
- base_attrs[0] = &base;
+ base.mod_type = (char*)"objectClass";
+ base.mod_values = (char**)topObjectClasses;
+ base_attrs[0] = (void*)&base;
base_attrs[1] = NULL;
if (ldapbase)
@@ -337,7 +343,7 @@
* I should probably rename this function, as not to cause any
* confusion with the isc* routines. Will exit on error. */
void
-isc_result_check (isc_result_t res, char *errorstr)
+isc_result_check (isc_result_t res, const char *errorstr)
{
if (res != ISC_R_SUCCESS)
{
@@ -449,7 +455,7 @@
exit (-1);
}
- for (i = 0; i < flags; i++)
+ for (i = 0; i < (int)flags; i++)
{
tmp->attrs[i] = (LDAPMod *) malloc (sizeof (LDAPMod));
if (tmp->attrs[i] == (LDAPMod *) NULL)
@@ -459,13 +465,13 @@
}
}
tmp->attrs[0]->mod_op = LDAP_MOD_ADD;
- tmp->attrs[0]->mod_type = "objectClass";
+ tmp->attrs[0]->mod_type = (char*)"objectClass";
if (flags == DNS_OBJECT)
- tmp->attrs[0]->mod_values = objectClasses;
+ tmp->attrs[0]->mod_values = (char**)objectClasses;
else
{
- tmp->attrs[0]->mod_values = topObjectClasses;
+ tmp->attrs[0]->mod_values = (char**)topObjectClasses;
tmp->attrs[1] = NULL;
tmp->attrcnt = 2;
tmp->next = ldap_info_base;
@@ -474,7 +480,7 @@
}
tmp->attrs[1]->mod_op = LDAP_MOD_ADD;
- tmp->attrs[1]->mod_type = "relativeDomainName";
+ tmp->attrs[1]->mod_type = (char*)"relativeDomainName";
tmp->attrs[1]->mod_values = (char **) calloc (sizeof (char *), 2);
if (tmp->attrs[1]->mod_values == (char **)NULL)
@@ -496,7 +502,7 @@
tmp->attrs[2]->mod_values[1] = NULL;
tmp->attrs[3]->mod_op = LDAP_MOD_ADD;
- tmp->attrs[3]->mod_type = "dNSTTL";
+ tmp->attrs[3]->mod_type = (char*)"dNSTTL";
tmp->attrs[3]->mod_values = (char **) calloc (sizeof (char *), 2);
if (tmp->attrs[3]->mod_values == (char **)NULL)
@@ -507,7 +513,7 @@
tmp->attrs[3]->mod_values[1] = NULL;
tmp->attrs[4]->mod_op = LDAP_MOD_ADD;
- tmp->attrs[4]->mod_type = "zoneName";
+ tmp->attrs[4]->mod_type = (char*)"zoneName";
tmp->attrs[4]->mod_values = (char **)calloc(sizeof(char *), 2);
tmp->attrs[4]->mod_values[0] = gbl_zone;
tmp->attrs[4]->mod_values[1] = NULL;
@@ -607,7 +613,7 @@
zname = ++tmp;
}
else
- hnamebuff = "@";
+ hnamebuff = (char*)"@";
}
else
{
@@ -686,12 +692,12 @@
}
result = ldap_simple_bind_s (conn, binddn, bindpw);
- ldap_result_check ("ldap_simple_bind_s", "LDAP Bind", result);
+ ldap_result_check ("ldap_simple_bind_s", (char*)"LDAP Bind", result);
}
/* Like isc_result_check, only for LDAP */
void
-ldap_result_check (char *msg, char *dn, int err)
+ldap_result_check (const char *msg, char *dn, int err)
{
if ((err != LDAP_SUCCESS) && (err != LDAP_ALREADY_EXISTS))
{
@@ -730,5 +736,8 @@
usage ()
{
fprintf (stderr,
- "zone2ldap -D [BIND DN] -w [BIND PASSWORD] -b [BASE DN] -z [ZONE] -f [ZONE FILE] -h [LDAP HOST]
- [-c Create LDAP Base structure][-d Debug Output (lots !)] \n ");}
+ "zone2ldap -D [BIND DN] -w [BIND PASSWORD] -b [BASE DN] -z [ZONE] -f [ZONE FILE] -h [LDAP HOST]\n"
+ "\t[-c Create LDAP Base structure][-d Debug Output (lots !)]\n "
+ );
+}
+
--- bind-9.3.2b2/contrib/sdb/bdb/bdb.c.sdbsrc 2002-07-02 00:45:34.000000000 -0400
+++ bind-9.3.2b2/contrib/sdb/bdb/bdb.c 2005-11-15 12:57:44.000000000 -0500
@@ -43,7 +43,7 @@
#include <dns/lib.h>
#include <dns/ttl.h>
-#include <named/bdb.h>
+#include "bdb.h"
#include <named/globals.h>
#include <named/config.h>
--- bind-9.3.2b2/contrib/sdb/pgsql/pgsqldb.c.sdbsrc 2004-03-08 04:04:22.000000000 -0500
+++ bind-9.3.2b2/contrib/sdb/pgsql/pgsqldb.c 2005-11-15 12:57:44.000000000 -0500
@@ -23,7 +23,7 @@
#include <string.h>
#include <stdlib.h>
-#include <pgsql/libpq-fe.h>
+#include <libpq-fe.h>
#include <isc/mem.h>
#include <isc/print.h>
--- bind-9.3.2b2/contrib/sdb/pgsql/zonetodb.c.sdbsrc 2005-09-05 22:12:40.000000000 -0400
+++ bind-9.3.2b2/contrib/sdb/pgsql/zonetodb.c 2005-11-15 12:58:12.000000000 -0500
@@ -37,7 +37,7 @@
#include <dns/rdatatype.h>
#include <dns/result.h>
-#include <pgsql/libpq-fe.h>
+#include <libpq-fe.h>
/*
* Generate a PostgreSQL table from a zone.
@@ -54,6 +54,9 @@
char str[10240];
void
+closeandexit(int status);
+
+void
closeandexit(int status) {
if (conn != NULL)
PQfinish(conn);
@@ -61,6 +64,9 @@
}
void
+check_result(isc_result_t result, const char *message);
+
+void
check_result(isc_result_t result, const char *message) {
if (result != ISC_R_SUCCESS) {
fprintf(stderr, "%s: %s\n", message,
@@ -84,7 +90,8 @@
}
*dest++ = 0;
}
-
+void
+addrdata(dns_name_t *name, dns_ttl_t ttl, dns_rdata_t *rdata);
void
addrdata(dns_name_t *name, dns_ttl_t ttl, dns_rdata_t *rdata) {
unsigned char namearray[DNS_NAME_MAXTEXT + 1];
@@ -165,7 +172,7 @@
check_result(result, "isc_mem_create");
result = isc_entropy_create(mctx, &ectx);
- result_check (result, "isc_entropy_create");
+ check_result (result, "isc_entropy_create");
result = isc_hash_create(mctx, ectx, DNS_NAME_MAXWIRE);
check_result (result, "isc_hash_create");