Merge branch 'ondrej/remove-cruft-from-contrib' into 'main'

Remove old-style DLZ drivers linked into named at compile time

Closes #2814

See merge request isc-projects/bind9!5427
This commit is contained in:
Ondřej Surý
2021-09-20 21:01:40 +00:00
59 changed files with 51 additions and 12228 deletions

View File

@@ -1,3 +1,6 @@
5720. [contrib] Remove old-style DLZ drivers that had to be enabled
during compile time. [GL #2814]
5719. [func] The "masterfile-format" format "map" has been removed.
[GL #2882]

View File

@@ -105,7 +105,6 @@ TESTS += \
checknames \
checkzone \
database \
dlz \
dlzexternal \
dns64 \
dscp \

View File

@@ -1 +0,0 @@
prereq.sh

View File

@@ -1,17 +0,0 @@
#!/bin/sh
#
# 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 https://mozilla.org/MPL/2.0/.
#
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
rm -f ns*/named.conf
rm -f dig.out.*
rm -f */named.memstats
rm -f */named.run
rm -f ns*/named.lock
rm -f ns*/managed-keys.bind*

View File

@@ -1,6 +0,0 @@
Copyright (C) Internet Systems Consortium, Inc. ("ISC")
See COPYRIGHT in the source root or https://isc.org/copyright.html for terms.
The contents of this file is not read by the filesystem driver.
This is the file for "DNAME 10 example.net.".

View File

@@ -1,6 +0,0 @@
Copyright (C) Internet Systems Consortium, Inc. ("ISC")
See COPYRIGHT in the source root or https://isc.org/copyright.html for terms.
The contents of this file is not read by the filesystem driver.
This is the file for "NS 10 example.com.".

View File

@@ -1,6 +0,0 @@
Copyright (C) Internet Systems Consortium, Inc. ("ISC")
See COPYRIGHT in the source root or https://isc.org/copyright.html for terms.
The contents of this file is not read by the filesystem driver.
This is the file for "SOA 10 ns.example.com. root.example.com. 2010062900 None None None None" which is a malformed SOA record.

View File

@@ -1,6 +0,0 @@
Copyright (C) Internet Systems Consortium, Inc. ("ISC")
See COPYRIGHT in the source root or https://isc.org/copyright.html for terms.
The contents of this file is not read by the filesystem driver.
This is the file for "DNAME 10 example.net.".

View File

@@ -1,6 +0,0 @@
Copyright (C) Internet Systems Consortium, Inc. ("ISC")
See COPYRIGHT in the source root or https://isc.org/copyright.html for terms.
The contents of this file is not read by the filesystem driver.
This is the file for "NS 10 example.com.".

View File

@@ -1,6 +0,0 @@
Copyright (C) Internet Systems Consortium, Inc. ("ISC")
See COPYRIGHT in the source root or https://isc.org/copyright.html for terms.
The contents of this file is not read by the filesystem driver.
This is the file for "SOA 10 ns.example.com. root.example.com. 2010062900 0 0 0 10".

View File

@@ -1,6 +0,0 @@
Copyright (C) Internet Systems Consortium, Inc. ("ISC")
See COPYRIGHT in the source root or https://isc.org/copyright.html for terms.
The contents of this file are not read by the filesystem driver.
The presence of this file allows 10.53.0.1 to transfer this zone.

View File

@@ -1,25 +0,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.
*/
options {
query-source address 10.53.0.1;
notify-source 10.53.0.1;
transfer-source 10.53.0.1;
port @PORT@;
pid-file "named.pid";
listen-on { 10.53.0.1; };
listen-on-v6 { none; };
recursion no;
};
dlz fszone {
database "filesystem dns-root/ dns.d xfr.d 0 =";
};

View File

@@ -1,18 +0,0 @@
#!/bin/sh
#
# 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 https://mozilla.org/MPL/2.0/.
#
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
. ../conf.sh
if ! $FEATURETEST --with-dlz-filesystem; then
echo_i "DLZ filesystem driver not supported"
exit 255
fi
exit 0

View File

@@ -1,15 +0,0 @@
#!/bin/sh
#
# 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 https://mozilla.org/MPL/2.0/.
#
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
. ../conf.sh
$SHELL clean.sh
copy_setports ns1/named.conf.in ns1/named.conf

View File

@@ -1,74 +0,0 @@
#!/bin/sh
#
# 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 https://mozilla.org/MPL/2.0/.
#
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
. ../conf.sh
status=0
n=0
rm -f dig.out.*
DIGOPTS="+tcp +noadd +nosea +nostat +nocmd +dnssec -p ${PORT}"
# Check the example.com. domain
echo_i "checking DNAME at apex works ($n)"
ret=0
$DIG $DIGOPTS +norec foo.example.com. \
@10.53.0.1 a > dig.out.ns1.test$n || ret=1
grep "status: NOERROR" dig.out.ns1.test$n > /dev/null || ret=1
grep "example.com..*DNAME.*example.net." dig.out.ns1.test$n > /dev/null || ret=1
grep "foo.example.com..*CNAME.*foo.example.net." dig.out.ns1.test$n > /dev/null || ret=1
grep "flags:[^;]* aa[ ;]" dig.out.ns1.test$n > /dev/null || ret=1
n=`expr $n + 1`
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
echo_i "checking DLZ IXFR=2010062899 (less than serial) ($n)"
ret=0
$DIG $DIGOPTS ixfr=2010062899 example.com @10.53.0.1 +all > dig.out.ns1.test$n
grep "example.com..*IN.IXFR" dig.out.ns1.test$n > /dev/null || ret=1
grep "example.com..*10.IN.DNAME.example.net." dig.out.ns1.test$n > /dev/null || ret=1
grep "example.com..*10.IN.NS.example.com." dig.out.ns1.test$n > /dev/null || ret=1
n=`expr $n + 1`
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
echo_i "checking DLZ IXFR=2010062900 (equal serial) ($n)"
ret=0
$DIG $DIGOPTS ixfr=2010062900 example.com @10.53.0.1 +all > dig.out.ns1.test$n
grep "example.com..*IN.IXFR" dig.out.ns1.test$n > /dev/null || ret=1
grep "example.com..*10.IN.DNAME.example.net." dig.out.ns1.test$n > /dev/null && ret=1
grep "example.com..*10.IN.NS.example.com." dig.out.ns1.test$n > /dev/null && ret=1
n=`expr $n + 1`
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
echo_i "checking DLZ IXFR=2010062901 (greater than serial) ($n)"
ret=0
$DIG $DIGOPTS ixfr=2010062901 example.com @10.53.0.1 +all > dig.out.ns1.test$n
grep "example.com..*IN.IXFR" dig.out.ns1.test$n > /dev/null || ret=1
grep "example.com..*10.IN.DNAME.example.net." dig.out.ns1.test$n > /dev/null && ret=1
grep "example.com..*10.IN.NS.example.com." dig.out.ns1.test$n > /dev/null && ret=1
n=`expr $n + 1`
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
echo_i "checking DLZ with a malformed SOA record"
ret=0
$DIG $DIGOPTS broken.com type600 @10.53.0.1 > dig.out.ns1.test$n
grep status: dig.out.ns1.test$n > /dev/null || ret=1
n=`expr $n + 1`
if [ $ret != 0 ]; then echo_i "failed"; fi
status=`expr $status + $ret`
echo_i "exit status: $status"
[ $status -eq 0 ] || exit 1

View File

@@ -150,7 +150,6 @@ AS_IF([test "$enable_developer" = "yes"],
test "${enable_fixed_rrset+set}" = set || enable_fixed_rrset=yes
test "${enable_querytrace+set}" = set || enable_querytrace=yes
test "${with_cmocka+set}" = set || with_cmocka=yes
test "${with_dlz_filesystem+set}" = set || with_dlz_filesystem=yes
test "${with_zlib+set}" = set || with_zlib=yes
test "${enable_warn_error+set}" = set || enable_warn_error=yes
])
@@ -1416,24 +1415,6 @@ AC_ARG_ENABLE(auto-validation,
AS_IF([test "$enable_auto_validation" = "no"],[validation_default=yes])
AC_DEFINE_UNQUOTED([VALIDATION_DEFAULT], ["$validation_default"], [the default value of dnssec-validation option])
#
# Configure any DLZ drivers.
#
# If config.dlz.in selects one or more DLZ drivers, it will set
# CONTRIB_DLZ to a non-empty value, which will be our clue to
# build DLZ drivers in contrib.
#
# This section has to come after the libtool stuff because it needs to
# know how to name the driver object files.
#
CONTRIB_DLZ=""
DLZ_DRIVER_INCLUDES=""
DLZ_DRIVER_LIBS=""
DLZ_DRIVER_SRCS=""
DLZ_DRIVER_OBJS=""
DLZ_SYSTEM_TEST=""
#
#
# Response policy rewriting using DNS Response Policy Service (DNSRPS)
@@ -1513,39 +1494,6 @@ AS_IF([test "$enable_dnsrps" != "no"],[
AC_DEFINE([USE_DNSRPS], [1], [Enable DNS Response Policy Service API])
])
# FIXME BEGIN
#sinclude(contrib/dlz/config.dlz.in)
# AC_MSG_CHECKING(contributed DLZ drivers)
#
# if test -n "$CONTRIB_DLZ"
# then
# AC_MSG_RESULT(yes)
# DLZ_DRIVER_RULES=contrib/dlz/drivers/rules
# AC_CONFIG_FILES([$DLZ_DRIVER_RULES
# contrib/dlz/modules/mysql/Makefile
# contrib/dlz/modules/mysqldyn/Makefile])
# else
# AC_MSG_RESULT(no)
# DLZ_DRIVER_RULES=/dev/null
# fi
#
# AC_SUBST(CONTRIB_DLZ)
# AC_SUBST(DLZ_DRIVER_INCLUDES)
# AC_SUBST(DLZ_DRIVER_LIBS)
# AC_SUBST(DLZ_DRIVER_SRCS)
# AC_SUBST(DLZ_DRIVER_OBJS)
# AC_SUBST(DLZ_SYSTEM_TEST)
# AC_SUBST_FILE(DLZ_DRIVER_RULES)
# this ensures the configure summary report comes out right
test -z "$with_dlz_bdb" && with_dlz_bdb=no
test -z "$with_dlz_ldap" && with_dlz_ldap=no
test -z "$with_dlz_mysql" && with_dlz_mysql=no
test -z "$with_dlz_odbc" && with_dlz_odbc=no
test -z "$with_dlz_postgres" && with_dlz_postgres=no
test -z "$with_dlz_filesystem" && with_dlz_filesystem=no
test -z "$with_dlz_stub" && with_dlz_stub=no
# FIXME END
AC_CHECK_HEADERS([glob.h])
#
@@ -1682,24 +1630,6 @@ report() {
test "auto" = "$validation_default" && echo " DNSSEC validation active by default (--enable-auto-validation)"
echo " Dynamically loadable zone (DLZ) drivers:"
test "no" = "$with_dlz_bdb" || \
echo " Berkeley DB (--with-dlz-bdb)"
test "no" = "$with_dlz_ldap" || \
echo " LDAP (--with-dlz-ldap)"
test "no" = "$with_dlz_mysql" || \
echo " MySQL (--with-dlz-mysql)"
test "no" = "$with_dlz_odbc" || \
echo " ODBC (--with-dlz-odbc)"
test "no" = "$with_dlz_postgres" || \
echo " Postgres (--with-dlz-postgres)"
test "no" = "$with_dlz_filesystem" || \
echo " Filesystem (--with-dlz-filesystem)"
test "no" = "$with_dlz_stub" || \
echo " Stub (--with-dlz-stub)"
test "$with_dlz_bdb $with_dlz_ldap $with_dlz_mysql $with_dlz_odbc $with_dlz_postgres $with_dlz_filesystem $with_dlz_stub" = "no no no no no no no" && \
echo " None"
echo "-------------------------------------------------------------------------------"
echo "Features disabled or unavailable on this platform:"

View File

@@ -8,32 +8,11 @@ be fixed as time permits.
named and restarts it in the event of a crash, 'zone-edit'
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).
- dnspriv/
Sample configuration for setting up a DNS-over-TLS server
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.
- 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 removed eventually.)
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.

View File

@@ -1,137 +0,0 @@
#!/bin/sh
# Copyright (C) 2010, 2012 Internet Systems Consortium, Inc. ("ISC")
#
# Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC 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.
#
# Generate a DNS RR from an x.509 certificate
# Currently only supports TLSA, but can be extended to support
# other DANE types such as SMIMEA in the future.
#
# Requires: openssl
USAGE="$BASENAME [options] <filename>
Options:
-f <input format>: PEM | DLR
-n <name>: record name (default: _443._tcp)
-o <origin>: zone origin (default: none; name will be relative)
-m <matching type>: NONE (0) | SHA256 (1) | SHA512 (2)
-r <RR type>: TLSA
-s <selector>: FULL (0) | PK (1)
-t <ttl>: TTL of the TLSA record (default: none)
-u <certificate usage>: CA (0) | SERVICE (1) | TA (2) | DOMAIN (3)"
NM="_443._tcp"
CU=2
SELECTOR=0
MTYPE=1
IN=
FORM=PEM
TTL=
RRTYPE=TLSA
BASENAME=`basename $0`;
while getopts "xn:o:u:s:t:m:i:f:r:" c; do
case $c in
x) set -x; DEBUG=-x;;
m) MTYPE="$OPTARG";;
n) NM="$OPTARG";;
o) ORIGIN="$OPTARG";;
r) RRTYPE="$OPTARG";;
s) SELECTOR="$OPTARG";;
t) TTL="$OPTARG";;
u) CU="$OPTARG";;
*) echo "$USAGE" 1>&2; exit 1;;
esac
done
shift `expr $OPTIND - 1 || true`
if test "$#" -eq 1; then
IN=$1
else
echo "$USAGE" 1>&2; exit 1
fi
ORIGIN=`echo $ORIGIN | sed 's/\([^.]$\)/\1./'`
if [ -n "$ORIGIN" ]; then
NM=`echo $NM | sed 's/\.$//'`
NM="$NM.$ORIGIN"
fi
case "$CU" in
[Cc][Aa]) CU=0;;
[Ss][Ee][Rr][Vv]*) CU=1;;
[Tt][Aa]) CU=2;;
[Dd][Oo][Mm]*) CU=3;;
[0123]) ;;
*) echo "bad certificate usage -u \"$CU\"" 1>&2; exit 1;;
esac
case "$SELECTOR" in
[Ff][Uu][Ll][Ll]) SELECTOR=0;;
[Pp][Kk]) SELECTOR=1;;
[01]) ;;
*) echo "bad selector -s \"$SELECTOR\"" 1>&2; exit 1;;
esac
case "$MTYPE" in
0|[Nn][Oo][Nn][Ee]) HASH='od -A n -v -t xC';;
1|[Ss][Hh][Aa]256) HASH='openssl dgst -sha256';;
2|[Ss][Hh][Aa]512) HASH='openssl dgst -sha512';;
*) echo "bad matching type -m \"$MTYPE\"" 1>&2; exit 1;;
esac
case "$FORM" in
[Pp][Ee][Mm]) FORM=PEM;;
[Dd][Ll][Rr]) FORM=DLR;;
*) echo "bad input file format -f \"$FORM\"" 1>&2; exit 1
esac
case "$RRTYPE" in
[Tt][Ll][Ss][Aa]) RRTYPE=TLSA;;
*) echo "invalid RR type" 1>&2; exit 1
esac
if test -z "$IN" -o ! -s "$IN"; then
echo "bad input file -i \"$IN\"" 1>&2; exit 1
fi
echo "; $BASENAME -o$NM -u$CU -s$SELECTOR -m$MTYPE -f$FORM $IN"
(if test "$SELECTOR" = 0; then
openssl x509 -in "$IN" -inform "$FORM" -outform DER
else
openssl x509 -in "$IN" -inform "$FORM" -noout -pubkey \
| sed -e '/PUBLIC KEY/d' \
| openssl base64 -d
fi) \
| $HASH \
| awk '
# format Association Data as in Appendix C of the DANE RFC
BEGIN {
print "'"$NM\t\t$TTL\tIN TLSA\t$CU $SELECTOR $MTYPE"' (";
leader = "\t\t\t\t\t";
}
/.+/ {
gsub(/ +/, "", $0);
buf = buf $0;
while (length(buf) >= 36) {
print leader substr(buf, 1, 36);
buf = substr(buf, 37);
}
}
END {
if (length(buf) > 34)
print leader buf "\n" leader ")";
else
print leader buf " )";
}'

View File

