Commit Diff
Diff:
3c13422e5a77fcb404c0310938e4dc2e40f2b794
22da1ac04eecb739fb7e112da769f6631c4740b2
Commit:
22da1ac04eecb739fb7e112da769f6631c4740b2
Tree:
9afd6ab6551b79fc8d0addec233caf7e72cce2a3
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Thu May 10 09:18:16 2018 UTC
Message:
Add a delphinusdnsd to BIND9 conversion utility syntax is: usage: command [arg ...] bindfile zonename zonefile Where zonename is the name of the domain and zonefile is file where it stands in delphinusdnsd format. It's best not to intermingle zonefiles here. Tested on OpenBSD with NSD which accepted my conversion.
blob - 2388bfcf5f6405828cb4cfaf74dec8e922bb3b04
blob + 76ae6affd1775fc0f984526d9d5e1fea57ee0725
--- dddctl.c
+++ dddctl.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: dddctl.c,v 1.9 2018/05/05 06:27:44 pjp Exp $
+ * $Id: dddctl.c,v 1.10 2018/05/10 09:18:16 pjp Exp $
*/
#include "ddd-include.h"
@@ -64,6 +64,7 @@ int add_dnskey(ddDB *);
char * parse_keyfile(int, uint32_t *, uint16_t *, uint8_t *, uint8_t *, char *, int *);
char * create_key(char *, int, int, int, int, uint32_t *);
int dump_db(ddDB *, FILE *, char *);
+int dump_db_bind(ddDB*, FILE *, char *);
char * alg_to_name(int);
int alg_to_rsa(int);
int construct_nsec3(ddDB *, char *, int, char *);
@@ -95,12 +96,14 @@ u_int64_t timethuman(time_t);
char * bitmap2human(char *, int);
char * bin2hex(char *, int);
int print_sd(FILE *, struct domain *);
+int print_sd_bind(FILE *, struct domain *);
int usage(int argc, char *argv[]);
int start(int argc, char *argv[]);
int restart(int argc, char *argv[]);
int stop(int argc, char *argv[]);
int signmain(int argc, char *argv[]);
int configtest(int argc, char *argv[]);
+int bindfile(int argc, char *argv[]);
int sshfp(int argc, char *argv[]);
void init_keys(void);
uint32_t getkeypid(char *);
@@ -111,6 +114,7 @@ struct _mycmdtab {
char *var;
int (*cmd)(int, char **);
} mycmdtab[] = {
+ { "bindfile", bindfile },
{ "configtest", configtest },
{ "help", usage },
{ "sign", signmain },
@@ -6915,6 +6919,7 @@ usage(int argc, char *argv[])
retval = 1;
} else {
fprintf(stderr, "usage: command [arg ...]\n");
+ fprintf(stderr, "\tbindfile zonename zonefile\n");
fprintf(stderr, "\tconfigtest [configfile]\n");
fprintf(stderr, "\thelp [command]\n");
fprintf(stderr, "\tsign [-KZ] [-a algorithm] [-B bits] [-e seconds]\n\t\t[-I iterations] [-i inputfile] [-k KSK] [-m mask] [-n zonename]\n\t\t[-o output] [-S pid] [-s salt] [-t ttl] [-z ZSK]\n");
@@ -7211,4 +7216,699 @@ sshfp(int argc, char *argv[])
pclose(po);
exit(0);
+}
+
+int
+dump_db_bind(ddDB *db, FILE *of, char *zonename)
+{
+ int j, rs;
+
+ ddDBT key, data;
+
+ struct node *n, *nx;
+ struct question *q;
+ struct domain *sdomain;
+
+ char replystring[512];
+ char *dnsname;
+ int labellen;
+ int lzerrno, retval;
+
+ fprintf(of, ";; This file was generated by dddctl.c of delphinusdnsd\n");
+
+ dnsname = dns_label(zonename, &labellen);
+ if (dnsname == NULL)
+ return -1;
+
+ q = build_fake_question(dnsname, labellen, DNS_TYPE_SOA);
+ if (q == NULL) {
+ return -1;
+ }
+
+ if ((sdomain = lookup_zone(db, q, &retval, &lzerrno, (char *)&replystring)) == NULL) {
+ return -1;
+ }
+
+ if (print_sd_bind(of, sdomain) < 0) {
+ fprintf(stderr, "print_sd_bind error\n");
+ return -1;
+ }
+
+ memset(&key, 0, sizeof(key));
+ memset(&data, 0, sizeof(data));
+
+ j = 0;
+ RB_FOREACH_SAFE(n, domaintree, &rbhead, nx) {
+ rs = n->datalen;
+ if ((sdomain = calloc(1, rs)) == NULL) {
+ dolog(LOG_INFO, "calloc: %s\n", strerror(errno));
+ exit(1);
+ }
+
+ memcpy((char *)sdomain, (char *)n->data, n->datalen);
+
+ if (strcmp(sdomain->zonename, zonename) == 0)
+ continue;
+
+ if (print_sd_bind(of, sdomain) < 0) {
+ fprintf(stderr, "print_sd_bind error\n");
+ return -1;
+ }
+
+
+ j++;
+ }
+
+#if DEBUG
+ printf("%d records\n", j);
+#endif
+ return (0);
+}
+
+/*
+ * dump the RR's in BIND format
+ */
+
+int
+print_sd_bind(FILE *of, struct domain *sdomain)
+{
+ int i, x, len;
+
+ struct domain_soa *sdsoa;
+ struct domain_ns *sdns;
+ struct domain_mx *sdmx;
+ struct domain_a *sda;
+ struct domain_aaaa *sdaaaa;
+ struct domain_cname *sdcname;
+ struct domain_ptr *sdptr;
+ struct domain_txt *sdtxt;
+ struct domain_naptr *sdnaptr;
+ struct domain_srv *sdsrv;
+ struct domain_rrsig *sdrr;
+ struct domain_dnskey *sddk;
+ struct domain_ds *sdds;
+ struct domain_nsec3 *sdn3;
+ struct domain_nsec3param *sdn3param;
+ struct domain_sshfp *sdsshfp;
+ struct domain_tlsa *sdtlsa;
+ struct rrsig *rss;
+
+ char buf[4096];
+
+ if (sdomain->flags & DOMAIN_HAVE_SOA) {
+ if ((sdsoa = (struct domain_soa *)find_substruct(sdomain, INTERNAL_TYPE_SOA)) == NULL) {
+ dolog(LOG_INFO, "no dnskeys in zone!\n");
+ return -1;
+ }
+ fprintf(of, "%s %d IN SOA %s %s (\n\t\t\t\t%u\t; Serial\n\t\t\t\t%d\t; Refresh\n\t\t\t\t%d\t; Retry\n\t\t\t\t%d\t; Expire\n\t\t\t\t%d )\t; Minimum TTL\n\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_SOA],
+ convert_name(sdsoa->soa.nsserver, sdsoa->soa.nsserver_len),
+ convert_name(sdsoa->soa.responsible_person, sdsoa->soa.rp_len),
+ sdsoa->soa.serial, sdsoa->soa.refresh, sdsoa->soa.retry,
+ sdsoa->soa.expire, sdsoa->soa.minttl);
+ }
+ if (sdomain->flags & DOMAIN_HAVE_NS) {
+ if ((sdns = (struct domain_ns *)find_substruct(sdomain, INTERNAL_TYPE_NS)) == NULL) {
+ dolog(LOG_INFO, "no dnskeys in zone!\n");
+ return -1;
+ }
+ for (i = 0; i < sdns->ns_count; i++) {
+ fprintf(of, "%s %d IN NS %s\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_NS],
+ convert_name(sdns->ns[i].nsserver, sdns->ns[i].nslen));
+ }
+ }
+ if (sdomain->flags & DOMAIN_HAVE_MX) {
+ if ((sdmx = (struct domain_mx *)find_substruct(sdomain, INTERNAL_TYPE_MX)) == NULL) {
+ dolog(LOG_INFO, "no dnskeys in zone!\n");
+ return -1;
+ }
+ for (i = 0; i < sdmx->mx_count; i++) {
+ fprintf(of, "%s %d IN MX %d %s\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_MX],
+ sdmx->mx[i].preference,
+ convert_name(sdmx->mx[i].exchange, sdmx->mx[i].exchangelen));
+ }
+ }
+ if (sdomain->flags & DOMAIN_HAVE_DS) {
+ if ((sdds = (struct domain_ds *)find_substruct(sdomain, INTERNAL_TYPE_DS)) == NULL) {
+ dolog(LOG_INFO, "no dnskeys in zone!\n");
+ return -1;
+ }
+ for (i = 0; i < sdds->ds_count; i++) {
+ fprintf(of, "%s %d IN DS %d %d %d (%s)\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_DS],
+ sdds->ds[i].key_tag,
+ sdds->ds[i].algorithm,
+ sdds->ds[i].digest_type,
+ bin2hex(sdds->ds[i].digest, sdds->ds[i].digestlen));
+ }
+ }
+ if (sdomain->flags & DOMAIN_HAVE_CNAME) {
+ if ((sdcname = (struct domain_cname *)find_substruct(sdomain, INTERNAL_TYPE_CNAME)) == NULL) {
+ dolog(LOG_INFO, "no dnskeys in zone!\n");
+ return -1;
+ }
+ fprintf(of, "%s %d IN CNAME %s\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_CNAME],
+ convert_name(sdcname->cname, sdcname->cnamelen));
+ }
+ if (sdomain->flags & DOMAIN_HAVE_NAPTR) {
+ if ((sdnaptr = (struct domain_naptr *)find_substruct(sdomain, INTERNAL_TYPE_NAPTR)) == NULL) {
+ dolog(LOG_INFO, "no dnskeys in zone!\n");
+ return -1;
+ }
+ for (i = 0; i < sdnaptr->naptr_count; i++) {
+ fprintf(of, "%s %d IN NAPTR (\t\t%d\t; order\n\t\t%d\t; preference\n\t\t\"",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_NAPTR],
+ sdnaptr->naptr[i].order,
+ sdnaptr->naptr[i].preference);
+
+ for (x = 0; x < sdnaptr->naptr[i].flagslen; x++) {
+ fprintf(of, "%c", sdnaptr->naptr[i].flags[x]);
+ }
+ fprintf(of, "\"\t; flag\n\t\t\"");
+ for (x = 0; x < sdnaptr->naptr[i].serviceslen; x++) {
+ fprintf(of, "%c", sdnaptr->naptr[i].services[x]);
+ }
+ fprintf(of, "\"\t; service\n\t\t\"");
+ for (x = 0; x < sdnaptr->naptr[i].regexplen; x++) {
+ fprintf(of, "%c", sdnaptr->naptr[i].regexp[x]);
+ }
+ fprintf(of, "\"\t; regexp\n\t\t%s ) ; replacement\n", (sdnaptr->naptr[i].replacement[0] == '\0') ? "." : convert_name(sdnaptr->naptr[i].replacement, sdnaptr->naptr[i].replacementlen));
+ }
+ }
+ if (sdomain->flags & DOMAIN_HAVE_TXT) {
+ if ((sdtxt = (struct domain_txt *)find_substruct(sdomain, INTERNAL_TYPE_TXT)) == NULL) {
+ dolog(LOG_INFO, "no dnskeys in zone!\n");
+ return -1;
+ }
+ fprintf(of, "%s %d IN TXT \"",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_TXT]);
+ for (i = 0; i < sdtxt->txtlen; i++) {
+ fprintf(of, "%c", sdtxt->txt[i]);
+ }
+ fprintf(of, "\"\n");
+ }
+ if (sdomain->flags & DOMAIN_HAVE_PTR) {
+ if ((sdptr = (struct domain_ptr *)find_substruct(sdomain, INTERNAL_TYPE_PTR)) == NULL) {
+ dolog(LOG_INFO, "no dnskeys in zone!\n");
+ return -1;
+ }
+ fprintf(of, "%s %d IN PTR %s\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_PTR],
+ convert_name(sdptr->ptr, sdptr->ptrlen));
+ }
+ if (sdomain->flags & DOMAIN_HAVE_SRV) {
+ if ((sdsrv = (struct domain_srv *)find_substruct(sdomain, INTERNAL_TYPE_SRV)) == NULL) {
+ dolog(LOG_INFO, "no dnskeys in zone!\n");
+ return -1;
+ }
+ for (i = 0; i < sdsrv->srv_count; i++) {
+ fprintf(of, "%s %d IN SRV %d %d %d %s\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_SRV],
+ sdsrv->srv[i].priority,
+ sdsrv->srv[i].weight,
+ sdsrv->srv[i].port,
+ convert_name(sdsrv->srv[i].target,sdsrv->srv[i].targetlen));
+ }
+ }
+ if (sdomain->flags & DOMAIN_HAVE_TLSA) {
+ if ((sdtlsa = (struct domain_tlsa *)find_substruct(sdomain, INTERNAL_TYPE_TLSA)) == NULL) {
+ dolog(LOG_INFO, "no dnskeys in zone!\n");
+ return -1;
+ }
+ for (i = 0; i < sdtlsa->tlsa_count; i++) {
+ fprintf(of, "%s %d IN TLSA %d %d %d (%s)\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_TLSA],
+ sdtlsa->tlsa[i].usage,
+ sdtlsa->tlsa[i].selector,
+ sdtlsa->tlsa[i].matchtype,
+ bin2hex(sdtlsa->tlsa[i].data, sdtlsa->tlsa[i].datalen));
+ }
+ }
+ if (sdomain->flags & DOMAIN_HAVE_SSHFP) {
+ if ((sdsshfp = (struct domain_sshfp *)find_substruct(sdomain, INTERNAL_TYPE_SSHFP)) == NULL) {
+ dolog(LOG_INFO, "no dnskeys in zone!\n");
+ return -1;
+ }
+ for (i = 0; i < sdsshfp->sshfp_count; i++) {
+ fprintf(of, "%s %d IN SSHFP %d %d (%s)\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_SSHFP],
+ sdsshfp->sshfp[i].algorithm,
+ sdsshfp->sshfp[i].fptype,
+ bin2hex(sdsshfp->sshfp[i].fingerprint, sdsshfp->sshfp[i].fplen));
+ }
+ }
+ if (sdomain->flags & DOMAIN_HAVE_A) {
+ if ((sda = (struct domain_a *)find_substruct(sdomain, INTERNAL_TYPE_A)) == NULL) {
+ dolog(LOG_INFO, "no dnskeys in zone!\n");
+ return -1;
+ }
+ for (i = 0; i < sda->a_count; i++) {
+ inet_ntop(AF_INET, &sda->a[i], buf, sizeof(buf));
+ fprintf(of, "%s %d IN A %s\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_A],
+ buf);
+ }
+ }
+ if (sdomain->flags & DOMAIN_HAVE_AAAA) {
+ if ((sdaaaa = (struct domain_aaaa *)find_substruct(sdomain, INTERNAL_TYPE_AAAA)) == NULL) {
+ dolog(LOG_INFO, "no dnskeys in zone!\n");
+ return -1;
+ }
+ for (i = 0; i < sdaaaa->aaaa_count; i++) {
+ inet_ntop(AF_INET6, &sdaaaa->aaaa[i], buf, sizeof(buf));
+ fprintf(of, "%s %d IN AAAA %s\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_AAAA],
+ buf);
+ }
+ }
+ if (sdomain->flags & DOMAIN_HAVE_DNSKEY) {
+#if DEBUG
+ printf(" has dnskey\n");
+#endif
+ if ((sddk = (struct domain_dnskey *)find_substruct(sdomain, INTERNAL_TYPE_DNSKEY)) == NULL) {
+ dolog(LOG_INFO, "no dnskeys in zone!\n");
+ return -1;
+ }
+ for (i = 0; i < sddk->dnskey_count; i++) {
+ len = mybase64_encode(sddk->dnskey[i].public_key, sddk->dnskey[i].publickey_len, buf, sizeof(buf));
+ buf[len] = '\0';
+ fprintf(of, "%s %d IN DNSKEY %d %d %d (%s)\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_DNSKEY],
+ sddk->dnskey[i].flags,
+ sddk->dnskey[i].protocol,
+ sddk->dnskey[i].algorithm,
+ buf);
+ }
+ }
+ if (sdomain->flags & DOMAIN_HAVE_NSEC3PARAM) {
+#if DEBUG
+ printf("has nsec3param\n");
+#endif
+ if ((sdn3param = (struct domain_nsec3param *)find_substruct(sdomain, INTERNAL_TYPE_NSEC3PARAM)) == NULL) {
+ dolog(LOG_INFO, "no nsec3param in zone!\n");
+ return -1;
+ }
+
+ fprintf(of, "%s 0 IN NSEC3PARAM %d %d %d (%s)\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdn3param->nsec3param.algorithm,
+ sdn3param->nsec3param.flags,
+ sdn3param->nsec3param.iterations,
+ (sdn3param->nsec3param.saltlen == 0) ? "-" : bin2hex(sdn3param->nsec3param.salt, sdn3param->nsec3param.saltlen));
+ }
+ if (sdomain->flags & DOMAIN_HAVE_NSEC3) {
+#if DEBUG
+ printf("has nsec3\n");
+#endif
+ if ((sdn3 = (struct domain_nsec3 *)find_substruct(sdomain, INTERNAL_TYPE_NSEC3)) == NULL) {
+ dolog(LOG_INFO, "no nsec3 in zone!\n");
+ return -1;
+ }
+
+ fprintf(of, "%s %d IN NSEC3 %d %d %d %s %s %s\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_NSEC3],
+ sdn3->nsec3.algorithm,
+ sdn3->nsec3.flags,
+ sdn3->nsec3.iterations,
+ (sdn3->nsec3.saltlen == 0) ? "-" : bin2hex(sdn3->nsec3.salt, sdn3->nsec3.saltlen),
+ base32hex_encode(sdn3->nsec3.next, sdn3->nsec3.nextlen),
+ bitmap2human(sdn3->nsec3.bitmap, sdn3->nsec3.bitmap_len));
+
+ }
+ if (sdomain->flags & DOMAIN_HAVE_RRSIG) {
+#if DEBUG
+ printf(" has rrsig\n");
+#endif
+
+ if ((sdrr = (struct domain_rrsig *)find_substruct(sdomain, INTERNAL_TYPE_RRSIG)) == NULL) {
+ dolog(LOG_INFO, "no rrsigs in zone!\n");
+ return -1;
+ }
+
+ if ((sdomain->flags & DOMAIN_HAVE_DNSKEY) && sdrr->rrsig_dnskey_count > 0) {
+ for (i = 0; i < sdrr->rrsig_dnskey_count; i++) {
+ rss = (struct rrsig *)&sdrr->rrsig_dnskey[i];
+ len = mybase64_encode(rss->signature, rss->signature_len, buf, sizeof(buf));
+ buf[len] = '\0';
+
+ fprintf(of, "%s %d IN RRSIG (%s %d %d %d %llu %llu %d %s %s)\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_DNSKEY],
+ get_dns_type(rss->type_covered, 0),
+ rss->algorithm, rss->labels,
+ rss->original_ttl,
+ timethuman(rss->signature_expiration),
+ timethuman(rss->signature_inception),
+ rss->key_tag,
+ convert_name(rss->signers_name, rss->signame_len),
+ buf);
+ }
+ }
+ if (sdomain->flags & DOMAIN_HAVE_SOA) {
+ rss = (struct rrsig *)&sdrr->rrsig[INTERNAL_TYPE_SOA];
+ len = mybase64_encode(rss->signature, rss->signature_len, buf, sizeof(buf));
+ buf[len] = '\0';
+
+ fprintf(of, "%s %d IN RRSIG (%s %d %d %d %llu %llu %d %s %s)\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_RRSIG],
+ get_dns_type(rss->type_covered, 0),
+ rss->algorithm, rss->labels,
+ rss->original_ttl,
+ timethuman(rss->signature_expiration),
+ timethuman(rss->signature_inception),
+ rss->key_tag,
+ convert_name(rss->signers_name, rss->signame_len),
+ buf);
+ }
+
+ if (sdomain->flags & DOMAIN_HAVE_DS) {
+ rss = (struct rrsig *)&sdrr->rrsig[INTERNAL_TYPE_DS];
+ len = mybase64_encode(rss->signature, rss->signature_len, buf, sizeof(buf));
+ buf[len] = '\0';
+
+ fprintf(of, "%s %d IN RRSIG (%s %d %d %d %llu %llu %d %s %s)\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_RRSIG],
+ get_dns_type(rss->type_covered, 0),
+ rss->algorithm, rss->labels,
+ rss->original_ttl,
+ timethuman(rss->signature_expiration),
+ timethuman(rss->signature_inception),
+ rss->key_tag,
+ convert_name(rss->signers_name, rss->signame_len),
+ buf);
+ }
+
+
+
+ if (sdomain->flags & DOMAIN_HAVE_TLSA) {
+ rss = (struct rrsig *)&sdrr->rrsig[INTERNAL_TYPE_TLSA];
+ len = mybase64_encode(rss->signature, rss->signature_len, buf, sizeof(buf));
+ buf[len] = '\0';
+
+ fprintf(of, "%s %d IN RRSIG (%s %d %d %d %llu %llu %d %s %s)\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_RRSIG],
+ get_dns_type(rss->type_covered, 0),
+ rss->algorithm, rss->labels,
+ rss->original_ttl,
+ timethuman(rss->signature_expiration),
+ timethuman(rss->signature_inception),
+ rss->key_tag,
+ convert_name(rss->signers_name, rss->signame_len),
+ buf);
+ }
+
+
+ if (sdomain->flags & DOMAIN_HAVE_SSHFP) {
+ rss = (struct rrsig *)&sdrr->rrsig[INTERNAL_TYPE_SSHFP];
+ len = mybase64_encode(rss->signature, rss->signature_len, buf, sizeof(buf));
+ buf[len] = '\0';
+
+ fprintf(of, "%s %d IN RRSIG (%s %d %d %d %llu %llu %d %s %s)\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_RRSIG],
+ get_dns_type(rss->type_covered, 0),
+ rss->algorithm, rss->labels,
+ rss->original_ttl,
+ timethuman(rss->signature_expiration),
+ timethuman(rss->signature_inception),
+ rss->key_tag,
+ convert_name(rss->signers_name, rss->signame_len),
+ buf);
+ }
+
+ if (sdomain->flags & DOMAIN_HAVE_SRV) {
+ rss = (struct rrsig *)&sdrr->rrsig[INTERNAL_TYPE_SRV];
+ len = mybase64_encode(rss->signature, rss->signature_len, buf, sizeof(buf));
+ buf[len] = '\0';
+
+ fprintf(of, "%s %d IN rrsig (%s %d %d %d %llu %llu %d %s %s)\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_RRSIG],
+ get_dns_type(rss->type_covered, 0),
+ rss->algorithm, rss->labels,
+ rss->original_ttl,
+ timethuman(rss->signature_expiration),
+ timethuman(rss->signature_inception),
+ rss->key_tag,
+ convert_name(rss->signers_name, rss->signame_len),
+ buf);
+ }
+
+
+ if (sdomain->flags & DOMAIN_HAVE_NAPTR) {
+ rss = (struct rrsig *)&sdrr->rrsig[INTERNAL_TYPE_NAPTR];
+ len = mybase64_encode(rss->signature, rss->signature_len, buf, sizeof(buf));
+ buf[len] = '\0';
+
+ fprintf(of, "%s %d IN RRSIG (%s %d %d %d %llu %llu %d %s %s)\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_RRSIG],
+ get_dns_type(rss->type_covered, 0),
+ rss->algorithm, rss->labels,
+ rss->original_ttl,
+ timethuman(rss->signature_expiration),
+ timethuman(rss->signature_inception),
+ rss->key_tag,
+ convert_name(rss->signers_name, rss->signame_len),
+ buf);
+ }
+
+
+ if (sdomain->flags & DOMAIN_HAVE_TXT) {
+ rss = (struct rrsig *)&sdrr->rrsig[INTERNAL_TYPE_TXT];
+ len = mybase64_encode(rss->signature, rss->signature_len, buf, sizeof(buf));
+ buf[len] = '\0';
+
+ fprintf(of, "%s %d IN RRSIG (%s %d %d %d %llu %llu %d %s %s)\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_RRSIG],
+ get_dns_type(rss->type_covered, 0),
+ rss->algorithm, rss->labels,
+ rss->original_ttl,
+ timethuman(rss->signature_expiration),
+ timethuman(rss->signature_inception),
+ rss->key_tag,
+ convert_name(rss->signers_name, rss->signame_len),
+ buf);
+ }
+
+ if (sdomain->flags & DOMAIN_HAVE_AAAA) {
+ rss = (struct rrsig *)&sdrr->rrsig[INTERNAL_TYPE_AAAA];
+ len = mybase64_encode(rss->signature, rss->signature_len, buf, sizeof(buf));
+ buf[len] = '\0';
+
+ fprintf(of, "%s %d IN RRSIG (%s %d %d %d %llu %llu %d %s %s)\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_RRSIG],
+ get_dns_type(rss->type_covered, 0),
+ rss->algorithm, rss->labels,
+ rss->original_ttl,
+ timethuman(rss->signature_expiration),
+ timethuman(rss->signature_inception),
+ rss->key_tag,
+ convert_name(rss->signers_name, rss->signame_len),
+ buf);
+ }
+
+ if (sdomain->flags & DOMAIN_HAVE_NSEC3) {
+ rss = (struct rrsig *)&sdrr->rrsig[INTERNAL_TYPE_NSEC3];
+ len = mybase64_encode(rss->signature, rss->signature_len, buf, sizeof(buf));
+ buf[len] = '\0';
+
+ fprintf(of, "%s %d IN RRSIG (%s %d %d %d %llu %llu %d %s %s)\n",
+ convert_name(sdomain->zone,sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_RRSIG],
+ get_dns_type(rss->type_covered, 0),
+ rss->algorithm, rss->labels,
+ rss->original_ttl,
+ timethuman(rss->signature_expiration),
+ timethuman(rss->signature_inception),
+ rss->key_tag,
+ convert_name(rss->signers_name, rss->signame_len),
+ buf);
+ }
+
+
+ if (sdomain->flags & DOMAIN_HAVE_NSEC3PARAM) {
+ rss = (struct rrsig *)&sdrr->rrsig[INTERNAL_TYPE_NSEC3PARAM];
+ len = mybase64_encode(rss->signature, rss->signature_len, buf, sizeof(buf));
+ buf[len] = '\0';
+
+ fprintf(of, "%s 0 IN RRSIG (%s %d %d %d %llu %llu %d %s %s)\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ get_dns_type(rss->type_covered, 0),
+ rss->algorithm, rss->labels,
+ 0, /* original ttl */
+ timethuman(rss->signature_expiration),
+ timethuman(rss->signature_inception),
+ rss->key_tag,
+ convert_name(rss->signers_name, rss->signame_len),
+ buf);
+ }
+
+ if (sdomain->flags & DOMAIN_HAVE_CNAME) {
+ rss = (struct rrsig *)&sdrr->rrsig[INTERNAL_TYPE_CNAME];
+ len = mybase64_encode(rss->signature, rss->signature_len, buf, sizeof(buf));
+ buf[len] = '\0';
+
+ fprintf(of, "%s %d IN RRSIG (%s %d %d %d %llu %llu %d %s %s)\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_RRSIG],
+ get_dns_type(rss->type_covered, 0),
+ rss->algorithm, rss->labels,
+ rss->original_ttl,
+ timethuman(rss->signature_expiration),
+ timethuman(rss->signature_inception),
+ rss->key_tag,
+ convert_name(rss->signers_name, rss->signame_len),
+ buf);
+ }
+
+ if (sdomain->flags & DOMAIN_HAVE_PTR) {
+ rss = (struct rrsig *)&sdrr->rrsig[INTERNAL_TYPE_PTR];
+ len = mybase64_encode(rss->signature, rss->signature_len, buf, sizeof(buf));
+ buf[len] = '\0';
+
+ fprintf(of, "%s %d IN RRSIG (%s %d %d %d %llu %llu %d %s %s)\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_RRSIG],
+ get_dns_type(rss->type_covered, 0),
+ rss->algorithm, rss->labels,
+ rss->original_ttl,
+ timethuman(rss->signature_expiration),
+ timethuman(rss->signature_inception),
+ rss->key_tag,
+ convert_name(rss->signers_name, rss->signame_len),
+ buf);
+ }
+
+
+
+ if (sdomain->flags & DOMAIN_HAVE_NS) {
+ rss = (struct rrsig *)&sdrr->rrsig[INTERNAL_TYPE_NS];
+ len = mybase64_encode(rss->signature, rss->signature_len, buf, sizeof(buf));
+ buf[len] = '\0';
+
+ fprintf(of, "%s %d IN RRSIG (%s %d %d %d %llu %llu %d %s %s)\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_RRSIG],
+ get_dns_type(rss->type_covered, 0),
+ rss->algorithm, rss->labels,
+ rss->original_ttl,
+ timethuman(rss->signature_expiration),
+ timethuman(rss->signature_inception),
+ rss->key_tag,
+ convert_name(rss->signers_name, rss->signame_len),
+ buf);
+ }
+
+ if (sdomain->flags & DOMAIN_HAVE_MX) {
+ rss = (struct rrsig *)&sdrr->rrsig[INTERNAL_TYPE_MX];
+ len = mybase64_encode(rss->signature, rss->signature_len, buf, sizeof(buf));
+ buf[len] = '\0';
+
+ fprintf(of, "%s %d IN RRSIG (%s %d %d %d %llu %llu %d %s %s)\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_RRSIG],
+ get_dns_type(rss->type_covered, 0),
+ rss->algorithm, rss->labels,
+ rss->original_ttl,
+ timethuman(rss->signature_expiration),
+ timethuman(rss->signature_inception),
+ rss->key_tag,
+ convert_name(rss->signers_name, rss->signame_len),
+ buf);
+ }
+
+ if (sdomain->flags & DOMAIN_HAVE_A) {
+ rss = (struct rrsig *)&sdrr->rrsig[INTERNAL_TYPE_A];
+ len = mybase64_encode(rss->signature, rss->signature_len, buf, sizeof(buf));
+ buf[len] = '\0';
+
+ fprintf(of, "%s %d IN RRSIG (%s %d %d %d %llu %llu %d %s %s)\n",
+ convert_name(sdomain->zone, sdomain->zonelen),
+ sdomain->ttl[INTERNAL_TYPE_RRSIG],
+ get_dns_type(rss->type_covered, 0),
+ rss->algorithm, rss->labels,
+ rss->original_ttl,
+ timethuman(rss->signature_expiration),
+ timethuman(rss->signature_inception),
+ rss->key_tag,
+ convert_name(rss->signers_name, rss->signame_len),
+ buf);
+ }
+ }
+
+ return 0;
+}
+
+int
+bindfile(int argc, char *argv[])
+{
+ ddDB *db;
+ char *zonefile;
+ char *zonename;
+ FILE *of = stdout;
+
+ if (argc != 3) {
+ usage(argc, argv);
+ exit(1);
+ }
+
+ zonename = argv[1];
+ zonefile = argv[2];
+
+#if __OpenBSD__
+ if (pledge("stdio rpath cpath", NULL) < 0) {
+ perror("pledge");
+ exit(1);
+ }
+#endif
+
+
+
+ /* open the database(s) */
+ db = dddbopen();
+ if (db == NULL) {
+ dolog(LOG_INFO, "dddbopen() failed\n");
+ return 1;
+ }
+
+ /* now we start reading our configfile */
+
+ if (parse_file(db, zonefile) < 0) {
+ dolog(LOG_INFO, "parsing config file failed\n");
+ return 1;
+ }
+
+ if (dump_db_bind(db, of, zonename) < 0) {
+ dddbclose(db);
+ return 1;
+ }
+
+ dddbclose(db);
+
+
+ return 0;
}
repomaster@centroid.eu