Skip to content

Commit

Permalink
Add greatly improved testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
dleonard committed Sep 25, 2008
1 parent 3e52509 commit 550fa44
Show file tree
Hide file tree
Showing 5 changed files with 733 additions and 157 deletions.
6 changes: 4 additions & 2 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
1.3.0.?
- use syslog as daemon facility
- alter packet format to match MS DNS Client
- new VGP xlator for group policy control
- use syslog for logging
- bug 570: -t0 wasn't deleting records
- use configuration file for options similar to Microsoft's DNS client
- use configuration file for options
- follow NS records when primary SOA update fails
- bug 484: detect the authoritative domain name by doing an SOA query
- bug 467: add -r option for PTR updates
Expand Down
7 changes: 7 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ quest-dnsupdate-xlator: xlator.sh.in
xlator-t: xlator-t.sh
cat $(srcdir)/xlator-t.sh > $@
chmod +x $@

check_PROGRAMS += xlator-t
EXTRA_DIST += xlator.sh.in xlator-t.sh
CLEANFILES += quest-dnsupdate-xlator xlator-t

dnsupdate-t: dnsupdate-t.sh
cat $(srcdir)/dnsupdate-t.sh > $@
chmod +x $@
check_PROGRAMS+= dnsupdate-t
CLEANFILES += dnsupdate-t
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ AC_CHECK_TYPE([socklen_t],[AC_DEFINE([HAVE_SOCKLEN_T],[1],[socklen_t])],,[
# include <sys/socket.h>
#endif
])

AC_TYPE_SIGNAL
AC_CANONICAL_HOST
AC_MSG_CHECKING([ipwatchd needed])
case $host in
Expand Down
71 changes: 71 additions & 0 deletions dnsupdate-t.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/sh

WRKDIR=${TMPDIR:-/tmp}/dnsupdate-t$$
mkdir -p $WRKDIR || exit
cleanup () { if $PASSED_ALL; then rm -rf $WRKDIR; fi; }
#trap 'cleanup' 0

PASSED_ALL=true
GDB=false # Wraps dnsupdate in a gdb process
VERBOSE=false # Adds -vvvv to server-t

ip=127.0.0.1
iprev="'1.0.0.127.in-addr.arpa" # leading quote to force a dname
localns=127.0.0.2
domain=example.com
domainrev=127.in-addr.arpa
authns=ns.example.com
authip=127.0.0.3
hostname=host.example.com
hostmaster=hostmaster.example.com
ttl=900

DNS_RESOLV_CONF=$WRKDIR/resolv.conf; export DNS_RESOLV_CONF
cat <<-. >$DNS_RESOLV_CONF
nameserver $localns
.

# Runs dnsupdate with the given arguments, but wraps it
# in the server-t wrapper which checks outgoing DNS packets
# as described on standard input to this function
test_dnsupdate () {
set -- ./dnsupdate "$@"
$GDB && set -- gdb --args "$@"
set -- -u "$@" ';'
$GDB && set -- -N "$@"
$VERBOSE && set -- -vvvv "$@"
set -- ./server-t "$@"
while read request; do
case "$request" in
""|"#"*) :;;
*) read response
case "$response" in
""|"#"*) echo "responses must come after request" >&2
exit 1;;
*) set -- "$@" "$request" "$response";;
esac;;
esac
done
$VERBOSE && echo "$@"
"$@" 0<&1
}

test_dnsupdate -h $hostname $ip <<.
[$localns]Q:$hostname SOA
OK::$domain SOA $authns $hostmaster 0:$authns A $authip
[$authns]U:$domain SOA:$hostname 0 NONE CNAME ~:\
$hostname 0 ANY A ~,$hostname $ttl IN A $ip
OK::$hostname 0 NONE CNAME ~:$hostname 0 ANY A ~,$hostname $ttl IN A $ip
[$localns]Q:$iprev SOA
OK::$domainrev SOA $authns $hostmaster 0:$authns A $authip
[$authns]U:$domainrev SOA:$iprev 0 NONE CNAME ~:\
$iprev 0 ANY PTR ~,$iprev $ttl IN PTR $hostname
OK::$iprev 0 NONE CNAME ~:\
$iprev 0 ANY PTR ~,$iprev $ttl IN PTR $hostname
.


$PASSED_ALL
Loading

0 comments on commit 550fa44

Please sign in to comment.