@@ -1,26 +0,0 @@
-----BEGIN CERTIFICATE-----
MIIEVDCCArwCCQCrWNJOd60q9jANBgkqhkiG9w0BAQUFADBsMQswCQYDVQQGEwJO
TDEWMBQGA1UECBMNTm9vcmQtSG9sbGFuZDESMBAGA1UEBxMJQW1zdGVyZGFtMQww
CgYDVQQKEwNPUzMxIzAhBgNVBAMTGmRhbmUua2lldi5wcmFjdGljdW0ub3MzLm5s
MB4XDTEyMDExNjE2NTcwM1oXDTIyMDExMzE2NTcwM1owbDELMAkGA1UEBhMCTkwx
FjAUBgNVBAgTDU5vb3JkLUhvbGxhbmQxEjAQBgNVBAcTCUFtc3RlcmRhbTEMMAoG
A1UEChMDT1MzMSMwIQYDVQQDExpkYW5lLmtpZXYucHJhY3RpY3VtLm9zMy5ubDCC
AaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBAOYshKWv5Z8KKmslDe5oesjF
xgT1fSbOshGRQP+sOMS5y76JIwguf4Fia2rV3qDIdxx048qn9hMFSu+jZz5I/+R7
P3r5h94oGmgjCyS52hqY3L5RGVtg5C/XUXwyjZg+JqgnyHerkU7kwb/erUi9Jb5f
LEc7qcHLvd2gw3TQ1Yw4nMPW2MIGYuGc92jzJEG399FK6olmznwyoXIqs4Yj0AgC
mp5HAog/i5d6Gh5Skr+K1yI51AOTN7hqOsYPoAEpBFIXe/F5hgmgWhMPAzRXpSEm
KfvduOcOKp5lVoc8T3ykauSosXjwX7MZAF4cHH1L1336NANVY8EmqiwzKLkA55kK
yXh/AdqC90w9S2Z0zOzh/Uxu+eZkT0Y17e2jnYsOL3yOBtrndWITvT1ggxF1vikE
QrSvxa5vRrdphVoGfBCX5heWJSnhZvIq7hDduYG4zW/xfT1wcjFpA42/vBpEnI0N
MbxoPF884mFI5C7Ju9TZ8mFWmyW1PB1/wt3/a0ysBQIDAQABMA0GCSqGSIb3DQEB
BQUAA4IBgQArKr4GPpyGrEofeDU3IJEHnIJ2qcLF0exXZN5SP92r3qs/005v5sug
VFgKZ4WmY1ldkBMrk9Rzkp6B+giH0v/3ioHH0BS5d3irasnl5pD29anpK7X7q3G4
V65ptuGL3MsLpvzZ1LCEo082NRSMSV1I/mNZA7iI7B3rJhBUjt1I1j+GUTpFYkaY
MUjA1duC1zpMNQpCu2YddjQw/GyOX50T6ht2qlKkw1jl6gQAD3lGGDA6ts7qTpqO
nHTXPBsLe68W3t52lrXi8gb3dxAPVyfhaE1BMvXmkvR69nVuqLQhAAvgMbXY8CIO
Q2tR+xVP6VlTM8E6JAP53gjl3cWiL9YYLjOVk+JjdEUCILwU8+QP8z8IRSawnDQl
BwLoo1KzMszLD53izysziCO5KvxhwLa4q9ta9xjtjdqXwpjka4KgGxSBSGjPpPLD
Ymi//0pZH0Jli/dZGJAtPkJt/h1f8PxqISBx9tqL2DP+LlYNh3dejukzPAW2+461
ZYnZENteqQM=
-----END CERTIFICATE-----

View File

@@ -1 +0,0 @@
Makefile

File diff suppressed because it is too large Load Diff

View File

@@ -1,508 +0,0 @@
# Copyright (C) 2005 Internet Systems Consortium, Inc. ("ISC")
#
# 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 ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC 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.
#
# Shorthand. Note quoting: DLZ_DRIVER_DIR expanded in Makefile, not here.
#
dlzdir='${DLZ_DRIVER_DIR}'
#
# Private autoconf macro to simplify configuring drivers:
#
# DLZ_ADD_DRIVER(DEFINE, DRIVER, INCLUDES, LIBS)
#
# where:
# DEFINE is FOO (to define -DDLZ_FOO)
# DRIVER is dlz_foo_driver (sources without the .c)
# INCLUDES is any necessary include definitions
# LIBS is any necessary library definitions
#
AC_DEFUN([DLZ_ADD_DRIVER], [
CONTRIB_DLZ="$CONTRIB_DLZ -DDLZ_$1"
for i in $2
do
DLZ_DRIVER_SRCS="$DLZ_DRIVER_SRCS $dlzdir/$i.c"
DLZ_DRIVER_OBJS="$DLZ_DRIVER_OBJS $i.$O"
done
if test -n "$3"
then
DLZ_DRIVER_INCLUDES="$DLZ_DRIVER_INCLUDES $3"
DLZ_DRIVER_$1_INCLUDES="$3"
fi
if test -n "$4"
then
DLZ_DRIVER_LIBS="$DLZ_DRIVER_LIBS $4"
DLZ_DRIVER_$1_LIBS="$4"
fi
])
#
# Check for the various DLZ drivers
#
#
# Was --with-dlz-postgres specified?
#
AC_MSG_CHECKING(for Postgres DLZ driver)
AC_ARG_WITH(dlz_postgres,
AS_HELP_STRING([--with-dlz-postgres[=PATH]],
[Build with Postgres DLZ driver [yes|no|path].
(Required to use Postgres with DLZ)]),
use_dlz_postgres="$withval", use_dlz_postgres="no")
if test "$use_dlz_postgres" != "no"
then
if test "$use_dlz_postgres" != "yes"
then
AC_PATH_PROGS(PG_CONFIG, pg_config, [not found], $use_dlz_postgres/bin)
else
AC_PATH_PROGS(PG_CONFIG, pg_config, [not found])
fi
if test "$PG_CONFIG" != "not found"
then
use_dlz_postgres=`$PG_CONFIG --includedir`
use_dlz_postgres_lib=`$PG_CONFIG --libdir`
else
pgprefix="$use_dlz_postgres"
use_dlz_postgres="$pgprefix/include"
use_dlz_postgres_lib="$pgprefix/lib"
fi
fi
if test "$use_dlz_postgres" = "yes/include"
then
# User did not specify path and Postgres didn't say - guess it
pgdirs="/usr /usr/local /usr/local/pgsql /usr/pkg"
for d in $pgdirs
do
if test -f $d/include/libpq-fe.h
then
use_dlz_postgres=$d/include
use_dlz_postgres_lib=$d/lib
break
fi
done
fi
if test "$use_dlz_postgres" = "yes/include"
then
# Still no joy, give up
AC_MSG_RESULT(not found)
AC_MSG_ERROR(
[No pg_config and PostgreSQL was not found in any of $pgdirs; use --with-dlz-postgres=/path or put pg_config in your path])
fi
case "$use_dlz_postgres" in
no)
AC_MSG_RESULT(no)
;;
*)
DLZ_ADD_DRIVER(POSTGRES, dlz_postgres_driver,
[-I$use_dlz_postgres],
[-L$use_dlz_postgres_lib -lpq])
AC_MSG_RESULT(
[using PostgreSQL from $use_dlz_postgres_lib and $use_dlz_postgres])
;;
esac
#
# Was --with-dlz-mysql specified?
#
AC_MSG_CHECKING(for MySQL DLZ driver)
AC_ARG_WITH(dlz_mysql,
AS_HELP_STRING([--with-dlz-mysql[=PATH]],
[Build with MySQL DLZ driver [yes|no|path].
(Required to use MySQL with DLZ)]),
use_dlz_mysql="$withval", use_dlz_mysql="no")
mysql_include=""
mysql_lib=""
if test "$use_dlz_mysql" = "yes"
then
AC_CHECK_PROGS(MYSQL_CONFIG, mysql_config)
if test -n "$MYSQL_CONFIG"
then
mysql_include=`${MYSQL_CONFIG} --include`
mysql_lib=`${MYSQL_CONFIG} --libs`
use_dlz_mysql="config"
else
# User did not specify a path - guess it
mysqldirs="/usr /usr/local /usr/local/mysql /usr/pkg"
for d in $mysqldirs
do
if test -f $d/include/mysql/mysql.h
then
use_dlz_mysql=$d
mysql_include=$d/include/mysql
break
elif test -f $d/include/mysql.h
then
use_dlz_mysql=$d
mysql_include=$d/include
break
fi
done
fi
elif test "$use_dlz_mysql" != "no"
then
d=$use_dlz_mysql
if test -f $d/include/mysql/mysql.h
then
mysql_include=$d/include/mysql
elif test -f $d/include/mysql.h
then
mysql_include=$d/include
fi
fi
if test "$use_dlz_mysql" = "yes"
then
AC_MSG_RESULT(not found)
AC_MSG_ERROR(
[MySQL was not found in any of $mysqldirs; use --with-dlz-mysql=/path])
fi
case "$use_dlz_mysql" in
no)
AC_MSG_RESULT(no)
;;
config)
DLZ_ADD_DRIVER(MYSQL, dlz_mysql_driver,
[${mysql_include}],
[${mysql_lib}])
AC_MSG_RESULT(
[using mysql with libs ${mysql_lib} and includes ${mysql_include}])
;;
*)
if test -d "$use_dlz_mysql/lib/mysql"
then
mysql_lib="$use_dlz_mysql/lib/mysql"
else
mysql_lib="$use_dlz_mysql/lib"
fi
DLZ_ADD_DRIVER(MYSQL, dlz_mysql_driver,
[-I${mysql_include}],
[-L${mysql_lib} -lmysqlclient -lz -lcrypt -lm])
AC_MSG_RESULT(
[using mysql from ${mysql_lib} and ${mysql_include}])
;;
esac
#
# Was --with-dlz-bdb specified?
#
AC_MSG_CHECKING(for Berkeley DB DLZ driver...)
AC_ARG_WITH(dlz_bdb,
AS_HELP_STRING([--with-dlz-bdb[=PATH]],
[Build with Berkeley DB DLZ driver [yes|no|path].
(Required to use Berkeley DB with DLZ)]),
use_dlz_bdb="$withval", use_dlz_bdb="no")
case "$use_dlz_bdb" in
no)
AC_MSG_RESULT(no)
;;
*)
if test "$use_dlz_bdb" = "yes"
then
# User did not specify a path - guess directories
bdbdirs="/usr/local /usr/pkg /usr"
elif test -d "$use_dlz_bdb"
then
# User specified directory and it exists
bdbdirs="$use_dlz_bdb"
else
AC_MSG_RESULT(not found)
AC_MSG_ERROR([path $use_dlz_bdb does not exist])
bdbdirs=""
fi
# Use path we were given or guessed. This is insanely
# complicated because we have to search for a bunch of
# platform-specific variations and have to check
# separately for include and library directories.
# Set both to yes, so we can check them later
dlz_bdb_inc="yes"
dlz_bdb_libs="yes"
AC_MSG_RESULT( )
for dd in $bdbdirs
do
# Skip nonexistent directories
if test ! -d "$dd"
then
continue
fi
# Check other locations for includes.
# Order is important (sigh).
bdb_incdirs="/db53 /db51 /db48 /db47 /db46 /db45 /db44 /db43 /db42 /db41 /db4 /db"
# include a blank element first
for d in "" $bdb_incdirs
do
if test -f "$dd/include${d}/db.h"
then
dlz_bdb_inc="-I$dd/include${d}"
break
fi
done
# Give up on this directory if we couldn't
# find the include subdir
if test "$dlz_bdb_inc" = "yes"
then
continue
fi
# Look for libname other than libdb.so.
# Order is important (sigh).
bdb_libnames="db53 db-5.3 db51 db-5.1 db48 db-4.8 db47 db-4.7 db46 db-4.6 db45 db-4.5 db44 db-4.4 db43 db-4.3 db42 db-4.2 db41 db-4.1 db"
for d in $bdb_libnames
do
if test "$dd" = "/usr"
then
AC_CHECK_LIB($d, db_create, dlz_bdb_libs="-l${d}")
if test $dlz_bdb_libs != "yes"
then
break
fi
elif test -f "$dd/lib/lib${d}.so"
then
dlz_bdb_libs="-L${dd}/lib -l${d}"
break
fi
done
# If we found both incdir and lib, we're done
if test "$dlz_bdb_libs" != "yes"
then
break
fi
# Otherwise, we're starting over
dlz_bdb_inc="yes"
dlz_bdb_libs="yes"
done
# Done searching, now make sure we got everything.
if test "$dlz_bdb_inc" = "yes"
then
AC_MSG_ERROR([could not find Berkeley DB include directory])
fi
if test "$dlz_bdb_libs" = "yes"
then
AC_MSG_RESULT(not found)
AC_MSG_ERROR([could not find Berkeley DB library])
fi
DLZ_ADD_DRIVER(BDB, dlz_bdb_driver dlz_bdbhpt_driver,
[$dlz_bdb_inc], [$dlz_bdb_libs])
AC_MSG_RESULT([using Berkeley DB: $dlz_bdb_inc $dlz_bdb_libs])
AC_CONFIG_FILES([contrib/dlz/bin/dlzbdb/Makefile])
;;
esac
#
# Was --with-dlz-filesystem specified?
#
AC_MSG_CHECKING(for file system DLZ driver)
AC_ARG_WITH(dlz_filesystem,
AS_HELP_STRING([--with-dlz-filesystem[=ARG]],
[Build with filesystem DLZ driver [yes|no].
(Required to use file system driver with DLZ)]),
use_dlz_filesystem="$withval", use_dlz_filesystem="no")
case "$use_dlz_filesystem" in
no)
AC_MSG_RESULT(no)
;;
*)
DLZ_ADD_DRIVER(FILESYSTEM, dlz_filesystem_driver)
DLZ_SYSTEM_TEST=filesystem
AC_MSG_RESULT(yes)
;;
esac
#
# Was --with-dlz-ldap specified?
#
AC_MSG_CHECKING(for LDAP DLZ driver)
AC_ARG_WITH(dlz_ldap,
AS_HELP_STRING([--with-dlz-ldap[=PATH]],
[Build with LDAP DLZ driver [yes|no|path].
(Required to use LDAP with DLZ)]),
use_dlz_ldap="$withval", use_dlz_ldap="no")
if test "$use_dlz_ldap" = "yes"
then
# User did not specify a path - guess it
ldapdirs="/usr /usr/local /usr/pkg"
for d in $ldapdirs
do
if test -f $d/include/ldap.h
then
use_dlz_ldap=$d
break
fi
done
fi
if test "$use_dlz_ldap" = "yes"
then
AC_MSG_RESULT(not found)
AC_MSG_ERROR(
[LDAP headers were not found in any of $ldapdirs; use --with-dlz-ldap=/path])
fi
case "$use_dlz_ldap" in
no)
AC_MSG_RESULT(no)
;;
*)
DLZ_ADD_DRIVER(LDAP, dlz_ldap_driver,
[-I$use_dlz_ldap/include],
[-L$use_dlz_ldap/lib -lldap -llber])
AC_MSG_RESULT(
[using LDAP from $use_dlz_ldap/lib and $use_dlz_ldap/include])
;;
esac
#
# Was --with-dlz-odbc specified?
#
AC_MSG_CHECKING(for ODBC DLZ driver)
AC_ARG_WITH(dlz_odbc,
AS_HELP_STRING([--with-dlz-odbc[=PATH]],
[Build with ODBC DLZ driver [yes|no|path].
(Required to use ODBC with DLZ)]),
use_dlz_odbc="$withval", use_dlz_odbc="no")
if test "$use_dlz_odbc" = "yes"
then
# User did not specify a path - guess it
libodbc_found=no
sql_h_found=no
AC_CHECK_HEADER(sql.h, sql_h_found=yes)
AC_CHECK_LIB(odbc, SQLConnect, libodbc_found=yes)
if test $libodbc_found = "yes" -o $sql_h_found = "yes"
then
use_dlz_odbc=system
dlz_odbc_include=""
dlz_odbc_libs="-lodbc"
else
odbcdirs="/usr /usr/local /usr/pkg"
for d in $odbcdirs
do
if test -f $d/include/sql.h -a -f $d/lib/libodbc.a
then
use_dlz_odbc=$d
dlz_odbc_include="-I$use_dlz_odbc/include"
dlz_odbc_libs="-L$use_dlz_odbc/lib -lodbc"
break
fi
done
fi
fi
case "$use_dlz_odbc" in
no)
AC_MSG_RESULT(no)
;;
yes)
AC_MSG_RESULT(not found)
AC_MSG_ERROR(
[ODBC headers were not found in any of $odbcdirs; use --with-dlz-odbc=/path])
;;
*)
DLZ_ADD_DRIVER(ODBC, dlz_odbc_driver,
[$dlz_odbc_include],
[$dlz_odbc_libs])
AC_MSG_RESULT([using ODBC from $use_dlz_odbc])
;;
esac
#
# Was --with-dlz-stub specified?
#
AC_MSG_CHECKING(for stub DLZ driver)
AC_ARG_WITH(dlz_stub,
AS_HELP_STRING([--with-dlz-stub[=ARG]],
[Build with stub DLZ driver [yes|no].
(Required to use stub driver with DLZ)]),
use_dlz_stub="$withval", use_dlz_stub="no")
case "$use_dlz_stub" in
no)
AC_MSG_RESULT(no)
;;
*)
DLZ_ADD_DRIVER(STUB, dlz_stub_driver)
AC_MSG_RESULT(yes)
;;
esac
# Add any additional DLZ drivers here.
#
# Finally, some generic stuff that applies to all drivers, assuming
# we're compiling contrib DLZ drivers at all.
#
if test -n "$CONTRIB_DLZ"
then
CONTRIB_DLZ="-DCONTRIB_DLZ $CONTRIB_DLZ"
#
# Where to find DLZ driver header files.
#
DLZ_DRIVER_INCLUDES="-I$dlzdir/include $DLZ_DRIVER_INCLUDES"
#
# Initialization and shutdown wrappers, helper functions.
#
DLZ_DRIVER_SRCS="$dlzdir/dlz_drivers.c $dlzdir/sdlz_helper.c $DLZ_DRIVER_SRCS"
DLZ_DRIVER_OBJS="dlz_drivers.$O sdlz_helper.$O $DLZ_DRIVER_OBJS"
fi

View File

@@ -1 +0,0 @@
rules

View File

