Commit f4ade46f authored by Evan Hunt's avatar Evan Hunt

Merge branch '428-remove-contrib-sdb' into 'master'

remove contrib/sdb

Closes #428

See merge request !1501
parents d27f41cb bcc2fd67
Pipeline #10233 passed with stages
in 23 minutes and 55 seconds
5165. [contrib] Removed SDB drivers from contrib; they're obsolete.
[GL #428]
5164. [bug] Correct errno to result translation in dlz filesystem
modules. [GL #884]
......
This directory contains contributed scripts, tools, libraries, and other
useful accessories to BIND 9. Contrib software is not supported by ISC,
but reported bugs will be fixed as time permits.
This directory contains scripts, tools, and other useful accessories to
BIND 9. Contrib software is not supported by ISC, but reported bugs will
be fixed as time permits.
- scripts/
Assorted useful scripts, including 'nanny' which monitors
named and restarts it in the event of a crash, 'zone-edit'
which enables editing of a dynamic zone, and others
which enables editing of a dynamic zone, and others.
- dane/
mkdane.sh generates TLSA records for use with DNS-based
Authentication of Named Entities (DANE)
Authentication of Named Entities (DANE).
- dnspriv/
Sample configuration for setting up a DNS-over-TLS server
using BIND with Nginx as a TLS proxy
using BIND with Nginx as a TLS proxy.
- kasp/
Scripts for converting key and signature policies from OpenDNSSEC
KASP format to the policy.conf format used by dnssec-keymgr.
- dlz/modules
Dynamically linkable DLZ modules that can be configured into
named at runtime, enabling access to external data sources including
LDAP, MySQL, Berkeley DB, perl scripts, etc
LDAP, MySQL, Berkeley DB, perl scripts, etc.
- dlz/drivers
Old-style DLZ drivers that can be linked into named at compile
time. (These are no longer actively maintained and are expected
to be deprecated eventually.)
- sdb/
SDB drivers: another mechanism for accessing external data
sources. (These are no longer actively maintained and are
expected to be deprecated eventually.)
External tools:
- https://gitlab.isc.org/isc-projects/queryperf
A DNS query performance testing tool
- https://gitlab.isc.org/isc-projects/perftcpdns
A performance testing tool for DNS over TCP
- https://gitlab.isc.org/isc-projects/dnsperf
DNS server performance testing tools, like 'queryperf' but more
advanced: 'dnsperf' focuses on authoritative server performance
and 'resperf' on recursive server performance. The patch that
adds support for EDNS Client Subnet has been applied to the
git repository.
Formerly, there was more software included in this directory, but we
have removed it in favour of using canonical upstream locations. You
can find the links to the nslint, query-loc and zkt, and other software
we find useful but do not necessarily support, at:
time. (These are no longer actively maintained and are expected
to be removed eventually.)
https://www.isc.org/community/tools/
Some links to useful software and other resources related to BIND 9 and
DNS can be found at https://www.isc.org/dns-tools-and-resources.
(Message trash:37216)
Date: Wed, 15 May 2002 20:44:45 +0100
To: <bind-workers@isc.org>
From: Nuno Miguel Rodrigues <nmr@co.sapo.pt>
Subject: Berkeley DB BIND9 SDB
Replied: Thu, 16 May 2002 11:47:35 +1000
Replied: Nuno Miguel Rodrigues <nmr@co.sapo.pt>
Return-Path: <bind-workers-bounce@isc.org>
X-X-Sender: <nmr@angelina.sl.pt>
MIME-Version: 1.0
X-ecartis-version: Ecartis v1.0.0
Sender: bind-workers-bounce@isc.org
Errors-To: bind-workers-bounce@isc.org
X-original-sender: nmr@co.sapo.pt
Precedence: bulk
X-list: bind-workers
Status:
Hello all,
I'm making available a BIND9 SDB using Berkeley DB 4.0.
You can get it at http://www.dhis.org/~nmr/bind9_berkeleydb_sdb-1.0.tar
Thanks,
--
Nuno M. Rodrigues <nmr@co.sapo.pt>
/*
* Copyright (C) 2002 Nuno M. Rodrigues.
*
* 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.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND NUNO M. RODRIGUES
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* BIND 9.1.x simple database driver
* implementation, using Berkeley DB.
*/
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <isc/file.h>
#include <isc/log.h>
#include <isc/lib.h>
#include <isc/mem.h>
#include <isc/region.h>
#include <isc/result.h>
#include <isc/types.h>
#include <isc/util.h>
#include <dns/sdb.h>
#include <dns/log.h>
#include <dns/lib.h>
#include <dns/ttl.h>
#include <named/bdb.h>
#include <named/globals.h>
#include <named/config.h>
#include <db.h>
#define DRIVERNAME "bdb"
static dns_sdbimplementation_t *bdb_imp;
static isc_result_t
bdb_create(const char *zone, int argc, char **argv,
void *unused, void **dbdata)
{
int ret;
UNUSED(zone);
UNUSED(unused);
if (argc < 1)
return ISC_R_FAILURE; /* database path must be given */
if (db_create((DB **)dbdata, NULL, 0) != 0) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_SDB, ISC_LOG_CRITICAL,
"db_create");
return ISC_R_FAILURE;
}
if (isc_file_exists(*argv) != true) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_SDB, ISC_LOG_CRITICAL,
"isc_file_exists: %s", *argv);
return ISC_R_FAILURE;
}
if ((ret = (*(DB **)dbdata)->open(*(DB **)dbdata, *argv, NULL, DB_HASH,
DB_RDONLY, 0)) != 0) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_SDB, ISC_LOG_CRITICAL,
"DB->open: %s",
db_strerror(ret));
return ISC_R_FAILURE;
}
return ISC_R_SUCCESS;
}
static isc_result_t
#ifdef DNS_CLIENTINFO_VERSION
bdb_lookup(const char *zone, const char *name, void *dbdata,
dns_sdblookup_t *l, dns_clientinfomethods_t *methods,
dns_clientinfo_t *clientinfo)
#else
bdb_lookup(const char *zone, const char *name, void *dbdata,
dns_sdblookup_t *l)
#endif /* DNS_CLIENTINFO_VERSION */
{
int ret;
char *type, *rdata;
dns_ttl_t ttl;
isc_consttextregion_t ttltext;
DBC *c;
DBT key, data;
char *last;
UNUSED(zone);
#ifdef DNS_CLIENTINFO_VERSION
UNUSED(methods);
UNUSED(clientinfo);
#endif /* DNS_CLIENTINFO_VERSION */
if ((ret = ((DB *)dbdata)->cursor((DB *)dbdata, NULL, &c, 0)) != 0) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_SDB, ISC_LOG_ERROR,
"DB->cursor: %s",
db_strerror(ret));
return ISC_R_FAILURE;
}
memset(&key, 0, sizeof(DBT));
memset(&data, 0, sizeof(DBT));
(const char *)key.data = name;
key.size = strlen(name);
ret = c->c_get(c, &key, &data, DB_SET);
while (ret == 0) {
((char *)key.data)[key.size] = 0;
((char *)data.data)[data.size] = 0;
ttltext.base = strtok_r((char *)data.data, " ", &last);
ttltext.length = strlen(ttltext.base);
dns_ttl_fromtext((isc_textregion_t *)&ttltext, &ttl);
type = strtok_r(NULL, " ", &last);
rdata = type + strlen(type) + 1;
if (dns_sdb_putrr(l, type, ttl, rdata) != ISC_R_SUCCESS) {
isc_log_write(dns_lctx,
DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_SDB, ISC_LOG_ERROR,
"dns_sdb_putrr");
return ISC_R_FAILURE;
}
ret = c->c_get(c, &key, &data, DB_NEXT_DUP);
}
c->c_close(c);
return ISC_R_SUCCESS;
}
static isc_result_t
bdb_allnodes(const char *zone, void *dbdata, dns_sdballnodes_t *n)
{
int ret;
char *type, *rdata;
dns_ttl_t ttl;
isc_consttextregion_t ttltext;
DBC *c;
DBT key, data;
UNUSED(zone);
if ((ret = ((DB *)dbdata)->cursor((DB *)dbdata, NULL, &c, 0)) != 0) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_SDB, ISC_LOG_ERROR,
"DB->cursor: %s",
db_strerror(ret));
return ISC_R_FAILURE;
}
memset(&key, 0, sizeof(DBT));
memset(&data, 0, sizeof(DBT));
while (c->c_get(c, &key, &data, DB_NEXT) == 0) {
char *last;
((char *)key.data)[key.size] = 0;
((char *)data.data)[data.size] = 0;
ttltext.base = strtok_r((char *)data.data, " ", &last);
ttltext.length = strlen(ttltext.base);
dns_ttl_fromtext((isc_textregion_t *)&ttltext, &ttl);
type = strtok_r(NULL, " ", &last);
rdata = type + strlen(type) + 1;
if (dns_sdb_putnamedrr(n, key.data, type, ttl, rdata) !=
ISC_R_SUCCESS) {
isc_log_write(dns_lctx,
DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_SDB, ISC_LOG_ERROR,
"dns_sdb_putnamedrr");
return ISC_R_FAILURE;
}
}
c->c_close(c);
return ISC_R_SUCCESS;
}
static isc_result_t
bdb_destroy(const char *zone, void *unused, void **dbdata)
{
UNUSED(zone);
UNUSED(unused);
(*(DB **)dbdata)->close(*(DB **)dbdata, 0);
return ISC_R_SUCCESS;
}
isc_result_t
bdb_init(void)
{
static dns_sdbmethods_t bdb_methods = {
bdb_lookup,
NULL,
bdb_allnodes,
bdb_create,
bdb_destroy,
NULL /* lookup2 */
};
return dns_sdb_register(DRIVERNAME, &bdb_methods, NULL, 0, ns_g_mctx,
&bdb_imp);
}
void
bdb_clear(void)
{
if (bdb_imp != NULL)
dns_sdb_unregister(&bdb_imp);
}
/*
* Copyright (C) 2002 Nuno M. Rodrigues.
*
* 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.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND NUNO M. RODRIGUES
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef BDB_H
#define BDB_H 1
#include <isc/types.h>
/*
* Prototypes.
*/
isc_result_t bdb_init(void);
void bdb_clear(void);
#endif /* BDB_H */
/*
* Copyright (C) 2002 Nuno M. Rodrigues.
*
* 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.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND NUNO M. RODRIGUES
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdio.h>
#include <isc/mem.h>
#include <isc/result.h>
#include <isc/types.h>
#include <isc/util.h>
#include <dns/db.h>
#include <dns/dbiterator.h>
#include <dns/fixedname.h>
#include <dns/name.h>
#include <dns/rdata.h>
#include <dns/rdataset.h>
#include <dns/rdatasetiter.h>
#include <dns/rdatatype.h>
#include <dns/ttl.h>
#include <dns/types.h>
#include <db.h>
#define MAX_RDATATEXT 63 + 4 + 65535 + 2 /* ttl + type + rdata + sep */
/*
* Returns a valid 'DB' handle.
*
* Requires:
* 'file' is a valid non-existant path.
*/
DB *
bdb_init(const char *file)
{
DB *db;
REQUIRE(db_create(&db, NULL, 0) == 0);
REQUIRE(db->set_flags(db, DB_DUP) == 0);
REQUIRE(db->open(db, file, NULL, DB_HASH, DB_CREATE | DB_EXCL, 0) == 0);
return db;
}
/*
* Puts resource record data on 'db'.
*/
isc_result_t
bdb_putrdata(DB *db, dns_name_t *name, dns_ttl_t ttl, dns_rdata_t *rdata)
{
static DBT key, data;
isc_buffer_t keybuf, databuf;
char nametext[DNS_NAME_MAXTEXT];
char rdatatext[MAX_RDATATEXT];
isc_buffer_init(&keybuf, nametext, DNS_NAME_MAXTEXT);
dns_name_totext(name, true, &keybuf);
key.data = isc_buffer_base(&keybuf);
key.size = isc_buffer_usedlength(&keybuf);
isc_buffer_init(&databuf, rdatatext, MAX_RDATATEXT);
dns_ttl_totext(ttl, false, true, &databuf);
*(char *)isc_buffer_used(&databuf) = ' ';
isc_buffer_add(&databuf, 1);
dns_rdatatype_totext(rdata->type, &databuf); /* XXX private data */
*(char *)isc_buffer_used(&databuf) = ' ';
isc_buffer_add(&databuf, 1);
dns_rdata_totext(rdata, NULL, &databuf);
data.data = isc_buffer_base(&databuf);
data.size = isc_buffer_usedlength(&databuf);
REQUIRE(db->put(db, NULL, &key, &data, 0) == 0);
return ISC_R_SUCCESS;
}
isc_result_t
bdb_destroy(DB *db)
{
return (db->close(db, 0) == 0) ? ISC_R_SUCCESS : ISC_R_FAILURE;
}
void
usage(const char *prog)
{
fprintf(stderr, "Usage: %s <origin> <zonefile> <db>\n", prog);
exit(1);
}
int
main(int argc, char *argv[])
{
isc_mem_t *mctx = NULL;
isc_buffer_t b;
int n;
dns_fixedname_t origin, name;
dns_db_t *db = NULL;
dns_dbiterator_t *dbiter = NULL;
isc_result_t res;
dns_dbnode_t *node = NULL;
dns_rdataset_t rdataset;
dns_rdatasetiter_t *rdatasetiter = NULL;
dns_rdata_t rdata;
DB *bdb;
if (argc != 4) usage(*argv);
REQUIRE(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
n = strlen(argv[1]);
isc_buffer_init(&b, argv[1], n);
isc_buffer_add(&b, n);
dns_fixedname_init(&origin);
REQUIRE(dns_name_fromtext(dns_fixedname_name(&origin), &b, dns_rootname,
0, NULL) == ISC_R_SUCCESS);
REQUIRE(dns_db_create(mctx, "rbt", dns_fixedname_name(&origin),
dns_dbtype_zone, dns_rdataclass_in, 0, NULL,
&db) == ISC_R_SUCCESS);
REQUIRE(dns_db_load(db, argv[2], dns_masterformat_text, 0)
== ISC_R_SUCCESS);
REQUIRE(dns_db_createiterator(db, 0, &dbiter) == ISC_R_SUCCESS);
dns_rdataset_init(&rdataset);
dns_rdata_init(&rdata);
dns_fixedname_init(&name);
bdb = bdb_init(argv[3]);
for (res = dns_dbiterator_first(dbiter); res == ISC_R_SUCCESS;
res = dns_dbiterator_next(dbiter)) {
dns_dbiterator_current(dbiter, &node, dns_fixedname_name(&name));
REQUIRE(dns_db_allrdatasets(db, node, NULL, 0, &rdatasetiter)
== ISC_R_SUCCESS);
for (res = dns_rdatasetiter_first(rdatasetiter);
res == ISC_R_SUCCESS;
res = dns_rdatasetiter_next(rdatasetiter)) {
dns_rdatasetiter_current(rdatasetiter, &rdataset);
res = dns_rdataset_first(&rdataset);
while (res == ISC_R_SUCCESS) {
dns_rdataset_current(&rdataset, &rdata);
REQUIRE(bdb_putrdata(bdb,
dns_fixedname_name(&name),
rdataset.ttl, &rdata)
== ISC_R_SUCCESS);
dns_rdata_reset(&rdata);
res = dns_rdataset_next(&rdataset);
}
dns_rdataset_disassociate(&rdataset);
}
dns_rdatasetiter_destroy(&rdatasetiter);
dns_db_detachnode(db, &node);
}
dns_dbiterator_destroy(&dbiter);
REQUIRE(bdb_destroy(bdb) == ISC_R_SUCCESS);
return 0;
}
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
/*
* A simple database driver that returns basic information about
* files and directories in the Unix file system as DNS data.
*/
#include <config.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include <isc/mem.h>
#include <isc/print.h>
#include <isc/result.h>
#include <isc/util.h>
#include <dns/sdb.h>
#include <named/globals.h>
#include "dirdb.h"
static dns_sdbimplementation_t *dirdb = NULL;
#define CHECK(op) \
do { result = (op); \
if (result != ISC_R_SUCCESS) return (result); \
} while (0)
#define CHECKN(op) \
do { n = (op); \
if (n < 0) return (ISC_R_FAILURE); \
} while (0)
/*
* This database operates on relative names.
*
* Any name will be interpreted as a pathname offset from the directory
* specified in the configuration file.
*/
#ifdef DNS_CLIENTINFO_VERSION
static isc_result_t
dirdb_lookup(const char *zone, const char *name, void *dbdata,
dns_sdblookup_t *lookup, dns_clientinfomethods_t *methods,
dns_clientinfo_t *clientinfo)
#else
static isc_result_t
dirdb_lookup(const char *zone, const char *name, void *dbdata,
dns_sdblookup_t *lookup)
#endif /* DNS_CLIENTINFO_VERSION */
{
char filename[255];
char filename2[255];