@@ -1,800 +0,0 @@
/*
* Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl.
*
* 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 STICHTING NLNET
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* STICHTING NLNET 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.
*
* The development of Dynamically Loadable Zones (DLZ) for Bind 9 was
* conceived and contributed by Rob Butler.
*
* 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 ROB BUTLER
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* ROB BUTLER 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.
*/
/*
* Copyright (C) 1999-2001, 2016 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/.
*/
#ifdef DLZ_BDB
#include <db.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <isc/mem.h>
#include <isc/print.h>
#include <isc/result.h>
#include <isc/util.h>
#include <dns/log.h>
#include <dns/result.h>
#include <dns/sdlz.h>
#include <dlz/dlz_bdb_driver.h>
#include <named/globals.h>
static dns_sdlzimplementation_t *dlz_bdb = NULL;
/* should the bdb driver use threads. */
#define bdb_threads DB_THREAD
/* BDB database names */
#define dlz_data "dns_data"
#define dlz_zone "dns_zone"
#define dlz_host "dns_host"
#define dlz_client "dns_client"
/*%
* This structure contains all the Berkeley DB handles
* for this instance of the BDB driver.
*/
typedef struct bdb_instance {
DB_ENV *dbenv; /*%< BDB environment */
DB *data; /*%< dns_data database handle */
DB *zone; /*%< zone database handle */
DB *host; /*%< host database handle */
DB *client; /*%< client database handle */
isc_mem_t *mctx; /*%< memory context */
} bdb_instance_t;
typedef struct parsed_data {
char *zone;
char *host;
char *type;
int ttl;
char *data;
} parsed_data_t;
/* forward reference */
static isc_result_t
bdb_findzone(void *driverarg, void *dbdata, const char *name,
dns_clientinfomethods_t *methods, dns_clientinfo_t *clientinfo);
/*%
* Parses the DBT from the Berkeley DB into a parsed_data record
* The parsed_data record should be allocated before and passed into the
* bdb_parse_data function. The char (type & data) fields should not
* be "free"d as that memory is part of the DBT data field. It will be
* "free"d when the DBT is freed.
*/
static isc_result_t
bdb_parse_data(char *in, parsed_data_t *pd) {
char *endp, *ttlStr;
char *tmp = in;
char *lastchar = (char *)&tmp[strlen(tmp) + 1];
/*%
* String should be formatted as:
* zone(a space)host(a space)ttl(a space)type(a space)remaining data
* examples:
* example.com www 10 A 127.0.0.1
* example.com mail 10 A 127.0.0.2
* example.com @ 10 MX 20 mail.example.com
*/
/* save pointer to zone */
pd->zone = tmp;
/* find space after zone and change it to a '\0' */
tmp = strchr(tmp, ' ');
/* verify we found a space */
if (tmp == NULL) {
return (ISC_R_FAILURE);
}
/* change the space to a null (string terminator) */
tmp[0] = '\0';
/* make sure it is safe to increment pointer */
if (++tmp > lastchar) {
return (ISC_R_FAILURE);
}
/* save pointer to host */
pd->host = tmp;
/* find space after type and change it to a '\0' */
tmp = strchr(tmp, ' ');
/* verify we found a space */
if (tmp == NULL) {
return (ISC_R_FAILURE);
}
/* change the space to a null (string terminator) */
tmp[0] = '\0';
/* make sure it is safe to increment pointer */
if (++tmp > lastchar) {
return (ISC_R_FAILURE);
}
/* save pointer to dns type */
pd->type = tmp;
/* find space after type and change it to a '\0' */
tmp = strchr(tmp, ' ');
/* verify we found a space */
if (tmp == NULL) {
return (ISC_R_FAILURE);
}
/* change the space to a null (string terminator) */
tmp[0] = '\0';
/* make sure it is safe to increment pointer */
if (++tmp > lastchar) {
return (ISC_R_FAILURE);
}
/* save pointer to dns ttl */
ttlStr = tmp;
/* find space after ttl and change it to a '\0' */
tmp = strchr(tmp, ' ');
/* verify we found a space */
if (tmp == NULL) {
return (ISC_R_FAILURE);
}
/* change the space to a null (string terminator) */
tmp[0] = '\0';
/* make sure it is safe to increment pointer */
if (++tmp > lastchar) {
return (ISC_R_FAILURE);
}
/* save pointer to remainder of DNS data */
pd->data = tmp;
/* convert ttl string to integer */
pd->ttl = strtol(ttlStr, &endp, 10);
if (*endp != '\0' || pd->ttl < 0) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"BDB driver ttl must be a positive number");
return (ISC_R_FAILURE);
}
/* if we get this far everything should have worked. */
return (ISC_R_SUCCESS);
}
/*
* DLZ methods
*/
static isc_result_t
bdb_allowzonexfr(void *driverarg, void *dbdata, const char *name,
const char *client) {
isc_result_t result;
bdb_instance_t *db = (bdb_instance_t *)dbdata;
DBC *client_cursor = NULL;
DBT key, data;
/* check to see if we are authoritative for the zone first. */
result = bdb_findzone(driverarg, dbdata, name, NULL, NULL);
if (result != ISC_R_SUCCESS) {
return (ISC_R_NOTFOUND);
}
memset(&key, 0, sizeof(DBT));
key.flags = DB_DBT_MALLOC;
key.data = strdup(name);
if (key.data == NULL) {
result = ISC_R_NOMEMORY;
goto xfr_cleanup;
}
key.size = strlen(key.data);
memset(&data, 0, sizeof(DBT));
data.flags = DB_DBT_MALLOC;
data.data = strdup(client);
if (data.data == NULL) {
result = ISC_R_NOMEMORY;
goto xfr_cleanup;
}
data.size = strlen(data.data);
/* get a cursor to loop through zone data */
if (db->client->cursor(db->client, NULL, &client_cursor, 0) != 0) {
result = ISC_R_FAILURE;
goto xfr_cleanup;
}
switch (client_cursor->c_get(client_cursor, &key, &data, DB_GET_BOTH)) {
case DB_NOTFOUND:
case DB_SECONDARY_BAD:
result = ISC_R_NOTFOUND;
break;
case 0:
result = ISC_R_SUCCESS;
break;
default:
result = ISC_R_FAILURE;
}
xfr_cleanup:
/* free any memory duplicate string in the key field */
if (key.data != NULL) {
free(key.data);
}
/* free any memory allocated to the data field. */
if (data.data != NULL) {
free(data.data);
}
/* get rid of zone_cursor */
if (client_cursor != NULL) {
client_cursor->c_close(client_cursor);
}
return (result);
}
static isc_result_t
bdb_allnodes(const char *zone, void *driverarg, void *dbdata,
dns_sdlzallnodes_t *allnodes) {
isc_result_t result = ISC_R_NOTFOUND;
bdb_instance_t *db = (bdb_instance_t *)dbdata;
DBC *zone_cursor = NULL;
DBT key, data;
int flags;
int bdbres;
parsed_data_t pd;
char *tmp = NULL, *tmp_zone;
UNUSED(driverarg);
memset(&key, 0, sizeof(DBT));
memset(&data, 0, sizeof(DBT));
key.data = tmp_zone = strdup(zone);
if (key.data == NULL) {
return (ISC_R_NOMEMORY);
}
key.size = strlen(key.data);
/* get a cursor to loop through zone data */
if (db->zone->cursor(db->zone, NULL, &zone_cursor, 0) != 0) {
result = ISC_R_FAILURE;
goto allnodes_cleanup;
}
flags = DB_SET;
while ((bdbres = zone_cursor->c_get(zone_cursor, &key, &data, flags)) ==
0) {
flags = DB_NEXT_DUP;
tmp = realloc(tmp, data.size + 1);
if (tmp == NULL) {
goto allnodes_cleanup;
}
strncpy(tmp, data.data, data.size);
tmp[data.size] = '\0';
if (bdb_parse_data(tmp, &pd) != ISC_R_SUCCESS) {
goto allnodes_cleanup;
}
result = dns_sdlz_putnamedrr(allnodes, pd.host, pd.type, pd.ttl,
pd.data);
if (result != ISC_R_SUCCESS) {
goto allnodes_cleanup;
}
} /* end while loop */
allnodes_cleanup:
if (tmp != NULL) {
free(tmp);
}
/* free any memory duplicate string in the key field */
if (tmp_zone != NULL) {
free(tmp_zone);
}
/* get rid of zone_cursor */
if (zone_cursor != NULL) {
zone_cursor->c_close(zone_cursor);
}
return (result);
}
/*%
* Performs BDB cleanup.
* Used by bdb_create if there is an error starting up.
* Used by bdb_destroy when the driver is shutting down.
*/
static void
bdb_cleanup(bdb_instance_t *db) {
isc_mem_t *mctx;
/* close databases */
if (db->data != NULL) {
db->data->close(db->data, 0);
}
if (db->host != NULL) {
db->host->close(db->host, 0);
}
if (db->zone != NULL) {
db->zone->close(db->zone, 0);
}
if (db->client != NULL) {
db->client->close(db->client, 0);
}
/* close environment */
if (db->dbenv != NULL) {
db->dbenv->close(db->dbenv, 0);
}
/* cleanup memory */
if (db->mctx != NULL) {
/* save mctx for later */
mctx = db->mctx;
/* return, and detach the memory */
isc_mem_putanddetach(&mctx, db, sizeof(bdb_instance_t));
}
}
static isc_result_t
bdb_findzone(void *driverarg, void *dbdata, const char *name,
dns_clientinfomethods_t *methods, dns_clientinfo_t *clientinfo) {
isc_result_t result;
bdb_instance_t *db = (bdb_instance_t *)dbdata;
DBC *zone_cursor = NULL;
DBT key, data;
UNUSED(driverarg);
UNUSED(methods);
UNUSED(clientinfo);
memset(&key, 0, sizeof(DBT));
memset(&data, 0, sizeof(DBT));
data.flags = DB_DBT_MALLOC;
key.data = strdup(name);
if (key.data == NULL) {
return (ISC_R_NOMEMORY);
}
key.size = strlen(key.data);
/* get a cursor to loop through zone data */
if (db->zone->cursor(db->zone, NULL, &zone_cursor, 0) != 0) {
result = ISC_R_NOTFOUND;
goto findzone_cleanup;
}
switch (zone_cursor->c_get(zone_cursor, &key, &data, DB_SET)) {
case DB_NOTFOUND:
case DB_SECONDARY_BAD:
result = ISC_R_NOTFOUND;
break;
case 0:
result = ISC_R_SUCCESS;
break;
default:
result = ISC_R_FAILURE;
}
findzone_cleanup:
/* free any memory duplicate string in the key field */
if (key.data != NULL) {
free(key.data);
}
/* free any memory allocated to the data field. */
if (data.data != NULL) {
free(data.data);
}
/* get rid of zone_cursor */
if (zone_cursor != NULL) {
zone_cursor->c_close(zone_cursor);
}
return (result);
}
static isc_result_t
bdb_lookup(const char *zone, const char *name, void *driverarg, void *dbdata,
dns_sdlzlookup_t *lookup, dns_clientinfomethods_t *methods,
dns_clientinfo_t *clientinfo) {
isc_result_t result = ISC_R_NOTFOUND;
bdb_instance_t *db = (bdb_instance_t *)dbdata;
DBC *zone_cursor = NULL;
DBC *host_cursor = NULL;
DBC *join_cursor = NULL;
DBT key, data;
DBC *cur_arr[3];
int bdbres;
parsed_data_t pd;
char *tmp_zone, *tmp_host = NULL;
char *tmp = NULL;
UNUSED(driverarg);
UNUSED(methods);
UNUSED(clientinfo);
memset(&key, 0, sizeof(DBT));
memset(&data, 0, sizeof(DBT));
/* set zone key */
key.data = tmp_zone = strdup(zone);
if (key.data == NULL) {
result = ISC_R_NOMEMORY;
goto lookup_cleanup;
}
key.size = strlen(key.data);
/* get a cursor to loop through zone data */
if (db->zone->cursor(db->zone, NULL, &zone_cursor, 0) != 0) {
result = ISC_R_FAILURE;
goto lookup_cleanup;
}
/* initialize zone_cursor with zone_key */
if (zone_cursor->c_get(zone_cursor, &key, &data, DB_SET) != 0) {
result = ISC_R_NOTFOUND;
goto lookup_cleanup;
}
/* set host key */
key.data = tmp_host = strdup(name);
if (key.data == NULL) {
result = ISC_R_NOMEMORY;
goto lookup_cleanup;
}
key.size = strlen(key.data);
/* get a cursor to loop through host data */
if (db->host->cursor(db->host, NULL, &host_cursor, 0) != 0) {
result = ISC_R_FAILURE;
goto lookup_cleanup;
}
/* initialize host_cursor with host_key */
if (host_cursor->c_get(host_cursor, &key, &data, DB_SET) != 0) {
result = ISC_R_NOTFOUND;
goto lookup_cleanup;
}
cur_arr[0] = zone_cursor;
cur_arr[1] = host_cursor;
cur_arr[2] = NULL;
db->data->join(db->data, cur_arr, &join_cursor, 0);
while ((bdbres = join_cursor->c_get(join_cursor, &key, &data, 0)) == 0)
{
tmp = realloc(tmp, data.size + 1);
if (tmp == NULL) {
goto lookup_cleanup;
}
strncpy(tmp, data.data, data.size);
tmp[data.size] = '\0';
if (bdb_parse_data(tmp, &pd) != ISC_R_SUCCESS) {
goto lookup_cleanup;
}
result = dns_sdlz_putrr(lookup, pd.type, pd.ttl, pd.data);
if (result != ISC_R_SUCCESS) {
goto lookup_cleanup;
}
} /* end while loop */
lookup_cleanup:
if (tmp != NULL) {
free(tmp);
}
if (tmp_zone != NULL) {
free(tmp_zone);
}
if (tmp_host != NULL) {
free(tmp_host);
}
/* get rid of the joined cusor */
if (join_cursor != NULL) {
join_cursor->c_close(join_cursor);
}
/* get rid of zone_cursor */
if (zone_cursor != NULL) {
zone_cursor->c_close(zone_cursor);
}
/* get rid of host_cursor */
if (host_cursor != NULL) {
host_cursor->c_close(host_cursor);
}
return (result);
}
/*% Initializes, sets flags and then opens Berkeley databases. */
static isc_result_t
bdb_opendb(DB_ENV *db_env, DBTYPE db_type, DB **db, const char *db_name,
char *db_file, int flags) {
int result;
/* Initialize the database. */
if ((result = db_create(db, db_env, 0)) != 0) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"BDB could not initialize %s database. "
"BDB error: %s",
db_name, db_strerror(result));
return (ISC_R_FAILURE);
}
/* set database flags. */
if ((result = (*db)->set_flags(*db, flags)) != 0) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"BDB could not set flags for %s database. "
"BDB error: %s",
db_name, db_strerror(result));
return (ISC_R_FAILURE);
}
/* open the database. */
if ((result = (*db)->open(*db, NULL, db_file, db_name, db_type,
DB_RDONLY | bdb_threads, 0)) != 0)
{
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"BDB could not open %s database in %s. "
"BDB error: %s",
db_name, db_file, db_strerror(result));
return (ISC_R_FAILURE);
}
return (ISC_R_SUCCESS);
}
static isc_result_t
bdb_create(const char *dlzname, unsigned int argc, char *argv[],
void *driverarg, void **dbdata) {
isc_result_t result;
int bdbres;
bdb_instance_t *db = NULL;
UNUSED(dlzname);
UNUSED(driverarg);
/* verify we have 3 arg's passed to the driver */
if (argc != 3) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"Berkeley DB driver requires at least "
"2 command line args.");
return (ISC_R_FAILURE);
}
/* allocate and zero memory for driver structure */
db = isc_mem_get(named_g_mctx, sizeof(bdb_instance_t));
memset(db, 0, sizeof(bdb_instance_t));
/* attach to the memory context */
isc_mem_attach(named_g_mctx, &db->mctx);
/* create BDB environment
* Basically BDB allocates and assigns memory to db->dbenv
*/
bdbres = db_env_create(&db->dbenv, 0);
if (bdbres != 0) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"BDB environment could not be created. "
"BDB error: %s",
db_strerror(bdbres));
result = ISC_R_FAILURE;
goto init_cleanup;
}
/* open BDB environment */
bdbres = db->dbenv->open(
db->dbenv, argv[1],
DB_INIT_CDB | DB_INIT_MPOOL | bdb_threads | DB_CREATE, 0);
if (bdbres != 0) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"BDB environment at '%s' could not be opened. "
"BDB error: %s",
argv[1], db_strerror(bdbres));
result = ISC_R_FAILURE;
goto init_cleanup;
}
/* open dlz_data database. */
result = bdb_opendb(db->dbenv, DB_UNKNOWN, &db->data, dlz_data, argv[2],
0);
if (result != ISC_R_SUCCESS) {
goto init_cleanup;
}
/* open dlz_host database. */
result = bdb_opendb(db->dbenv, DB_UNKNOWN, &db->host, dlz_host, argv[2],
DB_DUP | DB_DUPSORT);
if (result != ISC_R_SUCCESS) {
goto init_cleanup;
}
/* open dlz_zone database. */
result = bdb_opendb(db->dbenv, DB_UNKNOWN, &db->zone, dlz_zone, argv[2],
DB_DUP | DB_DUPSORT);
if (result != ISC_R_SUCCESS) {
goto init_cleanup;
}
/* open dlz_client database. */
result = bdb_opendb(db->dbenv, DB_UNKNOWN, &db->client, dlz_client,
argv[2], DB_DUP | DB_DUPSORT);
if (result != ISC_R_SUCCESS) {
goto init_cleanup;
}
/* associate the host secondary database with the primary database */
bdbres = db->data->associate(db->data, NULL, db->host, NULL, 0);
if (bdbres != 0) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"BDB could not associate %s database with %s. "
"BDB error: %s",
dlz_host, dlz_data, db_strerror(bdbres));
result = ISC_R_FAILURE;
goto init_cleanup;
}
/* associate the zone secondary database with the primary database */
bdbres = db->data->associate(db->data, NULL, db->zone, NULL, 0);
if (bdbres != 0) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"BDB could not associate %s database with %s. "
"BDB error: %s",
dlz_zone, dlz_data, db_strerror(bdbres));
result = ISC_R_FAILURE;
goto init_cleanup;
}
*dbdata = db;
return (ISC_R_SUCCESS);
init_cleanup:
bdb_cleanup(db);
return (result);
}
static void
bdb_destroy(void *driverarg, void *dbdata) {
UNUSED(driverarg);
bdb_cleanup((bdb_instance_t *)dbdata);
}
/* bdb_authority not needed as authority data is returned by lookup */
static dns_sdlzmethods_t dlz_bdb_methods = {
bdb_create,
bdb_destroy,
bdb_findzone,
bdb_lookup,
NULL,
bdb_allnodes,
bdb_allowzonexfr,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
};
/*%
* Wrapper around dns_sdlzregister().
*/
isc_result_t
dlz_bdb_init(void) {
isc_result_t result;
/*
* Write debugging message to log
*/
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DLZ,
ISC_LOG_DEBUG(2), "Registering DLZ bdb driver.");
result = dns_sdlzregister("bdb", &dlz_bdb_methods, NULL,
DNS_SDLZFLAG_RELATIVEOWNER |
DNS_SDLZFLAG_RELATIVERDATA |
DNS_SDLZFLAG_THREADSAFE,
named_g_mctx, &dlz_bdb);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"dns_sdlzregister() failed: %s",
isc_result_totext(result));
result = ISC_R_UNEXPECTED;
}
return (result);
}
/*%
* Wrapper around dns_sdlzunregister().
*/
void
dlz_bdb_clear(void) {
/*
* Write debugging message to log
*/
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DLZ,
ISC_LOG_DEBUG(2), "Unregistering DLZ bdb driver.");
if (dlz_bdb != NULL) {
dns_sdlzunregister(&dlz_bdb);
}
}
#endif /* ifdef DLZ_BDB */

View File

@@ -1,869 +0,0 @@
/*
* Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl.
*
* 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 STICHTING NLNET
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* STICHTING NLNET 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.
*
* The development of Dynamically Loadable Zones (DLZ) for Bind 9 was
* conceived and contributed by Rob Butler.
*
* 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 ROB BUTLER
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* ROB BUTLER 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.
*/
/*
* Copyright (C) 1999-2001, 2016 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/.
*/
#ifdef DLZ_BDB
#include <db.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <isc/mem.h>
#include <isc/print.h>
#include <isc/result.h>
#include <isc/util.h>
#include <dns/log.h>
#include <dns/result.h>
#include <dns/sdlz.h>
#include <dlz/dlz_bdbhpt_driver.h>
#include <named/globals.h>
static dns_sdlzimplementation_t *dlz_bdbhpt = NULL;
/* should the bdb driver use threads. */
#define bdbhpt_threads DB_THREAD
/* bdbhpt database names */
#define dlz_data "dns_data"
#define dlz_zone "dns_zone"
#define dlz_xfr "dns_xfr"
#define dlz_client "dns_client"
/* This structure contains all the Berkeley DB handles
* for this instance of the bdbhpt driver.
*/
typedef struct bdbhpt_instance {
DB_ENV *dbenv; /*%< bdbhpt environment */
DB *data; /*%< dns_data database handle */
DB *zone; /*%< zone database handle */
DB *xfr; /*%< zone xfr database handle */
DB *client; /*%< client database handle */
isc_mem_t *mctx; /*%< memory context */
} bdbhpt_instance_t;
typedef struct bdbhpt_parsed_data {
char *host;
char *type;
int ttl;
char *data;
} bdbhpt_parsed_data_t;
/* forward reference */
static isc_result_t
bdbhpt_findzone(void *driverarg, void *dbdata, const char *name,
dns_clientinfomethods_t *methods, dns_clientinfo_t *clientinfo);
/*%
* Reverses a string in place.
*/
static char *
bdbhpt_strrev(char *str) {
char *p1, *p2;
if (!str || !*str) {
return (str);
}
for (p1 = str, p2 = str + strlen(str) - 1; p2 > p1; ++p1, --p2) {
*p1 ^= *p2;
*p2 ^= *p1;
*p1 ^= *p2;
}
return (str);
}
/*%
* Parses the DBT from the Berkeley DB into a parsed_data record
* The parsed_data record should be allocated before and passed into the
* bdbhpt_parse_data function. The char (type & data) fields should not
* be "free"d as that memory is part of the DBT data field. It will be
* "free"d when the DBT is freed.
*/
static isc_result_t
bdbhpt_parse_data(char *in, bdbhpt_parsed_data_t *pd) {
char *endp, *ttlStr;
char *tmp = in;
char *lastchar = (char *)&tmp[strlen(tmp)];
/*%
* String should be formatted as:
* replication_id
* (a space)
* host_name
* (a space)
* ttl
* (a space)
* type
* (a space)
* remaining data
*
* examples:
*
* 9191 host 10 A 127.0.0.1
* server1_212 host 10 A 127.0.0.2
* {xxxx-xxxx-xxxx-xxxx-xxxx} host 10 MX 20 mail.example.com
*/
/*
* we don't need the replication id, so don't
* bother saving a pointer to it.
*/
/* find space after replication id */
tmp = strchr(tmp, ' ');
/* verify we found a space */
if (tmp == NULL) {
return (ISC_R_FAILURE);
}
/* make sure it is safe to increment pointer */
if (++tmp > lastchar) {
return (ISC_R_FAILURE);
}
/* save pointer to host */
pd->host = tmp;
/* find space after host and change it to a '\0' */
tmp = strchr(tmp, ' ');
/* verify we found a space */
if (tmp == NULL) {
return (ISC_R_FAILURE);
}
/* change the space to a null (string terminator) */
tmp[0] = '\0';
/* make sure it is safe to increment pointer */
if (++tmp > lastchar) {
return (ISC_R_FAILURE);
}
/* save pointer to ttl string */
ttlStr = tmp;
/* find space after ttl and change it to a '\0' */
tmp = strchr(tmp, ' ');
/* verify we found a space */
if (tmp == NULL) {
return (ISC_R_FAILURE);
}
/* change the space to a null (string terminator) */
tmp[0] = '\0';
/* make sure it is safe to increment pointer */
if (++tmp > lastchar) {
return (ISC_R_FAILURE);
}
/* save pointer to dns type */
pd->type = tmp;
/* find space after type and change it to a '\0' */
tmp = strchr(tmp, ' ');
/* verify we found a space */
if (tmp == NULL) {
return (ISC_R_FAILURE);
}
/* change the space to a null (string terminator) */
tmp[0] = '\0';
/* make sure it is safe to increment pointer */
if (++tmp > lastchar) {
return (ISC_R_FAILURE);
}
/* save pointer to remainder of DNS data */
pd->data = tmp;
/* convert ttl string to integer */
pd->ttl = strtol(ttlStr, &endp, 10);
if (*endp != '\0' || pd->ttl < 0) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"bdbhpt driver ttl must be a positive number");
return (ISC_R_FAILURE);
}
/* if we get this far everything should have worked. */
return (ISC_R_SUCCESS);
}
/*
* DLZ methods
*/
static isc_result_t
bdbhpt_allowzonexfr(void *driverarg, void *dbdata, const char *name,
const char *client) {
isc_result_t result;
bdbhpt_instance_t *db = (bdbhpt_instance_t *)dbdata;
DBT key, data;
/* check to see if we are authoritative for the zone first. */
result = bdbhpt_findzone(driverarg, dbdata, name, NULL, NULL);
if (result != ISC_R_SUCCESS) {
return (ISC_R_NOTFOUND);
}
memset(&key, 0, sizeof(DBT));
key.flags = DB_DBT_MALLOC;
key.data = strdup(name);
if (key.data == NULL) {
result = ISC_R_NOMEMORY;
goto xfr_cleanup;
}
key.size = strlen(key.data);
memset(&data, 0, sizeof(DBT));
data.flags = DB_DBT_MALLOC;
data.data = strdup(client);
if (data.data == NULL) {
result = ISC_R_NOMEMORY;
goto xfr_cleanup;
}
data.size = strlen(data.data);
switch (db->client->get(db->client, NULL, &key, &data, DB_GET_BOTH)) {
case DB_NOTFOUND:
result = ISC_R_NOTFOUND;
break;
case 0:
result = ISC_R_SUCCESS;
break;
default:
result = ISC_R_FAILURE;
}
xfr_cleanup:
/* free any memory duplicate string in the key field */
if (key.data != NULL) {
free(key.data);
}
/* free any memory allocated to the data field. */
if (data.data != NULL) {
free(data.data);
}
return (result);
}
/*%
* BDB does not allow a secondary index on a database that allows
* duplicates. We have a few options:
*
* 1) kill speed by having lookup method use a secondary db which
* is associated to the primary DB with the DNS data. Then have
* another secondary db for zone transfer which also points to
* the dns_data primary. NO - The point of this driver is
* lookup performance.
*
* 2) Blow up database size by storing DNS data twice. Once for
* the lookup (dns_data) database, and a second time for the zone
* transfer (dns_xfr) database. NO - That would probably require
* a larger cache to provide good performance. Also, that would
* make the DB larger on disk potentially slowing it as well.
*
* 3) Loop through the dns_xfr database with a cursor to get
* all the different hosts in a zone. Then use the zone & host
* together to lookup the data in the dns_data database. YES -
* This may slow down zone xfr's a little, but that's ok they
* don't happen as often and don't need to be as fast. We can
* also use this table when deleting a zone (The BDB driver
* is read only - the delete would be used during replication
* updates by a separate process).
*/
static isc_result_t
bdbhpt_allnodes(const char *zone, void *driverarg, void *dbdata,
dns_sdlzallnodes_t *allnodes) {
isc_result_t result = ISC_R_NOTFOUND;
bdbhpt_instance_t *db = (bdbhpt_instance_t *)dbdata;
DBC *xfr_cursor = NULL;
DBC *dns_cursor = NULL;
DBT xfr_key, xfr_data, dns_key, dns_data;
int xfr_flags;
int dns_flags;
int bdbhptres;
bdbhpt_parsed_data_t pd;
char *tmp = NULL, *tmp_zone, *tmp_zone_host = NULL;
UNUSED(driverarg);
memset(&xfr_key, 0, sizeof(DBT));
memset(&xfr_data, 0, sizeof(DBT));
memset(&dns_key, 0, sizeof(DBT));
memset(&dns_data, 0, sizeof(DBT));
xfr_key.data = tmp_zone = strdup(zone);
if (xfr_key.data == NULL) {
return (ISC_R_NOMEMORY);
}
xfr_key.size = strlen(xfr_key.data);
/* get a cursor to loop through dns_xfr table */
if (db->xfr->cursor(db->xfr, NULL, &xfr_cursor, 0) != 0) {
result = ISC_R_FAILURE;
goto allnodes_cleanup;
}
/* get a cursor to loop through dns_data table */
if (db->data->cursor(db->data, NULL, &dns_cursor, 0) != 0) {
result = ISC_R_FAILURE;
goto allnodes_cleanup;
}
xfr_flags = DB_SET;
/* loop through xfr table for specified zone. */
while ((bdbhptres = xfr_cursor->c_get(xfr_cursor, &xfr_key, &xfr_data,
xfr_flags)) == 0)
{
xfr_flags = DB_NEXT_DUP;
/* +1 to allow for space between zone and host names */
dns_key.size = xfr_data.size + xfr_key.size + 1;
/* +1 to allow for null term at end of string. */
dns_key.data = tmp_zone_host = malloc(dns_key.size + 1);
if (dns_key.data == NULL) {
goto allnodes_cleanup;
}
/*
* construct search key for dns_data.
* zone_name(a space)host_name
*/
strcpy(dns_key.data, zone);
strcat(dns_key.data, " ");
strncat(dns_key.data, xfr_data.data, xfr_data.size);
dns_flags = DB_SET;
while ((bdbhptres = dns_cursor->c_get(dns_cursor, &dns_key,
&dns_data, dns_flags)) ==
0)
{
dns_flags = DB_NEXT_DUP;
/* +1 to allow for null term at end of string. */
tmp = realloc(tmp, dns_data.size + 1);
if (tmp == NULL) {
goto allnodes_cleanup;
}
/* copy data to tmp string, and append null term. */
strncpy(tmp, dns_data.data, dns_data.size);
tmp[dns_data.size] = '\0';
/* split string into dns data parts. */
if (bdbhpt_parse_data(tmp, &pd) != ISC_R_SUCCESS) {
goto allnodes_cleanup;
}
result = dns_sdlz_putnamedrr(allnodes, pd.host, pd.type,
pd.ttl, pd.data);
if (result != ISC_R_SUCCESS) {
goto allnodes_cleanup;
}
} /* end inner while loop */
/* clean up memory */
if (tmp_zone_host != NULL) {
free(tmp_zone_host);
tmp_zone_host = NULL;
}
} /* end outer while loop */
allnodes_cleanup:
/* free any memory */
if (tmp != NULL) {
free(tmp);
}
if (tmp_zone_host != NULL) {
free(tmp_zone_host);
}
if (tmp_zone != NULL) {
free(tmp_zone);
}
/* get rid of cursors */
if (xfr_cursor != NULL) {
xfr_cursor->c_close(xfr_cursor);
}
if (dns_cursor != NULL) {
dns_cursor->c_close(dns_cursor);
}
return (result);
}
/*%
* Performs bdbhpt cleanup.
* Used by bdbhpt_create if there is an error starting up.
* Used by bdbhpt_destroy when the driver is shutting down.
*/
static void
bdbhpt_cleanup(bdbhpt_instance_t *db) {
isc_mem_t *mctx;
/* close databases */
if (db->data != NULL) {
db->data->close(db->data, 0);
}
if (db->xfr != NULL) {
db->xfr->close(db->xfr, 0);
}
if (db->zone != NULL) {
db->zone->close(db->zone, 0);
}
if (db->client != NULL) {
db->client->close(db->client, 0);
}
/* close environment */
if (db->dbenv != NULL) {
db->dbenv->close(db->dbenv, 0);
}
/* cleanup memory */
if (db->mctx != NULL) {
/* save mctx for later */
mctx = db->mctx;
/* return, and detach the memory */
isc_mem_putanddetach(&mctx, db, sizeof(bdbhpt_instance_t));
}
}
static isc_result_t
bdbhpt_findzone(void *driverarg, void *dbdata, const char *name,
dns_clientinfomethods_t *methods,
dns_clientinfo_t *clientinfo) {
isc_result_t result;
bdbhpt_instance_t *db = (bdbhpt_instance_t *)dbdata;
DBT key, data;
UNUSED(driverarg);
UNUSED(methods);
UNUSED(clientinfo);
memset(&key, 0, sizeof(DBT));
memset(&data, 0, sizeof(DBT));
data.flags = DB_DBT_MALLOC;
key.data = strdup(name);
if (key.data == NULL) {
return (ISC_R_NOMEMORY);
}
/*
* reverse string to take advantage of BDB locality of reference
* if we need further lookups because the zone doesn't match the
* first time.
*/
key.data = bdbhpt_strrev(key.data);
key.size = strlen(key.data);
switch (db->zone->get(db->zone, NULL, &key, &data, 0)) {
case DB_NOTFOUND:
result = ISC_R_NOTFOUND;
break;
case 0:
result = ISC_R_SUCCESS;
break;
default:
result = ISC_R_FAILURE;
}
/* free any memory duplicate string in the key field */
if (key.data != NULL) {
free(key.data);
}
/* free any memory allocated to the data field. */
if (data.data != NULL) {
free(data.data);
}
return (result);
}
static isc_result_t
bdbhpt_lookup(const char *zone, const char *name, void *driverarg, void *dbdata,
dns_sdlzlookup_t *lookup, dns_clientinfomethods_t *methods,
dns_clientinfo_t *clientinfo) {
isc_result_t result = ISC_R_NOTFOUND;
bdbhpt_instance_t *db = (bdbhpt_instance_t *)dbdata;
DBC *data_cursor = NULL;
DBT key, data;
int bdbhptres;
int flags;
bdbhpt_parsed_data_t pd;
char *tmp = NULL;
char *keyStr = NULL;
UNUSED(driverarg);
UNUSED(methods);
UNUSED(clientinfo);
memset(&key, 0, sizeof(DBT));
memset(&data, 0, sizeof(DBT));
key.size = strlen(zone) + strlen(name) + 1;
/* allocate mem for key */
key.data = keyStr = malloc((key.size + 1) * sizeof(char));
if (keyStr == NULL) {
return (ISC_R_NOMEMORY);
}
strcpy(keyStr, zone);
strcat(keyStr, " ");
strcat(keyStr, name);
/* get a cursor to loop through data */
if (db->data->cursor(db->data, NULL, &data_cursor, 0) != 0) {
result = ISC_R_FAILURE;
goto lookup_cleanup;
}
result = ISC_R_NOTFOUND;
flags = DB_SET;
while ((bdbhptres = data_cursor->c_get(data_cursor, &key, &data,
flags)) == 0) {
flags = DB_NEXT_DUP;
tmp = realloc(tmp, data.size + 1);
if (tmp == NULL) {
goto lookup_cleanup;
}
strncpy(tmp, data.data, data.size);
tmp[data.size] = '\0';
if (bdbhpt_parse_data(tmp, &pd) != ISC_R_SUCCESS) {
goto lookup_cleanup;
}
result = dns_sdlz_putrr(lookup, pd.type, pd.ttl, pd.data);
if (result != ISC_R_SUCCESS) {
goto lookup_cleanup;
}
} /* end while loop */
lookup_cleanup:
/* get rid of cursor */
if (data_cursor != NULL) {
data_cursor->c_close(data_cursor);
}
free(keyStr);
if (tmp != NULL) {
free(tmp);
}
return (result);
}
/*% Initializes, sets flags and then opens Berkeley databases. */
static isc_result_t
bdbhpt_opendb(DB_ENV *db_env, DBTYPE db_type, DB **db, const char *db_name,
char *db_file, int flags) {
int result;
/* Initialize the database. */
if ((result = db_create(db, db_env, 0)) != 0) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"bdbhpt could not initialize %s database. "
"bdbhpt error: %s",
db_name, db_strerror(result));
return (ISC_R_FAILURE);
}
/* set database flags. */
if ((result = (*db)->set_flags(*db, flags)) != 0) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"bdbhpt could not set flags for %s database. "
"bdbhpt error: %s",
db_name, db_strerror(result));
return (ISC_R_FAILURE);
}
/* open the database. */
if ((result = (*db)->open(*db, NULL, db_file, db_name, db_type,
DB_RDONLY | bdbhpt_threads, 0)) != 0)
{
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"bdbhpt could not open %s database in %s. "
"bdbhpt error: %s",
db_name, db_file, db_strerror(result));
return (ISC_R_FAILURE);
}
return (ISC_R_SUCCESS);
}
static isc_result_t
bdbhpt_create(const char *dlzname, unsigned int argc, char *argv[],
void *driverarg, void **dbdata) {
isc_result_t result;
int bdbhptres;
int bdbFlags = 0;
bdbhpt_instance_t *db = NULL;
UNUSED(dlzname);
UNUSED(driverarg);
/* verify we have 4 arg's passed to the driver */
if (argc != 4) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"bdbhpt driver requires at least "
"3 command line args.");
return (ISC_R_FAILURE);
}
switch ((char)*argv[1]) {
/*
* Transactional mode. Highest safety - lowest speed.
*/
case 'T':
case 't':
bdbFlags = DB_INIT_MPOOL | DB_INIT_LOCK | DB_INIT_LOG |
DB_INIT_TXN;
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_DEBUG(1),
"bdbhpt driver using transactional mode.");
break;
/*
* Concurrent mode. Lower safety (no rollback) -
* higher speed.
*/
case 'C':
case 'c':
bdbFlags = DB_INIT_CDB | DB_INIT_MPOOL;
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_DEBUG(1),
"bdbhpt driver using concurrent mode.");
break;
/*
* Private mode. No inter-process communication & no locking.
* Lowest safety - highest speed.
*/
case 'P':
case 'p':
bdbFlags = DB_PRIVATE | DB_INIT_MPOOL;
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_DEBUG(1),
"bdbhpt driver using private mode.");
break;
default:
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"bdbhpt driver requires the operating mode "
"be set to P or C or T. You specified '%s'",
argv[1]);
return (ISC_R_FAILURE);
}
/* allocate and zero memory for driver structure */
db = isc_mem_get(named_g_mctx, sizeof(bdbhpt_instance_t));
memset(db, 0, sizeof(bdbhpt_instance_t));
/* attach to the memory context */
isc_mem_attach(named_g_mctx, &db->mctx);
/*
* create bdbhpt environment
* Basically bdbhpt allocates and assigns memory to db->dbenv
*/
bdbhptres = db_env_create(&db->dbenv, 0);
if (bdbhptres != 0) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"bdbhpt environment could not be created. "
"bdbhpt error: %s",
db_strerror(bdbhptres));
result = ISC_R_FAILURE;
goto init_cleanup;
}
/* open bdbhpt environment */
bdbhptres = db->dbenv->open(db->dbenv, argv[2],
bdbFlags | bdbhpt_threads | DB_CREATE, 0);
if (bdbhptres != 0) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"bdbhpt environment at '%s' could not be opened."
" bdbhpt error: %s",
argv[2], db_strerror(bdbhptres));
result = ISC_R_FAILURE;
goto init_cleanup;
}
/* open dlz_data database. */
result = bdbhpt_opendb(db->dbenv, DB_UNKNOWN, &db->data, dlz_data,
argv[3], DB_DUP | DB_DUPSORT);
if (result != ISC_R_SUCCESS) {
goto init_cleanup;
}
/* open dlz_xfr database. */
result = bdbhpt_opendb(db->dbenv, DB_UNKNOWN, &db->xfr, dlz_xfr,
argv[3], DB_DUP | DB_DUPSORT);
if (result != ISC_R_SUCCESS) {
goto init_cleanup;
}
/* open dlz_zone database. */
result = bdbhpt_opendb(db->dbenv, DB_UNKNOWN, &db->zone, dlz_zone,
argv[3], 0);
if (result != ISC_R_SUCCESS) {
goto init_cleanup;
}
/* open dlz_client database. */
result = bdbhpt_opendb(db->dbenv, DB_UNKNOWN, &db->client, dlz_client,
argv[3], DB_DUP | DB_DUPSORT);
if (result != ISC_R_SUCCESS) {
goto init_cleanup;
}
*dbdata = db;
return (ISC_R_SUCCESS);
init_cleanup:
bdbhpt_cleanup(db);
return (result);
}
static void
bdbhpt_destroy(void *driverarg, void *dbdata) {
UNUSED(driverarg);
bdbhpt_cleanup((bdbhpt_instance_t *)dbdata);
}
/*
* bdbhpt_authority not needed as authority data is returned by lookup
*/
static dns_sdlzmethods_t dlz_bdbhpt_methods = {
bdbhpt_create,
bdbhpt_destroy,
bdbhpt_findzone,
bdbhpt_lookup,
NULL,
bdbhpt_allnodes,
bdbhpt_allowzonexfr,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
};
/*%
* Wrapper around dns_sdlzregister().
*/
isc_result_t
dlz_bdbhpt_init(void) {
isc_result_t result;
/*
* Write debugging message to log
*/
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DLZ,
ISC_LOG_DEBUG(2), "Registering DLZ bdbhpt driver.");
result = dns_sdlzregister("bdbhpt", &dlz_bdbhpt_methods, NULL,
DNS_SDLZFLAG_RELATIVEOWNER |
DNS_SDLZFLAG_RELATIVERDATA |
DNS_SDLZFLAG_THREADSAFE,
named_g_mctx, &dlz_bdbhpt);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"dns_sdlzregister() failed: %s",
isc_result_totext(result));
result = ISC_R_UNEXPECTED;
}
return (result);
}
/*%
* Wrapper around dns_sdlzunregister().
*/
void
dlz_bdbhpt_clear(void) {
/*
* Write debugging message to log
*/
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DLZ,
ISC_LOG_DEBUG(2), "Unregistering DLZ bdbhpt driver.");
if (dlz_bdbhpt != NULL) {
dns_sdlzunregister(&dlz_bdbhpt);
}
}
#endif /* ifdef DLZ_BDB */

View File

@@ -1,158 +0,0 @@
/*
* Copyright (C) 2005 Internet Systems Consortium, Inc. ("ISC")
*
* 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 ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC 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.
*/
/*! \file */
#include <isc/result.h>
/*
* Pull in declarations for this module's functions.
*/
#include <dlz/dlz_drivers.h>
/*
* Pull in driver-specific stuff.
*/
#ifdef DLZ_STUB
#include <dlz/dlz_stub_driver.h>
#endif /* ifdef DLZ_STUB */
#ifdef DLZ_POSTGRES
#include <dlz/dlz_postgres_driver.h>
#endif /* ifdef DLZ_POSTGRES */
#ifdef DLZ_MYSQL
#include <dlz/dlz_mysql_driver.h>
#endif /* ifdef DLZ_MYSQL */
#ifdef DLZ_FILESYSTEM
#include <dlz/dlz_filesystem_driver.h>
#endif /* ifdef DLZ_FILESYSTEM */
#ifdef DLZ_BDB
#include <dlz/dlz_bdb_driver.h>
#include <dlz/dlz_bdbhpt_driver.h>
#endif /* ifdef DLZ_BDB */
#ifdef DLZ_LDAP
#include <dlz/dlz_ldap_driver.h>
#endif /* ifdef DLZ_LDAP */
#ifdef DLZ_ODBC
#include <dlz/dlz_odbc_driver.h>
#endif /* ifdef DLZ_ODBC */
/*%
* Call init functions for all relevant DLZ drivers.
*/
isc_result_t
dlz_drivers_init(void) {
isc_result_t result = ISC_R_SUCCESS;
#ifdef DLZ_STUB
result = dlz_stub_init();
if (result != ISC_R_SUCCESS) {
return (result);
}
#endif /* ifdef DLZ_STUB */
#ifdef DLZ_POSTGRES
result = dlz_postgres_init();
if (result != ISC_R_SUCCESS) {
return (result);
}
#endif /* ifdef DLZ_POSTGRES */
#ifdef DLZ_MYSQL
result = dlz_mysql_init();
if (result != ISC_R_SUCCESS) {
return (result);
}
#endif /* ifdef DLZ_MYSQL */
#ifdef DLZ_FILESYSTEM
result = dlz_fs_init();
if (result != ISC_R_SUCCESS) {
return (result);
}
#endif /* ifdef DLZ_FILESYSTEM */
#ifdef DLZ_BDB
result = dlz_bdb_init();
if (result != ISC_R_SUCCESS) {
return (result);
}
result = dlz_bdbhpt_init();
if (result != ISC_R_SUCCESS) {
return (result);
}
#endif /* ifdef DLZ_BDB */
#ifdef DLZ_LDAP
result = dlz_ldap_init();
if (result != ISC_R_SUCCESS) {
return (result);
}
#endif /* ifdef DLZ_LDAP */
#ifdef DLZ_ODBC
result = dlz_odbc_init();
if (result != ISC_R_SUCCESS) {
return (result);
}
#endif /* ifdef DLZ_ODBC */
return (result);
}
/*%
* Call shutdown functions for all relevant DLZ drivers.
*/
void
dlz_drivers_clear(void) {
#ifdef DLZ_STUB
dlz_stub_clear();
#endif /* ifdef DLZ_STUB */
#ifdef DLZ_POSTGRES
dlz_postgres_clear();
#endif /* ifdef DLZ_POSTGRES */
#ifdef DLZ_MYSQL
dlz_mysql_clear();
#endif /* ifdef DLZ_MYSQL */
#ifdef DLZ_FILESYSTEM
dlz_fs_clear();
#endif /* ifdef DLZ_FILESYSTEM */
#ifdef DLZ_BDB
dlz_bdb_clear();
dlz_bdbhpt_clear();
#endif /* ifdef DLZ_BDB */
#ifdef DLZ_LDAP
dlz_ldap_clear();
#endif /* ifdef DLZ_LDAP */
#ifdef DLZ_ODBC
dlz_odbc_clear();
#endif /* ifdef DLZ_ODBC */
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,316 +0,0 @@
/*
* Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl.
*
* 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 STICHTING NLNET
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* STICHTING NLNET 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.
*
* The development of Dynamically Loadable Zones (DLZ) for Bind 9 was
* conceived and contributed by Rob Butler.
*
* 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 ROB BUTLER
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* ROB BUTLER 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.
*/
/*
* Copyright (C) 1999-2001, 2016 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/.
*/
#ifdef DLZ_STUB
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <isc/mem.h>
#include <isc/print.h>
#include <isc/result.h>
#include <isc/util.h>
#include <dns/log.h>
#include <dns/result.h>
#include <dns/sdlz.h>
#include <dlz/dlz_stub_driver.h>
#include <named/globals.h>
static dns_sdlzimplementation_t *dlz_stub = NULL;
typedef struct config_data {
char *myzone;
char *myname;
char *myip;
isc_mem_t *mctx;
} config_data_t;
/*
* SDLZ methods
*/
static isc_result_t
stub_dlz_allnodes(const char *zone, void *driverarg, void *dbdata,
dns_sdlzallnodes_t *allnodes) {
config_data_t *cd;
isc_result_t result;
UNUSED(zone);
UNUSED(driverarg);
cd = (config_data_t *)dbdata;
result = dns_sdlz_putnamedrr(allnodes, cd->myname, "soa", 86400,
"web root.localhost. "
"0 28800 7200 604800 86400");
if (result != ISC_R_SUCCESS) {
return (ISC_R_FAILURE);
}
result = dns_sdlz_putnamedrr(allnodes, "ns", "ns", 86400, cd->myname);
if (result != ISC_R_SUCCESS) {
return (ISC_R_FAILURE);
}
result = dns_sdlz_putnamedrr(allnodes, cd->myname, "a", 1, cd->myip);
if (result != ISC_R_SUCCESS) {
return (ISC_R_FAILURE);
}
return (ISC_R_SUCCESS);
}
static isc_result_t
stub_dlz_allowzonexfr(void *driverarg, void *dbdata, const char *name,
const char *client) {
config_data_t *cd;
UNUSED(driverarg);
UNUSED(client);
cd = (config_data_t *)dbdata;
if (strcmp(name, cd->myname) == 0) {
return (ISC_R_SUCCESS);
}
return (ISC_R_NOTFOUND);
}
static isc_result_t
stub_dlz_authority(const char *zone, void *driverarg, void *dbdata,
dns_sdlzlookup_t *lookup) {
isc_result_t result;
config_data_t *cd;
UNUSED(driverarg);
cd = (config_data_t *)dbdata;
if (strcmp(zone, cd->myzone) == 0) {
result = dns_sdlz_putsoa(lookup, cd->myname, "root.localhost.",
0);
if (result != ISC_R_SUCCESS) {
return (ISC_R_FAILURE);
}
result = dns_sdlz_putrr(lookup, "ns", 86400, cd->myname);
if (result != ISC_R_SUCCESS) {
return (ISC_R_FAILURE);
}
return (ISC_R_SUCCESS);
}
return (ISC_R_NOTFOUND);
}
static isc_result_t
stub_dlz_findzonedb(void *driverarg, void *dbdata, const char *name,
dns_clientinfomethods_t *methods,
dns_clientinfo_t *clientinfo) {
config_data_t *cd;
UNUSED(driverarg);
UNUSED(methods);
UNUSED(clientinfo);
cd = (config_data_t *)dbdata;
/* Write info message to log */
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DLZ,
ISC_LOG_DEBUG(2), "dlz_stub findzone looking for '%s'",
name);
if (strcmp(cd->myzone, name) == 0) {
return (ISC_R_SUCCESS);
} else {
return (ISC_R_NOTFOUND);
}
}
static isc_result_t
stub_dlz_lookup(const char *zone, const char *name, void *driverarg,
void *dbdata, dns_sdlzlookup_t *lookup,
dns_clientinfomethods_t *methods,
dns_clientinfo_t *clientinfo) {
isc_result_t result;
config_data_t *cd;
UNUSED(zone);
UNUSED(driverarg);
UNUSED(methods);
UNUSED(clientinfo);
cd = (config_data_t *)dbdata;
if (strcmp(name, cd->myname) == 0) {
result = dns_sdlz_putrr(lookup, "a", 1, cd->myip);
if (result != ISC_R_SUCCESS) {
return (ISC_R_FAILURE);
}
return (ISC_R_SUCCESS);
}
return (ISC_R_FAILURE);
}
static isc_result_t
stub_dlz_create(const char *dlzname, unsigned int argc, char *argv[],
void *driverarg, void **dbdata) {
config_data_t *cd;
UNUSED(driverarg);
if (argc < 4) {
return (ISC_R_FAILURE);
}
/*
* Write info message to log
*/
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DLZ,
ISC_LOG_INFO,
"Loading '%s' using DLZ_stub driver. "
"Zone: %s, Name: %s IP: %s",
dlzname, argv[1], argv[2], argv[3]);
cd = isc_mem_get(named_g_mctx, sizeof(config_data_t));
if ((cd) == NULL) {
return (ISC_R_NOMEMORY);
}
memset(cd, 0, sizeof(config_data_t));
cd->myzone = isc_mem_strdup(named_g_mctx, argv[1]);
cd->myname = isc_mem_strdup(named_g_mctx, argv[2]);
cd->myip = isc_mem_strdup(named_g_mctx, argv[3]);
isc_mem_attach(named_g_mctx, &cd->mctx);
*dbdata = cd;
return (ISC_R_SUCCESS);
}
static void
stub_dlz_destroy(void *driverarg, void *dbdata) {
config_data_t *cd;
isc_mem_t *mctx;
UNUSED(driverarg);
cd = (config_data_t *)dbdata;
/*
* Write debugging message to log
*/
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DLZ,
ISC_LOG_DEBUG(2), "Unloading DLZ_stub driver.");
isc_mem_free(named_g_mctx, cd->myzone);
isc_mem_free(named_g_mctx, cd->myname);
isc_mem_free(named_g_mctx, cd->myip);
mctx = cd->mctx;
isc_mem_putanddetach(&mctx, cd, sizeof(config_data_t));
}
static dns_sdlzmethods_t dlz_stub_methods = {
stub_dlz_create,
stub_dlz_destroy,
stub_dlz_findzonedb,
stub_dlz_lookup,
stub_dlz_authority,
stub_dlz_allnodes,
stub_dlz_allowzonexfr,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
};
/*%
* Wrapper around dns_sdlzregister().
*/
isc_result_t
dlz_stub_init(void) {
isc_result_t result;
/*
* Write debugging message to log
*/
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DLZ,
ISC_LOG_DEBUG(2), "Registering DLZ_stub driver.");
result = dns_sdlzregister("dlz_stub", &dlz_stub_methods, NULL,
DNS_SDLZFLAG_RELATIVEOWNER |
DNS_SDLZFLAG_RELATIVERDATA,
named_g_mctx, &dlz_stub);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"dns_sdlzregister() failed: %s",
isc_result_totext(result));
result = ISC_R_UNEXPECTED;
}
return (result);
}
/*
* Wrapper around dns_sdlzunregister().
*/
void
dlz_stub_clear(void) {
/*
* Write debugging message to log
*/
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DLZ,
ISC_LOG_DEBUG(2), "Unregistering DLZ_stub driver.");
if (dlz_stub != NULL) {
dns_sdlzunregister(&dlz_stub);
}
}
#endif /* ifdef DLZ_STUB */

View File

@@ -1 +0,0 @@
../../../../.clang-format.headers

View File

@@ -1,45 +0,0 @@
/*
* Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl.
*
* 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 STICHTING NLNET
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* STICHTING NLNET 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.
*
* The development of Dynamically Loadable Zones (DLZ) for Bind 9 was
* conceived and contributed by Rob Butler.
*
* 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 ROB BUTLER
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* ROB BUTLER 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 DLZ_BDB_DRIVER_H
#define DLZ_BDB_DRIVER_H
isc_result_t
dlz_bdb_init(void);
void
dlz_bdb_clear(void);
#endif /* ifndef DLZ_BDB_DRIVER_H */

View File

@@ -1,45 +0,0 @@
/*
* Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl.
*
* 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 STICHTING NLNET
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* STICHTING NLNET 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.
*
* The development of Dynamically Loadable Zones (DLZ) for Bind 9 was
* conceived and contributed by Rob Butler.
*
* 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 ROB BUTLER
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* ROB BUTLER 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 DLZ_BDBHPT_DRIVER_H
#define DLZ_BDBHPT_DRIVER_H
isc_result_t
dlz_bdbhpt_init(void);
void
dlz_bdbhpt_clear(void);
#endif /* ifndef DLZ_BDBHPT_DRIVER_H */

View File

@@ -1,28 +0,0 @@
/*
* Copyright (C) 2005 Internet Systems Consortium, Inc. ("ISC")
*
* 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 ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC 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 DLZ_DRIVERS_H
#define DLZ_DRIVERS_H 1
/*! \file */
isc_result_t
dlz_drivers_init(void);
void
dlz_drivers_clear(void);
#endif /* DLZ_DRIVERS_H */

View File

@@ -1,45 +0,0 @@
/*
* Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl.
*
* 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 STICHTING NLNET
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* STICHTING NLNET 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.
*
* The development of Dynamically Loadable Zones (DLZ) for Bind 9 was
* conceived and contributed by Rob Butler.
*
* 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 ROB BUTLER
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* ROB BUTLER 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 DLZ_FILESYSTEM_DRIVER_H
#define DLZ_FILESYSTEM_DRIVER_H
isc_result_t
dlz_fs_init(void);
void
dlz_fs_clear(void);
#endif /* ifndef DLZ_FILESYSTEM_DRIVER_H */

View File

@@ -1,45 +0,0 @@
/*
* Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl.
*
* 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 STICHTING NLNET
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* STICHTING NLNET 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.
*
* The development of Dynamically Loadable Zones (DLZ) for Bind 9 was
* conceived and contributed by Rob Butler.
*
* 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 ROB BUTLER
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* ROB BUTLER 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 DLZ_LDAP_DRIVER_H
#define DLZ_LDAP_DRIVER_H
isc_result_t
dlz_ldap_init(void);
void
dlz_ldap_clear(void);
#endif /* ifndef DLZ_LDAP_DRIVER_H */

View File

@@ -1,45 +0,0 @@
/*
* Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl.
*
* 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 STICHTING NLNET
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* STICHTING NLNET 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.
*
* The development of Dynamically Loadable Zones (DLZ) for Bind 9 was
* conceived and contributed by Rob Butler.
*
* 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 ROB BUTLER
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* ROB BUTLER 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 DLZ_MYSQL_DRIVER_H
#define DLZ_MYSQL_DRIVER_H
isc_result_t
dlz_mysql_init(void);
void
dlz_mysql_clear(void);
#endif /* ifndef DLZ_MYSQL_DRIVER_H */

View File

@@ -1,45 +0,0 @@
/*
* Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl.
*
* 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 STICHTING NLNET
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* STICHTING NLNET 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.
*
* The development of Dynamically Loadable Zones (DLZ) for Bind 9 was
* conceived and contributed by Rob Butler.
*
* 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 ROB BUTLER
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* ROB BUTLER 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 DLZ_ODBC_DRIVER_H
#define DLZ_ODBC_DRIVER_H
isc_result_t
dlz_odbc_init(void);
void
dlz_odbc_clear(void);
#endif /* ifndef DLZ_ODBC_DRIVER_H */

View File

@@ -1,45 +0,0 @@
/*
* Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl.
*
* 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 STICHTING NLNET
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* STICHTING NLNET 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.
*
* The development of Dynamically Loadable Zones (DLZ) for Bind 9 was
* conceived and contributed by Rob Butler.
*
* 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 ROB BUTLER
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* ROB BUTLER 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 DLZ_POSTGRES_DRIVER_H
#define DLZ_POSTGRES_DRIVER_H
isc_result_t
dlz_postgres_init(void);
void
dlz_postgres_clear(void);
#endif /* ifndef DLZ_POSTGRES_DRIVER_H */

View File

@@ -1,45 +0,0 @@
/*
* Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl.
*
* 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 STICHTING NLNET
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* STICHTING NLNET 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.
*
* The development of Dynamically Loadable Zones (DLZ) for Bind 9 was
* conceived and contributed by Rob Butler.
*
* 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 ROB BUTLER
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* ROB BUTLER 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 DLZ_STUB_DRIVER_H
#define DLZ_STUB_DRIVER_H
isc_result_t
dlz_stub_init(void);
void
dlz_stub_clear(void);
#endif /* ifndef DLZ_STUB_DRIVER_H */

View File

@@ -1,120 +0,0 @@
/*
* Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl.
*
* 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 STICHTING NLNET
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* STICHTING NLNET 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.
*
* The development of Dynamically Loadable Zones (DLZ) for Bind 9 was
* conceived and contributed by Rob Butler.
*
* 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 ROB BUTLER
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* ROB BUTLER 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 SDLZHELPER_H
#define SDLZHELPER_H
#include <stdbool.h>
/*
* Types
*/
#define SDLZH_REQUIRE_CLIENT 0x01
#define SDLZH_REQUIRE_QUERY 0x02
#define SDLZH_REQUIRE_RECORD 0x04
#define SDLZH_REQUIRE_ZONE 0x08
typedef struct query_segment query_segment_t;
typedef ISC_LIST(query_segment_t) query_list_t;
typedef struct dbinstance dbinstance_t;
typedef ISC_LIST(dbinstance_t) db_list_t;
typedef struct driverinstance driverinstance_t;
/*%
* a query segment is all the text between our special tokens
* special tokens are %zone%, %record%, %client%
*/
struct query_segment {
void * sql;
unsigned int strlen;
bool direct;
ISC_LINK(query_segment_t) link;
};
/*%
* a database instance contains everything we need for running
* a query against the database. Using it each separate thread
* can dynamically construct a query and execute it against the
* database. The "instance_lock" and locking code in the driver's
* make sure no two threads try to use the same DBI at a time.
*/
struct dbinstance {
void * dbconn;
query_list_t *allnodes_q;
query_list_t *allowxfr_q;
query_list_t *authority_q;
query_list_t *findzone_q;
query_list_t *lookup_q;
query_list_t *countzone_q;
char * query_buf;
char * zone;
char * record;
char * client;
isc_mem_t * mctx;
isc_mutex_t instance_lock;
ISC_LINK(dbinstance_t) link;
};
/*
* Method declarations
*/
/* see the code in sdlz_helper.c for more information on these methods */
char *
sdlzh_build_querystring(isc_mem_t *mctx, query_list_t *querylist);
isc_result_t
sdlzh_build_sqldbinstance(isc_mem_t *mctx, const char *allnodes_str,
const char *allowxfr_str, const char *authority_str,
const char *findzone_str, const char *lookup_str,
const char *countzone_str, dbinstance_t **dbi);
void
sdlzh_destroy_sqldbinstance(dbinstance_t *dbi);
char *
sdlzh_get_parameter_value(isc_mem_t *mctx, const char *input, const char *key);
/* Compatibility with existing DLZ drivers */
#define build_querystring sdlzh_build_querystring
#define build_sqldbinstance sdlzh_build_sqldbinstance
#define destroy_sqldbinstance sdlzh_destroy_sqldbinstance
#define getParameterValue(x, y) \
sdlzh_get_parameter_value(named_g_mctx, (x), (y))
#endif /* SDLZHELPER_H */

View File

@@ -1,48 +0,0 @@
# Copyright (C) 2005 Internet Systems Consortium, Inc. ("ISC")
#
# 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 ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC 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.
dlz_drivers.@O@: ${DLZ_DRIVER_DIR}/dlz_drivers.c ${DLZ_DRIVER_DIR}/include/dlz/dlz_drivers.h
${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} -c ${DLZ_DRIVER_DIR}/dlz_drivers.c
sdlz_helper.@O@: ${DLZ_DRIVER_DIR}/sdlz_helper.c ${DLZ_DRIVER_DIR}/include/dlz/sdlz_helper.h
${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} -c ${DLZ_DRIVER_DIR}/sdlz_helper.c
dlz_bdb_driver.@O@: ${DLZ_DRIVER_DIR}/dlz_bdb_driver.c ${DLZ_DRIVER_DIR}/include/dlz/dlz_bdb_driver.h
${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} -c ${DLZ_DRIVER_DIR}/dlz_bdb_driver.c
dlz_bdbhpt_driver.@O@: ${DLZ_DRIVER_DIR}/dlz_bdbhpt_driver.c ${DLZ_DRIVER_DIR}/include/dlz/dlz_bdbhpt_driver.h
${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} -c ${DLZ_DRIVER_DIR}/dlz_bdbhpt_driver.c
dlz_filesystem_driver.@O@: ${DLZ_DRIVER_DIR}/dlz_filesystem_driver.c ${DLZ_DRIVER_DIR}/include/dlz/dlz_filesystem_driver.h
${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} -c ${DLZ_DRIVER_DIR}/dlz_filesystem_driver.c
dlz_ldap_driver.@O@: ${DLZ_DRIVER_DIR}/dlz_ldap_driver.c ${DLZ_DRIVER_DIR}/include/dlz/dlz_ldap_driver.h
${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} -c ${DLZ_DRIVER_DIR}/dlz_ldap_driver.c
dlz_mysql_driver.@O@: ${DLZ_DRIVER_DIR}/dlz_mysql_driver.c ${DLZ_DRIVER_DIR}/include/dlz/dlz_mysql_driver.h
${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} -c ${DLZ_DRIVER_DIR}/dlz_mysql_driver.c
dlz_odbc_driver.@O@: ${DLZ_DRIVER_DIR}/dlz_odbc_driver.c ${DLZ_DRIVER_DIR}/include/dlz/dlz_odbc_driver.h
${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} -c ${DLZ_DRIVER_DIR}/dlz_odbc_driver.c
dlz_postgres_driver.@O@: ${DLZ_DRIVER_DIR}/dlz_postgres_driver.c ${DLZ_DRIVER_DIR}/include/dlz/dlz_postgres_driver.h
${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} -c ${DLZ_DRIVER_DIR}/dlz_postgres_driver.c
dlz_dlopen_driver.@O@: ${DLZ_DRIVER_DIR}/dlz_dlopen_driver.c ${DLZ_DRIVER_DIR}/include/dlz/dlz_dlopen_driver.h
${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} -c ${DLZ_DRIVER_DIR}/dlz_dlopen_driver.c
dlz_stub_driver.@O@: ${DLZ_DRIVER_DIR}/dlz_stub_driver.c ${DLZ_DRIVER_DIR}/include/dlz/dlz_stub_driver.h
${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} -c ${DLZ_DRIVER_DIR}/dlz_stub_driver.c

View File

@@ -1,489 +0,0 @@
/*
* Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl.
*
* 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 STICHTING NLNET
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* STICHTING NLNET 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.
*
* The development of Dynamically Loadable Zones (DLZ) for Bind 9 was
* conceived and contributed by Rob Butler.
*
* 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 ROB BUTLER
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* ROB BUTLER 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.
*/
/*
* Copyright (C) 1999-2001, 2016 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/.
*/
#include <stdbool.h>
#include <isc/mem.h>
#include <isc/result.h>
#include <isc/string.h>
#include <isc/util.h>
#include <dns/log.h>
#include <dns/result.h>
#include <dlz/sdlz_helper.h>
/*
* sdlz helper methods
*/
/*%
* properly destroys a querylist by de-allocating the
* memory for each query segment, and then the list itself
*/
static void
destroy_querylist(isc_mem_t *mctx, query_list_t **querylist) {
query_segment_t *tseg = NULL;
query_segment_t *nseg = NULL;
REQUIRE(mctx != NULL);
/* if query list is null, nothing to do */
if (*querylist == NULL) {
return;
}
/* start at the top of the list */
nseg = ISC_LIST_HEAD(**querylist);
while (nseg != NULL) { /* loop, until end of list */
tseg = nseg;
/*
* free the query segment's text string but only if it
* was really a query segment, and not a pointer to
* %zone%, or %record%, or %client%
*/
if (tseg->sql != NULL && tseg->direct) {
isc_mem_free(mctx, tseg->sql);
}
/* get the next query segment, before we destroy this one. */
nseg = ISC_LIST_NEXT(nseg, link);
/* deallocate this query segment. */
isc_mem_put(mctx, tseg, sizeof(query_segment_t));
}
/* deallocate the query segment list */
isc_mem_put(mctx, *querylist, sizeof(query_list_t));
}
/*% constructs a query list by parsing a string into query segments */
static isc_result_t
build_querylist(isc_mem_t *mctx, const char *query_str, char **zone,
char **record, char **client, query_list_t **querylist,
unsigned int flags) {
isc_result_t result;
bool foundzone = false;
bool foundrecord = false;
bool foundclient = false;
char *free_me = NULL;
char *temp_str = NULL;
query_list_t *tql;
query_segment_t *tseg = NULL;
char *last = NULL;
REQUIRE(querylist != NULL && *querylist == NULL);
REQUIRE(mctx != NULL);
/* if query string is null, or zero length */
if (query_str == NULL || strlen(query_str) < 1) {
if ((flags & SDLZH_REQUIRE_QUERY) == 0) {
/* we don't need it were ok. */
return (ISC_R_SUCCESS);
} else {
/* we did need it, PROBLEM!!! */
return (ISC_R_FAILURE);
}
}
/* allocate memory for query list */
tql = isc_mem_get(mctx, sizeof(query_list_t));
/* initialize the query segment list */
ISC_LIST_INIT(*tql);
/* make a copy of query_str so we can chop it up */
free_me = temp_str = isc_mem_strdup(mctx, query_str);
/* couldn't make a copy, problem!! */
if (temp_str == NULL) {
result = ISC_R_NOMEMORY;
goto cleanup;
}
/* loop through the string and chop it up */
for (;;) {
/*
* Split string into tokens at '$'.
*/
const char *sql = strtok_r(temp_str, "$", &last);
if (sql == NULL) {
break;
}
temp_str = NULL;
/* allocate memory for tseg */
tseg = isc_mem_get(mctx, sizeof(query_segment_t));
tseg->sql = NULL;
tseg->direct = false;
/* initialize the query segment link */
ISC_LINK_INIT(tseg, link);
/* append the query segment to the list */
ISC_LIST_APPEND(*tql, tseg, link);
tseg->sql = isc_mem_strdup(mctx, sql);
/* tseg->sql points directly to a string. */
tseg->direct = true;
tseg->strlen = strlen(tseg->sql);
/* check if we encountered "$zone$" token */
if (strcasecmp(tseg->sql, "zone") == 0) {
/*
* we don't really need, or want the "zone"
* text, so get rid of it.
*/
isc_mem_free(mctx, tseg->sql);
/* set tseg->sql to in-direct zone string */
tseg->sql = zone;
tseg->strlen = 0;
/* tseg->sql points in-directly to a string */
tseg->direct = false;
foundzone = true;
/* check if we encountered "$record$" token */
} else if (strcasecmp(tseg->sql, "record") == 0) {
/*
* we don't really need, or want the "record"
* text, so get rid of it.
*/
isc_mem_free(mctx, tseg->sql);
/* set tseg->sql to in-direct record string */
tseg->sql = record;
tseg->strlen = 0;
/* tseg->sql points in-directly points to a string */
tseg->direct = false;
foundrecord = true;
/* check if we encountered "$client$" token */
} else if (strcasecmp(tseg->sql, "client") == 0) {
/*
* we don't really need, or want the "client"
* text, so get rid of it.
*/
isc_mem_free(mctx, tseg->sql);
/* set tseg->sql to in-direct record string */
tseg->sql = client;
tseg->strlen = 0;
/* tseg->sql points in-directly points to a string */
tseg->direct = false;
foundclient = true;
}
}
/* we don't need temp_str any more */
isc_mem_free(mctx, free_me);
/*
* add checks later to verify zone and record are found if
* necessary.
*/
/* if this query requires %client%, make sure we found it */
if (((flags & SDLZH_REQUIRE_CLIENT) != 0) && (!foundclient)) {
/* Write error message to log */
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"Required token $client$ not found.");
result = ISC_R_FAILURE;
goto flag_fail;
}
/* if this query requires %record%, make sure we found it */
if (((flags & SDLZH_REQUIRE_RECORD) != 0) && (!foundrecord)) {
/* Write error message to log */
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"Required token $record$ not found.");
result = ISC_R_FAILURE;
goto flag_fail;
}
/* if this query requires %zone%, make sure we found it */
if (((flags & SDLZH_REQUIRE_ZONE) != 0) && (!foundzone)) {
/* Write error message to log */
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"Required token $zone$ not found.");
result = ISC_R_FAILURE;
goto flag_fail;
}
/* pass back the query list */
*querylist = (query_list_t *)tql;
/* return success */
return (ISC_R_SUCCESS);
cleanup:
/* get rid of free_me */
if (free_me != NULL) {
isc_mem_free(mctx, free_me);
}
flag_fail:
/* get rid of what was build of the query list */
destroy_querylist(mctx, &tql);
return (result);
}
/*%
* build a query string from query segments, and dynamic segments
* dynamic segments replace where the tokens %zone%, %record%, %client%
* used to be in our queries from named.conf
*/
char *
sdlzh_build_querystring(isc_mem_t *mctx, query_list_t *querylist) {
query_segment_t *tseg = NULL;
unsigned int length = 0;
char *qs = NULL;
REQUIRE(mctx != NULL);
REQUIRE(querylist != NULL);
/* start at the top of the list */
tseg = ISC_LIST_HEAD(*querylist);
while (tseg != NULL) {
/*
* if this is a query segment, use the
* precalculated string length
*/
if (tseg->direct) {
length += tseg->strlen;
} else { /* calculate string length for dynamic segments. */
length += strlen(*(char **)tseg->sql);
}
/* get the next segment */
tseg = ISC_LIST_NEXT(tseg, link);
}
/* allocate memory for the string */
qs = isc_mem_allocate(mctx, length + 1);
*qs = 0;
/* start at the top of the list again */
tseg = ISC_LIST_HEAD(*querylist);
while (tseg != NULL) {
if (tseg->direct) {
/* query segments */
strcat(qs, tseg->sql);
} else {
/* dynamic segments */
strcat(qs, *(char **)tseg->sql);
}
/* get the next segment */
tseg = ISC_LIST_NEXT(tseg, link);
}
return (qs);
}
/*% constructs a sql dbinstance (DBI) */
isc_result_t
sdlzh_build_sqldbinstance(isc_mem_t *mctx, const char *allnodes_str,
const char *allowxfr_str, const char *authority_str,
const char *findzone_str, const char *lookup_str,
const char *countzone_str, dbinstance_t **dbi) {
isc_result_t result;
dbinstance_t *db = NULL;
REQUIRE(dbi != NULL && *dbi == NULL);
REQUIRE(mctx != NULL);
/* allocate and zero memory for driver structure */
db = isc_mem_get(mctx, sizeof(dbinstance_t));
memset(db, 0, sizeof(dbinstance_t));
db->dbconn = NULL;
db->client = NULL;
db->record = NULL;
db->zone = NULL;
db->mctx = NULL;
db->query_buf = NULL;
db->allnodes_q = NULL;
db->allowxfr_q = NULL;
db->authority_q = NULL;
db->findzone_q = NULL;
db->countzone_q = NULL;
db->lookup_q = NULL;
/* attach to the memory context */
isc_mem_attach(mctx, &db->mctx);
/* initialize the reference count mutex */
isc_mutex_init(&db->instance_lock);
/* build the all nodes query list */
result = build_querylist(mctx, allnodes_str, &db->zone, &db->record,
&db->client, &db->allnodes_q,
SDLZH_REQUIRE_ZONE);
/* if unsuccessful, log err msg and cleanup */
if (result != ISC_R_SUCCESS) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"Could not build all nodes query list");
goto cleanup;
}
/* build the allow zone transfer query list */
result = build_querylist(mctx, allowxfr_str, &db->zone, &db->record,
&db->client, &db->allowxfr_q,
SDLZH_REQUIRE_ZONE | SDLZH_REQUIRE_CLIENT);
/* if unsuccessful, log err msg and cleanup */
if (result != ISC_R_SUCCESS) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"Could not build allow xfr query list");
goto cleanup;
}
/* build the authority query, query list */
result = build_querylist(mctx, authority_str, &db->zone, &db->record,
&db->client, &db->authority_q,
SDLZH_REQUIRE_ZONE);
/* if unsuccessful, log err msg and cleanup */
if (result != ISC_R_SUCCESS) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"Could not build authority query list");
goto cleanup;
}
/* build findzone query, query list */
result = build_querylist(mctx, findzone_str, &db->zone, &db->record,
&db->client, &db->findzone_q,
SDLZH_REQUIRE_ZONE);
/* if unsuccessful, log err msg and cleanup */
if (result != ISC_R_SUCCESS) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"Could not build find zone query list");
goto cleanup;
}
/* build countzone query, query list */
result = build_querylist(mctx, countzone_str, &db->zone, &db->record,
&db->client, &db->countzone_q,
SDLZH_REQUIRE_ZONE);
/* if unsuccessful, log err msg and cleanup */
if (result != ISC_R_SUCCESS) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"Could not build count zone query list");
goto cleanup;
}
/* build lookup query, query list */
result = build_querylist(mctx, lookup_str, &db->zone, &db->record,
&db->client, &db->lookup_q,
SDLZH_REQUIRE_RECORD);
/* if unsuccessful, log err msg and cleanup */
if (result != ISC_R_SUCCESS) {
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
DNS_LOGMODULE_DLZ, ISC_LOG_ERROR,
"Could not build lookup query list");
goto cleanup;
}
/* pass back the db instance */
*dbi = (dbinstance_t *)db;
/* return success */
return (ISC_R_SUCCESS);
cleanup:
/* destroy whatever was build of the db instance */
destroy_sqldbinstance(db);
/* return failure */
return (ISC_R_FAILURE);
}
void
sdlzh_destroy_sqldbinstance(dbinstance_t *dbi) {
isc_mem_t *mctx;
/* save mctx for later */
mctx = dbi->mctx;
/* destroy any query lists we created */
destroy_querylist(mctx, &dbi->allnodes_q);
destroy_querylist(mctx, &dbi->allowxfr_q);
destroy_querylist(mctx, &dbi->authority_q);
destroy_querylist(mctx, &dbi->findzone_q);
destroy_querylist(mctx, &dbi->countzone_q);
destroy_querylist(mctx, &dbi->lookup_q);
/* get rid of the mutex */
(void)isc_mutex_destroy(&dbi->instance_lock);
/* return, and detach the memory */
isc_mem_putanddetach(&mctx, dbi, sizeof(dbinstance_t));
}
char *
sdlzh_get_parameter_value(isc_mem_t *mctx, const char *input, const char *key) {
int keylen;
char *keystart;
char value[255];
int i;
if (key == NULL || input == NULL || strlen(input) < 1) {
return (NULL);
}
keylen = strlen(key);
if (keylen < 1) {
return (NULL);
}
keystart = strstr(input, key);
if (keystart == NULL) {
return (NULL);
}
REQUIRE(mctx != NULL);
for (i = 0; i < 255; i++) {
value[i] = keystart[keylen + i];
if (value[i] == ' ' || value[i] == '\0') {
value[i] = '\0';
break;
}
}
return (isc_mem_strdup(mctx, value));
}

View File

@@ -0,0 +1,21 @@
prefix = /usr
libdir = $(prefix)/lib/bind9
CFLAGS=-fPIC -g -I../include $(shell mysql_config --cflags)
LDAP_LIBS=$(shell mysql_config --libs)
all: dlz_mysql_dynamic.so
dlz_dbi.o: ../common/dlz_dbi.c
$(CC) $(CFLAGS) -c ../common/dlz_dbi.c
dlz_mysql_dynamic.so: dlz_mysql_dynamic.c dlz_dbi.o
$(CC) $(CFLAGS) -shared -o dlz_mysql_dynamic.so \
dlz_mysql_dynamic.c dlz_dbi.o $(MYSQL_LIBS)
clean:
rm -f dlz_mysql_dynamic.so *.o
install: dlz_mysql_dynamic.so
mkdir -p $(DESTDIR)$(libdir)
install dlz_mysql_dynamic.so $(DESTDIR)$(libdir)

View File

@@ -0,0 +1,21 @@
prefix = /usr
libdir = $(prefix)/lib/bind9
CFLAGS=-fPIC -g -I../include $(shell mysql_config --cflags)
LDAP_LIBS=$(shell mysql_config --libs)
all: dlz_mysqldyn_mod.so
dlz_dbi.o: ../common/dlz_dbi.c
$(CC) $(CFLAGS) -c ../common/dlz_dbi.c
dlz_mysqldyn_mod.so: dlz_mysqldyn_mod.c dlz_dbi.o
$(CC) $(CFLAGS) -shared -o dlz_mysqldyn_mod.so \
dlz_mysqldyn_mod.c dlz_dbi.o $(MYSQL_LIBS)
clean:
rm -f dlz_mysqldyn_mod.so *.o
install: dlz_mysqldyn_mod.so
mkdir -p $(DESTDIR)$(libdir)
install dlz_mysqldyn_mod.so $(DESTDIR)$(libdir)

View File

@@ -1,23 +0,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.
-->
### DNS Privacy in BIND
This directory contains sample configuration files to enable BIND,
with Nginx as a TLS proxy, to provide DNS over TLS.
`named.conf` configures a validating recursive name server to listen
on the localhost address at port 8853.
`nginx.conf` configures a TLS proxy to listen on port 853 and
forward queries and responses to `named`.
For more information, please see
[https://dnsprivacy.org/wiki/](https://dnsprivacy.org/wiki/)

View File

@@ -1,18 +0,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.
*/
options {
listen-on port 8853 { 127.0.0.1; };
allow-query { localhost; };
recursion yes;
dnssec-validation auto;
tcp-clients 1024;
};

View File

@@ -1,41 +0,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 https://mozilla.org/MPL/2.0/.
#
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
# uncomment to choose an appropriate UID/GID; default is 'nobody'
# user bind bind;
worker_processes auto;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
multi_accept on;
}
stream {
upstream dns_tcp_servers {
server 127.0.0.1:8853;
}
server {
listen 853 ssl;
proxy_pass dns_tcp_servers;
# update to a suitable SSL certificate (e.g. from LetsEncrypt),
# and uncomment the following lines:
# ssl_certificate /etc/nginx/lego/certificates/<cert>.crt;
# ssl_certificate_key /etc/nginx/lego/certificates/<cert>.key;
ssl_protocols TLSv1.2;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_session_tickets on;
ssl_session_timeout 4h;
ssl_handshake_timeout 30s;
}
}

View File

@@ -1,11 +0,0 @@
This directory is for tools and scripts related to the OpenDNSSEC KASP
("key and signature policy") format. Currently it only contains
"kasp2policy.py", a python script for converting KASP key policy
to the "dnssec.policy" format that is used by dnssec-keymgr.
This depends on PLY (python lex/yacc) and on the "isc.dnskey" module in
bin/python/isc.
Basic test:
$ python kasp2policy.py kasp.xml > policy.out
$ diff policy.out policy.good

View File

@@ -1,134 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Sample KASP file to use for testing kasp2policy.py. -->
<KASP>
<Policy name="Policy1">
<Description>A default policy that will
amaze you and your friends</Description>
<Signatures>
<Resign>PT5M</Resign>
<Refresh>PT5M</Refresh>
<Validity>
<Default>PT15M</Default>
<Denial>PT15M</Denial>
</Validity>
<Jitter>PT2M</Jitter>
<InceptionOffset>PT1M</InceptionOffset>
</Signatures>
<Denial>
<NSEC>
</NSEC>
</Denial>
<Keys>
<!-- Parameters for both KSK and ZSK -->
<TTL>PT1M</TTL>
<RetireSafety>PT0S</RetireSafety>
<PublishSafety>PT0S</PublishSafety>
<!-- Parameters for KSK only -->
<KSK>
<Algorithm length="2048">5</Algorithm>
<Lifetime>PT40M</Lifetime>
<Repository>softHSM</Repository>
<Standby>1</Standby>
</KSK>
<!-- Parameters for ZSK only -->
<ZSK>
<Algorithm length="2048">5</Algorithm>
<Lifetime>PT25M</Lifetime>
<Repository>softHSM</Repository>
<Standby>1</Standby>
</ZSK>
</Keys>
<Zone>
<PropagationDelay>PT0S</PropagationDelay>
<SOA>
<TTL>PT0S</TTL>
<Minimum>PT0S</Minimum>
<Serial>unixtime</Serial>
</SOA>
</Zone>
<Parent>
<PropagationDelay>PT8M</PropagationDelay>
<DS>
<TTL>PT0S</TTL>
</DS>
<SOA>
<TTL>PT0S</TTL>
<Minimum>PT0S</Minimum>
</SOA>
</Parent>
</Policy>
<Policy name="Policy2">
<Description>A default policy that will amaze you and your friends</Description>
<Signatures>
<Resign>PT7M</Resign>
<Refresh>PT7M</Refresh>
<Validity>
<Default>PT15M</Default>
<Denial>PT16M</Denial>
</Validity>
<Jitter>PT2M</Jitter>
<InceptionOffset>PT1M</InceptionOffset>
</Signatures>
<Denial>
<NSEC3>
<Resalt>P120D</Resalt>
<Hash>
<Algorithm>1</Algorithm>
<Iterations>5</Iterations>
<Salt length="8"/>
</Hash>
</NSEC3>
</Denial>
<Keys>
<!-- Parameters for both KSK and ZSK -->
<TTL>PT15M</TTL>
<RetireSafety>PT0S</RetireSafety>
<PublishSafety>PT0S</PublishSafety>
<!-- Parameters for KSK only -->
<KSK>
<Algorithm length="2048">7</Algorithm>
<Lifetime>PT45M</Lifetime>
<Repository>softHSM</Repository>
<Standby>1</Standby>
</KSK>
<!-- Parameters for ZSK only -->
<ZSK>
<Algorithm length="2048">7</Algorithm>
<Lifetime>PT25M</Lifetime>
<Repository>softHSM</Repository>
<Standby>1</Standby>
</ZSK>
</Keys>
<Zone>
<PropagationDelay>PT0S</PropagationDelay>
<SOA>
<TTL>PT0S</TTL>
<Minimum>PT0S</Minimum>
<Serial>unixtime</Serial>
</SOA>
</Zone>
<Parent>
<PropagationDelay>PT12M</PropagationDelay>
<DS>
<TTL>PT0S</TTL>
</DS>
<SOA>
<TTL>PT0S</TTL>
<Minimum>PT0S</Minimum>
</SOA>
</Parent>
</Policy>
</KASP>

View File

@@ -1,24 +0,0 @@
# A default policy that will
# amaze you and your friends
policy Policy1 {
algorithm RSASHA1;
keyttl 60;
key-size ksk 2048;
key-size zsk 2048;
roll-period ksk 2400;
roll-period zsk 1500;
standby ksk 1;
standby zsk 1;
};
# A default policy that will amaze you and your friends
policy Policy2 {
algorithm NSEC3RSASHA1;
keyttl 900;
key-size ksk 2048;
key-size zsk 2048;
roll-period ksk 2700;
roll-period zsk 1500;
standby ksk 1;
standby zsk 1;
};

View File

@@ -1,210 +0,0 @@
#!/bin/sh
# Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
#
# Permission to use, copy, modify, and/or 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 ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC 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.
#
# Original script contributed by Jeffry A. Spain <spainj@countryday.net>
HELP="
Generates a set of <count> successive DNSSEC keys for <zone>
Key timings are based on a pre-publication rollover strategy
<life> (lifetime) is the key active lifetime in days [default 180]
<intro> (introduction time) is the number of days from publication
to activation of a key [default 30]
<ret> (retirement time) is the number of days from inactivation
to deletion of a key [default 30]
Options:
-a <alg> Cryptographic algorithm. See man dnssec-keygen for defaults.
-b <bits> Number of bits in the key. See man dnssec-keygen for defaults.
-k if present, generate Key Signing Keys (KSKs). Otherwise,
generate Zone Signing Keys (ZSKs).
-3 If present and if -a is not specified, use an NSEC3-
capable algorithm. See man dnssec-keygen for defaults.
-i <date> Inception date of the set of keys, in 'mm/dd/yyyy' format.
The first two keys will be published by this date, and the
first one will be activated. Default is today.
-f <index> Index of first key generated. Defaults to 0.
-K <dir> Key repository: write keys to this directory. Defaults to CWD.
-d Dry run. No actual keys generated if present."
USAGE="Usage:
`basename $0` [-a <alg>] [-b <bits>] [-k] [-3] [-i <date>]
[-f <index>] [-d] <zone> <count> [<life>] [<intro>] [<ret>]"
ALGFLAG=''
BITSFLAG=''
KSKFLAG=''
NSEC3FLAG=''
KEYREPO=''
DRYRUN=false
OPTKSK=false
K=0
INCEP=`date +%m/%d/%Y`
# Parse command line options
while getopts ":a:b:df:hkK:3i:" thisOpt
do
case $thisOpt in
a)
ALGFLAG=" -a $OPTARG"
;;
b)
BITSFLAG=" -b $OPTARG"
;;
d)
DRYRUN=true
;;
f)
OPTKSK=true
K=$OPTARG
;;
h)
echo "$USAGE"
echo "$HELP"
exit 0
;;
k)
KSKFLAG=" -f KSK"
;;
K)
KEYREPO=$OPTARG
;;
3)
NSEC3FLAG=" -3"
;;
i)
INCEP=$OPTARG
;;
*)
echo 'Unrecognized option.'
echo "$USAGE"
exit 1
;;
esac
done
shift `expr $OPTIND - 1`
# Check that required arguments are present
if [ $# -gt 5 -o $# -lt 2 ]; then
echo "$USAGE"
exit 1
fi
# Remaining arguments:
# DNS zone name
ZONE=$1
shift
# Number of keys to be generated
COUNT=$1
shift
# Key active lifetime
LIFE=${1:-180}
[ $# -ne 0 ] && shift
# Key introduction time (publication to activation)
INTRO=${1:-30}
[ $# -ne 0 ] && shift
# Key retirement time (inactivation to deletion)
RET=${1:-30}
# Today's date in dnssec-keygen format (YYYYMMDD)
TODAY=`date +%Y%m%d`
# Key repository defaults to CWD
if [ -z "$KEYREPO" ]; then
KEYREPO="."
fi
if $DRYRUN; then
echo 'Dry Run (no key files generated)'
elif [ ! -d "$KEYREPO" ]; then
# Create the key repository if it does not currently exist
mkdir -p "$KEYREPO"
fi
# Iterate through the key set. K is the index, zero-based.
KLAST=`expr $K + $COUNT`
while [ $K -lt $KLAST ]; do
KEYLABEL="Key `printf \"%02d\" $K`:"
# Epoch of the current key
# (zero for the first key, increments of key lifetime)
# The epoch is in days relative to the inception date of the key set
EPOCH=`expr $LIFE \* $K`
# Activation date in days is the same as the epoch
ACTIVATE=$EPOCH
# Publication date in days relative to the key epoch
PUBLISH=`expr $EPOCH - $LIFE - $INTRO`
# Inactivation date in days relative to the key epoch
INACTIVE=`expr $EPOCH + $LIFE`
# Deletion date in days relative to the key epoch
DELETE=`expr $EPOCH + $LIFE + $RET`
# ... these values should not precede the key epoch
[ $ACTIVATE -lt 0 ] && ACTIVATE=0
[ $PUBLISH -lt 0 ] && PUBLISH=0
[ $INACTIVE -lt 0 ] && INACTIVE=0
[ $DELETE -lt 0 ] && DELETE=0
# Key timing dates in dnssec-keygen format (YYYYMMDD):
# publication, activation, inactivation, deletion
PDATE=`date -d "$INCEP +$PUBLISH day" +%Y%m%d`
ADATE=`date -d "$INCEP +$ACTIVATE day" +%Y%m%d`
IDATE=`date -d "$INCEP +$INACTIVE day" +%Y%m%d`
DDATE=`date -d "$INCEP +$DELETE day" +%Y%m%d`
# Construct the dnssec-keygen command including all the specified options.
# Suppress key generation progress information, and save the key in
# the $KEYREPO directory.
KEYGENCMD="dnssec-keygen -q$ALGFLAG$BITSFLAG$NSEC3FLAG$KSKFLAG -P $PDATE -A $ADATE -I $IDATE -D $DDATE -K $KEYREPO $ZONE"
echo "$KEYLABEL $KEYGENCMD"
# Generate the key and retrieve its name
if $DRYRUN; then
KEYNAME="DryRunKey-`printf \"%02d\" $K`"
else
KEYNAME=`$KEYGENCMD`
fi
# Indicate the key status based on key timing dates relative to today
if [ $TODAY -ge $DDATE ]; then
echo "$KEYLABEL $KEYNAME is obsolete post deletion date."
elif [ $TODAY -ge $IDATE ]; then
echo "$KEYLABEL $KEYNAME is published and inactive prior to deletion date."
elif [ $TODAY -ge $ADATE ]; then
echo "$KEYLABEL $KEYNAME is published and active."
elif [ $TODAY -ge $PDATE ]; then
echo "$KEYLABEL $KEYNAME is published prior to activation date."
else
echo "$KEYLABEL $KEYNAME is pending publication."
fi
# For published KSKs, generate the required DS records,
# saving them to the file $KEYREPO/DS-$KEYNAME
if $OPTKSK && [ $TODAY -ge $PDATE -a $TODAY -lt $DDATE ]; then
echo "$KEYLABEL $KEYNAME (KSK) requires the publication of DS records in the parent zone."
if $DRYRUN; then
echo "$KEYLABEL No DS-$KEYNAME file created."
else
dnssec-dsfromkey "$KEYREPO/$KEYNAME" > "$KEYREPO/DS-$KEYNAME"
echo "$KEYLABEL See $KEYREPO/DS-$KEYNAME."
fi
fi
K=`expr $K + 1`
done
exit 0

View File

@@ -1,299 +0,0 @@
#!/bin/sh
#
# Portions 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 https://mozilla.org/MPL/2.0/.
#
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
# $NetBSD: named-bootconf.sh,v 1.5 1998/12/15 01:00:53 tron Exp $
#
# Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Matthias Scheler.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
if [ ${OPTIONFILE-X} = X ]; then
WORKDIR=/tmp/`date +%s`.$$
( umask 077 ; mkdir $WORKDIR ) || {
echo "unable to create work directory '$WORKDIR'" >&2
exit 1
}
OPTIONFILE=$WORKDIR/options
ZONEFILE=$WORKDIR/zones
COMMENTFILE=$WORKDIR/comments
export OPTIONFILE ZONEFILE COMMENTFILE
touch $OPTIONFILE $ZONEFILE $COMMENTFILE
DUMP=1
else
DUMP=0
fi
while read CMD ARGS; do
class=
CMD=`echo "${CMD}" | tr '[A-Z]' '[a-z]'`
case $CMD in
\; )
echo \# $ARGS >>$COMMENTFILE
;;
cache )
set - X $ARGS
shift
if [ $# -eq 2 ]; then
(echo ""
cat $COMMENTFILE
echo "zone \"$1\" {"
echo " type hint;"
echo " file \"$2\";"
echo "};") >>$ZONEFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
fi
;;
directory )
set - X $ARGS
shift
if [ $# -eq 1 ]; then
(cat $COMMENTFILE
echo " directory \"$1\";") >>$OPTIONFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
DIRECTORY=$1
export DIRECTORY
fi
;;
forwarders )
(cat $COMMENTFILE
echo " forwarders {"
for ARG in $ARGS; do
echo " $ARG;"
done
echo " };") >>$OPTIONFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
;;
include )
if [ "$ARGS" != "" ]; then
(cd ${DIRECTORY-.}; cat $ARGS) | $0
fi
;;
limit )
ARGS=`echo "${ARGS}" | tr '[A-Z]' '[a-z]'`
set - X $ARGS
shift
if [ $# -eq 2 ]; then
cat $COMMENTFILE >>$OPTIONFILE
case $1 in
datasize | files | transfers-in | transfers-per-ns )
echo " $1 $2;" >>$OPTIONFILE
;;
esac
rm -f $COMMENTFILE
touch $COMMENTFILE
fi
;;
options )
ARGS=`echo "${ARGS}" | tr '[A-Z]' '[a-z]'`
cat $COMMENTFILE >>$OPTIONFILE
for ARG in $ARGS; do
case $ARG in
fake-iquery )
echo " fake-iquery yes;" >>$OPTIONFILE
;;
forward-only )
echo " forward only;" >>$OPTIONFILE
;;
no-fetch-glue )
echo " fetch-glue no;" >>$OPTIONFILE
;;
no-recursion )
echo " recursion no;" >>$OPTIONFILE
;;
esac
done
rm -f $COMMENTFILE
touch $COMMENTFILE
;;
primary|primary/* )
case $CMD in
primary/chaos )
class="chaos "
;;
primary/hs )
class="hesiod "
;;
esac
set - X $ARGS
shift
if [ $# -eq 2 ]; then
(echo ""
cat $COMMENTFILE
echo "zone \"$1\" ${class}{"
echo " type master;"
echo " file \"$2\";"
echo "};") >>$ZONEFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
fi
;;
secondary|secondary/* )
case $CMD in
secondary/chaos )
class="chaos "
;;
secondary/hs )
class="hesiod "
;;
esac
set - X $ARGS
shift
if [ $# -gt 2 ]; then
ZONE=$1
shift
PRIMARIES=$1
while [ $# -gt 2 ]; do
shift
PRIMARIES="$PRIMARIES $1"
done
(echo ""
cat $COMMENTFILE
echo "zone \"$ZONE\" ${class}{"
echo " type slave;"
echo " file \"$2\";"
echo " masters {"
for PRIMARY in $PRIMARIES; do
echo " $PRIMARY;"
done
echo " };"
echo "};") >>$ZONEFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
fi
;;
stub|stub/* )
case $CMD in
stub/chaos )
class="chaos "
;;
stub/hs )
class="hesiod "
;;
esac
set - X $ARGS
shift
if [ $# -gt 2 ]; then
ZONE=$1
shift
PRIMARIES=$1
while [ $# -gt 2 ]; do
shift
PRIMARIES="$PRIMARIES $1"
done
(echo ""
cat $COMMENTFILE
echo "zone \"$ZONE\" ${class}{"
echo " type stub;"
echo " file \"$2\";"
echo " masters {"
for PRIMARY in $PRIMARIES; do
echo " $PRIMARY;"
done
echo " };"
echo "};") >>$ZONEFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
fi
;;
slave )
cat $COMMENTFILE >>$OPTIONFILE
echo " forward only;" >>$OPTIONFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
;;
sortlist )
(cat $COMMENTFILE
echo " topology {"
for ARG in $ARGS; do
case $ARG in
*.0.0.0 )
echo " $ARG/8;"
;;
*.0.0 )
echo " $ARG/16;"
;;
*.0 )
echo " $ARG/24;"
;;
* )
echo " $ARG;"
;;
esac
done
echo " };") >>$OPTIONFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
;;
tcplist | xfrnets )
(cat $COMMENTFILE
echo " allow-transfer {"
for ARG in $ARGS; do
case $ARG in
*.0.0.0 )
echo " $ARG/8;"
;;
*.0.0 )
echo " $ARG/16;"
;;
*.0 )
echo " $ARG/24;"
;;
* )
echo " $ARG;"
;;
esac
done
echo " };") >>$OPTIONFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
;;
esac
done
if [ $DUMP -eq 1 ]; then
echo ""
echo "options {"
cat $OPTIONFILE
echo "};"
cat $ZONEFILE $COMMENTFILE
rm -f $OPTIONFILE $ZONEFILE $COMMENTFILE
rmdir $WORKDIR
fi
exit 0

View File

@@ -37,6 +37,10 @@ Removed Features
``named-compilezone`` and change the configuration prior to BIND 9
upgrade. :gl:`#2882`
- Remove old-style DLZ drivers that had to be enabled in ``named`` during the
compile time. The new-style dynamically loaded DLZ modules should be used
as a replacement. :gl:`#2814`
Feature Changes
~~~~~~~~~~~~~~~

View File

@@ -229,17 +229,6 @@
./bin/tests/system/digdelv/tests.sh SH 2015,2016,2017,2018,2019,2020,2021
./bin/tests/system/digdelv/yamlget.py PYTHON 2019,2020,2021
./bin/tests/system/ditch.pl PERL 2015,2016,2018,2019,2020,2021
./bin/tests/system/dlz/clean.sh SH 2010,2012,2014,2016,2018,2019,2020,2021
./bin/tests/system/dlz/ns1/dns-root/com/broken/dns.d/@/DNAME=10=example.net.= TXT.BRIEF 2015,2016,2018,2019,2020,2021
./bin/tests/system/dlz/ns1/dns-root/com/broken/dns.d/@/NS=10=example.com.= TXT.BRIEF 2015,2016,2018,2019,2020,2021
./bin/tests/system/dlz/ns1/dns-root/com/broken/dns.d/@/SOA=10=ns.example.com.=root.example.com.=None=None=None=None=None= TXT.BRIEF 2015,2016,2018,2019,2020,2021
./bin/tests/system/dlz/ns1/dns-root/com/example/dns.d/@/DNAME=10=example.net.= TXT.BRIEF 2010,2016,2018,2019,2020,2021
./bin/tests/system/dlz/ns1/dns-root/com/example/dns.d/@/NS=10=example.com.= TXT.BRIEF 2010,2016,2018,2019,2020,2021
./bin/tests/system/dlz/ns1/dns-root/com/example/dns.d/@/SOA=10=ns.example.com.=root.example.com.=2010062900=0=0=0=10= TXT.BRIEF 2010,2016,2018,2019,2020,2021
./bin/tests/system/dlz/ns1/dns-root/com/example/xfr.d/10.53.0.1 TXT.BRIEF 2010,2016,2018,2019,2020,2021
./bin/tests/system/dlz/prereq.sh SH 2011,2012,2016,2018,2019,2020,2021
./bin/tests/system/dlz/setup.sh SH 2018,2019,2020,2021
./bin/tests/system/dlz/tests.sh SH 2010,2011,2012,2013,2015,2016,2018,2019,2020,2021
./bin/tests/system/dlzexternal/clean.sh SH 2010,2012,2014,2015,2016,2018,2019,2020,2021
./bin/tests/system/dlzexternal/driver/driver.c C 2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021
./bin/tests/system/dlzexternal/driver/driver.h C 2011,2016,2018,2019,2020,2021
@@ -934,33 +923,6 @@
./conftools/perllib/dnsconf/Makefile.PL PERL 2000,2001,2004,2007,2012,2016,2018,2019,2020,2021
./conftools/perllib/dnsconf/test.pl PERL 2000,2001,2004,2007,2012,2016,2018,2019,2020,2021
./contrib/README X 2014,2015,2016,2017,2018,2019,2020,2021
./contrib/dane/mkdane.sh X 2012,2018,2019,2020,2021
./contrib/dane/tlsa6698.pem X 2012,2018,2019,2020,2021
./contrib/dlz/bin/dlzbdb/dlzbdb.c X 2005,2016,2018,2019,2020,2021
./contrib/dlz/config.dlz.in X 2005,2006,2008,2010,2011,2014,2016,2017,2018,2019,2020
./contrib/dlz/drivers/dlz_bdb_driver.c X 2005,2008,2010,2011,2012,2016,2017,2018,2019,2020,2021
./contrib/dlz/drivers/dlz_bdbhpt_driver.c X 2005,2010,2011,2012,2016,2017,2018,2019,2020,2021
./contrib/dlz/drivers/dlz_dlopen_driver.c X 2010,2011,2018,2019,2020,2021
./contrib/dlz/drivers/dlz_drivers.c X 2005,2010,2011,2018,2019,2020,2021
./contrib/dlz/drivers/dlz_filesystem_driver.c X 2005,2010,2011,2012,2016,2017,2018,2019,2020,2021
./contrib/dlz/drivers/dlz_ldap_driver.c X 2005,2010,2011,2012,2016,2017,2018,2019,2020,2021
./contrib/dlz/drivers/dlz_mysql_driver.c X 2005,2007,2009,2010,2011,2012,2016,2017,2018,2019,2020,2021
./contrib/dlz/drivers/dlz_odbc_driver.c X 2005,2010,2011,2012,2014,2016,2017,2018,2019,2020,2021
./contrib/dlz/drivers/dlz_postgres_driver.c X 2005,2007,2010,2011,2012,2014,2016,2017,2018,2019,2020,2021
./contrib/dlz/drivers/dlz_stub_driver.c X 2005,2010,2011,2012,2016,2017,2018,2019,2020,2021
./contrib/dlz/drivers/include/dlz/dlz_bdb_driver.h X 2005,2018,2019,2020,2021
./contrib/dlz/drivers/include/dlz/dlz_bdbhpt_driver.h X 2005,2018,2019,2020,2021
./contrib/dlz/drivers/include/dlz/dlz_dlopen_driver.h X 2010,2011,2018,2019,2020,2021
./contrib/dlz/drivers/include/dlz/dlz_drivers.h X 2005,2018,2019,2020,2021
./contrib/dlz/drivers/include/dlz/dlz_filesystem_driver.h X 2005,2018,2019,2020,2021
./contrib/dlz/drivers/include/dlz/dlz_ldap_driver.h X 2005,2018,2019,2020,2021
./contrib/dlz/drivers/include/dlz/dlz_mysql_driver.h X 2005,2018,2019,2020,2021
./contrib/dlz/drivers/include/dlz/dlz_odbc_driver.h X 2005,2018,2019,2020,2021
./contrib/dlz/drivers/include/dlz/dlz_postgres_driver.h X 2005,2018,2019,2020,2021
./contrib/dlz/drivers/include/dlz/dlz_stub_driver.h X 2005,2018,2019,2020,2021
./contrib/dlz/drivers/include/dlz/sdlz_helper.h X 2005,2017,2018,2019,2020,2021
./contrib/dlz/drivers/rules.in X 2005,2010,2018,2019,2020
./contrib/dlz/drivers/sdlz_helper.c X 2005,2010,2011,2012,2016,2018,2019,2020,2021
./contrib/dlz/example/Makefile X 2010,2013,2018,2019,2020,2021
./contrib/dlz/example/README X 2011,2012,2013,2014,2018,2019,2020,2021
./contrib/dlz/example/dlz_example.c X 2010,2011,2012,2013,2014,2018,2019,2020,2021
@@ -987,11 +949,13 @@
./contrib/dlz/modules/ldap/testing/example.ldif X 2013,2018,2019,2020,2021
./contrib/dlz/modules/ldap/testing/named.conf X 2013,2018,2019
./contrib/dlz/modules/ldap/testing/slapd.conf X 2013,2018,2019
./contrib/dlz/modules/mysql/Makefile X 2021
./contrib/dlz/modules/mysql/dlz_mysql_dynamic.c X 2013,2016,2018,2019,2020,2021
./contrib/dlz/modules/mysql/testing/README X 2013,2018,2019,2020,2021
./contrib/dlz/modules/mysql/testing/dlz.data X 2013,2017,2018,2019
./contrib/dlz/modules/mysql/testing/dlz.schema X 2013,2018,2019,2020,2021
./contrib/dlz/modules/mysql/testing/named.conf X 2013,2018,2019
./contrib/dlz/modules/mysqldyn/Makefile X 2021
./contrib/dlz/modules/mysqldyn/README X 2014,2018,2019,2020,2021
./contrib/dlz/modules/mysqldyn/dlz_mysqldyn_mod.c X 2014,2015,2018,2019,2020,2021
./contrib/dlz/modules/mysqldyn/testing/README X 2014,2018,2019,2020,2021
@@ -1016,15 +980,9 @@
./contrib/dlz/modules/wildcard/README X 2013,2018,2019,2020,2021
./contrib/dlz/modules/wildcard/dlz_wildcard_dynamic.c X 2013,2015,2016,2018,2019,2020,2021
./contrib/dlz/modules/wildcard/testing/named.conf X 2013,2018,2019
./contrib/dnspriv/nginx.conf SH 2017,2018,2019
./contrib/kasp/README X 2020,2021
./contrib/kasp/kasp.xml X 2020,2021
./contrib/kasp/policy.good X 2020,2021
./contrib/scripts/catzhash.py X 2020,2021
./contrib/scripts/check-secure-delegation.pl.in PERL 2010,2012,2014,2016,2018,2019,2020
./contrib/scripts/check5011.pl X 2013,2014,2017,2018,2019,2020,2021
./contrib/scripts/dnssec-keyset.sh X 2015,2018,2019,2020,2021
./contrib/scripts/named-bootconf.sh SH.PORTION 1999,2000,2001,2004,2006,2007,2012,2014,2016,2018,2019,2020,2021
./contrib/scripts/nanny.pl PERL 2000,2001,2004,2007,2012,2014,2016,2018,2019,2020,2021
./contrib/scripts/zone-edit.sh.in SH 2010,2012,2014,2016,2018,2019,2020
./dangerfile.py PYTHON 2020,2021