mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Import (trimmed) ISC bind-8.1.2-t3b. This will be updated to 8.1.2 on
final release. Obtained from: ftp.isc.org
This commit is contained in:
parent
e2f1a81473
commit
4e0ffe0bae
260 changed files with 80302 additions and 4581 deletions
3456
contrib/bind/CHANGES
3456
contrib/bind/CHANGES
File diff suppressed because it is too large
Load diff
|
|
@ -1,99 +1,271 @@
|
|||
$Id: INSTALL,v 8.9 1997/06/24 06:43:50 vixie Exp $
|
||||
Supported Systems
|
||||
|
||||
THE FILES:
|
||||
----------
|
||||
INSTALL -- This file
|
||||
README -- Release announcements, tips and traps (some out of date)
|
||||
OPTIONS -- The options that can be turned on and off
|
||||
RUNSON -- What machines/compilers is BIND known to build on
|
||||
TODO -- Have spare time? Consider contributing to the project!
|
||||
BSD/* -- How to integrate BIND into a 4.4BSD or 4.4BSD-Lite
|
||||
contrib/* -- Useful BIND-related contributions
|
||||
doc/info/* -- Platform-dependent build hints
|
||||
doc/* -- other RFCs, drafts, papers and
|
||||
AIX 4.x
|
||||
A/UX 3.1.1
|
||||
BSD/OS 2.1, 3.x
|
||||
Digital ULTRIX 4.5
|
||||
Digital UNIX 3.2C, 4.0
|
||||
FreeBSD 2.x, 3.0
|
||||
HP MPE
|
||||
HP-UX 9.x, 10.20
|
||||
IRIX 5.3, 6.2, 6.4
|
||||
LynxOS
|
||||
NetBSD 1.2, 1.3
|
||||
OpenBSD 2.1
|
||||
QNX
|
||||
Red Hat Linux 4.x, 5.0
|
||||
SCO UNIX 3.2v4.2, SCO OSE 5.0.4, UnixWare 2.0.x, 2.1.2
|
||||
SunOS 4.1.4
|
||||
SunOS 5.5 (Solaris 2.5), 5.6 (Solaris 2.6)
|
||||
|
||||
INTRODUCTION:
|
||||
-------------
|
||||
BIND used to be extremely difficult to build. That changed around
|
||||
version 4.9.3. These are the instructions on how to compile the
|
||||
software. For information on how to create your configuration files
|
||||
(resolv.conf, named.boot, and zone files) see the doc/bog directory for
|
||||
the complete "BIND Operations Guide". You might also consider getting
|
||||
"DNS and BIND" by C. Liu and P. Albitz from O'Reilly & Associates,
|
||||
Sebastopol, CA, ISBN 0-937175-82-X 1992
|
||||
|
||||
Note: If you maintain a BSD or are otherwise running a 4.4BSD-based system
|
||||
and want to integrate BIND into it, check out BSD/README.
|
||||
|
||||
BUILDING & INSTALLING:
|
||||
----------------------
|
||||
1. (optional) If you are going to compile for multiple platforms, you
|
||||
can make a symbolic link tree for each platform to save disk space. To
|
||||
create a directory called "sun4.dir", do:
|
||||
make DST=sun4.dir links
|
||||
Now "cd sun4.dir" and you can do everything as if you had a complete
|
||||
copy of the source. Just be careful if you are modifying a file, make
|
||||
sure you turn any links into files:
|
||||
mv file file.tmp ; cp file.tmp file ; rm file.tmp
|
||||
|
||||
2. (optional) If you have a typical site, you should find yourself only
|
||||
editing Makefile and conf/options.h. Make backups of them now:
|
||||
|
||||
mv conf/options.h conf/options.h.dist
|
||||
cp conf/options.h.dist conf/options.h
|
||||
chmod u+w conf/options.h
|
||||
|
||||
mv Makefile Makefile.dist
|
||||
cp Makefile.dist Makefile
|
||||
chmod u+w Makefile
|
||||
|
||||
3. Edit "conf/options.h" and turn on any options that you want. The
|
||||
defaults are pretty reasonable for most installations.
|
||||
|
||||
4. Edit "Makefile". The default build parameters are given for 4.4 BSD.
|
||||
They should be overridden (not edited!). Do this by going to the
|
||||
section that describes your operating system and uncoment the
|
||||
appropriate lines. Add any other variables (for example, some people
|
||||
add "DISTHELP=/usr/local/lib".) If in doubt, use the default! Read
|
||||
the comments carefully!
|
||||
|
||||
5. "make" should build everything. Consider putting "./bin" in your
|
||||
path if "make depend" fails and you think bin/mkdep will help you out.
|
||||
|
||||
*** NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE ***
|
||||
|
||||
The next step (#6) will burn down files which were supplied with
|
||||
your operating system. You should run the suggested "-n" first
|
||||
and make sure you have saved any files you want to save.
|
||||
|
||||
*** NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE ***
|
||||
|
||||
6. "make install" will install everything. You might first do
|
||||
"make -n install" to see what commands would be executed by "make install"
|
||||
to make sure you understand where everything is about to be installed.
|
||||
|
||||
7. (optional, SunOS 4, SunOS 5, NetBSD-1.x, IRIX, Linix only): You can
|
||||
integrate the new resolver (client-side) code into the shared libraries
|
||||
of your operating system so that all dynamicly linked programs take
|
||||
advantage of the new resolver. Read shres/<osname>/INSTALL to find out
|
||||
how to do it.
|
||||
See port/README for information on porting BIND 8 to other systems.
|
||||
|
||||
|
||||
Building
|
||||
|
||||
HOW TO GET HELP:
|
||||
----------------
|
||||
The "bind-users@vix.com" mailing list was created especially for people to
|
||||
talk about and ask questions about installation, maintenance, etc. It is
|
||||
highly recommended that you first help yourself by reading the BOG (doc/bog)
|
||||
or a book on DNS and BIND.
|
||||
If you do not have an ANSI/ISO C compiler, give up or get GCC. The
|
||||
one exception is the ULTRIX compiler, which isn't full ANSI C but it
|
||||
has function prototypes and BIND works around the rest. BIND 8 also
|
||||
wants a C library that's ANSI/ISO standard, although it can work
|
||||
around some common failings.
|
||||
|
||||
To be added to this mailing list, send mail to <bind-users-request@vix.com>
|
||||
If you do not have yacc, get byacc or GNU bison. If you do not have
|
||||
lex, get GNU flex. For information on where to get GNU software, see
|
||||
http://www.fsf.org/order/ftp.html.
|
||||
|
||||
Note that the bind-users mailing list is also available on Usenet as
|
||||
comp.protocols.dns.bind
|
||||
and that we would all prefer that you read it that way if you possibly can.
|
||||
If you want to build outside the source pool, then
|
||||
|
||||
This INSTALL was...
|
||||
originally written on 15Jul94 by Tom Limoncelli <tal@bell-labs.com>
|
||||
changed in minor ways 23Dec95 by Christopher Davis <ckd@kei.com>
|
||||
and then changed by Tom Limoncelli again 16Oct96.
|
||||
make DST=/your/destination/here SRC=`pwd` links
|
||||
cd /your/destination/here
|
||||
|
||||
If you want to use DST=/var/obj/bind, you can simply type
|
||||
|
||||
make stdlinks
|
||||
|
||||
Next, make sure you have no stale trash laying about
|
||||
|
||||
make clean
|
||||
|
||||
Then, update the Makefile dependencies:
|
||||
|
||||
make depend
|
||||
|
||||
Finally,
|
||||
|
||||
make
|
||||
|
||||
|
||||
Installation
|
||||
|
||||
To install, type
|
||||
|
||||
make install
|
||||
|
||||
This will copy binaries to the appropriate locations for your system,
|
||||
and install the BIND 8 library and header files under /usr/local/bind.
|
||||
|
||||
The following variables can be used to change where things get
|
||||
installed:
|
||||
|
||||
DESTDIR prefix used in front of all other
|
||||
DEST variables. The default is the
|
||||
empty prefix.
|
||||
DESTLIB libraries
|
||||
DESTINC include files
|
||||
DESTBIN ordinary binaries (e.g. dig, nslookup)
|
||||
DESTSBIN system binaries (e.g. named)
|
||||
DESTEXEC helper binaries (e.g. named-xfer)
|
||||
DESTHELP place to put nslookup's help file
|
||||
DESTETC configuration file
|
||||
DESTRUN PID file location
|
||||
|
||||
These variables may be specified on the command line of the 'make'
|
||||
or in the Makefile.set for your port (e.g. if you use Solaris, in
|
||||
src/port/solaris/Makefile.set).
|
||||
|
||||
Before doing 'make install' using either method, you must
|
||||
|
||||
rm .settings
|
||||
|
||||
in the top level source directory because the build system caches
|
||||
these variables.
|
||||
|
||||
|
||||
Using BIND 8 Library Routines
|
||||
|
||||
Until a method to update the system's libraries is available,
|
||||
applications wishing to use BIND 8 library routines must include
|
||||
BIND 8 .h files, and must link with libbind.a. E.g.
|
||||
|
||||
cc -I/usr/local/bind/include -c sample.c
|
||||
cc -o sample -L/usr/local/bind/lib sample.o -lbind
|
||||
|
||||
The default locations for libbind.a and .h files in BIND 8.1.1
|
||||
and BIND 8.1.2 are different from those used in BIND 8.1-REL. If
|
||||
you did a 'make install' for BIND 8.1-REL, then you should delete
|
||||
the files it installed. They are:
|
||||
|
||||
/usr/local/lib/libbind.a
|
||||
/usr/local/include/arpa/inet.h
|
||||
/usr/local/include/arpa/nameser.h
|
||||
/usr/local/include/arpa/nameser_compat.h
|
||||
/usr/local/include/netdb.h
|
||||
/usr/local/include/resolv.h
|
||||
/usr/local/include/sys/bitypes.h (if it exists)
|
||||
/usr/local/include/sys/cdefs.h (if it exists)
|
||||
|
||||
|
||||
Operating System Notes
|
||||
|
||||
SunOS 4.1.4
|
||||
|
||||
An ANSI/ISO C compiler is required; we used gcc 2.7.2.1.
|
||||
|
||||
Solaris
|
||||
|
||||
We've tested with Sun's compilers, yacc, and lex, and also
|
||||
with gcc, byacc, and flex. By default, the build will try
|
||||
to use gcc. If you want to use the Sun compilers, simply
|
||||
copy "port/solaris/Makefile.set.sun" to
|
||||
"port/solaris/Makefile.set". To go back to using gcc, copy
|
||||
"port/solaris/Makefile.set.gcc" to "port/solaris/Makefile.set".
|
||||
|
||||
If you're using a Solaris release earlier than 2.5 and you have
|
||||
a large number of interfaces on your system, you many need
|
||||
use a script to "limit descriptors N" (where 'N' is a
|
||||
suitably large number) before execing "named". On Solaris
|
||||
2.5 and later, the server will do this itself.
|
||||
|
||||
Certain older versions of FreeBSD, NetBSD and BSD/OS
|
||||
|
||||
These systems have a /bin/sh based on "ash", which doesn't
|
||||
handle POSIX-style quoting correctly. Using "bash" will fix
|
||||
the problem. Either run make with "SH=bash" on the command
|
||||
line, or edit src/Makefile and change "SH=sh" to "SH=bash".
|
||||
|
||||
QNX
|
||||
|
||||
Read src/port/qnx/README before trying to build.
|
||||
|
||||
|
||||
FD_SETSIZE
|
||||
|
||||
The highest numbered file descriptor that the server and the resolver
|
||||
can utilize is determined by the FD_SETSIZE value of the system. Some
|
||||
systems set FD_SETSIZE much smaller than the actual number of files
|
||||
that can be opened. On such systems, create an "fd_setsize.h" file
|
||||
that sets FD_SETSIZE appropriately in the port's include directory.
|
||||
|
||||
|
||||
User and Group ID
|
||||
|
||||
Specifying "-u" followed by a username or numeric user id on the
|
||||
"named" command line will cause the server to give up all
|
||||
privileges and become that user after the initial load of the
|
||||
configuation file is complete. "-g" may be used similarly to set
|
||||
the group id. If "-u" is specified but "-g" is not, the group
|
||||
used will be the given user's primary group.
|
||||
|
||||
Here are some hints:
|
||||
|
||||
Because the server will have no privileges after changing
|
||||
its user id, you must restart the server if you change the
|
||||
interfaces and ports that the server is listening on, or if
|
||||
you add an interface.
|
||||
|
||||
If you log to files, you should create all of the log files
|
||||
in advance (e.g. with "touch"), and make sure they are owned
|
||||
by the user and group "named" will be running as.
|
||||
|
||||
You'll have to edit "ndc" to get it to start the server
|
||||
with the appropriate flags.
|
||||
|
||||
Note: this feature is still experimental.
|
||||
|
||||
|
||||
Chroot
|
||||
|
||||
"-t" followed by a directory path on the "named" command line will
|
||||
cause the server to chroot() to that directory before it starts
|
||||
loading the configuration file.
|
||||
|
||||
Setting up a chrooted area varies somewhat by operating system. Some
|
||||
experimentation may be necessary. Here are some hints:
|
||||
|
||||
Don't forget to install named-xfer.
|
||||
|
||||
Either don't use shared libraries when you build, or do
|
||||
whatever is required on your OS to allow shared libraries
|
||||
to be used after a chroot().
|
||||
|
||||
syslog() is often troublesome after chrooting. Use the
|
||||
"logging" statement and log to a file instead.
|
||||
|
||||
/dev/null should be in the chroot directory hierarchy. You
|
||||
can usually find out the mknod parameters for a null device by
|
||||
looking in /dev/MAKEDEV.
|
||||
|
||||
You'll have to edit "ndc" to get it to start the server
|
||||
with the appropriate flags, and to use the right pid file.
|
||||
|
||||
Note: this feature is still experimental.
|
||||
|
||||
|
||||
Using the Server
|
||||
|
||||
Note that /etc/named.boot is long gone. You need to make yourself an
|
||||
/etc/named.conf (note, that ends in "conf" rather than "boot") file.
|
||||
This file looks a lot like a C program or a modern gated.conf file;
|
||||
there are lots of {curly braces} and it takes some getting used to.
|
||||
You may get a lot more help from the example file (which is
|
||||
bin/named/named.conf) than from the documentation (see ../doc/html).
|
||||
You can convert your named.boot file to a named.conf file if you have
|
||||
Perl; see bin/named/named-bootconf.pl.
|
||||
|
||||
All the files that used to be created in /var/tmp, e.g. named.run,
|
||||
will now be created in the directory specified in the options
|
||||
statement. If debugging is turned on using the "-d" flag on server
|
||||
startup, then named.run will be created in the current directory.
|
||||
|
||||
|
||||
Known Dynamic DNS Bugs
|
||||
|
||||
If the server is master for a zone and authoritative for a child of
|
||||
that zone, then a dynamic update to the parent will destroy the
|
||||
delegation to the child when the parent zone is written to disk.
|
||||
This problem will be fixed in a future release. The only workaround
|
||||
is to not be authoritative for child zones of a dynamic zone.
|
||||
|
||||
Slave servers do not forward update requests to the primary master
|
||||
correctly. This will be fixed in a future release. In the meantime,
|
||||
slaves will refuse dynamic updates.
|
||||
|
||||
|
||||
Shared Libraries
|
||||
|
||||
Absolutely no support exists for editing the system's shared
|
||||
libraries to update the resolver. If you want to do that you
|
||||
probably want to look at BIND Version 4 (see http://www.isc.org/isc/)
|
||||
or wait a while or help out a lot. This means you probably do not
|
||||
want to install the library or include files into /usr/lib or
|
||||
/usr/include, and this kit helpfully puts everything into
|
||||
/usr/local/lib and /usr/local/include for that reason among others.
|
||||
|
||||
|
||||
Notes about contrib and doc
|
||||
|
||||
The BIND 8 "doc" package includes HTML documentation as well as all
|
||||
the RFC's, Internet Drafts, and "man" pages we can think of. You may
|
||||
need to install the doc/tmac files in your nroff/troff support
|
||||
directory since we use the newer BSD "mandoc" system for our "man"
|
||||
pages.
|
||||
|
||||
The BIND 8 "contrib" package is full of junk that you may want to
|
||||
take a look at. Feel free to send us more junk for future releases.
|
||||
|
||||
|
||||
Bugs
|
||||
|
||||
Please report bugs to
|
||||
|
||||
bind-bugs@isc.org
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,279 +1,145 @@
|
|||
Internet Software Consortium
|
||||
BIND Release 4.9.7 README
|
||||
$Date: 1998/04/07 04:24:01 $
|
||||
This is the source portion of BIND version 8.1.2-T3B. Its companions are
|
||||
"doc" and "contrib" so you are probably not missing anything.
|
||||
|
||||
The official version of ISC BIND is now 8.1.1. This is ISC BIND 4.9.7,
|
||||
hoped to be the last of 4.*, which we are releasing since it has an important
|
||||
security bug (plus some memory leaks) fixed.
|
||||
See the CHANGES file for a detailed listing of all changes. See the INSTALL
|
||||
file for information on building and installing BIND 8.1.2.
|
||||
|
||||
The official place to get BIND is <URL:ftp://ftp.isc.org/isc/bind/src>.
|
||||
|
||||
The official mailing lists are: <bind-users@vix.com> - users/admins
|
||||
(use *-request@* for admin mail) <bind-workers@vix.com> - developers
|
||||
BIND 8.1.2 Highlights
|
||||
|
||||
The official Usenet newsgroups are: <URL:news:comp.protocols.dns.bind>
|
||||
<URL:news:comp.protocols.dns.ops>
|
||||
<URL:news:comp.protocols.dns.std>
|
||||
|
||||
BIND is maintained by: The Internet Software Consortium
|
||||
(see <URL:http://www.isc.org/>)
|
||||
Security fixes for a number of problems including:
|
||||
|
||||
Bug reports should be sent to: <bind-bugs@vix.com>
|
||||
An attacker could overwrite the stack if inverse query support
|
||||
was enabled.
|
||||
|
||||
Read the top of CHANGES for interesting stuff.
|
||||
A number of denial of service attacks where malformed packets
|
||||
could cause the server to crash.
|
||||
|
||||
To build this: QUICK
|
||||
The server was willing to answer queries on its forwarding
|
||||
sockets.
|
||||
|
||||
(on SUNOS, use the BSD build environment or you will
|
||||
get the wrong definition for O_NDELAY)
|
||||
Several memory leaks have been plugged.
|
||||
|
||||
look at conf/options.h and edit to your tastes.
|
||||
The OPTIONS file here in this directory will help you
|
||||
figure out what to do.
|
||||
The server no longer panics if a periodic interface scan fails due
|
||||
to no file descriptors being available.
|
||||
|
||||
You should also look at the Makefile to select the proper set
|
||||
of definitions depending on whether you are using Ultrix,
|
||||
SunOS, and other 4.[23] BSD-alikes or using BSD 4.4, BSD/386,
|
||||
and other net2-alikes.
|
||||
Updates to a number of ports. New ports for QNX, LynxOS, HP-UX 9.x,
|
||||
and HP MPE.
|
||||
|
||||
"make links" will build a shadow source tree full
|
||||
of symbolic links. the default name of this tree
|
||||
is "./native.b", but you can override it by setting
|
||||
the DST variable on the "make" command line, as in:
|
||||
make DST=vax.b SRC=..
|
||||
if your DST is not a subdir of "here", you will need to
|
||||
override the SRC variable's default (which is ".."),
|
||||
as in:
|
||||
make DST=/tmp/vax.b SRC=`pwd`
|
||||
note that the DST directory must be nonexistent at
|
||||
the time that you run "make links".
|
||||
"limit files unlimited" now works as expected on systems where setting
|
||||
an infinite rlim_max for RLIMIT_NOFILE works.
|
||||
|
||||
after "make links", you can cd to the new build
|
||||
directory, check the settings in the Makefile, and
|
||||
run "make depend". if you aren't using "make links"
|
||||
(shame on you), just use "make depend" from "here".
|
||||
"make depend" may fail on your system; if so, look in
|
||||
the bin/ directory and find a mkdep that does in fact
|
||||
work for you.
|
||||
Adding and deleting the same record in the same dynamic update no
|
||||
longer crashes the server.
|
||||
|
||||
if you skip the "make depend" phase, or after you run it,
|
||||
you can do "make all" (from the build directory if you
|
||||
used "make links" or from "here" if you're just hacking
|
||||
around). you will get the following new things out of it:
|
||||
res/libresolv.a
|
||||
compat/lib/lib44bsd.a (optional)
|
||||
include/{netdb,resolv}.h
|
||||
include/arpa/{inet,nameser}.h
|
||||
compat/include/sys/{cdefs,bitypes}.h
|
||||
tools/{nstest,nsquery,dig,host}
|
||||
tools/nslookup/nslookup
|
||||
named/named
|
||||
named/named-xfer
|
||||
if you have trouble with "make all", check conf/portability.h
|
||||
for things that your system needs, or doesn't need, or whatever.
|
||||
it is preferable to add #ifdef's to conf/portability.h than to
|
||||
add them anywhere else.
|
||||
If a dynamic update fails, rollback is now done in LIFO order instead
|
||||
of FIFO order.
|
||||
|
||||
Better behavior when priming of the root servers fails.
|
||||
|
||||
purge_zone() didn't work correctly for the root zone, allowing
|
||||
old data to persist after loading the zone.
|
||||
|
||||
Improved handling of oversized UDP packets.
|
||||
|
||||
All hosts on the also-notify list are now notified.
|
||||
|
||||
The meaning of the count returned by select() varies somewhat by
|
||||
operating system, and this could cause previous releases of the
|
||||
server to spin.
|
||||
|
||||
Per-host statistics may be disabled by specifying 'host-statistics no'
|
||||
in named.conf.
|
||||
|
||||
The maximum number of zones has been increased from 32768 to 65536.
|
||||
|
||||
query-source may specify an address and port that the server is
|
||||
already listening on. BIND 8.1.1 required that either the address
|
||||
or port be wild. E.g., you can now say:
|
||||
|
||||
listen-on port 53 { 10.0.0.1; };
|
||||
query-source address 10.0.0.1 port 53;
|
||||
|
||||
The value of FD_SETSIZE to use may be specified.
|
||||
|
||||
Experimental -u (set user id), -g (set group id), and -t (chroot)
|
||||
command line options. See the INSTALL file for details.
|
||||
|
||||
|
||||
BIND 8 Features
|
||||
|
||||
-> DNS Dynamic Updates (RFC 2136)
|
||||
|
||||
-> DNS Change Notification (RFC 1996)
|
||||
|
||||
-> Completely new configuration syntax
|
||||
|
||||
-> Flexible, categorized logging system
|
||||
|
||||
-> IP-address-based access control for queries, zone transfers, and
|
||||
updates that may be specified on a zone-by-zone basis
|
||||
|
||||
-> More efficient zone transfers
|
||||
|
||||
-> Improved performance for servers with thousands of zones
|
||||
|
||||
-> The server no longer forks for outbound zone transfers
|
||||
|
||||
-> Many bug fixes
|
||||
|
||||
|
||||
File and Directory Overview
|
||||
|
||||
CHANGES history of added features and
|
||||
fixed bugs
|
||||
|
||||
INSTALL how to build and install
|
||||
|
||||
README this file
|
||||
|
||||
TODO features planned but not yet written
|
||||
|
||||
Version the version number of this release
|
||||
|
||||
bin/* source for executables, including
|
||||
the nameserver
|
||||
|
||||
include/* public .h files
|
||||
|
||||
lib/* the resolver and various BIND
|
||||
support libraries
|
||||
|
||||
port/* ports to various operating systems
|
||||
|
||||
from the build directory (or "here" if you didn't
|
||||
use "make links"), you can try "make -n install"
|
||||
which will tell you what will be installed. it might
|
||||
actually be right; however, what you will probably have to
|
||||
do is copy the above files into the places you want
|
||||
run them from. the other files you will need are:
|
||||
tools/nslookup/nslookup.help
|
||||
named/named.restart
|
||||
named/named.reload
|
||||
|
||||
resolver library notes: to install it, either put the .a
|
||||
file into /usr/local/lib or /usr/lib (if you use -lresolv
|
||||
on all the links of your networking software), or use "ar"
|
||||
to put all res/*.o directly into your /lib/libc.a file.
|
||||
either way you will want to copy the include files
|
||||
(including those from compat/include/sys) over to
|
||||
/usr/include (or /usr/local/include if you're willing to
|
||||
use -I/usr/local/include on all your network-software
|
||||
compiles). something like this:
|
||||
cp res/libresolv.a /usr/lib; ranlib /usr/lib/libresolv.a
|
||||
tar chf - include | (cd /usr/include; tar xvpf -)
|
||||
cp compat/include/sys/*.h /usr/include/sys
|
||||
Kits, Questions, Comments, and Bug Reports
|
||||
|
||||
installing the man pages is left as an exercise for the
|
||||
reader. there are just too many different versions of
|
||||
"man" floating around for me to be able to help you figure
|
||||
out what to do for the one you happen to be using.
|
||||
<URL:ftp://ftp.isc.org/isc/bind/src/cur> current non-test release
|
||||
<URL:ftp://ftp.isc.org/isc/bind/src/testing> latest public test kit
|
||||
|
||||
WARNING: If you were running a BIND 4.8.3 or earlier based
|
||||
named you should remove all cache files prior to starting
|
||||
named. It would generally be a good idea to remove all cache
|
||||
files regardless when installing a new version. The creadability
|
||||
code depends upon the cache files having been made with the
|
||||
latest named-xfer for correct operation.
|
||||
<URL:usenet:comp.protocols.dns.bind> using BIND
|
||||
<URL:usenet:comp.protocols.dns.ops> DNS operations in general
|
||||
<URL:usenet:comp.protocols.dns.std> DNS standards in general
|
||||
|
||||
(special compilation-related warning about SunOS systems:)
|
||||
<URL:mailto:bind-users-request@vix.com> gw'd to u:c.p.d.bind
|
||||
<URL:mailto:namedroppers-request@internic.net> gw'd to u:c.p.d.std
|
||||
<URL:mailto:bind-workers-request@vix.com> code warriors only please
|
||||
|
||||
From: Tom Limoncelli
|
||||
To: vixie (Paul A Vixie)
|
||||
Date: Mon, 11 Jan 93 11:30:39 EST
|
||||
|
||||
Sun compiler v2.0.1 hates bind4.9 code.
|
||||
|
||||
Sun has 3 compilers:
|
||||
|
||||
/usr/ucb/cc -- the default for SunOS 4.1.[123],
|
||||
dropped in Solaris 2.0.
|
||||
/usr/lang/cc -- the "unbundled" cc v1.0
|
||||
(pretty good, but expensive), only
|
||||
generates code for SunOS 4.1.x.
|
||||
/usr/lang/cc.2.0.1 -- the latest "unbundled" cc,
|
||||
for when they stop shipping the
|
||||
bundled version altogether. This
|
||||
generates code for SunOS 4.1.x and Solaris 2.x.
|
||||
|
||||
Sun's 2.0.1 C compiler (the one with the floating licenses) for SunOS
|
||||
4.1.x outputs a HUGE number of warnings. They can be ignored.
|
||||
|
||||
--------------------- (4.8.3 README -- mostly obsolete now)
|
||||
|
||||
This directory contains all the info and sources
|
||||
for the Berkeley Internet Name Domain server.
|
||||
You should read and understand these directions before starting
|
||||
to install the libraries and nameserver. Some of these steps
|
||||
replace existing source and binary files; you should make backups
|
||||
of all existing files before you begin this installation.
|
||||
Two installation procedures are described. The first is for 4.3BSD
|
||||
and other similar systems that are already configured to use earlier
|
||||
versions of the nameserver, and which have the new version of <netdb.h>
|
||||
(containing a h_addr_list field in the hostent structure). The second
|
||||
procedure is for 4.2BSD and derived systems. This procedure requires
|
||||
more decisions to be made, and may have to be varied due to system
|
||||
or operation constraints.
|
||||
|
||||
The subdirectories and their contents are:
|
||||
|
||||
bin - shell scripts used by current Berkeley makefiles
|
||||
man - manual pages & documentation
|
||||
doc - copy of Bind Operations Guide, and other documents
|
||||
include - include files to go in /usr/include
|
||||
named - name server sources
|
||||
res - source for C library resolver routines (and other libc additions)
|
||||
(may be used as separate library, resolv.a)
|
||||
conf/master - Sample data files
|
||||
tools - some test programs
|
||||
<URL:http://www.isc.org/bind.html> the BIND home page
|
||||
<URL:mailto:bind-bugs@isc.org> bug reports
|
||||
|
||||
|
||||
Here is how to install the name server on 4.3BSD:
|
||||
To Support the Effort
|
||||
|
||||
0) cp bin/mkdep.append /usr/ucb/mkdep
|
||||
cp bin/manroff /usr/man/manroff
|
||||
1) cp include/arpa/nameser.h /usr/include/arpa
|
||||
2) cp include/*.h /usr/include
|
||||
3) cp man/*.1 /usr/man/manl
|
||||
cp man/*.3 /usr/man/man3
|
||||
cp man/*.5 /usr/man/man5
|
||||
cp man/*.7 /usr/man/man7
|
||||
cp man/*.8 /usr/man/man8
|
||||
4) NOTE: Don't install the Makefiles on 4.3 Tahoe Release
|
||||
cp res/{res*.c,herror.c} /usr/src/lib/libc/net
|
||||
cp res/Makefile.libc.net /usr/src/lib/libc/net/Makefile
|
||||
cp res/strcasecmp.c /usr/src/lib/libc/gen
|
||||
cp res/strpbrk.c /usr/src/lib/libc/compat-sys5
|
||||
cp res/named/{*.c,Makefile} /usr/src/lib/libc/net/named
|
||||
5) add strcasecmp.[co] to the Makefile in /usr/src/lib/libc/gen
|
||||
6) add strpbrk.[co] to the Makefile in /usr/src/lib/libc/compat-sys5
|
||||
7) rebuild and install /lib/libc.a.
|
||||
8) edit named/pathnames.h to correpond with your system's configuration
|
||||
9) cd named; make depend; make all; make install
|
||||
10) cd tools/nslookup; make nslookup; make install
|
||||
11) create the master files (samples in conf/master/*)
|
||||
12) edit /etc/rc.local to include:
|
||||
Note that BIND is supported by the Internet Software Consortium, and
|
||||
although it is free for use and redistribution and incorporation into
|
||||
vendor products and export and anything else you can think of, it
|
||||
costs money to produce. That money comes from ISPs, hardware and
|
||||
software vendors, companies who make extensive use of the software,
|
||||
and generally kind hearted folk such as yourself.
|
||||
|
||||
if [ -f /etc/named ]; then
|
||||
/etc/named; echo -n ' named' >/dev/console
|
||||
fi
|
||||
|
||||
13) recompile network client and server programs that use gethostbyname, etc.
|
||||
|
||||
|
||||
Here is how to install the name server on 4.2BSD or similar systems.
|
||||
First, a few notes on the choices that must be made.
|
||||
|
||||
Rather than building libresolv.a, you may wish to integrate the resolver
|
||||
routines into /lib/libc.a. This is recommended to make it easy to recompile
|
||||
network programs once named is running. This procedure may require hand-
|
||||
tayloring on some systems.
|
||||
|
||||
You will have to choose a version of mkdep from the bin directory
|
||||
that will work on your system:
|
||||
If you've modified make(1) to use .depend files as described
|
||||
in the current sendmail distribution, use mkdep; otherwise,
|
||||
if you have the 4.3BSD cc -M option, use mkdep.append; on ultrix,
|
||||
use mkdep.ultrix (uses cc -Em); otherwise, use mkdep.old.compiler.
|
||||
The mkdep script is used by "make depend" to regenerate Makefile dependency
|
||||
lists.
|
||||
|
||||
You will need to chose a version of netdb.h. First, check /usr/include/netdb.h
|
||||
on your system. If the hostent structure has a h_addr_list entry, you can
|
||||
probably use your existing netdb.h or the one in include/netdb.h.
|
||||
If the existing netdb.h in /usr/include does not have a h_addr_list field,
|
||||
you will have to decide whether to update to the 4.3BSD format of the hostent
|
||||
structure. This is the best approach, but cannot be used unless you plan
|
||||
to upgrade entirely: if you use the new structure in /usr/include/resolv.h,
|
||||
you must recompile everything that uses the hostent structure, including
|
||||
the rest of the C library and all networking programs, without using
|
||||
any pre-existing object files. If this isn't possible or desirable,
|
||||
and /usr/include/netdb.h doesn't have an h_addr_list line, use
|
||||
include/netdb.h.4.2 instead of netdb.h. The other version of netdb.h
|
||||
(include/netdb.h.4.2.compat) may be used instead of include/netdb.h.4.2.
|
||||
This version along with a change in res/named/gethostnamadr.c.compat
|
||||
provide for using the new format of the hostent structure while having
|
||||
binary compatibility with existing libraries.
|
||||
|
||||
On systems with Sun RPC, you will have to merge include/netdb.h or
|
||||
include/netdb.h.4.2 with /usr/include/netdb.h; copy the rpc-related lines
|
||||
into the appropriate copy of netdb.h. Alternatively, use an alternate
|
||||
include path when compiling the resolver library and programs that use it.
|
||||
|
||||
0) cp bin/{whatever} /usr/ucb/mkdep (see above)
|
||||
cp bin/manroff /usr/man/manroff
|
||||
1) cp include/arpa/nameser.h /usr/include/arpa
|
||||
Also, on ultrix 2.x, if you haven't fixed
|
||||
the inet_addr definition in inet.h, do
|
||||
cp include/arpa/inet.h /usr/include/arpa
|
||||
2) cp include/resolv.h /usr/include
|
||||
3) cp include/netdb.h /usr/include/netdb.h
|
||||
OR
|
||||
cp include/netdb.h.4.2 /usr/include/netdb.h
|
||||
OR
|
||||
edit /usr/include/netdb.h
|
||||
4) cp man/*.1 /usr/man/manl
|
||||
cp man/*.3 /usr/man/man3
|
||||
cp man/*.5 /usr/man/man5
|
||||
cp man/*.7 /usr/man/man7
|
||||
cp man/*.8 /usr/man/man8
|
||||
5) cd res; make depend;
|
||||
make libresolv.a;
|
||||
make install
|
||||
OR
|
||||
update the libc sources as in the 4.3BSD instructions above
|
||||
and use res/Makefile as a guide for integration
|
||||
and omit the RES=-lresolv in the next two steps
|
||||
OR
|
||||
compile the .o files in res according to Makefile,
|
||||
then use place those object files in /lib/libc.a (keeping a backup!)
|
||||
and omit the RES=-lresolv in the next two steps
|
||||
6) edit named/pathnames.h to correpond with your system's configuration
|
||||
7) cd named; make depend; make RES=-lresolv all; make install
|
||||
(if your system defines signal-catching routines to return int
|
||||
instead of void, use "make DEFINES=-DSIG_FN=int RES=-lresolv all")
|
||||
8) edit tools/nslookup/pathnames.h to correpond with your system's
|
||||
configuration
|
||||
9) cd tools/nslookup; make RES=-lresolv nslookup install
|
||||
10) create the master files (samples in conf/master/*)
|
||||
11) edit /etc/rc.local to include:
|
||||
|
||||
if [ -f /etc/named ]; then
|
||||
/etc/named; echo -n ' named' >/dev/console
|
||||
fi
|
||||
|
||||
12) eventually, recompile network client and server programs that use
|
||||
gethostbyname, etc.
|
||||
The Internet Software Consortium has also commissioned a DHCP server
|
||||
implementation, has taken over official support/release of the INN
|
||||
system, and supports the Kerberos Version 5 effort at MIT. You can
|
||||
learn more about the ISC's goals and accomplishments from the web page
|
||||
at <URL:http://www.isc.org/>.
|
||||
|
|
|
|||
|
|
@ -1,187 +1,27 @@
|
|||
$Id: TODO,v 8.3 1995/06/19 08:34:22 vixie Exp $
|
||||
These are not in priority order.
|
||||
|
||||
Things to do. Each entry should contain the proposer, date proposed, and an
|
||||
explaination of what's being proposed. New ones are added at the bottom.
|
||||
Note that the author/coordinator of BIND does not neccessarily endorse all
|
||||
of the proposals listed herein; if you did not get explicit "buy-in" then
|
||||
your changes may not be accepted even if they appear in proposal form here
|
||||
in this file.
|
||||
-> "make" should work in any subdirectory as it does in the top level.
|
||||
|
||||
[Mark.Andrews@dms.CSIRO.AU 14dec94]: rfc952/rfc1123 host name compliance:
|
||||
-> Test domain names to ensure that the name conforms to the form
|
||||
specified by RFC952 as modified by RFC1123.
|
||||
-> WARN if the domain name does not meet the conditions set by
|
||||
rfc952/rfc1123 for the following resource records.
|
||||
class == C_IN && type == T_A
|
||||
class == C_IN && type == T_MX
|
||||
-> REJECT this records on the primary server.
|
||||
-> CNAME which doesn't match pointing to the above is also
|
||||
illegal but harder to check.
|
||||
-> "make distclean" should remove .depend files, "make clean" shouldn't.
|
||||
|
||||
[paul@vix.com 30nov94]: cause NOTIFY to track the IETF process for it;
|
||||
reorder ns_resp() again so that "Notify notimp" causes qdelete()
|
||||
but the host source address checking and so on is still done.
|
||||
-> NT port
|
||||
|
||||
[paul@vix.com 25apr93]: clean up #ifdef's and portability
|
||||
feature #ifdef's should be limited to whole functions, which will be
|
||||
called no matter what and would only be non-empty if the feature is
|
||||
enabled. allow feature ifdef's in .h files, though.
|
||||
-> DNS Security (RFC 2065)
|
||||
|
||||
portability #ifdef's should be limited to whole functions, too. add
|
||||
a new portability.c module that implements anything which varies from
|
||||
system to system.
|
||||
-> IXFR
|
||||
|
||||
add a second portability.h-like file that is included _before_ all the
|
||||
system includes. portability.h as it stands is included _after_ all
|
||||
system includes, which is convenient for most things but not all.
|
||||
-> Enhanced forwarding
|
||||
|
||||
[sater@cs.vu.nl 26apr93]: sortlist improvement
|
||||
Improve the code around the sortlist area to better cope with parallel
|
||||
networks of different speeds. The -i hack I sent to you could function
|
||||
as inspiration only.
|
||||
-> Command protocol
|
||||
|
||||
[kre@munnari.oz.au 26apr93]: add an INN style control interface
|
||||
to replace sending signals. With that expand debugging to
|
||||
permit monitoring of actions taken on a single query
|
||||
(query through control port, full traced as it occurs)
|
||||
or all queries that reference some particular name or
|
||||
zone, or which are forwarded, or asked, of some
|
||||
particluar server. Allow reloads & dumps of a single
|
||||
zone, rather than the whole universe. Allow selective
|
||||
cache pruning (to edit away bad data that's been obtained
|
||||
from somewhere)
|
||||
-> IPv6 transport
|
||||
|
||||
[kre@munnari.oz.au 26apr93]: add a syntax to zone files (non rfc
|
||||
standard, but I don't care) to permit RR's to age away
|
||||
at some particular time, and others to become active at
|
||||
some particular time (probably with a syntax something
|
||||
like "<[date]" or "@[date]" preceding, or in the
|
||||
former case, replacing, the TTL field of the record).
|
||||
Approaching "date" in the "<[date]" case, the TTL's on
|
||||
the record would be decreased, so no data cached anywhere
|
||||
will remain valid after "date", after "date", this RR
|
||||
would simply be inoperative (essentially identical to
|
||||
a comment). In the "@[date]" case (or perhaps ">[date]"
|
||||
for symmetry) the RR would be ignored until "date" at
|
||||
which time the "@[date]" field would simply be ignored.
|
||||
Both annotations could be used together (with
|
||||
appropriate interpretations depending on which date is
|
||||
earlier than the other). Annotations on RR's in a zone
|
||||
would cause the SOA parameters to be automatically
|
||||
adjusted in zone transfers (and SOA requests) so that
|
||||
secondary servers would also hand out the same values
|
||||
(dropping the TTL down low as a "<[date]" approaches,
|
||||
and forcing a new zone transfer at "date").
|
||||
-> named-xfer elimination
|
||||
|
||||
[steve@uunet.uu.net 26apr93]: TXT RR improvements
|
||||
- fix TXT records so that they can deal properly with multiple
|
||||
strings (e.g., ``foo IN TXT "aaa" "bbb"''). This
|
||||
results in a fair number of smallish changes throughout the
|
||||
code and also throughout various tools (e.g., nslookup).
|
||||
-> asynchronous resolver
|
||||
|
||||
[kyle@uunet.uu.net 16may93]: need an option to die if primary zone file missing
|
||||
as of 4.9, a server will not forward a query if it is itself on the
|
||||
NS list for the relevant domain. this means that if a primary server
|
||||
cannot load its zone file, it will not be able to answer queries in
|
||||
that zone -- it won't even forward them. this is arguably correct,
|
||||
since it prevents bad forwarding loops when two or more servers are
|
||||
all unable to load the zone (primary or secondary, with secondary
|
||||
failures being the more common). what is needed is real loop detection
|
||||
such that reasonable non-looping queries can be forwarded. what we're
|
||||
likely to actually get is an option that causes named to just syslog
|
||||
and die if it can't load a primary zone file. note that at present,
|
||||
named is running somewhat bare-assed since an expired zone in a
|
||||
secondary (or missing zone file in a primary) will cause that named
|
||||
to return SERVFAIL for all queries to that zone. if your screwed up
|
||||
primary/secondary server is also the forwarding server for a collection
|
||||
of hosts, those hosts will get SERVFAIL's back from queries to the
|
||||
affected domains, and depending on the age of their resolvers, they
|
||||
might not try other servers after they get the first SERVFAIL.
|
||||
[ this entry was written by Paul Vixie after getting a problem report
|
||||
from Kyle after uu.net disappeared in a brief but ugly way. --vix ]
|
||||
-> new database -- DB 2.0?
|
||||
|
||||
[paul@vix.com 05jun94]: things i'm expecting to fix someday:
|
||||
-> finish STATS (b+tree?), remove older A_RR-based tagging
|
||||
-> (more?) svr4 changes from wisner@well, marc@cam, istewart@datlog
|
||||
-> switch completely to posix-style signals
|
||||
-> xfrnets directives should aggregate
|
||||
-> syntactic sugar to use "mtime" of file as soa serial number
|
||||
-> better support for "firewalls" (zohar@ibm, minnich@dupont)
|
||||
-> attributes in TXT RR (cpw@lanl)
|
||||
-> fix database consistency problems during zone reloads (Bob Heiney)
|
||||
-> preliminary support for variable width subnet masks
|
||||
-> failover isn't working very well for hesiod queries (gshapiro)
|
||||
-> dig needs to be able to turn on RES_INSECURE{1,2} options
|
||||
-> clean out old RR's that lay within a newly loaded zone file (heiney)
|
||||
-> automatically refresh root.cache from the root servers periodically
|
||||
-> Makefiles should use/pass CFLAGS rather than modifying CC
|
||||
-> use Berkeley DB rather than malloc() for all database ops
|
||||
-> include files should be generated from templates
|
||||
-> use nvi-style port/* hierarchy, fewer portability #ifdef's
|
||||
-> make __res static, add procedural interface to replace "extern"'ing
|
||||
-> add hesiod/yp capable versions of get{pw,serv,???}by*()
|
||||
-> add hesiod/yp to get{net,host}by*()
|
||||
-> do something like solaris' /etc/nsswitch.conf (but in resolv.conf)
|
||||
-> we should only need one copy of binary->text, text->binary, and
|
||||
packet marshalling/unmarshalling. add general routines to -lresolv,
|
||||
and rearrange the code to use them.
|
||||
-> apps that want to do DNS queries should not have to learn res_query;
|
||||
a higher level interface should be provided, that has its own cache
|
||||
and/or shares with the server's DB-based one.
|
||||
-> implement or integrate the next round of RFC's (coming soon).
|
||||
-> move man pages from doc/man/* into src/.
|
||||
|
||||
[paul@vix.com 05jun95]: more things i'm expecting to fix someday:
|
||||
-> add "ndc checkconf" (i.e., "named -v")
|
||||
|
||||
## ++Copyright++ 1993
|
||||
## -
|
||||
## Copyright (c) 1993
|
||||
## The Regents of the University of California. All rights reserved.
|
||||
##
|
||||
## 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.
|
||||
## 3. All advertising materials mentioning features or use of this software
|
||||
## must display the following acknowledgement:
|
||||
## This product includes software developed by the University of
|
||||
## California, Berkeley and its contributors.
|
||||
## 4. Neither the name of the University nor the names of its contributors
|
||||
## may be used to endorse or promote products derived from this software
|
||||
## without specific prior written permission.
|
||||
##
|
||||
## THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
## -
|
||||
## Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
##
|
||||
## 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, and that
|
||||
## the name of Digital Equipment Corporation not be used in advertising or
|
||||
## publicity pertaining to distribution of the document or software without
|
||||
## specific, written prior permission.
|
||||
##
|
||||
## THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
## WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
## CORPORATION 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--
|
||||
-> fix dynamic DNS delegation loss problem
|
||||
|
|
|
|||
1
contrib/bind/Version
Normal file
1
contrib/bind/Version
Normal file
|
|
@ -0,0 +1 @@
|
|||
8.1.2-T3B
|
||||
90
contrib/bind/bin/Makefile
Normal file
90
contrib/bind/bin/Makefile
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
## Copyright (c) 1996 by Internet Software Consortium
|
||||
##
|
||||
## 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
# $Id: Makefile,v 8.17 1998/03/20 00:40:13 halley Exp $
|
||||
|
||||
DESTDIR=
|
||||
CC= cc
|
||||
SHELL= /bin/sh
|
||||
|
||||
CDEBUG= -g
|
||||
|
||||
#(net2 and its descendents)
|
||||
SYSTYPE = bsdos
|
||||
TOP = ..
|
||||
O=o
|
||||
A=a
|
||||
INCL = ${TOP}/include
|
||||
LIBBIND = ${TOP}/lib/libbind.${A}
|
||||
LIBPORT = ${TOP}/port/libport.${A}
|
||||
PORTINCL = ${TOP}/port/${SYSTYPE}/include
|
||||
LEX = lex -I
|
||||
YACC = yacc
|
||||
SYSLIBS = -ll -lutil
|
||||
PIDDIR = /var/run
|
||||
DESTBIN = /usr/local/bin
|
||||
DESTSBIN = /usr/local/sbin
|
||||
DESTEXEC = /usr/local/libexec
|
||||
DESTMAN = /usr/share/man
|
||||
DESTHELP= /usr/share/misc
|
||||
AR= ar cruv
|
||||
|
||||
LDFLAGS=
|
||||
|
||||
MARGS = "SYSTYPE=${SYSTYPE}" "SHELL=${SHELL}" "A=${A}" "O=${O}" \
|
||||
"CC=${CC}" "LEX=${LEX}" "YACC=${YACC}" "CDEBUG=${CDEBUG}" \
|
||||
"SYSLIBS=${SYSLIBS}" "LDFLAGS=${LDFLAGS}" \
|
||||
"DESTDIR=${DESTDIR}" "PIDDIR=${PIDDIR}" "DESTMAN=${DESTMAN}" \
|
||||
"DESTBIN=${DESTBIN}" "DESTSBIN=${DESTSBIN}" "DESTEXEC=${DESTEXEC}" \
|
||||
"DESTLIB=${DESTLIB}" "DESTINC=${DESTINC}" "DESTETC=${DESTETC}" \
|
||||
"DESTRUN=${DESTRUN}" "DESTHELP=${DESTHELP}" \
|
||||
"RANLIB=${RANLIB}" "AR=${AR}" "ARPREF=${ARPREF}" "ARSUFF=${ARSUFF}" \
|
||||
"INCL=../${INCL}" "PORTINCL=../${PORTINCL}" \
|
||||
"LIBBIND=../${LIBBIND}" "LIBPORT=../${LIBPORT}" \
|
||||
"INSTALL=${INSTALL}" "CPPFLAGS=${CPPFLAGS}" "TOP=../${TOP}" \
|
||||
"VER=${VER}" "STRIP=${STRIP}" "PS=${PS}"
|
||||
|
||||
CFLAGS= ${CDEBUG} -I${PORTINCL} -I${INCL}
|
||||
|
||||
SUBDIRS = addr nslookup dig dnsquery host named named-xfer ndc nsupdate
|
||||
|
||||
all: ${SUBDIRS}
|
||||
|
||||
${SUBDIRS}: FRC
|
||||
@(cd $@; pwd; ${MAKE} ${MARGS})
|
||||
|
||||
install depend tags clean distclean::
|
||||
@for x in ${SUBDIRS}; do \
|
||||
(cd $$x; pwd; ${MAKE} ${MARGS} $@); \
|
||||
done
|
||||
|
||||
distclean:: clean
|
||||
|
||||
clean::
|
||||
rm -f *.BAK *.CKP *~ *.orig
|
||||
|
||||
links: FRC
|
||||
@set -e; \
|
||||
for x in $(SUBDIRS); do \
|
||||
( mkdir $$x; cd $$x; pwd; ln -s ../SRC/$$x SRC; \
|
||||
cp SRC/Makefile Makefile; chmod +w Makefile; \
|
||||
$(MAKE) $(MARGS) links; \
|
||||
); \
|
||||
done
|
||||
|
||||
FRC:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- mkdep uses it.
|
||||
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
|
||||
79
contrib/bind/bin/addr/Makefile
Normal file
79
contrib/bind/bin/addr/Makefile
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
## Copyright (c) 1996 by Internet Software Consortium
|
||||
##
|
||||
## 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
# $Id: Makefile,v 8.19 1997/06/19 03:22:06 halley Exp $
|
||||
|
||||
DESTDIR=
|
||||
CC= cc
|
||||
SHELL= /bin/sh
|
||||
|
||||
CDEBUG= -g
|
||||
|
||||
#(net2 and its descendents)
|
||||
SYSTYPE = bsdos
|
||||
TOP = ../..
|
||||
INCL = ${TOP}/include
|
||||
PORTINCL = ${TOP}/port/${SYSTYPE}/include
|
||||
LIBBIND = ${TOP}/lib/libbind.a
|
||||
A=a
|
||||
O=o
|
||||
LEX = lex -I
|
||||
SYSLIBS = -ll -lutil
|
||||
PIDDIR = /var/run
|
||||
DESTBIN = /usr/local/bin
|
||||
DESTSBIN = /usr/local/sbin
|
||||
DESTEXEC = /usr/local/libexec
|
||||
DESTMAN = /usr/share/man
|
||||
DESTHELP= /usr/share/misc
|
||||
STRIP=-s
|
||||
|
||||
LDFLAGS=
|
||||
CFLAGS= ${CDEBUG} -I${PORTINCL} -I${INCL}
|
||||
|
||||
PROG= addr
|
||||
SRCS= ${PROG}.c
|
||||
OBJS= ${PROG}.${O}
|
||||
|
||||
all: ${PROG}
|
||||
|
||||
${PROG}: ${OBJS} ${LIBBIND} Makefile
|
||||
${CC} ${CDEBUG} ${LDFLAGS} -o ${PROG} ${OBJS} \
|
||||
${LIBBIND} ${SYSLIBS}
|
||||
|
||||
distclean: clean
|
||||
|
||||
clean: FRC
|
||||
rm -f ${PROG} ${OBJS} core .depend
|
||||
rm -f *.BAK *.CKP *~ *.orig
|
||||
|
||||
depend: ${SRCS}
|
||||
mkdep -p ${CPPFLAGS} -I${INCL} -I${PORTINCL} ${SRCS}
|
||||
|
||||
${DESTDIR}${DESTBIN}:
|
||||
mkdir -p ${DESTDIR}${DESTBIN}
|
||||
|
||||
install: ${DESTDIR}${DESTBIN} ${PROG}
|
||||
${INSTALL} ${STRIP} -c -m 755 ${PROG} ${DESTDIR}${DESTBIN}/${PROG}
|
||||
|
||||
links: FRC
|
||||
@set -e; ln -s SRC/*.[ch] .
|
||||
|
||||
tags: FRC
|
||||
ctags *.[ch]
|
||||
|
||||
FRC:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- mkdep uses it.
|
||||
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
|
||||
172
contrib/bind/bin/addr/addr.c
Normal file
172
contrib/bind/bin/addr/addr.c
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
#if !defined(lint) && !defined(SABER)
|
||||
static char rcsid[] = "$Id: addr.c,v 8.5 1997/04/25 00:00:29 vixie Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "port_after.h"
|
||||
|
||||
static const char *prog = "addr";
|
||||
|
||||
#define BIGGEST_ADDRESS IN6ADDRSZ
|
||||
|
||||
static void
|
||||
usage() {
|
||||
fprintf(stderr,
|
||||
"usage: %s [-4] [-6] [-n hexstring] [-p address]\n",
|
||||
prog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Warning: this scribbles on `dst' even if it's going to return `0'. */
|
||||
static int
|
||||
hexstring(src, dst, len)
|
||||
const char *src;
|
||||
u_char *dst;
|
||||
int len;
|
||||
{
|
||||
static const char xdigits[] = "0123456789abcdef";
|
||||
u_char *ptr = dst, *end = dst + len;
|
||||
u_int val;
|
||||
int ch, digits;
|
||||
|
||||
val = 0;
|
||||
digits = 0;
|
||||
memset(dst, 0, len);
|
||||
while ((ch = *src++) != '\0') {
|
||||
if (ch == '0' && (*src == 'x' || *src == 'X')) {
|
||||
src++;
|
||||
continue;
|
||||
}
|
||||
if (isascii(ch) && (isspace(ch) || ispunct(ch))) {
|
||||
if (digits > 0) {
|
||||
if (ptr == end)
|
||||
return (0);
|
||||
*ptr++ = (u_char) (val & 0xff);
|
||||
val = 0;
|
||||
digits = 0;
|
||||
}
|
||||
digits = 0;
|
||||
continue;
|
||||
}
|
||||
if (!isascii(ch) || !isxdigit(ch))
|
||||
return (0);
|
||||
if (isupper(ch))
|
||||
ch = tolower(ch);
|
||||
/* Clock it in using little endian arithmetic. */
|
||||
val <<= 4;
|
||||
val |= (strchr(xdigits, ch) - xdigits);
|
||||
if (++digits == 2) {
|
||||
if (ptr == end)
|
||||
return (0);
|
||||
*ptr++ = (u_char) (val & 0xff);
|
||||
digits = 0;
|
||||
val = 0;
|
||||
}
|
||||
}
|
||||
if (digits > 0) {
|
||||
if (ptr == end)
|
||||
return (0);
|
||||
*ptr++ = (u_char) (val & 0xff);
|
||||
}
|
||||
return ((ptr - dst) == len);
|
||||
}
|
||||
|
||||
static void
|
||||
display(input, af, addr, len)
|
||||
const char *input;
|
||||
int af;
|
||||
const u_char *addr;
|
||||
int len;
|
||||
{
|
||||
static int before = 0;
|
||||
char p[sizeof "xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255"];
|
||||
int i;
|
||||
|
||||
if (before)
|
||||
putchar('\n');
|
||||
else
|
||||
before++;
|
||||
|
||||
printf("Input: \"%s\"\n", input);
|
||||
printf("Network: [af%d len%d]", af, len);
|
||||
for (i = 0; i < len; i++)
|
||||
printf(" %02x", addr[i]);
|
||||
putchar('\n');
|
||||
printf("Presentation: \"%s\"\n", inet_ntop(af, addr, p, sizeof p));
|
||||
}
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
u_char addr[BIGGEST_ADDRESS];
|
||||
int optchr, af, len;
|
||||
|
||||
prog = argv[0];
|
||||
af = AF_INET;
|
||||
len = INADDRSZ;
|
||||
while ((optchr = getopt(argc, argv, "46n:p:")) != -1) {
|
||||
switch (optchr) {
|
||||
case '4':
|
||||
af = AF_INET;
|
||||
len = INADDRSZ;
|
||||
break;
|
||||
case '6':
|
||||
af = AF_INET6;
|
||||
len = IN6ADDRSZ;
|
||||
break;
|
||||
case 'n':
|
||||
if (!hexstring(optarg, addr, len)) {
|
||||
fprintf(stderr, "bad hex string: \"%s\"\n",
|
||||
optarg);
|
||||
usage();
|
||||
/* NOTREACHED */
|
||||
}
|
||||
display(optarg, af, addr, len);
|
||||
break;
|
||||
case 'p':
|
||||
if (inet_pton(af, optarg, addr) <= 0) {
|
||||
fprintf(stderr, "bad address: \"%s\"\n",
|
||||
optarg);
|
||||
usage();
|
||||
/* NOTREACHED */
|
||||
}
|
||||
display(optarg, af, addr, len);
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
/* NOTREACHED */
|
||||
}
|
||||
}
|
||||
exit(0);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
83
contrib/bind/bin/dig/Makefile
Normal file
83
contrib/bind/bin/dig/Makefile
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
## Copyright (c) 1996 by Internet Software Consortium
|
||||
##
|
||||
## 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
# $Id: Makefile,v 8.19 1997/06/19 03:22:07 halley Exp $
|
||||
|
||||
DESTDIR=
|
||||
CC= cc
|
||||
SHELL= /bin/sh
|
||||
|
||||
CDEBUG= -g
|
||||
|
||||
#(net2 and its descendents)
|
||||
SYSTYPE = bsdos
|
||||
TOP = ../..
|
||||
INCL = ${TOP}/include
|
||||
PORTINCL = ${TOP}/port/${SYSTYPE}/include
|
||||
LIBBIND = ${TOP}/lib/libbind.a
|
||||
A=a
|
||||
O=o
|
||||
LEX = lex -I
|
||||
SYSLIBS = -ll -lutil
|
||||
PIDDIR = /var/run
|
||||
DESTBIN = /usr/local/bin
|
||||
DESTSBIN = /usr/local/sbin
|
||||
DESTEXEC = /usr/local/libexec
|
||||
DESTMAN = /usr/share/man
|
||||
DESTHELP= /usr/share/misc
|
||||
STRIP=-s
|
||||
|
||||
LDFLAGS=
|
||||
CFLAGS= ${CDEBUG} -I${PORTINCL} -I${INCL}
|
||||
|
||||
NSLOOKUP_OBJS= \
|
||||
../nslookup/subr.${O} ../nslookup/send.${O} \
|
||||
../nslookup/list.${O} ../nslookup/debug.${O}
|
||||
|
||||
PROG= dig
|
||||
SRCS= ${PROG}.c
|
||||
OBJS= ${PROG}.${O}
|
||||
|
||||
all: ${PROG}
|
||||
|
||||
${PROG}: ${OBJS} ${NSLOOKUP_OBJS} ${LIBBIND} Makefile
|
||||
${CC} ${CDEBUG} ${LDFLAGS} -o ${PROG} ${OBJS} ${NSLOOKUP_OBJS} \
|
||||
${LIBBIND} ${SYSLIBS}
|
||||
|
||||
distclean: clean
|
||||
|
||||
clean: FRC
|
||||
rm -f ${PROG} ${OBJS} core .depend
|
||||
rm -f *.BAK *.CKP *~ *.orig
|
||||
|
||||
depend: ${SRCS}
|
||||
mkdep -p ${CPPFLAGS} -I${INCL} -I${PORTINCL} ${SRCS}
|
||||
|
||||
${DESTDIR}${DESTBIN}:
|
||||
mkdir -p ${DESTDIR}${DESTBIN}
|
||||
|
||||
install: ${DESTDIR}${DESTBIN} ${PROG}
|
||||
${INSTALL} ${STRIP} -c -m 755 ${PROG} ${DESTDIR}${DESTBIN}/${PROG}
|
||||
|
||||
links: FRC
|
||||
@set -e; ln -s SRC/*.[ch] .
|
||||
|
||||
tags: FRC
|
||||
ctags *.[ch]
|
||||
|
||||
FRC:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- mkdep uses it.
|
||||
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
|
||||
1243
contrib/bind/bin/dig/dig.c
Normal file
1243
contrib/bind/bin/dig/dig.c
Normal file
File diff suppressed because it is too large
Load diff
79
contrib/bind/bin/dnsquery/Makefile
Normal file
79
contrib/bind/bin/dnsquery/Makefile
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
## Copyright (c) 1996 by Internet Software Consortium
|
||||
##
|
||||
## 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
# $Id: Makefile,v 8.18 1997/06/19 03:22:08 halley Exp $
|
||||
|
||||
DESTDIR=
|
||||
CC= cc
|
||||
SHELL= /bin/sh
|
||||
|
||||
CDEBUG= -g
|
||||
|
||||
#(net2 and its descendents)
|
||||
SYSTYPE = bsdos
|
||||
TOP = ../..
|
||||
INCL = ${TOP}/include
|
||||
PORTINCL = ${TOP}/port/${SYSTYPE}/include
|
||||
LIBBIND = ${TOP}/lib/libbind.a
|
||||
A=a
|
||||
O=o
|
||||
LEX = lex -I
|
||||
SYSLIBS = -ll -lutil
|
||||
PIDDIR = /var/run
|
||||
DESTBIN = /usr/local/bin
|
||||
DESTSBIN = /usr/local/sbin
|
||||
DESTEXEC = /usr/local/libexec
|
||||
DESTMAN = /usr/share/man
|
||||
DESTHELP= /usr/share/misc
|
||||
STRIP=-s
|
||||
|
||||
LDFLAGS=
|
||||
CFLAGS= ${CDEBUG} -I${PORTINCL} -I${INCL}
|
||||
|
||||
PROG= dnsquery
|
||||
SRCS= ${PROG}.c
|
||||
OBJS= ${PROG}.${O}
|
||||
|
||||
all: ${PROG}
|
||||
|
||||
${PROG}: ${OBJS} ${LIBBIND} Makefile
|
||||
${CC} ${CDEBUG} ${LDFLAGS} -o ${PROG} ${OBJS} \
|
||||
${LIBBIND} ${SYSLIBS}
|
||||
|
||||
distclean: clean
|
||||
|
||||
clean: FRC
|
||||
rm -f ${PROG} ${OBJS} core .depend
|
||||
rm -f *.BAK *.CKP *~ *.orig
|
||||
|
||||
depend: ${SRCS}
|
||||
mkdep -p ${CPPFLAGS} -I${INCL} -I${PORTINCL} ${SRCS}
|
||||
|
||||
${DESTDIR}${DESTBIN}:
|
||||
mkdir -p ${DESTDIR}${DESTBIN}
|
||||
|
||||
install: ${DESTDIR}${DESTBIN} ${PROG}
|
||||
${INSTALL} ${STRIP} -c -m 755 ${PROG} ${DESTDIR}${DESTBIN}/${PROG}
|
||||
|
||||
links: FRC
|
||||
@set -e; ln -s SRC/*.[ch] .
|
||||
|
||||
tags: FRC
|
||||
ctags *.[ch]
|
||||
|
||||
FRC:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- mkdep uses it.
|
||||
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
|
||||
206
contrib/bind/bin/dnsquery/dnsquery.c
Normal file
206
contrib/bind/bin/dnsquery/dnsquery.c
Normal file
|
|
@ -0,0 +1,206 @@
|
|||
#if !defined(lint) && !defined(SABER)
|
||||
static char rcsid[] = "$Id: dnsquery.c,v 8.7 1997/05/21 19:51:22 halley Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
extern int errno;
|
||||
extern int h_errno;
|
||||
extern char *h_errlist[];
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
char name[MAXDNAME];
|
||||
u_char answer[8*1024];
|
||||
int c, n, i = 0;
|
||||
u_int32_t ul;
|
||||
int nameservers = 0, class, type, len;
|
||||
struct in_addr q_nsaddr[MAXNS];
|
||||
struct hostent *q_nsname;
|
||||
extern int optind, opterr;
|
||||
extern char *optarg;
|
||||
HEADER *hp;
|
||||
int stream = 0, debug = 0;
|
||||
|
||||
/* set defaults */
|
||||
len = MAXDNAME;
|
||||
gethostname(name, len);
|
||||
class = C_IN;
|
||||
type = T_ANY;
|
||||
|
||||
/* if no args, exit */
|
||||
if (argc == 1) {
|
||||
fprintf(stderr, "Usage: %s [-h] host [-n ns] [-t type] [-c class] [-r retry] [-p period] [-s] [-v] [-d] [-a]\n", argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/* handle args */
|
||||
while ((c = getopt(argc, argv, "c:dh:n:p:r:st:u:v")) != EOF) {
|
||||
switch (c) {
|
||||
|
||||
case 'r' : _res.retry = atoi(optarg);
|
||||
break;
|
||||
|
||||
case 'p' : _res.retrans = atoi(optarg);
|
||||
break;
|
||||
|
||||
case 'h' : strcpy(name, optarg);
|
||||
break;
|
||||
|
||||
case 'c' : {
|
||||
int success, proto_class;
|
||||
|
||||
proto_class = sym_ston(__p_class_syms,
|
||||
optarg, &success);
|
||||
if (success)
|
||||
class = proto_class;
|
||||
else {
|
||||
fprintf(stderr, "Bad class (%s)\n", optarg);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 't' : {
|
||||
int success, proto_type;
|
||||
|
||||
proto_type = sym_ston(__p_type_syms,
|
||||
optarg, &success);
|
||||
if (success)
|
||||
type = proto_type;
|
||||
else {
|
||||
fprintf(stderr, "Bad type (%s)\n", optarg);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'd' : debug++;
|
||||
break;
|
||||
|
||||
case 's' :
|
||||
case 'v' : stream++;
|
||||
break;
|
||||
|
||||
case 'n' :
|
||||
/*
|
||||
* If we set some nameservers here without
|
||||
* using gethostbyname() first, then they will
|
||||
* get overwritten when we do the first query.
|
||||
* So, we must init the resolver before any
|
||||
* of this.
|
||||
*/
|
||||
if (!(_res.options & RES_INIT))
|
||||
if (res_init() == -1) {
|
||||
fprintf(stderr,
|
||||
"res_init() failed\n");
|
||||
exit(-1);
|
||||
}
|
||||
if (nameservers >= MAXNS) break;
|
||||
(void) inet_aton(optarg,
|
||||
&q_nsaddr[nameservers]);
|
||||
if (!inet_aton(optarg, (struct in_addr *)&ul)){
|
||||
q_nsname = gethostbyname(optarg);
|
||||
if (q_nsname == 0) {
|
||||
fprintf(stderr,
|
||||
"Bad nameserver (%s)\n",
|
||||
optarg);
|
||||
exit(-1);
|
||||
}
|
||||
memcpy(&q_nsaddr[nameservers],
|
||||
q_nsname->h_addr, INADDRSZ);
|
||||
}
|
||||
else
|
||||
q_nsaddr[nameservers].s_addr = ul;
|
||||
nameservers++;
|
||||
break;
|
||||
|
||||
default : fprintf(stderr,
|
||||
"\tUsage: %s [-n ns] [-h host] [-t type] [-c class] [-r retry] [-p period] [-s] [-v] [-d] [-a]\n", argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
if (optind < argc)
|
||||
strcpy(name, argv[optind]);
|
||||
|
||||
len = sizeof(answer);
|
||||
|
||||
/*
|
||||
* set these here so they aren't set for a possible call to
|
||||
* gethostbyname above
|
||||
*/
|
||||
if (debug || stream) {
|
||||
if (!(_res.options & RES_INIT))
|
||||
if (res_init() == -1) {
|
||||
fprintf(stderr, "res_init() failed\n");
|
||||
exit(-1);
|
||||
}
|
||||
if (debug)
|
||||
_res.options |= RES_DEBUG;
|
||||
if (stream)
|
||||
_res.options |= RES_USEVC;
|
||||
}
|
||||
|
||||
/* if the -n flag was used, add them to the resolver's list */
|
||||
if (nameservers != 0) {
|
||||
_res.nscount = nameservers;
|
||||
for (i = nameservers - 1; i >= 0; i--) {
|
||||
_res.nsaddr_list[i].sin_addr.s_addr = q_nsaddr[i].s_addr;
|
||||
_res.nsaddr_list[i].sin_family = AF_INET;
|
||||
_res.nsaddr_list[i].sin_port = htons(NAMESERVER_PORT);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* if the -h arg is fully-qualified, use res_query() since
|
||||
* using res_search() will lead to use of res_querydomain()
|
||||
* which will strip the trailing dot
|
||||
*/
|
||||
if (name[strlen(name) - 1] == '.') {
|
||||
n = res_query(name, class, type, answer, len);
|
||||
if (n < 0) {
|
||||
fprintf(stderr, "Query failed (h_errno = %d) : %s\n",
|
||||
h_errno, h_errlist[h_errno]);
|
||||
exit(-1);
|
||||
}
|
||||
} else if ((n = res_search(name, class, type, answer, len)) < 0) {
|
||||
fprintf(stderr, "Query failed (h_errno = %d) : %s\n",
|
||||
h_errno, h_errlist[h_errno]);
|
||||
exit(-1);
|
||||
}
|
||||
fp_nquery(answer, n, stdout);
|
||||
exit(0);
|
||||
}
|
||||
79
contrib/bind/bin/host/Makefile
Normal file
79
contrib/bind/bin/host/Makefile
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
## Copyright (c) 1996 by Internet Software Consortium
|
||||
##
|
||||
## 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
# $Id: Makefile,v 8.18 1997/06/19 03:22:08 halley Exp $
|
||||
|
||||
DESTDIR=
|
||||
CC= cc
|
||||
SHELL= /bin/sh
|
||||
|
||||
CDEBUG= -g
|
||||
|
||||
#(net2 and its descendents)
|
||||
SYSTYPE = bsdos
|
||||
TOP = ../..
|
||||
INCL = ${TOP}/include
|
||||
PORTINCL = ${TOP}/port/${SYSTYPE}/include
|
||||
LIBBIND = ${TOP}/lib/libbind.a
|
||||
A=a
|
||||
O=o
|
||||
LEX = lex -I
|
||||
SYSLIBS = -ll -lutil
|
||||
PIDDIR = /var/run
|
||||
DESTBIN = /usr/local/bin
|
||||
DESTSBIN = /usr/local/sbin
|
||||
DESTEXEC = /usr/local/libexec
|
||||
DESTMAN = /usr/share/man
|
||||
DESTHELP= /usr/share/misc
|
||||
STRIP=-s
|
||||
|
||||
LDFLAGS=
|
||||
CFLAGS= ${CDEBUG} -I${PORTINCL} -I${INCL}
|
||||
|
||||
PROG= host
|
||||
SRCS= ${PROG}.c
|
||||
OBJS= ${PROG}.${O}
|
||||
|
||||
all: ${PROG}
|
||||
|
||||
${PROG}: ${OBJS} ${LIBBIND} Makefile
|
||||
${CC} ${CDEBUG} ${LDFLAGS} -o ${PROG} ${OBJS} \
|
||||
${LIBBIND} ${SYSLIBS}
|
||||
|
||||
distclean: clean
|
||||
|
||||
clean: FRC
|
||||
rm -f ${PROG} ${OBJS} core .depend
|
||||
rm -f *.BAK *.CKP *~ *.orig
|
||||
|
||||
depend: ${SRCS}
|
||||
mkdep -p ${CPPFLAGS} -I${INCL} -I${PORTINCL} ${SRCS}
|
||||
|
||||
${DESTDIR}${DESTBIN}:
|
||||
mkdir -p ${DESTDIR}${DESTBIN}
|
||||
|
||||
install: ${DESTDIR}${DESTBIN} ${PROG}
|
||||
${INSTALL} ${STRIP} -c -m 755 ${PROG} ${DESTDIR}${DESTBIN}/${PROG}
|
||||
|
||||
links: FRC
|
||||
@set -e; ln -s SRC/*.[ch] .
|
||||
|
||||
tags: FRC
|
||||
ctags *.[ch]
|
||||
|
||||
FRC:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- mkdep uses it.
|
||||
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
|
||||
1411
contrib/bind/bin/host/host.c
Normal file
1411
contrib/bind/bin/host/host.c
Normal file
File diff suppressed because it is too large
Load diff
88
contrib/bind/bin/named-xfer/Makefile
Normal file
88
contrib/bind/bin/named-xfer/Makefile
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
## Copyright (c) 1996 by Internet Software Consortium
|
||||
##
|
||||
## 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
# $Id: Makefile,v 8.20 1997/06/19 03:22:09 halley Exp $
|
||||
|
||||
DESTDIR=
|
||||
CC= cc
|
||||
SHELL= /bin/sh
|
||||
|
||||
CDEBUG= -g
|
||||
|
||||
#(net2 and its descendents)
|
||||
SYSTYPE = bsdos
|
||||
TOP = ../..
|
||||
INCL = ${TOP}/include
|
||||
PORTINCL = ${TOP}/port/${SYSTYPE}/include
|
||||
LIBBIND = ${TOP}/lib/libbind.a
|
||||
A=a
|
||||
O=o
|
||||
LEX = lex -I
|
||||
SYSLIBS = -ll -lutil
|
||||
PIDDIR = /var/run
|
||||
DESTBIN = /usr/local/bin
|
||||
DESTSBIN = /usr/local/sbin
|
||||
DESTEXEC = /usr/local/libexec
|
||||
DESTMAN = /usr/share/man
|
||||
DESTHELP= /usr/share/misc
|
||||
AR= ar cruv
|
||||
INSTALL= install
|
||||
STRIP=-s
|
||||
|
||||
PS=ps
|
||||
LDFLAGS=
|
||||
CFLAGS= ${CDEBUG} -I${PORTINCL} -I${INCL}
|
||||
|
||||
NAMED_OBJS= \
|
||||
../named/db_glue.${O} ../named/ns_glue.${O} ../named/tmp_version.${O}
|
||||
|
||||
PROG= named-xfer
|
||||
SRCS= ${PROG}.c
|
||||
OBJS= ${PROG}.${O}
|
||||
|
||||
all: ${PROG}
|
||||
|
||||
${PROG}: ${OBJS} ${NAMED_OBJS} ${LIBBIND} Makefile
|
||||
${CC} ${CDEBUG} ${LDFLAGS} -o ${PROG} ${OBJS} ${NAMED_OBJS} \
|
||||
${LIBBIND} ${SYSLIBS}
|
||||
|
||||
distclean: clean
|
||||
|
||||
clean: FRC
|
||||
rm -f ${PROG} core .depend
|
||||
rm -f *.BAK *.CKP *~ *.${O} *.orig
|
||||
|
||||
depend: ${SRCS}
|
||||
mkdep -p ${CPPFLAGS} -I${INCL} -I${PORTINCL} ${SRCS}
|
||||
|
||||
${DESTDIR}${DESTEXEC}:
|
||||
mkdir -p ${DESTDIR}${DESTEXEC}
|
||||
|
||||
install: ${DESTDIR}${DESTSBIN} ${PROG}
|
||||
${INSTALL} ${STRIP} -c -m 755 ${PROG} ${DESTDIR}${DESTEXEC}/${PROG}
|
||||
|
||||
links: FRC
|
||||
@set -e; ln -s SRC/*.[ch] .
|
||||
|
||||
tags: FRC
|
||||
ctags ${SRCS} *.h
|
||||
|
||||
commands.c: commands.l
|
||||
${LEX} -t $< > $@ || rm $@
|
||||
|
||||
FRC:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- mkdep uses it.
|
||||
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
|
||||
2177
contrib/bind/bin/named-xfer/named-xfer.c
Normal file
2177
contrib/bind/bin/named-xfer/named-xfer.c
Normal file
File diff suppressed because it is too large
Load diff
126
contrib/bind/bin/named/Makefile
Normal file
126
contrib/bind/bin/named/Makefile
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
## Copyright (c) 1996, 1997 by Internet Software Consortium
|
||||
##
|
||||
## 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
# $Id: Makefile,v 8.31 1998/03/20 00:49:46 halley Exp $
|
||||
|
||||
DESTDIR=
|
||||
CC= cc
|
||||
SHELL= /bin/sh
|
||||
|
||||
CDEBUG= -g
|
||||
|
||||
#(net2 and its descendents)
|
||||
SYSTYPE = bsdos
|
||||
TOP = ../..
|
||||
INCL = ${TOP}/include
|
||||
PORTINCL = ${TOP}/port/${SYSTYPE}/include
|
||||
LIBBIND = ${TOP}/lib/libbind.a
|
||||
A=a
|
||||
O=o
|
||||
LEX = lex -I
|
||||
YACC = yacc -d
|
||||
SYSLIBS = -ll -lutil
|
||||
PIDDIR = /var/run
|
||||
DESTBIN = /usr/local/bin
|
||||
DESTSBIN = /usr/local/sbin
|
||||
DESTEXEC = /usr/local/libexec
|
||||
DESTMAN = /usr/share/man
|
||||
DESTHELP= /usr/share/misc
|
||||
AR= ar cruv
|
||||
INSTALL= install
|
||||
STRIP=-s
|
||||
|
||||
PS=ps
|
||||
LDFLAGS=
|
||||
CFLAGS= ${CDEBUG} -I${PORTINCL} -I${INCL} ${DEFS}
|
||||
|
||||
VER= LOCAL-`date +%y%m%d.%H%M%S`
|
||||
HOSTNAMECMD= hostname || uname -n
|
||||
|
||||
PROG= named
|
||||
HDRS= db_defs.h db_glob.h ns_defs.h ns_glob.h named.h pathnames.h
|
||||
SRCS= db_dump.c db_load.c db_lookup.c db_save.c db_update.c \
|
||||
db_glue.c \
|
||||
ns_parser.c ns_lexer.c ns_parseutil.c \
|
||||
ns_forw.c ns_init.c ns_main.c ns_maint.c ns_req.c \
|
||||
ns_resp.c ns_stats.c ns_ncache.c ns_xfr.c ns_glue.c \
|
||||
ns_udp.c ns_config.c ns_update.c
|
||||
OBJS= db_dump.${O} db_load.${O} db_lookup.${O} db_save.${O} db_update.${O} \
|
||||
db_glue.${O} \
|
||||
ns_parser.${O} ns_lexer.${O} ns_parseutil.${O} \
|
||||
ns_forw.${O} ns_init.${O} ns_main.${O} ns_maint.${O} ns_req.${O} \
|
||||
ns_resp.${O} ns_stats.${O} ns_ncache.${O} ns_xfr.${O} ns_glue.${O} \
|
||||
ns_udp.${O} ns_config.${O} ns_update.${O}
|
||||
|
||||
all: ${PROG} pathnames
|
||||
|
||||
${PROG}: pathnames.h ${OBJS} ${LIBBIND} Makefile tmp_version.${O}
|
||||
${CC} ${CDEBUG} ${LDFLAGS} -o ${PROG} ${OBJS} tmp_version.${O} \
|
||||
${LIBBIND} ${SYSLIBS}
|
||||
|
||||
ns_parser.c ns_parser.h: ns_parser.y
|
||||
${YACC} ns_parser.y
|
||||
mv y.tab.c ns_parser.c
|
||||
mv y.tab.h ns_parser.h
|
||||
|
||||
tmp_version.${O}: tmp_version.c
|
||||
|
||||
tmp_version.c: version.c Makefile ../Makefile ${SRCS} ${HDRS}
|
||||
(u=$${USER-root} d=`pwd` h=`${HOSTNAMECMD}` t=`date`; \
|
||||
sed -e "s|%WHEN%|$${t}|" -e "s|%VERSION%|"${VER}"|" \
|
||||
-e "s|%WHOANDWHERE%|$${u}@$${h}:$${d}|" \
|
||||
< version.c > tmp_version.c)
|
||||
|
||||
pathnames.h: ${TOP}/.settings Makefile
|
||||
rm -f pathnames.h
|
||||
sed -e "s|%DESTSBIN%|${DESTSBIN}|" \
|
||||
-e "s|%DESTEXEC%|${DESTEXEC}|" \
|
||||
-e "s|%DESTETC%|${DESTETC}|" \
|
||||
-e "s|%DESTRUN%|${DESTRUN}|" \
|
||||
< pathtemplate.h > pathnames.h
|
||||
|
||||
pathnames: pathnames.${O} pathnames.h ${LIBBIND} Makefile
|
||||
${CC} ${CDEBUG} ${LDFLAGS} -o $@ pathnames.${O} \
|
||||
${LIBBIND} ${SYSLIBS}
|
||||
|
||||
distclean: clean
|
||||
rm -f ns_parser.c ns_parser.h
|
||||
|
||||
clean: FRC
|
||||
rm -f ${PROG} ${OBJS} core .depend
|
||||
rm -f *.BAK *.CKP *~ *.orig
|
||||
rm -f tmp_version.c tmp_version.${O}
|
||||
rm -f pathnames pathnames.${O} tmp_pathnames.h pathnames.h
|
||||
rm -f y.tab.h y.tab.c
|
||||
|
||||
depend: ${SRCS} pathnames.h
|
||||
mkdep ${CPPFLAGS} -I${INCL} -I${PORTINCL} ${DEFS} ${SRCS}
|
||||
|
||||
${DESTDIR}${DESTSBIN}:
|
||||
mkdir -p ${DESTDIR}${DESTSBIN}
|
||||
|
||||
install: ${DESTDIR}${DESTSBIN} ${PROG}
|
||||
${INSTALL} ${STRIP} -c -m 755 ${PROG} ${DESTDIR}${DESTSBIN}/${PROG}
|
||||
|
||||
links: FRC
|
||||
@ln -s SRC/*.[chy] SRC/test .; rm -f ns_parser.[ch]
|
||||
|
||||
tags: FRC
|
||||
ctags ${SRCS} *.h
|
||||
|
||||
FRC:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- mkdep uses it.
|
||||
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
|
||||
233
contrib/bind/bin/named/db_defs.h
Normal file
233
contrib/bind/bin/named/db_defs.h
Normal file
|
|
@ -0,0 +1,233 @@
|
|||
/*
|
||||
* from db.h 4.16 (Berkeley) 6/1/90
|
||||
* $Id: db_defs.h,v 8.17 1998/02/17 17:17:43 vixie Exp $
|
||||
*/
|
||||
|
||||
/* Copyright (c) 1985, 1990
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* 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, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION 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.
|
||||
*/
|
||||
|
||||
/* Portions Copyright (c) 1996, 1997 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Global definitions for data base routines.
|
||||
*/
|
||||
|
||||
#define INVBLKSZ 7 /* # of namebuf pointers per block */
|
||||
#define INVHASHSZ 919 /* size of inverse hash table */
|
||||
|
||||
/* max length of data in RR data field */
|
||||
#define MAXDATA (2*MAXDNAME + 5*INT32SZ)
|
||||
|
||||
#define DB_ROOT_TIMBUF 3600
|
||||
#define TIMBUF 300
|
||||
|
||||
#define DICT_INDEXBITS 24
|
||||
#define DICT_MAXLENGTH 127
|
||||
#define DICT_INSERT_P 0x0001
|
||||
|
||||
/*
|
||||
* Hash table structures.
|
||||
*/
|
||||
struct databuf {
|
||||
struct databuf *d_next; /* linked list */
|
||||
struct nameser *d_ns; /* NS from whence this came */
|
||||
u_int32_t d_ttl; /* time to live */
|
||||
/* if d_zone == DB_Z_CACHE, then
|
||||
* d_ttl is actually the time when
|
||||
* the record will expire.
|
||||
* otherwise (for authoritative
|
||||
* primary and secondary zones),
|
||||
* d_ttl is the time to live.
|
||||
*/
|
||||
unsigned d_flags :7; /* see below */
|
||||
unsigned d_cred :3; /* DB_C_{??????} */
|
||||
unsigned d_clev :6;
|
||||
u_int16_t d_zone; /* zone number or 0 for the cache */
|
||||
int16_t d_class; /* class number */
|
||||
int16_t d_type; /* type number */
|
||||
int16_t d_size; /* size of data area */
|
||||
u_int32_t d_rcnt;
|
||||
unsigned d_rcode :4; /* rcode for negative caching */
|
||||
unsigned d_mark :12; /* place to mark data */
|
||||
u_int16_t d_nstime; /* NS response time, milliseconds */
|
||||
u_char d_data[sizeof(void*)]; /* dynamic (padded) */
|
||||
};
|
||||
#define DATASIZE(n) (sizeof(struct databuf) - sizeof(void*) + n)
|
||||
|
||||
#ifdef BIND_UPDATE
|
||||
/*
|
||||
* d_mark definitions
|
||||
*/
|
||||
#define D_MARK_DELETED 0x01
|
||||
#define D_MARK_ADDED 0x02
|
||||
#define D_MARK_FOUND 0x04
|
||||
#endif
|
||||
|
||||
/*
|
||||
* d_flags definitions
|
||||
*/
|
||||
#define DB_F_HINT 0x01 /* databuf belongs to fcachetab */
|
||||
#define DB_F_ACTIVE 0x02 /* databuf is linked into a cache */
|
||||
#define DB_F_FREE 0x04 /* databuf has been freed */
|
||||
|
||||
/*
|
||||
* d_cred definitions
|
||||
*/
|
||||
#define DB_C_ZONE 4 /* authoritative zone - best */
|
||||
#define DB_C_AUTH 3 /* authoritative answer */
|
||||
#define DB_C_ANSWER 2 /* non-authoritative answer */
|
||||
#define DB_C_ADDITIONAL 1 /* additional data */
|
||||
#define DB_C_CACHE 0 /* cache - worst */
|
||||
|
||||
struct namebuf {
|
||||
u_int n_hashval; /* hash value of _n_name */
|
||||
struct namebuf *n_next; /* linked list */
|
||||
struct databuf *n_data; /* data records */
|
||||
struct namebuf *n_parent; /* parent domain */
|
||||
struct hashbuf *n_hash; /* hash table for children */
|
||||
char _n_name[sizeof(void*)]; /* Counted str (dynamic). */
|
||||
};
|
||||
#define NAMESIZE(n) (sizeof(struct namebuf) - sizeof(void*) + 1 + n + 1)
|
||||
#define NAMELEN(nb) (((u_char *)((nb)._n_name))[0])
|
||||
#define NAME(nb) ((nb)._n_name + 1)
|
||||
|
||||
struct hashbuf {
|
||||
int h_size; /* size of hash table */
|
||||
int h_cnt; /* number of entries */
|
||||
struct namebuf *h_tab[1]; /* allocated as needed */
|
||||
};
|
||||
#define HASHSIZE(s) (sizeof(struct hashbuf) + (s-1) * sizeof(struct namebuf *))
|
||||
|
||||
#define HASHSHIFT 3
|
||||
#define HASHMASK 0x1f
|
||||
|
||||
/*
|
||||
* Flags to updatedb
|
||||
*/
|
||||
#define DB_NODATA 0x01 /* data should not exist */
|
||||
#define DB_MEXIST 0x02 /* data must exist */
|
||||
#define DB_DELETE 0x04 /* delete data if it exists */
|
||||
#define DB_NOTAUTH 0x08 /* must not update authoritative data */
|
||||
#define DB_NOHINTS 0x10 /* don't reflect update in fcachetab */
|
||||
#define DB_PRIMING 0x20 /* is this update the result of priming? */
|
||||
|
||||
#define DB_Z_CACHE 0 /* cache-zone-only db_dump() */
|
||||
#define DB_Z_ALL 65535 /* normal db_dump() */
|
||||
#define DB_Z_SPECIAL(z) ((z) == DB_Z_CACHE || (z) == DB_Z_ALL)
|
||||
|
||||
/*
|
||||
* Error return codes
|
||||
*/
|
||||
#define OK 0
|
||||
#define NONAME (-1)
|
||||
#define NOCLASS (-2)
|
||||
#define NOTYPE (-3)
|
||||
#define NODATA (-4)
|
||||
#define DATAEXISTS (-5)
|
||||
#define NODBFILE (-6)
|
||||
#define TOOMANYZONES (-7)
|
||||
#define GOODDB (-8)
|
||||
#define NEWDB (-9)
|
||||
#define AUTH (-10)
|
||||
#ifdef BIND_UPDATE
|
||||
#define SERIAL (-11)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* getnum() options
|
||||
*/
|
||||
#define GETNUM_NONE 0x00 /* placeholder */
|
||||
#define GETNUM_SERIAL 0x01 /* treat as serial number */
|
||||
#define GETNUM_SCALED 0x02 /* permit "k", "m" suffixes, scale result */
|
||||
|
||||
/*
|
||||
* Database access abstractions.
|
||||
*/
|
||||
#define foreach_rr(dp, np, ty, cl, zn) \
|
||||
for ((dp) = (np)->n_data; (dp) != NULL; (dp) = (dp)->d_next) \
|
||||
if ((cl) != C_ANY && (cl) != (dp)->d_class) \
|
||||
continue; \
|
||||
else if ((ty) != T_ANY && (ty) != (dp)->d_type) \
|
||||
continue; \
|
||||
else if (((zn) == DB_Z_CACHE) \
|
||||
? stale(dp) \
|
||||
: (zn) != (dp)->d_zone) \
|
||||
continue; \
|
||||
else if ((dp)->d_rcode) \
|
||||
continue; \
|
||||
else \
|
||||
/* Caller code follows in sequence. */
|
||||
|
||||
#define DRCNTINC(x) \
|
||||
do { \
|
||||
if (++((x)->d_rcnt) == 0) \
|
||||
ns_panic(ns_log_db, 1, "++d_rcnt == 0"); \
|
||||
} while (0)
|
||||
|
||||
#define DRCNTDEC(x) \
|
||||
do { \
|
||||
if (((x)->d_rcnt)-- == 0) \
|
||||
ns_panic(ns_log_db, 1, "d_rcnt-- == 0"); \
|
||||
} while (0)
|
||||
111
contrib/bind/bin/named/db_dict.c
Normal file
111
contrib/bind/bin/named/db_dict.c
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
#if !defined(lint) && !defined(SABER)
|
||||
static char rcsid[] = "$Id: db_dict.c,v 8.1 1997/09/26 17:55:40 halley Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1997 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/nameser.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
#include <isc/memcluster.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
|
||||
#define DICT_BLOCKBITS 8
|
||||
#define DICT_BLOCKSHIFT 16
|
||||
#define DICT_BLOCKMAX (1 << DICT_BLOCKBITS)
|
||||
#define DICT_OFFSETBITS 16
|
||||
#define DICT_OFFSETSHIFT 0
|
||||
#define DICT_OFFSETMAX (1 << DICT_OFFSETBITS)
|
||||
|
||||
#define DICT_CONSUMED(Length) ((Length) + 1)
|
||||
#define DICT_INDEX(Block,Offset) (((Block) << DICT_BLOCKSHIFT) | \
|
||||
((Offset) << DICT_OFFSETSHIFT))
|
||||
|
||||
static int dict_new(const char *, int);
|
||||
|
||||
static char * blocks[DICT_BLOCKMAX];
|
||||
static int offsets[DICT_BLOCKMAX];
|
||||
static int cur_block = 0;
|
||||
static int cur_offset = -1;
|
||||
|
||||
int
|
||||
dict_lookup(const char *text, int length, int flags) {
|
||||
int block, offset, ret;
|
||||
|
||||
/* XXX this is a proof of concept, some kind of hash is needed. */
|
||||
for (block = 0; block <= cur_block; block++) {
|
||||
const char *cur = &blocks[block][0];
|
||||
const char *end = &blocks[block][offsets[block]];
|
||||
|
||||
while (cur < end) {
|
||||
int xlength = *cur;
|
||||
|
||||
if (xlength == length &&
|
||||
memcmp(cur+1, text, length) == 0)
|
||||
return (DICT_INDEX(block, offset));
|
||||
cur += DICT_CONSUMED(length);
|
||||
}
|
||||
}
|
||||
if ((flags & DICT_INSERT_P) != 0)
|
||||
return (dict_new(text, length));
|
||||
return (-ENOENT);
|
||||
}
|
||||
|
||||
static int
|
||||
dict_new(const char *text, int length) {
|
||||
int ret;
|
||||
|
||||
if (length < 0 || length > DICT_MAXLENGTH)
|
||||
return (-E2BIG);
|
||||
if (cur_offset + DICT_CONSUMED(length) >= DICT_OFFSETMAX) {
|
||||
if (cur_block + 1 == DICT_BLOCKMAX)
|
||||
return (-ENOSPC);
|
||||
cur_block++;
|
||||
blocks[cur_block] = memget(DICT_OFFSETMAX);
|
||||
if (blocks[cur_block] == NULL)
|
||||
return (-ENOMEM);
|
||||
cur_offset = 0;
|
||||
}
|
||||
assert(cur_offset >= 0);
|
||||
assert(cur_offset + DICT_CONSUMED(length) < DICT_OFFSETMAX);
|
||||
ret = DICT_INDEX(cur_block, cur_offset);
|
||||
blocks[cur_block][cur_offset] = length;
|
||||
memcpy(&blocks[cur_block][cur_offset+1], text, length);
|
||||
cur_offset += DICT_CONSUMED(length);
|
||||
offsets[cur_block] = cur_offset;
|
||||
return (ret);
|
||||
}
|
||||
635
contrib/bind/bin/named/db_dump.c
Normal file
635
contrib/bind/bin/named/db_dump.c
Normal file
|
|
@ -0,0 +1,635 @@
|
|||
#if !defined(lint) && !defined(SABER)
|
||||
static char sccsid[] = "@(#)db_dump.c 4.33 (Berkeley) 3/3/91";
|
||||
static char rcsid[] = "$Id: db_dump.c,v 8.24 1998/02/13 19:49:09 halley Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1986, 1988, 1990
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* 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, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1995 by International Business Machines, Inc.
|
||||
*
|
||||
* International Business Machines, Inc. (hereinafter called IBM) grants
|
||||
* permission under its copyrights to use, copy, modify, and distribute this
|
||||
* Software with or without fee, provided that the above copyright notice and
|
||||
* all paragraphs of this notice appear in all copies, and that the name of IBM
|
||||
* not be used in connection with the marketing of any product incorporating
|
||||
* the Software or modifications thereof, without specific, written prior
|
||||
* permission.
|
||||
*
|
||||
* To the extent it has a right to do so, IBM grants an immunity from suit
|
||||
* under its patents, if any, for the use, sale or manufacture of products to
|
||||
* the extent that such products are used for performing Domain Name System
|
||||
* dynamic updates in TCP/IP networks by means of the Software. No immunity is
|
||||
* granted for any product per se or for any other function of any product.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
|
||||
* DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
|
||||
* IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1996, 1997 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
|
||||
static const char *MkCredStr(int);
|
||||
|
||||
/*
|
||||
* Dump current data base in a format similar to RFC 883.
|
||||
*/
|
||||
|
||||
void
|
||||
doadump()
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
ns_notice(ns_log_db, "dumping nameserver data");
|
||||
|
||||
if ((fp = write_open(server_options->dump_filename)) == NULL)
|
||||
return;
|
||||
gettime(&tt);
|
||||
fprintf(fp, "; Dumped at %s", ctimel(tt.tv_sec));
|
||||
if (zones && nzones)
|
||||
zt_dump(fp);
|
||||
fputs(
|
||||
"; Note: Cr=(auth,answer,addtnl,cache) tag only shown for non-auth RR's\n",
|
||||
fp);
|
||||
fputs(
|
||||
"; Note: NT=milliseconds for any A RR which we've used as a nameserver\n",
|
||||
fp);
|
||||
fprintf(fp, "; --- Cache & Data ---\n");
|
||||
if (hashtab != NULL)
|
||||
(void) db_dump(hashtab, fp, DB_Z_ALL, "");
|
||||
fprintf(fp, "; --- Hints ---\n");
|
||||
if (fcachetab != NULL)
|
||||
(void) db_dump(fcachetab, fp, DB_Z_ALL, "");
|
||||
(void) my_fclose(fp);
|
||||
ns_notice(ns_log_db, "finished dumping nameserver data");
|
||||
}
|
||||
|
||||
int
|
||||
zt_dump(FILE *fp) {
|
||||
struct zoneinfo *zp;
|
||||
|
||||
fprintf(fp, ";; ++zone table++\n");
|
||||
for (zp = &zones[1]; zp < &zones[nzones]; zp++) {
|
||||
char *pre, buf[64];
|
||||
u_int cnt;
|
||||
|
||||
if (!zp->z_origin)
|
||||
continue;
|
||||
|
||||
fprintf(fp, "; %s (type %d, class %d, source %s)\n",
|
||||
zp->z_origin
|
||||
? (*zp->z_origin ? zp->z_origin : ".")
|
||||
: "Nil",
|
||||
zp->z_type, zp->z_class,
|
||||
zp->z_source ? zp->z_source : "Nil");
|
||||
fprintf(fp, ";\ttime=%lu, lastupdate=%lu, serial=%u,\n",
|
||||
(u_long)zp->z_time, (u_long)zp->z_lastupdate,
|
||||
zp->z_serial);
|
||||
fprintf(fp, ";\trefresh=%u, retry=%u, expire=%u, minimum=%u\n",
|
||||
zp->z_refresh, zp->z_retry,
|
||||
zp->z_expire, zp->z_minimum);
|
||||
fprintf(fp, ";\tftime=%lu, xaddr=[%s], state=%04x, pid=%d\n",
|
||||
(u_long)zp->z_ftime, inet_ntoa(zp->z_xaddr),
|
||||
zp->z_flags, (int)zp->z_xferpid);
|
||||
sprintf(buf, ";\tz_addr[%d]: ", zp->z_addrcnt);
|
||||
pre = buf;
|
||||
for (cnt = 0; cnt < zp->z_addrcnt; cnt++) {
|
||||
fprintf(fp, "%s[%s]", pre, inet_ntoa(zp->z_addr[cnt]));
|
||||
pre = ", ";
|
||||
}
|
||||
if (zp->z_addrcnt)
|
||||
fputc('\n', fp);
|
||||
if (zp->z_axfr_src.s_addr != 0)
|
||||
fprintf(fp, "; update source [%s]\n",
|
||||
inet_ntoa(zp->z_axfr_src));
|
||||
}
|
||||
fprintf(fp, ";; --zone table--\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
db_dump(struct hashbuf *htp, FILE *fp, int zone, char *origin) {
|
||||
struct databuf *dp = NULL;
|
||||
struct namebuf *np;
|
||||
struct namebuf **npp, **nppend;
|
||||
char dname[MAXDNAME];
|
||||
u_int32_t n;
|
||||
u_int32_t addr;
|
||||
int j, i, found_data, tab, printed_origin;
|
||||
u_char *cp, *end;
|
||||
const char *proto, *sep;
|
||||
int16_t type;
|
||||
u_int16_t keyflags;
|
||||
u_char *sigdata;
|
||||
u_char *savecp;
|
||||
char temp_base64[NS_MD5RSA_MAX_BASE64];
|
||||
|
||||
found_data = 0;
|
||||
printed_origin = 0;
|
||||
npp = htp->h_tab;
|
||||
nppend = npp + htp->h_size;
|
||||
while (npp < nppend) {
|
||||
for (np = *npp++; np != NULL; np = np->n_next) {
|
||||
if (np->n_data == NULL)
|
||||
continue;
|
||||
/* Blecch - can't tell if there is data here for the
|
||||
* right zone, so can't print name yet
|
||||
*/
|
||||
found_data = 0;
|
||||
/* we want a snapshot in time... */
|
||||
for (dp = np->n_data; dp != NULL; dp = dp->d_next) {
|
||||
/* Is the data for this zone? */
|
||||
if (zone != DB_Z_ALL && dp->d_zone != zone)
|
||||
continue;
|
||||
/* XXX why are we not calling stale() here? */
|
||||
if (dp->d_zone == DB_Z_CACHE &&
|
||||
dp->d_ttl <= (u_int32_t)tt.tv_sec &&
|
||||
(dp->d_flags & DB_F_HINT) == 0)
|
||||
continue;
|
||||
if (!printed_origin) {
|
||||
fprintf(fp, "$ORIGIN %s.\n", origin);
|
||||
printed_origin++;
|
||||
}
|
||||
tab = 0;
|
||||
if (dp->d_rcode == NXDOMAIN ||
|
||||
dp->d_rcode == NOERROR_NODATA) {
|
||||
fputc(';', fp);
|
||||
} else if (found_data == 0 || found_data == 1) {
|
||||
found_data = 2;
|
||||
}
|
||||
if (found_data == 0 || found_data == 2) {
|
||||
if (NAME(*np)[0] == '\0') {
|
||||
if (origin[0] == '\0')
|
||||
fprintf(fp, ".\t");
|
||||
else
|
||||
fprintf(fp, ".%s.\t", origin); /* ??? */
|
||||
} else
|
||||
fprintf(fp, "%s\t", NAME(*np));
|
||||
if (NAMELEN(*np) < (unsigned)8)
|
||||
tab = 1;
|
||||
found_data++;
|
||||
} else {
|
||||
(void) putc('\t', fp);
|
||||
tab = 1;
|
||||
}
|
||||
if (dp->d_zone == DB_Z_CACHE) {
|
||||
if (dp->d_flags & DB_F_HINT &&
|
||||
(int32_t)(dp->d_ttl - tt.tv_sec)
|
||||
< DB_ROOT_TIMBUF)
|
||||
fprintf(fp, "%d\t", DB_ROOT_TIMBUF);
|
||||
else
|
||||
fprintf(fp, "%d\t",
|
||||
(int)(dp->d_ttl - tt.tv_sec));
|
||||
} else if (dp->d_ttl != USE_MINIMUM &&
|
||||
dp->d_ttl != zones[dp->d_zone].z_minimum)
|
||||
fprintf(fp, "%d\t", (int)dp->d_ttl);
|
||||
else if (tab)
|
||||
(void) putc('\t', fp);
|
||||
fprintf(fp, "%s\t%s\t",
|
||||
p_class(dp->d_class),
|
||||
p_type(dp->d_type));
|
||||
cp = (u_char *)dp->d_data;
|
||||
sep = "\t;";
|
||||
type = dp->d_type;
|
||||
if (dp->d_rcode == NXDOMAIN ||
|
||||
dp->d_rcode == NOERROR_NODATA) {
|
||||
#ifdef RETURNSOA
|
||||
if (dp->d_size == 0) {
|
||||
#endif
|
||||
|
||||
fprintf(fp, "%s%s-$",
|
||||
(dp->d_rcode == NXDOMAIN)
|
||||
?"NXDOMAIN" :"NODATA",
|
||||
sep);
|
||||
goto eoln;
|
||||
#ifdef RETURNSOA
|
||||
} else {
|
||||
type = T_SOA;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/*
|
||||
* Print type specific data
|
||||
*/
|
||||
/* XXX why are we not using ns_sprintrr() here? */
|
||||
switch (type) {
|
||||
case T_A:
|
||||
switch (dp->d_class) {
|
||||
case C_IN:
|
||||
case C_HS:
|
||||
fputs(inet_ntoa(ina_get(cp)), fp);
|
||||
break;
|
||||
}
|
||||
if (dp->d_nstime) {
|
||||
fprintf(fp, "%sNT=%d",
|
||||
sep, dp->d_nstime);
|
||||
sep = " ";
|
||||
}
|
||||
break;
|
||||
case T_CNAME:
|
||||
case T_MB:
|
||||
case T_MG:
|
||||
case T_MR:
|
||||
case T_PTR:
|
||||
fprintf(fp, "%s.", cp);
|
||||
break;
|
||||
|
||||
case T_NS:
|
||||
cp = (u_char *)dp->d_data;
|
||||
if (cp[0] == '\0')
|
||||
fprintf(fp, ".\t");
|
||||
else
|
||||
fprintf(fp, "%s.", cp);
|
||||
break;
|
||||
|
||||
case T_HINFO:
|
||||
case T_ISDN: {
|
||||
char buf[256];
|
||||
|
||||
if ((n = *cp++) != '\0') {
|
||||
memcpy(buf, cp, n); buf[n] = '\0';
|
||||
fprintf(fp, "\"%.*s\"", (int)n, buf);
|
||||
cp += n;
|
||||
} else
|
||||
fprintf(fp, "\"\"");
|
||||
if ((n = *cp++) != '\0') {
|
||||
memcpy(buf, cp, n); buf[n] = '\0';
|
||||
fprintf(fp, " \"%.*s\"", (int)n, buf);
|
||||
} else
|
||||
fprintf(fp, " \"\"");
|
||||
break;
|
||||
}
|
||||
|
||||
case T_SOA:
|
||||
fprintf(fp, "%s.", cp);
|
||||
cp += strlen((char *)cp) + 1;
|
||||
fprintf(fp, " %s. (\n", cp);
|
||||
#if defined(RETURNSOA)
|
||||
if (dp->d_rcode)
|
||||
fputs(";", fp);
|
||||
#endif
|
||||
cp += strlen((char *)cp) + 1;
|
||||
NS_GET32(n, cp);
|
||||
fprintf(fp, "\t\t%u", n);
|
||||
NS_GET32(n, cp);
|
||||
fprintf(fp, " %u", n);
|
||||
NS_GET32(n, cp);
|
||||
fprintf(fp, " %u", n);
|
||||
NS_GET32(n, cp);
|
||||
fprintf(fp, " %u", n);
|
||||
NS_GET32(n, cp);
|
||||
fprintf(fp, " %u )", n);
|
||||
#if defined(RETURNSOA)
|
||||
if (dp->d_rcode) {
|
||||
fprintf(fp,";%s.;%s%s-$",cp,
|
||||
(dp->d_rcode == NXDOMAIN) ?
|
||||
"NXDOMAIN" : "NODATA",
|
||||
sep);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case T_MX:
|
||||
case T_AFSDB:
|
||||
case T_RT:
|
||||
NS_GET16(n, cp);
|
||||
fprintf(fp, "%u", n);
|
||||
fprintf(fp, " %s.", cp);
|
||||
break;
|
||||
|
||||
case T_PX:
|
||||
NS_GET16(n, cp);
|
||||
fprintf(fp, "%u", n);
|
||||
fprintf(fp, " %s.", cp);
|
||||
cp += strlen((char *)cp) + 1;
|
||||
fprintf(fp, " %s.", cp);
|
||||
break;
|
||||
|
||||
case T_X25:
|
||||
if ((n = *cp++) != '\0')
|
||||
fprintf(fp, " \"%.*s\"", (int)n, cp);
|
||||
else
|
||||
fprintf(fp, " \"\"");
|
||||
break;
|
||||
|
||||
case T_TXT:
|
||||
end = (u_char *)dp->d_data + dp->d_size;
|
||||
while (cp < end) {
|
||||
(void) putc('"', fp);
|
||||
if ((n = *cp++) != '\0') {
|
||||
for (j = n ; j > 0 && cp < end ; j--) {
|
||||
if (*cp == '\n' || *cp == '"' || *cp == '\\')
|
||||
(void) putc('\\', fp);
|
||||
(void) putc(*cp++, fp);
|
||||
}
|
||||
}
|
||||
(void) putc('"', fp);
|
||||
if (cp < end)
|
||||
(void) putc(' ', fp);
|
||||
}
|
||||
break;
|
||||
|
||||
case T_NSAP:
|
||||
(void) fputs(inet_nsap_ntoa(dp->d_size,
|
||||
dp->d_data, NULL),
|
||||
fp);
|
||||
break;
|
||||
|
||||
case T_AAAA: {
|
||||
char t[sizeof
|
||||
"ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"
|
||||
];
|
||||
|
||||
(void) fputs(inet_ntop(AF_INET6, dp->d_data,
|
||||
t, sizeof t),
|
||||
fp);
|
||||
break;
|
||||
}
|
||||
|
||||
case T_LOC: {
|
||||
char t[256];
|
||||
|
||||
(void) fputs(loc_ntoa(dp->d_data, t), fp);
|
||||
break;
|
||||
}
|
||||
|
||||
case T_NAPTR: {
|
||||
u_int32_t order, preference;
|
||||
|
||||
NS_GET16(order, cp);
|
||||
fprintf(fp, "%u", order);
|
||||
|
||||
NS_GET16(preference, cp);
|
||||
fprintf(fp, "%u", preference);
|
||||
|
||||
if ((n = *cp++) != 0) {
|
||||
fprintf(fp, "\"%.*s\"", (int)n, cp);
|
||||
cp += n;
|
||||
}
|
||||
if ((n = *cp++) != 0) {
|
||||
fprintf(fp, "\"%.*s\"", (int)n, cp);
|
||||
cp += n;
|
||||
}
|
||||
if ((n = *cp++) != 0) {
|
||||
fprintf(fp, " \"%.*s\"", (int)n, cp);
|
||||
cp += n;
|
||||
}
|
||||
fprintf(fp, " %s.", cp);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case T_SRV: {
|
||||
u_int priority, weight, port;
|
||||
|
||||
NS_GET16(priority, cp);
|
||||
NS_GET16(weight, cp);
|
||||
NS_GET16(port, cp);
|
||||
fprintf(fp, "\t%u %u %u %s.",
|
||||
priority, weight, port, cp);
|
||||
break;
|
||||
}
|
||||
|
||||
case T_WKS:
|
||||
fputs(inet_ntoa(ina_get(cp)), fp);
|
||||
cp += INADDRSZ;
|
||||
proto = protocolname(*cp);
|
||||
cp += sizeof(char);
|
||||
fprintf(fp, " %s ", proto);
|
||||
i = 0;
|
||||
while(cp < (u_char *)dp->d_data + dp->d_size) {
|
||||
j = *cp++;
|
||||
do {
|
||||
if (j & 0200)
|
||||
fprintf(fp, " %s",
|
||||
servicename(i, proto));
|
||||
j <<= 1;
|
||||
} while (++i & 07);
|
||||
}
|
||||
break;
|
||||
|
||||
case T_MINFO:
|
||||
case T_RP:
|
||||
fprintf(fp, "%s.", cp);
|
||||
cp += strlen((char *)cp) + 1;
|
||||
fprintf(fp, " %s.", cp);
|
||||
break;
|
||||
|
||||
case T_KEY:
|
||||
savecp = cp; /* save the beginning */
|
||||
/*>>> Flags (unsigned_16) */
|
||||
NS_GET16(keyflags,cp);
|
||||
fprintf(fp, "0x%04x ", keyflags);
|
||||
/*>>> Protocol (8-bit decimal) */
|
||||
fprintf(fp, "%3u ", *cp++);
|
||||
/*>>> Algorithm id (8-bit decimal) */
|
||||
fprintf(fp, "%3u ", *cp++);
|
||||
|
||||
/*>>> Public-Key Data (multidigit BASE64) */
|
||||
/* containing ExponentLen, Exponent, and Modulus */
|
||||
i = b64_ntop(cp, dp->d_size - (cp - savecp),
|
||||
temp_base64,
|
||||
sizeof temp_base64);
|
||||
if (i < 0)
|
||||
fprintf(fp, "; BAD BASE64");
|
||||
else
|
||||
fprintf(fp, "%s", temp_base64);
|
||||
break;
|
||||
|
||||
case T_SIG:
|
||||
sigdata = cp;
|
||||
/* RRtype (char *) */
|
||||
NS_GET16(n,cp);
|
||||
fprintf(fp, "%s ", p_type(n));
|
||||
/* Algorithm id (8-bit decimal) */
|
||||
fprintf(fp, "%d ", *cp++);
|
||||
/* Labels (8-bit decimal) (not saved in file) */
|
||||
/* FIXME -- check value and print err if bad */
|
||||
cp++;
|
||||
/* OTTL (u_long) */
|
||||
NS_GET32(n, cp);
|
||||
fprintf(fp, "%u ", n);
|
||||
/* Texp (u_long) */
|
||||
NS_GET32(n, cp);
|
||||
fprintf(fp, "%s ", p_secstodate (n));
|
||||
/* Tsig (u_long) */
|
||||
NS_GET32(n, cp);
|
||||
fprintf(fp, "%s ", p_secstodate (n));
|
||||
/* Kfootprint (unsigned_16) */
|
||||
NS_GET16(n, cp);
|
||||
fprintf(fp, "%u ", n);
|
||||
/* Signer's Name (char *) */
|
||||
fprintf(fp, "%s ", cp);
|
||||
cp += strlen((char *)cp) + 1;
|
||||
/* Signature (base64 of any length) */
|
||||
i = b64_ntop(cp, dp->d_size - (cp - sigdata),
|
||||
temp_base64,
|
||||
sizeof temp_base64);
|
||||
if (i < 0)
|
||||
fprintf(fp, "; BAD BASE64");
|
||||
else
|
||||
fprintf(fp, "%s", temp_base64);
|
||||
break;
|
||||
|
||||
case T_NXT:
|
||||
fprintf(fp, "%s.", cp);
|
||||
n = strlen ((char *)cp) + 1;
|
||||
cp += n;
|
||||
i = 8 * (dp->d_size - n); /* How many bits? */
|
||||
for (n = 0; n < (u_int32_t)i; n++) {
|
||||
if (NS_NXT_BIT_ISSET(n, cp))
|
||||
fprintf(fp," %s",__p_type(n));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(fp, "%s?d_type=%d?",
|
||||
sep, dp->d_type);
|
||||
sep = " ";
|
||||
}
|
||||
if (dp->d_cred < DB_C_ZONE) {
|
||||
fprintf(fp, "%sCr=%s",
|
||||
sep, MkCredStr(dp->d_cred));
|
||||
sep = " ";
|
||||
} else {
|
||||
fprintf(fp, "%sCl=%d",
|
||||
sep, dp->d_clev);
|
||||
sep = " ";
|
||||
}
|
||||
eoln:
|
||||
if (dp->d_ns != NULL){
|
||||
fprintf(fp, "%s[%s]",
|
||||
sep, inet_ntoa(dp->d_ns->addr));
|
||||
sep = " ";
|
||||
}
|
||||
putc('\n', fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ferror(fp))
|
||||
return (NODBFILE);
|
||||
|
||||
npp = htp->h_tab;
|
||||
nppend = npp + htp->h_size;
|
||||
while (npp < nppend) {
|
||||
for (np = *npp++; np != NULL; np = np->n_next) {
|
||||
if (np->n_hash == NULL)
|
||||
continue;
|
||||
getname(np, dname, sizeof(dname));
|
||||
if (db_dump(np->n_hash, fp, zone, dname) == NODBFILE)
|
||||
return (NODBFILE);
|
||||
}
|
||||
}
|
||||
return (OK);
|
||||
}
|
||||
|
||||
static const char *
|
||||
MkCredStr(int cred) {
|
||||
static char badness[20];
|
||||
|
||||
switch (cred) {
|
||||
case DB_C_ZONE: return "zone";
|
||||
case DB_C_AUTH: return "auth";
|
||||
case DB_C_ANSWER: return "answer";
|
||||
case DB_C_ADDITIONAL: return "addtnl";
|
||||
case DB_C_CACHE: return "cache";
|
||||
default: break;
|
||||
}
|
||||
sprintf(badness, "?%d?", cred);
|
||||
return (badness);
|
||||
}
|
||||
151
contrib/bind/bin/named/db_func.h
Normal file
151
contrib/bind/bin/named/db_func.h
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
/* Copyright (c) 1985, 1990
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* 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, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION 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.
|
||||
*/
|
||||
|
||||
/* Portions Copyright (c) 1996, 1997 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/* db_proc.h - prototypes for functions in db_*.c
|
||||
*
|
||||
* $Id: db_func.h,v 8.22 1997/12/04 06:47:00 halley Exp $
|
||||
*/
|
||||
|
||||
/* ++from db_update.c++ */
|
||||
extern int db_update(const char *name,
|
||||
struct databuf *odp,
|
||||
struct databuf *newdp,
|
||||
struct databuf **savedpp,
|
||||
int flags,
|
||||
struct hashbuf *htp,
|
||||
struct sockaddr_in from),
|
||||
db_cmp(const struct databuf *, const struct databuf *),
|
||||
findMyZone(struct namebuf *np, int class);
|
||||
void fixttl(struct databuf *dp);
|
||||
/* --from db_update.c-- */
|
||||
|
||||
/* ++from db_save.c++ */
|
||||
extern struct namebuf *savename(const char *, int);
|
||||
extern struct databuf *savedata(int, int, u_int32_t, u_char *, int);
|
||||
extern struct hashbuf *savehash(struct hashbuf *);
|
||||
/* --from db_save.c-- */
|
||||
|
||||
/* ++from db_dump.c++ */
|
||||
extern int db_dump(struct hashbuf *, FILE *, int, char *),
|
||||
zt_dump(FILE *);
|
||||
extern void doadump(void);
|
||||
/* --from db_dump.c-- */
|
||||
|
||||
/* ++from db_load.c++ */
|
||||
extern void endline(FILE *);
|
||||
extern int getword(char *, size_t, FILE *, int),
|
||||
getnum(FILE *, const char *, int),
|
||||
db_load(const char *, const char *,
|
||||
struct zoneinfo *, const char *);
|
||||
extern int getnonblank(FILE *, const char *),
|
||||
getservices(int, char *, FILE *, const char *);
|
||||
extern char getprotocol(FILE *, const char *);
|
||||
extern int makename(char *, const char *, int);
|
||||
#ifdef BIND_NOTIFY
|
||||
extern void notify_after_load(evContext, void *, const void *),
|
||||
db_cancel_pending_notifies(void);
|
||||
#endif
|
||||
/* --from db_load.c-- */
|
||||
|
||||
/* ++from db_glue.c++ */
|
||||
extern void buildservicelist(void),
|
||||
destroyservicelist(void),
|
||||
buildprotolist(void),
|
||||
destroyprotolist(void),
|
||||
getname(struct namebuf *, char *, int);
|
||||
extern int servicenumber(const char *),
|
||||
protocolnumber(const char *),
|
||||
get_class(const char *),
|
||||
samedomain(const char *, const char *);
|
||||
extern u_int dhash(const u_char *, int),
|
||||
nhash(const char *);
|
||||
extern const char *protocolname(int),
|
||||
*servicename(u_int16_t, const char *);
|
||||
#ifndef BSD
|
||||
extern int getdtablesize(void);
|
||||
#endif
|
||||
extern struct databuf *rm_datum(struct databuf *,
|
||||
struct namebuf *,
|
||||
struct databuf *,
|
||||
struct databuf **);
|
||||
extern struct namebuf *rm_name(struct namebuf *,
|
||||
struct namebuf **,
|
||||
struct namebuf *);
|
||||
extern void rm_hash(struct hashbuf *);
|
||||
extern void db_freedata(struct databuf *);
|
||||
/* --from db_glue.c-- */
|
||||
|
||||
/* ++from db_lookup.c++ */
|
||||
extern struct namebuf *nlookup(const char *, struct hashbuf **,
|
||||
const char **, int);
|
||||
extern struct namebuf *np_parent __P((struct namebuf *));
|
||||
extern int match(struct databuf *, int, int);
|
||||
/* --from db_lookup.c-- */
|
||||
|
||||
/* ++from db_dict.c++ */
|
||||
int dict_lookup(const char *, int, int);
|
||||
/* --from db_dict.c-- */
|
||||
94
contrib/bind/bin/named/db_glob.h
Normal file
94
contrib/bind/bin/named/db_glob.h
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* from db.h 4.16 (Berkeley) 6/1/90
|
||||
* $Id: db_glob.h,v 8.8 1997/06/09 17:46:51 halley Exp $
|
||||
*/
|
||||
|
||||
/* Copyright (c) 1985, 1990
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* 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, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION 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.
|
||||
*/
|
||||
|
||||
/* Portions Copyright (c) 1996, 1997 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Global variables for data base routines.
|
||||
*/
|
||||
|
||||
/* ONE_WEEK maximum ttl */
|
||||
DECL u_int max_cache_ttl INIT(7*24*60*60);
|
||||
|
||||
/* no minimum ttl */
|
||||
DECL u_int min_cache_ttl INIT(0);
|
||||
|
||||
/* current line number */
|
||||
DECL int lineno;
|
||||
|
||||
/* root hash table */
|
||||
DECL struct hashbuf *hashtab INIT(NULL);
|
||||
|
||||
/* hash table of cache read from file */
|
||||
DECL struct hashbuf *fcachetab INIT(NULL);
|
||||
|
||||
#ifdef FORCED_RELOAD
|
||||
DECL int reloading INIT(0);
|
||||
#endif /* FORCED_RELOAD */
|
||||
616
contrib/bind/bin/named/db_glue.c
Normal file
616
contrib/bind/bin/named/db_glue.c
Normal file
|
|
@ -0,0 +1,616 @@
|
|||
#if !defined(lint) && !defined(SABER)
|
||||
static char sccsid[] = "@(#)db_glue.c 4.4 (Berkeley) 6/1/90";
|
||||
static char rcsid[] = "$Id: db_glue.c,v 8.27 1998/02/14 00:41:39 halley Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1986, 1988
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* 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, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1996, 1997 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/nameser.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
#include <isc/memcluster.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
|
||||
struct valuelist {
|
||||
struct valuelist * next;
|
||||
struct valuelist * prev;
|
||||
char * name;
|
||||
char * proto;
|
||||
int port;
|
||||
};
|
||||
static struct valuelist *servicelist, *protolist;
|
||||
|
||||
void
|
||||
buildservicelist() {
|
||||
struct servent *sp;
|
||||
struct valuelist *slp;
|
||||
|
||||
#ifdef MAYBE_HESIOD
|
||||
setservent(0);
|
||||
#else
|
||||
setservent(1);
|
||||
#endif
|
||||
while ((sp = getservent()) != NULL) {
|
||||
slp = (struct valuelist *)memget(sizeof(struct valuelist));
|
||||
if (!slp)
|
||||
panic("memget(servent)", NULL);
|
||||
slp->name = savestr(sp->s_name, 1);
|
||||
slp->proto = savestr(sp->s_proto, 1);
|
||||
slp->port = ntohs((u_int16_t)sp->s_port); /* host byt order */
|
||||
slp->next = servicelist;
|
||||
slp->prev = NULL;
|
||||
if (servicelist)
|
||||
servicelist->prev = slp;
|
||||
servicelist = slp;
|
||||
}
|
||||
endservent();
|
||||
}
|
||||
|
||||
void
|
||||
destroyservicelist() {
|
||||
struct valuelist *slp, *slp_next;
|
||||
|
||||
for (slp = servicelist; slp != NULL; slp = slp_next) {
|
||||
slp_next = slp->next;
|
||||
freestr(slp->name);
|
||||
freestr(slp->proto);
|
||||
memput(slp, sizeof *slp);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
buildprotolist() {
|
||||
struct protoent *pp;
|
||||
struct valuelist *slp;
|
||||
|
||||
#ifdef MAYBE_HESIOD
|
||||
setprotoent(0);
|
||||
#else
|
||||
setprotoent(1);
|
||||
#endif
|
||||
while ((pp = getprotoent()) != NULL) {
|
||||
slp = (struct valuelist *)memget(sizeof(struct valuelist));
|
||||
if (!slp)
|
||||
panic("memget(protoent)", NULL);
|
||||
slp->name = savestr(pp->p_name, 1);
|
||||
slp->port = pp->p_proto; /* host byte order */
|
||||
slp->next = protolist;
|
||||
slp->prev = NULL;
|
||||
if (protolist)
|
||||
protolist->prev = slp;
|
||||
protolist = slp;
|
||||
}
|
||||
endprotoent();
|
||||
}
|
||||
|
||||
void
|
||||
destroyprotolist() {
|
||||
struct valuelist *plp, *plp_next;
|
||||
|
||||
for (plp = protolist; plp != NULL; plp = plp_next) {
|
||||
plp_next = plp->next;
|
||||
freestr(plp->name);
|
||||
memput(plp, sizeof *plp);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
findservice(const char *s, struct valuelist **list) {
|
||||
struct valuelist *lp = *list;
|
||||
int n;
|
||||
|
||||
for (; lp != NULL; lp = lp->next)
|
||||
if (strcasecmp(lp->name, s) == 0) {
|
||||
if (lp != *list) {
|
||||
lp->prev->next = lp->next;
|
||||
if (lp->next)
|
||||
lp->next->prev = lp->prev;
|
||||
(*list)->prev = lp;
|
||||
lp->next = *list;
|
||||
*list = lp;
|
||||
}
|
||||
return (lp->port); /* host byte order */
|
||||
}
|
||||
if (sscanf(s, "%d", &n) != 1 || n <= 0)
|
||||
n = -1;
|
||||
return (n);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert service name or (ascii) number to int.
|
||||
*/
|
||||
int
|
||||
servicenumber(const char *p) {
|
||||
return (findservice(p, &servicelist));
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert protocol name or (ascii) number to int.
|
||||
*/
|
||||
int
|
||||
protocolnumber(const char *p) {
|
||||
return (findservice(p, &protolist));
|
||||
}
|
||||
|
||||
static struct servent *
|
||||
cgetservbyport(u_int16_t port, const char *proto) { /* Host byte order. */
|
||||
struct valuelist **list = &servicelist;
|
||||
struct valuelist *lp = *list;
|
||||
static struct servent serv;
|
||||
|
||||
port = ntohs(port);
|
||||
for (; lp != NULL; lp = lp->next) {
|
||||
if (port != (u_int16_t)lp->port) /* Host byte order. */
|
||||
continue;
|
||||
if (strcasecmp(lp->proto, proto) == 0) {
|
||||
if (lp != *list) {
|
||||
lp->prev->next = lp->next;
|
||||
if (lp->next)
|
||||
lp->next->prev = lp->prev;
|
||||
(*list)->prev = lp;
|
||||
lp->next = *list;
|
||||
*list = lp;
|
||||
}
|
||||
serv.s_name = lp->name;
|
||||
serv.s_port = htons((u_int16_t)lp->port);
|
||||
serv.s_proto = lp->proto;
|
||||
return (&serv);
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
static struct protoent *
|
||||
cgetprotobynumber(int proto) { /* Host byte order. */
|
||||
struct valuelist **list = &protolist;
|
||||
struct valuelist *lp = *list;
|
||||
static struct protoent prot;
|
||||
|
||||
for (; lp != NULL; lp = lp->next)
|
||||
if (lp->port == proto) { /* Host byte order. */
|
||||
if (lp != *list) {
|
||||
lp->prev->next = lp->next;
|
||||
if (lp->next)
|
||||
lp->next->prev = lp->prev;
|
||||
(*list)->prev = lp;
|
||||
lp->next = *list;
|
||||
*list = lp;
|
||||
}
|
||||
prot.p_name = lp->name;
|
||||
prot.p_proto = lp->port; /* Host byte order. */
|
||||
return (&prot);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
const char *
|
||||
protocolname(int num) {
|
||||
static char number[8];
|
||||
struct protoent *pp;
|
||||
|
||||
pp = cgetprotobynumber(num);
|
||||
if (pp == 0) {
|
||||
(void) sprintf(number, "%d", num);
|
||||
return (number);
|
||||
}
|
||||
return (pp->p_name);
|
||||
}
|
||||
|
||||
const char *
|
||||
servicename(u_int16_t port, const char *proto) { /* Host byte order. */
|
||||
static char number[8];
|
||||
struct servent *ss;
|
||||
|
||||
ss = cgetservbyport(htons(port), proto);
|
||||
if (ss == 0) {
|
||||
(void) sprintf(number, "%d", port);
|
||||
return (number);
|
||||
}
|
||||
return (ss->s_name);
|
||||
}
|
||||
|
||||
static struct map map_class[] = {
|
||||
{ "in", C_IN },
|
||||
{ "chaos", C_CHAOS },
|
||||
{ "hs", C_HS },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
int
|
||||
get_class(const char *class) {
|
||||
const struct map *mp;
|
||||
|
||||
if (isdigit(*class))
|
||||
return (atoi(class));
|
||||
for (mp = map_class; mp->token != NULL; mp++)
|
||||
if (strcasecmp(class, mp->token) == 0)
|
||||
return (mp->val);
|
||||
return (C_IN);
|
||||
}
|
||||
|
||||
/* rm_datum(dp, np, pdp, savedpp)
|
||||
* remove datum 'dp' from name 'np'. pdp is previous data pointer.
|
||||
* if savedpp is not NULL, and compiled with BIND_UPDATE, save
|
||||
* datum dp there rather than freeing the memory (caller will take
|
||||
* care of freeing it)
|
||||
* return value:
|
||||
* "next" field from removed datum, suitable for relinking
|
||||
*/
|
||||
struct databuf *
|
||||
rm_datum(struct databuf *dp, struct namebuf *np, struct databuf *pdp,
|
||||
struct databuf **savedpp) {
|
||||
struct databuf *ndp = dp->d_next;
|
||||
|
||||
ns_debug(ns_log_db, 3, "rm_datum(%lx, %lx, %lx, %lx) -> %lx",
|
||||
(u_long)dp, (u_long)np->n_data, (u_long)pdp,
|
||||
(u_long)savedpp, (u_long)ndp);
|
||||
if ((dp->d_flags & DB_F_ACTIVE) == 0)
|
||||
panic("rm_datum: DB_F_ACTIVE not set", NULL);
|
||||
if (pdp == NULL)
|
||||
np->n_data = ndp;
|
||||
else
|
||||
pdp->d_next = ndp;
|
||||
#ifdef BIND_UPDATE
|
||||
if (savedpp != NULL) {
|
||||
/* mark deleted or pending deletion */
|
||||
dp->d_mark |= D_MARK_DELETED;
|
||||
dp->d_next = *savedpp;
|
||||
*savedpp = dp;
|
||||
} else
|
||||
dp->d_next = NULL;
|
||||
#else
|
||||
dp->d_next = NULL;
|
||||
#endif
|
||||
dp->d_flags &= ~DB_F_ACTIVE;
|
||||
DRCNTDEC(dp);
|
||||
if (dp->d_rcnt) {
|
||||
#ifdef DEBUG
|
||||
int32_t ii;
|
||||
#endif
|
||||
|
||||
switch(dp->d_type) {
|
||||
case T_NS:
|
||||
ns_debug(ns_log_db, 3, "rm_datum: %s rcnt = %d",
|
||||
dp->d_data, dp->d_rcnt);
|
||||
break;
|
||||
#ifdef DEBUG
|
||||
case T_A:
|
||||
memcpy(&ii, dp->d_data, sizeof ii);
|
||||
ns_debug(ns_log_db, 3,
|
||||
"rm_datum: %08.8X rcnt = %d",
|
||||
ii, dp->d_rcnt);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
ns_debug(ns_log_db, 3,
|
||||
"rm_datum: rcnt = %d", dp->d_rcnt);
|
||||
}
|
||||
} else
|
||||
#ifdef BIND_UPDATE
|
||||
if (savedpp == NULL)
|
||||
#endif
|
||||
db_freedata(dp);
|
||||
return (ndp);
|
||||
}
|
||||
|
||||
/* rm_name(np, he, pnp)
|
||||
* remove name 'np' from parent 'pp'. pnp is previous name pointer.
|
||||
* return value:
|
||||
* "next" field from removed name, suitable for relinking.
|
||||
*/
|
||||
struct namebuf *
|
||||
rm_name(struct namebuf *np, struct namebuf **pp, struct namebuf *pnp) {
|
||||
struct namebuf *nnp = np->n_next;
|
||||
const char *msg;
|
||||
|
||||
/* verify */
|
||||
if ( (np->n_data && (msg = "data"))
|
||||
|| (np->n_hash && (msg = "hash"))
|
||||
) {
|
||||
ns_panic(ns_log_db, 1, "rm_name(%#x(%s)): non-nil %s pointer",
|
||||
np, NAME(*np), msg);
|
||||
}
|
||||
|
||||
/* unlink */
|
||||
if (pnp)
|
||||
pnp->n_next = nnp;
|
||||
else
|
||||
*pp = nnp;
|
||||
|
||||
/* deallocate */
|
||||
memput(np, NAMESIZE(NAMELEN(*np)));
|
||||
|
||||
/* done */
|
||||
return (nnp);
|
||||
}
|
||||
|
||||
void
|
||||
rm_hash(struct hashbuf *htp) {
|
||||
REQUIRE(htp != NULL);
|
||||
REQUIRE(htp->h_cnt == 0);
|
||||
|
||||
memput(htp, HASHSIZE(htp->h_size));
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the domain name of 'np' and put in 'buf'. Bounds checking is done.
|
||||
*/
|
||||
void
|
||||
getname(struct namebuf *np, char *buf, int buflen) {
|
||||
char *cp;
|
||||
int i;
|
||||
|
||||
cp = buf;
|
||||
while (np != NULL) {
|
||||
i = (int) NAMELEN(*np);
|
||||
if (i + 1 >= buflen) {
|
||||
*cp = '\0';
|
||||
ns_info(ns_log_db,
|
||||
"domain name too long: %s...", buf);
|
||||
strcpy(buf, "Name_Too_Long");
|
||||
return;
|
||||
}
|
||||
if (cp != buf)
|
||||
*cp++ = '.';
|
||||
memcpy(cp, NAME(*np), i);
|
||||
cp += i;
|
||||
buflen -= i + 1;
|
||||
np = np->n_parent;
|
||||
}
|
||||
*cp = '\0';
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute hash value from data.
|
||||
*/
|
||||
u_int
|
||||
dhash(const u_char *dp, int dlen) {
|
||||
u_char *cp;
|
||||
u_int hval;
|
||||
int n;
|
||||
|
||||
n = dlen;
|
||||
if (n > 8)
|
||||
n = 8;
|
||||
hval = 0;
|
||||
while (--n >= 0) {
|
||||
hval <<= 1;
|
||||
hval += *dp++;
|
||||
}
|
||||
return (hval % INVHASHSZ);
|
||||
}
|
||||
|
||||
/* u_int
|
||||
* nhash(name)
|
||||
* compute hash for this name and return it; ignore case differences
|
||||
*/
|
||||
u_int
|
||||
nhash(const char *name) {
|
||||
u_char ch;
|
||||
u_int hval;
|
||||
|
||||
hval = 0;
|
||||
while ((ch = (u_char)*name++) != (u_char)'\0') {
|
||||
if (isascii(ch) && isupper(ch))
|
||||
ch = tolower(ch);
|
||||
hval <<= 1;
|
||||
hval += ch;
|
||||
}
|
||||
return (hval % INVHASHSZ);
|
||||
}
|
||||
|
||||
/*
|
||||
** SAMEDOMAIN -- Check whether a name belongs to a domain
|
||||
** ------------------------------------------------------
|
||||
**
|
||||
** Returns:
|
||||
** TRUE if the given name lies in the domain.
|
||||
** FALSE otherwise.
|
||||
**
|
||||
** Trailing dots are first removed from name and domain.
|
||||
** Always compare complete subdomains, not only whether the
|
||||
** domain name is the trailing string of the given name.
|
||||
**
|
||||
** "host.foobar.top" lies in "foobar.top" and in "top" and in ""
|
||||
** but NOT in "bar.top"
|
||||
*/
|
||||
|
||||
int
|
||||
samedomain(const char *a, const char *b) {
|
||||
size_t la, lb;
|
||||
int diff, i, escaped;
|
||||
const char *cp;
|
||||
|
||||
la = strlen(a);
|
||||
lb = strlen(b);
|
||||
|
||||
/* ignore a trailing label separator (i.e. an unescaped dot) in 'a' */
|
||||
if (la && a[la-1] == '.') {
|
||||
escaped = 0;
|
||||
/* note this loop doesn't get executed if la==1 */
|
||||
for (i = la - 2; i >= 0; i--)
|
||||
if (a[i] == '\\') {
|
||||
if (escaped)
|
||||
escaped = 0;
|
||||
else
|
||||
escaped = 1;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
if (!escaped)
|
||||
la--;
|
||||
}
|
||||
/* ignore a trailing label separator (i.e. an unescaped dot) in 'b' */
|
||||
if (lb && b[lb-1] == '.') {
|
||||
escaped = 0;
|
||||
/* note this loop doesn't get executed if lb==1 */
|
||||
for (i = lb - 2; i >= 0; i--)
|
||||
if (b[i] == '\\') {
|
||||
if (escaped)
|
||||
escaped = 0;
|
||||
else
|
||||
escaped = 1;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
if (!escaped)
|
||||
lb--;
|
||||
}
|
||||
|
||||
/* lb==0 means 'b' is the root domain, so 'a' must be in 'b'. */
|
||||
if (lb == 0)
|
||||
return (1);
|
||||
|
||||
/* 'b' longer than 'a' means 'a' can't be in 'b'. */
|
||||
if (lb > la)
|
||||
return (0);
|
||||
|
||||
/* We use strncasecmp because we might be trying to
|
||||
* ignore a trailing dot. */
|
||||
if (lb == la)
|
||||
return (strncasecmp(a, b, lb) == 0);
|
||||
|
||||
/* Ok, we know la > lb. */
|
||||
|
||||
diff = la - lb;
|
||||
|
||||
/* If 'a' is only 1 character longer than 'b', then it can't be
|
||||
a subdomain of 'b' (because of the need for the '.' label
|
||||
separator). */
|
||||
if (diff < 2)
|
||||
return (0);
|
||||
|
||||
/* If the character before the last 'lb' characters of 'b'
|
||||
isn't '.', then it can't be a match (this lets us avoid
|
||||
having "foobar.com" match "bar.com"). */
|
||||
if (a[diff-1] != '.')
|
||||
return (0);
|
||||
|
||||
/* We're not sure about that '.', however. It could be escaped
|
||||
and thus not a really a label separator. */
|
||||
escaped=0;
|
||||
for (i = diff-2; i >= 0; i--)
|
||||
if (a[i] == '\\') {
|
||||
if (escaped)
|
||||
escaped = 0;
|
||||
else
|
||||
escaped = 1;
|
||||
}
|
||||
else
|
||||
break;
|
||||
if (escaped)
|
||||
return (0);
|
||||
|
||||
/* We use strncasecmp because we might be trying to
|
||||
* ignore trailing dots. */
|
||||
cp = a + diff;
|
||||
return (strncasecmp(cp, b, lb) == 0);
|
||||
}
|
||||
|
||||
void
|
||||
db_freedata(struct databuf *dp) {
|
||||
int bytes = (dp->d_type == T_NS) ?
|
||||
DATASIZE(dp->d_size)+INT32SZ : DATASIZE(dp->d_size);
|
||||
|
||||
if (dp->d_rcnt != 0)
|
||||
panic("db_freedata: d_rcnt != 0", NULL);
|
||||
if ((dp->d_flags & (DB_F_ACTIVE|DB_F_FREE)) != 0)
|
||||
panic("db_freedata: %s set",
|
||||
(dp->d_flags & DB_F_FREE) != 0 ? "DB_F_FREE" :
|
||||
"DB_F_ACTIVE");
|
||||
if (dp->d_next != NULL)
|
||||
panic("db_free: d_next != NULL", NULL);
|
||||
dp->d_flags |= DB_F_FREE;
|
||||
memput(dp, bytes);
|
||||
}
|
||||
2218
contrib/bind/bin/named/db_load.c
Normal file
2218
contrib/bind/bin/named/db_load.c
Normal file
File diff suppressed because it is too large
Load diff
269
contrib/bind/bin/named/db_lookup.c
Normal file
269
contrib/bind/bin/named/db_lookup.c
Normal file
|
|
@ -0,0 +1,269 @@
|
|||
#if !defined(lint) && !defined(SABER)
|
||||
static char sccsid[] = "@(#)db_lookup.c 4.18 (Berkeley) 3/21/91";
|
||||
static char rcsid[] = "$Id: db_lookup.c,v 8.13 1998/02/13 19:52:54 halley Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1986
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* 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, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1996, 1997 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Table lookup routines.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
|
||||
/*
|
||||
* Lookup 'name' and return a pointer to the namebuf;
|
||||
* NULL otherwise. If 'insert', insert name into tables.
|
||||
* Wildcard lookups are handled.
|
||||
*/
|
||||
struct namebuf *
|
||||
nlookup(const char *name, struct hashbuf **htpp,
|
||||
const char **fname, int insert)
|
||||
{
|
||||
struct namebuf *np;
|
||||
const char *cp;
|
||||
int c;
|
||||
u_int hval;
|
||||
struct hashbuf *htp;
|
||||
struct namebuf *parent = NULL;
|
||||
int escaped = 0;
|
||||
|
||||
htp = *htpp;
|
||||
hval = 0;
|
||||
*fname = "???";
|
||||
for (cp = name; (c = *cp++) != 0; (void)NULL) {
|
||||
if (!escaped && (c == '.')) {
|
||||
parent = np = nlookup(cp, htpp, fname, insert);
|
||||
if (np == NULL)
|
||||
return (NULL);
|
||||
if (*fname != cp)
|
||||
return (np);
|
||||
if ((htp = np->n_hash) == NULL) {
|
||||
if (!insert) {
|
||||
if (ns_wildcard(NAME(*np)))
|
||||
*fname = name;
|
||||
return (np);
|
||||
}
|
||||
htp = savehash((struct hashbuf *)NULL);
|
||||
np->n_hash = htp;
|
||||
}
|
||||
*htpp = htp;
|
||||
break;
|
||||
}
|
||||
|
||||
/* rotate left HASHSHIFT */
|
||||
hval = (hval << HASHSHIFT) |
|
||||
(hval>>((sizeof(hval)*8)-HASHSHIFT));
|
||||
hval += ((isascii(c) && isupper(c)) ? tolower(c) : c)
|
||||
& HASHMASK;
|
||||
if (escaped)
|
||||
escaped = 0;
|
||||
else if (c == '\\')
|
||||
escaped = 1;
|
||||
}
|
||||
cp--;
|
||||
/*
|
||||
* Lookup this label in current hash table.
|
||||
*/
|
||||
for (np = htp->h_tab[hval % htp->h_size];
|
||||
np != NULL;
|
||||
np = np->n_next) {
|
||||
if (np->n_hashval == hval &&
|
||||
((size_t)NAMELEN(*np) == (size_t)(cp - name)) &&
|
||||
(strncasecmp(name, NAME(*np), cp - name) == 0)) {
|
||||
*fname = name;
|
||||
return (np);
|
||||
}
|
||||
}
|
||||
if (!insert) {
|
||||
/*
|
||||
* Look for wildcard in this hash table.
|
||||
* Don't use a cached "*" name as a wildcard,
|
||||
* only authoritative.
|
||||
*/
|
||||
hval = ('*' & HASHMASK) % htp->h_size;
|
||||
for (np = htp->h_tab[hval]; np != NULL; np = np->n_next) {
|
||||
if (ns_wildcard(NAME(*np)) &&
|
||||
np->n_data && np->n_data->d_zone != 0) {
|
||||
*fname = name;
|
||||
return (np);
|
||||
}
|
||||
}
|
||||
return (parent);
|
||||
}
|
||||
np = savename(name, cp - name);
|
||||
np->n_parent = parent;
|
||||
np->n_hashval = hval;
|
||||
hval %= htp->h_size;
|
||||
np->n_next = htp->h_tab[hval];
|
||||
htp->h_tab[hval] = np;
|
||||
/* Increase hash table size. */
|
||||
if (++htp->h_cnt > htp->h_size * 2) {
|
||||
*htpp = savehash(htp);
|
||||
if (parent == NULL) {
|
||||
if (htp == hashtab) {
|
||||
hashtab = *htpp;
|
||||
} else {
|
||||
fcachetab = *htpp;
|
||||
}
|
||||
}
|
||||
else
|
||||
parent->n_hash = *htpp;
|
||||
htp = *htpp;
|
||||
}
|
||||
*fname = name;
|
||||
return (np);
|
||||
}
|
||||
|
||||
/* struct namebuf *
|
||||
* np_parent(struct namebuf *np)
|
||||
* Find the "parent" namebuf of np.
|
||||
* This is tricky since the parent of "com" is "" and both are stored
|
||||
* in the same hashbuf.
|
||||
* See also:
|
||||
* the AXFR wart description in ns_req.c
|
||||
*/
|
||||
struct namebuf *
|
||||
np_parent(np)
|
||||
struct namebuf *np;
|
||||
{
|
||||
struct hashbuf *htp;
|
||||
struct namebuf *np2;
|
||||
|
||||
if (np->n_parent != NULL || NAME(*np)[0] == '\0')
|
||||
return (np->n_parent);
|
||||
|
||||
/* Try to figure out if np is pointing into the cache or hints. */
|
||||
/* Try the cache first. */
|
||||
htp = hashtab;
|
||||
try_again:
|
||||
/* Search the hash chain that np should be part of. */
|
||||
for (np2 = htp->h_tab[np->n_hashval % htp->h_size];
|
||||
np2 != NULL;
|
||||
np2 = np2->n_next) {
|
||||
|
||||
if (np == np2) { /* found it! */
|
||||
/* "" hashes into the first bucket */
|
||||
for (np = htp->h_tab[0]; np ; np=np->n_next) {
|
||||
if (NAME(*np)[0] == '\0')
|
||||
/* found the root namebuf */
|
||||
return (np);
|
||||
}
|
||||
ns_debug(ns_log_db, 1,
|
||||
"np_parent(0x%lx) couldn't find root entry",
|
||||
(u_long) np);
|
||||
return (NULL); /* XXX shouldn't happen */
|
||||
}
|
||||
}
|
||||
/* Try the hints. */
|
||||
if (htp == hashtab) {
|
||||
htp = fcachetab;
|
||||
goto try_again;
|
||||
}
|
||||
ns_debug(ns_log_db, 1, "np_parent(0x%lx) couldn't namebuf",
|
||||
(u_long)np);
|
||||
return (NULL); /* XXX shouldn't happen */
|
||||
}
|
||||
|
||||
/* int
|
||||
* match(dp, class, type)
|
||||
* Does data record `dp' match the class and type?
|
||||
* return value:
|
||||
* boolean
|
||||
*/
|
||||
int
|
||||
match(struct databuf *dp, int class, int type) {
|
||||
if (dp->d_class != class && class != C_ANY)
|
||||
return (0);
|
||||
if (dp->d_type != type && type != T_ANY)
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
221
contrib/bind/bin/named/db_save.c
Normal file
221
contrib/bind/bin/named/db_save.c
Normal file
|
|
@ -0,0 +1,221 @@
|
|||
#if !defined(lint) && !defined(SABER)
|
||||
static char sccsid[] = "@(#)db_save.c 4.16 (Berkeley) 3/21/91";
|
||||
static char rcsid[] = "$Id: db_save.c,v 8.15 1998/01/26 22:40:08 halley Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1986
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* 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, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1996, 1997 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Buffer allocation and deallocation routines.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
#include <isc/memcluster.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
|
||||
/*
|
||||
* Allocate a name buffer & save name.
|
||||
*/
|
||||
struct namebuf *
|
||||
savename(const char *name, int len) {
|
||||
struct namebuf *np;
|
||||
|
||||
/*
|
||||
* Note that MAXLABEL * 4 < 256, so a single length byte is enough.
|
||||
* Also, we use MAXLABEL * 4 because each label character can
|
||||
* expand into up to four characters when rendered in canonical
|
||||
* form.
|
||||
*/
|
||||
INSIST(len >= 0 && len <= (MAXLABEL * 4));
|
||||
np = (struct namebuf *) memget(NAMESIZE(len));
|
||||
if (np == NULL)
|
||||
panic("savename: memget", NULL);
|
||||
memset(np, 0, NAMESIZE(len));
|
||||
NAMELEN(*np) = (unsigned)len;
|
||||
memcpy(NAME(*np), name, len);
|
||||
NAME(*np)[len] = '\0';
|
||||
return (np);
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate a data buffer & save data.
|
||||
*/
|
||||
struct databuf *
|
||||
savedata(class, type, ttl, data, size)
|
||||
int class, type;
|
||||
u_int32_t ttl;
|
||||
u_char *data;
|
||||
int size;
|
||||
{
|
||||
struct databuf *dp;
|
||||
int bytes = (type == T_NS) ? DATASIZE(size)+INT32SZ : DATASIZE(size);
|
||||
|
||||
dp = (struct databuf *)memget(bytes);
|
||||
if (dp == NULL)
|
||||
panic("savedata: memget", NULL);
|
||||
memset(dp, 0, bytes);
|
||||
dp->d_next = NULL;
|
||||
dp->d_type = type;
|
||||
dp->d_class = class;
|
||||
dp->d_ttl = ttl;
|
||||
dp->d_size = size;
|
||||
dp->d_mark = 0;
|
||||
dp->d_flags = 0;
|
||||
dp->d_cred = 0;
|
||||
dp->d_clev = 0;
|
||||
dp->d_rcode = NOERROR;
|
||||
dp->d_ns = NULL;
|
||||
dp->d_nstime = 0;
|
||||
memcpy(dp->d_data, data, dp->d_size);
|
||||
return (dp);
|
||||
}
|
||||
|
||||
int hashsizes[] = { /* hashtable sizes */
|
||||
2,
|
||||
11,
|
||||
113,
|
||||
337,
|
||||
977,
|
||||
2053,
|
||||
4073,
|
||||
8011,
|
||||
16001,
|
||||
99887,
|
||||
0
|
||||
};
|
||||
|
||||
/*
|
||||
* Allocate a data buffer & save data.
|
||||
*/
|
||||
struct hashbuf *
|
||||
savehash(oldhtp)
|
||||
struct hashbuf *oldhtp;
|
||||
{
|
||||
struct hashbuf *htp;
|
||||
struct namebuf *np, *nnp, **hp;
|
||||
int n, newsize;
|
||||
|
||||
if (oldhtp == NULL)
|
||||
newsize = hashsizes[0];
|
||||
else {
|
||||
for (n = 0; (newsize = hashsizes[n++]) != 0; (void)NULL)
|
||||
if (oldhtp->h_size == newsize) {
|
||||
newsize = hashsizes[n];
|
||||
break;
|
||||
}
|
||||
if (newsize == 0)
|
||||
newsize = oldhtp->h_size * 2 + 1;
|
||||
}
|
||||
ns_debug(ns_log_db, 4, "savehash GROWING to %d", newsize);
|
||||
htp = (struct hashbuf *) memget(HASHSIZE(newsize));
|
||||
if (htp == NULL)
|
||||
ns_panic(ns_log_db, 0, "savehash: %s", strerror(errno));
|
||||
htp->h_size = newsize;
|
||||
memset(htp->h_tab, 0, newsize * sizeof(struct namebuf *));
|
||||
if (oldhtp == NULL) {
|
||||
htp->h_cnt = 0;
|
||||
return (htp);
|
||||
}
|
||||
ns_debug(ns_log_db, 4, "savehash(%#lx) cnt=%d, sz=%d, newsz=%d",
|
||||
(u_long)oldhtp, oldhtp->h_cnt, oldhtp->h_size, newsize);
|
||||
htp->h_cnt = oldhtp->h_cnt;
|
||||
for (n = 0; n < oldhtp->h_size; n++) {
|
||||
for (np = oldhtp->h_tab[n]; np != NULL; np = nnp) {
|
||||
nnp = np->n_next;
|
||||
hp = &htp->h_tab[np->n_hashval % htp->h_size];
|
||||
np->n_next = *hp;
|
||||
*hp = np;
|
||||
}
|
||||
}
|
||||
oldhtp->h_cnt = 0; /* Keep rm_hash() happy. */
|
||||
rm_hash(oldhtp);
|
||||
return (htp);
|
||||
}
|
||||
932
contrib/bind/bin/named/db_update.c
Normal file
932
contrib/bind/bin/named/db_update.c
Normal file
|
|
@ -0,0 +1,932 @@
|
|||
#if !defined(lint) && !defined(SABER)
|
||||
static char sccsid[] = "@(#)db_update.c 4.28 (Berkeley) 3/21/91";
|
||||
static char rcsid[] = "$Id: db_update.c,v 8.23 1998/02/13 20:01:38 halley Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1986, 1990
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* 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, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1996, 1997 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/nameser.h>
|
||||
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
|
||||
/* int
|
||||
* isRefByNS(name, htp)
|
||||
* recurse through all of `htp' looking for NS RR's that refer to `name'.
|
||||
* returns:
|
||||
* nonzero if at least one such NS RR exists
|
||||
* cautions:
|
||||
* this is very expensive; probably you only want to use on fcachetab.
|
||||
*/
|
||||
static int
|
||||
isRefByNS(const char *name, struct hashbuf *htp) {
|
||||
struct namebuf *np;
|
||||
struct databuf *dp;
|
||||
|
||||
for (np = htp->h_tab[0]; np != NULL; np = np->n_next) {
|
||||
for (dp = np->n_data; dp != NULL; dp = dp->d_next) {
|
||||
if ((dp->d_class == C_ANY ||
|
||||
dp->d_class == C_IN ||
|
||||
dp->d_class == C_HS) &&
|
||||
dp->d_type == T_NS &&
|
||||
!dp->d_rcode &&
|
||||
!strcasecmp(name, (char *)dp->d_data)) {
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
if (np->n_hash && isRefByNS(name, np->n_hash))
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* int
|
||||
* findMyZone(struct namebuf *np, int class)
|
||||
* surf the zone cuts and find this zone the hard way
|
||||
* return value:
|
||||
* zone number or DB_Z_CACHE if it's outside a zone
|
||||
* interesting cases:
|
||||
* DEC.COM SOA (primary)
|
||||
* CRL.DEC.COM NS (in primary)
|
||||
* if you start at CRL.. here, you find the DEC.COM zone
|
||||
* if you start at NS.CRL.. here, you're in the cache
|
||||
* DEC.COM SOA (primary)
|
||||
* CRL.DEC.COM NS (in primary)
|
||||
* CRL.DEC.COM SOA (secondary)
|
||||
* CRL.DEC.COM NS (in secondary)
|
||||
* if you start at CRL.. here, you find the CRL.DEC.COM zone
|
||||
* if you start at NS.CRL.. here, you're in the CRL.. zone
|
||||
*/
|
||||
int
|
||||
findMyZone(struct namebuf *np, int class) {
|
||||
for ((void)NULL; np; np = np_parent(np)) {
|
||||
struct databuf *dp;
|
||||
|
||||
/* if we encounter an SOA, we're in its zone (which can be
|
||||
* the cache or an authoritative zone, depending).
|
||||
*/
|
||||
for (dp = np->n_data; dp; dp = dp->d_next)
|
||||
if (match(dp, class, T_SOA))
|
||||
return (dp->d_zone);
|
||||
|
||||
/* if we find an NS at some node without having seen an SOA
|
||||
* (above), then we're out in the cache somewhere.
|
||||
*/
|
||||
for (dp = np->n_data; dp; dp = dp->d_next)
|
||||
if (match(dp, class, T_NS))
|
||||
return (DB_Z_CACHE);
|
||||
}
|
||||
|
||||
/* getting all the way to the root without finding an NS or SOA
|
||||
* probably means that we are in deep dip, but we'll treat it as
|
||||
* being in the cache. (XXX?)
|
||||
*/
|
||||
return (DB_Z_CACHE);
|
||||
}
|
||||
|
||||
|
||||
#define ISVALIDGLUE(xdp) ((xdp)->d_type == T_NS || (xdp)->d_type == T_A \
|
||||
|| (xdp)->d_type == T_AAAA)
|
||||
|
||||
/* int
|
||||
* db_update(name, odp, newdp, savedpp, flags, htp, from)
|
||||
* update data base node at `name'. `flags' controls the action.
|
||||
* side effects:
|
||||
* inverse query tables modified, if we're using them.
|
||||
* return value:
|
||||
* OK - success
|
||||
* NONAME - name doesn't exist
|
||||
* AUTH - you can't do that
|
||||
* DATAEXISTS - there's something there and DB_NODATA was specified
|
||||
* NODATA - there's no data, and (DB_DELETE or DB_MEXIST) was spec'd
|
||||
*
|
||||
* Policy: How to add data if one more RR is -ve data
|
||||
*
|
||||
* NEND NOERROR_NODATA
|
||||
* NXD NXDOMAIN
|
||||
*
|
||||
* match
|
||||
* old
|
||||
* Data NEND NXD
|
||||
* Data Merge Data Data
|
||||
* new NEND NEND NEND NEND
|
||||
* NXD NXD NXD NXD
|
||||
*
|
||||
* no match
|
||||
* old
|
||||
* Data NEND NXD
|
||||
* Data Merge Merge Data
|
||||
* new NEND Merge Merge NEND
|
||||
* NXD NXD NXD NXD
|
||||
*
|
||||
*/
|
||||
/* XXX: this code calls nlookup, which can create namebuf's. if this code
|
||||
* has to exit with a fatal error, it should scan from the new np upward
|
||||
* and for each node which has no children and no data it should remove
|
||||
* the namebuf. design notes: (1) there's no harm in doing this even if
|
||||
* success occurred; (2) stopping on the first nonremovable np is optimal;
|
||||
* the code for removal should be taken out of clean_cache() and made
|
||||
* general enough for this use, and for clean_cache()'s continued use.
|
||||
* vix, 21jul94
|
||||
*/
|
||||
int
|
||||
db_update(const char *name,
|
||||
struct databuf *odp, struct databuf *newdp,
|
||||
struct databuf **savedpp,
|
||||
int flags, struct hashbuf *htp, struct sockaddr_in from)
|
||||
{
|
||||
struct databuf *dp, *pdp;
|
||||
struct namebuf *np;
|
||||
int zn, isHintNS;
|
||||
int check_ttl = 0;
|
||||
const char *fname;
|
||||
#ifdef BIND_UPDATE
|
||||
int i, found_other_ns = 0;
|
||||
struct databuf *tmpdp;
|
||||
u_char *cp1, *cp2;
|
||||
u_int32_t dp_serial, newdp_serial;
|
||||
#endif
|
||||
|
||||
ns_debug(ns_log_db, 3, "db_update(%s, %#x, %#x, %#x, 0%o, %#x)%s",
|
||||
name, odp, newdp, savedpp, flags, htp,
|
||||
(odp && (odp->d_flags&DB_F_HINT)) ? " hint" : "");
|
||||
np = nlookup(name, &htp, &fname, newdp != NULL);
|
||||
if (np == NULL || fname != name)
|
||||
return (NONAME);
|
||||
|
||||
if (newdp && zones[newdp->d_zone].z_type == Z_PRIMARY)
|
||||
check_ttl = 1;
|
||||
|
||||
/* don't let nonauthoritative updates write in authority zones */
|
||||
if (newdp && ((zn = findMyZone(np, newdp->d_class)) != DB_Z_CACHE) &&
|
||||
#ifdef STUBS
|
||||
(zones[zn].z_type != Z_STUB) &&
|
||||
#endif
|
||||
(flags & DB_NOTAUTH)) {
|
||||
int foundRR = 0;
|
||||
|
||||
/*
|
||||
* Don't generate the warning if the update
|
||||
* would have been harmless (identical data).
|
||||
*/
|
||||
for (dp = np->n_data; dp != NULL; dp = dp->d_next) {
|
||||
if (!db_cmp(dp, newdp)) {
|
||||
foundRR++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!foundRR)
|
||||
ns_debug(ns_log_db, 5,
|
||||
"[%s].%d update? to auth zone \"%s\" (%s)",
|
||||
inet_ntoa(from.sin_addr),
|
||||
ntohs(from.sin_port),
|
||||
zones[zn].z_origin,
|
||||
name);
|
||||
return (AUTH);
|
||||
}
|
||||
|
||||
if (newdp && zn && !(flags & DB_NOTAUTH)) {
|
||||
if (nlabels(zones[zn].z_origin) > newdp->d_clev) {
|
||||
ns_debug(ns_log_db, 5,
|
||||
"attempted update child zone %s, %s",
|
||||
zones[zn].z_origin, name);
|
||||
return (AUTH);
|
||||
}
|
||||
}
|
||||
|
||||
/* some special checks for root NS' A RR's */
|
||||
isHintNS = isRefByNS(name, fcachetab);
|
||||
#ifdef DEPRECATED
|
||||
if (newdp && isHintNS && newdp->d_type == T_A) {
|
||||
/* upgrade credibility of additional data for rootsrv addrs */
|
||||
if (newdp->d_cred == DB_C_ADDITIONAL) {
|
||||
ns_debug(ns_log_db, 3,
|
||||
"upgrading credibility for A RR (%s)",
|
||||
name);
|
||||
/* XXX: should copy NS RR's, but we really just want
|
||||
* to prevent deprecation later so this will do.
|
||||
*/
|
||||
newdp->d_cred = DB_C_ANSWER;
|
||||
newdp->d_clev = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Reflect certain updates in hint cache also... */
|
||||
/* Don't stick data we are authoritative for in hints. */
|
||||
if (!(flags & DB_NOHINTS) &&
|
||||
(flags & DB_PRIMING) &&
|
||||
(odp != NULL) &&
|
||||
(htp != fcachetab) &&
|
||||
(DB_Z_SPECIAL(odp->d_zone)) &&
|
||||
!(odp->d_flags & DB_F_HINT) &&
|
||||
(!newdp || !newdp->d_rcode) &&
|
||||
((name[0] == '\0' && odp->d_type == T_NS) ||
|
||||
(odp->d_type == T_A && isHintNS)
|
||||
)
|
||||
)
|
||||
{
|
||||
ns_debug(ns_log_db, 3, "db_update: hint '%s' %u",
|
||||
name, odp->d_ttl);
|
||||
dp = savedata(odp->d_class, odp->d_type, odp->d_ttl,
|
||||
odp->d_data, odp->d_size);
|
||||
dp->d_zone = DB_Z_CACHE;
|
||||
dp->d_flags = DB_F_HINT;
|
||||
dp->d_cred = DB_C_CACHE;
|
||||
dp->d_clev = 0;
|
||||
if (db_update(name,
|
||||
dp, dp, NULL,
|
||||
(flags|DB_NOHINTS),
|
||||
fcachetab, from)
|
||||
!= OK) {
|
||||
ns_debug(ns_log_db, 3,
|
||||
"db_update: hint %#x freed", dp);
|
||||
db_freedata(dp);
|
||||
}
|
||||
}
|
||||
|
||||
if (odp != NULL) {
|
||||
int foundRR = 0;
|
||||
|
||||
pdp = NULL;
|
||||
for (dp = np->n_data; dp != NULL; ) {
|
||||
if (!match(dp, odp->d_class, odp->d_type)) {
|
||||
/* {class,type} doesn't match. these are
|
||||
* the aggregation cases.
|
||||
*/
|
||||
/* Check that CNAMEs are only accompanied by
|
||||
* Secure DNS RR's (KEY, SIG, and NXT).
|
||||
*/
|
||||
if (((dp->d_type == T_CNAME &&
|
||||
odp->d_type != T_KEY &&
|
||||
odp->d_type != T_SIG &&
|
||||
odp->d_type != T_NXT) ||
|
||||
(odp->d_type == T_CNAME &&
|
||||
dp->d_type != T_KEY &&
|
||||
dp->d_type != T_SIG &&
|
||||
dp->d_type != T_NXT)) &&
|
||||
odp->d_class == dp->d_class &&
|
||||
/* XXXRTH d_mark removed in 4.9.5,
|
||||
but still here for dynamic
|
||||
update */
|
||||
odp->d_mark == dp->d_mark &&
|
||||
!dp->d_rcode &&
|
||||
!odp->d_rcode &&
|
||||
#ifdef BIND_UPDATE
|
||||
/* updating a CNAME with another CNAME is permitted */
|
||||
(dp->d_type != T_CNAME ||
|
||||
odp->d_type != T_CNAME) &&
|
||||
#endif
|
||||
zones[odp->d_zone].z_type != Z_CACHE) {
|
||||
ns_info(ns_log_db,
|
||||
"%s has CNAME and other data (invalid)",
|
||||
name);
|
||||
goto skip;
|
||||
}
|
||||
if (!newdp || newdp->d_class != dp->d_class)
|
||||
goto skip;
|
||||
|
||||
/* if the new data is authorative
|
||||
* remove any data for this domain with
|
||||
* the same class that isn't as credable
|
||||
*/
|
||||
if (newdp->d_cred == DB_C_ZONE &&
|
||||
newdp->d_cred > dp->d_cred)
|
||||
/* better credibility and the old datum
|
||||
* was not from a zone file. remove
|
||||
* the old datum.
|
||||
*/
|
||||
goto delete;
|
||||
|
||||
#if 0 /* caught by findMyZone() now. */
|
||||
/* if we have authoritative data for a
|
||||
* node, don't add in other data.
|
||||
*/
|
||||
if (dp->d_cred == DB_C_ZONE &&
|
||||
newdp->d_cred < dp->d_cred)
|
||||
return (AUTH);
|
||||
#endif
|
||||
|
||||
/* if the new data is authoritative but
|
||||
* but isn't as credible, reject it.
|
||||
*/
|
||||
if (newdp->d_cred == DB_C_ZONE &&
|
||||
dp->d_cred == DB_C_ZONE) {
|
||||
/* Both records are from a zone file.
|
||||
* If their credibility levels differ,
|
||||
* we're dealing with a zone cut. The
|
||||
* record with lower clev is from the
|
||||
* upper zone's file and is therefore
|
||||
* glue.
|
||||
*/
|
||||
if (newdp->d_clev < dp->d_clev) {
|
||||
if (!ISVALIDGLUE(newdp)) {
|
||||
ns_info(ns_log_db,
|
||||
"domain %s %s record in zone %s should be in zone %s, ignored",
|
||||
name, p_type(newdp->d_type),
|
||||
zones[newdp->d_zone].z_origin,
|
||||
zones[dp->d_zone].z_origin);
|
||||
}
|
||||
return (AUTH);
|
||||
}
|
||||
if (newdp->d_clev > dp->d_clev) {
|
||||
if (!ISVALIDGLUE(dp)) {
|
||||
ns_info(ns_log_db,
|
||||
"domain %s %s record in zone %s should be in zone %s, deleted",
|
||||
name, p_type(dp->d_type),
|
||||
zones[dp->d_zone].z_origin,
|
||||
zones[newdp->d_zone].z_origin);
|
||||
}
|
||||
goto delete;
|
||||
}
|
||||
}
|
||||
|
||||
/* process NXDOMAIN */
|
||||
/* policy */
|
||||
if (newdp->d_rcode == NXDOMAIN) {
|
||||
if (dp->d_cred < DB_C_AUTH)
|
||||
goto delete;
|
||||
else
|
||||
return (DATAEXISTS);
|
||||
}
|
||||
|
||||
if (dp->d_rcode == NXDOMAIN)
|
||||
goto delete;
|
||||
|
||||
/* process NOERROR_NODATA */
|
||||
/* NO PROCESSING REQUIRED */
|
||||
|
||||
goto skip;
|
||||
} /*if {class,type} did not match*/
|
||||
|
||||
/*
|
||||
* {type,class} did match. This is the replace case.
|
||||
*/
|
||||
ns_debug(ns_log_db, 5,
|
||||
"db_update: flags = %#x, sizes = %d, %d (cmp %d)",
|
||||
flags, odp->d_size, dp->d_size,
|
||||
db_cmp(dp, odp));
|
||||
if (newdp) {
|
||||
ns_debug(ns_log_db, 4,
|
||||
"credibility for %s is %d(%d) from [%s].%d, is %d(%d) in cache",
|
||||
*name ? name : ".",
|
||||
newdp->d_cred,
|
||||
newdp->d_clev,
|
||||
inet_ntoa(from.sin_addr),
|
||||
ntohs(from.sin_port),
|
||||
dp->d_cred,
|
||||
dp->d_clev);
|
||||
if (newdp->d_cred > dp->d_cred) {
|
||||
/* better credibility.
|
||||
* remove the old datum.
|
||||
*/
|
||||
goto delete;
|
||||
}
|
||||
if (newdp->d_cred < dp->d_cred) {
|
||||
/* credibility is worse. ignore it. */
|
||||
return (AUTH);
|
||||
}
|
||||
if (newdp->d_cred == DB_C_ZONE &&
|
||||
dp->d_cred == DB_C_ZONE ) {
|
||||
/* Both records are from a zone file.
|
||||
* If their credibility levels differ,
|
||||
* we're dealing with a zone cut. The
|
||||
* record with lower clev is from the
|
||||
* upper zone's file and is therefore
|
||||
* glue.
|
||||
*/
|
||||
|
||||
/* XXX - Tricky situation here is you
|
||||
* have 2 zones a.b.c and sub.a.b.c
|
||||
* being served by the same server.
|
||||
* named will send NS records for
|
||||
* sub.a.b.c during zone transfer of
|
||||
* a.b.c zone. If we're secondary for
|
||||
* both zones, and we reload zone
|
||||
* a.b.c, we'll get the NS records
|
||||
* (and possibly A records to go with
|
||||
* them?) for sub.a.b.c as part of the
|
||||
* a.b.c zone transfer. But we've
|
||||
* already got a more credible record
|
||||
* from the sub.a.b.c zone. So we want
|
||||
* to ignore the new record, but we
|
||||
* shouldn't syslog because there's
|
||||
* nothing the user can do to prevent
|
||||
* the situation. Perhaps we should
|
||||
* only complain when we are primary?
|
||||
*/
|
||||
|
||||
if (newdp->d_clev < dp->d_clev) {
|
||||
if (!ISVALIDGLUE(newdp)) {
|
||||
ns_info(ns_log_db,
|
||||
"domain %s %s record in zone %s should be in zone %s, ignored",
|
||||
name, p_type(newdp->d_type),
|
||||
zones[newdp->d_zone].z_origin,
|
||||
zones[dp->d_zone].z_origin);
|
||||
}
|
||||
return (AUTH);
|
||||
}
|
||||
if (newdp->d_clev > dp->d_clev) {
|
||||
if (!ISVALIDGLUE(dp)) {
|
||||
ns_info(ns_log_db,
|
||||
"domain %s %s record in zone %s should be in zone %s, deleted",
|
||||
name, p_type(dp->d_type),
|
||||
zones[dp->d_zone].z_origin,
|
||||
zones[newdp->d_zone].z_origin);
|
||||
}
|
||||
goto delete;
|
||||
}
|
||||
}
|
||||
|
||||
/* credibility is the same.
|
||||
* let it aggregate in the normal way.
|
||||
*/
|
||||
|
||||
/*
|
||||
* if the new or old RR is -ve, delete old.
|
||||
*/
|
||||
if (dp->d_rcode || newdp->d_rcode) {
|
||||
/* XXX: how can a zone rr be neg? */
|
||||
if (dp->d_cred != DB_C_ZONE)
|
||||
goto delete;
|
||||
else
|
||||
return (DATAEXISTS);
|
||||
}
|
||||
|
||||
/*
|
||||
* Some RR types should not be aggregated.
|
||||
*/
|
||||
if (dp->d_type == T_SOA) {
|
||||
#ifdef BIND_UPDATE
|
||||
u_int32_t dp_ser, ndp_ser;
|
||||
u_char *dp_cp, *ndp_cp;
|
||||
|
||||
dp_cp = findsoaserial(dp->d_data);
|
||||
ndp_cp = findsoaserial(newdp->d_data);
|
||||
GETLONG(dp_ser, dp_cp);
|
||||
GETLONG(ndp_ser, ndp_cp);
|
||||
|
||||
if (SEQ_GT(ndp_ser, dp_ser))
|
||||
goto delete;
|
||||
else
|
||||
return (SERIAL);
|
||||
#else
|
||||
goto delete;
|
||||
#endif /*BIND_UPDATE*/
|
||||
}
|
||||
if (dp->d_type == T_WKS &&
|
||||
!memcmp(dp->d_data, newdp->d_data,
|
||||
INT32SZ + sizeof(u_char)))
|
||||
goto delete;
|
||||
if (dp->d_type == T_CNAME &&
|
||||
!NS_OPTION_P(OPTION_MULTIPLE_CNAMES))
|
||||
goto delete;
|
||||
#ifdef BIND_UPDATE
|
||||
if (dp->d_type == T_SIG)
|
||||
/*
|
||||
* Type covered has already been
|
||||
* checked.
|
||||
*/
|
||||
goto delete;
|
||||
#endif
|
||||
if (check_ttl) {
|
||||
if (newdp->d_ttl != dp->d_ttl)
|
||||
ns_warning(ns_log_db,
|
||||
"%s %s %s differing ttls: corrected",
|
||||
name[0]?name:".",
|
||||
p_class(dp->d_class),
|
||||
p_type(dp->d_type));
|
||||
if (newdp->d_ttl > dp->d_ttl) {
|
||||
newdp->d_ttl = dp->d_ttl;
|
||||
} else {
|
||||
dp->d_ttl = newdp->d_ttl;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((flags & DB_NODATA) && !db_cmp(dp, odp)) {
|
||||
/* Refresh ttl if cache entry. */
|
||||
if (dp->d_zone == DB_Z_CACHE) {
|
||||
if (odp->d_zone != DB_Z_CACHE) {
|
||||
/* Changing cache->auth. */
|
||||
dp->d_zone = odp->d_zone;
|
||||
dp->d_ttl = odp->d_ttl;
|
||||
ns_debug(ns_log_db, 4,
|
||||
"db_update: cache entry now in auth zone");
|
||||
return (DATAEXISTS);
|
||||
}
|
||||
fixttl(odp);
|
||||
if (odp->d_ttl > dp->d_ttl)
|
||||
dp->d_ttl = odp->d_ttl;
|
||||
ns_debug(ns_log_db, 3,
|
||||
"db_update: new ttl %u +%lu",
|
||||
dp->d_ttl,
|
||||
(u_long)(dp->d_ttl - tt.tv_sec)
|
||||
);
|
||||
}
|
||||
return (DATAEXISTS);
|
||||
}
|
||||
/*
|
||||
* If the old databuf has some data, check that the
|
||||
* data matches that in the new databuf.
|
||||
*/
|
||||
if (odp->d_size > 0)
|
||||
if (db_cmp(dp, odp))
|
||||
goto skip;
|
||||
if (odp->d_clev < dp->d_clev)
|
||||
goto skip;
|
||||
if (odp->d_cred < dp->d_cred)
|
||||
goto skip;
|
||||
#ifdef BIND_UPDATE
|
||||
if (!strcasecmp(name, zones[dp->d_zone].z_origin) &&
|
||||
!newdp) {
|
||||
/* do not delete SOA or NS records as a set */
|
||||
/* XXXRTH isn't testing d_size unnecessary? */
|
||||
if ((odp->d_size == 0) &&
|
||||
(odp->d_class == C_ANY) &&
|
||||
(odp->d_type == T_ANY ||
|
||||
odp->d_type == T_SOA ||
|
||||
odp->d_type == T_NS) &&
|
||||
(dp->d_type == T_SOA ||
|
||||
dp->d_type == T_NS))
|
||||
goto skip;
|
||||
/* XXXRTH I added this to prevent SOA deletion
|
||||
I'm using the same style of comparison as
|
||||
the other code in this section. Do we
|
||||
really need to look at dp->d_type here?
|
||||
We're in the "match" section... */
|
||||
if ((odp->d_type == T_SOA) &&
|
||||
(dp->d_type == T_SOA))
|
||||
goto skip;
|
||||
/* do not delete the last NS record
|
||||
for the zone */
|
||||
if ((odp->d_type == T_NS) &&
|
||||
(dp->d_type == T_NS)) {
|
||||
found_other_ns = 0;
|
||||
for (tmpdp = np->n_data;
|
||||
tmpdp && !found_other_ns;
|
||||
tmpdp = tmpdp->d_next)
|
||||
if ((tmpdp->d_type == T_NS) &&
|
||||
(tmpdp != dp))
|
||||
found_other_ns = 1;
|
||||
if (!found_other_ns) {
|
||||
ns_debug(ns_log_db, 3,
|
||||
"cannot delete last remaining NS record for zone %s",
|
||||
name);
|
||||
goto skip;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
foundRR = 1;
|
||||
if (flags & DB_DELETE) {
|
||||
delete:
|
||||
#ifdef BIND_UPDATE
|
||||
/*
|
||||
* XXX assume here that savedpp!=NULL iff. db_update
|
||||
* has been called by the dyanmic update code.
|
||||
* Maybe a new flag is more appropriate?
|
||||
*/
|
||||
if (savedpp != NULL)
|
||||
foundRR = 1;
|
||||
#endif
|
||||
dp = rm_datum(dp, np, pdp, savedpp);
|
||||
} else {
|
||||
skip: pdp = dp;
|
||||
dp = dp->d_next;
|
||||
}
|
||||
}
|
||||
if (!foundRR) {
|
||||
if (flags & DB_DELETE)
|
||||
return (NODATA);
|
||||
if (flags & DB_MEXIST)
|
||||
return (NODATA);
|
||||
}
|
||||
}
|
||||
/* XXX: delete a terminal namebuf also if all databuf's
|
||||
* underneath of it have been deleted) */
|
||||
if (newdp == NULL)
|
||||
return (OK);
|
||||
/* XXX: empty nodes bypass credibility checks above; should check
|
||||
* response source address here if flags&NOTAUTH.
|
||||
*/
|
||||
fixttl(newdp);
|
||||
ns_debug(ns_log_db, 3, "db_update: adding%s %#x",
|
||||
(newdp->d_flags&DB_F_HINT) ? " hint":"", newdp);
|
||||
|
||||
if (NS_OPTION_P(OPTION_HOSTSTATS) &&
|
||||
newdp->d_zone == DB_Z_CACHE &&
|
||||
(newdp->d_flags & DB_F_HINT) == 0)
|
||||
newdp->d_ns = nameserFind(from.sin_addr, NS_F_INSERT);
|
||||
|
||||
/* Add to end of list, generally preserving order */
|
||||
newdp->d_next = NULL;
|
||||
if ((dp = np->n_data) == NULL) {
|
||||
DRCNTINC(newdp);
|
||||
if (newdp->d_flags & DB_F_ACTIVE)
|
||||
panic("db_update: DB_F_ACTIVE set", NULL);
|
||||
newdp->d_flags |= DB_F_ACTIVE;
|
||||
np->n_data = newdp;
|
||||
return (OK);
|
||||
}
|
||||
while (dp->d_next != NULL) {
|
||||
if ((flags & DB_NODATA) && !db_cmp(dp, newdp))
|
||||
return (DATAEXISTS);
|
||||
dp = dp->d_next;
|
||||
}
|
||||
if ((flags & DB_NODATA) && !db_cmp(dp, newdp))
|
||||
return (DATAEXISTS);
|
||||
DRCNTINC(newdp);
|
||||
if (newdp->d_flags & DB_F_ACTIVE)
|
||||
panic("db_update: DB_F_ACTIVE set", NULL);
|
||||
newdp->d_flags |= DB_F_ACTIVE;
|
||||
dp->d_next = newdp;
|
||||
return (OK);
|
||||
}
|
||||
|
||||
void
|
||||
fixttl(struct databuf *dp) {
|
||||
if (dp->d_zone == DB_Z_CACHE && (dp->d_flags & DB_F_HINT) == 0) {
|
||||
if (dp->d_ttl <= (u_int32_t)tt.tv_sec)
|
||||
return;
|
||||
else if (dp->d_ttl < (u_int32_t)tt.tv_sec+min_cache_ttl)
|
||||
dp->d_ttl = (u_int32_t)tt.tv_sec+min_cache_ttl;
|
||||
else if (dp->d_ttl > (u_int32_t)tt.tv_sec+max_cache_ttl)
|
||||
dp->d_ttl = (u_int32_t)tt.tv_sec+max_cache_ttl;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Compare type, class and data from databufs for equivalence.
|
||||
* All domain names in RR's must be compared case-insensitively.
|
||||
* Return 0 if equivalent, nonzero otherwise.
|
||||
*/
|
||||
int
|
||||
db_cmp(const struct databuf *dp1, const struct databuf *dp2) {
|
||||
const u_char *cp1, *cp2;
|
||||
int len, len2;
|
||||
|
||||
/* XXXDYNUP- should be changed to
|
||||
if (!match(dp1, dp2->d_type, dp2->d_class) */
|
||||
if (dp1->d_type != dp2->d_type || dp1->d_class != dp2->d_class)
|
||||
return (1);
|
||||
/* XXXDYNUP - should be changed to (dp1->d_size != dp2->d_size &&
|
||||
dp1->d_size != 0 && dp2->d_size != 0) */
|
||||
if (dp1->d_size != dp2->d_size)
|
||||
return (1);
|
||||
/* d_mark is only used for dynamic updates currently */
|
||||
#ifndef BIND_UPDATE
|
||||
if (dp1->d_mark != dp2->d_mark)
|
||||
return (1); /* old and new RR's are distinct */
|
||||
#endif
|
||||
if (dp1->d_rcode && dp2->d_rcode)
|
||||
return ((dp1->d_rcode == dp1->d_rcode)?0:1);
|
||||
if (dp1->d_rcode || dp2->d_rcode)
|
||||
return (1);
|
||||
|
||||
switch (dp1->d_type) {
|
||||
|
||||
case T_A:
|
||||
case T_WKS:
|
||||
case T_NULL:
|
||||
case T_NSAP:
|
||||
case T_AAAA:
|
||||
case T_LOC:
|
||||
case T_KEY:
|
||||
/* Only binary data */
|
||||
return (memcmp(dp1->d_data, dp2->d_data, dp1->d_size));
|
||||
|
||||
case T_NS:
|
||||
case T_CNAME:
|
||||
case T_PTR:
|
||||
case T_MB:
|
||||
case T_MG:
|
||||
case T_MR:
|
||||
/* Only a domain name */
|
||||
return (strcasecmp((char *)dp1->d_data, (char *)dp2->d_data));
|
||||
|
||||
case T_SIG:
|
||||
/* Binary data, a domain name, more binary data */
|
||||
if (dp1->d_size < NS_SIG_SIGNER)
|
||||
return (1);
|
||||
if (memcmp(dp1->d_data, dp2->d_data, NS_SIG_SIGNER))
|
||||
return (1);
|
||||
len = NS_SIG_SIGNER +
|
||||
strlen((char *)dp1->d_data + NS_SIG_SIGNER);
|
||||
if (strcasecmp((char *)dp1->d_data + NS_SIG_SIGNER,
|
||||
(char *)dp2->d_data + NS_SIG_SIGNER))
|
||||
return (1);
|
||||
return (memcmp(dp1->d_data + len,
|
||||
dp2->d_data + len,
|
||||
dp1->d_size - len));
|
||||
|
||||
case T_NXT:
|
||||
/* First a domain name, then binary data */
|
||||
if (strcasecmp((char *)dp1->d_data, (char *)dp2->d_data))
|
||||
return (1);
|
||||
len = strlen((char *)dp1->d_data)+1;
|
||||
return (memcmp(dp1->d_data + len,
|
||||
dp2->d_data + len,
|
||||
dp1->d_size - len));
|
||||
|
||||
case T_HINFO:
|
||||
case T_ISDN:
|
||||
cp1 = dp1->d_data;
|
||||
cp2 = dp2->d_data;
|
||||
len = *cp1;
|
||||
len2 = *cp2;
|
||||
if (len != len2)
|
||||
return (1);
|
||||
if (strncasecmp((char *)++cp1, (char *)++cp2, len))
|
||||
return (1);
|
||||
cp1 += len;
|
||||
cp2 += len;
|
||||
len = *cp1;
|
||||
len2 = *cp2;
|
||||
if (len != len2)
|
||||
return (1);
|
||||
return (strncasecmp((char *)++cp1, (char *)++cp2, len));
|
||||
|
||||
case T_SOA:
|
||||
case T_MINFO:
|
||||
case T_RP:
|
||||
if (strcasecmp((char *)dp1->d_data, (char *)dp2->d_data))
|
||||
return (1);
|
||||
cp1 = dp1->d_data + strlen((char *)dp1->d_data) + 1;
|
||||
cp2 = dp2->d_data + strlen((char *)dp2->d_data) + 1;
|
||||
if (dp1->d_type != T_SOA)
|
||||
return (strcasecmp((char *)cp1, (char *)cp2));
|
||||
if (strcasecmp((char *)cp1, (char *)cp2))
|
||||
return (1);
|
||||
cp1 += strlen((char *)cp1) + 1;
|
||||
cp2 += strlen((char *)cp2) + 1;
|
||||
return (memcmp(cp1, cp2, INT32SZ * 5));
|
||||
|
||||
case T_NAPTR: {
|
||||
int t1,t2;
|
||||
|
||||
if (dp1->d_size != dp2->d_size)
|
||||
return (1);
|
||||
cp1 = dp1->d_data;
|
||||
cp2 = dp2->d_data;
|
||||
|
||||
/* Order */
|
||||
if (*cp1++ != *cp2++ || *cp1++ != *cp2++)
|
||||
return (1);
|
||||
|
||||
/* Preference */
|
||||
if (*cp1++ != *cp2++ || *cp1++ != *cp2++)
|
||||
return (1);
|
||||
|
||||
/* Flags */
|
||||
t1 = *cp1++; t2 = *cp2++;
|
||||
if (t1 != t2 || memcmp(cp1, cp2, t1))
|
||||
return (1);
|
||||
cp1 += t1; cp2 += t2;
|
||||
|
||||
/* Services */
|
||||
t1 = *cp1++; t2 = *cp2++;
|
||||
if (t1 != t2 || memcmp(cp1, cp2, t1))
|
||||
return (1);
|
||||
cp1 += t1; cp2 += t2;
|
||||
|
||||
/* Regexp */
|
||||
t1 = *cp1++; t2 = *cp2++;
|
||||
if (t1 != t2 || memcmp(cp1, cp2, t1))
|
||||
return (1);
|
||||
cp1 += t1; cp2 += t2;
|
||||
|
||||
/* Replacement */
|
||||
t1 = strlen((char *)cp1); t2 = strlen((char *)cp2);
|
||||
if (t1 != t2 || memcmp(cp1, cp2, t1))
|
||||
return (1);
|
||||
cp1 += t1 + 1; cp2 += t2 + 1;
|
||||
|
||||
/* they all checked out! */
|
||||
return (0);
|
||||
}
|
||||
|
||||
case T_MX:
|
||||
case T_AFSDB:
|
||||
case T_RT:
|
||||
case T_SRV:
|
||||
cp1 = dp1->d_data;
|
||||
cp2 = dp2->d_data;
|
||||
if (*cp1++ != *cp2++ || *cp1++ != *cp2++) /* cmp prio */
|
||||
return (1);
|
||||
if (dp1->d_type == T_SRV) {
|
||||
if (*cp1++ != *cp2++ || *cp1++ != *cp2++) /* weight */
|
||||
return (1);
|
||||
if (*cp1++ != *cp2++ || *cp1++ != *cp2++) /* port */
|
||||
return (1);
|
||||
}
|
||||
return (strcasecmp((char *)cp1, (char *)cp2));
|
||||
|
||||
case T_PX:
|
||||
cp1 = dp1->d_data;
|
||||
cp2 = dp2->d_data;
|
||||
if (*cp1++ != *cp2++ || *cp1++ != *cp2++) /* cmp prio */
|
||||
return (1);
|
||||
if (strcasecmp((char *)cp1, (char *)cp2))
|
||||
return (1);
|
||||
cp1 += strlen((char *)cp1) + 1;
|
||||
cp2 += strlen((char *)cp2) + 1;
|
||||
return (strcasecmp((char *)cp1, (char *)cp2));
|
||||
|
||||
case T_TXT:
|
||||
case T_X25:
|
||||
if (dp1->d_size != dp2->d_size)
|
||||
return (1);
|
||||
return (memcmp(dp1->d_data, dp2->d_data, dp1->d_size));
|
||||
|
||||
default:
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
324
contrib/bind/bin/named/named-bootconf.pl
Executable file
324
contrib/bind/bin/named/named-bootconf.pl
Executable file
|
|
@ -0,0 +1,324 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
## Copyright (c) 1996, 1997 by Internet Software Consortium
|
||||
##
|
||||
## 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
## $Id: named-bootconf.pl,v 8.16 1998/02/13 19:48:25 halley Exp $
|
||||
|
||||
# This is a filter. Input is a named.boot. Output is a named.conf.
|
||||
|
||||
$new_config = "";
|
||||
|
||||
$have_options = 0;
|
||||
%options = ();
|
||||
%options_comments = ();
|
||||
@topology = ();
|
||||
@topology_comments = ();
|
||||
@bogus = ();
|
||||
@bogus_comments = ();
|
||||
@transfer_acl = ();
|
||||
@transfer_comments = ();
|
||||
$logging = "";
|
||||
|
||||
while(<>) {
|
||||
next if /^$/;
|
||||
|
||||
# skip comment-only lines
|
||||
if (/^\s*;+\s*(.*)$/) {
|
||||
$new_config .= "// $1\n";
|
||||
next;
|
||||
}
|
||||
|
||||
# handle continued lines
|
||||
while (/\\$/) {
|
||||
s/\\$/ /;
|
||||
$_ .= <>;
|
||||
}
|
||||
|
||||
chop;
|
||||
|
||||
# deal with lines ending in a coment
|
||||
if (s/\s*;+\s*(.*)$//) {
|
||||
$comment = "// $1";
|
||||
} else {
|
||||
$comment = "";
|
||||
}
|
||||
|
||||
($directive, @rest) = split;
|
||||
|
||||
$class = "";
|
||||
if ($directive =~ /^(.*)\/(.*)$/) {
|
||||
$directive = $1;
|
||||
$class = $2;
|
||||
}
|
||||
|
||||
if ($directive eq "primary") {
|
||||
$zname = shift(@rest);
|
||||
&maybe_print_comment("","\n");
|
||||
$new_config .= "zone \"$zname\" ";
|
||||
if ($class ne "") {
|
||||
$new_config .= "$class ";
|
||||
}
|
||||
$new_config .= "{\n";
|
||||
$new_config .= "\ttype master;\n";
|
||||
$filename = shift(@rest);
|
||||
$new_config .= "\tfile \"$filename\";\n";
|
||||
$new_config .= "};\n\n";
|
||||
} elsif ($directive eq "secondary" || $directive eq "stub") {
|
||||
if ($directive eq "secondary") {
|
||||
$type = "slave";
|
||||
} else {
|
||||
$type = "stub";
|
||||
}
|
||||
$zname = shift(@rest);
|
||||
&maybe_print_comment("","\n");
|
||||
$new_config .= "zone \"$zname\" ";
|
||||
if ($class ne "") {
|
||||
$new_config .= "$class ";
|
||||
}
|
||||
$new_config .= "{\n";
|
||||
$new_config .= "\ttype $type;\n";
|
||||
$filename = pop(@rest);
|
||||
if ($filename =~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/) {
|
||||
push(@rest, $filename);
|
||||
$filename = "";
|
||||
} else {
|
||||
$new_config .= "\tfile \"$filename\";\n";
|
||||
}
|
||||
$new_config .= "\tmasters {\n";
|
||||
foreach $master (@rest) {
|
||||
$new_config .= "\t\t$master;\n";
|
||||
}
|
||||
$new_config .= "\t};\n";
|
||||
$new_config .= "};\n\n";
|
||||
} elsif ($directive eq "cache") {
|
||||
$zname = shift(@rest);
|
||||
&maybe_print_comment("","\n");
|
||||
$new_config .= "zone \"$zname\" {\n";
|
||||
$new_config .= "\ttype hint;\n";
|
||||
$filename = shift(@rest);
|
||||
$new_config .= "\tfile \"$filename\";\n";
|
||||
$new_config .= "};\n\n";
|
||||
} elsif ($directive eq "directory") {
|
||||
$options{"directory"} = "\"$rest[0]\"";
|
||||
$options_comments{"directory"} = $comment;
|
||||
$have_options = 1;
|
||||
} elsif ($directive eq "check-names") {
|
||||
$type = shift(@rest);
|
||||
if ($type eq "primary") {
|
||||
$type = "master";
|
||||
} elsif ($type eq "secondary") {
|
||||
$type = "slave";
|
||||
}
|
||||
$action = shift(@rest);
|
||||
$options{"check-names $type"} = $action;
|
||||
$options_comments{"check-names $type"} = $comment;
|
||||
$have_options = 1;
|
||||
} elsif ($directive eq "forwarders") {
|
||||
$options{"forwarders"}="{\n";
|
||||
foreach $forwarder (@rest) {
|
||||
$options{"forwarders"} .= "\t\t$forwarder;\n";
|
||||
}
|
||||
$options{"forwarders"} .= "\t}";
|
||||
$options_comments{"forwarders"} = $comment;
|
||||
$have_options = 1;
|
||||
} elsif ($directive eq "slave") {
|
||||
&handle_options("forward-only");
|
||||
} elsif ($directive eq "options") {
|
||||
&handle_options(@rest);
|
||||
} elsif ($directive eq "limit") {
|
||||
&handle_limit(@rest);
|
||||
} elsif ($directive eq "include") {
|
||||
$new_config .=
|
||||
"// make sure your include is still in the right place\n";
|
||||
$comment = "\t" . $comment;
|
||||
$new_config .= "include \"$rest[0]\";$comment\n\n";
|
||||
} elsif ($directive eq "xfrnets" || $directive eq "tcplist") {
|
||||
if ($comment ne "") {
|
||||
$comment = "\t$comment";
|
||||
}
|
||||
foreach $elt (@rest) {
|
||||
push(@transfer_acl, $elt);
|
||||
push(@transfer_comments, $comment);
|
||||
}
|
||||
$have_options = 1;
|
||||
} elsif ($directive eq "sortlist") {
|
||||
if ($comment ne "") {
|
||||
$comment = "\t$comment";
|
||||
}
|
||||
foreach $elt (@rest) {
|
||||
push(@topology, $elt);
|
||||
push(@topology_comments, $comment);
|
||||
}
|
||||
} elsif ($directive eq "bogusns") {
|
||||
if ($comment ne "") {
|
||||
$comment = "\t$comment";
|
||||
}
|
||||
foreach $elt (@rest) {
|
||||
push(@bogus, $elt);
|
||||
push(@bogus_comments, $comment);
|
||||
}
|
||||
} elsif ($directive eq "max-fetch") {
|
||||
$options{"transfers-in"}=$rest[0];
|
||||
$options_comments{"transfers-in"}=$comment;
|
||||
$have_options = 1;
|
||||
} else {
|
||||
$new_config .= "// NOTE: unconverted directive '$directive @rest'\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
print "// generated by named-bootconf.pl\n\n";
|
||||
if ($have_options) {
|
||||
print "options {\n";
|
||||
foreach $option (sort(keys(%options))) {
|
||||
print "\t$option $options{$option};";
|
||||
if ($options_comments{$option} ne "") {
|
||||
print "\t$options_comments{$option}";
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
if (@transfer_acl > 0) {
|
||||
print "\tallow-transfer {\n";
|
||||
for ($i = 0; $i <= $#transfer_acl; $i++) {
|
||||
&print_maybe_masked("\t\t", $transfer_acl[$i],
|
||||
$transfer_comments[$i]);
|
||||
}
|
||||
print "\t};\n";
|
||||
}
|
||||
print "\t/*
|
||||
\t * If there is a firewall between you and nameservers you want
|
||||
\t * to talk to, you might need to uncomment the query-source
|
||||
\t * directive below. Previous versions of BIND always asked
|
||||
\t * questions using port 53, but BIND 8.1 uses an unprivileged
|
||||
\t * port by default.
|
||||
\t */
|
||||
\t// query-source address * port 53;
|
||||
";
|
||||
|
||||
print "};\n\n";
|
||||
}
|
||||
if ($logging ne "") {
|
||||
print "logging {\n$logging};\n\n";
|
||||
}
|
||||
if (@topology > 0) {
|
||||
print "// Note: the following will be supported in a future release.\n";
|
||||
print "/*\n";
|
||||
print "host { any; } {\n\ttopology {\n";
|
||||
for ($i = 0; $i <= $#topology; $i++) {
|
||||
&print_maybe_masked("\t\t", $topology[$i],
|
||||
$topology_comments[$i]);
|
||||
}
|
||||
print "\t};\n};\n";
|
||||
print "*/\n";
|
||||
print "\n";
|
||||
}
|
||||
if (@bogus > 0) {
|
||||
for ($i = 0; $i <= $#bogus; $i++) {
|
||||
print "server $bogus[$i] { bogus yes; };$bogus_comments[$i]\n";
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
print $new_config;
|
||||
|
||||
exit 0;
|
||||
|
||||
sub maybe_print_comment {
|
||||
$prefix = shift;
|
||||
$suffix = shift;
|
||||
if ($comment ne "") {
|
||||
$new_config .= sprintf("%s%s%s", $prefix, $comment, $suffix);
|
||||
}
|
||||
}
|
||||
|
||||
sub handle_options {
|
||||
foreach $option (@_) {
|
||||
if ($option eq "forward-only") {
|
||||
$options{"forward"}="only";
|
||||
$options_comments{"forward"}=$comment;
|
||||
$have_options = 1;
|
||||
} elsif ($option eq "no-recursion") {
|
||||
$options{"recursion"}="no";
|
||||
$options_comments{"recursion"}=$comment;
|
||||
$have_options = 1;
|
||||
} elsif ($option eq "no-fetch-glue") {
|
||||
$options{"fetch-glue"}="no";
|
||||
$options_comments{"fetch-glue"}=$comment;
|
||||
$have_options = 1;
|
||||
} elsif ($option eq "fake-iquery") {
|
||||
$options{"fake-iquery"}="yes";
|
||||
$options_comments{"fake-iquery"}=$comment;
|
||||
$have_options = 1;
|
||||
} elsif ($option eq "query-log") {
|
||||
if ($comment ne "") {
|
||||
$logging .= "\t$comment\n";
|
||||
}
|
||||
$logging .= "\tcategory queries { default_syslog; };\n";
|
||||
} else {
|
||||
$options{"// NOTE: unconverted option '$option'"}="";
|
||||
$options_comments{"// NOTE: unconverted option '$option'"}=
|
||||
$comment;
|
||||
$have_options = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub handle_limit {
|
||||
$limit = shift;
|
||||
if ($limit eq "datasize" || $limit eq "transfers-in"
|
||||
|| $limit eq "transfers-per-ns" || $limit eq "files") {
|
||||
$options{$limit}=$_[0];
|
||||
$options_comments{$limit}=$comment;
|
||||
$have_options = 1;
|
||||
} else {
|
||||
$options{"// NOTE: unconverted limit '$limit @_'"}="";
|
||||
$options_comments{"// NOTE: unconverted limit '$limit @_'"}=$comment;
|
||||
$have_options = 1;
|
||||
}
|
||||
}
|
||||
|
||||
sub print_maybe_masked {
|
||||
# this assumes a contiguous netmask starting at the MSB
|
||||
$prefix = shift;
|
||||
$elt = shift;
|
||||
$elt_comment = shift;
|
||||
if ($elt =~ /^(.*)&(.*)$/) {
|
||||
$address = $1;
|
||||
$mask = $2;
|
||||
($m1,$m2,$m3,$m4) = split(/\./, $mask);
|
||||
$mask_val = ($m1 << 24) + ($m2 << 16) +($m3 << 8) + $m4;
|
||||
$zero_bits = 0;
|
||||
while (($mask_val % 2) == 0) {
|
||||
$mask_val /= 2;
|
||||
$zero_bits++;
|
||||
}
|
||||
$mask_bits = 32 - $zero_bits;
|
||||
} else {
|
||||
$address = $elt;
|
||||
($a1,$a2,$a3,$a4) = split(/\./, $address);
|
||||
if ($a1 < 128) {
|
||||
$mask_bits = 8;
|
||||
} elsif ($a1 < 192) {
|
||||
$mask_bits = 16;
|
||||
} else {
|
||||
$mask_bits = 24;
|
||||
}
|
||||
}
|
||||
|
||||
print "$prefix$address";
|
||||
if ($mask_bits != 32) {
|
||||
print "/$mask_bits";
|
||||
}
|
||||
print ";$elt_comment\n";
|
||||
}
|
||||
426
contrib/bind/bin/named/named.conf
Normal file
426
contrib/bind/bin/named/named.conf
Normal file
|
|
@ -0,0 +1,426 @@
|
|||
/*
|
||||
* This is a worthless, nonrunnable example of a named.conf file that has
|
||||
* every conceivable syntax element in use. We use it to test the parser.
|
||||
* It could also be used as a conceptual template for users of new features.
|
||||
*/
|
||||
|
||||
/*
|
||||
* C-style comments are OK
|
||||
*/
|
||||
|
||||
// So are C++-style comments
|
||||
|
||||
# So are shell-style comments
|
||||
|
||||
// watch out for ";" -- it's important!
|
||||
|
||||
options {
|
||||
directory "."; // use current directory
|
||||
named-xfer "/usr/libexec/named-xfer"; // _PATH_XFER
|
||||
dump-file "named_dump.db"; // _PATH_DUMPFILE
|
||||
pid-file "/var/run/named.pid"; // _PATH_PIDFILE
|
||||
statistics-file "named.stats"; // _PATH_STATS
|
||||
memstatistics-file "named.memstats"; // _PATH_MEMSTATS
|
||||
check-names master fail;
|
||||
check-names slave warn;
|
||||
check-names response ignore;
|
||||
host-statistics yes;
|
||||
deallocate-on-exit no; // Painstakingly deallocate all
|
||||
// objects when exiting instead of
|
||||
// letting the OS clean up for us.
|
||||
// Useful a memory leak is suspected.
|
||||
// Final statistics are written to the
|
||||
// memstatistics-file.
|
||||
datasize default;
|
||||
stacksize default;
|
||||
coresize default;
|
||||
files unlimited;
|
||||
recursion yes;
|
||||
fetch-glue yes;
|
||||
fake-iquery no;
|
||||
notify yes; // send NOTIFY messages. You can set
|
||||
// notify on a zone-by-zone
|
||||
// basis in the "zone" statement
|
||||
// see (below)
|
||||
auth-nxdomain yes; // always set AA on NXDOMAIN.
|
||||
// don't set this to 'no' unless
|
||||
// you know what you're doing -- older
|
||||
// servers won't like it.
|
||||
multiple-cnames no; // if yes, then a name my have more
|
||||
// than one CNAME RR. This use
|
||||
// is non-standard and is not
|
||||
// recommended, but it is available
|
||||
// because previous releases supported
|
||||
// it and it was used by large sites
|
||||
// for load balancing.
|
||||
allow-query { any; };
|
||||
allow-transfer { any; };
|
||||
transfers-in 10; // DEFAULT_XFERS_RUNNING, cannot be
|
||||
// set > than MAX_XFERS_RUNNING (20)
|
||||
transfers-per-ns 2; // DEFAULT_XFERS_PER_NS
|
||||
transfers-out 0; // not implemented
|
||||
max-transfer-time-in 120; // MAX_XFER_TIME; the default number
|
||||
// of minutes an inbound zone transfer
|
||||
// may run. May be set on a per-zone
|
||||
// basis.
|
||||
/*
|
||||
* The "transfer-format" option specifies the way outbound zone
|
||||
* transfers (i.e. from us to them) are formatted. Two values are
|
||||
* allowed:
|
||||
*
|
||||
* one-answer Each RR gets its own DNS message.
|
||||
* This format is not very efficient,
|
||||
* but is widely understood. All
|
||||
* versions of BIND prior to 8.1 generate
|
||||
* this format for outbound zone
|
||||
* and require it on inbound transfers.
|
||||
*
|
||||
* many-answers As many RRs as will fit are put into
|
||||
* each DNS message. This format is
|
||||
* the most efficient, but is only known
|
||||
* to work with BIND 8. Patches to
|
||||
* BIND 4.9.5 named-xfer that enable it
|
||||
* to understand 'many-answers' will be
|
||||
* available.
|
||||
*
|
||||
* If you are going to be doing zone transfers to older servers, you
|
||||
* shouldn't use 'many-answers'. 'transfer-format' may also be set
|
||||
* on a host-by-host basis using the 'server' statement (see below).
|
||||
*/
|
||||
transfer-format one-answer;
|
||||
query-source address * port *;
|
||||
/*
|
||||
* The "forward" option is only meaningful if you've defined
|
||||
* forwarders. "first" gives the normal BIND
|
||||
* forwarding behavior, i.e. ask the forwarders first, and if that
|
||||
* doesn't work then do the full lookup. You can also say
|
||||
* "forward only;" which is what used to be specified with
|
||||
* "slave" or "options forward-only". "only" will never attempt
|
||||
* a full lookup; only the forwarders will be used.
|
||||
*/
|
||||
forward first;
|
||||
forwarders { }; // default is no forwarders
|
||||
/*
|
||||
* Here's a forwarders example that isn't trivial
|
||||
*/
|
||||
/*
|
||||
forwarders {
|
||||
1.2.3.4;
|
||||
5.6.7.8;
|
||||
};
|
||||
*/
|
||||
topology { localhost; localnets; }; // prefer local nameservers
|
||||
/*
|
||||
* Here's a more complicated topology example; it's commented out
|
||||
* because only one topology block is allowed.
|
||||
*
|
||||
topology {
|
||||
10/8; // prefer network 10.0.0.0
|
||||
// netmask 255.0.0.0 most
|
||||
!1.2.3/24; // don't like 1.2.3.0 netmask
|
||||
// 255.255.255.0 at all
|
||||
{ 1.2/16; 3/8; }; // like 1.2.0.0 netmask 255.255.0.0
|
||||
// and 3.0.0.0 netmask 255.0.0.0
|
||||
// equally well, but less than 10/8
|
||||
};
|
||||
*/
|
||||
|
||||
listen-on port 53 { any; }; // listen for queries on port 53 on
|
||||
// any interface on the system
|
||||
// (i.e. all interfaces). The
|
||||
// "port 53" is optional; if you
|
||||
// don't specify a port, port 53
|
||||
// is assumed.
|
||||
/*
|
||||
* Multiple listen-on statements are allowed. Here's a more
|
||||
* complicated example:
|
||||
*/
|
||||
/*
|
||||
listen-on { 5.6.7.8; }; // listen on port 53 on interface
|
||||
// 5.6.7.8
|
||||
listen-on port 1234 { // listen on port 1234 on any
|
||||
!1.2.3.4; // interface on network 1.2.3
|
||||
1.2.3/24; // netmask 255.255.255.0, except for
|
||||
}; // interface 1.2.3.4.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Interval Timers
|
||||
*/
|
||||
cleaning-interval 60; // clean the cache of expired RRs
|
||||
// every 'cleaning-interval' minutes
|
||||
interface-interval 60; // scan for new or deleted interfaces
|
||||
// every 'interface-interval' minutes
|
||||
statistics-interval 60; // log statistics every
|
||||
// 'statistics-interval' minutes
|
||||
};
|
||||
|
||||
zone "master.demo.zone" {
|
||||
type master; // what used to be called "primary"
|
||||
file "master.demo.zone";
|
||||
check-names fail;
|
||||
allow-update { none; };
|
||||
allow-transfer { any; };
|
||||
allow-query { any; };
|
||||
// notify yes; // send NOTIFY messages for this
|
||||
// zone? The global option is used
|
||||
// if "notify" is not specified
|
||||
// here.
|
||||
also-notify { }; // don't notify any nameservers other
|
||||
// than those on the NS list for this
|
||||
// zone
|
||||
};
|
||||
|
||||
zone "slave.demo.zone" {
|
||||
type slave; // what used to be called "secondary"
|
||||
file "slave.demo.zone";
|
||||
masters {
|
||||
1.2.3.4; // where to zone transfer from
|
||||
5.6.7.8;
|
||||
};
|
||||
transfer-source 10.0.0.53; // fixes multihoming problems
|
||||
check-names warn;
|
||||
allow-update { none; };
|
||||
allow-transfer { any; };
|
||||
allow-query { any; };
|
||||
max-transfer-time-in 120; // if not set, global option is used.
|
||||
also-notify { }; // don't notify any nameservers other
|
||||
// than those on the NS list for this
|
||||
// zone
|
||||
};
|
||||
|
||||
zone "stub.demo.zone" {
|
||||
type stub; // stub zones are like slave zones,
|
||||
// except that only the NS records
|
||||
// are transferred.
|
||||
file "stub.demo.zone";
|
||||
masters {
|
||||
1.2.3.4; // where to zone transfer from
|
||||
5.6.7.8;
|
||||
};
|
||||
check-names warn;
|
||||
allow-update { none; };
|
||||
allow-transfer { any; };
|
||||
allow-query { any; };
|
||||
max-transfer-time-in 120; // if not set, global option is used.
|
||||
};
|
||||
|
||||
zone "." {
|
||||
type hint; // used to be specified w/ "cache"
|
||||
file "cache.db";
|
||||
};
|
||||
|
||||
acl can_query { !1.2.3/24; any; }; // network 1.2.3.0 mask 255.255.255.0
|
||||
// is disallowed; rest are OK
|
||||
acl can_axfr { 1.2.3.4; can_query; }; // host 1.2.3.4 and any host allowed
|
||||
// by can_query are OK
|
||||
|
||||
zone "non-default-acl.demo.zone" {
|
||||
type master;
|
||||
file "foo";
|
||||
allow-query { can_query; };
|
||||
allow-transfer { can_axfr; };
|
||||
allow-update {
|
||||
1.2.3.4;
|
||||
5.6.7.8;
|
||||
};
|
||||
};
|
||||
|
||||
key sample_key { // for TSIG; supported by parser
|
||||
algorithm hmac-md5; // but not yet implemented in the
|
||||
secret "your secret here"; // rest of the server
|
||||
};
|
||||
|
||||
key key2 {
|
||||
algorithm hmac-md5;
|
||||
secret "ereh terces rouy";
|
||||
};
|
||||
|
||||
server 1.2.3.4 {
|
||||
bogus no; // if yes, we won't query or listen
|
||||
// to this server
|
||||
transfer-format one-answer; // set transfer format for this
|
||||
// server (see the description of
|
||||
// 'transfer-format' above)
|
||||
// if not specified, the global option
|
||||
// will be used
|
||||
transfers 0; // not implemented
|
||||
keys { sample_key; key2; }; // for TSIG; supported by the parser
|
||||
// but not yet implemented in the
|
||||
// rest of the server
|
||||
};
|
||||
|
||||
logging {
|
||||
/*
|
||||
* All log output goes to one or more "channels"; you can make as
|
||||
* many of them as you want.
|
||||
*/
|
||||
|
||||
channel syslog_errors { // this channel will send errors or
|
||||
syslog user; // or worse to syslog (user facility)
|
||||
severity error;
|
||||
};
|
||||
|
||||
/*
|
||||
* Channels have a severity level. Messages at severity levels
|
||||
* greater than or equal to the channel's level will be logged on
|
||||
* the channel. In order of decreasing severity, the levels are:
|
||||
*
|
||||
* critical a fatal error
|
||||
* error
|
||||
* warning
|
||||
* notice a normal, but significant event
|
||||
* info an informational message
|
||||
* debug 1 the least detailed debugging info
|
||||
* ...
|
||||
* debug 99 the most detailed debugging info
|
||||
*/
|
||||
|
||||
/*
|
||||
* Here are the built-in channels:
|
||||
*
|
||||
* channel default_syslog {
|
||||
* syslog daemon;
|
||||
* severity info;
|
||||
* };
|
||||
*
|
||||
* channel default_debug {
|
||||
* file "named.run";
|
||||
* severity dynamic; // this means log debugging
|
||||
* // at whatever debugging level
|
||||
* // the server is at, and don't
|
||||
* // log anything if not
|
||||
* // debugging
|
||||
* };
|
||||
*
|
||||
* channel null { // this is the bit bucket;
|
||||
* file "/dev/null"; // any logging to this channel
|
||||
* // is discarded.
|
||||
* };
|
||||
*
|
||||
* channel default_stderr { // writes to stderr
|
||||
* file "<stderr>"; // this is illustrative only;
|
||||
* // there's currently no way
|
||||
* // of saying "stderr" in the
|
||||
* // configuration language.
|
||||
* // i.e. don't try this at home.
|
||||
* severity info;
|
||||
* };
|
||||
*
|
||||
* default_stderr only works before the server daemonizes (i.e.
|
||||
* during initial startup) or when it is running in foreground
|
||||
* mode (-f command line option).
|
||||
*/
|
||||
|
||||
/*
|
||||
* There are many categories, so you can send the logs
|
||||
* you want to see wherever you want, without seeing logs you
|
||||
* don't want. Right now the categories are
|
||||
*
|
||||
* default the catch-all. many things still
|
||||
* aren't classified into categories, and
|
||||
* they all end up here. also, if you
|
||||
* don't specify any channels for a
|
||||
* category, the default category is used
|
||||
* instead.
|
||||
* config high-level configuration file
|
||||
* processing
|
||||
* parser low-level configuration file processing
|
||||
* queries what used to be called "query logging"
|
||||
* lame-servers messages like "Lame server on ..."
|
||||
* statistics
|
||||
* panic if the server has to shut itself
|
||||
* down due to an internal problem, it
|
||||
* logs the problem here (as well as
|
||||
* in the problem's native category)
|
||||
* update dynamic update
|
||||
* ncache negative caching
|
||||
* xfer-in zone transfers we're receiving
|
||||
* xfer-out zone transfers we're sending
|
||||
* db all database operations
|
||||
* eventlib debugging info from the event system
|
||||
* (see below)
|
||||
* packet dumps of packets received and sent
|
||||
* (see below)
|
||||
* notify the NOTIFY protocol
|
||||
* cname messages like "XX points to a CNAME"
|
||||
* security approved/unapproved requests
|
||||
* os operating system problems
|
||||
* insist consistency check failures
|
||||
* maintenance periodic maintenance
|
||||
* load zone loading
|
||||
* response-checks messages like
|
||||
* "Malformed response ..."
|
||||
* "wrong ans. name ..."
|
||||
* "unrelated additional info ..."
|
||||
* "invalid RR type ..."
|
||||
* "bad referral ..."
|
||||
*/
|
||||
|
||||
category parser {
|
||||
syslog_errors; // you can log to as many channels
|
||||
default_syslog; // as you want
|
||||
};
|
||||
|
||||
category lame-servers { null; }; // don't log these at all
|
||||
|
||||
channel moderate_debug {
|
||||
severity debug 3; // level 3 debugging to file
|
||||
file "foo"; // foo
|
||||
print-time yes; // timestamp log entries
|
||||
print-category yes; // print category name
|
||||
print-severity yes; // print severity level
|
||||
/*
|
||||
* Note that debugging must have been turned on either
|
||||
* on the command line or with a signal to get debugging
|
||||
* output (non-debugging output will still be written to
|
||||
* this channel).
|
||||
*/
|
||||
};
|
||||
|
||||
/*
|
||||
* If you don't want to see "zone XXXX loaded" messages but do
|
||||
* want to see any problems, you could do the following.
|
||||
*/
|
||||
channel no_info_messages {
|
||||
syslog;
|
||||
severity notice;
|
||||
};
|
||||
|
||||
category load { no_info_messages; };
|
||||
|
||||
/*
|
||||
* You can also define category "default"; it gets used when no
|
||||
* "category" statement has been given for a category.
|
||||
*/
|
||||
category default {
|
||||
default_syslog;
|
||||
moderate_debug;
|
||||
};
|
||||
|
||||
/*
|
||||
* If you don't define category default yourself, the default
|
||||
* default category will be used. It is
|
||||
*
|
||||
* category default { default_syslog; default_debug; };
|
||||
*/
|
||||
|
||||
/*
|
||||
* If you don't define category panic yourself, the default
|
||||
* panic category will be used. It is
|
||||
*
|
||||
* category panic { default_syslog; default_stderr; };
|
||||
*/
|
||||
|
||||
/*
|
||||
* Two categories, 'packet' and 'eventlib', are special. Only one
|
||||
* channel may be assigned to each of them, and it must be a
|
||||
* file channel. If you don't define them yourself, they default to
|
||||
*
|
||||
* category eventlib { default_debug; };
|
||||
*
|
||||
* category packet { default_debug; };
|
||||
*/
|
||||
};
|
||||
|
||||
include "filename"; // can't do within a statement
|
||||
68
contrib/bind/bin/named/named.h
Normal file
68
contrib/bind/bin/named/named.h
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 1997 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* $Id: named.h,v 8.12 1997/12/04 06:52:27 halley Exp $
|
||||
*/
|
||||
|
||||
/* Options. Leave these on. */
|
||||
#define DEBUG
|
||||
#define ADDAUTH
|
||||
#define STUBS
|
||||
#define RETURNSOA
|
||||
#define BOGUSNS
|
||||
#define TRACEROOT
|
||||
#define XFRNETS
|
||||
#define QRYLOG
|
||||
#define YPKLUDGE
|
||||
#define RENICE
|
||||
#define FORCED_RELOAD
|
||||
#define SLAVE_FORWARD
|
||||
#define BIND_UPDATE
|
||||
#define BIND_NOTIFY
|
||||
#define WANT_PIDFILE
|
||||
#define FWD_LOOP
|
||||
#define DOTTED_SERIAL
|
||||
#define SENSIBLE_DOTS
|
||||
#define ROUND_ROBIN
|
||||
#define SORT_RESPONSE
|
||||
#define DNS_SECURITY
|
||||
#undef RSAREF
|
||||
#undef BSAFE
|
||||
#define ALLOW_LONG_TXT_RDATA
|
||||
|
||||
#if 0
|
||||
#define strdup PLEASE_USE_SAVESTR
|
||||
#define malloc PLEASE_USE_DB_MEMGET
|
||||
#define calloc PLEASE_USE_DB_MEMGET
|
||||
#define realloc PLEASE_USE_DB_MEMGET
|
||||
#define free PLEASE_USE_DB_MEMPUT
|
||||
#endif
|
||||
|
||||
#include <isc/assertions.h>
|
||||
#include <isc/list.h>
|
||||
|
||||
#include "pathnames.h"
|
||||
|
||||
#include "ns_defs.h"
|
||||
#include "db_defs.h"
|
||||
|
||||
#include "ns_glob.h"
|
||||
#include "db_glob.h"
|
||||
|
||||
#include "ns_func.h"
|
||||
#include "db_func.h"
|
||||
2366
contrib/bind/bin/named/ns_config.c
Normal file
2366
contrib/bind/bin/named/ns_config.c
Normal file
File diff suppressed because it is too large
Load diff
756
contrib/bind/bin/named/ns_defs.h
Normal file
756
contrib/bind/bin/named/ns_defs.h
Normal file
|
|
@ -0,0 +1,756 @@
|
|||
/*
|
||||
* from ns.h 4.33 (Berkeley) 8/23/90
|
||||
* $Id: ns_defs.h,v 8.38 1998/03/17 03:22:27 halley Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1986
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* 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, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1996, 1997 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Global definitions for the name server.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Effort has been expended here to make all structure members 32 bits or
|
||||
* larger land on 32-bit boundaries; smaller structure members have been
|
||||
* deliberately shuffled and smaller integer sizes chosen where possible
|
||||
* to make sure this happens. This is all meant to avoid structure member
|
||||
* padding which can cost a _lot_ of memory when you have hundreds of
|
||||
* thousands of entries in your cache.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Timeout time should be around 1 minute or so. Using the
|
||||
* the current simplistic backoff strategy, the sequence
|
||||
* retrys after 4, 8, and 16 seconds. With 3 servers, this
|
||||
* dies out in a little more than a minute.
|
||||
* (sequence RETRYBASE, 2*RETRYBASE, 4*RETRYBASE... for MAXRETRY)
|
||||
*/
|
||||
#define MINROOTS 2 /* min number of root hints */
|
||||
#define NSMAX 16 /* max number of NS addrs to try ([0..255]) */
|
||||
#define RETRYBASE 4 /* base time between retries */
|
||||
#define MAXCLASS 255 /* XXX - may belong elsewhere */
|
||||
#define MAXRETRY 3 /* max number of retries per addr */
|
||||
#define MAXCNAMES 8 /* max # of CNAMES tried per addr */
|
||||
#define MAXQUERIES 20 /* max # of queries to be made */
|
||||
#define MAXQSERIAL 4 /* max # of outstanding QSERIAL's */
|
||||
/* (prevent "recursive" loops) */
|
||||
#define INIT_REFRESH 600 /* retry time for initial secondary */
|
||||
/* contact (10 minutes) */
|
||||
#define MIN_REFRESH 2 /* never refresh more frequently than once */
|
||||
/* every MIN_REFRESH seconds */
|
||||
#define MIN_RETRY 1 /* never retry more frequently than once */
|
||||
/* every MIN_RETRY seconds */
|
||||
#define NADDRECS 20 /* max addt'l rr's per resp */
|
||||
|
||||
#define XFER_TIMER 120 /* named-xfer's connect timeout */
|
||||
#define MAX_XFER_TIME 60*60*2 /* default max seconds for an xfer */
|
||||
#define XFER_TIME_FUDGE 10 /* MAX_XFER_TIME fudge */
|
||||
#define MAX_XFERS_RUNNING 20 /* max value of transfers_in */
|
||||
#define DEFAULT_XFERS_RUNNING 10 /* default value of transfers_in */
|
||||
#define DEFAULT_XFERS_PER_NS 2 /* default # of xfers per peer nameserver */
|
||||
#define XFER_BUFSIZE (16*1024) /* arbitrary but bigger than most MTU's */
|
||||
|
||||
#define ALPHA 0.7 /* How much to preserve of old response time */
|
||||
#define BETA 1.2 /* How much to penalize response time on failure */
|
||||
#define GAMMA 0.98 /* How much to decay unused response times */
|
||||
|
||||
/* What maintainance operations need to be performed sometime soon? */
|
||||
#define MAIN_NEED_RELOAD 0x0001 /* db_reload() needed. */
|
||||
#define MAIN_NEED_MAINT 0x0002 /* ns_maint() needed. */
|
||||
#define MAIN_NEED_ENDXFER 0x0004 /* endxfer() needed. */
|
||||
#define MAIN_NEED_ZONELOAD 0x0008 /* loadxfer() needed. */
|
||||
#define MAIN_NEED_DUMP 0x0010 /* doadump() needed. */
|
||||
#define MAIN_NEED_STATSDUMP 0x0020 /* ns_stats() needed. */
|
||||
#define MAIN_NEED_EXIT 0x0040 /* exit() needed. */
|
||||
#define MAIN_NEED_QRYLOG 0x0080 /* toggle_qrylog() needed. */
|
||||
#define MAIN_NEED_DEBUG 0x0100 /* use_desired_debug() needed. */
|
||||
#define MAIN_NEED_NOTIFY 0x0200 /* do_notify_after_load() needed */
|
||||
|
||||
/* What global options are set? */
|
||||
#define OPTION_NORECURSE 0x0001 /* Don't recurse even if asked. */
|
||||
#define OPTION_NOFETCHGLUE 0x0002 /* Don't fetch missing glue. */
|
||||
#define OPTION_FORWARD_ONLY 0x0004 /* Don't use NS RR's, just forward. */
|
||||
#define OPTION_FAKE_IQUERY 0x0008 /* Fake up bogus response to IQUERY. */
|
||||
#define OPTION_NONOTIFY 0x0010 /* Turn off notify */
|
||||
#define OPTION_NONAUTH_NXDOMAIN 0x0020 /* Generate non-auth NXDOMAINs? */
|
||||
#define OPTION_MULTIPLE_CNAMES 0x0040 /* Allow a name to have multiple
|
||||
* CNAME RRs */
|
||||
#define OPTION_HOSTSTATS 0x0080 /* Maintain per-host statistics? */
|
||||
#define OPTION_DEALLOC_ON_EXIT 0x0100 /* Deallocate everything on exit? */
|
||||
|
||||
#define DEFAULT_OPTION_FLAGS (OPTION_HOSTSTATS)
|
||||
|
||||
#ifdef BIND_UPDATE
|
||||
#define SOAINCRINTVL 300 /* default value for the time after which
|
||||
* the zone serial number must be incremented
|
||||
* after a successful update has occurred */
|
||||
#define DUMPINTVL 3600 /* default interval at which to dump changed zones
|
||||
* randomized, not exact */
|
||||
#define DEFERUPDCNT 100 /* default number of updates that can happen
|
||||
* before the zone serial number will be
|
||||
* incremented */
|
||||
#define UPDATE_TIMER XFER_TIMER
|
||||
#endif /* BIND_UPDATE */
|
||||
|
||||
#define USE_MINIMUM 0xffffffff
|
||||
#define MAXIMUM_TTL 0x7fffffff
|
||||
|
||||
#define CLEAN_TIMER 0x01
|
||||
#define INTERFACE_TIMER 0x02
|
||||
#define STATS_TIMER 0x04
|
||||
|
||||
/* IP address accessor, network byte order. */
|
||||
#define ina_ulong(ina) (ina.s_addr)
|
||||
|
||||
/* IP address accessor, host byte order, read only. */
|
||||
#define ina_hlong(ina) ntohl(ina.s_addr)
|
||||
|
||||
/* IP address equality. */
|
||||
/* XXX: assumes that network byte order won't affect equality. */
|
||||
#define ina_equal(a, b) (ina_ulong(a) == ina_ulong(b))
|
||||
|
||||
/* IP address equality with a mask. */
|
||||
#define ina_onnet(h, n, m) ((ina_ulong(h) & ina_ulong(m)) == ina_ulong(n))
|
||||
|
||||
/* Sequence space arithmetic. */
|
||||
#define SEQ_GT(a,b) ((int32_t)((a)-(b)) > 0)
|
||||
|
||||
#define NS_OPTION_P(option) ((server_options == NULL) ? \
|
||||
(panic(panic_msg_no_options, NULL), 0) : \
|
||||
((server_options->flags & option) != 0))
|
||||
|
||||
#define NS_INCRSTAT(addr, which) \
|
||||
do { \
|
||||
if ((int)which >= (int)nssLast) \
|
||||
ns_panic(ns_log_insist, 1, panic_msg_bad_which, \
|
||||
__FILE__, __LINE__, #which); \
|
||||
else { \
|
||||
if (NS_OPTION_P(OPTION_HOSTSTATS)) { \
|
||||
struct nameser *ns = \
|
||||
nameserFind(addr, NS_F_INSERT); \
|
||||
if (ns != NULL) \
|
||||
ns->stats[(int)which]++; \
|
||||
} \
|
||||
globalStats[(int)which]++; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
enum severity { ignore, warn, fail, not_set };
|
||||
|
||||
enum znotify { znotify_use_default=0, znotify_yes, znotify_no };
|
||||
|
||||
enum axfr_format { axfr_use_default=0, axfr_one_answer, axfr_many_answers };
|
||||
|
||||
struct ip_match_direct {
|
||||
struct in_addr address;
|
||||
struct in_addr mask;
|
||||
};
|
||||
|
||||
struct ip_match_indirect {
|
||||
struct ip_match_list *list;
|
||||
};
|
||||
|
||||
typedef enum { ip_match_pattern, ip_match_indirect, ip_match_localhost,
|
||||
ip_match_localnets } ip_match_type;
|
||||
|
||||
typedef struct ip_match_element {
|
||||
ip_match_type type;
|
||||
u_int flags;
|
||||
union {
|
||||
struct ip_match_direct direct;
|
||||
struct ip_match_indirect indirect;
|
||||
} u;
|
||||
struct ip_match_element *next;
|
||||
} *ip_match_element;
|
||||
|
||||
/* Flags for ip_match_element */
|
||||
#define IP_MATCH_NEGATE 0x01 /* match means deny access */
|
||||
|
||||
typedef struct ip_match_list {
|
||||
ip_match_element first;
|
||||
ip_match_element last;
|
||||
} *ip_match_list;
|
||||
|
||||
typedef struct ztimer_info {
|
||||
char *name;
|
||||
int class;
|
||||
int type;
|
||||
} *ztimer_info;
|
||||
|
||||
/* these fields are ordered to maintain word-alignment;
|
||||
* be careful about changing them.
|
||||
*/
|
||||
struct zoneinfo {
|
||||
char *z_origin; /* root domain name of zone */
|
||||
time_t z_time; /* time for next refresh */
|
||||
time_t z_lastupdate; /* time of last soa serial increment */
|
||||
u_int32_t z_refresh; /* refresh interval */
|
||||
u_int32_t z_retry; /* refresh retry interval */
|
||||
u_int32_t z_expire; /* expiration time for cached info */
|
||||
u_int32_t z_minimum; /* minimum TTL value */
|
||||
u_int32_t z_serial; /* changes if zone modified */
|
||||
char *z_source; /* source location of data */
|
||||
time_t z_ftime; /* modification time of source file */
|
||||
struct in_addr z_axfr_src; /* bind() the axfr socket to this */
|
||||
struct in_addr z_xaddr; /* override server for next xfer */
|
||||
struct in_addr z_addr[NSMAX]; /* list of master servers for zone */
|
||||
u_char z_addrcnt; /* number of entries in z_addr[] */
|
||||
u_char z_type; /* type of zone; see below */
|
||||
u_int16_t z_flags; /* state bits; see below */
|
||||
pid_t z_xferpid; /* xfer child pid */
|
||||
int z_class; /* class of zone */
|
||||
int z_numxfrs; /* Ref count of concurrent xfrs. */
|
||||
enum severity z_checknames; /* How to handle non-RFC-compliant names */
|
||||
#ifdef BIND_UPDATE
|
||||
time_t z_dumptime; /* randomized time for next zone dump
|
||||
* if Z_NEED_DUMP is set */
|
||||
u_int32_t z_dumpintvl; /* time interval between zone dumps */
|
||||
time_t z_soaincrintvl; /* interval for updating soa serial */
|
||||
time_t z_soaincrtime; /* time for soa increment */
|
||||
u_int32_t z_deferupdcnt; /* max number of updates before SOA
|
||||
* serial number incremented */
|
||||
u_int32_t z_updatecnt; /* number of update requests processed
|
||||
* since the last SOA serial update */
|
||||
char *z_updatelog; /* log file for updates */
|
||||
#endif
|
||||
ip_match_list z_update_acl; /* list of who can issue dynamic
|
||||
updates */
|
||||
ip_match_list z_query_acl; /* sites we'll answer questions for */
|
||||
ip_match_list z_transfer_acl; /* sites that may get a zone transfer
|
||||
from us */
|
||||
long z_max_transfer_time_in; /* max num seconds for AXFR */
|
||||
enum znotify z_notify; /* Notify mode */
|
||||
struct in_addr z_also_notify[NSMAX]; /* More nameservers to notify */
|
||||
int z_notify_count;
|
||||
evTimerID z_timer; /* maintenance timer */
|
||||
ztimer_info z_timerinfo; /* UAP associated with timer */
|
||||
time_t z_nextmaint; /* time of next maintenance */
|
||||
};
|
||||
|
||||
/* zone types (z_type) */
|
||||
enum zonetype { z_nil, z_master, z_slave, z_hint, z_stub, z_any };
|
||||
#define Z_NIL z_nil /* XXX */
|
||||
#define Z_MASTER z_master /* XXX */
|
||||
#define Z_PRIMARY z_master /* XXX */
|
||||
#define Z_SLAVE z_slave /* XXX */
|
||||
#define Z_SECONDARY z_slave /* XXX */
|
||||
#define Z_HINT z_hint /* XXX */
|
||||
#define Z_CACHE z_hint /* XXX */
|
||||
#define Z_STUB z_stub /* XXX */
|
||||
#define Z_ANY z_any /* XXX*2 */
|
||||
|
||||
/* zone state bits (16 bits) */
|
||||
#define Z_AUTH 0x0001 /* zone is authoritative */
|
||||
#define Z_NEED_XFER 0x0002 /* waiting to do xfer */
|
||||
#define Z_XFER_RUNNING 0x0004 /* asynch. xfer is running */
|
||||
#define Z_NEED_RELOAD 0x0008 /* waiting to do reload */
|
||||
#define Z_SYSLOGGED 0x0010 /* have logged timeout */
|
||||
#define Z_QSERIAL 0x0020 /* sysquery()'ing for serial number */
|
||||
#define Z_FOUND 0x0040 /* found in boot file when reloading */
|
||||
#define Z_INCLUDE 0x0080 /* set if include used in file */
|
||||
#define Z_DB_BAD 0x0100 /* errors when loading file */
|
||||
#define Z_TMP_FILE 0x0200 /* backup file for xfer is temporary */
|
||||
#ifdef BIND_UPDATE
|
||||
#define Z_DYNAMIC 0x0400 /* allow dynamic updates */
|
||||
#define Z_NEED_DUMP 0x0800 /* zone has changed, needs a dump */
|
||||
#define Z_NEED_SOAUPDATE 0x1000 /* soa serial number needs increment */
|
||||
#endif /* BIND_UPDATE */
|
||||
#define Z_XFER_ABORTED 0x2000 /* zone transfer has been aborted */
|
||||
#define Z_XFER_GONE 0x4000 /* zone transfer process is gone */
|
||||
#define Z_TIMER_SET 0x8000 /* z_timer contains a valid id */
|
||||
|
||||
/* named_xfer exit codes */
|
||||
#define XFER_UPTODATE 0 /* zone is up-to-date */
|
||||
#define XFER_SUCCESS 1 /* performed transfer successfully */
|
||||
#define XFER_TIMEOUT 2 /* no server reachable/xfer timeout */
|
||||
#define XFER_FAIL 3 /* other failure, has been logged */
|
||||
|
||||
/* XXX - "struct qserv" is deprecated in favor of "struct nameser" */
|
||||
struct qserv {
|
||||
struct sockaddr_in
|
||||
ns_addr; /* address of NS */
|
||||
struct databuf *ns; /* databuf for NS record */
|
||||
struct databuf *nsdata; /* databuf for server address */
|
||||
struct timeval stime; /* time first query started */
|
||||
int nretry; /* # of times addr retried */
|
||||
};
|
||||
|
||||
/*
|
||||
* Structure for recording info on forwarded or generated queries.
|
||||
*/
|
||||
struct qinfo {
|
||||
u_int16_t q_id; /* id of query */
|
||||
u_int16_t q_nsid; /* id of forwarded query */
|
||||
struct sockaddr_in
|
||||
q_from; /* requestor's address */
|
||||
u_char *q_msg, /* the message */
|
||||
*q_cmsg; /* the cname message */
|
||||
int16_t q_msglen, /* len of message */
|
||||
q_msgsize, /* allocated size of message */
|
||||
q_cmsglen, /* len of cname message */
|
||||
q_cmsgsize; /* allocated size of cname message */
|
||||
int16_t q_dfd; /* UDP file descriptor */
|
||||
struct fwdinfo *q_fwd; /* last forwarder used */
|
||||
time_t q_time; /* time to retry */
|
||||
time_t q_expire; /* time to expire */
|
||||
struct qinfo *q_next; /* rexmit list (sorted by time) */
|
||||
struct qinfo *q_link; /* storage list (random order) */
|
||||
struct databuf *q_usedns[NSMAX]; /* databuf for NS that we've tried */
|
||||
struct qserv q_addr[NSMAX]; /* addresses of NS's */
|
||||
#ifdef notyet
|
||||
struct nameser *q_ns[NSMAX]; /* name servers */
|
||||
#endif
|
||||
u_char q_naddr; /* number of addr's in q_addr */
|
||||
u_char q_curaddr; /* last addr sent to */
|
||||
u_char q_nusedns; /* number of elements in q_usedns[] */
|
||||
u_int8_t q_flags; /* see below */
|
||||
int16_t q_cname; /* # of cnames found */
|
||||
int16_t q_nqueries; /* # of queries required */
|
||||
struct qstream *q_stream; /* TCP stream, null if UDP */
|
||||
struct zoneinfo *q_zquery; /* Zone query is about (Q_ZSERIAL) */
|
||||
char *q_domain; /* domain of most enclosing zone cut */
|
||||
char *q_name; /* domain of query */
|
||||
u_int16_t q_class; /* class of query */
|
||||
u_int16_t q_type; /* type of query */
|
||||
#ifdef BIND_NOTIFY
|
||||
int q_notifyzone; /* zone which needs a sysnotify()
|
||||
* when the reply to this comes in.
|
||||
*/
|
||||
#endif
|
||||
};
|
||||
|
||||
/* q_flags bits (8 bits) */
|
||||
#define Q_SYSTEM 0x01 /* is a system query */
|
||||
#define Q_PRIMING 0x02 /* generated during priming phase */
|
||||
#define Q_ZSERIAL 0x04 /* getting zone serial for xfer test */
|
||||
#define Q_USEVC 0x08 /* forward using tcp not udp */
|
||||
|
||||
#define Q_NEXTADDR(qp,n) \
|
||||
(((qp)->q_fwd == (struct fwdinfo *)0) ? \
|
||||
&(qp)->q_addr[n].ns_addr : &(qp)->q_fwd->fwdaddr)
|
||||
|
||||
#define RETRY_TIMEOUT 45
|
||||
|
||||
/*
|
||||
* Return codes from ns_forw:
|
||||
*/
|
||||
#define FW_OK 0
|
||||
#define FW_DUP 1
|
||||
#define FW_NOSERVER 2
|
||||
#define FW_SERVFAIL 3
|
||||
|
||||
typedef void (*sq_closure)(struct qstream *qs);
|
||||
|
||||
#ifdef BIND_UPDATE
|
||||
struct fdlist {
|
||||
int fd;
|
||||
struct fdlist *next;
|
||||
};
|
||||
#endif
|
||||
|
||||
typedef struct _interface {
|
||||
int dfd, /* Datagram file descriptor */
|
||||
sfd; /* Stream file descriptor. */
|
||||
time_t gen; /* Generation number. */
|
||||
struct in_addr addr; /* Interface address. */
|
||||
u_int16_t port; /* Interface port. */
|
||||
u_int16_t flags; /* Valid bits for evXXXXID. */
|
||||
evFileID evID_d; /* Datagram read-event. */
|
||||
evConnID evID_s; /* Stream listen-event. */
|
||||
LINK(struct _interface) link;
|
||||
} interface;
|
||||
|
||||
#define INTERFACE_FILE_VALID 0x01
|
||||
#define INTERFACE_CONN_VALID 0x02
|
||||
#define INTERFACE_FORWARDING 0x04
|
||||
|
||||
struct qstream {
|
||||
int s_rfd; /* stream file descriptor */
|
||||
int s_size; /* expected amount of data to rcv */
|
||||
int s_bufsize; /* amount of data received in s_buf */
|
||||
u_char *s_buf; /* buffer of received data */
|
||||
u_char *s_wbuf; /* send buffer */
|
||||
u_char *s_wbuf_send; /* next sendable byte of send buffer */
|
||||
u_char *s_wbuf_free; /* next free byte of send buffer */
|
||||
u_char *s_wbuf_end; /* byte after end of send buffer */
|
||||
sq_closure s_wbuf_closure; /* callback for writable descriptor */
|
||||
struct qstream *s_next; /* next stream */
|
||||
struct sockaddr_in
|
||||
s_from; /* address query came from */
|
||||
interface *s_ifp; /* interface query came from */
|
||||
time_t s_time; /* time stamp of last transaction */
|
||||
int s_refcnt; /* number of outstanding queries */
|
||||
u_char s_temp[HFIXEDSZ];
|
||||
#ifdef BIND_UPDATE
|
||||
int s_opcode; /* type of request */
|
||||
int s_linkcnt; /* number of client connections using
|
||||
* this connection to forward updates
|
||||
* to the primary */
|
||||
struct fdlist *s_fds; /* linked list of connections to the
|
||||
* primaries that have been used by
|
||||
* the server to forward this client's
|
||||
* update requests */
|
||||
#endif
|
||||
evStreamID evID_r; /* read event. */
|
||||
evFileID evID_w; /* writable event handle. */
|
||||
evConnID evID_c; /* connect event handle */
|
||||
u_int flags; /* see below */
|
||||
struct qstream_xfr {
|
||||
enum { s_x_base, s_x_firstsoa, s_x_zone,
|
||||
s_x_lastsoa, s_x_done }
|
||||
state; /* state of transfer. */
|
||||
u_char *msg, /* current assembly message. */
|
||||
*cp, /* where are we in msg? */
|
||||
*eom, /* end of msg. */
|
||||
*ptrs[128]; /* ptrs for dn_comp(). */
|
||||
int class, /* class of an XFR. */
|
||||
id, /* id of an XFR. */
|
||||
opcode; /* opcode of an XFR. */
|
||||
u_int zone; /* zone being XFR'd. */
|
||||
struct namebuf *top; /* top np of an XFR. */
|
||||
struct qs_x_lev { /* decompose the recursion. */
|
||||
enum {sxl_ns, sxl_all, sxl_sub}
|
||||
state; /* what's this level doing? */
|
||||
int flags; /* see below (SXL_*). */
|
||||
char dname[MAXDNAME];
|
||||
struct namebuf *np, /* this node. */
|
||||
*nnp, /* next node to process. */
|
||||
**npp, /* subs. */
|
||||
**npe; /* end of subs. */
|
||||
struct databuf *dp; /* current rr. */
|
||||
struct qs_x_lev *next; /* link. */
|
||||
} *lev; /* LIFO. */
|
||||
enum axfr_format transfer_format;
|
||||
} xfr;
|
||||
};
|
||||
#define SXL_GLUING 0x01
|
||||
#define SXL_ZONECUT 0x02
|
||||
|
||||
/* flags */
|
||||
#define STREAM_MALLOC 0x01
|
||||
#define STREAM_WRITE_EV 0x02
|
||||
#define STREAM_READ_EV 0x04
|
||||
#define STREAM_CONNECT_EV 0x08
|
||||
#define STREAM_DONE_CLOSE 0x10
|
||||
#define STREAM_AXFR 0x20
|
||||
|
||||
#define ALLOW_NETS 0x0001
|
||||
#define ALLOW_HOSTS 0x0002
|
||||
#define ALLOW_ALL (ALLOW_NETS | ALLOW_HOSTS)
|
||||
|
||||
struct fwdinfo {
|
||||
struct fwdinfo *next;
|
||||
struct sockaddr_in
|
||||
fwdaddr;
|
||||
};
|
||||
|
||||
enum nameserStats { nssRcvdR, /* sent us an answer */
|
||||
nssRcvdNXD, /* sent us a negative response */
|
||||
nssRcvdFwdR, /* sent us a response we had to fwd */
|
||||
nssRcvdDupR, /* sent us an extra answer */
|
||||
nssRcvdFail, /* sent us a SERVFAIL */
|
||||
nssRcvdFErr, /* sent us a FORMERR */
|
||||
nssRcvdErr, /* sent us some other error */
|
||||
nssRcvdAXFR, /* sent us an AXFR */
|
||||
nssRcvdLDel, /* sent us a lame delegation */
|
||||
nssRcvdOpts, /* sent us some IP options */
|
||||
nssSentSysQ, /* sent them a sysquery */
|
||||
nssSentAns, /* sent them an answer */
|
||||
nssSentFwdQ, /* fwdd a query to them */
|
||||
nssSentDupQ, /* sent them a retry */
|
||||
nssSendtoErr, /* error in sendto */
|
||||
nssRcvdQ, /* sent us a query */
|
||||
nssRcvdIQ, /* sent us an inverse query */
|
||||
nssRcvdFwdQ, /* sent us a query we had to fwd */
|
||||
nssRcvdDupQ, /* sent us a retry */
|
||||
nssRcvdTCP, /* sent us a query using TCP */
|
||||
nssSentFwdR, /* fwdd a response to them */
|
||||
nssSentFail, /* sent them a SERVFAIL */
|
||||
nssSentFErr, /* sent them a FORMERR */
|
||||
nssSentNaAns, /* sent them a non autoritative answer */
|
||||
nssSentNXD, /* sent them a negative response */
|
||||
nssLast };
|
||||
|
||||
struct nameser {
|
||||
struct in_addr addr; /* key */
|
||||
u_long stats[nssLast]; /* statistics */
|
||||
#ifdef notyet
|
||||
u_int32_t rtt; /* round trip time */
|
||||
/* XXX - need to add more stuff from "struct qserv", and use our rtt */
|
||||
u_int16_t flags; /* see below */
|
||||
#endif
|
||||
u_int8_t xfers; /* #/xfers running right now */
|
||||
};
|
||||
|
||||
enum transport { primary_trans, secondary_trans, response_trans, num_trans };
|
||||
|
||||
/* types used by the parser or config routines */
|
||||
|
||||
typedef struct zone_config {
|
||||
void *opaque;
|
||||
} zone_config;
|
||||
|
||||
typedef struct listen_info {
|
||||
u_short port;
|
||||
ip_match_list list;
|
||||
struct listen_info *next;
|
||||
} *listen_info;
|
||||
|
||||
typedef struct listen_info_list {
|
||||
listen_info first;
|
||||
listen_info last;
|
||||
} *listen_info_list;
|
||||
|
||||
#ifndef RLIMIT_TYPE
|
||||
#define RLIMIT_TYPE u_long
|
||||
#endif
|
||||
typedef RLIMIT_TYPE rlimit_type;
|
||||
|
||||
typedef struct options {
|
||||
u_int flags;
|
||||
char *directory;
|
||||
char *dump_filename;
|
||||
char *pid_filename;
|
||||
char *stats_filename;
|
||||
char *memstats_filename;
|
||||
char *named_xfer;
|
||||
int transfers_in;
|
||||
int transfers_per_ns;
|
||||
int transfers_out;
|
||||
enum axfr_format transfer_format;
|
||||
long max_transfer_time_in;
|
||||
struct sockaddr_in query_source;
|
||||
ip_match_list query_acl;
|
||||
ip_match_list transfer_acl;
|
||||
ip_match_list topology;
|
||||
enum severity check_names[num_trans];
|
||||
u_long data_size;
|
||||
u_long stack_size;
|
||||
u_long core_size;
|
||||
u_long files;
|
||||
listen_info_list listen_list;
|
||||
struct fwdinfo *fwdtab;
|
||||
/* XXX need to add forward option */
|
||||
int clean_interval;
|
||||
int interface_interval;
|
||||
int stats_interval;
|
||||
} *options;
|
||||
|
||||
typedef struct key_info {
|
||||
char *name;
|
||||
char *algorithm;
|
||||
char *secret; /* XXX should be u_char? */
|
||||
} *key_info;
|
||||
|
||||
typedef struct key_list_element {
|
||||
key_info info;
|
||||
struct key_list_element *next;
|
||||
} *key_list_element;
|
||||
|
||||
typedef struct key_info_list {
|
||||
key_list_element first;
|
||||
key_list_element last;
|
||||
} *key_info_list;
|
||||
|
||||
typedef struct topology_config {
|
||||
void *opaque;
|
||||
} topology_config;
|
||||
|
||||
#define UNKNOWN_TOPOLOGY_DISTANCE 9998
|
||||
#define MAX_TOPOLOGY_DISTANCE 9999
|
||||
|
||||
typedef struct topology_distance {
|
||||
ip_match_list patterns;
|
||||
struct topology_distance *next;
|
||||
} *topology_distance;
|
||||
|
||||
typedef struct topology_context {
|
||||
topology_distance first;
|
||||
topology_distance last;
|
||||
} *topology_context;
|
||||
|
||||
typedef struct acl_table_entry {
|
||||
char *name;
|
||||
ip_match_list list;
|
||||
struct acl_table_entry *next;
|
||||
} *acl_table_entry;
|
||||
|
||||
typedef struct server_config {
|
||||
void *opaque;
|
||||
} server_config;
|
||||
|
||||
#define SERVER_INFO_BOGUS 0x01
|
||||
|
||||
typedef struct server_info {
|
||||
struct in_addr address;
|
||||
u_int flags;
|
||||
int transfers;
|
||||
enum axfr_format transfer_format;
|
||||
key_info_list key_list;
|
||||
/* could move statistics to here, too */
|
||||
struct server_info *next;
|
||||
} *server_info;
|
||||
|
||||
/*
|
||||
* enum <--> name translation
|
||||
*/
|
||||
|
||||
struct ns_sym {
|
||||
int number; /* Identifying number, like ns_log_default */
|
||||
char * name; /* Its symbolic name, like "default" */
|
||||
};
|
||||
|
||||
/*
|
||||
* Logging options
|
||||
*/
|
||||
|
||||
typedef enum ns_logging_categories {
|
||||
ns_log_default = 0,
|
||||
ns_log_config,
|
||||
ns_log_parser,
|
||||
ns_log_queries,
|
||||
ns_log_lame_servers,
|
||||
ns_log_statistics,
|
||||
ns_log_panic,
|
||||
ns_log_update,
|
||||
ns_log_ncache,
|
||||
ns_log_xfer_in,
|
||||
ns_log_xfer_out,
|
||||
ns_log_db,
|
||||
ns_log_eventlib,
|
||||
ns_log_packet,
|
||||
ns_log_notify,
|
||||
ns_log_cname,
|
||||
ns_log_security,
|
||||
ns_log_os,
|
||||
ns_log_insist,
|
||||
ns_log_maint,
|
||||
ns_log_load,
|
||||
ns_log_resp_checks,
|
||||
ns_log_max_category
|
||||
} ns_logging_categories;
|
||||
|
||||
typedef struct log_config {
|
||||
log_context log_ctx;
|
||||
log_channel eventlib_channel;
|
||||
log_channel packet_channel;
|
||||
int default_debug_active;
|
||||
} *log_config;
|
||||
|
||||
struct map {
|
||||
char * token;
|
||||
int val;
|
||||
};
|
||||
|
||||
#define NOERROR_NODATA 6 /* only used internally by the server, used for
|
||||
* -ve $ing non-existence of records. 6 is not
|
||||
* a code used as yet anyway. anant@isi.edu
|
||||
*/
|
||||
|
||||
#define NTTL 600 /* ttl for negative data: 10 minutes? */
|
||||
|
||||
#define VQEXPIRY 900 /* a VQ entry expires in 15*60 = 900 seconds */
|
||||
|
||||
#ifdef BIND_UPDATE
|
||||
enum req_action { Finish, Refuse, Return };
|
||||
#endif
|
||||
|
||||
#ifdef BIND_NOTIFY
|
||||
typedef enum {
|
||||
notify_info_waitfor, notify_info_delay, notify_info_error,
|
||||
notify_info_done
|
||||
} notify_info_state;
|
||||
|
||||
typedef struct notify_info {
|
||||
char *name;
|
||||
int class;
|
||||
notify_info_state state;
|
||||
evWaitID wait_id;
|
||||
evTimerID timer_id;
|
||||
LINK(struct notify_info) link;
|
||||
} *notify_info;
|
||||
|
||||
typedef LIST(struct notify_info) notify_info_list;
|
||||
#endif /* BIND_NOTIFY */
|
||||
|
||||
#ifdef INIT
|
||||
error "INIT already defined, check system include files"
|
||||
#endif
|
||||
#ifdef DECL
|
||||
error "DECL already defined, check system include files"
|
||||
#endif
|
||||
|
||||
#ifdef MAIN_PROGRAM
|
||||
#define INIT(x) = x
|
||||
#define DECL
|
||||
#else
|
||||
#define INIT(x)
|
||||
#define DECL extern
|
||||
#endif
|
||||
1132
contrib/bind/bin/named/ns_forw.c
Normal file
1132
contrib/bind/bin/named/ns_forw.c
Normal file
File diff suppressed because it is too large
Load diff
380
contrib/bind/bin/named/ns_func.h
Normal file
380
contrib/bind/bin/named/ns_func.h
Normal file
|
|
@ -0,0 +1,380 @@
|
|||
/* Copyright (c) 1985, 1990
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* 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, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION 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.
|
||||
*/
|
||||
|
||||
/* Portions Copyright (c) 1996, 1997 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/* ns_func.h - declarations for ns_*.c's externally visible functions
|
||||
*
|
||||
* $Id: ns_func.h,v 8.43 1998/03/20 00:53:44 halley Exp $
|
||||
*/
|
||||
|
||||
/* ++from ns_glue.c++ */
|
||||
extern struct in_addr ina_get(const u_char *data);
|
||||
extern const char *sin_ntoa(struct sockaddr_in);
|
||||
extern void ns_debug(int, int, const char *, ...),
|
||||
ns_info(int, const char *, ...),
|
||||
ns_notice(int, const char *, ...),
|
||||
ns_warning(int, const char *, ...),
|
||||
ns_error(int, const char *, ...),
|
||||
ns_panic(int, int, const char *, ...),
|
||||
ns_assertion_failed(char *file, int line,
|
||||
assertion_type type, char *cond,
|
||||
int print_errno);
|
||||
extern void panic(const char *, const void *),
|
||||
gettime(struct timeval *);
|
||||
extern int nlabels(const char *),
|
||||
my_close(int),
|
||||
my_fclose(FILE *);
|
||||
extern void __freestr(char *);
|
||||
extern char *__newstr(size_t, int),
|
||||
*__savestr(const char *, int),
|
||||
*checked_ctime(const time_t *t),
|
||||
*ctimel(long);
|
||||
extern u_char *ina_put(struct in_addr ina, u_char *data),
|
||||
*savebuf(const u_char *, size_t, int);
|
||||
extern void dprintf(int level, const char *format, ...);
|
||||
#ifdef DEBUG_STRINGS
|
||||
extern char *debug_newstr(size_t, int, const char *, int),
|
||||
*debug_savestr(const char *, int, const char *, int);
|
||||
extern void debug_freestr(char *, const char *, int);
|
||||
#define newstr(l, n) debug_newstr((l), (n), __FILE__, __LINE__)
|
||||
#define savestr(s, n) debug_savestr((s), (n), __FILE__, __LINE__)
|
||||
#define freestr(s) debug_freestr((s), __FILE__, __LINE__)
|
||||
#else
|
||||
#define newstr(l, n) __newstr((l), (n))
|
||||
#define savestr(s, n) __savestr((s), (n))
|
||||
#define freestr(s) __freestr((s))
|
||||
#endif /* DEBUG_STRINGS */
|
||||
/* --from ns_glue.c-- */
|
||||
|
||||
/* ++from ns_resp.c++ */
|
||||
extern void ns_resp(u_char *, int, struct sockaddr_in,
|
||||
struct qstream *),
|
||||
prime_cache(void),
|
||||
delete_all(struct namebuf *, int, int),
|
||||
delete_stale(struct namebuf *);
|
||||
extern struct qinfo *sysquery(const char *, int, int,
|
||||
struct in_addr *, int, int);
|
||||
extern void sysnotify(const char *, int, int);
|
||||
extern int doupdate(u_char *, u_char *, struct databuf **,
|
||||
int, int, int, u_int, struct sockaddr_in),
|
||||
send_msg(u_char *, int, struct qinfo *),
|
||||
findns(struct namebuf **, int,
|
||||
struct databuf **, int *, int),
|
||||
finddata(struct namebuf *, int, int, HEADER *,
|
||||
char **, int *, int *),
|
||||
wanted(const struct databuf *, int, int),
|
||||
add_data(struct namebuf *,
|
||||
struct databuf **,
|
||||
u_char *, int, int *),
|
||||
trunc_adjust(u_char *, int, int);
|
||||
/* --from ns_resp.c-- */
|
||||
|
||||
/* ++from ns_req.c++ */
|
||||
extern void ns_req(u_char *, int, int,
|
||||
struct qstream *,
|
||||
struct sockaddr_in,
|
||||
int),
|
||||
free_addinfo(void),
|
||||
free_nsp(struct databuf **);
|
||||
extern int stale(struct databuf *),
|
||||
make_rr(const char *, struct databuf *,
|
||||
u_char *, int, int,
|
||||
u_char **, u_char **),
|
||||
doaddinfo(HEADER *, u_char *, int),
|
||||
doaddauth(HEADER *, u_char *, int,
|
||||
struct namebuf *,
|
||||
struct databuf *);
|
||||
#ifdef BIND_NOTIFY
|
||||
extern int findZonePri(const struct zoneinfo *,
|
||||
const struct sockaddr_in);
|
||||
#endif
|
||||
/* --from ns_req.c-- */
|
||||
|
||||
/* ++from ns_xfr.c++ */
|
||||
extern void ns_xfr(struct qstream *qsp, struct namebuf *znp,
|
||||
int zone, int class, int type,
|
||||
int id, int opcode),
|
||||
ns_stopxfrs(struct zoneinfo *),
|
||||
ns_freexfr(struct qstream *);
|
||||
/* --from ns_xfr.c-- */
|
||||
|
||||
/* ++from ns_forw.c++ */
|
||||
extern time_t retrytime(struct qinfo *);
|
||||
extern int ns_forw(struct databuf *nsp[],
|
||||
u_char *msg,
|
||||
int msglen,
|
||||
struct sockaddr_in from,
|
||||
struct qstream *qsp,
|
||||
int dfd,
|
||||
struct qinfo **qpp,
|
||||
const char *dname,
|
||||
int class,
|
||||
int type,
|
||||
struct namebuf *np,
|
||||
int use_tcp),
|
||||
haveComplained(u_long, u_long),
|
||||
nslookup(struct databuf *nsp[],
|
||||
struct qinfo *qp,
|
||||
const char *syslogdname,
|
||||
const char *sysloginfo),
|
||||
qcomp(struct qserv *, struct qserv *);
|
||||
extern void schedretry(struct qinfo *, time_t),
|
||||
unsched(struct qinfo *),
|
||||
reset_retrytimer(void),
|
||||
retrytimer(evContext ctx, void *uap,
|
||||
struct timespec due, struct timespec ival),
|
||||
retry(struct qinfo *),
|
||||
qflush(void),
|
||||
qremove(struct qinfo *),
|
||||
ns_freeqns(struct qinfo *, char *),
|
||||
ns_freeqry(struct qinfo *),
|
||||
freeComplaints(void);
|
||||
extern struct qinfo *qfindid(u_int16_t),
|
||||
*qnew(const char *, int, int);
|
||||
/* --from ns_forw.c-- */
|
||||
|
||||
/* ++from ns_main.c++ */
|
||||
extern struct in_addr net_mask(struct in_addr);
|
||||
extern void sq_remove(struct qstream *),
|
||||
sq_flushw(struct qstream *),
|
||||
sq_flush(struct qstream *allbut),
|
||||
dq_remove_gen(time_t gen),
|
||||
dq_remove_all(),
|
||||
sq_done(struct qstream *),
|
||||
ns_setproctitle(char *, int),
|
||||
getnetconf(int),
|
||||
nsid_init(void),
|
||||
ns_setoption(int option),
|
||||
writestream(struct qstream *, const u_char *, int),
|
||||
ns_need(int need),
|
||||
opensocket_f(void);
|
||||
extern u_int16_t nsid_next(void);
|
||||
extern int sq_openw(struct qstream *, int),
|
||||
sq_writeh(struct qstream *, sq_closure),
|
||||
sq_write(struct qstream *, const u_char *, int),
|
||||
ns_need_p(int option),
|
||||
tcp_send(struct qinfo *),
|
||||
aIsUs(struct in_addr);
|
||||
/* --from ns_main.c-- */
|
||||
|
||||
/* ++from ns_maint.c++ */
|
||||
extern void ns_maint(void),
|
||||
zone_maint(struct zoneinfo *),
|
||||
sched_zone_maint(struct zoneinfo *),
|
||||
ns_cleancache(evContext ctx, void *uap,
|
||||
struct timespec due,
|
||||
struct timespec inter),
|
||||
purge_zone(const char *, struct hashbuf *, int),
|
||||
loadxfer(void),
|
||||
qserial_retrytime(struct zoneinfo *, time_t),
|
||||
qserial_query(struct zoneinfo *),
|
||||
qserial_answer(struct qinfo *, u_int32_t,
|
||||
struct sockaddr_in),
|
||||
#ifdef DEBUG
|
||||
printzoneinfo(int, int, int),
|
||||
#endif
|
||||
endxfer(void),
|
||||
ns_reload(void);
|
||||
extern int clean_cache(struct hashbuf *, int);
|
||||
extern void reapchild(evContext, void *, int);
|
||||
extern const char * zoneTypeString(const struct zoneinfo *);
|
||||
/* --from ns_maint.c-- */
|
||||
|
||||
/* ++from ns_init.c++ */
|
||||
extern void ns_refreshtime(struct zoneinfo *, time_t),
|
||||
ns_retrytime(struct zoneinfo *, time_t),
|
||||
ns_init(const char *);
|
||||
extern enum context ns_ptrcontext(const char *owner);
|
||||
extern enum context ns_ownercontext(int type, enum transport);
|
||||
extern int ns_nameok(const char *name, int class,
|
||||
struct zoneinfo *zp,
|
||||
enum transport, enum context,
|
||||
const char *owner,
|
||||
struct in_addr source);
|
||||
extern int ns_wildcard(const char *name);
|
||||
extern void zoneinit(struct zoneinfo *),
|
||||
do_reload(const char *, int, int),
|
||||
ns_shutdown(void);
|
||||
/* --from ns_init.c-- */
|
||||
|
||||
/* ++from ns_ncache.c++ */
|
||||
extern void cache_n_resp(u_char *, int, struct sockaddr_in);
|
||||
/* --from ns_ncache.c-- */
|
||||
|
||||
/* ++from ns_udp.c++ */
|
||||
extern void ns_udp(void);
|
||||
/* --from ns_udp.c-- */
|
||||
|
||||
/* ++from ns_stats.c++ */
|
||||
extern void ns_stats(void),
|
||||
ns_freestats(void);
|
||||
extern void ns_logstats(evContext ctx, void *uap,
|
||||
struct timespec, struct timespec);
|
||||
extern void qtypeIncr(int qtype);
|
||||
extern struct nameser *nameserFind(struct in_addr addr, int flags);
|
||||
#define NS_F_INSERT 0x0001
|
||||
#define nameserIncr(a,w) NS_INCRSTAT(a,w) /* XXX should change name. */
|
||||
/* --from ns_stats.c-- */
|
||||
|
||||
/* ++from ns_update.c++ */
|
||||
u_char *findsoaserial(u_char *data);
|
||||
u_int32_t get_serial_unchecked(struct zoneinfo *zp);
|
||||
u_int32_t get_serial(struct zoneinfo *zp);
|
||||
void set_serial(struct zoneinfo *zp, u_int32_t serial);
|
||||
int schedule_soa_update(struct zoneinfo *, int);
|
||||
int schedule_dump(struct zoneinfo *);
|
||||
int incr_serial(struct zoneinfo *zp);
|
||||
int merge_logs(struct zoneinfo *zp);
|
||||
int zonedump(struct zoneinfo *zp);
|
||||
void dynamic_about_to_exit(void);
|
||||
enum req_action req_update(HEADER *hp, u_char *cp, u_char *eom,
|
||||
u_char *msg, struct qstream *qsp,
|
||||
int dfd, struct sockaddr_in from);
|
||||
void rdata_dump(struct databuf *dp, FILE *fp);
|
||||
/* --from ns_update.c-- */
|
||||
|
||||
/* ++from ns_config.c++ */
|
||||
void free_zone_timerinfo(struct zoneinfo *);
|
||||
void free_zone_contents(struct zoneinfo *, int);
|
||||
struct zoneinfo *find_zone(const char *, int, int);
|
||||
zone_config begin_zone(char *, int);
|
||||
void end_zone(zone_config, int);
|
||||
int set_zone_type(zone_config, int);
|
||||
int set_zone_filename(zone_config, char *);
|
||||
int set_zone_checknames(zone_config, enum severity);
|
||||
int set_zone_notify(zone_config, int value);
|
||||
int set_zone_update_acl(zone_config, ip_match_list);
|
||||
int set_zone_query_acl(zone_config, ip_match_list);
|
||||
int set_zone_transfer_acl(zone_config, ip_match_list);
|
||||
int set_zone_transfer_source(zone_config, struct in_addr);
|
||||
int set_zone_transfer_time_in(zone_config, long);
|
||||
int add_zone_master(zone_config, struct in_addr);
|
||||
int add_zone_notify(zone_config, struct in_addr);
|
||||
options new_options(void);
|
||||
void free_options(options);
|
||||
void set_boolean_option(options, int, int);
|
||||
listen_info_list new_listen_info_list(void);
|
||||
void free_listen_info_list(listen_info_list);
|
||||
void add_listen_on(options, u_int16_t, ip_match_list);
|
||||
FILE * write_open(char *filename);
|
||||
void update_pid_file(void);
|
||||
void set_options(options, int);
|
||||
void use_default_options(void);
|
||||
ip_match_list new_ip_match_list(void);
|
||||
void free_ip_match_list(ip_match_list);
|
||||
ip_match_element new_ip_match_pattern(struct in_addr, u_int);
|
||||
ip_match_element new_ip_match_mask(struct in_addr, struct in_addr);
|
||||
ip_match_element new_ip_match_indirect(ip_match_list);
|
||||
ip_match_element new_ip_match_localhost(void);
|
||||
ip_match_element new_ip_match_localnets(void);
|
||||
void ip_match_negate(ip_match_element);
|
||||
void add_to_ip_match_list(ip_match_list, ip_match_element);
|
||||
void dprint_ip_match_list(int, ip_match_list, int, char *,
|
||||
char *);
|
||||
int ip_match_address(ip_match_list, struct in_addr);
|
||||
int ip_address_allowed(ip_match_list, struct in_addr);
|
||||
int ip_match_network(ip_match_list, struct in_addr,
|
||||
struct in_addr);
|
||||
int distance_of_address(ip_match_list, struct in_addr);
|
||||
int ip_match_is_none(ip_match_list);
|
||||
void add_forwarder(options, struct in_addr);
|
||||
void free_forwarders(struct fwdinfo *);
|
||||
server_info find_server(struct in_addr);
|
||||
server_config begin_server(struct in_addr);
|
||||
void end_server(server_config, int);
|
||||
void set_server_option(server_config, int, int);
|
||||
void set_server_transfers(server_config, int);
|
||||
void set_server_transfer_format(server_config,
|
||||
enum axfr_format);
|
||||
void add_server_key_info(server_config, key_info);
|
||||
key_info new_key_info(char *, char *, char *);
|
||||
void free_key_info(key_info);
|
||||
void dprint_key_info(key_info);
|
||||
key_info_list new_key_info_list(void);
|
||||
void free_key_info_list(key_info_list);
|
||||
void add_to_key_info_list(key_info_list, key_info);
|
||||
void dprint_key_info_list(key_info_list);
|
||||
log_config begin_logging(void);
|
||||
void add_log_channel(log_config, int, log_channel);
|
||||
void open_special_channels(void);
|
||||
void set_logging(log_config, int);
|
||||
void end_logging(log_config, int);
|
||||
void use_default_logging(void);
|
||||
void init_logging(void);
|
||||
void shutdown_logging(void);
|
||||
void init_configuration(void);
|
||||
void shutdown_configuration(void);
|
||||
void load_configuration(const char *);
|
||||
/* --from ns_config.c-- */
|
||||
/* ++from parser.y++ */
|
||||
ip_match_list lookup_acl(char *);
|
||||
void define_acl(char *, ip_match_list);
|
||||
key_info lookup_key(char *);
|
||||
void define_key(char *, key_info);
|
||||
void parse_configuration(const char *);
|
||||
void parser_initialize(void);
|
||||
void parser_shutdown(void);
|
||||
/* --from parser.y-- */
|
||||
317
contrib/bind/bin/named/ns_glob.h
Normal file
317
contrib/bind/bin/named/ns_glob.h
Normal file
|
|
@ -0,0 +1,317 @@
|
|||
/*
|
||||
* from ns.h 4.33 (Berkeley) 8/23/90
|
||||
* $Id: ns_glob.h,v 8.34 1998/03/20 01:18:07 halley Exp $
|
||||
*/
|
||||
|
||||
/* Copyright (c) 1986
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* 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, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION 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.
|
||||
*/
|
||||
|
||||
/* Portions Copyright (c) 1996, 1997 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Global variables for the name server.
|
||||
*/
|
||||
|
||||
#ifdef DEBUG
|
||||
DECL int debug INIT(0);
|
||||
DECL int desired_debug INIT(0);
|
||||
#endif
|
||||
|
||||
/* global event context */
|
||||
DECL evContext ev;
|
||||
|
||||
/* list of open streams */
|
||||
DECL struct qstream *streamq;
|
||||
|
||||
/* often set to the current time */
|
||||
DECL struct timeval tt;
|
||||
|
||||
/* head of allocated queries */
|
||||
DECL struct qinfo *nsqhead;
|
||||
|
||||
/* datagram socket for sysquery() and ns_forw(). */
|
||||
DECL int ds INIT(-1);
|
||||
|
||||
/* event ID for reads of "ds". */
|
||||
DECL evFileID ds_evID;
|
||||
|
||||
#ifdef QRYLOG
|
||||
/* is query logging turned on? */
|
||||
DECL int qrylog;
|
||||
#endif /*QRYLOG*/
|
||||
|
||||
/* port to which we send queries */
|
||||
DECL u_int16_t ns_port;
|
||||
|
||||
/* Source addr of our internal resolver. */
|
||||
DECL struct sockaddr_in source_addr; /* INITs to <INADDR_ANY, 0>. */
|
||||
|
||||
/* Used by ns_stats */
|
||||
DECL time_t boottime;
|
||||
|
||||
DECL time_t resettime;
|
||||
|
||||
/* next query to retry */
|
||||
DECL struct qinfo *retryqp;
|
||||
|
||||
/* default configuration file */
|
||||
DECL char *conffile INIT(NULL);
|
||||
|
||||
/* default debug output file */
|
||||
DECL const char *debugfile INIT(_PATH_DEBUG);
|
||||
|
||||
/* zone information */
|
||||
DECL struct zoneinfo *zones;
|
||||
|
||||
/* number of zones in use */
|
||||
DECL int nzones;
|
||||
|
||||
/* set if we need a priming */
|
||||
DECL int needs_prime_cache;
|
||||
|
||||
/* is cache being primed */
|
||||
DECL int priming;
|
||||
|
||||
/* ptrs to dnames in msg for dn_comp */
|
||||
DECL u_char *dnptrs[40];
|
||||
|
||||
/* end pointer for dnptrs */
|
||||
DECL u_char **dnptrs_end
|
||||
INIT(dnptrs + sizeof dnptrs / sizeof(u_char*));
|
||||
|
||||
/* number of names in addinfo */
|
||||
DECL int addcount;
|
||||
|
||||
/* name of cache file */
|
||||
DECL const char *cache_file;
|
||||
|
||||
#ifdef SLAVE_FORWARD
|
||||
/* retry time when a slave */
|
||||
DECL int slave_retry INIT(4);
|
||||
#endif
|
||||
|
||||
#ifdef BIND_UPDATE
|
||||
DECL const char * LogSignature INIT(";BIND LOG V8\n");
|
||||
DECL const char * DumpSignature INIT(";BIND DUMP V8\n");
|
||||
DECL const char * DumpSuffix INIT(".dumptmp");
|
||||
#endif
|
||||
|
||||
DECL const char sendtoStr[] INIT("sendto");
|
||||
DECL const char tcpsendStr[] INIT("tcp_send");
|
||||
|
||||
/* defined in version.c, can't use DECL/INIT */
|
||||
extern char Version[];
|
||||
extern char ShortVersion[];
|
||||
|
||||
/* If getnum() has an error, here will be the result. */
|
||||
DECL int getnum_error INIT(0);
|
||||
|
||||
enum context { domain_ctx, owner_ctx, mailname_ctx, hostname_ctx };
|
||||
DECL const char *context_strings[]
|
||||
#ifdef MAIN_PROGRAM
|
||||
= { "domain", "owner", "mail", "host", NULL }
|
||||
#endif
|
||||
;
|
||||
|
||||
DECL const char *transport_strings[]
|
||||
#ifdef MAIN_PROGRAM
|
||||
= { "primary", "secondary", "response", NULL }
|
||||
#endif
|
||||
;
|
||||
|
||||
DECL const char *severity_strings[]
|
||||
#ifdef MAIN_PROGRAM
|
||||
= { "ignore", "warn", "fail", "not_set", NULL }
|
||||
#endif
|
||||
;
|
||||
|
||||
DECL struct in_addr inaddr_any; /* Inits to 0.0.0.0 */
|
||||
|
||||
DECL options server_options INIT(NULL);
|
||||
|
||||
DECL server_info nameserver_info INIT(NULL);
|
||||
|
||||
/* These will disappear some day in favour of "struct nameser". */
|
||||
DECL ip_match_list bogus_nameservers INIT(NULL);
|
||||
|
||||
DECL log_context log_ctx;
|
||||
DECL int log_ctx_valid INIT(0);
|
||||
|
||||
DECL log_channel syslog_channel INIT(NULL);
|
||||
DECL log_channel debug_channel INIT(NULL);
|
||||
DECL log_channel stderr_channel INIT(NULL);
|
||||
DECL log_channel eventlib_channel INIT(NULL);
|
||||
DECL log_channel packet_channel INIT(NULL);
|
||||
DECL log_channel null_channel INIT(NULL);
|
||||
|
||||
DECL ip_match_list local_addresses INIT(NULL);
|
||||
DECL ip_match_list local_networks INIT(NULL);
|
||||
|
||||
/* are we running in no-fork mode? */
|
||||
|
||||
DECL int foreground INIT(0);
|
||||
|
||||
DECL const struct ns_sym logging_constants[]
|
||||
#ifdef MAIN_PROGRAM
|
||||
= {
|
||||
{ log_info, "info" },
|
||||
{ log_notice, "notice" },
|
||||
{ log_warning, "warning" },
|
||||
{ log_error, "error" },
|
||||
{ log_critical, "critical" },
|
||||
{ 0, NULL }
|
||||
}
|
||||
#endif
|
||||
;
|
||||
|
||||
DECL const struct ns_sym syslog_constants[]
|
||||
#ifdef MAIN_PROGRAM
|
||||
= {
|
||||
{ LOG_KERN, "kern" },
|
||||
{ LOG_USER, "user" },
|
||||
{ LOG_MAIL, "mail" },
|
||||
{ LOG_DAEMON, "daemon" },
|
||||
{ LOG_AUTH, "auth" },
|
||||
{ LOG_SYSLOG, "syslog" },
|
||||
{ LOG_LPR, "lpr" },
|
||||
#ifdef LOG_NEWS
|
||||
{ LOG_NEWS, "news" },
|
||||
#endif
|
||||
#ifdef LOG_UUCP
|
||||
{ LOG_UUCP, "uucp" },
|
||||
#endif
|
||||
#ifdef LOG_CRON
|
||||
{ LOG_CRON, "cron" },
|
||||
#endif
|
||||
#ifdef LOG_AUTHPRIV
|
||||
{ LOG_AUTHPRIV, "authpriv" },
|
||||
#endif
|
||||
#ifdef LOG_FTP
|
||||
{ LOG_FTP, "ftp" },
|
||||
#endif
|
||||
{ LOG_LOCAL0, "local0"},
|
||||
{ LOG_LOCAL1, "local1"},
|
||||
{ LOG_LOCAL2, "local2"},
|
||||
{ LOG_LOCAL3, "local3"},
|
||||
{ LOG_LOCAL4, "local4"},
|
||||
{ LOG_LOCAL5, "local5"},
|
||||
{ LOG_LOCAL6, "local6"},
|
||||
{ LOG_LOCAL7, "local7"},
|
||||
{ 0, NULL }
|
||||
}
|
||||
#endif
|
||||
;
|
||||
|
||||
DECL const struct ns_sym category_constants[]
|
||||
#ifdef MAIN_PROGRAM
|
||||
= {
|
||||
{ ns_log_default, "default" },
|
||||
{ ns_log_config, "config" },
|
||||
{ ns_log_parser, "parser" },
|
||||
{ ns_log_queries, "queries" },
|
||||
{ ns_log_lame_servers, "lame-servers" },
|
||||
{ ns_log_statistics, "statistics" },
|
||||
{ ns_log_panic, "panic" },
|
||||
{ ns_log_update, "update" },
|
||||
{ ns_log_ncache, "ncache" },
|
||||
{ ns_log_xfer_in, "xfer-in" },
|
||||
{ ns_log_xfer_out, "xfer-out" },
|
||||
{ ns_log_db, "db" },
|
||||
{ ns_log_eventlib, "eventlib" },
|
||||
{ ns_log_packet, "packet" },
|
||||
{ ns_log_notify, "notify" },
|
||||
{ ns_log_cname, "cname" },
|
||||
{ ns_log_security, "security" },
|
||||
{ ns_log_os, "os" },
|
||||
{ ns_log_insist, "insist" },
|
||||
{ ns_log_maint, "maintenance" },
|
||||
{ ns_log_load, "load" },
|
||||
{ ns_log_resp_checks, "response-checks" },
|
||||
{ 0, NULL }
|
||||
}
|
||||
#endif
|
||||
;
|
||||
|
||||
DECL const char panic_msg_no_options[]
|
||||
INIT("no server_options in NS_OPTION_P");
|
||||
|
||||
DECL const char panic_msg_insist_failed[]
|
||||
INIT("%s:%d: insist '%s' failed: %s");
|
||||
|
||||
DECL const char panic_msg_bad_which[]
|
||||
INIT("%s:%d: INCRSTATS(%s): bad \"which\"");
|
||||
|
||||
DECL u_long globalStats[nssLast];
|
||||
|
||||
DECL evTimerID clean_timer;
|
||||
DECL evTimerID interface_timer;
|
||||
DECL evTimerID stats_timer;
|
||||
DECL int active_timers INIT(0);
|
||||
|
||||
DECL uid_t user_id;
|
||||
DECL char * user_name INIT(NULL);
|
||||
DECL gid_t group_id;
|
||||
DECL char * group_name INIT(NULL);
|
||||
DECL char * chroot_dir INIT(NULL);
|
||||
416
contrib/bind/bin/named/ns_glue.c
Normal file
416
contrib/bind/bin/named/ns_glue.c
Normal file
|
|
@ -0,0 +1,416 @@
|
|||
#if !defined(lint) && !defined(SABER)
|
||||
static char rcsid[] = "$Id: ns_glue.c,v 8.7 1998/02/13 19:51:45 halley Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <resolv.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
#include <isc/memcluster.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
|
||||
/*
|
||||
* IP address from unaligned octets.
|
||||
*/
|
||||
struct in_addr
|
||||
ina_get(const u_char *data) {
|
||||
struct in_addr ret;
|
||||
u_int32_t i;
|
||||
|
||||
GETLONG(i, data);
|
||||
ina_ulong(ret) = htonl(i);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* IP address to unaligned octets.
|
||||
*/
|
||||
u_char *
|
||||
ina_put(struct in_addr ina, u_char *data) {
|
||||
PUTLONG(ntohl(ina_ulong(ina)), data);
|
||||
return (data);
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX: sin_ntoa() should probably be in libc.
|
||||
*/
|
||||
const char *
|
||||
sin_ntoa(struct sockaddr_in sin) {
|
||||
static char ret[sizeof "[111.222.333.444].55555"];
|
||||
|
||||
sprintf(ret, "[%s].%u",
|
||||
inet_ntoa(sin.sin_addr),
|
||||
ntohs(sin.sin_port));
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* Logging Support
|
||||
*/
|
||||
|
||||
void
|
||||
ns_debug(int category, int level, const char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
if (!log_ctx_valid)
|
||||
return;
|
||||
va_start(args, format);
|
||||
log_vwrite(log_ctx, category, log_debug(level), format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void
|
||||
ns_info(int category, const char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
if (!log_ctx_valid)
|
||||
return;
|
||||
va_start(args, format);
|
||||
log_vwrite(log_ctx, category, log_info, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void
|
||||
ns_notice(int category, const char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
if (!log_ctx_valid)
|
||||
return;
|
||||
va_start(args, format);
|
||||
log_vwrite(log_ctx, category, log_notice, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void
|
||||
ns_warning(int category, const char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
if (!log_ctx_valid)
|
||||
return;
|
||||
va_start(args, format);
|
||||
log_vwrite(log_ctx, category, log_warning, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void
|
||||
ns_error(int category, const char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
if (!log_ctx_valid)
|
||||
return;
|
||||
va_start(args, format);
|
||||
log_vwrite(log_ctx, category, log_error, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void
|
||||
ns_panic(int category, int dump_core, const char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
if (!log_ctx_valid)
|
||||
return;
|
||||
va_start(args, format);
|
||||
log_vwrite(log_ctx, category, log_critical, format, args);
|
||||
va_end(args);
|
||||
va_start(args, format);
|
||||
log_vwrite(log_ctx, ns_log_panic, log_critical, format, args);
|
||||
va_end(args);
|
||||
if (dump_core)
|
||||
abort();
|
||||
else
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void
|
||||
ns_assertion_failed(char *file, int line, assertion_type type, char *cond,
|
||||
int print_errno)
|
||||
{
|
||||
ns_panic(ns_log_insist, 1, "%s:%d: %s(%s)%s%s failed.",
|
||||
file, line, assertion_type_to_text(type), cond,
|
||||
(print_errno) ? ": " : "",
|
||||
(print_errno) ? strerror(errno) : "");
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX This is for compatibility and will eventually be removed.
|
||||
*/
|
||||
void
|
||||
panic(const char *msg, const void *arg) {
|
||||
ns_panic(ns_log_default, 1, msg, arg);
|
||||
}
|
||||
|
||||
/*
|
||||
* How many labels in this name?
|
||||
* Note: the root label is not included in the count.
|
||||
*/
|
||||
int
|
||||
nlabels (const char *dname) {
|
||||
int count, i, found, escaped;
|
||||
const char *tmpdname, *end_tmpdname;
|
||||
int tmpdnamelen, c;
|
||||
|
||||
INSIST(dname != NULL);
|
||||
|
||||
count = 0;
|
||||
tmpdname = dname;
|
||||
tmpdnamelen = strlen(tmpdname);
|
||||
/*
|
||||
* Ignore a trailing label separator (i.e. an unescaped dot)
|
||||
* in 'tmpdname'.
|
||||
*/
|
||||
if (tmpdnamelen && tmpdname[tmpdnamelen-1] == '.') {
|
||||
escaped = 0;
|
||||
/* note this loop doesn't get executed if tmpdnamelen==1 */
|
||||
for (i = tmpdnamelen - 2; i >= 0; i--)
|
||||
if (tmpdname[i] == '\\') {
|
||||
if (escaped)
|
||||
escaped = 0;
|
||||
else
|
||||
escaped = 1;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
if (!escaped)
|
||||
tmpdnamelen--;
|
||||
}
|
||||
|
||||
end_tmpdname = tmpdname + tmpdnamelen;
|
||||
|
||||
while(tmpdname != end_tmpdname) {
|
||||
count++;
|
||||
/*
|
||||
* Strip off the first label if we're not already at
|
||||
* the root label.
|
||||
*/
|
||||
for (escaped = found = 0;
|
||||
(tmpdname != end_tmpdname) && !found;
|
||||
tmpdname++) {
|
||||
c = *tmpdname;
|
||||
if (!escaped && (c == '.'))
|
||||
found = 1;
|
||||
|
||||
if (escaped)
|
||||
escaped = 0;
|
||||
else if (c == '\\')
|
||||
escaped = 1;
|
||||
}
|
||||
}
|
||||
|
||||
ns_debug(ns_log_default, 12, "nlabels of \"%s\" -> %d", dname,
|
||||
count);
|
||||
return (count);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get current system time and put it in a global.
|
||||
*/
|
||||
void
|
||||
gettime(struct timeval *ttp) {
|
||||
if (gettimeofday(ttp, NULL) < 0)
|
||||
ns_error(ns_log_default, "gettimeofday: %s", strerror(errno));
|
||||
}
|
||||
|
||||
/*
|
||||
* This is useful for tracking down lost file descriptors.
|
||||
*/
|
||||
int
|
||||
my_close(int fd) {
|
||||
int s;
|
||||
|
||||
do {
|
||||
errno = 0;
|
||||
s = close(fd);
|
||||
} while (s < 0 && errno == EINTR);
|
||||
|
||||
if (s < 0 && errno != EBADF)
|
||||
ns_info(ns_log_default, "close(%d) failed: %s", fd,
|
||||
strerror(errno));
|
||||
else
|
||||
ns_debug(ns_log_default, 3, "close(%d) succeeded", fd);
|
||||
return (s);
|
||||
}
|
||||
|
||||
/*
|
||||
* This is useful for tracking down lost file descriptors.
|
||||
*/
|
||||
int
|
||||
my_fclose(FILE *fp) {
|
||||
int fd = fileno(fp),
|
||||
s = fclose(fp);
|
||||
|
||||
if (s < 0)
|
||||
ns_info(ns_log_default, "fclose(%d) failed: %m", fd,
|
||||
strerror(errno));
|
||||
else
|
||||
ns_debug(ns_log_default, 3, "fclose(%d) succeeded", fd);
|
||||
return (s);
|
||||
}
|
||||
|
||||
/*
|
||||
* Save a counted buffer and return a pointer to it.
|
||||
*/
|
||||
u_char *
|
||||
savebuf(const u_char *buf, size_t len, int needpanic) {
|
||||
u_char *bp = (u_char *)memget(len);
|
||||
|
||||
if (bp == NULL) {
|
||||
if (needpanic)
|
||||
panic("savebuf: memget failed (%s)", strerror(errno));
|
||||
else
|
||||
return (NULL);
|
||||
}
|
||||
memcpy(bp, buf, len);
|
||||
return (bp);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_STRINGS
|
||||
char *
|
||||
debug_newstr(size_t len, int needpanic, const char *file, int line) {
|
||||
size_t size;
|
||||
|
||||
size = len + 3; /* 2 length bytes + NUL. */
|
||||
printf("%s:%d: newstr %d\n", file, line, size);
|
||||
return (__newstr(len, needpanic));
|
||||
}
|
||||
|
||||
char *
|
||||
debug_savestr(const char *str, int needpanic, const char *file, int line) {
|
||||
size_t len;
|
||||
|
||||
len = strlen(str);
|
||||
len += 3; /* 2 length bytes + NUL. */
|
||||
printf("%s:%d: savestr %d %s\n", file, line, len, str);
|
||||
return (__savestr(str, needpanic));
|
||||
}
|
||||
|
||||
void
|
||||
debug_freestr(char *str, const char *file, int line) {
|
||||
u_char *buf, *bp;
|
||||
size_t len;
|
||||
|
||||
buf = (u_char *)str - 2/*Len*/;
|
||||
bp = buf;
|
||||
NS_GET16(len, bp);
|
||||
len += 3; /* 2 length bytes + NUL. */
|
||||
printf("%s:%d: freestr %d %s\n", file, line, len, str);
|
||||
__freestr(str);
|
||||
return;
|
||||
}
|
||||
#endif /* DEBUG_STRINGS */
|
||||
|
||||
/*
|
||||
* Return a counted string buffer big enough for a string of length 'len'.
|
||||
*/
|
||||
char *
|
||||
__newstr(size_t len, int needpanic) {
|
||||
u_char *buf, *bp;
|
||||
|
||||
REQUIRE(len <= 65536);
|
||||
|
||||
buf = (u_char *)memget(2/*Len*/ + len + 1/*Nul*/);
|
||||
if (buf == NULL) {
|
||||
if (needpanic)
|
||||
panic("savestr: memget failed (%s)", strerror(errno));
|
||||
else
|
||||
return (NULL);
|
||||
}
|
||||
bp = buf;
|
||||
NS_PUT16(len, bp);
|
||||
return ((char *)bp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Save a NUL terminated string and return a pointer to it.
|
||||
*/
|
||||
char *
|
||||
__savestr(const char *str, int needpanic) {
|
||||
char *buf;
|
||||
size_t len;
|
||||
|
||||
len = strlen(str);
|
||||
if (len > 65536) {
|
||||
if (needpanic)
|
||||
ns_panic(ns_log_default, 1,
|
||||
"savestr: string too long");
|
||||
else
|
||||
return (NULL);
|
||||
}
|
||||
buf = __newstr(len, needpanic);
|
||||
memcpy(buf, str, len + 1);
|
||||
return (buf);
|
||||
}
|
||||
|
||||
void
|
||||
__freestr(char *str) {
|
||||
u_char *buf, *bp;
|
||||
size_t len;
|
||||
|
||||
buf = (u_char *)str - 2/*Len*/;
|
||||
bp = buf;
|
||||
NS_GET16(len, bp);
|
||||
memput(buf, 2/*Len*/ + len + 1/*Nul*/);
|
||||
}
|
||||
|
||||
char *
|
||||
checked_ctime(const time_t *t) {
|
||||
char *ctime_result;
|
||||
|
||||
ctime_result = ctime(t);
|
||||
if (ctime_result == NULL) {
|
||||
ns_error(ns_log_default, "ctime() returned NULL!");
|
||||
ctime_result = "<unknown time>\n";
|
||||
}
|
||||
|
||||
return (ctime_result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Since the fields in a "struct timeval" are longs, and the argument to ctime
|
||||
* is a pointer to a time_t (which might not be a long), here's a bridge.
|
||||
*/
|
||||
char *
|
||||
ctimel(long l) {
|
||||
time_t t = (time_t)l;
|
||||
|
||||
return (checked_ctime(&t));
|
||||
}
|
||||
512
contrib/bind/bin/named/ns_init.c
Normal file
512
contrib/bind/bin/named/ns_init.c
Normal file
|
|
@ -0,0 +1,512 @@
|
|||
#if !defined(lint) && !defined(SABER)
|
||||
static char sccsid[] = "@(#)ns_init.c 4.38 (Berkeley) 3/21/91";
|
||||
static char rcsid[] = "$Id: ns_init.c,v 8.40 1998/04/07 18:11:58 halley Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1986, 1990
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* 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, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1996, 1997 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
#include <isc/memcluster.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
static void content_zone(int, int);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Set new refresh time for zone. Use a random number in the last half of
|
||||
* the refresh limit; we want it to be substantially correct while still
|
||||
* preventing slave synchronization.
|
||||
*/
|
||||
void
|
||||
ns_refreshtime(struct zoneinfo *zp, time_t timebase) {
|
||||
u_long refresh = (zp->z_refresh > 0) ? zp->z_refresh : INIT_REFRESH;
|
||||
time_t half = (refresh + 1) / 2;
|
||||
|
||||
zp->z_time = timebase + half + (rand() % half);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set new retry time for zone.
|
||||
*/
|
||||
void
|
||||
ns_retrytime(struct zoneinfo *zp, time_t timebase) {
|
||||
zp->z_time = timebase + zp->z_retry;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read configuration file and save it as internal state.
|
||||
*/
|
||||
void
|
||||
ns_init(const char *conffile) {
|
||||
struct zoneinfo *zp;
|
||||
static int loads = 0; /* number of times loaded */
|
||||
|
||||
ns_debug(ns_log_config, 1, "ns_init(%s)", conffile);
|
||||
gettime(&tt);
|
||||
|
||||
if (loads == 0) {
|
||||
zones = (struct zoneinfo *)memget(64 * sizeof *zones);
|
||||
if (zones == NULL)
|
||||
ns_panic(ns_log_config, 0,
|
||||
"Not enough memory to allocate initial zones array");
|
||||
memset(zones, 0, 64 * sizeof *zones);
|
||||
nzones = 1; /* zone zero is cache data */
|
||||
/* allocate cache hash table, formerly the root hash table. */
|
||||
hashtab = savehash((struct hashbuf *)NULL);
|
||||
|
||||
/* allocate root-hints/file-cache hash table */
|
||||
fcachetab = savehash((struct hashbuf *)NULL);
|
||||
/* init zone data */
|
||||
zones[0].z_type = Z_CACHE;
|
||||
zones[0].z_origin = savestr("", 1);
|
||||
init_configuration();
|
||||
} else {
|
||||
/* Mark previous zones as not yet found in boot file. */
|
||||
for (zp = &zones[1]; zp < &zones[nzones]; zp++)
|
||||
zp->z_flags &= ~Z_FOUND;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (debug >= 3) {
|
||||
ns_debug(ns_log_config, 3, "content of zones before loading");
|
||||
content_zone(nzones - 1, 3);
|
||||
}
|
||||
#endif
|
||||
|
||||
load_configuration(conffile);
|
||||
|
||||
/* Erase all old zones that were not found. */
|
||||
for (zp = &zones[1]; zp < &zones[nzones]; zp++) {
|
||||
if (zp->z_type && (zp->z_flags & Z_FOUND) == 0) {
|
||||
#ifdef BIND_UPDATE
|
||||
/*
|
||||
* A dynamic zone might have changed, so we
|
||||
* need to dump it before removing it.
|
||||
*/
|
||||
if ((zp->z_flags & Z_DYNAMIC) &&
|
||||
((zp->z_flags & Z_NEED_SOAUPDATE) ||
|
||||
(zp->z_flags & Z_NEED_DUMP)))
|
||||
(void)zonedump(zp);
|
||||
#endif
|
||||
ns_stopxfrs(zp);
|
||||
do_reload(zp->z_origin, zp->z_type, zp->z_class);
|
||||
ns_notice(ns_log_config,
|
||||
"%s zone \"%s\" (%s) removed",
|
||||
zoneTypeString(zp), zp->z_origin,
|
||||
p_class(zp->z_class));
|
||||
free_zone_contents(zp, 1);
|
||||
memset(zp, 0, sizeof(*zp));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (debug >= 2) {
|
||||
ns_debug(ns_log_config, 2, "content of zones after loading");
|
||||
content_zone(nzones-1, 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
ns_debug(ns_log_config, 1, "exit ns_init()");
|
||||
loads++;
|
||||
}
|
||||
|
||||
void
|
||||
zoneinit(struct zoneinfo *zp) {
|
||||
struct stat sb;
|
||||
int result;
|
||||
|
||||
/*
|
||||
* Try to load zone from backup file,
|
||||
* if one was specified and it exists.
|
||||
* If not, or if the data are out of date,
|
||||
* we will refresh the zone from a primary
|
||||
* immediately.
|
||||
*/
|
||||
if (!zp->z_source)
|
||||
return;
|
||||
result = stat(zp->z_source, &sb);
|
||||
if (result != -1) {
|
||||
ns_stopxfrs(zp);
|
||||
purge_zone(zp->z_origin, hashtab, zp->z_class);
|
||||
}
|
||||
if (result == -1 || db_load(zp->z_source, zp->z_origin, zp, NULL)) {
|
||||
/*
|
||||
* Set zone to be refreshed immediately.
|
||||
*/
|
||||
zp->z_refresh = INIT_REFRESH;
|
||||
zp->z_retry = INIT_REFRESH;
|
||||
if (!(zp->z_flags & (Z_QSERIAL|Z_XFER_RUNNING))) {
|
||||
zp->z_time = tt.tv_sec;
|
||||
sched_zone_maint(zp);
|
||||
}
|
||||
} else {
|
||||
zp->z_flags |= Z_AUTH;
|
||||
zp->z_flags &= ~Z_NEED_RELOAD;
|
||||
ns_refreshtime(zp, tt.tv_sec);
|
||||
sched_zone_maint(zp);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
do_reload(const char *domain, int type, int class) {
|
||||
struct zoneinfo *zp;
|
||||
|
||||
ns_debug(ns_log_config, 1, "do_reload: %s %d %d",
|
||||
*domain ? domain : ".", type, class);
|
||||
|
||||
/*
|
||||
* Check if the zone has changed type. If so, we might not need to
|
||||
* do any purging or parent reloading.
|
||||
*
|
||||
* If the new zone is a master zone, then it will have purged the
|
||||
* old data and loaded, so we don't need to do anything.
|
||||
*
|
||||
* If the new zone is a slave or stub zone and has successfully loaded,
|
||||
* then we don't need to do anything either.
|
||||
*
|
||||
* NOTE: we take care not to match ourselves.
|
||||
*/
|
||||
if ((type != z_master &&
|
||||
find_zone(domain, z_master, class) != NULL) ||
|
||||
(type != z_slave &&
|
||||
(zp = find_zone(domain, z_slave, class)) != NULL &&
|
||||
zp->z_serial != 0) ||
|
||||
(type != z_stub &&
|
||||
(zp = find_zone(domain, z_stub, class)) != NULL &&
|
||||
zp->z_serial != 0)
|
||||
)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Clean up any leftover data.
|
||||
*/
|
||||
purge_zone(domain, hashtab, class);
|
||||
|
||||
/*
|
||||
* Reload
|
||||
*/
|
||||
while (*domain) {
|
||||
const char *s;
|
||||
int escaped;
|
||||
|
||||
/*
|
||||
* XXX this is presentation level hair and belongs elsewhere.
|
||||
*/
|
||||
escaped = 0;
|
||||
for (s = domain; *s != '\0'; s++) {
|
||||
if (!escaped) {
|
||||
if (*s == '.')
|
||||
break;
|
||||
else if (*s == '\\')
|
||||
escaped = 1;
|
||||
} else
|
||||
escaped = 0;
|
||||
}
|
||||
|
||||
if (*s != '\0')
|
||||
domain = s + 1; /* skip label and its separator */
|
||||
else
|
||||
domain = ""; /* root zone */
|
||||
|
||||
if ((zp = find_zone(domain, Z_STUB, class)) ||
|
||||
(zp = find_zone(domain, Z_CACHE, class)) ||
|
||||
(zp = find_zone(domain, Z_PRIMARY, class)) ||
|
||||
(zp = find_zone(domain, Z_SECONDARY, class))) {
|
||||
|
||||
ns_debug(ns_log_config, 1, "do_reload: matched %s",
|
||||
*domain ? domain : ".");
|
||||
|
||||
if (zp->z_type == Z_CACHE)
|
||||
purge_zone(zp->z_origin, fcachetab,
|
||||
zp->z_class);
|
||||
else
|
||||
purge_zone(zp->z_origin, hashtab, zp->z_class);
|
||||
|
||||
zp->z_flags &= ~Z_AUTH;
|
||||
|
||||
switch (zp->z_type) {
|
||||
case Z_SECONDARY:
|
||||
case Z_STUB:
|
||||
zoneinit(zp);
|
||||
break;
|
||||
case Z_PRIMARY:
|
||||
if (db_load(zp->z_source, zp->z_origin, zp, 0)
|
||||
== 0)
|
||||
zp->z_flags |= Z_AUTH;
|
||||
break;
|
||||
case Z_CACHE:
|
||||
(void)db_load(zp->z_source, zp->z_origin, zp,
|
||||
0);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
/* prints out the content of zones */
|
||||
static void
|
||||
content_zone(int end, int level) {
|
||||
int i;
|
||||
|
||||
for (i = 1; i <= end; i++) {
|
||||
printzoneinfo(i, ns_log_config, level);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
enum context
|
||||
ns_ptrcontext(owner)
|
||||
const char *owner;
|
||||
{
|
||||
if (samedomain(owner, "in-addr.arpa") || samedomain(owner, "ip6.int"))
|
||||
return (hostname_ctx);
|
||||
return (domain_ctx);
|
||||
}
|
||||
|
||||
enum context
|
||||
ns_ownercontext(type, transport)
|
||||
int type;
|
||||
enum transport transport;
|
||||
{
|
||||
enum context context = domain_ctx;
|
||||
|
||||
switch (type) {
|
||||
case T_A:
|
||||
case T_WKS:
|
||||
case T_MX:
|
||||
switch (transport) {
|
||||
case primary_trans:
|
||||
case secondary_trans:
|
||||
context = owner_ctx;
|
||||
break;
|
||||
case response_trans:
|
||||
context = hostname_ctx;
|
||||
break;
|
||||
default:
|
||||
panic("impossible condition in ns_ownercontext()",
|
||||
NULL);
|
||||
}
|
||||
break;
|
||||
case T_MB:
|
||||
case T_MG:
|
||||
context = mailname_ctx;
|
||||
break;
|
||||
default:
|
||||
/* Nothing to do. */
|
||||
break;
|
||||
}
|
||||
return (context);
|
||||
}
|
||||
|
||||
int
|
||||
ns_nameok(const char *name, int class, struct zoneinfo *zp,
|
||||
enum transport transport,
|
||||
enum context context,
|
||||
const char *owner,
|
||||
struct in_addr source)
|
||||
{
|
||||
enum severity severity = not_set;
|
||||
int ok = 1;
|
||||
|
||||
if (zp != NULL)
|
||||
severity = zp->z_checknames;
|
||||
if (severity == not_set)
|
||||
severity = server_options->check_names[transport];
|
||||
|
||||
if (severity == ignore)
|
||||
return (1);
|
||||
switch (context) {
|
||||
case domain_ctx:
|
||||
ok = (class != C_IN) || res_dnok(name);
|
||||
break;
|
||||
case owner_ctx:
|
||||
ok = (class != C_IN) || res_ownok(name);
|
||||
break;
|
||||
case mailname_ctx:
|
||||
ok = res_mailok(name);
|
||||
break;
|
||||
case hostname_ctx:
|
||||
ok = res_hnok(name);
|
||||
break;
|
||||
default:
|
||||
ns_panic(ns_log_default, 1,
|
||||
"unexpected context %d in ns_nameok", (int)context);
|
||||
}
|
||||
if (!ok) {
|
||||
char *s, *o;
|
||||
|
||||
if (source.s_addr == INADDR_ANY)
|
||||
s = savestr(transport_strings[transport], 0);
|
||||
else {
|
||||
s = newstr(strlen(transport_strings[transport]) +
|
||||
sizeof " from [000.000.000.000]", 0);
|
||||
if (s)
|
||||
sprintf(s, "%s from [%s]",
|
||||
transport_strings[transport],
|
||||
inet_ntoa(source));
|
||||
}
|
||||
if (strcasecmp(owner, name) == 0)
|
||||
o = savestr("", 0);
|
||||
else {
|
||||
const char *t = (*owner == '\0') ? "." : owner;
|
||||
|
||||
o = newstr(strlen(t) + sizeof " (owner \"\")", 0);
|
||||
if (o)
|
||||
sprintf(o, " (owner \"%s\")", t);
|
||||
}
|
||||
/*
|
||||
* We use log_write directly here to avoid duplicating
|
||||
* the message formatting and arguments.
|
||||
*/
|
||||
log_write(log_ctx, ns_log_default,
|
||||
(transport == response_trans) ?
|
||||
log_info : log_notice,
|
||||
"%s name \"%s\"%s %s (%s) is invalid - %s",
|
||||
context_strings[context],
|
||||
name, o != NULL ? o : "[memget failed]",
|
||||
p_class(class),
|
||||
s != NULL ? s : "[memget failed]",
|
||||
(severity == fail) ?
|
||||
"rejecting" : "proceeding anyway");
|
||||
if (severity == warn)
|
||||
ok = 1;
|
||||
if (s != NULL)
|
||||
freestr(s);
|
||||
if (o != NULL)
|
||||
freestr(o);
|
||||
}
|
||||
return (ok);
|
||||
}
|
||||
|
||||
int
|
||||
ns_wildcard(const char *name) {
|
||||
if (*name != '*')
|
||||
return (0);
|
||||
return (*++name == '\0');
|
||||
}
|
||||
|
||||
void
|
||||
ns_shutdown() {
|
||||
struct zoneinfo *zp;
|
||||
|
||||
/* Erase zones. */
|
||||
for (zp = &zones[0]; zp < &zones[nzones]; zp++) {
|
||||
if (zp->z_type) {
|
||||
if (zp->z_type != z_hint) {
|
||||
ns_stopxfrs(zp);
|
||||
purge_zone(zp->z_origin, hashtab, zp->z_class);
|
||||
}
|
||||
free_zone_contents(zp, 1);
|
||||
}
|
||||
}
|
||||
memput(zones, ((nzones / 64) + 1) * 64 * sizeof *zones);
|
||||
|
||||
/* Erase the cache. */
|
||||
clean_cache(hashtab, 1);
|
||||
hashtab->h_cnt = 0; /* ??? */
|
||||
rm_hash(hashtab);
|
||||
clean_cache(fcachetab, 1);
|
||||
fcachetab->h_cnt = 0; /* ??? */
|
||||
rm_hash(fcachetab);
|
||||
|
||||
#ifdef BIND_NOTIFY
|
||||
db_cancel_pending_notifies();
|
||||
#endif
|
||||
freeComplaints();
|
||||
shutdown_configuration();
|
||||
}
|
||||
750
contrib/bind/bin/named/ns_lexer.c
Normal file
750
contrib/bind/bin/named/ns_lexer.c
Normal file
|
|
@ -0,0 +1,750 @@
|
|||
#if !defined(lint) && !defined(SABER)
|
||||
static char rcsid[] = "$Id: ns_lexer.c,v 8.12 1997/12/04 08:11:52 halley Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <stdarg.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
#include <isc/memcluster.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
#include "ns_parser.h"
|
||||
#include "ns_parseutil.h"
|
||||
#include "ns_lexer.h"
|
||||
|
||||
typedef enum lexer_state {
|
||||
scan, number, identifier, ipv4, quoted_string
|
||||
} LexerState;
|
||||
|
||||
#define LEX_EOF 0x01
|
||||
|
||||
typedef struct lexer_file_context {
|
||||
const char * name;
|
||||
FILE * stream;
|
||||
int line_number;
|
||||
LexerState state;
|
||||
u_int flags;
|
||||
int warnings;
|
||||
int errors;
|
||||
struct lexer_file_context *
|
||||
next;
|
||||
} *LexerFileContext;
|
||||
|
||||
LexerFileContext current_file = NULL;
|
||||
|
||||
#define LEX_LAST_WAS_DOT 0x01
|
||||
#define LEX_CONSECUTIVE_DOTS 0x02
|
||||
|
||||
typedef struct lexer_identifier {
|
||||
char buffer[LEX_MAX_IDENT_SIZE+1];
|
||||
int index;
|
||||
int num_dots;
|
||||
unsigned int flags;
|
||||
} *LexerIdentifier;
|
||||
|
||||
static LexerIdentifier id;
|
||||
|
||||
static char special_chars[256];
|
||||
|
||||
#define whitespace(c) ((c) == ' ' || (c) == '\t' || (c) == '\n')
|
||||
#define domain_char(c) (isalnum((c)) || (c) == '.' || (c) == '-')
|
||||
#define special_char(c) (special_chars[(c)] == 1)
|
||||
#define identifier_char(c) (!whitespace(c) && !special_char(c))
|
||||
|
||||
static int last_token;
|
||||
static YYSTYPE last_yylval;
|
||||
|
||||
static int lexer_initialized = 0;
|
||||
|
||||
/*
|
||||
* Problem Reporting
|
||||
*/
|
||||
|
||||
static char *
|
||||
token_to_text(int token, YYSTYPE lval) {
|
||||
static char buffer[LEX_MAX_IDENT_SIZE+50];
|
||||
|
||||
if (token < 128) {
|
||||
if (token == 0)
|
||||
strcpy(buffer, "<end of file>");
|
||||
else
|
||||
sprintf(buffer, "'%c'", token);
|
||||
} else {
|
||||
switch (token) {
|
||||
case L_EOS:
|
||||
strcpy(buffer, ";");
|
||||
break;
|
||||
case L_STRING:
|
||||
sprintf(buffer, "'%s'", lval.cp);
|
||||
break;
|
||||
case L_QSTRING:
|
||||
sprintf(buffer, "\"%s\"", lval.cp);
|
||||
break;
|
||||
case L_IPADDR:
|
||||
sprintf(buffer, "%s", inet_ntoa(lval.ip_addr));
|
||||
break;
|
||||
case L_NUMBER:
|
||||
sprintf(buffer, "%ld", lval.num);
|
||||
break;
|
||||
case L_END_INCLUDE:
|
||||
sprintf(buffer, "<end of include>");
|
||||
break;
|
||||
default:
|
||||
sprintf(buffer, "%s", lval.cp);
|
||||
}
|
||||
}
|
||||
|
||||
return (buffer);
|
||||
}
|
||||
|
||||
static char where[MAXPATHLEN + 100];
|
||||
static char message[20480];
|
||||
|
||||
static void
|
||||
parser_complain(int is_warning, int print_last_token, const char *format,
|
||||
va_list args)
|
||||
{
|
||||
LexerFileContext lf;
|
||||
int severity;
|
||||
|
||||
if (is_warning) {
|
||||
severity = log_warning;
|
||||
} else {
|
||||
severity = log_error;
|
||||
}
|
||||
|
||||
INSIST(current_file != NULL);
|
||||
if (current_file->next != NULL) {
|
||||
for (lf = current_file; lf != NULL; lf = lf->next) {
|
||||
log_write(log_ctx, ns_log_parser, severity,
|
||||
"%s '%s' line %d",
|
||||
(lf == current_file) ?
|
||||
"In" : "included from",
|
||||
lf->name, lf->line_number);
|
||||
}
|
||||
}
|
||||
sprintf(where, "%s:%d: ", current_file->name,
|
||||
current_file->line_number);
|
||||
vsprintf(message, format, args);
|
||||
if (print_last_token)
|
||||
log_write(log_ctx, ns_log_parser, severity, "%s%s near %s",
|
||||
where, message,
|
||||
token_to_text(last_token, last_yylval));
|
||||
else
|
||||
log_write(log_ctx, ns_log_parser, severity,
|
||||
"%s%s", where, message);
|
||||
}
|
||||
|
||||
int
|
||||
parser_warning(int print_last_token, const char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
parser_complain(1, print_last_token, format, args);
|
||||
va_end(args);
|
||||
current_file->warnings++;
|
||||
return (1);
|
||||
}
|
||||
|
||||
int
|
||||
parser_error(int print_last_token, const char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
parser_complain(0, print_last_token, format, args);
|
||||
va_end(args);
|
||||
current_file->errors++;
|
||||
return (1);
|
||||
}
|
||||
|
||||
void
|
||||
yyerror(const char *message) {
|
||||
parser_error(1, message);
|
||||
}
|
||||
|
||||
/*
|
||||
* Keywords
|
||||
*/
|
||||
|
||||
struct keyword {
|
||||
char *name;
|
||||
int token;
|
||||
};
|
||||
|
||||
/*
|
||||
* "keywords" is an array of the keywords which are the fixed syntactic
|
||||
* elements of the configuration file. Each keyword has a string version
|
||||
* of the keyword and a token id, which should be an identifier which
|
||||
* matches that in a %token statement inside the parser.y file.
|
||||
*/
|
||||
static struct keyword keywords[] = {
|
||||
{"acl", T_ACL},
|
||||
{"address", T_ADDRESS},
|
||||
{"algorithm", T_ALGID},
|
||||
{"allow-query", T_ALLOW_QUERY},
|
||||
{"allow-transfer", T_ALLOW_TRANSFER},
|
||||
{"allow-update", T_ALLOW_UPDATE},
|
||||
{"also-notify", T_ALSO_NOTIFY},
|
||||
{"auth-nxdomain", T_AUTH_NXDOMAIN},
|
||||
{"bogus", T_BOGUS},
|
||||
{"category", T_CATEGORY},
|
||||
{"channel", T_CHANNEL},
|
||||
{"check-names", T_CHECK_NAMES},
|
||||
{"cleaning-interval", T_CLEAN_INTERVAL},
|
||||
{"coresize", T_CORESIZE},
|
||||
{"datasize", T_DATASIZE},
|
||||
{"deallocate-on-exit", T_DEALLOC_ON_EXIT},
|
||||
{"debug", T_DEBUG},
|
||||
{"default", T_DEFAULT},
|
||||
{"directory", T_DIRECTORY},
|
||||
{"dump-file", T_DUMP_FILE},
|
||||
{"dynamic", T_DYNAMIC},
|
||||
{"fail", T_FAIL},
|
||||
{"fake-iquery", T_FAKE_IQUERY},
|
||||
{"false", T_FALSE},
|
||||
{"fetch-glue", T_FETCH_GLUE},
|
||||
{"file", T_FILE},
|
||||
{"files", T_FILES},
|
||||
{"first", T_FIRST},
|
||||
{"forward", T_FORWARD},
|
||||
{"forwarders", T_FORWARDERS},
|
||||
{"hint", T_HINT},
|
||||
{"host-statistics", T_HOSTSTATS},
|
||||
{"if-no-answer", T_IF_NO_ANSWER},
|
||||
{"if-no-domain", T_IF_NO_DOMAIN},
|
||||
{"ignore", T_IGNORE},
|
||||
{"include", T_INCLUDE},
|
||||
{"interface-interval", T_INTERFACE_INTERVAL},
|
||||
{"key", T_SEC_KEY},
|
||||
{"keys", T_KEYS},
|
||||
{"listen-on", T_LISTEN_ON},
|
||||
{"logging", T_LOGGING},
|
||||
{"many-answers", T_MANY_ANSWERS},
|
||||
{"master", T_MASTER},
|
||||
{"masters", T_MASTERS},
|
||||
{"max-transfer-time-in", T_MAX_TRANSFER_TIME_IN},
|
||||
{"memstatistics-file", T_MEMSTATS_FILE},
|
||||
{"multiple-cnames", T_MULTIPLE_CNAMES},
|
||||
{"named-xfer", T_NAMED_XFER},
|
||||
{"no", T_NO},
|
||||
{"notify", T_NOTIFY},
|
||||
{"null", T_NULL_OUTPUT},
|
||||
{"one-answer", T_ONE_ANSWER},
|
||||
{"only", T_ONLY},
|
||||
{"options", T_OPTIONS},
|
||||
{"pid-file", T_PIDFILE},
|
||||
{"port", T_PORT},
|
||||
{"print-category", T_PRINT_CATEGORY},
|
||||
{"print-severity", T_PRINT_SEVERITY},
|
||||
{"print-time", T_PRINT_TIME},
|
||||
{"query-source", T_QUERY_SOURCE},
|
||||
{"recursion", T_RECURSION},
|
||||
{"response", T_RESPONSE},
|
||||
{"secret", T_SECRET},
|
||||
{"server", T_SERVER},
|
||||
{"severity", T_SEVERITY},
|
||||
{"size", T_SIZE},
|
||||
{"slave", T_SLAVE},
|
||||
{"stacksize", T_STACKSIZE},
|
||||
{"statistics-file", T_STATS_FILE},
|
||||
{"statistics-interval", T_STATS_INTERVAL},
|
||||
{"stub", T_STUB},
|
||||
{"syslog", T_SYSLOG},
|
||||
{"topology", T_TOPOLOGY},
|
||||
{"transfer-format", T_TRANSFER_FORMAT},
|
||||
{"transfer-source", T_TRANSFER_SOURCE},
|
||||
{"transfers", T_TRANSFERS},
|
||||
{"transfers-in", T_TRANSFERS_IN},
|
||||
{"transfers-out", T_TRANSFERS_OUT},
|
||||
{"transfers-per-ns", T_TRANSFERS_PER_NS},
|
||||
{"true", T_TRUE},
|
||||
{"type", T_TYPE},
|
||||
{"unlimited", T_UNLIMITED},
|
||||
{"versions", T_VERSIONS},
|
||||
{"warn", T_WARN},
|
||||
{"yes", T_YES},
|
||||
{"zone", T_ZONE},
|
||||
{(char *) NULL, 0},
|
||||
};
|
||||
|
||||
/*
|
||||
* The table size should be a prime chosen to minimize collisions.
|
||||
*/
|
||||
#define KEYWORD_TABLE_SIZE 461
|
||||
|
||||
static symbol_table keyword_table = NULL;
|
||||
|
||||
static void
|
||||
init_keywords() {
|
||||
struct keyword *k;
|
||||
symbol_value value;
|
||||
|
||||
if (keyword_table != NULL)
|
||||
free_symbol_table(keyword_table);
|
||||
keyword_table = new_symbol_table(KEYWORD_TABLE_SIZE, NULL);
|
||||
for (k = keywords; k->name != NULL; k++) {
|
||||
value.integer = k->token;
|
||||
define_symbol(keyword_table, k->name, 0, value, 0);
|
||||
}
|
||||
dprint_symbol_table(99, keyword_table);
|
||||
}
|
||||
|
||||
/*
|
||||
* File Contexts
|
||||
*/
|
||||
|
||||
void
|
||||
lexer_begin_file(const char *filename, FILE *stream) {
|
||||
LexerFileContext lf;
|
||||
|
||||
if (stream == NULL) {
|
||||
stream = fopen(filename, "r");
|
||||
if (stream == NULL) {
|
||||
parser_error(0, "couldn't open include file '%s'",
|
||||
filename);
|
||||
return;
|
||||
}
|
||||
}
|
||||
lf = (LexerFileContext)memget(sizeof (struct lexer_file_context));
|
||||
if (lf == NULL)
|
||||
panic("memget failed in lexer_begin_file", NULL);
|
||||
INSIST(stream != NULL);
|
||||
lf->stream = stream;
|
||||
lf->name = filename; /* note copy by reference */
|
||||
lf->line_number = 1;
|
||||
lf->state = scan;
|
||||
lf->flags = 0;
|
||||
lf->warnings = 0;
|
||||
lf->errors = 0;
|
||||
lf->next = current_file;
|
||||
current_file = lf;
|
||||
}
|
||||
|
||||
void
|
||||
lexer_end_file(void) {
|
||||
LexerFileContext lf;
|
||||
|
||||
INSIST(current_file != NULL);
|
||||
lf = current_file;
|
||||
current_file = lf->next;
|
||||
fclose(lf->stream);
|
||||
memput(lf, sizeof *lf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Character Input
|
||||
*/
|
||||
|
||||
static void
|
||||
scan_to_comment_end(int c_plus_plus_style) {
|
||||
int c, nc;
|
||||
int done = 0;
|
||||
int prev_was_star = 0;
|
||||
|
||||
while (!done) {
|
||||
c = getc(current_file->stream);
|
||||
switch (c) {
|
||||
case EOF:
|
||||
if (!c_plus_plus_style)
|
||||
parser_error(0, "EOF in comment");
|
||||
current_file->flags |= LEX_EOF;
|
||||
done = 1;
|
||||
break;
|
||||
case '*':
|
||||
prev_was_star = 1;
|
||||
break;
|
||||
case '/':
|
||||
if (prev_was_star && !c_plus_plus_style)
|
||||
done = 1;
|
||||
prev_was_star = 0;
|
||||
break;
|
||||
case '\n':
|
||||
if (c_plus_plus_style) {
|
||||
/* don't consume the newline because
|
||||
we want it to be a delimiter for
|
||||
anything before the comment
|
||||
started */
|
||||
ungetc(c, current_file->stream);
|
||||
done = 1;
|
||||
} else {
|
||||
current_file->line_number++;
|
||||
}
|
||||
prev_was_star = 0;
|
||||
break;
|
||||
default:
|
||||
prev_was_star = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
get_next_char(int comment_ok) {
|
||||
int c, nc;
|
||||
|
||||
if (current_file->flags & LEX_EOF)
|
||||
return (EOF);
|
||||
|
||||
c = getc(current_file->stream);
|
||||
|
||||
if (comment_ok) {
|
||||
while (c == '/' || c == '#') {
|
||||
if (c == '#') {
|
||||
scan_to_comment_end(1);
|
||||
if (current_file->flags & LEX_EOF)
|
||||
return (EOF);
|
||||
c = getc(current_file->stream);
|
||||
} else {
|
||||
nc = getc(current_file->stream);
|
||||
switch (nc) {
|
||||
case EOF:
|
||||
current_file->flags |= LEX_EOF;
|
||||
return ('/');
|
||||
case '*':
|
||||
case '/':
|
||||
scan_to_comment_end((nc == '/'));
|
||||
if (current_file->flags & LEX_EOF)
|
||||
return (EOF);
|
||||
c = getc(current_file->stream);
|
||||
break;
|
||||
default:
|
||||
ungetc((nc), current_file->stream);
|
||||
return ('/');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (c == EOF)
|
||||
current_file->flags |= LEX_EOF;
|
||||
else if (c == '\n')
|
||||
current_file->line_number++;
|
||||
return (c);
|
||||
}
|
||||
|
||||
void
|
||||
put_back_char(int c) {
|
||||
if (c == EOF)
|
||||
current_file->flags |= LEX_EOF;
|
||||
else {
|
||||
ungetc((c), current_file->stream);
|
||||
if (c == '\n')
|
||||
current_file->line_number--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Identifiers
|
||||
*/
|
||||
|
||||
static void
|
||||
clear_identifier(LexerIdentifier id) {
|
||||
INSIST(id != NULL);
|
||||
id->index = 0;
|
||||
id->num_dots = 0;
|
||||
id->flags = 0;
|
||||
}
|
||||
|
||||
static char *
|
||||
dup_identifier(LexerIdentifier id) {
|
||||
char *duplicate;
|
||||
|
||||
INSIST(id != NULL);
|
||||
duplicate = savestr(id->buffer, 1);
|
||||
return (duplicate);
|
||||
}
|
||||
|
||||
static void
|
||||
finish_identifier(LexerIdentifier id) {
|
||||
INSIST(id != NULL && id->index < LEX_MAX_IDENT_SIZE);
|
||||
id->buffer[id->index] = '\0';
|
||||
}
|
||||
|
||||
static void
|
||||
add_to_identifier(LexerIdentifier id, int c) {
|
||||
INSIST(id != NULL);
|
||||
id->buffer[id->index] = c;
|
||||
id->index++;
|
||||
if (id->index >= LEX_MAX_IDENT_SIZE) {
|
||||
parser_error(0, "identifier too long");
|
||||
current_file->state = scan;
|
||||
/* discard chars until we hit a non-identifier char */
|
||||
while (identifier_char(c)) {
|
||||
c = get_next_char(1);
|
||||
}
|
||||
put_back_char(c);
|
||||
clear_identifier(id);
|
||||
} else {
|
||||
if (c == '.') {
|
||||
if (id->flags & LEX_LAST_WAS_DOT)
|
||||
id->flags |= LEX_CONSECUTIVE_DOTS;
|
||||
id->flags |= LEX_LAST_WAS_DOT;
|
||||
id->num_dots++;
|
||||
} else {
|
||||
id->flags &= ~LEX_LAST_WAS_DOT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* yylex() -- return the next token from the current input stream
|
||||
*/
|
||||
int
|
||||
yylex() {
|
||||
int c, i;
|
||||
int comment_ok = 1;
|
||||
int token = -1;
|
||||
symbol_value value;
|
||||
|
||||
while (token < 0) {
|
||||
c = get_next_char(comment_ok);
|
||||
switch(current_file->state) {
|
||||
case scan:
|
||||
if (c == EOF) {
|
||||
if (current_file->next == NULL)
|
||||
/*
|
||||
* We don't want to call
|
||||
* lexer_end_file() here because we
|
||||
* want to keep the toplevel file
|
||||
* context to log errors against.
|
||||
*/
|
||||
token = 0;
|
||||
else {
|
||||
lexer_end_file();
|
||||
token = L_END_INCLUDE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (whitespace(c))
|
||||
break;
|
||||
if (identifier_char(c)) {
|
||||
if (isdigit(c))
|
||||
current_file->state = number;
|
||||
else
|
||||
current_file->state = identifier;
|
||||
clear_identifier(id);
|
||||
add_to_identifier(id, c);
|
||||
} else
|
||||
if (special_char(c)) {
|
||||
if (c == ';') {
|
||||
token = L_EOS;
|
||||
break;
|
||||
}
|
||||
if (c == '"') {
|
||||
clear_identifier(id);
|
||||
current_file->state =
|
||||
quoted_string;
|
||||
comment_ok = 0;
|
||||
break;
|
||||
}
|
||||
token = c;
|
||||
} else {
|
||||
parser_error(0,
|
||||
"invalid character '%c'",
|
||||
c);
|
||||
}
|
||||
break;
|
||||
|
||||
case number:
|
||||
if (identifier_char(c)) {
|
||||
if (!isdigit(c))
|
||||
current_file->state =
|
||||
(c == '.') ? ipv4 : identifier;
|
||||
add_to_identifier(id, c);
|
||||
} else {
|
||||
put_back_char(c);
|
||||
current_file->state = scan;
|
||||
finish_identifier(id);
|
||||
yylval.num = atoi(id->buffer);
|
||||
token = L_NUMBER;
|
||||
}
|
||||
break;
|
||||
|
||||
case identifier:
|
||||
if (identifier_char(c)) {
|
||||
add_to_identifier(id, c);
|
||||
} else {
|
||||
put_back_char(c);
|
||||
current_file->state = scan;
|
||||
finish_identifier(id);
|
||||
/* is it a keyword? */
|
||||
if (lookup_symbol(keyword_table, id->buffer,
|
||||
0, &value)) {
|
||||
yylval.cp = id->buffer;
|
||||
token = value.integer;
|
||||
} else {
|
||||
yylval.cp = dup_identifier(id);
|
||||
token = L_STRING;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ipv4:
|
||||
if (identifier_char(c)) {
|
||||
if (!isdigit(c)) {
|
||||
if (c != '.' ||
|
||||
(id->flags & LEX_CONSECUTIVE_DOTS))
|
||||
current_file->state =
|
||||
identifier;
|
||||
}
|
||||
add_to_identifier(id, c);
|
||||
} else {
|
||||
put_back_char(c);
|
||||
if (id->num_dots > 3 ||
|
||||
(id->flags & LEX_LAST_WAS_DOT))
|
||||
current_file->state = identifier;
|
||||
else {
|
||||
if (id->num_dots == 1) {
|
||||
add_to_identifier(id, '.');
|
||||
add_to_identifier(id, '0');
|
||||
add_to_identifier(id, '.');
|
||||
add_to_identifier(id, '0');
|
||||
} else if (id->num_dots == 2) {
|
||||
add_to_identifier(id, '.');
|
||||
add_to_identifier(id, '0');
|
||||
}
|
||||
current_file->state = scan;
|
||||
finish_identifier(id);
|
||||
token = L_IPADDR;
|
||||
if (inet_aton(id->buffer,
|
||||
&(yylval.ip_addr))==0) {
|
||||
yylval.cp = dup_identifier(id);
|
||||
token = L_STRING;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case quoted_string:
|
||||
if (c == EOF) {
|
||||
parser_error(0, "EOF in quoted string");
|
||||
return 0;
|
||||
} else {
|
||||
if (c == '"') {
|
||||
comment_ok = 1;
|
||||
current_file->state = scan;
|
||||
finish_identifier(id);
|
||||
yylval.cp = dup_identifier(id);
|
||||
token = L_QSTRING;
|
||||
} else {
|
||||
/* XXX add backslash escapes here */
|
||||
add_to_identifier(id, c);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
panic("unhandled state in yylex", NULL);
|
||||
}
|
||||
}
|
||||
|
||||
last_token = token;
|
||||
last_yylval = yylval;
|
||||
return (token);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialization
|
||||
*/
|
||||
|
||||
symbol_table constants;
|
||||
|
||||
static void
|
||||
import_constants(const struct ns_sym *s, int type) {
|
||||
symbol_value value;
|
||||
for ((void)NULL; s != NULL && s->name != NULL; s++) {
|
||||
value.integer = s->number;
|
||||
define_symbol(constants, s->name, type, value, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
import_res_constants(const struct res_sym *r, int type) {
|
||||
symbol_value value;
|
||||
for ((void)NULL; r != NULL && r->name != NULL; r++) {
|
||||
value.integer = r->number;
|
||||
define_symbol(constants, r->name, type, value, 0);
|
||||
}
|
||||
}
|
||||
|
||||
#define CONSTANTS_TABLE_SIZE 397 /* should be prime */
|
||||
|
||||
static void
|
||||
import_all_constants() {
|
||||
constants = new_symbol_table(CONSTANTS_TABLE_SIZE, NULL);
|
||||
import_res_constants(__p_class_syms, SYM_CLASS);
|
||||
import_constants(category_constants, SYM_CATEGORY);
|
||||
import_constants(logging_constants, SYM_LOGGING);
|
||||
import_constants(syslog_constants, SYM_SYSLOG);
|
||||
}
|
||||
|
||||
void
|
||||
lexer_initialize() {
|
||||
memset(special_chars, 0, sizeof special_chars);
|
||||
special_chars[';'] = 1;
|
||||
special_chars['{'] = 1;
|
||||
special_chars['}'] = 1;
|
||||
special_chars['!'] = 1;
|
||||
special_chars['/'] = 1;
|
||||
special_chars['"'] = 1;
|
||||
special_chars['*'] = 1;
|
||||
id = (LexerIdentifier)memget(sizeof (struct lexer_identifier));
|
||||
if (id == NULL)
|
||||
panic("memget failed in init_once", NULL);
|
||||
init_keywords();
|
||||
import_all_constants();
|
||||
lexer_initialized = 1;
|
||||
}
|
||||
|
||||
void
|
||||
lexer_setup(void) {
|
||||
REQUIRE(lexer_initialized);
|
||||
|
||||
current_file = NULL; /* XXX should we INSIST(current_file==NULL)? */
|
||||
INSIST(id != NULL);
|
||||
}
|
||||
|
||||
void
|
||||
lexer_shutdown(void) {
|
||||
REQUIRE(lexer_initialized);
|
||||
|
||||
free_symbol_table(keyword_table);
|
||||
free_symbol_table(constants);
|
||||
memput(id, sizeof (struct lexer_identifier));
|
||||
lexer_initialized = 0;
|
||||
}
|
||||
45
contrib/bind/bin/named/ns_lexer.h
Normal file
45
contrib/bind/bin/named/ns_lexer.h
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 1997 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef NS_LEXER_H
|
||||
#define NS_LEXER_H
|
||||
|
||||
/*
|
||||
* Note: <stdio.h> and "ns_parseutil.h" must be included
|
||||
* before this file is included.
|
||||
*/
|
||||
|
||||
#define LEX_MAX_IDENT_SIZE 1024
|
||||
|
||||
#define SYM_CLASS 0x01
|
||||
#define SYM_CATEGORY 0x02
|
||||
#define SYM_LOGGING 0x04
|
||||
#define SYM_SYSLOG 0x08
|
||||
|
||||
int parser_warning(int, const char *, ...);
|
||||
int parser_error(int, const char *, ...);
|
||||
void yyerror(const char *);
|
||||
void lexer_begin_file(const char *, FILE *);
|
||||
void lexer_end_file(void);
|
||||
int yylex(void);
|
||||
void lexer_initialize(void);
|
||||
void lexer_setup(void);
|
||||
void lexer_shutdown(void);
|
||||
|
||||
extern symbol_table constants;
|
||||
|
||||
#endif /* NS_LEXER_H */
|
||||
2200
contrib/bind/bin/named/ns_main.c
Normal file
2200
contrib/bind/bin/named/ns_main.c
Normal file
File diff suppressed because it is too large
Load diff
1210
contrib/bind/bin/named/ns_maint.c
Normal file
1210
contrib/bind/bin/named/ns_maint.c
Normal file
File diff suppressed because it is too large
Load diff
226
contrib/bind/bin/named/ns_ncache.c
Normal file
226
contrib/bind/bin/named/ns_ncache.c
Normal file
|
|
@ -0,0 +1,226 @@
|
|||
#if !defined(lint) && !defined(SABER)
|
||||
static char rcsid[] = "$Id: ns_ncache.c,v 8.17 1998/03/20 01:12:01 halley Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/file.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
|
||||
#define BOUNDS_CHECK(ptr, count) \
|
||||
do { \
|
||||
if ((ptr) + (count) > eom) { \
|
||||
return; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
void
|
||||
cache_n_resp(u_char *msg, int msglen, struct sockaddr_in from) {
|
||||
struct databuf *dp;
|
||||
HEADER *hp;
|
||||
u_char *cp, *eom, *rdatap;
|
||||
char dname[MAXDNAME];
|
||||
int n;
|
||||
int type, class;
|
||||
int Vcode;
|
||||
int flags;
|
||||
u_int16_t ancount;
|
||||
u_int dlen;
|
||||
|
||||
nameserIncr(from.sin_addr, nssRcvdNXD);
|
||||
|
||||
hp = (HEADER *)msg;
|
||||
cp = msg+HFIXEDSZ;
|
||||
eom = msg + msglen;
|
||||
|
||||
n = dn_expand(msg, eom, cp, dname, sizeof dname);
|
||||
if (n < 0) {
|
||||
ns_debug(ns_log_ncache, 1,
|
||||
"Query expand name failed: cache_n_resp");
|
||||
hp->rcode = FORMERR;
|
||||
return;
|
||||
}
|
||||
cp += n;
|
||||
BOUNDS_CHECK(cp, 2 * INT16SZ);
|
||||
GETSHORT(type, cp);
|
||||
GETSHORT(class, cp);
|
||||
ns_debug(ns_log_ncache, 1, "ncache: dname %s, type %d, class %d",
|
||||
dname, type, class);
|
||||
|
||||
ancount = ntohs(hp->ancount);
|
||||
|
||||
while (ancount--) {
|
||||
u_int32_t ttl;
|
||||
u_int16_t atype;
|
||||
u_int16_t aclass;
|
||||
n = dn_skipname(cp, eom);
|
||||
if (n < 0) {
|
||||
ns_debug(ns_log_ncache, 3, "ncache: form error");
|
||||
return;
|
||||
}
|
||||
cp += n;
|
||||
BOUNDS_CHECK(cp, 3 * INT16SZ + INT32SZ);
|
||||
GETSHORT(atype, cp);
|
||||
GETSHORT(aclass, cp);
|
||||
if (atype != T_CNAME || aclass != class) {
|
||||
ns_debug(ns_log_ncache, 3, "ncache: form error");
|
||||
return;
|
||||
}
|
||||
GETLONG(ttl, cp);
|
||||
GETSHORT(dlen, cp);
|
||||
BOUNDS_CHECK(cp, dlen);
|
||||
rdatap = cp;
|
||||
n = dn_expand(msg, msg + msglen, cp, dname, sizeof dname);
|
||||
if (n < 0) {
|
||||
ns_debug(ns_log_ncache, 3, "ncache: form error");
|
||||
return;
|
||||
}
|
||||
cp += n;
|
||||
if (cp != rdatap + dlen) {
|
||||
ns_debug(ns_log_ncache, 3, "ncache: form error");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef RETURNSOA
|
||||
if (hp->nscount) {
|
||||
u_int32_t ttl;
|
||||
u_int16_t atype;
|
||||
u_char *tp = cp;
|
||||
u_char *cp1;
|
||||
u_char data[MAXDATA];
|
||||
size_t len = sizeof data;
|
||||
|
||||
/* we store NXDOMAIN as T_SOA regardless of the query type */
|
||||
if (hp->rcode == NXDOMAIN)
|
||||
type = T_SOA;
|
||||
|
||||
/* store ther SOA record */
|
||||
n = dn_skipname(tp, msg + msglen);
|
||||
if (n < 0) {
|
||||
ns_debug(ns_log_ncache, 3, "ncache: form error");
|
||||
return;
|
||||
}
|
||||
tp += n;
|
||||
|
||||
BOUNDS_CHECK(tp, 3 * INT16SZ + INT32SZ);
|
||||
GETSHORT(atype, tp); /* type */
|
||||
if (atype != T_SOA) {
|
||||
ns_debug(ns_log_ncache, 3,
|
||||
"ncache: type (%d) != T_SOA", atype);
|
||||
goto no_soa;
|
||||
}
|
||||
tp += INT16SZ; /* class */
|
||||
GETLONG(ttl, tp); /* ttl */
|
||||
GETSHORT(dlen, tp); /* dlen */
|
||||
BOUNDS_CHECK(tp, dlen);
|
||||
rdatap = tp;
|
||||
|
||||
/* origin */
|
||||
n = dn_expand(msg, msg + msglen, tp, (char*)data, len);
|
||||
if (n < 0) {
|
||||
ns_debug(ns_log_ncache, 3,
|
||||
"ncache: origin form error");
|
||||
return;
|
||||
}
|
||||
tp += n;
|
||||
n = strlen((char*)data) + 1;
|
||||
cp1 = data + n;
|
||||
len -= n;
|
||||
/* mail */
|
||||
n = dn_expand(msg, msg + msglen, tp, (char*)cp1, len);
|
||||
if (n < 0) {
|
||||
ns_debug(ns_log_ncache, 3, "ncache: mail form error");
|
||||
return;
|
||||
}
|
||||
tp += n;
|
||||
n = strlen((char*)cp1) + 1;
|
||||
cp1 += n;
|
||||
len -= n;
|
||||
n = 5 * INT32SZ;
|
||||
BOUNDS_CHECK(tp, n);
|
||||
memcpy(cp1, tp, n);
|
||||
/* serial, refresh, retry, expire, min */
|
||||
cp1 += n;
|
||||
len -= n;
|
||||
tp += n;
|
||||
if (tp != rdatap + dlen) {
|
||||
ns_debug(ns_log_ncache, 3, "ncache: form error");
|
||||
return;
|
||||
}
|
||||
/* store the zone of the soa record */
|
||||
n = dn_expand(msg, msg + msglen, cp, (char*)cp1, len);
|
||||
if (n < 0) {
|
||||
ns_debug(ns_log_ncache, 3, "ncache: form error 2");
|
||||
return;
|
||||
}
|
||||
n = strlen((char*)cp1) + 1;
|
||||
cp1 += n;
|
||||
|
||||
dp = savedata(class, type, MIN(ttl, NTTL) + tt.tv_sec, data,
|
||||
cp1 - data);
|
||||
} else {
|
||||
no_soa:
|
||||
#endif
|
||||
dp = savedata(class, type, NTTL + tt.tv_sec, NULL, 0);
|
||||
#ifdef RETURNSOA
|
||||
}
|
||||
#endif
|
||||
dp->d_zone = DB_Z_CACHE;
|
||||
dp->d_cred = hp->aa ? DB_C_AUTH : DB_C_ANSWER;
|
||||
dp->d_clev = 0;
|
||||
if(hp->rcode == NXDOMAIN) {
|
||||
dp->d_rcode = NXDOMAIN;
|
||||
flags = DB_NODATA|DB_NOTAUTH|DB_NOHINTS;
|
||||
} else {
|
||||
dp->d_rcode = NOERROR_NODATA;
|
||||
flags = DB_NOTAUTH|DB_NOHINTS;
|
||||
}
|
||||
|
||||
if ((n = db_update(dname, dp, dp, NULL, flags, hashtab, from)) != OK) {
|
||||
ns_debug(ns_log_ncache, 1,
|
||||
"db_update failed (%d), cache_n_resp()", n);
|
||||
db_freedata(dp);
|
||||
return;
|
||||
}
|
||||
ns_debug(ns_log_ncache, 4,
|
||||
"ncache succeeded: [%s %s %s] rcode:%d ttl:%ld",
|
||||
dname, p_type(type), p_class(class),
|
||||
dp->d_rcode, (long)(dp->d_ttl - tt.tv_sec));
|
||||
}
|
||||
2376
contrib/bind/bin/named/ns_parser.c
Normal file
2376
contrib/bind/bin/named/ns_parser.c
Normal file
File diff suppressed because it is too large
Load diff
110
contrib/bind/bin/named/ns_parser.h
Normal file
110
contrib/bind/bin/named/ns_parser.h
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
#define YYEMPTY (-1)
|
||||
#define L_EOS 257
|
||||
#define L_IPADDR 258
|
||||
#define L_NUMBER 259
|
||||
#define L_STRING 260
|
||||
#define L_QSTRING 261
|
||||
#define L_END_INCLUDE 262
|
||||
#define T_INCLUDE 263
|
||||
#define T_OPTIONS 264
|
||||
#define T_DIRECTORY 265
|
||||
#define T_PIDFILE 266
|
||||
#define T_NAMED_XFER 267
|
||||
#define T_DUMP_FILE 268
|
||||
#define T_STATS_FILE 269
|
||||
#define T_MEMSTATS_FILE 270
|
||||
#define T_FAKE_IQUERY 271
|
||||
#define T_RECURSION 272
|
||||
#define T_FETCH_GLUE 273
|
||||
#define T_QUERY_SOURCE 274
|
||||
#define T_LISTEN_ON 275
|
||||
#define T_PORT 276
|
||||
#define T_ADDRESS 277
|
||||
#define T_DATASIZE 278
|
||||
#define T_STACKSIZE 279
|
||||
#define T_CORESIZE 280
|
||||
#define T_DEFAULT 281
|
||||
#define T_UNLIMITED 282
|
||||
#define T_FILES 283
|
||||
#define T_HOSTSTATS 284
|
||||
#define T_DEALLOC_ON_EXIT 285
|
||||
#define T_TRANSFERS_IN 286
|
||||
#define T_TRANSFERS_OUT 287
|
||||
#define T_TRANSFERS_PER_NS 288
|
||||
#define T_TRANSFER_FORMAT 289
|
||||
#define T_MAX_TRANSFER_TIME_IN 290
|
||||
#define T_ONE_ANSWER 291
|
||||
#define T_MANY_ANSWERS 292
|
||||
#define T_NOTIFY 293
|
||||
#define T_AUTH_NXDOMAIN 294
|
||||
#define T_MULTIPLE_CNAMES 295
|
||||
#define T_CLEAN_INTERVAL 296
|
||||
#define T_INTERFACE_INTERVAL 297
|
||||
#define T_STATS_INTERVAL 298
|
||||
#define T_LOGGING 299
|
||||
#define T_CATEGORY 300
|
||||
#define T_CHANNEL 301
|
||||
#define T_SEVERITY 302
|
||||
#define T_DYNAMIC 303
|
||||
#define T_FILE 304
|
||||
#define T_VERSIONS 305
|
||||
#define T_SIZE 306
|
||||
#define T_SYSLOG 307
|
||||
#define T_DEBUG 308
|
||||
#define T_NULL_OUTPUT 309
|
||||
#define T_PRINT_TIME 310
|
||||
#define T_PRINT_CATEGORY 311
|
||||
#define T_PRINT_SEVERITY 312
|
||||
#define T_TOPOLOGY 313
|
||||
#define T_SERVER 314
|
||||
#define T_LONG_AXFR 315
|
||||
#define T_BOGUS 316
|
||||
#define T_TRANSFERS 317
|
||||
#define T_KEYS 318
|
||||
#define T_ZONE 319
|
||||
#define T_IN 320
|
||||
#define T_CHAOS 321
|
||||
#define T_HESIOD 322
|
||||
#define T_TYPE 323
|
||||
#define T_MASTER 324
|
||||
#define T_SLAVE 325
|
||||
#define T_STUB 326
|
||||
#define T_RESPONSE 327
|
||||
#define T_HINT 328
|
||||
#define T_MASTERS 329
|
||||
#define T_TRANSFER_SOURCE 330
|
||||
#define T_ALSO_NOTIFY 331
|
||||
#define T_ACL 332
|
||||
#define T_ALLOW_UPDATE 333
|
||||
#define T_ALLOW_QUERY 334
|
||||
#define T_ALLOW_TRANSFER 335
|
||||
#define T_SEC_KEY 336
|
||||
#define T_ALGID 337
|
||||
#define T_SECRET 338
|
||||
#define T_CHECK_NAMES 339
|
||||
#define T_WARN 340
|
||||
#define T_FAIL 341
|
||||
#define T_IGNORE 342
|
||||
#define T_FORWARD 343
|
||||
#define T_FORWARDERS 344
|
||||
#define T_ONLY 345
|
||||
#define T_FIRST 346
|
||||
#define T_IF_NO_ANSWER 347
|
||||
#define T_IF_NO_DOMAIN 348
|
||||
#define T_YES 349
|
||||
#define T_TRUE 350
|
||||
#define T_NO 351
|
||||
#define T_FALSE 352
|
||||
typedef union {
|
||||
char * cp;
|
||||
int s_int;
|
||||
long num;
|
||||
u_long ul_int;
|
||||
u_int16_t us_int;
|
||||
struct in_addr ip_addr;
|
||||
ip_match_element ime;
|
||||
ip_match_list iml;
|
||||
key_info keyi;
|
||||
enum axfr_format axfr_fmt;
|
||||
} YYSTYPE;
|
||||
extern YYSTYPE yylval;
|
||||
1473
contrib/bind/bin/named/ns_parser.y
Normal file
1473
contrib/bind/bin/named/ns_parser.y
Normal file
File diff suppressed because it is too large
Load diff
242
contrib/bind/bin/named/ns_parseutil.c
Normal file
242
contrib/bind/bin/named/ns_parseutil.c
Normal file
|
|
@ -0,0 +1,242 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 1997 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/* Global C stuff goes here. */
|
||||
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
#include <isc/memcluster.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
#include "ns_parseutil.h"
|
||||
|
||||
|
||||
/*
|
||||
* Symbol Table
|
||||
*/
|
||||
|
||||
symbol_table
|
||||
new_symbol_table(int size_guess, free_function free_value) {
|
||||
symbol_table st;
|
||||
|
||||
st = (symbol_table)memget(sizeof (struct symbol_table));
|
||||
if (st == NULL)
|
||||
panic("memget failed in new_symbol_table()", NULL);
|
||||
st->table = (symbol_entry *)memget(size_guess * sizeof *st->table);
|
||||
if (st->table == NULL)
|
||||
panic("memget failed in new_symbol_table()", NULL);
|
||||
memset(st->table, 0, size_guess * sizeof (symbol_entry));
|
||||
st->size = size_guess; /* size_guess should be prime */
|
||||
st->free_value = free_value;
|
||||
return (st);
|
||||
}
|
||||
|
||||
void
|
||||
free_symbol(symbol_table st, symbol_entry ste) {
|
||||
if (ste->flags & SYMBOL_FREE_KEY)
|
||||
freestr(ste->key);
|
||||
if (ste->flags & SYMBOL_FREE_VALUE)
|
||||
(st->free_value)(ste->type, ste->value.pointer);
|
||||
}
|
||||
|
||||
void
|
||||
free_symbol_table(symbol_table st) {
|
||||
int i;
|
||||
symbol_entry ste, ste_next;
|
||||
|
||||
for (i = 0; i < st->size; i++) {
|
||||
for (ste = st->table[i]; ste != NULL; ste = ste_next) {
|
||||
ste_next = ste->next;
|
||||
free_symbol(st, ste);
|
||||
memput(ste, sizeof *ste);
|
||||
}
|
||||
}
|
||||
memput(st->table, st->size * sizeof (symbol_entry));
|
||||
memput(st, sizeof *st);
|
||||
}
|
||||
|
||||
void
|
||||
dprint_symbol_table(int level, symbol_table st) {
|
||||
int i;
|
||||
symbol_entry ste;
|
||||
|
||||
for (i = 0; i < st->size; i++) {
|
||||
for (ste = st->table[i]; ste != NULL; ste = ste->next)
|
||||
ns_debug(ns_log_parser, level,
|
||||
"%7d: (%s: %d %p/%d %04x) ",
|
||||
i, ste->key, ste->type, ste->value.pointer,
|
||||
ste->value.integer, ste->flags);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* P. J. Weinberger's hash function, adapted from p. 436 of
|
||||
* _Compilers: Principles, Techniques, and Tools_, Aho, Sethi
|
||||
* and Ullman, Addison-Wesley, 1986, ISBN 0-201-10088-6.
|
||||
*/
|
||||
static int
|
||||
symbol_hash(const char *key, int prime) {
|
||||
const char *s;
|
||||
unsigned int h = 0;
|
||||
unsigned int g;
|
||||
int c;
|
||||
|
||||
for (s = key; *s != '\0'; s++) {
|
||||
c = *s;
|
||||
if (isascii(c) && isupper(c))
|
||||
c = tolower(c);
|
||||
h = ( h << 4 ) + c;
|
||||
if ((g = ( h & 0xf0000000 )) != 0) {
|
||||
h = h ^ (g >> 24);
|
||||
h = h ^ g;
|
||||
}
|
||||
}
|
||||
return (h % prime);
|
||||
}
|
||||
|
||||
int
|
||||
lookup_symbol(symbol_table st, const char *key, int type,
|
||||
symbol_value *value) {
|
||||
int hash;
|
||||
symbol_entry ste;
|
||||
|
||||
hash = symbol_hash(key, st->size);
|
||||
for (ste = st->table[hash]; ste != NULL; ste = ste->next)
|
||||
if ((type == 0 || ste->type == type) &&
|
||||
strcasecmp(ste->key, key) == 0)
|
||||
break;
|
||||
if (ste != NULL) {
|
||||
if (value != NULL)
|
||||
*value = ste->value;
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
define_symbol(symbol_table st, char *key, int type, symbol_value value,
|
||||
unsigned int flags) {
|
||||
int hash;
|
||||
symbol_entry ste;
|
||||
|
||||
hash = symbol_hash(key, st->size);
|
||||
for (ste = st->table[hash]; ste != NULL; ste = ste->next)
|
||||
if ((type == 0 || ste->type == type) &&
|
||||
strcasecmp(ste->key, key) == 0)
|
||||
break;
|
||||
if (ste == NULL) {
|
||||
ste = (symbol_entry)memget(sizeof *ste);
|
||||
if (ste == NULL)
|
||||
panic("memget failed in define_symbol()", NULL);
|
||||
ste->key = key;
|
||||
ste->type = type;
|
||||
ste->value = value;
|
||||
ste->flags = flags;
|
||||
ste->next = st->table[hash];
|
||||
st->table[hash] = ste;
|
||||
} else {
|
||||
ns_debug(ns_log_parser, 7, "redefined symbol %s type %d",
|
||||
key, type);
|
||||
free_symbol(st, ste);
|
||||
ste->key = key;
|
||||
ste->value = value;
|
||||
ste->flags = flags;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
undefine_symbol(symbol_table st, char *key, int type) {
|
||||
int hash;
|
||||
symbol_entry prev_ste, ste, next_ste;
|
||||
|
||||
hash = symbol_hash(key, st->size);
|
||||
for (prev_ste = NULL, ste = st->table[hash];
|
||||
ste != NULL;
|
||||
prev_ste = ste, ste = ste->next)
|
||||
if ((type == 0 || ste->type == type) &&
|
||||
strcasecmp(ste->key, key) == 0)
|
||||
break;
|
||||
if (ste != NULL) {
|
||||
free_symbol(st, ste);
|
||||
if (prev_ste != NULL)
|
||||
prev_ste->next = ste->next;
|
||||
else
|
||||
st->table[hash] = ste->next;
|
||||
memput(ste, sizeof *ste);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Conversion Routines
|
||||
*/
|
||||
|
||||
int
|
||||
unit_to_ulong(char *in, u_long *out) {
|
||||
int c, units_done = 0;
|
||||
u_long result = 0L;
|
||||
|
||||
INSIST(in != NULL);
|
||||
|
||||
for (; (c = *in) != '\0'; in++) {
|
||||
if (units_done)
|
||||
return (0);
|
||||
if (isdigit(c)) {
|
||||
result *= 10;
|
||||
result += (c - '0');
|
||||
} else {
|
||||
switch (c) {
|
||||
case 'k':
|
||||
case 'K':
|
||||
result *= 1024;
|
||||
units_done = 1;
|
||||
break;
|
||||
case 'm':
|
||||
case 'M':
|
||||
result *= (1024*1024);
|
||||
units_done = 1;
|
||||
break;
|
||||
case 'g':
|
||||
case 'G':
|
||||
result *= (1024*1024*1024);
|
||||
units_done = 1;
|
||||
break;
|
||||
default:
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*out = result;
|
||||
return (1);
|
||||
}
|
||||
65
contrib/bind/bin/named/ns_parseutil.h
Normal file
65
contrib/bind/bin/named/ns_parseutil.h
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 1997 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef NS_PARSEUTIL_H
|
||||
#define NS_PARSEUTIL_H
|
||||
|
||||
/*
|
||||
* Symbol Table
|
||||
*/
|
||||
|
||||
#define SYMBOL_FREE_KEY 0x01
|
||||
#define SYMBOL_FREE_VALUE 0x02
|
||||
|
||||
typedef union symbol_value {
|
||||
void *pointer;
|
||||
int integer;
|
||||
} symbol_value;
|
||||
|
||||
typedef void (*free_function)(int, void *);
|
||||
|
||||
typedef struct symbol_entry {
|
||||
char *key;
|
||||
int type;
|
||||
symbol_value value;
|
||||
unsigned int flags;
|
||||
struct symbol_entry *next;
|
||||
} *symbol_entry;
|
||||
|
||||
typedef struct symbol_table {
|
||||
int size;
|
||||
symbol_entry *table;
|
||||
free_function free_value;
|
||||
} *symbol_table;
|
||||
|
||||
symbol_table new_symbol_table(int, free_function);
|
||||
void free_symbol(symbol_table, symbol_entry);
|
||||
void free_symbol_table(symbol_table);
|
||||
void dprint_symbol_table(int, symbol_table);
|
||||
int lookup_symbol(symbol_table, const char *, int,
|
||||
symbol_value *);
|
||||
void define_symbol(symbol_table, char *, int, symbol_value,
|
||||
unsigned int);
|
||||
void undefine_symbol(symbol_table, char *, int type);
|
||||
|
||||
/*
|
||||
* Conversion Routines
|
||||
*/
|
||||
|
||||
int unit_to_ulong(char *, u_long *);
|
||||
|
||||
#endif /* !NS_PARSEUTIL_H */
|
||||
1669
contrib/bind/bin/named/ns_req.c
Normal file
1669
contrib/bind/bin/named/ns_req.c
Normal file
File diff suppressed because it is too large
Load diff
3298
contrib/bind/bin/named/ns_resp.c
Normal file
3298
contrib/bind/bin/named/ns_resp.c
Normal file
File diff suppressed because it is too large
Load diff
415
contrib/bind/bin/named/ns_stats.c
Normal file
415
contrib/bind/bin/named/ns_stats.c
Normal file
|
|
@ -0,0 +1,415 @@
|
|||
#if !defined(lint) && !defined(SABER)
|
||||
static char sccsid[] = "@(#)ns_stats.c 4.10 (Berkeley) 6/27/90";
|
||||
static char rcsid[] = "$Id: ns_stats.c,v 8.18 1998/02/13 19:50:24 halley Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1986
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* 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, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1996, 1997 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
#include <isc/memcluster.h>
|
||||
#include <isc/tree.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#ifdef HAVE_GETRUSAGE /* XXX */
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
#include "named.h"
|
||||
|
||||
static u_long typestats[T_ANY+1];
|
||||
static const char *typenames[T_ANY+1] = {
|
||||
/* 5 types per line */
|
||||
"Unknown", "A", "NS", "invalid(MD)", "invalid(MF)",
|
||||
"CNAME", "SOA", "MB", "MG", "MR",
|
||||
"NULL", "WKS", "PTR", "HINFO", "MINFO",
|
||||
"MX", "TXT", "RP", "AFSDB", "X25",
|
||||
"ISDN", "RT", "NSAP", "NSAP_PTR", "SIG",
|
||||
"KEY", "PX", "invalid(GPOS)", "AAAA", "LOC",
|
||||
0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
/* 20 per line */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
/* 100 */
|
||||
"UINFO", "UID", "GID", "UNSPEC", 0, 0, 0, 0, 0, 0,
|
||||
/* 110 */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
/* 120 */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
/* 200 */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
/* 240 */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
/* 250 */
|
||||
0, 0, "AXFR", "MAILB", "MAILA", "ANY"
|
||||
};
|
||||
|
||||
static void nameserStats(FILE *);
|
||||
|
||||
void
|
||||
ns_stats() {
|
||||
time_t timenow = time(NULL);
|
||||
FILE *f;
|
||||
int i;
|
||||
|
||||
ns_notice(ns_log_statistics, "dumping nameserver stats");
|
||||
|
||||
if (!(f = fopen(server_options->stats_filename, "a"))) {
|
||||
ns_notice(ns_log_statistics, "cannot open stat file, \"%s\"",
|
||||
server_options->stats_filename);
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(f, "+++ Statistics Dump +++ (%ld) %s",
|
||||
(long)timenow, checked_ctime(&timenow));
|
||||
fprintf(f, "%ld\ttime since boot (secs)\n",
|
||||
(long)(timenow - boottime));
|
||||
fprintf(f, "%ld\ttime since reset (secs)\n",
|
||||
(long)(timenow - resettime));
|
||||
|
||||
/* query type statistics */
|
||||
fprintf(f, "%lu\tUnknown query types\n", (u_long)typestats[0]);
|
||||
for(i=1; i < T_ANY+1; i++)
|
||||
if (typestats[i]) {
|
||||
if (typenames[i] != NULL)
|
||||
fprintf(f, "%lu\t%s queries\n",
|
||||
(u_long)typestats[i], typenames[i]);
|
||||
else
|
||||
fprintf(f, "%lu\ttype %d queries\n",
|
||||
(u_long)typestats[i], i);
|
||||
}
|
||||
|
||||
/* name server statistics */
|
||||
nameserStats(f);
|
||||
|
||||
fprintf(f, "++ Memory Statistics ++\n");
|
||||
memstats(f);
|
||||
fprintf(f, "-- Memory Statistics --\n");
|
||||
fprintf(f, "--- Statistics Dump --- (%ld) %s",
|
||||
(long)timenow, checked_ctime(&timenow));
|
||||
(void) my_fclose(f);
|
||||
ns_notice(ns_log_statistics, "done dumping nameserver stats");
|
||||
}
|
||||
|
||||
void
|
||||
qtypeIncr(qtype)
|
||||
int qtype;
|
||||
{
|
||||
if (qtype < T_A || qtype > T_ANY)
|
||||
qtype = 0; /* bad type */
|
||||
typestats[qtype]++;
|
||||
}
|
||||
|
||||
static tree *nameserTree;
|
||||
static int nameserInit;
|
||||
|
||||
static FILE *nameserStatsFile;
|
||||
static const char *statNames[nssLast] = {
|
||||
"RR", /* sent us an answer */
|
||||
"RNXD", /* sent us a negative response */
|
||||
"RFwdR", /* sent us a response we had to fwd */
|
||||
"RDupR", /* sent us an extra answer */
|
||||
"RFail", /* sent us a SERVFAIL */
|
||||
"RFErr", /* sent us a FORMERR */
|
||||
"RErr", /* sent us some other error */
|
||||
"RAXFR", /* sent us an AXFR */
|
||||
"RLame", /* sent us a lame delegation */
|
||||
"ROpts", /* sent us some IP options */
|
||||
"SSysQ", /* sent them a sysquery */
|
||||
"SAns", /* sent them an answer */
|
||||
"SFwdQ", /* fwdd a query to them */
|
||||
"SDupQ", /* sent them a retry */
|
||||
"SErr", /* sent failed (in sendto) */
|
||||
"RQ", /* sent us a query */
|
||||
"RIQ", /* sent us an inverse query */
|
||||
"RFwdQ", /* sent us a query we had to fwd */
|
||||
"RDupQ", /* sent us a retry */
|
||||
"RTCP", /* sent us a query using TCP */
|
||||
"SFwdR", /* fwdd a response to them */
|
||||
"SFail", /* sent them a SERVFAIL */
|
||||
"SFErr", /* sent them a FORMERR */
|
||||
"SNaAns", /* sent them a non autoritative answer */
|
||||
"SNXD", /* sent them a negative response */
|
||||
};
|
||||
|
||||
/*
|
||||
* Note that addresses in network byte order always have the high byte first.
|
||||
* XXX - this is horribly IPv4 dependent, but it's performance critical.
|
||||
*/
|
||||
static int
|
||||
nameserCompar(const tree_t t1, const tree_t t2) {
|
||||
u_char *p1 = (u_char *)t1, *p2 = (u_char *)t2;
|
||||
int i;
|
||||
|
||||
for (i = INADDRSZ; i > 0; i--) {
|
||||
u_char c1 = *p1++, c2 = *p2++;
|
||||
|
||||
if (c1 < c2)
|
||||
return (-1);
|
||||
if (c1 > c2)
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
struct nameser *
|
||||
nameserFind(addr, flags)
|
||||
struct in_addr addr;
|
||||
int flags;
|
||||
{
|
||||
struct nameser dummy;
|
||||
struct nameser *ns;
|
||||
|
||||
if (!nameserInit) {
|
||||
tree_init(&nameserTree);
|
||||
nameserInit++;
|
||||
}
|
||||
|
||||
dummy.addr = addr;
|
||||
ns = (struct nameser *)tree_srch(&nameserTree, nameserCompar,
|
||||
(tree_t)&dummy);
|
||||
if (ns == NULL && (flags & NS_F_INSERT) != 0) {
|
||||
ns = (struct nameser *)memget(sizeof(struct nameser));
|
||||
if (ns == NULL) {
|
||||
nomem: if (!haveComplained((u_long)nameserFind, 0))
|
||||
ns_notice(ns_log_statistics,
|
||||
"nameserFind: memget failed; %s",
|
||||
strerror(errno));
|
||||
return (NULL);
|
||||
}
|
||||
memset(ns, 0, sizeof *ns);
|
||||
ns->addr = addr;
|
||||
if (!tree_add(&nameserTree, nameserCompar, (tree_t)ns, NULL)) {
|
||||
int save = errno;
|
||||
memput(ns, sizeof *ns);
|
||||
errno = save;
|
||||
goto nomem;
|
||||
}
|
||||
}
|
||||
return (ns);
|
||||
}
|
||||
|
||||
static void
|
||||
nameserStatsOut(f, stats)
|
||||
FILE *f;
|
||||
u_long stats[];
|
||||
{
|
||||
int i;
|
||||
const char *pre = "\t";
|
||||
|
||||
for (i = 0; i < (int)nssLast; i++) {
|
||||
fprintf(f, "%s%lu", pre, (u_long)stats[i]);
|
||||
pre = ((i+1) % 5) ? " " : " ";
|
||||
}
|
||||
fputc('\n', f);
|
||||
}
|
||||
|
||||
static void
|
||||
nameserStatsHdr(f)
|
||||
FILE *f;
|
||||
{
|
||||
int i;
|
||||
const char *pre = "\t";
|
||||
|
||||
fprintf(f, "(Legend)\n");
|
||||
for (i = 0; i < (int)nssLast; i++) {
|
||||
fprintf(f, "%s%s", pre,
|
||||
statNames[i] ? statNames[i] : "");
|
||||
pre = ((i+1) % 5) ? "\t" : "\n\t";
|
||||
}
|
||||
fputc('\n', f);
|
||||
}
|
||||
|
||||
static int
|
||||
nameserStatsTravUAR(t)
|
||||
tree_t t;
|
||||
{
|
||||
struct nameser *ns = (struct nameser *)t;
|
||||
|
||||
fprintf(nameserStatsFile, "[%s]\n", /* : rtt %u */
|
||||
inet_ntoa(ns->addr) /*, ns->rtt*/ );
|
||||
nameserStatsOut(nameserStatsFile, ns->stats);
|
||||
return (1);
|
||||
}
|
||||
|
||||
static void
|
||||
nameserStats(f)
|
||||
FILE *f;
|
||||
{
|
||||
nameserStatsFile = f;
|
||||
fprintf(f, "++ Name Server Statistics ++\n");
|
||||
nameserStatsHdr(f);
|
||||
fprintf(f, "(Global)\n");
|
||||
nameserStatsOut(f, globalStats);
|
||||
if (NS_OPTION_P(OPTION_HOSTSTATS))
|
||||
tree_trav(&nameserTree, nameserStatsTravUAR);
|
||||
fprintf(f, "-- Name Server Statistics --\n");
|
||||
nameserStatsFile = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
ns_logstats(evContext ctx, void *uap, struct timespec due,
|
||||
struct timespec inter)
|
||||
{
|
||||
char buffer[1024];
|
||||
char buffer2[32], header[64];
|
||||
time_t timenow = time(NULL);
|
||||
int i;
|
||||
#ifdef HAVE_GETRUSAGE
|
||||
struct rusage usage, childu;
|
||||
#endif /*HAVE_GETRUSAGE*/
|
||||
|
||||
#ifdef HAVE_GETRUSAGE
|
||||
# define tv_float(tv) ((tv).tv_sec + ((tv).tv_usec / 1000000.0))
|
||||
|
||||
getrusage(RUSAGE_SELF, &usage);
|
||||
getrusage(RUSAGE_CHILDREN, &childu);
|
||||
|
||||
sprintf(buffer, "CPU=%gu/%gs CHILDCPU=%gu/%gs",
|
||||
tv_float(usage.ru_utime), tv_float(usage.ru_stime),
|
||||
tv_float(childu.ru_utime), tv_float(childu.ru_stime));
|
||||
ns_info(ns_log_statistics, "USAGE %lu %lu %s", (u_long)timenow,
|
||||
(u_long)boottime, buffer);
|
||||
# undef tv_float
|
||||
#endif /*HAVE_GETRUSAGE*/
|
||||
|
||||
sprintf(header, "NSTATS %lu %lu", (u_long)timenow, (u_long)boottime);
|
||||
strcpy(buffer, header);
|
||||
|
||||
for (i = 0; i < T_ANY+1; i++) {
|
||||
if (typestats[i]) {
|
||||
if (typenames[i])
|
||||
sprintf(buffer2, " %s=%lu",
|
||||
typenames[i], typestats[i]);
|
||||
else
|
||||
sprintf(buffer2, " %d=%lu", i, typestats[i]);
|
||||
if (strlen(buffer) + strlen(buffer2) >
|
||||
sizeof(buffer) - 1) {
|
||||
ns_info(ns_log_statistics, buffer);
|
||||
strcpy(buffer, header);
|
||||
}
|
||||
strcat(buffer, buffer2);
|
||||
}
|
||||
}
|
||||
ns_info(ns_log_statistics, buffer);
|
||||
|
||||
sprintf(header, "XSTATS %lu %lu", (u_long)timenow, (u_long)boottime);
|
||||
strcpy(buffer, header);
|
||||
for (i = 0; i < (int)nssLast; i++) {
|
||||
sprintf(buffer2, " %s=%lu",
|
||||
statNames[i]?statNames[i]:"?", (u_long)globalStats[i]);
|
||||
if (strlen(buffer) + strlen(buffer2) > sizeof(buffer) - 1) {
|
||||
ns_info(ns_log_statistics, buffer);
|
||||
strcpy(buffer, header);
|
||||
}
|
||||
strcat(buffer, buffer2);
|
||||
}
|
||||
ns_info(ns_log_statistics, buffer);
|
||||
}
|
||||
|
||||
static void
|
||||
nameserFree(void *uap) {
|
||||
struct nameser *ns = uap;
|
||||
|
||||
memput(ns, sizeof *ns);
|
||||
}
|
||||
|
||||
void
|
||||
ns_freestats(void) {
|
||||
if (nameserTree == NULL)
|
||||
return;
|
||||
tree_mung(&nameserTree, nameserFree);
|
||||
nameserInit = 0;
|
||||
}
|
||||
123
contrib/bind/bin/named/ns_udp.c
Normal file
123
contrib/bind/bin/named/ns_udp.c
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
#if !defined(lint) && !defined(SABER)
|
||||
static char rcsid[] = "$Id: ns_udp.c,v 8.5 1997/05/21 19:52:26 halley Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/file.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
#include <nlist.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
|
||||
void
|
||||
ns_udp() {
|
||||
#if defined(CHECK_UDP_SUM) || defined(FIX_UDP_SUM)
|
||||
struct nlist nl[2];
|
||||
int fd;
|
||||
int sum;
|
||||
u_long res, offset;
|
||||
|
||||
nl[0].n_name = UDPSUM;
|
||||
nl[1].n_name = 0;
|
||||
|
||||
if (nlist(KSYMS, nl)) {
|
||||
ns_debug(ns_log_default, 1, "ns_udp: nlist (%s,%s) failed",
|
||||
KSYMS, UDPSUM);
|
||||
return;
|
||||
}
|
||||
|
||||
ns_debug(ns_log_default, 1, "ns_udp: %s %d %lu (%ld)",
|
||||
nl[0].n_name, nl[0].n_type, nl[0].n_value, nl[0].n_value);
|
||||
|
||||
if (!nl[0].n_type)
|
||||
return;
|
||||
|
||||
if ((fd = open(KMEM, O_RDWR, 0)) < 0) {
|
||||
ns_debug(ns_log_default, 1, "ns_udp: open %s failed: %s", KMEM,
|
||||
strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
offset = nl[0].n_value;
|
||||
#ifdef KMAP
|
||||
offset &= ((~0UL)>>1);
|
||||
#endif
|
||||
|
||||
res = lseek(fd, offset, SEEK_SET);
|
||||
if (res != offset) {
|
||||
ns_debug(ns_log_default, 1, "ns_udp: lseek %lu failed %lu: %s",
|
||||
offset, res, strerror(errno));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (read(fd, &sum, sizeof(sum)) != sizeof(sum)) {
|
||||
ns_debug(ns_log_default, 1, "ns_udp: read failed: %s",
|
||||
strerror(errno));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ns_debug(ns_log_default, 1, "ns_udp: %d", sum);
|
||||
if (sum == 0) {
|
||||
#ifdef FIX_UDP_SUM
|
||||
sum = 1;
|
||||
lseek(fd, offset, SEEK_SET);
|
||||
if (res != offset) {
|
||||
ns_debug(ns_log_default, 1,
|
||||
"ns_udp: lseek %lu failed %lu: %s",
|
||||
offset, res, strerror(errno));
|
||||
goto cleanup;
|
||||
}
|
||||
if (write(fd, &sum, sizeof(sum)) != sizeof(sum)) {
|
||||
ns_debug(ns_log_default, 1, "ns_udp: write failed: %s",
|
||||
strerror(errno));
|
||||
goto cleanup;
|
||||
}
|
||||
ns_warning(ns_log_default, "ns_udp: check sums turned on");
|
||||
#else
|
||||
ns_panic(ns_log_default, 0,
|
||||
"ns_udp: checksums NOT turned on, exiting");
|
||||
#endif
|
||||
}
|
||||
cleanup:
|
||||
close(fd);
|
||||
#endif
|
||||
}
|
||||
2393
contrib/bind/bin/named/ns_update.c
Normal file
2393
contrib/bind/bin/named/ns_update.c
Normal file
File diff suppressed because it is too large
Load diff
642
contrib/bind/bin/named/ns_xfr.c
Normal file
642
contrib/bind/bin/named/ns_xfr.c
Normal file
|
|
@ -0,0 +1,642 @@
|
|||
#if !defined(lint) && !defined(SABER)
|
||||
static char rcsid[] = "$Id: ns_xfr.c,v 8.25 1998/03/25 18:47:34 halley Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <syslog.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
#include <isc/memcluster.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
|
||||
static struct qs_x_lev *sx_freelev(struct qs_x_lev *lev);
|
||||
|
||||
static void sx_newmsg(struct qstream *qsp),
|
||||
sx_sendlev(struct qstream *qsp),
|
||||
sx_sendsoa(struct qstream *qsp);
|
||||
|
||||
static int sx_flush(struct qstream *qsp),
|
||||
sx_addrr(struct qstream *qsp,
|
||||
const char *dname,
|
||||
struct databuf *dp),
|
||||
sx_nsrrs(struct qstream *qsp),
|
||||
sx_allrrs(struct qstream *qsp),
|
||||
sx_pushlev(struct qstream *qsp, struct namebuf *np);
|
||||
|
||||
/*
|
||||
* void
|
||||
* ns_xfr(qsp, znp, zone, class, type, opcode, id)
|
||||
* Initiate a concurrent (event driven) outgoing zone transfer.
|
||||
*/
|
||||
void
|
||||
ns_xfr(struct qstream *qsp, struct namebuf *znp,
|
||||
int zone, int class, int type,
|
||||
int opcode, int id)
|
||||
{
|
||||
FILE *rfp;
|
||||
int fdstat;
|
||||
pid_t pid;
|
||||
server_info si;
|
||||
#ifdef SO_SNDBUF
|
||||
static const int sndbuf = XFER_BUFSIZE * 2;
|
||||
#endif
|
||||
#ifdef SO_SNDLOWAT
|
||||
static const int sndlowat = XFER_BUFSIZE;
|
||||
#endif
|
||||
|
||||
ns_info(ns_log_xfer_out, "zone transfer of \"%s\" (%s) to %s",
|
||||
zones[zone].z_origin, p_class(class), sin_ntoa(qsp->s_from));
|
||||
|
||||
#ifdef SO_SNDBUF
|
||||
/*
|
||||
* The default seems to be 4K, and we'd like it to have enough room
|
||||
* to parallelize sending the pushed data with accumulating more
|
||||
* write() data from us.
|
||||
*/
|
||||
(void) setsockopt(qsp->s_rfd, SOL_SOCKET, SO_SNDBUF,
|
||||
(char *)&sndbuf, sizeof sndbuf);
|
||||
#endif
|
||||
#ifdef SO_SNDLOWAT
|
||||
/*
|
||||
* We don't want select() to show writability 'til we can write
|
||||
* an XFER_BUFSIZE block of data.
|
||||
*/
|
||||
(void) setsockopt(qsp->s_rfd, SOL_SOCKET, SO_SNDLOWAT,
|
||||
(char *)&sndlowat, sizeof sndlowat);
|
||||
#endif
|
||||
if (sq_openw(qsp, 64*1024) == -1)
|
||||
goto abort;
|
||||
memset(&qsp->xfr, 0, sizeof qsp->xfr);
|
||||
qsp->xfr.top = znp;
|
||||
qsp->xfr.zone = zone;
|
||||
qsp->xfr.class = class;
|
||||
qsp->xfr.id = id;
|
||||
qsp->xfr.opcode = opcode;
|
||||
qsp->xfr.msg = memget(XFER_BUFSIZE);
|
||||
if (!qsp->xfr.msg)
|
||||
goto abort;
|
||||
qsp->xfr.eom = qsp->xfr.msg + XFER_BUFSIZE;
|
||||
qsp->xfr.cp = NULL;
|
||||
qsp->xfr.state = s_x_firstsoa;
|
||||
zones[zone].z_numxfrs++;
|
||||
qsp->flags |= STREAM_AXFR;
|
||||
|
||||
si = find_server(qsp->s_from.sin_addr);
|
||||
if (si != NULL && si->transfer_format != axfr_use_default)
|
||||
qsp->xfr.transfer_format = si->transfer_format;
|
||||
else
|
||||
qsp->xfr.transfer_format = server_options->transfer_format;
|
||||
|
||||
if (sx_pushlev(qsp, znp) < 0) {
|
||||
abort:
|
||||
(void) shutdown(qsp->s_rfd, 2);
|
||||
sq_remove(qsp);
|
||||
return;
|
||||
}
|
||||
(void) sq_writeh(qsp, sx_sendsoa);
|
||||
}
|
||||
|
||||
/*
|
||||
* void
|
||||
* ns_stopxfrs(zp)
|
||||
* Stop (abort, reset) all transfers of the zone specified by 'zp'.
|
||||
*/
|
||||
void
|
||||
ns_stopxfrs(struct zoneinfo *zp) {
|
||||
struct qstream *this, *next;
|
||||
u_int zone = (u_int)(zp - zones);
|
||||
|
||||
for (this = streamq; this; this = next) {
|
||||
next = this->s_next;
|
||||
if (this->xfr.zone == zone) {
|
||||
(void) shutdown(this->s_rfd, 2);
|
||||
sq_remove(this);
|
||||
}
|
||||
}
|
||||
INSIST(zp->z_numxfrs == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* void
|
||||
* ns_freexfr(qsp)
|
||||
* Free all xfr-related dynamic data associated with qsp.
|
||||
*/
|
||||
void
|
||||
ns_freexfr(struct qstream *qsp) {
|
||||
if (qsp->xfr.msg != NULL) {
|
||||
memput(qsp->xfr.msg, XFER_BUFSIZE);
|
||||
qsp->xfr.msg = NULL;
|
||||
}
|
||||
while (qsp->xfr.lev)
|
||||
qsp->xfr.lev = sx_freelev(qsp->xfr.lev);
|
||||
zones[qsp->xfr.zone].z_numxfrs--;
|
||||
qsp->flags &= ~STREAM_AXFR;
|
||||
}
|
||||
|
||||
/*
|
||||
* u_char *
|
||||
* renew_msg(msg)
|
||||
* init the header of a message, reset the compression pointers, and
|
||||
* reset the write pointer to the first byte following the header.
|
||||
*/
|
||||
static void
|
||||
sx_newmsg(struct qstream *qsp) {
|
||||
HEADER *hp = (HEADER *)qsp->xfr.msg;
|
||||
|
||||
memset(hp, 0, HFIXEDSZ);
|
||||
hp->id = htons(qsp->xfr.id);
|
||||
hp->opcode = qsp->xfr.opcode;
|
||||
hp->qr = 1;
|
||||
hp->rcode = NOERROR;
|
||||
|
||||
qsp->xfr.ptrs[0] = qsp->xfr.msg;
|
||||
qsp->xfr.ptrs[1] = NULL;
|
||||
|
||||
qsp->xfr.cp = qsp->xfr.msg + HFIXEDSZ;
|
||||
}
|
||||
|
||||
/*
|
||||
* int
|
||||
* sx_flush(qsp)
|
||||
* flush the intermediate buffer out to the stream IO system.
|
||||
* return:
|
||||
* passed through from sq_write().
|
||||
*/
|
||||
static int
|
||||
sx_flush(struct qstream *qsp) {
|
||||
int ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
if (debug >= 10)
|
||||
fp_nquery(qsp->xfr.msg, qsp->xfr.cp - qsp->xfr.msg,
|
||||
log_get_stream(packet_channel));
|
||||
#endif
|
||||
ret = sq_write(qsp, qsp->xfr.msg, qsp->xfr.cp - qsp->xfr.msg);
|
||||
if (ret >= 0)
|
||||
qsp->xfr.cp = NULL;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* int
|
||||
* sx_addrr(qsp, name, dp)
|
||||
* add name/dp's RR to the current assembly message. if it won't fit,
|
||||
* write current message out, renew the message, and then RR should fit.
|
||||
* return:
|
||||
* -1 = the sx_flush() failed so we could not queue the full message.
|
||||
* 0 = one way or another, everything is fine.
|
||||
* side effects:
|
||||
* on success, the ANCOUNT is incremented and the pointers are advanced.
|
||||
*/
|
||||
static int
|
||||
sx_addrr(struct qstream *qsp, const char *dname, struct databuf *dp) {
|
||||
HEADER *hp = (HEADER *)qsp->xfr.msg;
|
||||
u_char **edp = qsp->xfr.ptrs + sizeof qsp->xfr.ptrs / sizeof(u_char*);
|
||||
int n;
|
||||
|
||||
if (qsp->xfr.cp != NULL) {
|
||||
if (qsp->xfr.transfer_format == axfr_one_answer &&
|
||||
sx_flush(qsp) < 0)
|
||||
return (-1);
|
||||
}
|
||||
if (qsp->xfr.cp == NULL)
|
||||
sx_newmsg(qsp);
|
||||
n = make_rr(dname, dp, qsp->xfr.cp, qsp->xfr.eom - qsp->xfr.cp,
|
||||
0, qsp->xfr.ptrs, edp);
|
||||
if (n < 0) {
|
||||
if (sx_flush(qsp) < 0)
|
||||
return (-1);
|
||||
if (qsp->xfr.cp == NULL)
|
||||
sx_newmsg(qsp);
|
||||
n = make_rr(dname, dp, qsp->xfr.cp, qsp->xfr.eom - qsp->xfr.cp,
|
||||
0, qsp->xfr.ptrs, edp);
|
||||
INSIST(n >= 0);
|
||||
}
|
||||
hp->ancount = htons(ntohs(hp->ancount) + 1);
|
||||
qsp->xfr.cp += n;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* int
|
||||
* sx_soarr(qsp)
|
||||
* add the SOA RR's at the current level's top np to the assembly message.
|
||||
* return:
|
||||
* 0 = success
|
||||
* -1 = write buffer full, cannot continue at this time
|
||||
* side effects:
|
||||
* if progress was made, header and pointers will be advanced.
|
||||
*/
|
||||
static int
|
||||
sx_soarr(struct qstream *qsp) {
|
||||
struct databuf *dp;
|
||||
|
||||
foreach_rr(dp, qsp->xfr.top, T_SOA, qsp->xfr.class, qsp->xfr.zone) {
|
||||
if (sx_addrr(qsp, zones[qsp->xfr.zone].z_origin, dp) < 0) {
|
||||
/* RR wouldn't fit. Bail out. */
|
||||
return (-1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
ns_panic(ns_log_xfer_out, 1, "no SOA at zone top");
|
||||
}
|
||||
|
||||
/*
|
||||
* int
|
||||
* sx_nsrrs(qsp)
|
||||
* add the NS RR's at the current level's current np,
|
||||
* to the assembly message
|
||||
* return:
|
||||
* >1 = number of NS RRs added, note that there may be more
|
||||
* 0 = success, there are no more NS RRs at this level
|
||||
* -1 = write buffer full, cannot continue at this time
|
||||
* side effects:
|
||||
* if progress was made, header and pointers will be advanced.
|
||||
* note:
|
||||
* this is meant for AXFR, which includes glue as part of the answer
|
||||
* sections. this is different from and incompatible with the additional
|
||||
* data of a referral response.
|
||||
*/
|
||||
static int
|
||||
sx_nsrrs(struct qstream *qsp) {
|
||||
struct databuf *dp, *tdp, *gdp;
|
||||
struct namebuf *gnp, *tnp, *top;
|
||||
struct hashbuf *htp;
|
||||
const char *fname;
|
||||
int rrcount, class;
|
||||
|
||||
class = qsp->xfr.class;
|
||||
top = qsp->xfr.top;
|
||||
rrcount = 0;
|
||||
for ((void)NULL;
|
||||
(dp = qsp->xfr.lev->dp) != NULL;
|
||||
qsp->xfr.lev->dp = dp->d_next) {
|
||||
/* XYZZY foreach_rr? */
|
||||
if (dp->d_class != class && class != C_ANY)
|
||||
continue;
|
||||
if (dp->d_rcode)
|
||||
continue;
|
||||
/*
|
||||
* It might not be in the same zone, if we are authoritative
|
||||
* for both parent and child, but it does have to be a zone.
|
||||
*
|
||||
* XXX: this is sort of a bug, since it means we merge the
|
||||
* @ NS RRset into our parent's zone. But that is what
|
||||
* db_load() does, so for now we have no choice.
|
||||
*/
|
||||
if (dp->d_zone == DB_Z_CACHE)
|
||||
continue;
|
||||
if (dp->d_type != T_NS)
|
||||
continue;
|
||||
if (!(qsp->xfr.lev->flags & SXL_GLUING)) {
|
||||
if (sx_addrr(qsp, qsp->xfr.lev->dname, dp) < 0) {
|
||||
/* RR wouldn't fit. Bail out. */
|
||||
return (-1);
|
||||
}
|
||||
rrcount++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Glue the sub domains together by sending the address
|
||||
* records for the sub domain name servers along if necessary.
|
||||
* Glue is necessary if the server is in any zone delegated
|
||||
* from the current (top) zone. Such a delegated zone might
|
||||
* or might not be that referred to by the NS record now
|
||||
* being handled.
|
||||
*/
|
||||
htp = hashtab;
|
||||
gnp = nlookup((char *)dp->d_data, &htp, &fname, 0);
|
||||
if (gnp == NULL || fname != (char *)dp->d_data)
|
||||
continue;
|
||||
for (tnp = gnp;
|
||||
tnp != NULL && tnp != top;
|
||||
tnp = tnp->n_parent)
|
||||
(void)NULL;
|
||||
if (tnp == NULL && NAME(*top)[0] != '\0')
|
||||
continue; /* name server is not below top domain */
|
||||
for (tnp = gnp;
|
||||
tnp != NULL && tnp != top;
|
||||
tnp = tnp->n_parent) {
|
||||
foreach_rr(tdp, tnp, T_NS, class, DB_Z_CACHE)
|
||||
break;
|
||||
/* If we found a zone cut, we're outta here. */
|
||||
if (tdp != NULL)
|
||||
break;
|
||||
}
|
||||
/* If name server is not in a delegated zone, skip it. */
|
||||
if (tnp == top || (tnp == NULL && NAME(*top)[0] == '\0'))
|
||||
continue;
|
||||
/* Now we know glue records are needed. Send them. */
|
||||
qsp->xfr.lev->flags |= SXL_GLUING;
|
||||
foreach_rr(gdp, gnp, T_A, class, DB_Z_CACHE)
|
||||
if (sx_addrr(qsp, fname, gdp) < 0) {
|
||||
/*
|
||||
* Rats. We already sent the NS RR, too.
|
||||
* Note that SXL_GLUING is being left on.
|
||||
*/
|
||||
return (-1);
|
||||
}
|
||||
qsp->xfr.lev->flags &= ~SXL_GLUING;
|
||||
}
|
||||
return (rrcount);
|
||||
}
|
||||
|
||||
/*
|
||||
* int
|
||||
* sx_allrrs(qsp)
|
||||
* add the non-(SOA,NS) RR's at the current level's current np,
|
||||
* to the assembly message
|
||||
* return:
|
||||
* >0 = number of RR's added, note that there may be more
|
||||
* 0 = success, there are no more RRs at this level
|
||||
* -1 = write buffer full, cannot continue at this time
|
||||
* side effects:
|
||||
* if progress was made, header and pointers will be advanced.
|
||||
* note:
|
||||
* this is meant for AXFR, which includes glue as part of the answer
|
||||
* sections. this is different from and incompatible with the additional
|
||||
* data of a referral response.
|
||||
*/
|
||||
static int
|
||||
sx_allrrs(struct qstream *qsp) {
|
||||
struct databuf *dp, *tdp, *gdp;
|
||||
struct namebuf *gnp, *tnp, *top;
|
||||
struct hashbuf *htp;
|
||||
const char *fname;
|
||||
int rrcount, class;
|
||||
u_int zone;
|
||||
|
||||
class = qsp->xfr.class;
|
||||
top = qsp->xfr.top;
|
||||
zone = qsp->xfr.zone;
|
||||
rrcount = 0;
|
||||
for ((void)NULL;
|
||||
(dp = qsp->xfr.lev->dp) != NULL;
|
||||
qsp->xfr.lev->dp = dp->d_next) {
|
||||
/* XYZZY foreach_rr? */
|
||||
if (dp->d_class != class && class != C_ANY)
|
||||
continue;
|
||||
if (dp->d_rcode)
|
||||
continue;
|
||||
if (dp->d_zone != zone || stale(dp))
|
||||
continue;
|
||||
if (dp->d_type == T_SOA || dp->d_type == T_NS)
|
||||
continue;
|
||||
/* XXXRTH I presume this is still relevant and that
|
||||
this is the right place... */
|
||||
#if 0 /* Not yet implemented. Only a SHOULD in the I-D. -gnu@toad.com */
|
||||
/* skip the SIG AXFR record because we did it first too. */
|
||||
if (dp->d_type == T_SIG) {
|
||||
int sig_rrtype = GETSHORT (dp->d_data);
|
||||
if (sig_rrtype == T_AXFR)
|
||||
continue;
|
||||
}
|
||||
#endif /* 0 */
|
||||
INSIST(!(qsp->xfr.lev->flags & SXL_GLUING));
|
||||
|
||||
if (sx_addrr(qsp, qsp->xfr.lev->dname, dp) < 0) {
|
||||
/* RR wouldn't fit. Bail out. */
|
||||
return (-1);
|
||||
}
|
||||
rrcount++;
|
||||
}
|
||||
return (rrcount);
|
||||
}
|
||||
|
||||
/*
|
||||
* void
|
||||
* sx_sendlev(qsp)
|
||||
* send all the RRs at the current level (really a domain name), and
|
||||
* do a decomposed recursion to get all subdomains up to and including
|
||||
* but not exceeding bottom zone cuts.
|
||||
* side effects:
|
||||
* advances qsp->xfr pointers. changes qsp->xfr.lev quite often.
|
||||
* causes messages to be sent to a remote TCP client. changes the
|
||||
* qsp->xfr.state at the end of the topmost level. changes the
|
||||
* qsp->xfr.lev->state several times per domain name.
|
||||
*/
|
||||
static void
|
||||
sx_sendlev(struct qstream *qsp) {
|
||||
struct qs_x_lev *lev;
|
||||
int rrcount;
|
||||
|
||||
again:
|
||||
lev = qsp->xfr.lev;
|
||||
switch (lev->state) {
|
||||
case sxl_ns: {
|
||||
while (lev->dp) {
|
||||
rrcount = sx_nsrrs(qsp);
|
||||
/* If we can't pack this one in, come back later. */
|
||||
if (rrcount < 0)
|
||||
return;
|
||||
/*
|
||||
* NS RRs other than those at the
|
||||
* zone top are zone cuts.
|
||||
*/
|
||||
if (rrcount > 0 && qsp->xfr.top != lev->np)
|
||||
lev->flags |= SXL_ZONECUT;
|
||||
}
|
||||
/* No more DP's for the NS RR pass on this NP. */
|
||||
if (lev->flags & SXL_ZONECUT) {
|
||||
/* Zone cut, so go directly to end of level. */
|
||||
break;
|
||||
}
|
||||
/* No NS RR's, so it's safe to send other types. */
|
||||
lev->state = sxl_all;
|
||||
lev->dp = lev->np->n_data;
|
||||
goto again;
|
||||
}
|
||||
case sxl_all: {
|
||||
while (lev->dp) {
|
||||
/* If we can't pack this one in, come back later. */
|
||||
if (sx_allrrs(qsp) < 0)
|
||||
return;
|
||||
}
|
||||
/* No more non-NS DP's for this NP, do subdomains. */
|
||||
lev->state = sxl_sub;
|
||||
goto again;
|
||||
}
|
||||
case sxl_sub: {
|
||||
struct namebuf *np;
|
||||
|
||||
/* Get next in-use hash chain if we're not following one. */
|
||||
while (lev->nnp == NULL) {
|
||||
/* If no, or no more subdomains, end of level. */
|
||||
if (lev->npp == NULL || lev->npp == lev->npe)
|
||||
break;
|
||||
lev->nnp = *lev->npp++;
|
||||
}
|
||||
/* If we encountered the end of the level, we're outta here. */
|
||||
if ((np = lev->nnp) == NULL)
|
||||
break;
|
||||
/* Next time, we'll do the following NP, or the next chain. */
|
||||
lev->nnp = np->n_next;
|
||||
/* Skip our own NP if it appears as a subdom (as in root). */
|
||||
if (np != lev->np)
|
||||
sx_pushlev(qsp, np);
|
||||
goto again;
|
||||
}
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
|
||||
/* End of level. Pop it off the stack. */
|
||||
|
||||
if ((qsp->xfr.lev = sx_freelev(lev)) == NULL) {
|
||||
/* End of topmost level. */
|
||||
qsp->xfr.state = s_x_lastsoa;
|
||||
sq_writeh(qsp, sx_sendsoa);
|
||||
return;
|
||||
}
|
||||
goto again;
|
||||
}
|
||||
|
||||
/*
|
||||
* void
|
||||
* sx_sendsoa(qsp)
|
||||
* send either the first or last SOA needed for an AXFR.
|
||||
* side effects:
|
||||
* changes qsp->xfr.state. adds RR to output buffer.
|
||||
*/
|
||||
static void
|
||||
sx_sendsoa(struct qstream *qsp) {
|
||||
if (sx_soarr(qsp) == -1)
|
||||
return; /* No state change, come back here later. */
|
||||
|
||||
switch (qsp->xfr.state) {
|
||||
case s_x_firstsoa: {
|
||||
/* Next thing to do is send the zone. */
|
||||
qsp->xfr.state = s_x_zone;
|
||||
sq_writeh(qsp, sx_sendlev);
|
||||
break;
|
||||
}
|
||||
case s_x_lastsoa: {
|
||||
/* Next thing to do is go back and wait for another query. */
|
||||
(void)sx_flush(qsp);
|
||||
qsp->xfr.state = s_x_done;
|
||||
sq_writeh(qsp, sq_flushw);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ns_panic(ns_log_xfer_out, 1,
|
||||
"unexpected state %d in sx_sendsoa", qsp->xfr.state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* int
|
||||
* sx_pushlev(qsp, np)
|
||||
* manage the decomposed recursion. set up for a new level (domain).
|
||||
* returns:
|
||||
* 0 = success
|
||||
* -1 = failure (check errno)
|
||||
*/
|
||||
static int
|
||||
sx_pushlev(struct qstream *qsp, struct namebuf *np) {
|
||||
struct qs_x_lev *new = memget(sizeof *new);
|
||||
struct hashbuf *htp;
|
||||
|
||||
if (!new) {
|
||||
errno = ENOMEM;
|
||||
return (-1);
|
||||
}
|
||||
memset(new, 0, sizeof *new);
|
||||
new->state = sxl_ns;
|
||||
new->np = np;
|
||||
new->dp = np->n_data;
|
||||
getname(np, new->dname, sizeof new->dname);
|
||||
/*
|
||||
* We find the subdomains by looking in the hash table for this
|
||||
* domain, but the root domain needs special treatment, because
|
||||
* of the following wart in the database design:
|
||||
*
|
||||
* The top level hash table (pointed to by the global `hashtab'
|
||||
* variable) contains pointers to the namebuf's for the root as
|
||||
* well as for the top-level domains below the root, in contrast
|
||||
* to the usual situation where a hash table contains entries
|
||||
* for domains at the same level. The n_hash member of the
|
||||
* namebuf for the root domain is NULL instead of pointing to a
|
||||
* hashbuf for the top-level domains. The n_parent members of
|
||||
* the namebufs for the top-level domains are NULL instead of
|
||||
* pointing to the namebuf for the root.
|
||||
*
|
||||
* We work around the wart as follows:
|
||||
*
|
||||
* If we are not dealing with the root zone then we just set
|
||||
* htp = np->n_hash, pointing to the hash table for the current
|
||||
* domain, and we walk through the hash table as usual,
|
||||
* processing the namebufs for all the subdomains.
|
||||
*
|
||||
* If we are dealing with the root zone, then we set
|
||||
* htp = hashtab, pointing to the global hash table (because
|
||||
* there is no hash table associated with the root domain's
|
||||
* namebuf. While we walk this hash table, we take care not to
|
||||
* recursively process the entry for the root namebuf.
|
||||
*
|
||||
* (apb@und nov1990)
|
||||
*/
|
||||
htp = ((new->dname[0] == '\0') ? hashtab : np->n_hash);
|
||||
if (htp) {
|
||||
new->npp = htp->h_tab;
|
||||
new->npe = htp->h_tab + htp->h_size;
|
||||
} else {
|
||||
new->npp = NULL;
|
||||
new->npe = NULL;
|
||||
}
|
||||
new->nnp = NULL;
|
||||
new->next = qsp->xfr.lev;
|
||||
qsp->xfr.lev = new;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* qs_x_lev *
|
||||
* sx_freelev(lev)
|
||||
* free the memory occupied by a level descriptor
|
||||
* return:
|
||||
* pointer to "next" level descriptor
|
||||
*/
|
||||
static struct qs_x_lev *
|
||||
sx_freelev(struct qs_x_lev *lev) {
|
||||
struct qs_x_lev *next = lev->next;
|
||||
|
||||
memput(lev, sizeof *lev);
|
||||
return (next);
|
||||
}
|
||||
55
contrib/bind/bin/named/pathnames.c
Normal file
55
contrib/bind/bin/named/pathnames.c
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright (c) 1996 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* $Id: pathnames.c,v 8.5 1997/05/21 19:52:28 halley Exp $
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <isc/eventlib.h>
|
||||
#include <isc/logging.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "named.h"
|
||||
|
||||
int
|
||||
main(int argc, char *argv[], char *envp[]) {
|
||||
char *arg;
|
||||
|
||||
argc--, argv++;
|
||||
while (argc-- && (arg = *argv++) != NULL)
|
||||
if (!strcasecmp("_PATH_XFER", arg))
|
||||
puts(_PATH_XFER);
|
||||
else if (!strcasecmp("_PATH_PIDFILE", arg))
|
||||
puts(_PATH_PIDFILE);
|
||||
else if (!strcasecmp("_PATH_NAMED", arg))
|
||||
puts(_PATH_NAMED);
|
||||
else
|
||||
exit(1);
|
||||
exit(0);
|
||||
}
|
||||
70
contrib/bind/bin/named/pathtemplate.h
Normal file
70
contrib/bind/bin/named/pathtemplate.h
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* $Id: pathtemplate.h,v 8.1 1998/03/19 19:53:21 halley Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996, 1997 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <paths.h>
|
||||
|
||||
#ifndef _PATH_CONF
|
||||
#define _PATH_CONF "%DESTETC%/named.conf"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_DEBUG
|
||||
#define _PATH_DEBUG "named.run"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_DUMPFILE
|
||||
#define _PATH_DUMPFILE "named_dump.db"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_NAMED
|
||||
#define _PATH_NAMED "%DESTSBIN%/named"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_PIDFILE
|
||||
#define _PATH_PIDFILE "%DESTRUN%/named.pid"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_STATS
|
||||
#define _PATH_STATS "named.stats"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_MEMSTATS
|
||||
#define _PATH_MEMSTATS "named.memstats"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_TMPXFER
|
||||
#define _PATH_TMPXFER "xfer.ddt.XXXXXX"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_XFER
|
||||
#define _PATH_XFER "%DESTEXEC%/named-xfer"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_XFERTRACE
|
||||
#define _PATH_XFERTRACE "xfer.trace"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_XFERDDT
|
||||
#define _PATH_XFERDDT "xfer.ddt"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_DEVNULL
|
||||
#define _PATH_DEVNULL "/dev/null"
|
||||
#endif
|
||||
11
contrib/bind/bin/named/test/127.0.0.zone
Normal file
11
contrib/bind/bin/named/test/127.0.0.zone
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
$ORIGIN 0.0.127.in-addr.arpa.
|
||||
|
||||
@ 1D IN SOA localhost. root.localhost. (
|
||||
42 ; serial (d. adams)
|
||||
3H ; refresh
|
||||
15M ; retry
|
||||
1W ; expiry
|
||||
1D ) ; minimum
|
||||
|
||||
1D IN NS localhost.
|
||||
1 1D IN PTR localhost.
|
||||
10
contrib/bind/bin/named/test/localhost.zone
Normal file
10
contrib/bind/bin/named/test/localhost.zone
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
$ORIGIN localhost.
|
||||
@ 1D IN SOA @ root (
|
||||
42 ; serial (d. adams)
|
||||
3H ; refresh
|
||||
15M ; retry
|
||||
1W ; expiry
|
||||
1D ) ; minimum
|
||||
|
||||
1D IN NS @
|
||||
1D IN A 127.0.0.1
|
||||
29
contrib/bind/bin/named/test/named.conf
Normal file
29
contrib/bind/bin/named/test/named.conf
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
// This is a configuration file for named (from BIND 8.1 or later).
|
||||
// It would normally be installed as /etc/named.conf.
|
||||
|
||||
options {
|
||||
// directory "/var/named";
|
||||
check-names master warn; /* default. */
|
||||
datasize 20M;
|
||||
};
|
||||
|
||||
zone "localhost" IN {
|
||||
type master;
|
||||
file "localhost.zone";
|
||||
check-names fail;
|
||||
allow-update { none; };
|
||||
allow-transfer { any; };
|
||||
};
|
||||
|
||||
zone "0.0.127.in-addr.arpa" IN {
|
||||
type master;
|
||||
file "127.0.0.zone";
|
||||
check-names fail;
|
||||
allow-update { none; };
|
||||
allow-transfer { any; };
|
||||
};
|
||||
|
||||
zone "." IN {
|
||||
type hint;
|
||||
file "root.hint";
|
||||
};
|
||||
37
contrib/bind/bin/named/test/root.hint
Normal file
37
contrib/bind/bin/named/test/root.hint
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
|
||||
; <<>> DiG 2.2 <<>> @192.5.5.241
|
||||
; (1 server found)
|
||||
;; res options: init recurs defnam dnsrch
|
||||
;; got answer:
|
||||
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10
|
||||
;; flags: qr aa rd; QUERY: 1, ANSWER: 9, AUTHORITY: 0, ADDITIONAL: 9
|
||||
;; QUERY SECTION:
|
||||
;; ., type = NS, class = IN
|
||||
|
||||
;; ANSWER SECTION:
|
||||
. 6D IN NS C.ROOT-SERVERS.NET.
|
||||
. 6D IN NS D.ROOT-SERVERS.NET.
|
||||
. 6D IN NS E.ROOT-SERVERS.NET.
|
||||
. 6D IN NS I.ROOT-SERVERS.NET.
|
||||
. 6D IN NS F.ROOT-SERVERS.NET.
|
||||
. 6D IN NS G.ROOT-SERVERS.NET.
|
||||
. 6D IN NS A.ROOT-SERVERS.NET.
|
||||
. 6D IN NS H.ROOT-SERVERS.NET.
|
||||
. 6D IN NS B.ROOT-SERVERS.NET.
|
||||
|
||||
;; ADDITIONAL SECTION:
|
||||
C.ROOT-SERVERS.NET. 5w6d16h IN A 192.33.4.12
|
||||
D.ROOT-SERVERS.NET. 5w6d16h IN A 128.8.10.90
|
||||
E.ROOT-SERVERS.NET. 5w6d16h IN A 192.203.230.10
|
||||
I.ROOT-SERVERS.NET. 5w6d16h IN A 192.36.148.17
|
||||
F.ROOT-SERVERS.NET. 5w6d16h IN A 192.5.5.241
|
||||
G.ROOT-SERVERS.NET. 5w6d16h IN A 192.112.36.4
|
||||
A.ROOT-SERVERS.NET. 5w6d16h IN A 198.41.0.4
|
||||
H.ROOT-SERVERS.NET. 5w6d16h IN A 128.63.2.53
|
||||
B.ROOT-SERVERS.NET. 5w6d16h IN A 128.9.0.107
|
||||
|
||||
;; Total query time: 8 msec
|
||||
;; FROM: wisdom.home.vix.com to SERVER: 192.5.5.241
|
||||
;; WHEN: Fri Nov 22 00:08:05 1996
|
||||
;; MSG SIZE sent: 17 rcvd: 312
|
||||
|
||||
89
contrib/bind/bin/named/version.c
Normal file
89
contrib/bind/bin/named/version.c
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* @(#)Version.c 4.9 (Berkeley) 7/21/90
|
||||
* $Id: version.c,v 8.2 1997/04/24 23:59:02 vixie Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
char sccsid[] = "@(#)named %VERSION% %WHEN% %WHOANDWHERE%";
|
||||
char rcsid[] = "$Id: version.c,v 8.2 1997/04/24 23:59:02 vixie Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
char Version[] = "named %VERSION% %WHEN%\n\t%WHOANDWHERE%";
|
||||
char ShortVersion[] = "%VERSION%";
|
||||
|
||||
#ifdef COMMENT
|
||||
|
||||
SCCS/s.Version.c:
|
||||
|
||||
D 4.8.3 90/06/27 17:05:21 bloom 37 35 00031/00028/00079
|
||||
Version distributed with 4.3 Reno tape (June 1990)
|
||||
|
||||
D 4.8.2 89/09/18 13:57:11 bloom 35 34 00020/00014/00087
|
||||
Interim fixes release
|
||||
|
||||
D 4.8.1 89/02/08 17:12:15 karels 34 33 00026/00017/00075
|
||||
branch for 4.8.1
|
||||
|
||||
D 4.8 88/07/09 14:27:00 karels 33 28 00043/00031/00049
|
||||
4.8 is here!
|
||||
|
||||
D 4.7 87/11/20 13:15:52 karels 25 24 00000/00000/00062
|
||||
4.7.3 beta
|
||||
|
||||
D 4.6 87/07/21 12:15:52 karels 25 24 00000/00000/00062
|
||||
4.6 declared stillborn
|
||||
|
||||
D 4.5 87/02/10 12:33:25 kjd 24 18 00000/00000/00062
|
||||
February 1987, Network Release. Child (bind) grows up, parent (kevin) leaves home.
|
||||
|
||||
D 4.4 86/10/01 10:06:26 kjd 18 12 00020/00017/00042
|
||||
October 1, 1986 Network Distribution
|
||||
|
||||
D 4.3 86/06/04 12:12:18 kjd 12 7 00015/00028/00044
|
||||
Version distributed with 4.3BSD
|
||||
|
||||
D 4.2 86/04/30 20:57:16 kjd 7 1 00056/00000/00016
|
||||
Network distribution Freeze and one more version until 4.3BSD
|
||||
|
||||
D 1.1 86/04/30 19:30:00 kjd 1 0 00016/00000/00000
|
||||
date and time created 86/04/30 19:30:00 by kjd
|
||||
|
||||
code versions:
|
||||
|
||||
Makefile
|
||||
Makefile 4.14 (Berkeley) 2/28/88
|
||||
db.h
|
||||
db.h 4.13 (Berkeley) 2/17/88
|
||||
db_dump.c
|
||||
db_dump.c 4.20 (Berkeley) 2/17/88
|
||||
db_load.c
|
||||
db_load.c 4.26 (Berkeley) 2/28/88
|
||||
db_lookup.c
|
||||
db_lookup.c 4.14 (Berkeley) 2/17/88
|
||||
db_reload.c
|
||||
db_reload.c 4.15 (Berkeley) 2/28/88
|
||||
db_save.c
|
||||
db_save.c 4.13 (Berkeley) 2/17/88
|
||||
db_update.c
|
||||
db_update.c 4.16 (Berkeley) 2/28/88
|
||||
ns_forw.c
|
||||
ns_forw.c 4.26 (Berkeley) 3/28/88
|
||||
ns_init.c
|
||||
ns_init.c 4.23 (Berkeley) 2/28/88
|
||||
ns_main.c
|
||||
Copyright (c) 1986 Regents of the University of California.\n\
|
||||
ns_main.c 4.30 (Berkeley) 3/7/88
|
||||
ns_maint.c
|
||||
ns_maint.c 4.23 (Berkeley) 2/28/88
|
||||
ns_req.c
|
||||
ns_req.c 4.32 (Berkeley) 3/31/88
|
||||
ns_resp.c
|
||||
ns_resp.c 4.50 (Berkeley) 4/7/88
|
||||
ns_sort.c
|
||||
ns_sort.c 4.3 (Berkeley) 2/17/88
|
||||
ns_stats.c
|
||||
ns_stats.c 4.3 (Berkeley) 2/17/88
|
||||
newvers.sh
|
||||
newvers.sh 4.4 (Berkeley) 3/28/88
|
||||
|
||||
#endif /* COMMENT */
|
||||
87
contrib/bind/bin/ndc/Makefile
Normal file
87
contrib/bind/bin/ndc/Makefile
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
## Copyright (c) 1996 by Internet Software Consortium
|
||||
##
|
||||
## 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
# $Id: Makefile,v 1.6 1997/06/19 03:22:10 halley Exp $
|
||||
|
||||
DESTDIR=
|
||||
CC= cc
|
||||
SHELL= /bin/sh
|
||||
|
||||
CDEBUG= -g
|
||||
|
||||
#(net2 and its descendents)
|
||||
SYSTYPE = bsdos
|
||||
TOP = ../..
|
||||
INCL = ${TOP}/include
|
||||
PORTINCL = ${TOP}/port/${SYSTYPE}/include
|
||||
LIBBIND = ${TOP}/lib/libbind.a
|
||||
A=a
|
||||
O=o
|
||||
LEX = lex -I
|
||||
SYSLIBS = -ll -lutil
|
||||
PIDDIR = /var/run
|
||||
DESTBIN = /usr/local/bin
|
||||
DESTSBIN = /usr/local/sbin
|
||||
DESTEXEC = /usr/local/libexec
|
||||
DESTMAN = /usr/share/man
|
||||
DESTHELP= /usr/share/misc
|
||||
AR= ar cruv
|
||||
INSTALL= install
|
||||
STRIP=-s
|
||||
PS=ps
|
||||
|
||||
LDFLAGS=
|
||||
CFLAGS= ${CDEBUG} -I${PORTINCL} -I${INCL} ${DEFS}
|
||||
|
||||
PROG= ndc
|
||||
SRCS=
|
||||
OBJS=
|
||||
|
||||
all: ${PROG}
|
||||
|
||||
${PROG}: ${PROG}.sh ../named/pathnames ../named/pathnames.h Makefile
|
||||
sed -e "s|%PIDFILE%|"`../named/pathnames _path_pidfile`"|" \
|
||||
-e "s|%NAMED%|"`../named/pathnames _path_named`"|" \
|
||||
-e "s|%PS%|${PS}|" \
|
||||
< ndc.sh > ndc
|
||||
chmod +x ndc
|
||||
|
||||
distclean: clean
|
||||
|
||||
clean: FRC
|
||||
rm -f ${PROG} ${OBJS} core .depend
|
||||
rm -f *.BAK *.CKP *~ *.orig
|
||||
|
||||
depend:
|
||||
|
||||
${DESTDIR}${DESTSBIN}:
|
||||
mkdir -p ${DESTDIR}${DESTSBIN}
|
||||
|
||||
install: ${DESTDIR}${DESTSBIN} ${PROG}
|
||||
${INSTALL} -c -m 755 ${PROG} ${DESTDIR}${DESTSBIN}/${PROG}
|
||||
|
||||
links: FRC
|
||||
@set -e; ln -s SRC/*.sh .
|
||||
|
||||
tags: FRC
|
||||
ctags ${SRCS} *.h
|
||||
|
||||
commands.c: commands.l
|
||||
${LEX} -t $< > $@ || rm $@
|
||||
|
||||
FRC:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- mkdep uses it.
|
||||
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
|
||||
83
contrib/bind/bin/ndc/ndc.sh
Normal file
83
contrib/bind/bin/ndc/ndc.sh
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
#!/bin/sh
|
||||
|
||||
USAGE='echo \
|
||||
"usage: $0 \
|
||||
(status|dumpdb|reload|stats|trace|notrace|querylog|start|stop|restart) \
|
||||
... \
|
||||
"; exit 1'
|
||||
|
||||
PATH=/bin:/usr/bin:/usr/ucb:$PATH; export PATH
|
||||
PIDFILE=%PIDFILE%
|
||||
|
||||
if [ -f $PIDFILE ]
|
||||
then
|
||||
PID=`cat $PIDFILE`
|
||||
PS=`%PS% $PID | tail -1 | grep $PID`
|
||||
RUNNING=1
|
||||
[ `echo $PS | wc -w` -ne 0 ] || {
|
||||
PS="named (pid $PID?) not running"
|
||||
RUNNING=0
|
||||
}
|
||||
else
|
||||
PS="named (no pid file) not running"
|
||||
RUNNING=0
|
||||
fi
|
||||
|
||||
for ARG
|
||||
do
|
||||
case $ARG in
|
||||
start|stop|restart)
|
||||
;;
|
||||
*)
|
||||
[ $RUNNING -eq 0 ] && {
|
||||
echo $PS
|
||||
exit 1
|
||||
}
|
||||
esac
|
||||
|
||||
case $ARG in
|
||||
status) echo "$PS";;
|
||||
dumpdb) kill -INT $PID && echo Dumping Database;;
|
||||
reload) kill -HUP $PID && echo Reloading Database;;
|
||||
stats) kill -ILL $PID && echo Dumping Statistics;;
|
||||
trace) kill -USR1 $PID && echo Trace Level Incremented;;
|
||||
notrace) kill -USR2 $PID && echo Tracing Cleared;;
|
||||
querylog|qrylog) kill -WINCH $PID && echo Query Logging Toggled;;
|
||||
start)
|
||||
[ $RUNNING -eq 1 ] && {
|
||||
echo "$0: start: named (pid $PID) already running"
|
||||
continue
|
||||
}
|
||||
rm -f $PIDFILE
|
||||
%NAMED% && {
|
||||
sleep 5
|
||||
echo Name Server Started
|
||||
}
|
||||
;;
|
||||
stop)
|
||||
[ $RUNNING -eq 0 ] && {
|
||||
echo "$0: stop: named not running"
|
||||
continue
|
||||
}
|
||||
kill $PID && {
|
||||
sleep 5
|
||||
rm -f $PIDFILE
|
||||
echo Name Server Stopped
|
||||
}
|
||||
;;
|
||||
restart)
|
||||
[ $RUNNING -eq 1 ] && {
|
||||
kill $PID && sleep 5
|
||||
}
|
||||
rm -f $PIDFILE
|
||||
%NAMED% && {
|
||||
sleep 5
|
||||
echo Name Server Restarted
|
||||
}
|
||||
;;
|
||||
*) eval "$USAGE";;
|
||||
esac
|
||||
done
|
||||
test -z "$ARG" && eval "$USAGE"
|
||||
|
||||
exit 0
|
||||
91
contrib/bind/bin/nslookup/Makefile
Normal file
91
contrib/bind/bin/nslookup/Makefile
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
## Copyright (c) 1996 by Internet Software Consortium
|
||||
##
|
||||
## 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
# $Id: Makefile,v 8.18 1997/12/03 22:55:16 halley Exp $
|
||||
|
||||
DESTDIR=
|
||||
CC= cc
|
||||
SHELL= /bin/sh
|
||||
|
||||
CDEBUG= -g
|
||||
|
||||
#(net2 and its descendents)
|
||||
SYSTYPE = bsdos
|
||||
TOP = ../..
|
||||
INCL = ${TOP}/include
|
||||
PORTINCL = ${TOP}/port/${SYSTYPE}/include
|
||||
LIBBIND = ${TOP}/lib/libbind.a
|
||||
A=a
|
||||
O=o
|
||||
LEX = lex -I
|
||||
SYSLIBS = -ll -lutil
|
||||
PIDDIR = /var/run
|
||||
DESTBIN = /usr/local/bin
|
||||
DESTSBIN = /usr/local/sbin
|
||||
DESTEXEC = /usr/local/libexec
|
||||
DESTMAN = /usr/share/man
|
||||
DESTHELP= /usr/share/misc
|
||||
STRIP=-s
|
||||
|
||||
LDFLAGS=
|
||||
DEFS= -D_PATH_HELPFILE=\"${DESTDIR}${DESTHELP}/nslookup.help\"
|
||||
CFLAGS= ${CDEBUG} -I${PORTINCL} -I${INCL} ${DEFS}
|
||||
|
||||
PROG= nslookup
|
||||
CSRCS= main.c getinfo.c debug.c send.c skip.c list.c subr.c
|
||||
SRCS= ${CSRCS} commands.l
|
||||
OBJS= main.${O} getinfo.${O} debug.${O} send.${O} skip.${O} list.${O} \
|
||||
subr.${O} commands.${O}
|
||||
|
||||
all: ${PROG}
|
||||
|
||||
${PROG}: ${OBJS} ${LIBBIND} Makefile
|
||||
${CC} ${CDEBUG} ${LDFLAGS} -o ${PROG} ${OBJS} \
|
||||
${LIBBIND} ${SYSLIBS}
|
||||
|
||||
distclean: clean
|
||||
rm -f commands.c
|
||||
|
||||
clean: FRC
|
||||
rm -f ${PROG} ${OBJS} core .depend
|
||||
rm -f *.BAK *.CKP *~ *.orig
|
||||
rm -f lex.yy.c lex.yy.o
|
||||
|
||||
depend: ${SRCS}
|
||||
mkdep ${CPPFLAGS} -I${INCL} -I${PORTINCL} ${DEFS} ${CSRCS}
|
||||
|
||||
${DESTDIR}${DESTHELP}:
|
||||
mkdir -p ${DESTDIR}${DESTHELP}
|
||||
|
||||
${DESTDIR}${DESTBIN}:
|
||||
mkdir -p ${DESTDIR}${DESTBIN}
|
||||
|
||||
install: ${DESTDIR}${DESTBIN} ${DESTDIR}${DESTHELP} ${PROG}
|
||||
${INSTALL} ${STRIP} -c -m 755 ${PROG} ${DESTDIR}${DESTBIN}/${PROG}
|
||||
${INSTALL} -c -o bin -g bin -m 444 nslookup.help ${DESTDIR}${DESTHELP}/
|
||||
|
||||
links: FRC
|
||||
@set -e; ln -s SRC/*.[chl] SRC/nslookup.help .
|
||||
|
||||
tags: FRC
|
||||
ctags ${CSRCS} *.h
|
||||
|
||||
commands.c: commands.l
|
||||
${LEX} -t $< > $@ || rm $@
|
||||
|
||||
FRC:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- mkdep uses it.
|
||||
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
|
||||
2036
contrib/bind/bin/nslookup/commands.c
Normal file
2036
contrib/bind/bin/nslookup/commands.c
Normal file
File diff suppressed because it is too large
Load diff
221
contrib/bind/bin/nslookup/commands.l
Normal file
221
contrib/bind/bin/nslookup/commands.l
Normal file
|
|
@ -0,0 +1,221 @@
|
|||
%{
|
||||
|
||||
/*
|
||||
* Copyright (c) 1985
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* 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, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION 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 lint
|
||||
static char sccsid[] = "@(#)commands.l 5.13 (Berkeley) 7/24/90";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* commands.l
|
||||
*
|
||||
* Andrew Cherenson CS298-26 Fall 1985
|
||||
*
|
||||
* Lex input file for the nslookup program command interpreter.
|
||||
* When a sequence is recognized, the associated action
|
||||
* routine is called. The action routine may need to
|
||||
* parse the string for additional information.
|
||||
*
|
||||
* Recognized commands: (identifiers are shown in uppercase)
|
||||
*
|
||||
* server NAME - set default server to NAME, using default server
|
||||
* lserver NAME - set default server to NAME, using initial server
|
||||
* finger [NAME] - finger the optional NAME
|
||||
* exit - exit the program
|
||||
* root - set default server to the root
|
||||
* ls NAME - list the domain NAME
|
||||
* view FILE - sorts and view the file with more
|
||||
* set OPTION - set an option
|
||||
* help - print help information
|
||||
* ? - print help information
|
||||
* NAME - print info about the host/domain NAME
|
||||
* using default server.
|
||||
* NAME1 NAME2 - as above, but use NAME2 as server
|
||||
*
|
||||
*
|
||||
* yylex Results:
|
||||
* 0 upon end-of-file.
|
||||
* 1 after each command.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
#include <sys/types.h>
|
||||
#include "port_after.h"
|
||||
#include "res.h"
|
||||
|
||||
extern char rootServerName[];
|
||||
extern void PrintHelp();
|
||||
|
||||
%}
|
||||
WS [ \t]
|
||||
FLET [A-Za-z0-9.*\\]
|
||||
LET [A-Za-z0-9.*]
|
||||
NAME [A-Za-z0-9.*=_/-]
|
||||
%%
|
||||
^{WS}*server{WS}+{LET}{NAME}*{WS}*$ {
|
||||
/*
|
||||
* 0 == use current server to find
|
||||
* the new one.
|
||||
* 1 == use original server to find
|
||||
* the new one.
|
||||
*/
|
||||
SetDefaultServer(yytext, 0);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*lserver{WS}+{LET}{NAME}*{WS}*$ {
|
||||
SetDefaultServer(yytext, 1);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*exit{WS}*$ {
|
||||
return(0);
|
||||
}
|
||||
^{WS}*root{WS}*$ {
|
||||
SetDefaultServer(rootServerName, 1);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*finger({WS}+{LET}{NAME}*)?{WS}+>>?{WS}*{NAME}+{WS}*$ {
|
||||
/*
|
||||
* 2nd arg.
|
||||
* 0 == output to stdout
|
||||
* 1 == output to file
|
||||
*/
|
||||
Finger(yytext, 1);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*finger({WS}+{LET}{NAME}*)?{WS}*$ {
|
||||
Finger(yytext, 0);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*view{WS}+{NAME}+{WS}*$ {
|
||||
ViewList(yytext);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*ls{WS}+(("-a"|"-d"|"-h"|"-m"|"-s"){WS}+)?{LET}{NAME}*{WS}+>>?{WS}+{NAME}+{WS}*$ {
|
||||
/*
|
||||
* 2nd arg.
|
||||
* 0 == output to stdout
|
||||
* 1 == output to file
|
||||
*/
|
||||
ListHosts(yytext, 1);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*ls{WS}+(("-a"|"-d"|"-h"|"-m"|"-s"){WS}+)?{LET}{NAME}*{WS}*$ {
|
||||
ListHosts(yytext, 0);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*ls{WS}+-t{WS}+({LET}{NAME}*{WS}+)?{LET}{NAME}*{WS}+>>?{WS}+{NAME}+{WS}*$ {
|
||||
/*
|
||||
* 2nd arg.
|
||||
* 0 == output to stdout
|
||||
* 1 == output to file
|
||||
*/
|
||||
ListHostsByType(yytext, 1);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*ls{WS}+-t{WS}+({LET}{NAME}*{WS}+)?{LET}{NAME}*{WS}*$ {
|
||||
ListHostsByType(yytext, 0);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*set{WS}+{NAME}+{WS}*$ {
|
||||
SetOption(yytext);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*help{WS}*$ {
|
||||
PrintHelp();
|
||||
return(1);
|
||||
}
|
||||
^{WS}*"?"{WS}*$ {
|
||||
extern void PrintHelp();
|
||||
|
||||
PrintHelp();
|
||||
return(1);
|
||||
}
|
||||
^{WS}*{FLET}{NAME}*{WS}+>>?{WS}*{NAME}+{WS}*$ {
|
||||
/*
|
||||
* 0 == output to stdout
|
||||
* 1 == output to file
|
||||
*/
|
||||
LookupHost(yytext, 1);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*{FLET}{NAME}*{WS}*$ {
|
||||
LookupHost(yytext, 0);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*{FLET}{NAME}*{WS}+{LET}{NAME}*{WS}+>>?{WS}*{NAME}+{WS}*$ {
|
||||
/*
|
||||
* 0 == output to stdout
|
||||
* 1 == output to file
|
||||
*/
|
||||
LookupHostWithServer(yytext, 1);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*{FLET}{NAME}*{WS}+{LET}{NAME}*{WS}*$ {
|
||||
LookupHostWithServer(yytext, 0);
|
||||
return(1);
|
||||
}
|
||||
^{WS}*\n {
|
||||
return(1);
|
||||
}
|
||||
^.*\n {
|
||||
printf("Unrecognized command: %s",
|
||||
yytext);
|
||||
return(1);
|
||||
}
|
||||
\n { ; }
|
||||
%%
|
||||
646
contrib/bind/bin/nslookup/debug.c
Normal file
646
contrib/bind/bin/nslookup/debug.c
Normal file
|
|
@ -0,0 +1,646 @@
|
|||
/*
|
||||
* Copyright (c) 1985, 1989
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* 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, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION 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 lint
|
||||
static char sccsid[] = "@(#)debug.c 5.26 (Berkeley) 3/21/91";
|
||||
static char rcsid[] = "$Id: debug.c,v 8.11 1998/03/19 19:30:54 halley Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* debug.c --
|
||||
*
|
||||
* Routines to print out packets received from a name server query.
|
||||
*
|
||||
* Modified version of 4.3BSD BIND res_debug.c 5.30 6/27/90
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <netdb.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "res.h"
|
||||
|
||||
/*
|
||||
* Imported from res_debug.c
|
||||
*/
|
||||
extern char *_res_resultcodes[];
|
||||
extern char *_res_opcodes[];
|
||||
|
||||
/*
|
||||
* Used to highlight the start of a record when printing it.
|
||||
*/
|
||||
#define INDENT " -> "
|
||||
|
||||
/*
|
||||
* Print the contents of a query.
|
||||
* This is intended to be primarily a debugging routine.
|
||||
*/
|
||||
|
||||
void
|
||||
Print_query(const u_char *msg, const u_char *eom, int printHeader) {
|
||||
Fprint_query(msg, eom, printHeader, stdout);
|
||||
}
|
||||
|
||||
void
|
||||
Fprint_query(const u_char *msg, const u_char *eom, int printHeader, FILE *file)
|
||||
{
|
||||
const u_char *cp;
|
||||
const HEADER *hp;
|
||||
int n;
|
||||
u_int class, type;
|
||||
|
||||
/*
|
||||
* Print header fields.
|
||||
*/
|
||||
hp = (HEADER *)msg;
|
||||
cp = msg + HFIXEDSZ;
|
||||
if (printHeader || (_res.options & RES_DEBUG2)) {
|
||||
fprintf(file," HEADER:\n");
|
||||
fprintf(file,"\topcode = %s", _res_opcodes[hp->opcode]);
|
||||
fprintf(file,", id = %d", ntohs(hp->id));
|
||||
fprintf(file,", rcode = %s\n", _res_resultcodes[hp->rcode]);
|
||||
fprintf(file,"\theader flags: ");
|
||||
if (hp->qr) {
|
||||
fprintf(file," response");
|
||||
} else {
|
||||
fprintf(file," query");
|
||||
}
|
||||
if (hp->aa)
|
||||
fprintf(file,", auth. answer");
|
||||
if (hp->tc)
|
||||
fprintf(file,", truncation");
|
||||
if (hp->rd)
|
||||
fprintf(file,", want recursion");
|
||||
if (hp->ra)
|
||||
fprintf(file,", recursion avail.");
|
||||
if (hp->unused)
|
||||
fprintf(file,", UNUSED-QUERY_BIT");
|
||||
if (hp->ad)
|
||||
fprintf(file,", authentic data");
|
||||
if (hp->cd)
|
||||
fprintf(file,", checking disabled");
|
||||
fprintf(file,"\n\tquestions = %d", ntohs(hp->qdcount));
|
||||
fprintf(file,", answers = %d", ntohs(hp->ancount));
|
||||
fprintf(file,", authority records = %d", ntohs(hp->nscount));
|
||||
fprintf(file,", additional = %d\n\n", ntohs(hp->arcount));
|
||||
}
|
||||
|
||||
/*
|
||||
* Print question records.
|
||||
*/
|
||||
n = ntohs(hp->qdcount);
|
||||
if (n > 0) {
|
||||
fprintf(file," QUESTIONS:\n");
|
||||
while (--n >= 0) {
|
||||
fprintf(file,"\t");
|
||||
cp = Print_cdname(cp, msg, eom, file);
|
||||
if (cp == NULL)
|
||||
return;
|
||||
type = ns_get16((u_char*)cp);
|
||||
cp += INT16SZ;
|
||||
class = ns_get16((u_char*)cp);
|
||||
cp += INT16SZ;
|
||||
fprintf(file,", type = %s", p_type(type));
|
||||
fprintf(file,", class = %s\n", p_class(class));
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Print authoritative answer records
|
||||
*/
|
||||
n = ntohs(hp->ancount);
|
||||
if (n > 0) {
|
||||
fprintf(file," ANSWERS:\n");
|
||||
if (type == ns_t_a && n > MAXADDRS) {
|
||||
printf("Limiting response to MAX Addrs = %d \n",
|
||||
MAXADDRS);
|
||||
n = MAXADDRS;
|
||||
}
|
||||
while (--n >= 0) {
|
||||
fprintf(file, INDENT);
|
||||
cp = Print_rr(cp, msg, eom, file);
|
||||
if (cp == NULL)
|
||||
return;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* print name server records
|
||||
*/
|
||||
n = ntohs(hp->nscount);
|
||||
if (n > 0) {
|
||||
fprintf(file," AUTHORITY RECORDS:\n");
|
||||
while (--n >= 0) {
|
||||
fprintf(file, INDENT);
|
||||
cp = Print_rr(cp, msg, eom, file);
|
||||
if (cp == NULL)
|
||||
return;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* print additional records
|
||||
*/
|
||||
n = ntohs(hp->arcount);
|
||||
if (n > 0) {
|
||||
fprintf(file," ADDITIONAL RECORDS:\n");
|
||||
while (--n >= 0) {
|
||||
fprintf(file, INDENT);
|
||||
cp = Print_rr(cp, msg, eom, file);
|
||||
if (cp == NULL)
|
||||
return;
|
||||
}
|
||||
}
|
||||
fprintf(file,"\n------------\n");
|
||||
}
|
||||
|
||||
const u_char *
|
||||
Print_cdname_sub(const u_char *cp, const u_char *msg, const u_char *eom,
|
||||
FILE *file, int format)
|
||||
{
|
||||
char name[MAXDNAME];
|
||||
int n;
|
||||
|
||||
n = dn_expand(msg, eom, cp, name, sizeof name);
|
||||
if (n < 0)
|
||||
return (NULL);
|
||||
if (name[0] == '\0')
|
||||
strcpy(name, "(root)");
|
||||
if (format)
|
||||
fprintf(file, "%-30s", name);
|
||||
else
|
||||
fputs(name, file);
|
||||
return (cp + n);
|
||||
}
|
||||
|
||||
const u_char *
|
||||
Print_cdname(const u_char *cp, const u_char *msg, const u_char *eom,
|
||||
FILE *file)
|
||||
{
|
||||
return (Print_cdname_sub(cp, msg, eom, file, 0));
|
||||
}
|
||||
|
||||
const u_char *
|
||||
Print_cdname2(const u_char *cp, const u_char *msg, const u_char *eom,
|
||||
FILE *file)
|
||||
{
|
||||
return (Print_cdname_sub(cp, msg, eom, file, 1));
|
||||
}
|
||||
|
||||
#define BOUNDS_CHECK(ptr, count) \
|
||||
do { \
|
||||
if ((ptr) + (count) > eom) { \
|
||||
fprintf(file, "(form error.)\n"); \
|
||||
return (NULL); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Print resource record fields in human readable form (not master file form).
|
||||
*/
|
||||
const u_char *
|
||||
Print_rr(const u_char *ocp, const u_char *msg, const u_char *eom, FILE *file) {
|
||||
u_int type, class;
|
||||
int dlen, n, c, debug;
|
||||
u_long rrttl, ttl;
|
||||
struct in_addr inaddr;
|
||||
const u_char *cp, *cp1, *cp2;
|
||||
|
||||
if ((cp = Print_cdname(ocp, msg, eom, file)) == NULL) {
|
||||
fprintf(file, "(name truncated?)\n");
|
||||
return (NULL); /* compression error */
|
||||
}
|
||||
|
||||
BOUNDS_CHECK(cp, 3 * INT16SZ + INT32SZ);
|
||||
NS_GET16(type, cp);
|
||||
NS_GET16(class, cp);
|
||||
NS_GET32(rrttl, cp);
|
||||
NS_GET16(dlen, cp);
|
||||
BOUNDS_CHECK(cp, dlen);
|
||||
|
||||
debug = _res.options & (RES_DEBUG|RES_DEBUG2);
|
||||
if (debug) {
|
||||
if (_res.options & RES_DEBUG2)
|
||||
fprintf(file,"\n\ttype = %s, class = %s, dlen = %d",
|
||||
p_type(type), p_class(class), dlen);
|
||||
if (type == T_SOA)
|
||||
fprintf(file,"\n\tttl = %lu (%s)",
|
||||
rrttl, p_time(rrttl));
|
||||
putc('\n', file);
|
||||
}
|
||||
|
||||
cp1 = cp;
|
||||
|
||||
/*
|
||||
* Print type specific data, if appropriate
|
||||
*/
|
||||
switch (type) {
|
||||
case T_A:
|
||||
BOUNDS_CHECK(cp, INADDRSZ);
|
||||
memcpy(&inaddr, cp, INADDRSZ);
|
||||
fprintf(file,"\tinternet address = %s\n", inet_ntoa(inaddr));
|
||||
cp += dlen;
|
||||
break;
|
||||
|
||||
case T_CNAME:
|
||||
fprintf(file,"\tcanonical name = ");
|
||||
goto doname;
|
||||
|
||||
case T_MG:
|
||||
fprintf(file,"\tmail group member = ");
|
||||
goto doname;
|
||||
|
||||
case T_MB:
|
||||
fprintf(file,"\tmail box = ");
|
||||
goto doname;
|
||||
|
||||
case T_MR:
|
||||
fprintf(file,"\tmailbox rename = ");
|
||||
goto doname;
|
||||
|
||||
case T_MX:
|
||||
BOUNDS_CHECK(cp, INT16SZ);
|
||||
fprintf(file,"\tpreference = %u",ns_get16((u_char*)cp));
|
||||
cp += INT16SZ;
|
||||
fprintf(file,", mail exchanger = ");
|
||||
goto doname;
|
||||
|
||||
case T_NAPTR:
|
||||
BOUNDS_CHECK(cp, 2 * INT16SZ);
|
||||
fprintf(file, "\torder = %u",ns_get16((u_char*)cp));
|
||||
cp += INT16SZ;
|
||||
fprintf(file,", preference = %u\n", ns_get16((u_char*)cp));
|
||||
cp += INT16SZ;
|
||||
/* Flags */
|
||||
BOUNDS_CHECK(cp, 1);
|
||||
n = *cp++;
|
||||
BOUNDS_CHECK(cp, n);
|
||||
fprintf(file,"\tflags = \"%.*s\"\n", (int)n, cp);
|
||||
cp += n;
|
||||
/* Service */
|
||||
BOUNDS_CHECK(cp, 1);
|
||||
n = *cp++;
|
||||
BOUNDS_CHECK(cp, n);
|
||||
fprintf(file,"\tservices = \"%.*s\"\n", (int)n, cp);
|
||||
cp += n;
|
||||
/* Regexp */
|
||||
BOUNDS_CHECK(cp, 1);
|
||||
n = *cp++;
|
||||
BOUNDS_CHECK(cp, n);
|
||||
fprintf(file,"\trule = \"%.*s\"\n", (int)n, cp);
|
||||
cp += n;
|
||||
/* Replacement */
|
||||
fprintf(file,"\treplacement = ");
|
||||
cp = Print_cdname(cp, msg, eom, file);
|
||||
if (cp == NULL) {
|
||||
fprintf(file, "(replacement truncated?)\n");
|
||||
return (NULL); /* compression error */
|
||||
}
|
||||
(void) putc('\n', file);
|
||||
break;
|
||||
|
||||
case T_SRV:
|
||||
BOUNDS_CHECK(cp, 3 * INT16SZ);
|
||||
fprintf(file, "\tpriority = %u",ns_get16((u_char*)cp));
|
||||
cp += INT16SZ;
|
||||
fprintf(file,", weight = %u", ns_get16((u_char*)cp));
|
||||
cp += INT16SZ;
|
||||
fprintf(file,", port= %u\n", ns_get16((u_char*)cp));
|
||||
cp += INT16SZ;
|
||||
|
||||
fprintf(file,"\thost = ");
|
||||
goto doname;
|
||||
|
||||
case T_PX:
|
||||
BOUNDS_CHECK(cp, INT16SZ);
|
||||
fprintf(file,"\tpreference = %u",ns_get16((u_char*)cp));
|
||||
cp += INT16SZ;
|
||||
fprintf(file,", RFC 822 = ");
|
||||
cp = Print_cdname(cp, msg, eom, file);
|
||||
if (cp == NULL) {
|
||||
fprintf(file, "(name truncated?)\n");
|
||||
return (NULL); /* compression error */
|
||||
}
|
||||
fprintf(file,"\nX.400 = ");
|
||||
cp = Print_cdname(cp, msg, eom, file);
|
||||
if (cp == NULL) {
|
||||
fprintf(file, "(name truncated?)\n");
|
||||
return (NULL); /* compression error */
|
||||
}
|
||||
(void) putc('\n', file);
|
||||
break;
|
||||
|
||||
case T_RT:
|
||||
BOUNDS_CHECK(cp, INT16SZ);
|
||||
fprintf(file,"\tpreference = %u",ns_get16((u_char*)cp));
|
||||
cp += INT16SZ;
|
||||
fprintf(file,", router = ");
|
||||
goto doname;
|
||||
|
||||
case T_AFSDB:
|
||||
BOUNDS_CHECK(cp, INT16SZ);
|
||||
fprintf(file,"\tsubtype = %d",ns_get16((u_char*)cp));
|
||||
cp += INT16SZ;
|
||||
fprintf(file,", DCE/AFS server = ");
|
||||
goto doname;
|
||||
|
||||
case T_NS:
|
||||
fprintf(file,"\tnameserver = ");
|
||||
goto doname;
|
||||
|
||||
case T_PTR:
|
||||
fprintf(file,"\tname = ");
|
||||
doname:
|
||||
cp = Print_cdname(cp, msg, eom, file);
|
||||
if (cp == NULL) {
|
||||
fprintf(file, "(name truncated?)\n");
|
||||
return (NULL); /* compression error */
|
||||
}
|
||||
(void) putc('\n', file);
|
||||
break;
|
||||
|
||||
case T_HINFO:
|
||||
cp2 = cp + dlen;
|
||||
BOUNDS_CHECK(cp, 1);
|
||||
if ((n = *cp++) != 0) {
|
||||
BOUNDS_CHECK(cp, n);
|
||||
fprintf(file,"\tCPU = %.*s", n, cp);
|
||||
cp += n;
|
||||
}
|
||||
if ((cp < cp2) && ((n = *cp++) != 0)) {
|
||||
BOUNDS_CHECK(cp, n);
|
||||
fprintf(file,"\tOS = %.*s\n", n, cp);
|
||||
cp += n;
|
||||
} else fprintf(file, "\n*** Warning *** OS-type missing\n");
|
||||
break;
|
||||
|
||||
case T_ISDN:
|
||||
cp2 = cp + dlen;
|
||||
BOUNDS_CHECK(cp, 1);
|
||||
n = *cp++;
|
||||
if (n != 0) {
|
||||
BOUNDS_CHECK(cp, n);
|
||||
fprintf(file,"\tISDN = \"%.*s", n, cp);
|
||||
cp += n;
|
||||
}
|
||||
if ((cp < cp2) && (n = *cp++)) {
|
||||
BOUNDS_CHECK(cp, n);
|
||||
fprintf(file,"-%.*s\"\n", n, cp);
|
||||
cp += n;
|
||||
} else fprintf(file,"\"\n");
|
||||
break;
|
||||
|
||||
case T_SOA:
|
||||
if (!debug)
|
||||
putc('\n', file);
|
||||
fprintf(file,"\torigin = ");
|
||||
cp = Print_cdname(cp, msg, eom, file);
|
||||
if (cp == NULL) {
|
||||
fprintf(file, "(name truncated?)\n");
|
||||
return (NULL); /* compression error */
|
||||
}
|
||||
fprintf(file,"\n\tmail addr = ");
|
||||
cp = Print_cdname(cp, msg, eom, file);
|
||||
if (cp == NULL) {
|
||||
fprintf(file, "(name truncated?)\n");
|
||||
return (NULL); /* compression error */
|
||||
}
|
||||
BOUNDS_CHECK(cp, 5 * INT32SZ);
|
||||
fprintf(file,"\n\tserial = %lu", ns_get32((u_char*)cp));
|
||||
cp += INT32SZ;
|
||||
ttl = ns_get32((u_char*)cp);
|
||||
fprintf(file,"\n\trefresh = %lu (%s)", ttl, p_time(ttl));
|
||||
cp += INT32SZ;
|
||||
ttl = ns_get32((u_char*)cp);
|
||||
fprintf(file,"\n\tretry = %lu (%s)", ttl, p_time(ttl));
|
||||
cp += INT32SZ;
|
||||
ttl = ns_get32((u_char*)cp);
|
||||
fprintf(file,"\n\texpire = %lu (%s)", ttl, p_time(ttl));
|
||||
cp += INT32SZ;
|
||||
ttl = ns_get32((u_char*)cp);
|
||||
fprintf(file,
|
||||
"\n\tminimum ttl = %lu (%s)\n", ttl, p_time(ttl));
|
||||
cp += INT32SZ;
|
||||
break;
|
||||
|
||||
case T_MINFO:
|
||||
if (!debug)
|
||||
putc('\n', file);
|
||||
fprintf(file,"\trequests = ");
|
||||
cp = Print_cdname(cp, msg, eom, file);
|
||||
if (cp == NULL) {
|
||||
fprintf(file, "(name truncated?)\n");
|
||||
return (NULL); /* compression error */
|
||||
}
|
||||
fprintf(file,"\n\terrors = ");
|
||||
cp = Print_cdname(cp, msg, eom, file);
|
||||
if (cp == NULL) {
|
||||
fprintf(file, "(name truncated?)\n");
|
||||
return (NULL); /* compression error */
|
||||
}
|
||||
(void) putc('\n', file);
|
||||
break;
|
||||
|
||||
case T_RP:
|
||||
if (!debug)
|
||||
putc('\n', file);
|
||||
fprintf(file,"\tmailbox = ");
|
||||
cp = Print_cdname(cp, msg, eom, file);
|
||||
if (cp == NULL) {
|
||||
fprintf(file, "(name truncated?)\n");
|
||||
return (NULL); /* compression error */
|
||||
}
|
||||
fprintf(file,"\n\ttext = ");
|
||||
cp = Print_cdname(cp, msg, eom, file);
|
||||
if (cp == NULL) {
|
||||
fprintf(file, "(name truncated?)\n");
|
||||
return (NULL); /* compression error */
|
||||
}
|
||||
(void) putc('\n', file);
|
||||
break;
|
||||
|
||||
case T_TXT:
|
||||
(void) fputs("\ttext = ", file);
|
||||
cp2 = cp1 + dlen;
|
||||
while (cp < cp2) {
|
||||
(void) putc('"', file);
|
||||
n = (unsigned char) *cp++;
|
||||
if (n != 0) {
|
||||
for (c = n; c > 0 && cp < cp2; c--) {
|
||||
if ((*cp == '\n') || (*cp == '"') || (*cp == '\\'))
|
||||
(void) putc('\\', file);
|
||||
(void) putc(*cp++, file);
|
||||
}
|
||||
}
|
||||
(void) putc('"', file);
|
||||
if (cp < cp2)
|
||||
(void) putc(' ', file);
|
||||
}
|
||||
(void) putc('\n', file);
|
||||
break;
|
||||
|
||||
case T_X25:
|
||||
(void) fputs("\tX25 = \"", file);
|
||||
cp2 = cp1 + dlen;
|
||||
while (cp < cp2) {
|
||||
n = (unsigned char) *cp++;
|
||||
if (n != 0) {
|
||||
for (c = n; c > 0 && cp < cp2; c--)
|
||||
if (*cp == '\n') {
|
||||
(void) putc('\\', file);
|
||||
(void) putc(*cp++, file);
|
||||
} else
|
||||
(void) putc(*cp++, file);
|
||||
}
|
||||
}
|
||||
(void) fputs("\"\n", file);
|
||||
break;
|
||||
|
||||
case T_NSAP:
|
||||
fprintf(file, "\tnsap = %s\n", inet_nsap_ntoa(dlen, cp, NULL));
|
||||
cp += dlen;
|
||||
break;
|
||||
|
||||
case T_AAAA: {
|
||||
char t[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
|
||||
|
||||
BOUNDS_CHECK(cp, IN6ADDRSZ);
|
||||
fprintf(file, "\tIPv6 address = %s\n",
|
||||
inet_ntop(AF_INET6, cp, t, sizeof t));
|
||||
cp += IN6ADDRSZ;
|
||||
break;
|
||||
}
|
||||
|
||||
case T_WKS: {
|
||||
struct protoent *protoPtr;
|
||||
|
||||
BOUNDS_CHECK(cp, INADDRSZ + 1);
|
||||
if (!debug)
|
||||
(void) putc('\n', file);
|
||||
memcpy(&inaddr, cp, INADDRSZ);
|
||||
cp += INADDRSZ;
|
||||
if ((protoPtr = getprotobynumber(*cp)) != NULL) {
|
||||
fprintf(file,"\tinet address = %s, protocol = %s\n\t",
|
||||
inet_ntoa(inaddr), protoPtr->p_name);
|
||||
} else {
|
||||
fprintf(file,"\tinet address = %s, protocol = %d\n\t",
|
||||
inet_ntoa(inaddr), *cp);
|
||||
}
|
||||
cp++;
|
||||
n = 0;
|
||||
while (cp < cp1 + dlen) {
|
||||
c = *cp++;
|
||||
do {
|
||||
struct servent *s;
|
||||
|
||||
if (c & 0200) {
|
||||
s = getservbyport((int)htons(n),
|
||||
protoPtr ? protoPtr->p_name : NULL);
|
||||
if (s != NULL) {
|
||||
fprintf(file," %s", s->s_name);
|
||||
} else {
|
||||
fprintf(file," #%d", n);
|
||||
}
|
||||
}
|
||||
c <<= 1;
|
||||
} while (++n & 07);
|
||||
}
|
||||
putc('\n',file);
|
||||
break;
|
||||
}
|
||||
|
||||
case T_NULL:
|
||||
fprintf(file, "\tNULL (dlen %d)\n", dlen);
|
||||
cp += dlen;
|
||||
break;
|
||||
|
||||
case T_NXT:
|
||||
case T_SIG:
|
||||
case T_KEY:
|
||||
default: {
|
||||
char buf[2048]; /* XXX need to malloc/realloc. */
|
||||
|
||||
if (ns_sprintrrf(msg, eom - msg, "?", class, type, rrttl,
|
||||
cp1, dlen, NULL, NULL, buf, sizeof buf) < 0) {
|
||||
perror("ns_sprintrrf");
|
||||
} else {
|
||||
fprintf(file,
|
||||
"\trecord type %s, interpreted as:\n%s\n",
|
||||
p_type(type), buf);
|
||||
}
|
||||
cp += dlen;
|
||||
}
|
||||
}
|
||||
if (_res.options & RES_DEBUG && type != T_SOA) {
|
||||
fprintf(file,"\tttl = %lu (%s)\n", rrttl, p_time(rrttl));
|
||||
}
|
||||
if (cp != cp1 + dlen) {
|
||||
fprintf(file,
|
||||
"\n*** Error: record size incorrect (%d != %d)\n\n",
|
||||
cp - cp1, dlen);
|
||||
cp = NULL;
|
||||
}
|
||||
return (cp);
|
||||
}
|
||||
872
contrib/bind/bin/nslookup/getinfo.c
Normal file
872
contrib/bind/bin/nslookup/getinfo.c
Normal file
|
|
@ -0,0 +1,872 @@
|
|||
/*
|
||||
* Copyright (c) 1985, 1989
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* 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, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION 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 lint
|
||||
static char sccsid[] = "@(#)getinfo.c 5.26 (Berkeley) 3/21/91";
|
||||
static char rcsid[] = "$Id: getinfo.c,v 8.11 1998/03/19 19:30:55 halley Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* getinfo.c --
|
||||
*
|
||||
* Routines to create requests to name servers
|
||||
* and interpret the answers.
|
||||
*
|
||||
* Adapted from 4.3BSD BIND gethostnamadr.c
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "res.h"
|
||||
|
||||
extern char *_res_resultcodes[];
|
||||
extern char *res_skip();
|
||||
|
||||
static char *addr_list[MAXADDRS + 1];
|
||||
|
||||
static char *host_aliases[MAXALIASES];
|
||||
static int host_aliases_len[MAXALIASES];
|
||||
static u_char hostbuf[MAXDNAME];
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
char *domain[MAXDOMAINS];
|
||||
int numDomains;
|
||||
char *address[MAXADDRS];
|
||||
int numAddresses;
|
||||
} ServerTable;
|
||||
|
||||
ServerTable server[MAXSERVERS];
|
||||
|
||||
typedef union {
|
||||
HEADER qb1;
|
||||
u_char qb2[PACKETSZ*2];
|
||||
} querybuf;
|
||||
|
||||
typedef union {
|
||||
int32_t al;
|
||||
char ac;
|
||||
} align;
|
||||
|
||||
#define GetShort(cp) ns_get16(cp); cp += INT16SZ;
|
||||
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* GetAnswer --
|
||||
*
|
||||
* Interprets an answer packet and retrieves the following
|
||||
* information:
|
||||
*
|
||||
* Results:
|
||||
* SUCCESS the info was retrieved.
|
||||
* NO_INFO the packet did not contain an answer.
|
||||
* NONAUTH non-authoritative information was found.
|
||||
* ERROR the answer was malformed.
|
||||
* Other errors returned in the packet header.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
static int
|
||||
GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer)
|
||||
struct in_addr *nsAddrPtr;
|
||||
char *msg;
|
||||
int queryType;
|
||||
int msglen;
|
||||
Boolean iquery;
|
||||
register HostInfo *hostPtr;
|
||||
Boolean isServer;
|
||||
{
|
||||
register HEADER *headerPtr;
|
||||
register u_char *cp;
|
||||
querybuf answer;
|
||||
char **aliasPtr;
|
||||
u_char *eom, *bp;
|
||||
char **addrPtr;
|
||||
char *namePtr;
|
||||
char *dnamePtr;
|
||||
int type, class;
|
||||
int qdcount, ancount, arcount, nscount, buflen;
|
||||
int origClass;
|
||||
int numAliases = 0;
|
||||
int numAddresses = 0;
|
||||
int n, i, j;
|
||||
int len;
|
||||
int dlen;
|
||||
int status;
|
||||
int numServers;
|
||||
Boolean haveAnswer;
|
||||
Boolean printedAnswers = FALSE;
|
||||
|
||||
|
||||
/*
|
||||
* If the hostPtr was used before, free up the calloc'd areas.
|
||||
*/
|
||||
FreeHostInfoPtr(hostPtr);
|
||||
|
||||
status = SendRequest(nsAddrPtr, msg, msglen, (u_char *) &answer,
|
||||
sizeof(answer), &n);
|
||||
|
||||
if (status != SUCCESS) {
|
||||
if (_res.options & RES_DEBUG2)
|
||||
printf("SendRequest failed\n");
|
||||
return (status);
|
||||
}
|
||||
eom = (u_char *) &answer + n;
|
||||
|
||||
headerPtr = (HEADER *) &answer;
|
||||
|
||||
if (headerPtr->rcode != NOERROR) {
|
||||
return (headerPtr->rcode);
|
||||
}
|
||||
|
||||
qdcount = ntohs(headerPtr->qdcount);
|
||||
ancount = ntohs(headerPtr->ancount);
|
||||
arcount = ntohs(headerPtr->arcount);
|
||||
nscount = ntohs(headerPtr->nscount);
|
||||
|
||||
/*
|
||||
* If there are no answer, n.s. or additional records
|
||||
* then return with an error.
|
||||
*/
|
||||
if (ancount == 0 && nscount == 0 && arcount == 0) {
|
||||
return (NO_INFO);
|
||||
}
|
||||
|
||||
|
||||
bp = hostbuf;
|
||||
buflen = sizeof(hostbuf);
|
||||
cp = (u_char *) &answer + HFIXEDSZ;
|
||||
|
||||
/* Skip over question section. */
|
||||
while (qdcount-- > 0) {
|
||||
n = dn_skipname(cp, eom);
|
||||
if (n < 0)
|
||||
return (ERROR);
|
||||
cp += n + QFIXEDSZ;
|
||||
if (cp > eom)
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
aliasPtr = host_aliases;
|
||||
addrPtr = addr_list;
|
||||
haveAnswer = FALSE;
|
||||
|
||||
/*
|
||||
* Scan through the answer resource records.
|
||||
* Answers for address query types are saved.
|
||||
* Other query type answers are just printed.
|
||||
*/
|
||||
if (ancount != 0) {
|
||||
|
||||
if (headerPtr->ad)
|
||||
printf("Answer crypto-validated by server:\n");
|
||||
|
||||
if (!isServer && !headerPtr->aa) {
|
||||
printf("Non-authoritative answer:\n");
|
||||
}
|
||||
|
||||
if (queryType != T_A && !(iquery && queryType == T_PTR)) {
|
||||
while (--ancount >= 0 && cp < eom) {
|
||||
if ((cp = (u_char *)Print_rr(cp,
|
||||
(u_char *)&answer, eom, stdout)) == NULL) {
|
||||
return(ERROR);
|
||||
}
|
||||
}
|
||||
printedAnswers = TRUE;
|
||||
} else {
|
||||
while (--ancount >= 0 && cp < eom) {
|
||||
n = dn_expand(answer.qb2, eom, cp, (char *)bp, buflen);
|
||||
if (n < 0)
|
||||
return(ERROR);
|
||||
cp += n;
|
||||
if (cp + 3 * INT16SZ + INT32SZ > eom)
|
||||
return (ERROR);
|
||||
type = GetShort(cp);
|
||||
class = GetShort(cp);
|
||||
cp += INT32SZ; /* skip TTL */
|
||||
dlen = GetShort(cp);
|
||||
if (cp + dlen > eom)
|
||||
return (ERROR);
|
||||
if (type == T_CNAME) {
|
||||
/*
|
||||
* Found an alias.
|
||||
*/
|
||||
cp += dlen;
|
||||
if (aliasPtr >= &host_aliases[MAXALIASES-1]) {
|
||||
continue;
|
||||
}
|
||||
*aliasPtr++ = (char *)bp;
|
||||
n = strlen((char *)bp) + 1;
|
||||
host_aliases_len[numAliases] = n;
|
||||
numAliases++;
|
||||
bp += n;
|
||||
buflen -= n;
|
||||
continue;
|
||||
} else if (type == T_PTR) {
|
||||
/*
|
||||
* Found a "pointer" to the real name.
|
||||
*/
|
||||
n = dn_expand(answer.qb2, eom, cp, (char *)bp, buflen);
|
||||
if (n < 0) {
|
||||
cp += n;
|
||||
continue;
|
||||
}
|
||||
cp += n;
|
||||
len = strlen((char *)bp) + 1;
|
||||
hostPtr->name = Calloc(1, len);
|
||||
memcpy(hostPtr->name, bp, len);
|
||||
haveAnswer = TRUE;
|
||||
break;
|
||||
} else if (type != T_A) {
|
||||
cp += dlen;
|
||||
continue;
|
||||
}
|
||||
if (dlen != INADDRSZ)
|
||||
return (ERROR);
|
||||
if (haveAnswer) {
|
||||
/*
|
||||
* If we've already got 1 address, we aren't interested
|
||||
* in addresses with a different length or class.
|
||||
*/
|
||||
if (dlen != hostPtr->addrLen) {
|
||||
cp += dlen;
|
||||
continue;
|
||||
}
|
||||
if (class != origClass) {
|
||||
cp += dlen;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* First address: record its length and class so we
|
||||
* only save additonal ones with the same attributes.
|
||||
*/
|
||||
hostPtr->addrLen = dlen;
|
||||
origClass = class;
|
||||
hostPtr->addrType = (class == C_IN) ? AF_INET : AF_UNSPEC;
|
||||
len = strlen((char *)bp) + 1;
|
||||
hostPtr->name = Calloc(1, len);
|
||||
memcpy(hostPtr->name, bp, len);
|
||||
}
|
||||
bp += (((u_int32_t)bp) % sizeof(align));
|
||||
|
||||
if (bp + dlen >= &hostbuf[sizeof(hostbuf)]) {
|
||||
if (_res.options & RES_DEBUG) {
|
||||
printf("Size (%d) too big\n", dlen);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (numAddresses >= MAXADDRS) {
|
||||
printf("MAXADDRS exceeded: skipping address\n");
|
||||
cp += dlen;
|
||||
continue;
|
||||
}
|
||||
memcpy(*addrPtr++ = (char *)bp, cp, dlen);
|
||||
bp += dlen;
|
||||
cp += dlen;
|
||||
numAddresses++;
|
||||
haveAnswer = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((queryType == T_A || queryType == T_PTR) && haveAnswer) {
|
||||
|
||||
/*
|
||||
* Go through the alias and address lists and return them
|
||||
* in the hostPtr variable.
|
||||
*/
|
||||
|
||||
if (numAliases > 0) {
|
||||
hostPtr->aliases =
|
||||
(char **) Calloc(1 + numAliases, sizeof(char *));
|
||||
for (i = 0; i < numAliases; i++) {
|
||||
hostPtr->aliases[i] = Calloc(1, host_aliases_len[i]);
|
||||
memcpy(hostPtr->aliases[i], host_aliases[i],
|
||||
host_aliases_len[i]);
|
||||
}
|
||||
hostPtr->aliases[i] = NULL;
|
||||
}
|
||||
if (numAddresses > 0) {
|
||||
hostPtr->addrList =
|
||||
(char **)Calloc(1+numAddresses, sizeof(char *));
|
||||
for (i = 0; i < numAddresses; i++) {
|
||||
hostPtr->addrList[i] = Calloc(1, hostPtr->addrLen);
|
||||
memcpy(hostPtr->addrList[i], addr_list[i], hostPtr->addrLen);
|
||||
}
|
||||
hostPtr->addrList[i] = NULL;
|
||||
}
|
||||
#ifdef verbose
|
||||
if (headerPtr->aa || nscount == 0) {
|
||||
hostPtr->servers = NULL;
|
||||
return (SUCCESS);
|
||||
}
|
||||
#else
|
||||
hostPtr->servers = NULL;
|
||||
return (SUCCESS);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* At this point, for the T_A query type, only empty answers remain.
|
||||
* For other query types, additional information might be found
|
||||
* in the additional resource records part.
|
||||
*/
|
||||
|
||||
if (!headerPtr->aa && (queryType != T_A) && (nscount > 0 || arcount > 0)) {
|
||||
if (printedAnswers) {
|
||||
putchar('\n');
|
||||
}
|
||||
printf("Authoritative answers can be found from:\n");
|
||||
}
|
||||
|
||||
cp = (u_char *)res_skip((char *) &answer, 2, eom);
|
||||
|
||||
numServers = 0;
|
||||
if (queryType != T_A) {
|
||||
/*
|
||||
* If we don't need to save the record, just print it.
|
||||
*/
|
||||
while (--nscount >= 0 && cp < eom) {
|
||||
if ((cp = (u_char *)Print_rr(cp,
|
||||
(u_char *) &answer, eom, stdout)) == NULL) {
|
||||
return(ERROR);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while (--nscount >= 0 && cp < eom) {
|
||||
/*
|
||||
* Go through the NS records and retrieve the names of hosts
|
||||
* that serve the requested domain.
|
||||
*/
|
||||
|
||||
n = dn_expand(answer.qb2, eom, cp, (char *)bp, buflen);
|
||||
if (n < 0) {
|
||||
return(ERROR);
|
||||
}
|
||||
cp += n;
|
||||
len = strlen((char *)bp) + 1;
|
||||
dnamePtr = Calloc(1, len); /* domain name */
|
||||
memcpy(dnamePtr, bp, len);
|
||||
|
||||
if (cp + 3 * INT16SZ + INT32SZ > eom)
|
||||
return (ERROR);
|
||||
type = GetShort(cp);
|
||||
class = GetShort(cp);
|
||||
cp += INT32SZ; /* skip TTL */
|
||||
dlen = GetShort(cp);
|
||||
if (cp + dlen > eom)
|
||||
return (ERROR);
|
||||
|
||||
if (type != T_NS) {
|
||||
cp += dlen;
|
||||
} else {
|
||||
Boolean found;
|
||||
|
||||
n = dn_expand(answer.qb2, eom, cp, (char *)bp, buflen);
|
||||
if (n < 0) {
|
||||
return(ERROR);
|
||||
}
|
||||
cp += n;
|
||||
len = strlen((char *)bp) + 1;
|
||||
namePtr = Calloc(1, len); /* server host name */
|
||||
memcpy(namePtr, bp, len);
|
||||
|
||||
/*
|
||||
* Store the information keyed by the server host name.
|
||||
*/
|
||||
found = FALSE;
|
||||
for (j = 0; j < numServers; j++) {
|
||||
if (strcmp(namePtr, server[j].name) == 0) {
|
||||
found = TRUE;
|
||||
free(namePtr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
server[j].numDomains++;
|
||||
if (server[j].numDomains <= MAXDOMAINS) {
|
||||
server[j].domain[server[j].numDomains-1] = dnamePtr;
|
||||
}
|
||||
} else {
|
||||
if (numServers >= MAXSERVERS) {
|
||||
break;
|
||||
}
|
||||
server[numServers].name = namePtr;
|
||||
server[numServers].domain[0] = dnamePtr;
|
||||
server[numServers].numDomains = 1;
|
||||
server[numServers].numAddresses = 0;
|
||||
numServers++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Additional resource records contain addresses of servers.
|
||||
*/
|
||||
cp = (u_char *)res_skip((char *) &answer, 3, eom);
|
||||
|
||||
if (queryType != T_A) {
|
||||
/*
|
||||
* If we don't need to save the record, just print it.
|
||||
*/
|
||||
while (--arcount >= 0 && cp < eom) {
|
||||
if ((cp = (u_char *)Print_rr(cp,
|
||||
(u_char *) &answer, eom, stdout)) == NULL) {
|
||||
return(ERROR);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while (--arcount >= 0 && cp < eom) {
|
||||
n = dn_expand(answer.qb2, eom, cp, (char *)bp, buflen);
|
||||
if (n < 0) {
|
||||
break;
|
||||
}
|
||||
cp += n;
|
||||
if (cp + 3 * INT16SZ + INT32SZ > eom)
|
||||
return (ERROR);
|
||||
type = GetShort(cp);
|
||||
class = GetShort(cp);
|
||||
cp += INT32SZ; /* skip TTL */
|
||||
dlen = GetShort(cp);
|
||||
if (cp + dlen > eom)
|
||||
return (ERROR);
|
||||
|
||||
if (type != T_A) {
|
||||
cp += dlen;
|
||||
continue;
|
||||
} else {
|
||||
if (dlen != INADDRSZ)
|
||||
return (ERROR);
|
||||
for (j = 0; j < numServers; j++) {
|
||||
if (strcmp((char *)bp, server[j].name) == 0) {
|
||||
server[j].numAddresses++;
|
||||
if (server[j].numAddresses <= MAXADDRS) {
|
||||
server[j].address[server[j].numAddresses-1] =
|
||||
Calloc(1,dlen);
|
||||
memcpy(server[j].address[server[j].numAddresses-1],
|
||||
cp, dlen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
cp += dlen;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If we are returning name server info, transfer it to the hostPtr.
|
||||
*/
|
||||
if (numServers > 0) {
|
||||
hostPtr->servers = (ServerInfo **)
|
||||
Calloc(numServers+1, sizeof(ServerInfo *));
|
||||
|
||||
for (i = 0; i < numServers; i++) {
|
||||
hostPtr->servers[i] = (ServerInfo *) Calloc(1, sizeof(ServerInfo));
|
||||
hostPtr->servers[i]->name = server[i].name;
|
||||
|
||||
|
||||
hostPtr->servers[i]->domains = (char **)
|
||||
Calloc(server[i].numDomains+1,sizeof(char *));
|
||||
for (j = 0; j < server[i].numDomains; j++) {
|
||||
hostPtr->servers[i]->domains[j] = server[i].domain[j];
|
||||
}
|
||||
hostPtr->servers[i]->domains[j] = NULL;
|
||||
|
||||
|
||||
hostPtr->servers[i]->addrList = (char **)
|
||||
Calloc(server[i].numAddresses+1,sizeof(char *));
|
||||
for (j = 0; j < server[i].numAddresses; j++) {
|
||||
hostPtr->servers[i]->addrList[j] = server[i].address[j];
|
||||
}
|
||||
hostPtr->servers[i]->addrList[j] = NULL;
|
||||
|
||||
}
|
||||
hostPtr->servers[i] = NULL;
|
||||
}
|
||||
|
||||
switch (queryType) {
|
||||
case T_A:
|
||||
return NONAUTH;
|
||||
case T_PTR:
|
||||
if (iquery)
|
||||
return NO_INFO;
|
||||
/* fall through */
|
||||
default:
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* GetHostInfo --
|
||||
*
|
||||
* Retrieves host name, address and alias information
|
||||
* for a domain.
|
||||
*
|
||||
* Algorithm from res_search().
|
||||
*
|
||||
* Results:
|
||||
* ERROR - res_mkquery failed.
|
||||
* + return values from GetAnswer()
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
int
|
||||
GetHostInfoByName(nsAddrPtr, queryClass, queryType, name, hostPtr, isServer)
|
||||
struct in_addr *nsAddrPtr;
|
||||
int queryClass;
|
||||
int queryType;
|
||||
char *name;
|
||||
HostInfo *hostPtr;
|
||||
Boolean isServer;
|
||||
{
|
||||
int n;
|
||||
register int result;
|
||||
register char **domain;
|
||||
const char *cp;
|
||||
Boolean got_nodata = FALSE;
|
||||
struct in_addr ina;
|
||||
Boolean tried_as_is = FALSE;
|
||||
|
||||
/* Catch explicit addresses */
|
||||
if ((queryType == T_A) && IsAddr(name, &ina)) {
|
||||
hostPtr->name = Calloc(strlen(name)+3, 1);
|
||||
(void)sprintf(hostPtr->name,"[%s]",name);
|
||||
hostPtr->aliases = NULL;
|
||||
hostPtr->servers = NULL;
|
||||
hostPtr->addrType = AF_INET;
|
||||
hostPtr->addrLen = INADDRSZ;
|
||||
hostPtr->addrList = (char **)Calloc(2, sizeof(char *));
|
||||
hostPtr->addrList[0] = Calloc(INT32SZ, sizeof(char));
|
||||
memcpy(hostPtr->addrList[0], &ina, INADDRSZ);
|
||||
hostPtr->addrList[1] = NULL;
|
||||
return(SUCCESS);
|
||||
}
|
||||
|
||||
result = NXDOMAIN;
|
||||
for (cp = name, n = 0; *cp; cp++)
|
||||
if (*cp == '.')
|
||||
n++;
|
||||
if (n == 0 && (cp = hostalias(name))) {
|
||||
printf("Aliased to \"%s\"\n\n", cp);
|
||||
return (GetHostDomain(nsAddrPtr, queryClass, queryType,
|
||||
cp, (char *)NULL, hostPtr, isServer));
|
||||
}
|
||||
|
||||
/*
|
||||
* If there are dots in the name already, let's just give it a try
|
||||
* 'as is'. The threshold can be set with the "ndots" option.
|
||||
*/
|
||||
if (n >= (int)_res.ndots) {
|
||||
result = GetHostDomain(nsAddrPtr, queryClass, queryType,
|
||||
name, (char *)NULL, hostPtr, isServer);
|
||||
if (result == SUCCESS)
|
||||
return (result);
|
||||
if (result == NO_INFO)
|
||||
got_nodata++;
|
||||
tried_as_is++;
|
||||
}
|
||||
|
||||
/*
|
||||
* We do at least one level of search if
|
||||
* - there is no dot and RES_DEFNAME is set, or
|
||||
* - there is at least one dot, there is no trailing dot,
|
||||
* and RES_DNSRCH is set.
|
||||
*/
|
||||
if ((n == 0 && _res.options & RES_DEFNAMES) ||
|
||||
(n != 0 && *--cp != '.' && _res.options & RES_DNSRCH))
|
||||
for (domain = _res.dnsrch; *domain; domain++) {
|
||||
result = GetHostDomain(nsAddrPtr, queryClass, queryType,
|
||||
name, *domain, hostPtr, isServer);
|
||||
/*
|
||||
* If no server present, give up.
|
||||
* If name isn't found in this domain,
|
||||
* keep trying higher domains in the search list
|
||||
* (if that's enabled).
|
||||
* On a NO_INFO error, keep trying, otherwise
|
||||
* a wildcard entry of another type could keep us
|
||||
* from finding this entry higher in the domain.
|
||||
* If we get some other error (negative answer or
|
||||
* server failure), then stop searching up,
|
||||
* but try the input name below in case it's fully-qualified.
|
||||
*/
|
||||
if (result == SUCCESS || result == NO_RESPONSE)
|
||||
return result;
|
||||
if (result == NO_INFO)
|
||||
got_nodata++;
|
||||
if ((result != NXDOMAIN && result != NO_INFO) ||
|
||||
(_res.options & RES_DNSRCH) == 0)
|
||||
break;
|
||||
}
|
||||
/* if we have not already tried the name "as is", do that now.
|
||||
* note that we do this regardless of how many dots were in the
|
||||
* name or whether it ends with a dot.
|
||||
*/
|
||||
if (!tried_as_is &&
|
||||
(result = GetHostDomain(nsAddrPtr, queryClass, queryType,
|
||||
name, (char *)NULL, hostPtr, isServer)
|
||||
) == SUCCESS)
|
||||
return (result);
|
||||
if (got_nodata)
|
||||
result = NO_INFO;
|
||||
return (result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Perform a query on the concatenation of name and domain,
|
||||
* removing a trailing dot from name if domain is NULL.
|
||||
*/
|
||||
GetHostDomain(nsAddrPtr, queryClass, queryType, name, domain, hostPtr, isServer)
|
||||
struct in_addr *nsAddrPtr;
|
||||
int queryClass;
|
||||
int queryType;
|
||||
char *name, *domain;
|
||||
HostInfo *hostPtr;
|
||||
Boolean isServer;
|
||||
{
|
||||
querybuf buf;
|
||||
char nbuf[2*MAXDNAME+2];
|
||||
char *longname = nbuf;
|
||||
int n;
|
||||
|
||||
if (domain == NULL) {
|
||||
/*
|
||||
* Check for trailing '.';
|
||||
* copy without '.' if present.
|
||||
*/
|
||||
n = strlen(name) - 1;
|
||||
if (name[n] == '.' && n < sizeof(nbuf) - 1) {
|
||||
memcpy(nbuf, name, n);
|
||||
nbuf[n] = '\0';
|
||||
} else
|
||||
longname = name;
|
||||
} else {
|
||||
(void)sprintf(nbuf, "%.*s.%.*s",
|
||||
MAXDNAME, name, MAXDNAME, domain);
|
||||
longname = nbuf;
|
||||
}
|
||||
n = res_mkquery(QUERY, longname, queryClass, queryType,
|
||||
NULL, 0, 0, buf.qb2, sizeof(buf));
|
||||
if (n < 0) {
|
||||
if (_res.options & RES_DEBUG) {
|
||||
printf("Res_mkquery failed\n");
|
||||
}
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
n = GetAnswer(nsAddrPtr, queryType, (char *)&buf, n, 0, hostPtr, isServer);
|
||||
|
||||
/*
|
||||
* GetAnswer didn't find a name, so set it to the specified one.
|
||||
*/
|
||||
if (n == NONAUTH) {
|
||||
if (hostPtr->name == NULL) {
|
||||
int len = strlen(longname) + 1;
|
||||
hostPtr->name = Calloc(len, sizeof(char));
|
||||
memcpy(hostPtr->name, longname, len);
|
||||
}
|
||||
}
|
||||
return(n);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* GetHostInfoByAddr --
|
||||
*
|
||||
* Performs a PTR lookup in in-addr.arpa to find the host name
|
||||
* that corresponds to the given address.
|
||||
*
|
||||
* Results:
|
||||
* ERROR - res_mkquery failed.
|
||||
* + return values from GetAnswer()
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
int
|
||||
GetHostInfoByAddr(nsAddrPtr, address, hostPtr)
|
||||
struct in_addr *nsAddrPtr;
|
||||
struct in_addr *address;
|
||||
HostInfo *hostPtr;
|
||||
{
|
||||
int n;
|
||||
querybuf buf;
|
||||
char qbuf[MAXDNAME];
|
||||
char *p = (char *) &address->s_addr;
|
||||
|
||||
(void)sprintf(qbuf, "%u.%u.%u.%u.in-addr.arpa",
|
||||
((unsigned)p[3] & 0xff),
|
||||
((unsigned)p[2] & 0xff),
|
||||
((unsigned)p[1] & 0xff),
|
||||
((unsigned)p[0] & 0xff));
|
||||
n = res_mkquery(QUERY, qbuf, C_IN, T_PTR, NULL, 0, NULL,
|
||||
buf.qb2, sizeof buf);
|
||||
if (n < 0) {
|
||||
if (_res.options & RES_DEBUG) {
|
||||
printf("res_mkquery() failed\n");
|
||||
}
|
||||
return (ERROR);
|
||||
}
|
||||
n = GetAnswer(nsAddrPtr, T_PTR, (char *) &buf, n, 1, hostPtr, 1);
|
||||
if (n == SUCCESS) {
|
||||
hostPtr->addrType = AF_INET;
|
||||
hostPtr->addrLen = 4;
|
||||
hostPtr->addrList = (char **)Calloc(2, sizeof(char *));
|
||||
hostPtr->addrList[0] = Calloc(INT32SZ, sizeof(char));
|
||||
memcpy(hostPtr->addrList[0], p, INADDRSZ);
|
||||
hostPtr->addrList[1] = NULL;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* FreeHostInfoPtr --
|
||||
*
|
||||
* Deallocates all the calloc'd areas for a HostInfo variable.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
void
|
||||
FreeHostInfoPtr(hostPtr)
|
||||
register HostInfo *hostPtr;
|
||||
{
|
||||
int i, j;
|
||||
|
||||
if (hostPtr->name != NULL) {
|
||||
free(hostPtr->name);
|
||||
hostPtr->name = NULL;
|
||||
}
|
||||
|
||||
if (hostPtr->aliases != NULL) {
|
||||
i = 0;
|
||||
while (hostPtr->aliases[i] != NULL) {
|
||||
free(hostPtr->aliases[i]);
|
||||
i++;
|
||||
}
|
||||
free((char *)hostPtr->aliases);
|
||||
hostPtr->aliases = NULL;
|
||||
}
|
||||
|
||||
if (hostPtr->addrList != NULL) {
|
||||
i = 0;
|
||||
while (hostPtr->addrList[i] != NULL) {
|
||||
free(hostPtr->addrList[i]);
|
||||
i++;
|
||||
}
|
||||
free((char *)hostPtr->addrList);
|
||||
hostPtr->addrList = NULL;
|
||||
}
|
||||
|
||||
if (hostPtr->servers != NULL) {
|
||||
i = 0;
|
||||
while (hostPtr->servers[i] != NULL) {
|
||||
|
||||
if (hostPtr->servers[i]->name != NULL) {
|
||||
free(hostPtr->servers[i]->name);
|
||||
}
|
||||
|
||||
if (hostPtr->servers[i]->domains != NULL) {
|
||||
j = 0;
|
||||
while (hostPtr->servers[i]->domains[j] != NULL) {
|
||||
free(hostPtr->servers[i]->domains[j]);
|
||||
j++;
|
||||
}
|
||||
free((char *)hostPtr->servers[i]->domains);
|
||||
}
|
||||
|
||||
if (hostPtr->servers[i]->addrList != NULL) {
|
||||
j = 0;
|
||||
while (hostPtr->servers[i]->addrList[j] != NULL) {
|
||||
free(hostPtr->servers[i]->addrList[j]);
|
||||
j++;
|
||||
}
|
||||
free((char *)hostPtr->servers[i]->addrList);
|
||||
}
|
||||
free((char *)hostPtr->servers[i]);
|
||||
i++;
|
||||
}
|
||||
free((char *)hostPtr->servers);
|
||||
hostPtr->servers = NULL;
|
||||
}
|
||||
}
|
||||
622
contrib/bind/bin/nslookup/list.c
Normal file
622
contrib/bind/bin/nslookup/list.c
Normal file
|
|
@ -0,0 +1,622 @@
|
|||
/*
|
||||
* Copyright (c) 1985, 1989
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* 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, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION 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 lint
|
||||
static char sccsid[] = "@(#)list.c 5.23 (Berkeley) 3/21/91";
|
||||
static char rcsid[] = "$Id: list.c,v 8.13 1997/11/18 00:32:33 halley Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* list.c --
|
||||
*
|
||||
* Routines to obtain info from name and finger servers.
|
||||
*
|
||||
* Adapted from 4.3BSD BIND ns_init.c and from finger.c.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <netdb.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "res.h"
|
||||
|
||||
extern char *_res_resultcodes[]; /* res_debug.c */
|
||||
extern char *pager;
|
||||
|
||||
typedef union {
|
||||
HEADER qb1;
|
||||
u_char qb2[PACKETSZ];
|
||||
} querybuf;
|
||||
|
||||
extern HostInfo *defaultPtr;
|
||||
extern HostInfo curHostInfo;
|
||||
extern int curHostValid;
|
||||
extern int queryType;
|
||||
extern int queryClass;
|
||||
|
||||
static int sockFD = -1;
|
||||
int ListSubr();
|
||||
|
||||
/*
|
||||
* During a listing to a file, hash marks are printed
|
||||
* every HASH_SIZE records.
|
||||
*/
|
||||
|
||||
#define HASH_SIZE 50
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* ListHosts --
|
||||
* ListHostsByType --
|
||||
*
|
||||
* Requests the name server to do a zone transfer so we
|
||||
* find out what hosts it knows about.
|
||||
*
|
||||
* For ListHosts, there are five types of output:
|
||||
* - Internet addresses (default)
|
||||
* - cpu type and operating system (-h option)
|
||||
* - canonical and alias names (-a option)
|
||||
* - well-known service names (-s option)
|
||||
* - ALL records (-d option)
|
||||
* ListHostsByType prints records of the default type or of a speicific
|
||||
* type.
|
||||
*
|
||||
* To see all types of information sorted by name, do the following:
|
||||
* ls -d domain.edu > file
|
||||
* view file
|
||||
*
|
||||
* Results:
|
||||
* SUCCESS the listing was successful.
|
||||
* ERROR the server could not be contacted because
|
||||
* a socket could not be obtained or an error
|
||||
* occured while receiving, or the output file
|
||||
* could not be opened.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
void
|
||||
ListHostsByType(char *string, int putToFile) {
|
||||
char *namePtr, name[NAME_LEN], option[NAME_LEN];
|
||||
int i, qtype, result;
|
||||
|
||||
/*
|
||||
* Parse the command line. It maybe of the form "ls -t domain"
|
||||
* or "ls -t type domain".
|
||||
*/
|
||||
|
||||
i = sscanf(string, " ls -t %s %s", option, name);
|
||||
if (putToFile && i == 2 && name[0] == '>')
|
||||
i--;
|
||||
if (i == 2) {
|
||||
qtype = StringToType(option, -1, stderr);
|
||||
if (qtype == -1)
|
||||
return;
|
||||
namePtr = name;
|
||||
} else if (i == 1) {
|
||||
namePtr = option;
|
||||
qtype = queryType;
|
||||
} else {
|
||||
fprintf(stderr, "*** ls: invalid request %s\n", string);
|
||||
return;
|
||||
}
|
||||
result = ListSubr(qtype, namePtr, putToFile ? string : NULL);
|
||||
if (result != SUCCESS)
|
||||
fprintf(stderr, "*** Can't list domain %s: %s\n",
|
||||
namePtr, DecodeError(result));
|
||||
}
|
||||
|
||||
void
|
||||
ListHosts(char *string, int putToFile) {
|
||||
char *namePtr, name[NAME_LEN], option[NAME_LEN];
|
||||
int i, qtype, result;
|
||||
|
||||
/*
|
||||
* Parse the command line. It maybe of the form "ls domain",
|
||||
* "ls -X domain".
|
||||
*/
|
||||
i = sscanf(string, " ls %s %s", option, name);
|
||||
if (putToFile && i == 2 && name[0] == '>')
|
||||
i--;
|
||||
if (i == 2) {
|
||||
if (strcmp("-a", option) == 0)
|
||||
qtype = T_CNAME;
|
||||
else if (strcmp("-h", option) == 0)
|
||||
qtype = T_HINFO;
|
||||
else if (strcmp("-m", option) == 0)
|
||||
qtype = T_MX;
|
||||
else if (strcmp("-p", option) == 0)
|
||||
qtype = T_PX;
|
||||
else if (strcmp("-s", option) == 0)
|
||||
qtype = T_WKS;
|
||||
else if (strcmp("-d", option) == 0)
|
||||
qtype = T_ANY;
|
||||
else if (strcmp("-n", option) == 0)
|
||||
qtype = T_NAPTR;
|
||||
else
|
||||
qtype = T_A;
|
||||
namePtr = name;
|
||||
} else if (i == 1) {
|
||||
namePtr = option;
|
||||
qtype = T_A;
|
||||
} else {
|
||||
fprintf(stderr, "*** ls: invalid request %s\n",string);
|
||||
return;
|
||||
}
|
||||
result = ListSubr(qtype, namePtr, putToFile ? string : NULL);
|
||||
if (result != SUCCESS)
|
||||
fprintf(stderr, "*** Can't list domain %s: %s\n",
|
||||
namePtr, DecodeError(result));
|
||||
}
|
||||
|
||||
int
|
||||
ListSubr(int qtype, char *domain, char *cmd) {
|
||||
static u_char *answer = NULL;
|
||||
static int answerLen = 0;
|
||||
|
||||
ns_msg handle;
|
||||
querybuf buf;
|
||||
struct sockaddr_in sin;
|
||||
HEADER *headerPtr;
|
||||
int msglen, amtToRead, numRead, n, count, soacnt;
|
||||
u_int len;
|
||||
int numAnswers = 0;
|
||||
int numRecords = 0;
|
||||
u_char tmp[INT16SZ], *cp;
|
||||
char soaname[2][NAME_LEN], file[NAME_LEN];
|
||||
enum { NO_ERRORS, ERR_READING_LEN, ERR_READING_MSG, ERR_PRINTING }
|
||||
error = NO_ERRORS;
|
||||
|
||||
/*
|
||||
* Create a query packet for the requested domain name.
|
||||
*/
|
||||
msglen = res_mkquery(QUERY, domain, queryClass, T_AXFR,
|
||||
NULL, 0, 0, buf.qb2, sizeof buf);
|
||||
if (msglen < 0) {
|
||||
if (_res.options & RES_DEBUG)
|
||||
fprintf(stderr, "*** ls: res_mkquery failed\n");
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
memset(&sin, 0, sizeof sin);
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(nsport);
|
||||
|
||||
/*
|
||||
* Check to see if we have the address of the server or the
|
||||
* address of a server who knows about this domain.
|
||||
*
|
||||
* For now, just use the first address in the list. XXX.
|
||||
*/
|
||||
|
||||
if (defaultPtr->addrList != NULL)
|
||||
sin.sin_addr = *(struct in_addr *) defaultPtr->addrList[0];
|
||||
else
|
||||
sin.sin_addr = *(struct in_addr *)
|
||||
defaultPtr->servers[0]->addrList[0];
|
||||
|
||||
/*
|
||||
* Set up a virtual circuit to the server.
|
||||
*/
|
||||
sockFD = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (sockFD < 0) {
|
||||
perror("ls: socket");
|
||||
return (ERROR);
|
||||
}
|
||||
if (connect(sockFD, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
|
||||
int e;
|
||||
|
||||
if (errno == ECONNREFUSED)
|
||||
e = NO_RESPONSE;
|
||||
else {
|
||||
perror("ls: connect");
|
||||
e = ERROR;
|
||||
}
|
||||
(void) close(sockFD);
|
||||
sockFD = -1;
|
||||
return (e);
|
||||
}
|
||||
|
||||
/*
|
||||
* Send length & message for zone transfer
|
||||
*/
|
||||
ns_put16(msglen, tmp);
|
||||
if (write(sockFD, (char *)tmp, INT16SZ) != INT16SZ ||
|
||||
write(sockFD, (char *)buf.qb2, msglen) != msglen) {
|
||||
perror("ls: write");
|
||||
(void) close(sockFD);
|
||||
sockFD = -1;
|
||||
return(ERROR);
|
||||
}
|
||||
|
||||
fprintf(stdout,"[%s]\n", (defaultPtr->addrList != NULL)
|
||||
? defaultPtr->name : defaultPtr->servers[0]->name);
|
||||
|
||||
if (cmd == NULL) {
|
||||
filePtr = stdout;
|
||||
} else {
|
||||
filePtr = OpenFile(cmd, file);
|
||||
if (filePtr == NULL) {
|
||||
fprintf(stderr, "*** Can't open %s for writing\n",
|
||||
file);
|
||||
(void) close(sockFD);
|
||||
sockFD = -1;
|
||||
return (ERROR);
|
||||
}
|
||||
fprintf(filePtr, "> %s\n", cmd);
|
||||
fprintf(filePtr, "[%s]\n", (defaultPtr->addrList != NULL)
|
||||
? defaultPtr->name : defaultPtr->servers[0]->name);
|
||||
}
|
||||
|
||||
soacnt = 0;
|
||||
while (soacnt < 2) {
|
||||
/*
|
||||
* Read the length of the response.
|
||||
*/
|
||||
|
||||
cp = tmp; amtToRead = INT16SZ;
|
||||
while (amtToRead > 0 &&
|
||||
(numRead = read(sockFD, cp, amtToRead)) > 0) {
|
||||
cp += numRead;
|
||||
amtToRead -= numRead;
|
||||
}
|
||||
if (numRead <= 0) {
|
||||
error = ERR_READING_LEN;
|
||||
break;
|
||||
}
|
||||
|
||||
len = ns_get16(tmp);
|
||||
if (len == 0)
|
||||
break; /* nothing left to read */
|
||||
|
||||
/*
|
||||
* If the server sent too much data to fit the existing
|
||||
* buffer, allocate a new one.
|
||||
*/
|
||||
if (len > (u_int)answerLen) {
|
||||
if (answerLen != 0)
|
||||
free(answer);
|
||||
answerLen = len;
|
||||
answer = (u_char *)Malloc(answerLen);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the response.
|
||||
*/
|
||||
amtToRead = len; cp = answer;
|
||||
while (amtToRead > 0 &&
|
||||
(numRead = read(sockFD, cp, amtToRead)) > 0) {
|
||||
cp += numRead;
|
||||
amtToRead -= numRead;
|
||||
}
|
||||
if (numRead <= 0) {
|
||||
error = ERR_READING_MSG;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ns_initparse(answer, cp - answer, &handle) < 0) {
|
||||
perror("ns_initparse");
|
||||
error = ERR_PRINTING;
|
||||
break;
|
||||
}
|
||||
if (ns_msg_getflag(handle, ns_f_rcode) != ns_r_noerror ||
|
||||
ns_msg_count(handle, ns_s_an) == 0) {
|
||||
/* Signalled protocol error, or empty message. */
|
||||
error = ERR_PRINTING;
|
||||
break;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
static char origin[NS_MAXDNAME], name_ctx[NS_MAXDNAME];
|
||||
const char *name;
|
||||
char buf[2048]; /* XXX need to malloc/realloc. */
|
||||
ns_rr rr;
|
||||
|
||||
if (ns_parserr(&handle, ns_s_an, -1, &rr)) {
|
||||
if (errno != ENODEV) {
|
||||
perror("ns_parserr");
|
||||
error = ERR_PRINTING;
|
||||
}
|
||||
break;
|
||||
}
|
||||
name = ns_rr_name(rr);
|
||||
if (origin[0] == '\0' && name[0] != '\0') {
|
||||
fprintf(filePtr, "$ORIGIN %s.\n", name);
|
||||
strcpy(origin, name);
|
||||
}
|
||||
if (qtype == T_ANY || ns_rr_type(rr) == qtype) {
|
||||
if (ns_sprintrr(&handle, &rr, name_ctx, origin,
|
||||
buf, sizeof buf) < 0) {
|
||||
perror("ns_sprintrr");
|
||||
error = ERR_PRINTING;
|
||||
break;
|
||||
}
|
||||
strcpy(name_ctx, name);
|
||||
numAnswers++;
|
||||
fputs(buf, filePtr);
|
||||
fputc('\n', filePtr);
|
||||
}
|
||||
if (ns_rr_type(rr) == T_SOA) {
|
||||
strcpy(soaname[soacnt], name);
|
||||
if (soacnt == 0)
|
||||
soacnt = 1;
|
||||
else if (strcasecmp(soaname[0],
|
||||
soaname[1]) == 0) {
|
||||
soacnt = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (error != NO_ERRORS)
|
||||
break;
|
||||
numAnswers++;
|
||||
if (cmd != NULL && ((numAnswers % HASH_SIZE) == 0)) {
|
||||
fprintf(stdout, "#");
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd != NULL)
|
||||
fprintf(stdout, "%sReceived %d answer%s (%d record%s).\n",
|
||||
(numAnswers >= HASH_SIZE) ? "\n" : "",
|
||||
numAnswers, (numAnswers != 1) ? "s" : "",
|
||||
numRecords, (numRecords != 1) ? "s" : "");
|
||||
|
||||
(void) close(sockFD);
|
||||
sockFD = -1;
|
||||
if (cmd != NULL && filePtr != NULL) {
|
||||
fclose(filePtr);
|
||||
filePtr = NULL;
|
||||
}
|
||||
|
||||
switch (error) {
|
||||
case NO_ERRORS:
|
||||
return (SUCCESS);
|
||||
|
||||
case ERR_READING_LEN:
|
||||
return (ERROR);
|
||||
|
||||
case ERR_PRINTING:
|
||||
return (ERROR);
|
||||
|
||||
case ERR_READING_MSG:
|
||||
headerPtr = (HEADER *) answer;
|
||||
fprintf(stderr,"*** ls: error receiving zone transfer:\n");
|
||||
fprintf(stderr,
|
||||
" result: %s, answers = %d, authority = %d, additional = %d\n",
|
||||
_res_resultcodes[headerPtr->rcode],
|
||||
ntohs(headerPtr->ancount), ntohs(headerPtr->nscount),
|
||||
ntohs(headerPtr->arcount));
|
||||
return (ERROR);
|
||||
default:
|
||||
return (ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* ViewList --
|
||||
*
|
||||
* A hack to view the output of the ls command in sorted
|
||||
* order using more.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
ViewList(string)
|
||||
char *string;
|
||||
{
|
||||
char file[PATH_MAX];
|
||||
char command[PATH_MAX];
|
||||
|
||||
sscanf(string, " view %s", file);
|
||||
(void)sprintf(command, "grep \"^ \" %s | sort | %s", file, pager);
|
||||
system(command);
|
||||
}
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* Finger --
|
||||
*
|
||||
* Connects with the finger server for the current host
|
||||
* to request info on the specified person (long form)
|
||||
* who is on the system (short form).
|
||||
*
|
||||
* Results:
|
||||
* SUCCESS the finger server was contacted.
|
||||
* ERROR the server could not be contacted because
|
||||
* a socket could not be obtained or connected
|
||||
* to or the service could not be found.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
Finger(string, putToFile)
|
||||
char *string;
|
||||
int putToFile;
|
||||
{
|
||||
struct servent *sp;
|
||||
struct sockaddr_in sin;
|
||||
FILE *f;
|
||||
int c;
|
||||
int lastc;
|
||||
char name[NAME_LEN];
|
||||
char file[NAME_LEN];
|
||||
|
||||
/*
|
||||
* We need a valid current host info to get an inet address.
|
||||
*/
|
||||
if (!curHostValid) {
|
||||
fprintf(stderr, "Finger: no current host defined.\n");
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
if (sscanf(string, " finger %s", name) == 1) {
|
||||
if (putToFile && (name[0] == '>')) {
|
||||
name[0] = '\0';
|
||||
}
|
||||
} else {
|
||||
name[0] = '\0';
|
||||
}
|
||||
|
||||
sp = getservbyname("finger", "tcp");
|
||||
if (sp == 0) {
|
||||
fprintf(stderr, "Finger: unknown service\n");
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
memset(&sin, 0, sizeof sin);
|
||||
sin.sin_family = curHostInfo.addrType;
|
||||
sin.sin_port = sp->s_port;
|
||||
memcpy(&sin.sin_addr, curHostInfo.addrList[0], curHostInfo.addrLen);
|
||||
|
||||
/*
|
||||
* Set up a virtual circuit to the host.
|
||||
*/
|
||||
|
||||
sockFD = socket(curHostInfo.addrType, SOCK_STREAM, 0);
|
||||
if (sockFD < 0) {
|
||||
fflush(stdout);
|
||||
perror("finger: socket");
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
if (connect(sockFD, (struct sockaddr *)&sin, sizeof (sin)) < 0) {
|
||||
fflush(stdout);
|
||||
perror("finger: connect");
|
||||
close(sockFD);
|
||||
sockFD = -1;
|
||||
return (ERROR);
|
||||
}
|
||||
|
||||
if (!putToFile) {
|
||||
filePtr = stdout;
|
||||
} else {
|
||||
filePtr = OpenFile(string, file);
|
||||
if (filePtr == NULL) {
|
||||
fprintf(stderr, "*** Can't open %s for writing\n", file);
|
||||
close(sockFD);
|
||||
sockFD = -1;
|
||||
return(ERROR);
|
||||
}
|
||||
fprintf(filePtr,"> %s\n", string);
|
||||
}
|
||||
fprintf(filePtr, "[%s]\n", curHostInfo.name);
|
||||
|
||||
if (name[0] != '\0') {
|
||||
write(sockFD, "/W ", 3);
|
||||
}
|
||||
write(sockFD, name, strlen(name));
|
||||
write(sockFD, "\r\n", 2);
|
||||
f = fdopen(sockFD, "r");
|
||||
lastc = '\n';
|
||||
while ((c = getc(f)) != EOF) {
|
||||
switch (c) {
|
||||
case 0210:
|
||||
case 0211:
|
||||
case 0212:
|
||||
case 0214:
|
||||
c -= 0200;
|
||||
break;
|
||||
case 0215:
|
||||
c = '\n';
|
||||
break;
|
||||
}
|
||||
putc(lastc = c, filePtr);
|
||||
}
|
||||
if (lastc != '\n') {
|
||||
putc('\n', filePtr);
|
||||
}
|
||||
putc('\n', filePtr);
|
||||
|
||||
close(sockFD);
|
||||
sockFD = -1;
|
||||
|
||||
if (putToFile) {
|
||||
fclose(filePtr);
|
||||
filePtr = NULL;
|
||||
}
|
||||
return (SUCCESS);
|
||||
}
|
||||
|
||||
ListHost_close()
|
||||
{
|
||||
if (sockFD != -1) {
|
||||
(void) close(sockFD);
|
||||
sockFD = -1;
|
||||
}
|
||||
}
|
||||
1125
contrib/bind/bin/nslookup/main.c
Normal file
1125
contrib/bind/bin/nslookup/main.c
Normal file
File diff suppressed because it is too large
Load diff
34
contrib/bind/bin/nslookup/nslookup.help
Normal file
34
contrib/bind/bin/nslookup/nslookup.help
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
$Id: nslookup.help,v 8.4 1996/10/25 18:09:41 vixie Exp $
|
||||
|
||||
Commands: (identifiers are shown in uppercase, [] means optional)
|
||||
NAME - print info about the host/domain NAME using default server
|
||||
NAME1 NAME2 - as above, but use NAME2 as server
|
||||
help or ? - print info on common commands; see nslookup(1) for details
|
||||
set OPTION - set an option
|
||||
all - print options, current server and host
|
||||
[no]debug - print debugging information
|
||||
[no]d2 - print exhaustive debugging information
|
||||
[no]defname - append domain name to each query
|
||||
[no]recurse - ask for recursive answer to query
|
||||
[no]vc - always use a virtual circuit
|
||||
domain=NAME - set default domain name to NAME
|
||||
srchlist=N1[/N2/.../N6] - set domain to N1 and search list to N1,N2, etc.
|
||||
root=NAME - set root server to NAME
|
||||
retry=X - set number of retries to X
|
||||
timeout=X - set initial time-out interval to X seconds
|
||||
querytype=X - set query type, e.g., A,ANY,CNAME,HINFO,MX,PX,NS,PTR,SOA,TXT,WKS,SRV,NAPTR
|
||||
port=X - set port number to send query on
|
||||
type=X - synonym for querytype
|
||||
class=X - set query class to one of IN (Internet), CHAOS, HESIOD or ANY
|
||||
server NAME - set default server to NAME, using current default server
|
||||
lserver NAME - set default server to NAME, using initial server
|
||||
finger [USER] - finger the optional USER at the current default host
|
||||
root - set current default server to the root
|
||||
ls [opt] DOMAIN [> FILE] - list addresses in DOMAIN (optional: output to FILE)
|
||||
-a - list canonical names and aliases
|
||||
-h - list HINFO (CPU type and operating system)
|
||||
-s - list well-known services
|
||||
-d - list all records
|
||||
-t TYPE - list records of the given type (e.g., A,CNAME,MX, etc.)
|
||||
view FILE - sort an 'ls' output file and view it with more
|
||||
exit - exit the program, ^D also exits
|
||||
71
contrib/bind/bin/nslookup/pathnames.h
Normal file
71
contrib/bind/bin/nslookup/pathnames.h
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* ++Copyright++ 1990
|
||||
* -
|
||||
* Copyright (c) 1990
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
* -
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* 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, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION 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--
|
||||
*/
|
||||
|
||||
/*
|
||||
* @(#)pathnames.h 5.1 (Berkeley) 5/28/90
|
||||
* $Id: pathnames.h,v 8.1 1994/12/15 06:24:31 vixie Exp $
|
||||
*/
|
||||
|
||||
#define _PATH_NSLOOKUPRC "/.nslookuprc"
|
||||
#define _PATH_PAGERCMD "more"
|
||||
|
||||
#ifndef _PATH_HELPFILE
|
||||
#if defined(BSD) && BSD >= 198810
|
||||
#define _PATH_HELPFILE "/usr/share/misc/nslookup.help"
|
||||
#else
|
||||
#define _PATH_HELPFILE "/usr/lib/nslookup.help"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
183
contrib/bind/bin/nslookup/res.h
Normal file
183
contrib/bind/bin/nslookup/res.h
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
/*
|
||||
* ++Copyright++ 1985, 1989
|
||||
* -
|
||||
* Copyright (c) 1985, 1989
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
* -
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* 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, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION 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--
|
||||
*/
|
||||
|
||||
/*
|
||||
* @(#)res.h 5.10 (Berkeley) 6/1/90
|
||||
* $Id: res.h,v 8.4 1996/12/04 09:38:59 vixie Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* res.h --
|
||||
*
|
||||
* Definitions used by modules of the name server lookup program.
|
||||
*
|
||||
* Copyright (c) 1985
|
||||
* Andrew Cherenson
|
||||
* U.C. Berkeley
|
||||
* CS298-26 Fall 1985
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
typedef int Boolean;
|
||||
|
||||
#define MAXALIASES 35
|
||||
#define MAXADDRS 35
|
||||
#define MAXDOMAINS 35
|
||||
#define MAXSERVERS 10
|
||||
|
||||
/*
|
||||
* Define return statuses in addtion to the ones defined in namserv.h
|
||||
* let SUCCESS be a synonym for NOERROR
|
||||
*
|
||||
* TIME_OUT - a socket connection timed out.
|
||||
* NO_INFO - the server didn't find any info about the host.
|
||||
* ERROR - one of the following types of errors:
|
||||
* dn_expand, res_mkquery failed
|
||||
* bad command line, socket operation failed, etc.
|
||||
* NONAUTH - the server didn't have the desired info but
|
||||
* returned the name(s) of some servers who should.
|
||||
* NO_RESPONSE - the server didn't respond.
|
||||
*
|
||||
*/
|
||||
|
||||
#define SUCCESS 0
|
||||
#define TIME_OUT -1
|
||||
#define NO_INFO -2
|
||||
#define ERROR -3
|
||||
#define NONAUTH -4
|
||||
#define NO_RESPONSE -5
|
||||
|
||||
/*
|
||||
* Define additional options for the resolver state structure.
|
||||
*
|
||||
* RES_DEBUG2 more verbose debug level
|
||||
*/
|
||||
|
||||
#define RES_DEBUG2 0x80000000
|
||||
|
||||
/*
|
||||
* Maximum length of server, host and file names.
|
||||
*/
|
||||
|
||||
#define NAME_LEN 256
|
||||
|
||||
|
||||
/*
|
||||
* Modified struct hostent from <netdb.h>
|
||||
*
|
||||
* "Structures returned by network data base library. All addresses
|
||||
* are supplied in host order, and returned in network order (suitable
|
||||
* for use in system calls)."
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
char *name; /* official name of host */
|
||||
char **domains; /* domains it serves */
|
||||
char **addrList; /* list of addresses from name server */
|
||||
} ServerInfo;
|
||||
|
||||
typedef struct {
|
||||
char *name; /* official name of host */
|
||||
char **aliases; /* alias list */
|
||||
char **addrList; /* list of addresses from name server */
|
||||
int addrType; /* host address type */
|
||||
int addrLen; /* length of address */
|
||||
ServerInfo **servers;
|
||||
} HostInfo;
|
||||
|
||||
|
||||
/*
|
||||
* FilePtr is used for directing listings to a file.
|
||||
* It is global so the Control-C handler can close it.
|
||||
*/
|
||||
|
||||
extern FILE *filePtr;
|
||||
|
||||
/*
|
||||
* TCP/UDP port of server.
|
||||
*/
|
||||
extern unsigned short nsport;
|
||||
|
||||
/*
|
||||
* External routines:
|
||||
*/
|
||||
|
||||
/* XXX need prototypes */
|
||||
extern Boolean IsAddr();
|
||||
void Print_query(const u_char *msg, const u_char *eom, int printHeader);
|
||||
void Fprint_query(const u_char *msg, const u_char *eom, int printHeader,
|
||||
FILE *file);
|
||||
const u_char *Print_cdname(const u_char *cp, const u_char *msg,
|
||||
const u_char *eom, FILE *file);
|
||||
const u_char *Print_cdname2(const u_char *cp, const u_char *msg,
|
||||
const u_char *eom, FILE *file);
|
||||
const u_char *Print_rr(const u_char *ocp, const u_char *msg,
|
||||
const u_char *eom, FILE *file);
|
||||
extern const char *DecodeType(); /* descriptive version of p_type */
|
||||
extern const char *DecodeError();
|
||||
extern char *Calloc();
|
||||
extern char *Malloc();
|
||||
extern void NsError();
|
||||
extern void PrintServer();
|
||||
extern void PrintHostInfo();
|
||||
extern void ShowOptions();
|
||||
extern void FreeHostInfoPtr();
|
||||
extern FILE *OpenFile();
|
||||
extern char *res_skip();
|
||||
414
contrib/bind/bin/nslookup/send.c
Normal file
414
contrib/bind/bin/nslookup/send.c
Normal file
|
|
@ -0,0 +1,414 @@
|
|||
/*
|
||||
* Copyright (c) 1985, 1989
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* 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, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION 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 lint
|
||||
static char sccsid[] = "@(#)send.c 5.18 (Berkeley) 3/2/91";
|
||||
static char rcsid[] = "$Id: send.c,v 8.6 1997/05/21 19:49:58 halley Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* send.c --
|
||||
*
|
||||
* Routine to send request packets to a name server.
|
||||
*
|
||||
* Based on "@(#)res_send.c 6.25 (Berkeley) 6/1/90".
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Send query to name server and wait for reply.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "res.h"
|
||||
|
||||
static int s = -1; /* socket used for communications */
|
||||
|
||||
|
||||
#ifndef FD_SET
|
||||
#define NFDBITS 32
|
||||
#define FD_SETSIZE 32
|
||||
#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
|
||||
#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
|
||||
#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
|
||||
#define FD_ZERO(p) memset((p), 0, sizeof(*(p)))
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
unsigned short nsport = NAMESERVER_PORT;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
******************************************************************************
|
||||
*
|
||||
* SendRequest --
|
||||
*
|
||||
* Sends a request packet to a name server whose address
|
||||
* is specified by the first argument and returns with
|
||||
* the answer packet.
|
||||
*
|
||||
* Results:
|
||||
* SUCCESS - the request was sent and an answer
|
||||
* was received.
|
||||
* TIME_OUT - the virtual circuit connection timed-out
|
||||
* or a reply to a datagram wasn't received.
|
||||
*
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
int
|
||||
SendRequest(struct in_addr *nsAddrPtr, const u_char *buf, int buflen,
|
||||
u_char *answer, u_int anslen, int *trueLenPtr)
|
||||
{
|
||||
int n, try, v_circuit, resplen, salen;
|
||||
int gotsomewhere = 0, connected = 0;
|
||||
int connreset = 0;
|
||||
u_short id, len;
|
||||
u_char *cp;
|
||||
fd_set dsmask;
|
||||
struct timeval timeout;
|
||||
const HEADER *hp = (HEADER *) buf;
|
||||
HEADER *anhp = (HEADER *) answer;
|
||||
struct iovec iov[2];
|
||||
int terrno = ETIMEDOUT;
|
||||
char junk[512];
|
||||
struct sockaddr_in sin, sa;
|
||||
|
||||
if (_res.options & RES_DEBUG2) {
|
||||
printf("------------\nSendRequest(), len %d\n", buflen);
|
||||
Print_query(buf, buf + buflen, 1);
|
||||
}
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(nsport);
|
||||
sin.sin_addr = *nsAddrPtr;
|
||||
v_circuit = (_res.options & RES_USEVC) || buflen > PACKETSZ;
|
||||
id = hp->id;
|
||||
/*
|
||||
* Send request, RETRY times, or until successful
|
||||
*/
|
||||
for (try = 0; try < _res.retry; try++) {
|
||||
usevc:
|
||||
if (v_circuit) {
|
||||
int truncated = 0;
|
||||
|
||||
/*
|
||||
* Use virtual circuit;
|
||||
* at most one attempt per server.
|
||||
*/
|
||||
try = _res.retry;
|
||||
if (s < 0) {
|
||||
s = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (s < 0) {
|
||||
terrno = errno;
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("socket (vc) failed");
|
||||
continue;
|
||||
}
|
||||
if (connect(s, (struct sockaddr *)&sin,
|
||||
sizeof(struct sockaddr)) < 0) {
|
||||
terrno = errno;
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("connect failed");
|
||||
(void) close(s);
|
||||
s = -1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Send length & message
|
||||
*/
|
||||
__putshort(buflen, (u_char *)&len);
|
||||
iov[0].iov_base = (caddr_t)&len;
|
||||
iov[0].iov_len = INT16SZ;
|
||||
iov[1].iov_base = (caddr_t)buf;
|
||||
iov[1].iov_len = buflen;
|
||||
if (writev(s, iov, 2) != INT16SZ + buflen) {
|
||||
terrno = errno;
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("write failed");
|
||||
(void) close(s);
|
||||
s = -1;
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* Receive length & response
|
||||
*/
|
||||
cp = answer;
|
||||
len = INT16SZ;
|
||||
while ((n = read(s, (char *)cp, (int)len)) > 0) {
|
||||
cp += n;
|
||||
if ((len -= n) <= 0)
|
||||
break;
|
||||
}
|
||||
if (n <= 0) {
|
||||
terrno = errno;
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("read failed");
|
||||
(void) close(s);
|
||||
s = -1;
|
||||
/*
|
||||
* A long running process might get its TCP
|
||||
* connection reset if the remote server was
|
||||
* restarted. Requery the server instead of
|
||||
* trying a new one. When there is only one
|
||||
* server, this means that a query might work
|
||||
* instead of failing. We only allow one reset
|
||||
* per query to prevent looping.
|
||||
*/
|
||||
if (terrno == ECONNRESET && !connreset) {
|
||||
connreset = 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
cp = answer;
|
||||
if ((resplen = ns_get16((u_char*)cp)) > anslen) {
|
||||
if (_res.options & RES_DEBUG)
|
||||
fprintf(stderr, "response truncated\n");
|
||||
len = anslen;
|
||||
truncated = 1;
|
||||
} else
|
||||
len = resplen;
|
||||
while (len != 0 &&
|
||||
(n = read(s, (char *)cp, (int)len)) > 0) {
|
||||
cp += n;
|
||||
len -= n;
|
||||
}
|
||||
if (n <= 0) {
|
||||
terrno = errno;
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("read failed");
|
||||
(void) close(s);
|
||||
s = -1;
|
||||
continue;
|
||||
}
|
||||
if (truncated) {
|
||||
/*
|
||||
* Flush rest of answer
|
||||
* so connection stays in synch.
|
||||
*/
|
||||
anhp->tc = 1;
|
||||
len = resplen - anslen;
|
||||
while (len != 0) {
|
||||
n = (len > sizeof(junk) ?
|
||||
sizeof(junk) : len);
|
||||
if ((n = read(s, junk, n)) > 0)
|
||||
len -= n;
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Use datagrams.
|
||||
*/
|
||||
if (s < 0) {
|
||||
s = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (s < 0) {
|
||||
terrno = errno;
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("socket (dg) failed");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#if BSD >= 43
|
||||
if (connected == 0) {
|
||||
if (connect(s, (struct sockaddr *)&sin,
|
||||
sizeof sin) < 0) {
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("connect");
|
||||
continue;
|
||||
}
|
||||
connected = 1;
|
||||
}
|
||||
if (send(s, buf, buflen, 0) != buflen) {
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("send");
|
||||
continue;
|
||||
}
|
||||
#else /* BSD */
|
||||
if (sendto(s, (const char *)buf, buflen, 0,
|
||||
(struct sockaddr *) &sin,
|
||||
sizeof sin) != buflen) {
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("sendto");
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Wait for reply
|
||||
*/
|
||||
timeout.tv_sec = (_res.retrans << try);
|
||||
if (timeout.tv_sec <= 0)
|
||||
timeout.tv_sec = 1;
|
||||
timeout.tv_usec = 0;
|
||||
wait:
|
||||
FD_ZERO(&dsmask);
|
||||
FD_SET(s, &dsmask);
|
||||
n = select(s+1, &dsmask, (fd_set *)NULL,
|
||||
(fd_set *)NULL, &timeout);
|
||||
if (n < 0) {
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("select");
|
||||
continue;
|
||||
}
|
||||
if (n == 0) {
|
||||
/*
|
||||
* timeout
|
||||
*/
|
||||
if (_res.options & RES_DEBUG)
|
||||
printf("timeout\n");
|
||||
#if BSD >= 43
|
||||
gotsomewhere = 1;
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
salen = sizeof sa;
|
||||
resplen = recvfrom(s, (char *)answer, anslen, 0,
|
||||
(struct sockaddr *)&sa, &salen);
|
||||
if (resplen <= 0) {
|
||||
if (_res.options & RES_DEBUG)
|
||||
perror("recvfrom");
|
||||
continue;
|
||||
}
|
||||
gotsomewhere = 1;
|
||||
if (id != anhp->id) {
|
||||
/*
|
||||
* response from old query, ignore it
|
||||
*/
|
||||
if (_res.options & RES_DEBUG2) {
|
||||
printf("------------\nOld answer:\n");
|
||||
Print_query(answer, answer+resplen, 1);
|
||||
}
|
||||
goto wait;
|
||||
}
|
||||
if (!(_res.options & RES_IGNTC) && anhp->tc) {
|
||||
/*
|
||||
* get rest of answer;
|
||||
* use TCP with same server.
|
||||
*/
|
||||
if (_res.options & RES_DEBUG)
|
||||
printf("truncated answer\n");
|
||||
(void) close(s);
|
||||
s = -1;
|
||||
v_circuit = 1;
|
||||
goto usevc;
|
||||
}
|
||||
}
|
||||
if (_res.options & RES_DEBUG) {
|
||||
if (_res.options & RES_DEBUG2)
|
||||
printf("------------\nGot answer (%d bytes):\n",
|
||||
resplen);
|
||||
else
|
||||
printf("------------\nGot answer:\n");
|
||||
Print_query(answer, answer+resplen, 1);
|
||||
}
|
||||
(void) close(s);
|
||||
s = -1;
|
||||
*trueLenPtr = resplen;
|
||||
return (SUCCESS);
|
||||
}
|
||||
if (s >= 0) {
|
||||
(void) close(s);
|
||||
s = -1;
|
||||
}
|
||||
if (v_circuit == 0)
|
||||
if (gotsomewhere == 0)
|
||||
return NO_RESPONSE; /* no nameservers found */
|
||||
else
|
||||
return TIME_OUT; /* no answer obtained */
|
||||
else
|
||||
if (errno == ECONNREFUSED)
|
||||
return NO_RESPONSE;
|
||||
else
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* This routine is for closing the socket if a virtual circuit is used and
|
||||
* the program wants to close it.
|
||||
*
|
||||
* Called from the interrupt handler.
|
||||
*/
|
||||
void SendRequest_close()
|
||||
{
|
||||
if (s != -1) {
|
||||
(void) close(s);
|
||||
s = -1;
|
||||
}
|
||||
}
|
||||
218
contrib/bind/bin/nslookup/skip.c
Normal file
218
contrib/bind/bin/nslookup/skip.c
Normal file
|
|
@ -0,0 +1,218 @@
|
|||
/*
|
||||
* Copyright (c) 1985, 1989
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* 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, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION 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 lint
|
||||
static char sccsid[] = "@(#)skip.c 5.12 (Berkeley) 3/21/91";
|
||||
static char rcsid[] = "$Id: skip.c,v 8.4 1997/04/25 00:27:19 vixie Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* skip.c --
|
||||
*
|
||||
* Routines to skip over portions of a query buffer.
|
||||
*
|
||||
* Note: this file has been submitted for inclusion in
|
||||
* BIND resolver library. When this has been done, this file
|
||||
* is no longer necessary (assuming there haven't been any
|
||||
* changes).
|
||||
*
|
||||
* Adapted from 4.3BSD BIND res_debug.c
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
char *res_skip_rr();
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* res_skip --
|
||||
*
|
||||
* Skip the contents of a query.
|
||||
*
|
||||
* Interpretation of numFieldsToSkip argument:
|
||||
* res_skip returns pointer to:
|
||||
* 1 -> start of question records.
|
||||
* 2 -> start of authoritative answer records.
|
||||
* 3 -> start of additional records.
|
||||
* 4 -> first byte after end of additional records.
|
||||
*
|
||||
* Results:
|
||||
* (address) - success operation.
|
||||
* NULL - a resource record had an incorrect format.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
char *
|
||||
res_skip(msg, numFieldsToSkip, eom)
|
||||
char *msg;
|
||||
int numFieldsToSkip;
|
||||
char *eom;
|
||||
{
|
||||
register char *cp;
|
||||
register HEADER *hp;
|
||||
register int tmp;
|
||||
register int n;
|
||||
|
||||
/*
|
||||
* Skip the header fields.
|
||||
*/
|
||||
hp = (HEADER *)msg;
|
||||
cp = msg + HFIXEDSZ;
|
||||
|
||||
/*
|
||||
* skip question records.
|
||||
*/
|
||||
n = ntohs(hp->qdcount);
|
||||
if (n > 0) {
|
||||
while (--n >= 0 && cp < eom) {
|
||||
tmp = dn_skipname((u_char *)cp, (u_char *)eom);
|
||||
if (tmp == -1) return(NULL);
|
||||
cp += tmp;
|
||||
cp += INT16SZ; /* type */
|
||||
cp += INT16SZ; /* class */
|
||||
}
|
||||
}
|
||||
if (--numFieldsToSkip <= 0) return(cp);
|
||||
|
||||
/*
|
||||
* skip authoritative answer records
|
||||
*/
|
||||
n = ntohs(hp->ancount);
|
||||
if (n > 0) {
|
||||
while (--n >= 0 && cp < eom) {
|
||||
cp = res_skip_rr(cp, eom);
|
||||
if (cp == NULL) return(NULL);
|
||||
}
|
||||
}
|
||||
if (--numFieldsToSkip == 0) return(cp);
|
||||
|
||||
/*
|
||||
* skip name server records
|
||||
*/
|
||||
n = ntohs(hp->nscount);
|
||||
if (n > 0) {
|
||||
while (--n >= 0 && cp < eom) {
|
||||
cp = res_skip_rr(cp, eom);
|
||||
if (cp == NULL) return(NULL);
|
||||
}
|
||||
}
|
||||
if (--numFieldsToSkip == 0) return(cp);
|
||||
|
||||
/*
|
||||
* skip additional records
|
||||
*/
|
||||
n = ntohs(hp->arcount);
|
||||
if (n > 0) {
|
||||
while (--n >= 0 && cp < eom) {
|
||||
cp = res_skip_rr(cp, eom);
|
||||
if (cp == NULL) return(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
return(cp);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* res_skip_rr --
|
||||
*
|
||||
* Skip over resource record fields.
|
||||
*
|
||||
* Results:
|
||||
* (address) - success operation.
|
||||
* NULL - a resource record had an incorrect format.
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
char *
|
||||
res_skip_rr(cp, eom)
|
||||
char *cp;
|
||||
char *eom;
|
||||
{
|
||||
int tmp;
|
||||
int dlen;
|
||||
|
||||
if ((tmp = dn_skipname((u_char *)cp, (u_char *)eom)) == -1)
|
||||
return (NULL); /* compression error */
|
||||
cp += tmp;
|
||||
if ((cp + RRFIXEDSZ) > eom)
|
||||
return (NULL);
|
||||
cp += INT16SZ; /* type */
|
||||
cp += INT16SZ; /* class */
|
||||
cp += INT32SZ; /* ttl */
|
||||
dlen = ns_get16((u_char*)cp);
|
||||
cp += INT16SZ; /* dlen */
|
||||
cp += dlen;
|
||||
if (cp > eom)
|
||||
return (NULL);
|
||||
return (cp);
|
||||
}
|
||||
475
contrib/bind/bin/nslookup/subr.c
Normal file
475
contrib/bind/bin/nslookup/subr.c
Normal file
|
|
@ -0,0 +1,475 @@
|
|||
/*
|
||||
* Copyright (c) 1985, 1989
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
*
|
||||
* 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, and that
|
||||
* the name of Digital Equipment Corporation not be used in advertising or
|
||||
* publicity pertaining to distribution of the document or software without
|
||||
* specific, written prior permission.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
* CORPORATION 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 lint
|
||||
static char sccsid[] = "@(#)subr.c 5.24 (Berkeley) 3/2/91";
|
||||
static char rcsid[] = "$Id: subr.c,v 8.9 1997/04/25 00:27:19 vixie Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* subr.c --
|
||||
*
|
||||
* Miscellaneous subroutines for the name server
|
||||
* lookup program.
|
||||
*
|
||||
* Copyright (c) 1985
|
||||
* Andrew Cherenson
|
||||
* U.C. Berkeley
|
||||
* CS298-26 Fall 1985
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <netdb.h>
|
||||
#include <setjmp.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "port_after.h"
|
||||
|
||||
#include "resolv.h"
|
||||
#include "res.h"
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* IntrHandler --
|
||||
*
|
||||
* This routine is called whenever a control-C is typed.
|
||||
* It performs three main functions:
|
||||
* - closes an open socket connection,
|
||||
* - closes an open output file (used by LookupHost, et al.),
|
||||
* - jumps back to the main read-eval loop.
|
||||
*
|
||||
* If a user types a ^C in the middle of a routine that uses a socket,
|
||||
* the routine would not be able to close the socket. To prevent an
|
||||
* overflow of the process's open file table, the socket and output
|
||||
* file descriptors are closed by the interrupt handler.
|
||||
*
|
||||
* Side effects:
|
||||
* Open file descriptors are closed.
|
||||
* If filePtr is valid, it is closed.
|
||||
* Flow of control returns to the main() routine.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
SIG_FN
|
||||
IntrHandler()
|
||||
{
|
||||
extern jmp_buf env;
|
||||
#if defined(BSD) && BSD >= 199006 && !defined(RISCOS_BSD) && !defined(__osf__)
|
||||
extern FILE *yyin; /* scanner input file */
|
||||
extern void yyrestart(); /* routine to restart scanner after interrupt */
|
||||
#endif
|
||||
|
||||
SendRequest_close();
|
||||
ListHost_close();
|
||||
if (filePtr != NULL && filePtr != stdout) {
|
||||
fclose(filePtr);
|
||||
filePtr = NULL;
|
||||
}
|
||||
printf("\n");
|
||||
#if defined(BSD) && BSD >= 199006 && !defined(RISCOS_BSD) && !defined(__osf__)
|
||||
yyrestart(yyin);
|
||||
#endif
|
||||
longjmp(env, 1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* Malloc --
|
||||
* Calloc --
|
||||
*
|
||||
* Calls the malloc library routine with SIGINT blocked to prevent
|
||||
* corruption of malloc's data structures. We need to do this because
|
||||
* a control-C doesn't kill the program -- it causes a return to the
|
||||
* main command loop.
|
||||
*
|
||||
* NOTE: This method doesn't prevent the pointer returned by malloc
|
||||
* from getting lost, so it is possible to get "core leaks".
|
||||
*
|
||||
* If malloc fails, the program exits.
|
||||
*
|
||||
* Results:
|
||||
* (address) - address of new buffer.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
char *
|
||||
Malloc(size)
|
||||
int size;
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
#ifdef SYSV
|
||||
#if defined(SVR3) || defined(SVR4)
|
||||
sighold(SIGINT);
|
||||
ptr = malloc((unsigned) size);
|
||||
sigrelse(SIGINT);
|
||||
#else
|
||||
{ SIG_FN (*old)();
|
||||
old = signal(SIGINT, SIG_IGN);
|
||||
ptr = malloc((unsigned) size);
|
||||
signal(SIGINT, old);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
#ifdef POSIX_SIGNALS
|
||||
{ sigset_t sset;
|
||||
sigemptyset(&sset);
|
||||
sigaddset(&sset,SIGINT);
|
||||
sigprocmask(SIG_BLOCK,&sset,NULL);
|
||||
ptr = malloc((unsigned) size);
|
||||
sigprocmask(SIG_UNBLOCK,&sset,NULL);
|
||||
}
|
||||
#else
|
||||
{ int saveMask;
|
||||
saveMask = sigblock(sigmask(SIGINT));
|
||||
ptr = malloc((unsigned) size);
|
||||
(void) sigsetmask(saveMask);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
if (ptr == NULL) {
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "*** Can't allocate memory\n");
|
||||
fflush(stderr);
|
||||
abort();
|
||||
/*NOTREACHED*/
|
||||
} else {
|
||||
return(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
Calloc(num, size)
|
||||
register int num, size;
|
||||
{
|
||||
char *ptr = Malloc(num*size);
|
||||
memset(ptr, 0, num*size);
|
||||
return(ptr);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* PrintHostInfo --
|
||||
*
|
||||
* Prints out the HostInfo structure for a host.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
void
|
||||
PrintHostInfo(file, title, hp)
|
||||
FILE *file;
|
||||
char *title;
|
||||
register HostInfo *hp;
|
||||
{
|
||||
register char **cp;
|
||||
register ServerInfo **sp;
|
||||
char comma;
|
||||
int i;
|
||||
|
||||
fprintf(file, "%-7s %s", title, hp->name);
|
||||
|
||||
if (hp->addrList != NULL) {
|
||||
if (hp->addrList[1] != NULL) {
|
||||
fprintf(file, "\nAddresses:");
|
||||
} else {
|
||||
fprintf(file, "\nAddress:");
|
||||
}
|
||||
comma = ' ';
|
||||
i = 0;
|
||||
for (cp = hp->addrList; cp && *cp; cp++) {
|
||||
i++;
|
||||
if (i > 4) {
|
||||
fprintf(file, "\n\t");
|
||||
comma = ' ';
|
||||
i = 0;
|
||||
}
|
||||
fprintf(file,"%c %s", comma, inet_ntoa(*(struct in_addr *)*cp));
|
||||
comma = ',';
|
||||
}
|
||||
}
|
||||
|
||||
if (hp->aliases != NULL) {
|
||||
fprintf(file, "\nAliases:");
|
||||
comma = ' ';
|
||||
i = 10;
|
||||
for (cp = hp->aliases; cp && *cp && **cp; cp++) {
|
||||
i += strlen(*cp) + 2;
|
||||
if (i > 75) {
|
||||
fprintf(file, "\n\t");
|
||||
comma = ' ';
|
||||
i = 10;
|
||||
}
|
||||
fprintf(file, "%c %s", comma, *cp);
|
||||
comma = ',';
|
||||
}
|
||||
}
|
||||
|
||||
if (hp->servers != NULL) {
|
||||
fprintf(file, "\nServed by:\n");
|
||||
for (sp = hp->servers; *sp != NULL ; sp++) {
|
||||
|
||||
fprintf(file, "- %s\n\t", (*sp)->name);
|
||||
|
||||
comma = ' ';
|
||||
i = 0;
|
||||
for (cp = (*sp)->addrList; cp && *cp && **cp; cp++) {
|
||||
i++;
|
||||
if (i > 4) {
|
||||
fprintf(file, "\n\t");
|
||||
comma = ' ';
|
||||
i = 0;
|
||||
}
|
||||
fprintf(file,
|
||||
"%c %s", comma, inet_ntoa(*(struct in_addr *)*cp));
|
||||
comma = ',';
|
||||
}
|
||||
fprintf(file, "\n\t");
|
||||
|
||||
comma = ' ';
|
||||
i = 10;
|
||||
for (cp = (*sp)->domains; cp && *cp && **cp; cp++) {
|
||||
i += strlen(*cp) + 2;
|
||||
if (i > 75) {
|
||||
fprintf(file, "\n\t");
|
||||
comma = ' ';
|
||||
i = 10;
|
||||
}
|
||||
fprintf(file, "%c %s", comma, *cp);
|
||||
comma = ',';
|
||||
}
|
||||
fprintf(file, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(file, "\n\n");
|
||||
}
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* OpenFile --
|
||||
*
|
||||
* Parses a command string for a file name and opens
|
||||
* the file.
|
||||
*
|
||||
* Results:
|
||||
* file pointer - the open was successful.
|
||||
* NULL - there was an error opening the file or
|
||||
* the input string was invalid.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
FILE *
|
||||
OpenFile(string, file)
|
||||
char *string;
|
||||
char *file;
|
||||
{
|
||||
char *redirect;
|
||||
FILE *tmpPtr;
|
||||
|
||||
/*
|
||||
* Open an output file if we see '>' or >>'.
|
||||
* Check for overwrite (">") or concatenation (">>").
|
||||
*/
|
||||
|
||||
redirect = strchr(string, '>');
|
||||
if (redirect == NULL) {
|
||||
return(NULL);
|
||||
}
|
||||
if (redirect[1] == '>') {
|
||||
sscanf(redirect, ">> %s", file);
|
||||
tmpPtr = fopen(file, "a+");
|
||||
} else {
|
||||
sscanf(redirect, "> %s", file);
|
||||
tmpPtr = fopen(file, "w");
|
||||
}
|
||||
|
||||
if (tmpPtr != NULL) {
|
||||
redirect[0] = '\0';
|
||||
}
|
||||
|
||||
return(tmpPtr);
|
||||
}
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* DecodeError --
|
||||
*
|
||||
* Converts an error code into a character string.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
const struct res_sym error_syms[] = {
|
||||
{ NOERROR, "Success" },
|
||||
{ FORMERR, "Format error" },
|
||||
{ SERVFAIL, "Server failed" },
|
||||
{ NXDOMAIN, "Non-existent host/domain" },
|
||||
{ NOTIMP, "Not implemented" },
|
||||
{ REFUSED, "Query refused" },
|
||||
#ifdef NOCHANGE
|
||||
{ NOCHANGE, "No change" },
|
||||
#endif
|
||||
{ TIME_OUT, "Timed out" },
|
||||
{ NO_INFO, "No information" },
|
||||
{ ERROR, "Unspecified error" },
|
||||
{ NONAUTH, "Non-authoritative answer" },
|
||||
{ NO_RESPONSE, "No response from server" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
const char *
|
||||
DecodeError(result)
|
||||
int result;
|
||||
{
|
||||
const char *string;
|
||||
int success;
|
||||
|
||||
string = sym_ntos(error_syms, result, &success);
|
||||
if (success)
|
||||
return string;
|
||||
return ("BAD ERROR VALUE");
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
StringToClass(class, dflt, errorfile)
|
||||
char *class;
|
||||
int dflt;
|
||||
FILE *errorfile;
|
||||
{
|
||||
int result, success;
|
||||
|
||||
result = sym_ston(__p_class_syms, class, &success);
|
||||
if (success)
|
||||
return result;
|
||||
|
||||
if (errorfile)
|
||||
fprintf(errorfile, "unknown query class: %s\n", class);
|
||||
return(dflt);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* StringToType --
|
||||
*
|
||||
* Converts a string form of a query type name to its
|
||||
* corresponding integer value.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
int
|
||||
StringToType(type, dflt, errorfile)
|
||||
char *type;
|
||||
int dflt;
|
||||
FILE *errorfile;
|
||||
{
|
||||
int result, success;
|
||||
|
||||
result = sym_ston(__p_type_syms, type, &success);
|
||||
if (success)
|
||||
return (result);
|
||||
|
||||
if (errorfile)
|
||||
fprintf(errorfile, "unknown query type: %s\n", type);
|
||||
return (dflt);
|
||||
}
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* DecodeType --
|
||||
*
|
||||
* Converts a query type to a descriptive name.
|
||||
* (A more verbose form of p_type.)
|
||||
*
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
const char *
|
||||
DecodeType(type)
|
||||
int type;
|
||||
{
|
||||
|
||||
return (sym_ntop(__p_type_syms, type, (int *)0));
|
||||
}
|
||||
79
contrib/bind/bin/nsupdate/Makefile
Normal file
79
contrib/bind/bin/nsupdate/Makefile
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
## Copyright (c) 1996 by Internet Software Consortium
|
||||
##
|
||||
## 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
# $Id: Makefile,v 8.18 1997/06/19 03:22:11 halley Exp $
|
||||
|
||||
DESTDIR=
|
||||
CC= cc
|
||||
SHELL= /bin/sh
|
||||
|
||||
CDEBUG= -g
|
||||
|
||||
#(net2 and its descendents)
|
||||
SYSTYPE = bsdos
|
||||
TOP = ../..
|
||||
INCL = ${TOP}/include
|
||||
PORTINCL = ${TOP}/port/${SYSTYPE}/include
|
||||
LIBBIND = ${TOP}/lib/libbind.a
|
||||
A=a
|
||||
O=o
|
||||
LEX = lex -I
|
||||
SYSLIBS = -ll -lutil
|
||||
PIDDIR = /var/run
|
||||
DESTBIN = /usr/local/bin
|
||||
DESTSBIN = /usr/local/sbin
|
||||
DESTEXEC = /usr/local/libexec
|
||||
DESTMAN = /usr/share/man
|
||||
DESTHELP= /usr/share/misc
|
||||
STRIP=-s
|
||||
|
||||
LDFLAGS=
|
||||
CFLAGS= ${CDEBUG} -I${PORTINCL} -I${INCL}
|
||||
|
||||
PROG= nsupdate
|
||||
SRCS= ${PROG}.c
|
||||
OBJS= ${PROG}.${O}
|
||||
|
||||
all: ${PROG}
|
||||
|
||||
${PROG}: ${OBJS} ${LIBBIND} Makefile
|
||||
${CC} ${CDEBUG} ${LDFLAGS} -o ${PROG} ${OBJS} \
|
||||
${LIBBIND} ${SYSLIBS}
|
||||
|
||||
distclean: clean
|
||||
|
||||
clean: FRC
|
||||
rm -f ${PROG} ${OBJS} core .depend
|
||||
rm -f *.BAK *.CKP *~ *.orig
|
||||
|
||||
depend: ${SRCS}
|
||||
mkdep -p ${CPPFLAGS} -I${INCL} -I${PORTINCL} ${SRCS}
|
||||
|
||||
${DESTDIR}${DESTBIN}:
|
||||
mkdir -p ${DESTDIR}${DESTBIN}
|
||||
|
||||
install: ${DESTDIR}${DESTBIN} ${PROG}
|
||||
${INSTALL} ${STRIP} -c -m 755 ${PROG} ${DESTDIR}${DESTBIN}/${PROG}
|
||||
|
||||
links: FRC
|
||||
@set -e; ln -s SRC/*.[ch] .
|
||||
|
||||
tags: FRC
|
||||
ctags *.[ch]
|
||||
|
||||
FRC:
|
||||
|
||||
# DO NOT DELETE THIS LINE -- mkdep uses it.
|
||||
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
|
||||
471
contrib/bind/bin/nsupdate/nsupdate.c
Normal file
471
contrib/bind/bin/nsupdate/nsupdate.c
Normal file
|
|
@ -0,0 +1,471 @@
|
|||
#if !defined(lint) && !defined(SABER)
|
||||
static char rcsid[] = "$Id: nsupdate.c,v 8.5 1998/02/14 20:54:48 halley Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 by Internet Software Consortium.
|
||||
*
|
||||
* 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "port_before.h"
|
||||
#include <sys/param.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <netdb.h>
|
||||
#include <resolv.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "port_after.h"
|
||||
|
||||
/* XXX all of this stuff should come from libbind.a */
|
||||
|
||||
/*
|
||||
* Map class and type names to number
|
||||
*/
|
||||
struct map {
|
||||
char token[10];
|
||||
int val;
|
||||
};
|
||||
|
||||
struct map class_strs[] = {
|
||||
{ "in", C_IN },
|
||||
{ "chaos", C_CHAOS },
|
||||
{ "hs", C_HS },
|
||||
};
|
||||
#define M_CLASS_CNT (sizeof(class_strs) / sizeof(struct map))
|
||||
|
||||
struct map type_strs[] = {
|
||||
{ "a", T_A },
|
||||
{ "ns", T_NS },
|
||||
{ "cname", T_CNAME },
|
||||
{ "soa", T_SOA },
|
||||
{ "mb", T_MB },
|
||||
{ "mg", T_MG },
|
||||
{ "mr", T_MR },
|
||||
{ "null", T_NULL },
|
||||
{ "wks", T_WKS },
|
||||
{ "ptr", T_PTR },
|
||||
{ "hinfo", T_HINFO },
|
||||
{ "minfo", T_MINFO },
|
||||
{ "mx", T_MX },
|
||||
{ "txt", T_TXT },
|
||||
{ "rp", T_RP },
|
||||
{ "afsdb", T_AFSDB },
|
||||
{ "x25", T_X25 },
|
||||
{ "isdn", T_ISDN },
|
||||
{ "rt", T_RT },
|
||||
{ "nsap", T_NSAP },
|
||||
{ "nsap_ptr", T_NSAP_PTR },
|
||||
{ "px", T_PX },
|
||||
{ "loc", T_LOC },
|
||||
};
|
||||
#define M_TYPE_CNT (sizeof(type_strs) / sizeof(struct map))
|
||||
|
||||
struct map section_strs[] = {
|
||||
{ "zone", S_ZONE },
|
||||
{ "prereq", S_PREREQ },
|
||||
{ "update", S_UPDATE },
|
||||
{ "reserved", S_ADDT },
|
||||
};
|
||||
#define M_SECTION_CNT (sizeof(section_strs) / sizeof(struct map))
|
||||
|
||||
struct map opcode_strs[] = {
|
||||
{ "nxdomain", NXDOMAIN },
|
||||
{ "yxdomain", YXDOMAIN },
|
||||
{ "nxrrset", NXRRSET },
|
||||
{ "yxrrset", YXRRSET },
|
||||
{ "delete", DELETE },
|
||||
{ "add", ADD },
|
||||
};
|
||||
#define M_OPCODE_CNT (sizeof(opcode_strs) / sizeof(struct map))
|
||||
|
||||
static char *progname;
|
||||
static FILE *log;
|
||||
|
||||
static void usage(void);
|
||||
static int getword_str(char *, int, char **, char *);
|
||||
|
||||
/*
|
||||
* format of file read by nsupdate is kept the same as the log
|
||||
* file generated by updates, so that the log file can be fed
|
||||
* to nsupdate to reconstruct lost updates.
|
||||
*
|
||||
* file is read on line at a time using fgets() rather than
|
||||
* one word at a time using getword() so that it is easy to
|
||||
* adapt nsupdate to read piped input from other scripts
|
||||
*
|
||||
* overloading of class/type has to be deferred to res_update()
|
||||
* because class is needed by res_update() to determined the
|
||||
* zone to which a resource record belongs
|
||||
*/
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
FILE *fp = NULL;
|
||||
char buf[BUFSIZ], buf2[BUFSIZ], hostbuf[100], filebuf[100];
|
||||
char dnbuf[MAXDNAME];
|
||||
u_char packet[PACKETSZ], answer[PACKETSZ];
|
||||
char *host = hostbuf, *batchfile = filebuf;
|
||||
char *r_dname, *cp, *startp, *endp, *svstartp;
|
||||
char section[15], opcode[10];
|
||||
int i, c, n, n1, inside, lineno = 0, vc = 0,
|
||||
debug = 0, r_size, r_section, r_opcode,
|
||||
prompt = 0, ret = 0;
|
||||
int16_t r_class, r_type;
|
||||
u_int32_t r_ttl;
|
||||
struct map *mp;
|
||||
ns_updrec *rrecp_start = NULL, *rrecp, *tmprrecp;
|
||||
struct in_addr hostaddr;
|
||||
extern int getopt();
|
||||
extern char *optarg;
|
||||
extern int optind, opterr, optopt;
|
||||
|
||||
|
||||
progname = argv[0];
|
||||
|
||||
while ((c = getopt(argc, argv, "dv")) != EOF) {
|
||||
switch (c) {
|
||||
case 'v':
|
||||
vc = 1;
|
||||
break;
|
||||
case 'd':
|
||||
debug = 1;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
||||
if ((argc - optind) == 0) {
|
||||
/* no file specified, read from stdin */
|
||||
ret = system("tty -s");
|
||||
if (ret == 0) /* terminal */
|
||||
prompt = 1;
|
||||
else /* stdin redirect from a file or a pipe */
|
||||
prompt = 0;
|
||||
} else {
|
||||
/* file specified, open it */
|
||||
/* XXX - currently accepts only one filename */
|
||||
if ((fp = fopen(argv[optind], "r")) == NULL) {
|
||||
fprintf(stderr, "error opening file: %s\n", argv[optind]);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
for (;;) {
|
||||
|
||||
inside = 1;
|
||||
if (prompt)
|
||||
fprintf(stdout, "> ");
|
||||
if (!fp)
|
||||
cp = fgets(buf, sizeof buf, stdin);
|
||||
else
|
||||
cp = fgets(buf, sizeof buf, fp);
|
||||
if (cp == NULL) /* EOF */
|
||||
break;
|
||||
lineno++;
|
||||
|
||||
/* get rid of the trailing newline */
|
||||
n = strlen(buf);
|
||||
buf[--n] = '\0';
|
||||
|
||||
startp = cp;
|
||||
endp = strchr(cp, ';');
|
||||
if (endp != NULL)
|
||||
endp--;
|
||||
else
|
||||
endp = cp + n - 1;
|
||||
|
||||
/* verify section name */
|
||||
if (!getword_str(section, sizeof section, &startp, endp)) {
|
||||
/* empty line */
|
||||
inside = 0;
|
||||
}
|
||||
if (inside) {
|
||||
/* inside the same update packet,
|
||||
* continue accumulating records */
|
||||
r_section = -1;
|
||||
n1 = strlen(section);
|
||||
if (section[n1-1] == ':')
|
||||
section[--n1] = '\0';
|
||||
for (mp = section_strs; mp < section_strs+M_SECTION_CNT; mp++)
|
||||
if (!strcasecmp(section, mp->token)) {
|
||||
r_section = mp->val;
|
||||
break;
|
||||
}
|
||||
if (r_section == -1) {
|
||||
fprintf(stderr, "incorrect section name: %s\n", section);
|
||||
exit (1);
|
||||
}
|
||||
if (r_section == S_ZONE) {
|
||||
fprintf(stderr, "section ZONE not permitted\n");
|
||||
exit (1);
|
||||
}
|
||||
/* read operation code */
|
||||
if (!getword_str(opcode, sizeof opcode, &startp, endp)) {
|
||||
fprintf(stderr, "failed to read operation code\n");
|
||||
exit (1);
|
||||
}
|
||||
r_opcode = -1;
|
||||
if (opcode[0] == '{') {
|
||||
n1 = strlen(opcode);
|
||||
for (i = 0; i < n1; i++)
|
||||
opcode[i] = opcode[i+1];
|
||||
if (opcode[n1-2] == '}')
|
||||
opcode[n1-2] = '\0';
|
||||
}
|
||||
for (mp = opcode_strs; mp < opcode_strs+M_OPCODE_CNT; mp++) {
|
||||
if (!strcasecmp(opcode, mp->token)) {
|
||||
r_opcode = mp->val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (r_opcode == -1) {
|
||||
fprintf(stderr, "incorrect operation code: %s\n", opcode);
|
||||
exit (1);
|
||||
}
|
||||
/* read owner's domain name */
|
||||
if (!getword_str(dnbuf, sizeof dnbuf, &startp, endp)) {
|
||||
fprintf(stderr, "failed to read owner name\n");
|
||||
exit (1);
|
||||
}
|
||||
r_dname = dnbuf;
|
||||
r_ttl = 0;
|
||||
r_type = -1;
|
||||
r_class = C_IN; /* default to IN */
|
||||
r_size = 0;
|
||||
|
||||
(void) getword_str(buf2, sizeof buf2, &startp, endp);
|
||||
|
||||
if (isdigit(buf2[0])) { /* ttl */
|
||||
r_ttl = strtoul(buf2, 0, 10);
|
||||
if (errno == ERANGE && r_ttl == ULONG_MAX) {
|
||||
fprintf(stderr, "oversized ttl: %s\n", buf2);
|
||||
exit (1);
|
||||
}
|
||||
(void) getword_str(buf2, sizeof buf2, &startp, endp);
|
||||
}
|
||||
|
||||
if (buf2[0]) { /* possibly class */
|
||||
for (mp = class_strs; mp < class_strs+M_CLASS_CNT; mp++) {
|
||||
if (!strcasecmp(buf2, mp->token)) {
|
||||
r_class = mp->val;
|
||||
(void) getword_str(buf2, sizeof buf2, &startp, endp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* type and rdata field may or may not be required depending
|
||||
* on the section and operation
|
||||
*/
|
||||
switch (r_section) {
|
||||
case S_PREREQ:
|
||||
if (r_ttl) {
|
||||
fprintf(stderr, "nonzero ttl in prereq section: %ul\n",
|
||||
r_ttl);
|
||||
r_ttl = 0;
|
||||
}
|
||||
switch (r_opcode) {
|
||||
case NXDOMAIN:
|
||||
case YXDOMAIN:
|
||||
if (buf2[0]) {
|
||||
fprintf (stderr, "invalid field: %s, ignored\n",
|
||||
buf2);
|
||||
exit (1);
|
||||
}
|
||||
break;
|
||||
case NXRRSET:
|
||||
case YXRRSET:
|
||||
if (buf2[0])
|
||||
for (mp = type_strs; mp < type_strs+M_TYPE_CNT; mp++)
|
||||
if (!strcasecmp(buf2, mp->token)) {
|
||||
r_type = mp->val;
|
||||
break;
|
||||
}
|
||||
if (r_type == -1) {
|
||||
fprintf (stderr, "invalid type for RRset: %s\n",
|
||||
buf2);
|
||||
exit (1);
|
||||
}
|
||||
if (r_opcode == NXRRSET)
|
||||
break;
|
||||
/*
|
||||
* for RRset exists (value dependent) case,
|
||||
* nonempty rdata field will be present.
|
||||
* simply copy the whole string now and let
|
||||
* res_update() interpret the various fields
|
||||
* depending on type
|
||||
*/
|
||||
cp = startp;
|
||||
while (cp <= endp && isspace(*cp))
|
||||
cp++;
|
||||
r_size = endp - cp + 1;
|
||||
break;
|
||||
default:
|
||||
fprintf (stderr,
|
||||
"unknown operation in prereq section\"%s\"\n",
|
||||
opcode);
|
||||
exit (1);
|
||||
}
|
||||
break;
|
||||
case S_UPDATE:
|
||||
switch (r_opcode) {
|
||||
case DELETE:
|
||||
r_ttl = 0;
|
||||
r_type = T_ANY;
|
||||
/* read type, if specified */
|
||||
if (buf2[0])
|
||||
for (mp = type_strs; mp < type_strs+M_TYPE_CNT; mp++)
|
||||
if (!strcasecmp(buf2, mp->token)) {
|
||||
r_type = mp->val;
|
||||
svstartp = startp;
|
||||
(void) getword_str(buf2, sizeof buf2,
|
||||
&startp, endp);
|
||||
if (buf2[0]) /* unget preference */
|
||||
startp = svstartp;
|
||||
break;
|
||||
}
|
||||
/* read rdata portion, if specified */
|
||||
cp = startp;
|
||||
while (cp <= endp && isspace(*cp))
|
||||
cp++;
|
||||
r_size = endp - cp + 1;
|
||||
break;
|
||||
case ADD:
|
||||
if (r_ttl == 0) {
|
||||
fprintf (stderr,
|
||||
"ttl must be specified for record to be added: %s\n", buf);
|
||||
exit (1);
|
||||
}
|
||||
/* read type */
|
||||
if (buf2[0])
|
||||
for (mp = type_strs; mp < type_strs+M_TYPE_CNT; mp++)
|
||||
if (!strcasecmp(buf2, mp->token)) {
|
||||
r_type = mp->val;
|
||||
break;
|
||||
}
|
||||
if (r_type == -1) {
|
||||
fprintf(stderr,
|
||||
"invalid type for record to be added: %s\n", buf2);
|
||||
exit (1);
|
||||
}
|
||||
/* read rdata portion */
|
||||
cp = startp;
|
||||
while (cp < endp && isspace(*cp))
|
||||
cp++;
|
||||
r_size = endp - cp + 1;
|
||||
if (r_size <= 0) {
|
||||
fprintf(stderr,
|
||||
"nonempty rdata field needed to add the record at line %d\n",
|
||||
lineno);
|
||||
exit (1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,
|
||||
"unknown operation in update section\"%s\"\n", opcode);
|
||||
exit (1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,
|
||||
"unknown section identifier \"%s\"\n", section);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if ( !(rrecp = res_mkupdrec(r_section, r_dname, r_class,
|
||||
r_type, r_ttl)) ||
|
||||
(r_size > 0 && !(rrecp->r_data = (u_char *)malloc(r_size))) ) {
|
||||
fprintf(stderr, "saverrec error\n");
|
||||
exit (1);
|
||||
}
|
||||
rrecp->r_opcode = r_opcode;
|
||||
rrecp->r_size = r_size;
|
||||
(void) strncpy((char *)rrecp->r_data, cp, r_size);
|
||||
/* append current record to the end of linked list of
|
||||
* records seen so far */
|
||||
if (rrecp_start == NULL)
|
||||
rrecp_start = rrecp;
|
||||
else {
|
||||
tmprrecp = rrecp_start;
|
||||
while (tmprrecp->r_next != NULL)
|
||||
tmprrecp = tmprrecp->r_next;
|
||||
tmprrecp->r_next = rrecp;
|
||||
}
|
||||
} else { /* end of an update packet */
|
||||
(void) res_init();
|
||||
if (vc)
|
||||
_res.options |= RES_USEVC | RES_STAYOPEN;
|
||||
if (debug)
|
||||
_res.options |= RES_DEBUG;
|
||||
if (rrecp_start) {
|
||||
if ((n = res_update(rrecp_start)) < 0)
|
||||
fprintf(stderr, "failed update packet\n");
|
||||
/* free malloc'ed memory */
|
||||
while(rrecp_start) {
|
||||
tmprrecp = rrecp_start;
|
||||
rrecp_start = rrecp_start->r_next;
|
||||
free((char *)tmprrecp->r_dname);
|
||||
free((char *)tmprrecp);
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* for */
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
usage() {
|
||||
fprintf(stderr, "Usage: %s [-d] [-v] [file]\n",
|
||||
progname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a whitespace delimited word from a string (not file)
|
||||
* into buf. modify the start pointer to point after the
|
||||
* word in the string.
|
||||
*/
|
||||
static int
|
||||
getword_str(char *buf, int size, char **startpp, char *endp) {
|
||||
char *cp;
|
||||
int c;
|
||||
|
||||
for (cp = buf; *startpp <= endp; ) {
|
||||
c = **startpp;
|
||||
if (isspace(c) || c == '\0') {
|
||||
if (cp != buf) /* trailing whitespace */
|
||||
break;
|
||||
else { /* leading whitespace */
|
||||
(*startpp)++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
(*startpp)++;
|
||||
if (cp >= buf+size-1)
|
||||
break;
|
||||
*cp++ = (u_char)c;
|
||||
}
|
||||
*cp = '\0';
|
||||
return (cp != buf);
|
||||
}
|
||||
|
|
@ -57,7 +57,7 @@
|
|||
.b "Name Server Operations Guide"
|
||||
.b "for \s-1BIND\s+1"
|
||||
.sz
|
||||
\fIRelease 4.9.5\fP
|
||||
\fIRelease 4.9.3\fP
|
||||
.eh 'SMM:10-%''Name Server Operations Guide for \s-1BIND\s+1'
|
||||
.oh 'Name Server Operations Guide for \s-1BIND\s+1''\s-1SMM\s+1:10-%'
|
||||
.sp
|
||||
|
|
|
|||
|
|
@ -62,9 +62,6 @@ ME= -me
|
|||
NROFF= nroff -rb3
|
||||
PRINTER= -Pdp
|
||||
TBL= dtbl $(PRINTER)
|
||||
# For Linux:
|
||||
#PRINTER=
|
||||
#TBL= tbl $(PRINTER)
|
||||
TROFF= ditroff $(PRINTER)
|
||||
GROFF= groff -Tps -t $(ME)
|
||||
|
||||
|
|
@ -84,7 +81,6 @@ cat: $(FILES)
|
|||
|
||||
clean:
|
||||
rm -f *.psf *.lst *.BAK *.CKP *~ *.orig
|
||||
rm -f file
|
||||
|
||||
spell: $(FILES)
|
||||
@for i in $(FILES); do \
|
||||
|
|
|
|||
|
|
@ -543,7 +543,7 @@ resolver variable. Supported options at this time are:
|
|||
sets the \s-1RES_DEBUG\s+1 bit in \fB_res.options\fP.
|
||||
.ip \fBndots:\fP\fIn\fP
|
||||
sets the lower threshold (measured in ``number of dots'') on names given to
|
||||
\fIres_query\fP() such that names with at least this number of dots will be
|
||||
\fIres_query\fP() such that names with more than this number of dots will be
|
||||
tried as absolute names before any \fIlocal-domain\fP or \fIsearch-list\fP
|
||||
processing is done. The default for this internal variable is ``1''.
|
||||
.\" .pp
|
||||
|
|
@ -1046,10 +1046,6 @@ recognize it.
|
|||
|
||||
.sh 2 "Discussion about the TTL"
|
||||
.pp
|
||||
The use of different Time To Live fields with in a RRset have been
|
||||
deprecated and this is enforced by the server when loading a primary
|
||||
zone. See the Security section for more discussion of differing TTLs.
|
||||
.pp
|
||||
The Time To Live assigned to the records and to the zone via the
|
||||
Minimum field in the SOA record is very important. High values will
|
||||
lead to lower BIND network traffic and faster response time. Lower
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
.\" ++Copyright++ 1986, 1988
|
||||
.\" -
|
||||
.\" Copyright (c) 1986, 1988
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
|
|
@ -46,6 +48,8 @@
|
|||
.\" 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--
|
||||
.\"
|
||||
.\" @(#)ns.me 6.3 (Berkeley) 9/19/89
|
||||
.\"
|
||||
|
|
@ -90,38 +94,3 @@ Berkeley would look as follows:
|
|||
.)b
|
||||
The top level domain for educational organizations is EDU;
|
||||
Berkeley is a subdomain of EDU and monet is the name of the host.
|
||||
.sh 1 Security
|
||||
.pp
|
||||
This section examines some of the know security implications of various
|
||||
versions of BIND. Some of these have been used to attack the nameservers
|
||||
in the past.
|
||||
.sh 2 "Unnecessary Glue"
|
||||
.pp
|
||||
Unnecessary glue can lead to incorrect records being loaded into the
|
||||
server. This can result in connections going to the wrong machines.
|
||||
.pp
|
||||
To prevent unnecessary glue being loaded, all the servers of zones being
|
||||
servered by a server and the servers of the parent zones need to be
|
||||
upgraded to BIND 4.9.3 or later.
|
||||
.sh 2 "Insertion of data into a zone that is being servered"
|
||||
.pp
|
||||
BIND versions prior to BIND 4.9.2 are subject to the insertion of
|
||||
resource records into zone that they are serving.
|
||||
.sh 2 "Denial of Service: Hash Bug Exploit"
|
||||
.pp
|
||||
September 1996 saw the COM TLD subject to a denial of service attack by
|
||||
injecting into the DNS a record with a final label of COM, eight spaces
|
||||
and COM. This effected BIND 4.9.4 servers. Similar attacks are possible
|
||||
on BIND 4.9.3 and BIND 4.9.3-P1.
|
||||
.pp
|
||||
It is recommend that you run a BIND 4.9.4-P1 or later server to avoid
|
||||
this exploit.
|
||||
.sh 2 "Denial of Service: TTL Inconsistency Attacks"
|
||||
.pp
|
||||
If you are still using multiple TTL values within a RRset you can be
|
||||
subject to a denial of service attack. BIND 4.9.5 onwards uses multiple
|
||||
ttl values within a RRset to reject obviously bad RRset.
|
||||
.pp
|
||||
It is recommend that you upgrade to BIND 4.9.5 or later as these server
|
||||
prevent you loading multiple TTL values and doesn't merge answers received
|
||||
across the network.
|
||||
|
|
|
|||
63
contrib/bind/doc/html/acl.html
Normal file
63
contrib/bind/doc/html/acl.html
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>BIND acl Statement</TITLE>
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<H2>BIND Configuration File Guide--<CODE>acl</CODE> Statement</H2>
|
||||
|
||||
<HR>
|
||||
|
||||
<A NAME="Syntax"><H3>Syntax</H3></A>
|
||||
|
||||
<PRE>
|
||||
acl <VAR>name</VAR> {
|
||||
<VAR><A HREF="address_list.html">address_match_list</A></VAR>
|
||||
};
|
||||
</PRE>
|
||||
|
||||
<HR>
|
||||
|
||||
<A NAME="Usage"><H3>Definition and Usage</H3></A>
|
||||
|
||||
<P>The <CODE>acl</CODE> statement creates a named address match list.
|
||||
It gets its name from a primary use of address match lists: Access
|
||||
Control Lists (ACLs).</P>
|
||||
|
||||
<P>Note that an address match list's name must be defined with
|
||||
<CODE>acl</CODE> before it can be used elsewhere; no forward
|
||||
references are allowed.</P>
|
||||
|
||||
The following ACLs are built-in:
|
||||
|
||||
<DL>
|
||||
<DT><CODE>any</CODE>
|
||||
<DD>
|
||||
Allows all hosts.
|
||||
|
||||
<DT><CODE>none</CODE>
|
||||
<DD>
|
||||
Denies all hosts.
|
||||
|
||||
<DT><CODE>localhost</CODE>
|
||||
<DD>
|
||||
Allows the IP addresses of all interfaces on the system.
|
||||
|
||||
<DT><CODE>localnets</CODE>
|
||||
<DD>
|
||||
Allows any host on a network for which the system has an interface.
|
||||
</DL>
|
||||
|
||||
<HR>
|
||||
|
||||
<CENTER><P>[ <A HREF="config.html">BIND Config. File</A>
|
||||
| <A HREF="http://www.vix.com/isc/bind.html">BIND Home</A>
|
||||
| <A HREF="http://www.isc.org">ISC</A> ]</P></CENTER>
|
||||
|
||||
<HR>
|
||||
<ADDRESS>
|
||||
Last Updated: $Id: acl.html,v 1.4 1998/03/21 01:03:10 halley Exp $
|
||||
</ADDRESS>
|
||||
</BODY>
|
||||
</HTML>
|
||||
87
contrib/bind/doc/html/address_list.html
Normal file
87
contrib/bind/doc/html/address_list.html
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>BIND Address Match Lists</TITLE>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
|
||||
<H2>BIND Configuration File Guide--Address Match Lists</H2>
|
||||
|
||||
<HR>
|
||||
|
||||
<A NAME="Syntax"><H3>Syntax</H3></A>
|
||||
|
||||
<PRE>
|
||||
<VAR>address_match_list</VAR> = 1*<VAR>address_match_element</VAR>
|
||||
|
||||
<VAR>address_match_element</VAR> = [ "!" ] (<VAR><A HREF="docdef.html">ip_address</A></VAR> / <VAR><A HREF="docdef.html">ip_prefix</A></VAR> / <VAR><A HREF="acl.html">acl_name</A></VAR> / <VAR>address_match_list</VAR>) ";"
|
||||
</PRE>
|
||||
|
||||
<HR>
|
||||
|
||||
<A NAME="Usage"><H3>Definition and Usage</H3></A>
|
||||
|
||||
<P>Address match lists are lists of elements. The elements can be any
|
||||
of the following:</P>
|
||||
|
||||
<UL>
|
||||
<LI>an IP address (in dotted-decimal notation),</LI>
|
||||
|
||||
<LI>an IP prefix (in the '/'-notation),</LI>
|
||||
|
||||
<LI>the name of an address match list previously defined with
|
||||
the <A HREF="acl.html"><CODE>acl</CODE></A> statment.</LI>
|
||||
|
||||
<LI>an IP address match list</LI>
|
||||
</UL>
|
||||
|
||||
<P>The ACLs "any", "none", "localhost" and "localnets" are
|
||||
predefined. More information can be found in the description of the
|
||||
<A HREF="acl.html"><CODE>acl</CODE></A> statement.
|
||||
|
||||
<P>Elements can be negated with a leading "!".
|
||||
|
||||
<P>When a given IP address or prefix is compared to an address match
|
||||
list, the list is traversed in order and the first match (regardless
|
||||
of negation) is used. The interpretation of a match depends on
|
||||
whether the list is being used for access control or as a
|
||||
topology.</P>
|
||||
|
||||
<P>When used as an access control list, a non-negated match allows
|
||||
access and a negated match denies access. If there is no match,
|
||||
access is denied. The clauses <CODE>allow-query</CODE>,
|
||||
<CODE>allow-transfer</CODE> and <CODE>allow-update</CODE> all use
|
||||
address match lists like this. Similarly, the <CODE>listen-on</CODE>
|
||||
clause can use negation to define local addresses which should not be
|
||||
used to accept nameserver connections.</P>
|
||||
|
||||
<P>When used with the <CODE>topology</CODE> clause, a non-negated
|
||||
match returns a distance based on its postion on the list (the closer
|
||||
the match is to the start of the list, the shorter the distance is
|
||||
between it and the server). A negated match will be assigned the
|
||||
maximum distance from the server. If there is no match, the address
|
||||
will get a distance which is further than any non-negated list
|
||||
element, and closer than any negated element.</P>
|
||||
|
||||
<P>Because of the first-match aspect of the algorithm, an element that
|
||||
defines a subset of another element in the list should come before the
|
||||
broader element, regardless of whether either is negated. For
|
||||
example, in <CODE>1.2.3/24; ! 1.2.3.13;</CODE> the 1.2.3.13
|
||||
element is completely useless, because the algorithm will match
|
||||
any lookup for 1.2.3.13 to the 1.2.3/24 element. Using
|
||||
<CODE>! 1.2.3.13; 1.2.3/24</CODE> fixes that problem by
|
||||
having 1.2.3.13 blocked by the negation but all other 1.2.3.* hosts
|
||||
fall through.
|
||||
|
||||
<HR>
|
||||
|
||||
<CENTER><P>[ <A HREF="config.html">BIND Config. File</A>
|
||||
| <A HREF="http://www.vix.com/isc/bind.html">BIND Home</A>
|
||||
| <A HREF="http://www.isc.org">ISC</A> ]</P></CENTER>
|
||||
|
||||
<HR>
|
||||
<ADDRESS>
|
||||
Last Updated: $Id: address_list.html,v 1.5 1998/03/21 01:03:10 halley Exp $
|
||||
</ADDRESS>
|
||||
</BODY>
|
||||
</HTML>
|
||||
84
contrib/bind/doc/html/comments.html
Normal file
84
contrib/bind/doc/html/comments.html
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>BIND Comment Syntax</TITLE>
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<H2>BIND Configuration File Guide--Comment Syntax</H2>
|
||||
|
||||
<HR>
|
||||
|
||||
<A NAME="Syntax"><H3>Syntax</H3></A>
|
||||
|
||||
<PRE>
|
||||
/* This is a BIND comment as in C */
|
||||
|
||||
// This is a BIND comment as in C++
|
||||
|
||||
# This is a BIND comment as in common Unix shells and perl
|
||||
</PRE>
|
||||
|
||||
<A NAME="Usage"><H3>Definition and Usage</H3></A>
|
||||
|
||||
<P>Comments may appear anywhere that whitespace may appear in a BIND
|
||||
configuration file.</P>
|
||||
|
||||
<P>C-style comments start with the two characters <CODE>/*</CODE>
|
||||
(slash, star) and end with <CODE>*/</CODE> (star, slash). Because
|
||||
they are completely delimited with these characters, they can be used
|
||||
to comment only a portion of a line or to span multiple lines.</P>
|
||||
|
||||
<P>C-style comments cannot be nested. For example, the following is
|
||||
not valid because the entire comment ends with the first
|
||||
<CODE>*/</CODE>:
|
||||
|
||||
<PRE>
|
||||
/* This is the start of a comment.
|
||||
This is still part of the comment.
|
||||
/* This is an incorrect attempt at nesting a comment. */
|
||||
This is no longer in any comment. */
|
||||
</PRE>
|
||||
|
||||
|
||||
<P>C++-style comments start with the two characters <CODE>//</CODE>
|
||||
(slash, slash) and continue to the end of the physical line. They
|
||||
cannot be continued across multiple physical lines; to have one
|
||||
logical comment span multiple lines, each line must use the
|
||||
<CODE>//</CODE> pair. For example:
|
||||
|
||||
<PRE>
|
||||
// This is the start of a comment. The next line
|
||||
// is a new comment, even though it is logically
|
||||
// part of the previous comment.
|
||||
</PRE>
|
||||
|
||||
<P>Shell-style (or perl-style, if you prefer) comments start with the
|
||||
character <CODE>#</CODE> (hash or pound or number or octothorpe or
|
||||
whatever) and continue to the end of the physical line, like C++
|
||||
comments.</P> For example:
|
||||
|
||||
<PRE>
|
||||
# This is the start of a comment. The next line
|
||||
# is a new comment, even though it is logically
|
||||
# part of the previous comment.
|
||||
</PRE>
|
||||
|
||||
<P><STRONG>WARNING:</STRONG> you cannot use the <CODE>;</CODE>
|
||||
(semicolon) character to start a comment such as you would in a zone
|
||||
file. The semicolon indicates the end of a configuration statement,
|
||||
so whatever follows it will be interpreted as the start of the next
|
||||
statement.</P>
|
||||
|
||||
<HR>
|
||||
|
||||
<CENTER><P>[ <A HREF="config.html">BIND Config. File</A>
|
||||
| <A HREF="http://www.vix.com/isc/bind.html">BIND Home</A>
|
||||
| <A HREF="http://www.isc.org">ISC</A> ]</P></CENTER>
|
||||
|
||||
<HR>
|
||||
<ADDRESS>
|
||||
Last Updated: $Id: comments.html,v 1.4 1998/03/21 01:03:11 halley Exp $
|
||||
</ADDRESS>
|
||||
</BODY>
|
||||
</HTML>
|
||||
83
contrib/bind/doc/html/config.html
Normal file
83
contrib/bind/doc/html/config.html
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>BIND Configuration File Guide</TITLE>
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<H2>BIND Configuration File Guide</H2>
|
||||
|
||||
<HR>
|
||||
|
||||
<H3>Overview</H3>
|
||||
|
||||
<P>BIND 8 is much more configurable than previous release of BIND.
|
||||
There are entirely new areas of configuration, such as access control lists
|
||||
and categorized logging. Many options that previously applied to all zones
|
||||
can now be used selectively. These features, plus a consideration of future
|
||||
configuration needs led to the creation of a new configuration file format.
|
||||
|
||||
<H3>The Configuration File</H3>
|
||||
|
||||
<H4><A HREF="example.html">Example Configuration</A></H4>
|
||||
|
||||
<H4>Statements</H4>
|
||||
|
||||
<P>A BIND 8 configuration consists of statements and comments.
|
||||
Statements end with a semicolon. Many statements contain a block of
|
||||
substatements, which are also terminated with a semicolon.</P>
|
||||
|
||||
<P>The following statements are supported:
|
||||
<DL>
|
||||
<DT><CODE><A HREF="acl.html">acl</A></CODE>
|
||||
<DD>
|
||||
defines a named IP address matching list, for access control and other uses
|
||||
|
||||
<DT><CODE><A HREF="include.html">include</A></CODE>
|
||||
<DD>
|
||||
includes a file
|
||||
|
||||
<DT><CODE><A HREF="key.html">key</A></CODE>
|
||||
<DD>
|
||||
specifies key information for use in authentication and authorization
|
||||
|
||||
<DT><CODE><A HREF="logging.html">logging</A></CODE>
|
||||
<DD>
|
||||
specifies what the server logs, and where the log messages are sent
|
||||
|
||||
<DT><CODE><A HREF="options.html">options</A></CODE>
|
||||
<DD>
|
||||
controls global server configuation options and sets defaults for other
|
||||
statements
|
||||
|
||||
<DT><CODE><A HREF="server.html">server</A></CODE>
|
||||
<DD>
|
||||
sets certain configuration options on a per-server basis
|
||||
|
||||
<DT><CODE><A HREF="zone.html">zone</A></CODE>
|
||||
<DD>
|
||||
defines a zone
|
||||
</DL>
|
||||
|
||||
<P>The <CODE>logging</CODE> and <CODE>options</CODE> statements may only
|
||||
occur once per configuration.
|
||||
|
||||
<H4><A HREF="comments.html">Comments</A></H4>
|
||||
|
||||
<H3>Converting from BIND 4.9.x</H3>
|
||||
|
||||
<P>BIND 4.9.x configuration files can be converted to the new format
|
||||
by using <CODE>src/bin/named/named-bootconf.pl</CODE>, a perl script that
|
||||
is part of the BIND 8.1 source kit.
|
||||
|
||||
<HR>
|
||||
|
||||
<CENTER><P>[ <A HREF="http://www.vix.com/isc/bind.html">BIND Home</A>
|
||||
| <A HREF="http://www.isc.org">ISC</A> ]</P></CENTER>
|
||||
|
||||
<HR>
|
||||
<ADDRESS>
|
||||
Last Updated: $Id: config.html,v 1.4 1998/03/21 01:03:11 halley Exp $
|
||||
</ADDRESS>
|
||||
</BODY>
|
||||
</HTML>
|
||||
112
contrib/bind/doc/html/docdef.html
Normal file
112
contrib/bind/doc/html/docdef.html
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>BIND Documentation Definitions</TITLE>
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<H2>BIND Configuration File Guide--Documentation Definitions</H2>
|
||||
|
||||
<HR>
|
||||
|
||||
<H3>Syntactic Miscellany</H3>
|
||||
|
||||
<P>Described below are elements used throughout the BIND configuration
|
||||
file documentation. Elements which are only associated with one
|
||||
statement are described only in the section describing that statement.
|
||||
|
||||
<DL>
|
||||
<DT><VAR>acl_name</VAR>
|
||||
<DD>
|
||||
The name of an <A HREF="address_list.html">address match list</A>,
|
||||
as defined by the <A HREF="acl.html">acl</A> statement.
|
||||
|
||||
<DT><VAR>address_match_list</VAR>
|
||||
<DD>
|
||||
A list of one or more <VAR>ip_address</VAR>, <VAR>ip_prefix</VAR> or
|
||||
<VAR>acl_name</VAR> elements, as described in the
|
||||
<A HREF="address_list.html">Address Match Lists</A> section.
|
||||
|
||||
<DT><VAR>dotted-decimal</VAR>
|
||||
<DD>
|
||||
One or more integers valued 0 through 255 separated only by dots
|
||||
("."), such as <CODE>123</CODE> or <CODE>45.67</CODE> or
|
||||
<CODE>89.123.45.67</CODE>.
|
||||
|
||||
<DT><VAR>domain_name</VAR>
|
||||
<DD>
|
||||
A quoted string which will be used as a DNS name, for example
|
||||
<CODE>"my.test.domain"</CODE>.
|
||||
|
||||
<DT><VAR>path_name</VAR>
|
||||
<DD>
|
||||
A quoted string which will be used as a pathname, such as
|
||||
<CODE>"zones/master/my.test.domain"</CODE>.
|
||||
|
||||
<DT><VAR>ip_addr</VAR>
|
||||
<DD>
|
||||
An IP address in with exactly four elements in
|
||||
<VAR>dotted-decimal</VAR> notation.
|
||||
|
||||
<DT><VAR>ip_port</VAR>
|
||||
<DD>
|
||||
An IP port <VAR>number</VAR>. <VAR>number</VAR> is limited to 0
|
||||
through 65535, with values below 1024 typically restricted to
|
||||
root-owned processes.
|
||||
|
||||
<DT><VAR>ip_prefix</VAR>
|
||||
<DD>
|
||||
An IP network specified in <VAR>dotted-decimal</VAR> form, followed by "/"
|
||||
and then the number of bits in the netmask. E.g. <CODE>127/8</CODE> is
|
||||
the network <CODE>127.0.0.0</CODE> with netmask <CODE>255.0.0.0</CODE>.
|
||||
<CODE>1.2.3.0/24</CODE> is network <CODE>1.2.3.0</CODE> with netmask
|
||||
<CODE>255.255.255.0</CODE>.
|
||||
|
||||
<DT><VAR>number</VAR>
|
||||
<DD>
|
||||
A non-negative integer with an entire range limited by the range of a
|
||||
C language signed integer (2,147,483,647 on a machine with 32 bit
|
||||
integers). Its acceptable value might further be limited by the
|
||||
context in which it is used.
|
||||
|
||||
<DT><VAR>size_spec</VAR>
|
||||
<DD>
|
||||
A <VAR>number</VAR>, the word <CODE>unlimited</CODE>, or the word
|
||||
<CODE>default</CODE>.
|
||||
|
||||
<P>The maximum value of <VAR>size_spec</VAR> is that of unsigned long
|
||||
integers on the machine. <CODE>unlimited</CODE> requests unlimited use, or
|
||||
the maximum available amount. <CODE>default</CODE> uses the limit that
|
||||
was in force when the server was started.</P>
|
||||
|
||||
<P>A <VAR>number</VAR> can optionally be followed by a scaling factor:
|
||||
<CODE>K</CODE> or <CODE>k</CODE> for kilobytes, <CODE>M</CODE> or
|
||||
<CODE>m</CODE> for megabytes, and <CODE>G</CODE> or <CODE>g</CODE> for
|
||||
gigabytes, which scale by 1024, 1024*1024, and 1024*1024*1024
|
||||
respectively.
|
||||
|
||||
<P>Integer storage overflow is currently silently ignored during
|
||||
conversion of scaled values, resulting in values less than intended,
|
||||
possibly even negative. Using <CODE>unlimited</CODE> is the best way
|
||||
to safely set a really large number.</P>
|
||||
|
||||
<DT><VAR>yes_or_no</VAR>
|
||||
<DD>
|
||||
Either <CODE>yes</CODE> or <CODE>no</CODE>. The words
|
||||
<CODE>true</CODE> and <CODE>false</CODE> are also accepted, as are the
|
||||
numbers <CODE>1</CODE> and <CODE>0</CODE>.
|
||||
|
||||
</DL>
|
||||
|
||||
<HR>
|
||||
|
||||
<CENTER><P>[ <A HREF="config.html">BIND Config. File</A>
|
||||
| <A HREF="http://www.vix.com/isc/bind.html">BIND Home</A>
|
||||
| <A HREF="http://www.isc.org">ISC</A> ]</P></CENTER>
|
||||
|
||||
<HR>
|
||||
<ADDRESS>
|
||||
Last Updated: $Id: docdef.html,v 1.4 1998/03/21 01:03:12 halley Exp $
|
||||
</ADDRESS>
|
||||
</BODY>
|
||||
</HTML>
|
||||
59
contrib/bind/doc/html/example.html
Normal file
59
contrib/bind/doc/html/example.html
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>BIND Configuration File Guide -- Example Config File</TITLE>
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<H2>BIND Configuration File Guide -- Example Config File</H2>
|
||||
|
||||
<HR>
|
||||
|
||||
<PRE>
|
||||
|
||||
/*
|
||||
* A simple BIND 8 configuration
|
||||
*/
|
||||
|
||||
options {
|
||||
directory "/var/named";
|
||||
};
|
||||
|
||||
logging {
|
||||
category lame-servers { null; };
|
||||
category cname { null; };
|
||||
};
|
||||
|
||||
zone "isc.org" in {
|
||||
type master;
|
||||
file "master/isc.org";
|
||||
};
|
||||
|
||||
zone "vix.com" in {
|
||||
type slave;
|
||||
file "slave/vix.com";
|
||||
masters { 10.0.0.53; };
|
||||
};
|
||||
|
||||
zone "." in {
|
||||
type hint;
|
||||
file "named.cache";
|
||||
};
|
||||
|
||||
zone "0.0.127.in-addr.arpa" in {
|
||||
type master;
|
||||
file "master/127.0.0";
|
||||
};
|
||||
</PRE>
|
||||
|
||||
<HR>
|
||||
|
||||
<CENTER><P>[ <A HREF="http://www.vix.com/isc/bind.html">BIND Home</A>
|
||||
| <A HREF="http://www.isc.org">ISC</A> ]</P></CENTER>
|
||||
|
||||
<HR>
|
||||
<ADDRESS>
|
||||
Last Updated: $Id: example.html,v 1.1 1997/05/06 22:11:31 vixie Exp $
|
||||
</ADDRESS>
|
||||
</BODY>
|
||||
</HTML>
|
||||
53
contrib/bind/doc/html/include.html
Normal file
53
contrib/bind/doc/html/include.html
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>BIND include Statement</TITLE>
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<H2>BIND Configuration File Guide--<CODE>include</CODE> Statement</H2>
|
||||
|
||||
<HR>
|
||||
|
||||
<A NAME="Syntax"><H3>Syntax</H3></A>
|
||||
|
||||
<P><CODE>include <VAR><A HREF="docdef.html">path_name</A></VAR>;</CODE></P>
|
||||
|
||||
<HR>
|
||||
|
||||
<A Name="#Usage"><H3>Definition and Usage</H3></A>
|
||||
|
||||
<P>The <CODE>include</CODE> statement inserts the specified file at
|
||||
the point that the <CODE>include</CODE> statement is encountered. It
|
||||
cannot be used within another statement, though, so a line such as
|
||||
<CODE>acl internal_hosts { "include internal_hosts.acl" }</CODE> is
|
||||
not allowed.</P>
|
||||
|
||||
<P>Use <CODE>include</CODE> to break the configuration up into
|
||||
easily-managed chunks. For example:</P>
|
||||
|
||||
<UL COMPACT>
|
||||
<LI><CODE>include "/etc/security/keys.bind";</CODE></LI>
|
||||
<LI><CODE>include "/etc/acls.bind";</CODE></LI>
|
||||
</UL>
|
||||
|
||||
<P>could be used at the top of a BIND configuration file in order to
|
||||
include any ACL or key information.</P>
|
||||
|
||||
<P>Be careful not to type
|
||||
"<CODE>#include</CODE>", like you would in a C
|
||||
program, because "<CODE>#</CODE>" is used to start a
|
||||
comment.</P>
|
||||
|
||||
<HR>
|
||||
|
||||
<CENTER><P>[ <A HREF="config.html">BIND Config. File</A>
|
||||
| <A HREF="http://www.vix.com/isc/bind.html">BIND Home</A>
|
||||
| <A HREF="http://www.isc.org">ISC</A> ]</P></CENTER>
|
||||
|
||||
<HR>
|
||||
<ADDRESS>
|
||||
Last Updated: $Id: include.html,v 1.5 1998/03/21 01:03:12 halley Exp $
|
||||
</ADDRESS>
|
||||
</BODY>
|
||||
</HTML>
|
||||
63
contrib/bind/doc/html/index.html
Normal file
63
contrib/bind/doc/html/index.html
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>BIND Version 8 Online Documentation</TITLE>
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<H2>BIND Version 8 Online Documentation</H2>
|
||||
|
||||
<H3>BIND 8 Highlights</H3>
|
||||
|
||||
<UL>
|
||||
<LI>DNS Dynamic Updates
|
||||
(<A HREF=http://ds.internic.net/rfc/rfc2136.txt>RFC 2136</A>)</LI>
|
||||
<LI>DNS Change Notification
|
||||
(<A HREF=http://ds.internic.net/rfc/rfc1996.txt>RFC 1996</A>)</LI>
|
||||
<LI>Completely new configuration syntax</LI>
|
||||
<LI>Flexible, categorized logging system</LI>
|
||||
<LI>IP-address-based access control for queries, zone transfers, and
|
||||
updates that may be specified on a zone-by-zone basis</LI>
|
||||
<LI>More efficient zone transfers</LI>
|
||||
<LI>Improved performance for servers with thousands of zones</LI>
|
||||
<LI>The server no longer forks for outbound zone transfers</LI>
|
||||
<LI>Many bug fixes</LI>
|
||||
</UL>
|
||||
|
||||
<H3><A HREF="config.html">Configuration File Guide</A></H3>
|
||||
|
||||
<H3>Kits</H3>
|
||||
<UL>
|
||||
<LI><A HREF="ftp://ftp.isc.org/isc/bind/src/cur">
|
||||
The latest production release</A></LI>
|
||||
<LI><A HREF="ftp://ftp.isc.org/isc/bind/src/testing">
|
||||
The latest public test release</A></LI>
|
||||
</UL>
|
||||
|
||||
<H3>Bug Reports and Comments</H3>
|
||||
<P>Send bug reports to
|
||||
<A HREF="mailto:bind-bugs@isc.org">bind-bugs@isc.org</A>.
|
||||
|
||||
<H3>DNS Related Newsgroups</H3>
|
||||
<UL>
|
||||
<LI><A HREF="news:comp.protocols.dns.bind">Using BIND</A></LI>
|
||||
<LI><A HREF="news:comp.protocols.dns.ops">DNS Operations</A></LI>
|
||||
<LI><A HREF="news:comp.protocols.dns.std">DNS Standards</A></LI>
|
||||
</UL>
|
||||
|
||||
<H3><A HREF="http://www.isc.org/">The Internet Software Consortium</A></H3>
|
||||
|
||||
BIND is supported by the Internet Software Consortium, and
|
||||
although it is free for use and redistribution and incorporation into
|
||||
vendor products and export and anything else you can think of, it
|
||||
costs money to produce. That money comes from ISPs, hardware and
|
||||
software vendors, companies who make extensive use of the software,
|
||||
and generally kind hearted folk such as yourself.
|
||||
|
||||
<HR>
|
||||
<ADDRESS>
|
||||
Last Updated: $Id: index.html,v 1.4 1998/03/21 01:03:12 halley Exp $
|
||||
</ADDRESS>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
||||
50
contrib/bind/doc/html/key.html
Normal file
50
contrib/bind/doc/html/key.html
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>BIND key Statement</TITLE>
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<H2>BIND Configuration File Guide--<CODE>key</CODE> Statement</H2>
|
||||
|
||||
<HR>
|
||||
|
||||
<A NAME="Syntax"><H3>Syntax</H3></A>
|
||||
|
||||
<PRE>
|
||||
key <VAR>key_id</VAR> {
|
||||
algorithm <VAR>algorithm_id</VAR>;
|
||||
secret <VAR>secret_string</VAR>;
|
||||
};
|
||||
</PRE>
|
||||
|
||||
<HR>
|
||||
|
||||
<A NAME="Usage"><H3>Definition and Usage</H3></A>
|
||||
|
||||
<P>The <CODE>key</CODE> statement defines a key ID which can be used
|
||||
in a <A HREF="server.html"><CODE>server</CODE> statement</A> to
|
||||
associate an authentication method with a particular name server.
|
||||
|
||||
<P>A key ID must be created with the <CODE>key</CODE>
|
||||
statement before it can be used in a <CODE>server</CODE>
|
||||
definition.</P>
|
||||
|
||||
<P>The <VAR>algorithm_id</VAR> is a string that specifies a
|
||||
security/authentication algorithm.
|
||||
<VAR>secret_string</VAR> is the secret to be used by the algorithm.
|
||||
|
||||
<P>The <CODE>key</CODE> statement is intended for future use by the
|
||||
server. It is checked for syntax but is otherwise ignored.
|
||||
<HR>
|
||||
|
||||
<CENTER><P>[ <A HREF="config.html">BIND Config. File</A>
|
||||
| <A HREF="http://www.vix.com/isc/bind.html">BIND Home</A>
|
||||
| <A HREF="http://www.isc.org">ISC</A> ]</P></CENTER>
|
||||
|
||||
<HR>
|
||||
<ADDRESS>
|
||||
Last Updated: $Id: key.html,v 1.5 1998/03/21 01:03:13 halley Exp $
|
||||
</ADDRESS>
|
||||
</BODY>
|
||||
</HTML>
|
||||
346
contrib/bind/doc/html/logging.html
Normal file
346
contrib/bind/doc/html/logging.html
Normal file
|
|
@ -0,0 +1,346 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>BIND logging Statement</TITLE>
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<H2>BIND Configuration File Guide -- <CODE>logging</CODE> Statement</H2>
|
||||
|
||||
<HR>
|
||||
|
||||
<A NAME="Syntax"><H3>Syntax</H3></A>
|
||||
|
||||
<PRE>
|
||||
logging {
|
||||
[ channel <VAR>channel_name</VAR> {
|
||||
( file <VAR><A HREF="docdef.html">path_name</A></VAR>
|
||||
[ versions ( <VAR>number</VAR> | unlimited ) ]
|
||||
[ size <VAR><A HREF="docdef.html">size_spec</A></VAR> ]
|
||||
| syslog ( kern | user | mail | daemon | auth | syslog | lpr |
|
||||
news | uucp | cron | authpriv | ftp |
|
||||
local0 | local1 | local2 | local3 |
|
||||
local4 | local5 | local6 | local7 )
|
||||
| null );
|
||||
|
||||
[ severity ( critical | error | warning | notice |
|
||||
info | debug [ <VAR>level</VAR> ] | dynamic ); ]
|
||||
[ print-category <VAR><A HREF="docdef.html">yes_or_no</A></VAR>; ]
|
||||
[ print-severity <VAR><A HREF="docdef.html">yes_or_no</A></VAR>; ]
|
||||
[ print-time <VAR><A HREF="docdef.html">yes_or_no</A></VAR>; ]
|
||||
}; ]
|
||||
|
||||
[ category <VAR>category_name</VAR> {
|
||||
<VAR>channel_name</VAR>; [ <VAR>channel_name</VAR>; ... ]
|
||||
}; ]
|
||||
...
|
||||
};
|
||||
</PRE>
|
||||
|
||||
<A NAME="Usage"><H3>Definition and Usage</H3></A>
|
||||
|
||||
<P>The <CODE>logging</CODE> statement configures a wide variety of
|
||||
logging options for the nameserver. Its <CODE>channel</CODE> phrase
|
||||
associates output methods, format options and severity levels with
|
||||
a name that can then be used with the <CODE>category</CODE> phrase to
|
||||
select how various classes of messages are logged.</P>
|
||||
|
||||
<P>Only one <CODE>logging</CODE> statement is used to define as many
|
||||
channels and categories as are wanted. If there are multiple logging
|
||||
statements in a configuration, the first defined determines the logging,
|
||||
and warnings are issued for the others. If there is no logging statement,
|
||||
the logging configuration will be:</P>
|
||||
|
||||
<PRE>
|
||||
logging {
|
||||
category default { default_syslog; default_debug; };
|
||||
category panic { default_syslog; default_stderr; };
|
||||
category packet { default_debug; };
|
||||
category eventlib { default_debug; };
|
||||
};
|
||||
</PRE>
|
||||
|
||||
<H4>The <CODE>channel</CODE> phrase</H4>
|
||||
|
||||
<P>All log output goes to one or more "channels"; you can make as many
|
||||
of them as you want.</P>
|
||||
|
||||
<P>Every channel definition must include a clause that says whether
|
||||
messages selected for the channel go to a file, to a particular syslog
|
||||
facility, or are discarded. It can optionally also limit the message
|
||||
severity level that will be accepted by the channel (default is
|
||||
"info"), and whether to include a <CODE>named</CODE>-generated time
|
||||
stamp, the category name and/or severity level (default is not to
|
||||
include any).</P>
|
||||
|
||||
<P>The word <CODE>null</CODE> as the destination option for the
|
||||
channel will cause all messages sent to it to be discarded; other
|
||||
options for the channel are meaningless.</P>
|
||||
|
||||
<P>The <CODE>file</CODE> clause can include limitations both on how
|
||||
large the file is allowed to become, and how many versions of the file
|
||||
will be saved each time the file is opened.
|
||||
|
||||
<P>The <CODE>size</CODE> option for files is simply a hard ceiling on
|
||||
log growth. If the file ever exceeds the size, then
|
||||
<CODE>named</CODE> will just not write anything more to it until the
|
||||
file is reopened; exceeding the size does not automatically trigger a
|
||||
reopen. The default behavior is to not limit the size of the file.</P>
|
||||
|
||||
<P>If you use the <CODE>version</CODE> logfile option, then
|
||||
<CODE>named</CODE> will retain that many backup versions of the file
|
||||
by renaming them when opening. For example, if you choose to keep 3
|
||||
old versions of the file "lamers.log" then just before it is opened
|
||||
lamers.log.1 is renamed to lames.log.2, lamers.log.0 is renamed to
|
||||
lamers.log.1, and lamers.log is renamed to lamers.log.0. No rolled
|
||||
versions are kept by default. The <CODE>unlimited</CODE> keyword is
|
||||
synonymous with <CODE>99</CODE> in current BIND releases.</P>
|
||||
|
||||
<P>The argument for the <CODE>syslog</CODE> clause is a syslog
|
||||
facility as described in the <CODE>syslog</CODE> manual page. How
|
||||
<CODE>syslogd</CODE> will handle messages sent to this facility is
|
||||
described in the <CODE>syslog.conf</CODE> manual page. If you have a
|
||||
system which uses a very old version of <CODE>syslog</CODE> that only
|
||||
uses two arguments to the <CODE>openlog()</CODE> function, then this
|
||||
clause is silently ignored.</P>
|
||||
|
||||
<P>The <CODE>severity</CODE> clause works like <CODE>syslog</CODE>'s
|
||||
"priorities", except that they can also be used if you are writing
|
||||
straight to a file rather than using <CODE>syslog</CODE>. Messages
|
||||
which are not at least of the severity level given will not be
|
||||
selected for the channel; messages of higher severity levels will be
|
||||
accepted.</P>
|
||||
|
||||
<P>If you are using <CODE>syslog</CODE>, then the
|
||||
<CODE>syslog.conf</CODE> priorities will also determine what
|
||||
eventually passes through. For example, defining a channel facility
|
||||
and severity as <CODE>daemon</CODE> and <CODE>debug</CODE> but only
|
||||
logging <CODE>daemon.warning</CODE> via <CODE>syslog.conf</CODE> will
|
||||
cause messages of severity <CODE>info</CODE> and <CODE>notice</CODE>
|
||||
to be dropped. If the situation were reversed, with
|
||||
<CODE>named</CODE> writing messages of only <CODE>warning</CODE> or
|
||||
higher, then <CODE>syslogd</CODE> would print all messages it received
|
||||
from the channel.</P>
|
||||
|
||||
<P>The server can supply extensive debugging information when it is in
|
||||
debugging mode. If the server's global debug level is greater than
|
||||
zero, then debugging mode will be active. The global debug level is
|
||||
set either by starting the server with the "-d" flag followed by a
|
||||
positive integer, or by sending the server the SIGUSR1 signal (for
|
||||
example, by using "ndc trace"). The global debug level can be set to
|
||||
zero, and debugging mode turned off, by sending the server the SIGUSR2
|
||||
signal ("ndc notrace". All debugging messages in the server have a
|
||||
debug level, and higher debug levels give more more detailed output.
|
||||
Channels that specify a specific debug severity, e.g.
|
||||
|
||||
<PRE>
|
||||
channel specific_debug_level {
|
||||
file "foo";
|
||||
severity debug 3;
|
||||
};
|
||||
</PRE>
|
||||
|
||||
<P>will get debugging output of level 3 or less any time the
|
||||
server is in debugging mode, regardless of the global debugging level.
|
||||
Channels with <code>dynamic</code> severity use the server's global
|
||||
level to determine what messages to print.
|
||||
|
||||
<P>If <CODE>print-time</CODE> has been turned on, then the date and
|
||||
time will be logged. <CODE>print-time</CODE> may be specified for a
|
||||
syslog channel, but is usually pointless since syslog also prints the
|
||||
date and time. If <CODE>print-category</CODE> is requested,
|
||||
then the category of the message will be logged as well. Finally, if
|
||||
<CODE>print-severity</CODE> is on, then the severity level of the
|
||||
message will be logged. The <CODE>print-</CODE> options may be used
|
||||
in any combination, and will always be printed in the following order:
|
||||
time, category, severity. Here is an example where all three
|
||||
<CODE>print-</CODE> options are on:
|
||||
|
||||
<PRE>
|
||||
28-Apr-1997 15:05:32.863 default: notice: Ready to answer queries.
|
||||
</PRE>
|
||||
|
||||
<P>There are four predefined channels that are used for
|
||||
<CODE>named</CODE>'s default logging as follows. How they are used
|
||||
used is described in the next section, The <CODE>category</CODE> phrase.
|
||||
|
||||
<PRE>
|
||||
channel default_syslog {
|
||||
syslog daemon; # send to syslog's daemon facility
|
||||
severity info; # only send priority info and higher
|
||||
};
|
||||
|
||||
channel default_debug {
|
||||
file "named.run"; # write to named.run in the working directory
|
||||
severity dynamic; # log at the server's current debug level
|
||||
};
|
||||
|
||||
channel default_stderr { # writes to stderr
|
||||
file "<stderr>"; # this is illustrative only; there's currently
|
||||
# no way of specifying an internal file
|
||||
# descriptor in the configuration language.
|
||||
severity info; # only send priority info and higher
|
||||
};
|
||||
|
||||
channel null {
|
||||
null; # toss anything sent to this channel
|
||||
};
|
||||
</PRE>
|
||||
|
||||
<P>Once a channel is defined, it cannot be redefined. Thus you cannot
|
||||
alter the built-in channels directly, but you can modify the default
|
||||
logging by pointing categories at channels you have defined.</P>
|
||||
|
||||
<H4>The <CODE>category</CODE> phrase</H4>
|
||||
|
||||
<P>There are many categories, so you can send the logs you want to see
|
||||
wherever you want, without seeing logs you don't want. If you don't specify
|
||||
a list of channels for a category, then log messages in that category will
|
||||
be sent to the <CODE>default</CODE> category instead. If you don't specify
|
||||
a default category, the following "default default" is used:
|
||||
|
||||
<PRE>
|
||||
category default { default_syslog; default_debug; };
|
||||
</PRE>
|
||||
|
||||
<P>As an example, let's say you want to log security events to a file,
|
||||
but you also want keep the default logging behavior. You'd specify the
|
||||
following:
|
||||
|
||||
<PRE>
|
||||
channel my_security_channel {
|
||||
file "my_security_file";
|
||||
severity info;
|
||||
};
|
||||
category security { my_security_channel; default_syslog; default_debug; };
|
||||
</PRE>
|
||||
|
||||
<P>To discard all messages in a category, specify the
|
||||
<CODE>null</CODE> channel:
|
||||
|
||||
<PRE>
|
||||
category lame-servers { null; };
|
||||
category cname { null; };
|
||||
</PRE>
|
||||
|
||||
<P>The following
|
||||
categories are available:</P>
|
||||
|
||||
<DL>
|
||||
<DT><CODE>default</CODE>
|
||||
<DD>
|
||||
The catch-all. Many things still aren't classified into categories,
|
||||
and they all end up here. Also, if you don't specify any channels for
|
||||
a category, the default category is used instead. If you do not
|
||||
define the default category, the following definition is used:
|
||||
<CODE>category default { default_syslog; default_debug; };</CODE>
|
||||
|
||||
<DT><CODE>config</CODE>
|
||||
<DD>
|
||||
High-level configuration file processing.
|
||||
|
||||
<DT><CODE>parser</CODE>
|
||||
<DD>
|
||||
Low-level configuration file processing.
|
||||
|
||||
<DT><CODE>queries</CODE>
|
||||
<DD>
|
||||
A short log message is generated for every query the server receives.
|
||||
|
||||
<DT><CODE>lame-servers</CODE>
|
||||
<DD>
|
||||
Messages like "Lame server on ..."
|
||||
|
||||
<DT><CODE>statistics</CODE>
|
||||
<DD>
|
||||
Statistics.
|
||||
|
||||
<DT><CODE>panic</CODE>
|
||||
<DD>
|
||||
If the server has to shut itself down due to an internal problem, it
|
||||
will log the problem in this category as well as in the problem's native
|
||||
category. If you do not define the panic category, the following definition
|
||||
is used: <CODE>category panic { default_syslog; default_stderr; };</CODE>
|
||||
|
||||
<DT><CODE>update</CODE>
|
||||
<DD>
|
||||
Dynamic updates.
|
||||
|
||||
<DT><CODE>ncache</CODE>
|
||||
<DD>
|
||||
Negative caching.
|
||||
|
||||
<DT><CODE>xfer-in</CODE>
|
||||
<DD>
|
||||
Zone transfers the server is receiving.
|
||||
|
||||
<DT><CODE>xfer-out</CODE>
|
||||
<DD>
|
||||
Zone transfers the server is sending.
|
||||
|
||||
<DT><CODE>db</CODE>
|
||||
<DD>
|
||||
All database operations.
|
||||
|
||||
<DT><CODE>eventlib</CODE>
|
||||
<DD>
|
||||
Debugging info from the event system. Only one channel may be specified for
|
||||
this category, and it must be a file channel. If you do not define the
|
||||
eventlib category, the following definition is used: <CODE>category eventlib
|
||||
{ default_debug; };</CODE>
|
||||
|
||||
<DT><CODE>packet</CODE>
|
||||
<DD>
|
||||
Dumps of packets received and sent. Only one channel may be specified for
|
||||
this category, and it must be a file channel. If you do not define the
|
||||
packet category, the following definition is used: <CODE>category packet
|
||||
{ default_debug; };</CODE>
|
||||
|
||||
<DT><CODE>notify</CODE>
|
||||
<DD>
|
||||
The NOTIFY protocol.
|
||||
|
||||
<DT><CODE>cname</CODE>
|
||||
<DD>
|
||||
Messages like "... points to a CNAME".
|
||||
|
||||
<DT><CODE>security</CODE>
|
||||
<DD>
|
||||
Approved/unapproved requests.
|
||||
|
||||
<DT><CODE>os</CODE>
|
||||
<DD>
|
||||
Operating system problems.
|
||||
|
||||
<DT><CODE>insist</CODE>
|
||||
<DD>
|
||||
Internal consistency check failures.
|
||||
|
||||
<DT><CODE>maintenance</CODE>
|
||||
<DD>
|
||||
Periodic maintenance events.
|
||||
|
||||
<DT><CODE>load</CODE>
|
||||
<DD>
|
||||
Zone loading messages.
|
||||
|
||||
<DT><CODE>response-checks</CODE>
|
||||
<DD>
|
||||
Messages arising from response checking, such as
|
||||
"Malformed response ...", "wrong ans. name ...",
|
||||
"unrelated additional info ...", "invalid RR type ...", and "bad referral ...".
|
||||
|
||||
</DL>
|
||||
|
||||
<HR>
|
||||
|
||||
<CENTER><P>[ <A HREF="config.html">BIND Config. File</A>
|
||||
| <A HREF="http://www.vix.com/isc/bind.html">BIND Home</A>
|
||||
| <A HREF="http://www.isc.org">ISC</A> ]</P></CENTER>
|
||||
|
||||
<HR>
|
||||
<ADDRESS>
|
||||
Last Updated: $Id: logging.html,v 1.6 1998/03/21 01:03:13 halley Exp $
|
||||
</ADDRESS>
|
||||
</BODY>
|
||||
</HTML>
|
||||
462
contrib/bind/doc/html/options.html
Normal file
462
contrib/bind/doc/html/options.html
Normal file
|
|
@ -0,0 +1,462 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>BIND options Statement</TITLE>
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<H2>BIND Configuration File Guide -- <CODE>options</CODE> Statement</H2>
|
||||
|
||||
<HR>
|
||||
|
||||
<A NAME="Syntax"><H3>Syntax</H3></A>
|
||||
|
||||
<PRE>
|
||||
options {
|
||||
[ directory <VAR>path_name</VAR>; ]
|
||||
[ named-xfer <VAR>path_name</VAR>; ]
|
||||
[ dump-file <VAR>path_name</VAR>; ]
|
||||
[ memstatistics-file <VAR>path_name</VAR>; ]
|
||||
[ pid-file <VAR>path_name</VAR>; ]
|
||||
[ statistics-file <VAR>path_name</VAR>; ]
|
||||
[ auth-nxdomain <VAR><A HREF="docdef.html">yes_or_no</A></VAR>; ]
|
||||
[ deallocate-on-exit <VAR><A HREF="docdef.html">yes_or_no</A></VAR>; ]
|
||||
[ fake-iquery <VAR><A HREF="docdef.html">yes_or_no</A></VAR>; ]
|
||||
[ fetch-glue <VAR><A HREF="docdef.html">yes_or_no</A></VAR>; ]
|
||||
[ multiple-cnames <VAR><A HREF="docdef.html">yes_or_no</A></VAR>; ]
|
||||
[ notify <VAR><A HREF="docdef.html">yes_or_no</A></VAR>; ]
|
||||
[ recursion <VAR><A HREF="docdef.html">yes_or_no</A></VAR>; ]
|
||||
[ forward ( only | first ); ]
|
||||
[ forwarders { [ <VAR><A HREF="docdef.html">in_addr</A></VAR> ; [ <VAR><A HREF="docdef.html">in_addr</A></VAR> ; ... ] ] }; ]
|
||||
[ check-names ( master | slave | response ) ( warn | fail | ignore); ]
|
||||
[ allow-query { <VAR>address_match_list</VAR> }; ]
|
||||
[ allow-transfer { <VAR>address_match_list</VAR> }; ]
|
||||
[ listen-on [ port <VAR><A HREF="docdef.html">ip_port</A></VAR> ] { <VAR>address_match_list</VAR> }; ]
|
||||
[ query-source [ address ( <VAR><A HREF="docdef.html">ip_addr</A></VAR> | * ) ] [ port ( <VAR><A HREF="docdef.html">ip_port</A></VAR> | * ) ] ; ]
|
||||
[ max-transfer-time-in <VAR>number</VAR>; ]
|
||||
[ transfer-format ( one-answer | many-answers ); ]
|
||||
[ transfers-in <VAR>number</VAR>; ]
|
||||
[ transfers-out <VAR>number</VAR>; ]
|
||||
[ transfers-per-ns <VAR>number</VAR>; ]
|
||||
[ coresize <VAR><A HREF="docdef.html">size_spec</A></VAR> ; ]
|
||||
[ datasize <VAR><A HREF="docdef.html">size_spec</A></VAR> ; ]
|
||||
[ files <VAR><A HREF="docdef.html">size_spec</A></VAR> ; ]
|
||||
[ stacksize <VAR><A HREF="docdef.html">size_spec</A></VAR> ; ]
|
||||
[ cleaning-interval <VAR>number</VAR>; ]
|
||||
[ interface-interval <VAR>number</VAR>; ]
|
||||
[ statistics-interval <VAR>number</VAR>; ]
|
||||
[ topology { <VAR>address_match_list</VAR> }; ]
|
||||
};
|
||||
</PRE>
|
||||
<HR>
|
||||
|
||||
<A NAME="Usage"><H3>Definition and Use</H3></A>
|
||||
|
||||
<P>The options statement sets up global options to be used by
|
||||
BIND. This statement may appear at only once in a
|
||||
configuration file; if more than one occurrence is found, the
|
||||
first occurrence determines the actual options used,
|
||||
and a warning will be generated. If there is no options statement,
|
||||
an options block with each option set to its default will be used.</P>
|
||||
|
||||
<H4>Pathnames</H4>
|
||||
|
||||
<DL>
|
||||
<DT><CODE>directory</CODE>
|
||||
<DD>
|
||||
The working directory of the server. Any non-absolute
|
||||
pathnames in the configuration file will be taken as relative to this
|
||||
directory. The default location for most server output files
|
||||
(e.g. "named.run") is this directory. If a directory is not
|
||||
specified, the working directory defaults to ".", the directory from which the
|
||||
server was started. The directory specified should be an absolute path.
|
||||
|
||||
<DT><CODE>named-xfer</CODE>
|
||||
<DD>
|
||||
The pathname to the named-xfer program that the server uses for
|
||||
inbound zone transfers. If not specified, the default is
|
||||
system dependent (e.g. "/usr/sbin/named-xfer").
|
||||
|
||||
<DT><CODE>dump-file</CODE>
|
||||
<DD>
|
||||
The pathname of the file the server dumps the database to when it
|
||||
receives <CODE>SIGINT</CODE> signal (<CODE>ndc dumpdb</CODE>). If not
|
||||
specified, the default is "named_dump.db".
|
||||
|
||||
<DT><CODE>memstatistics-file</CODE>
|
||||
<DD>
|
||||
The pathname of the file the server writes memory usage statistics to on exit,
|
||||
if <CODE>deallocate-on-exit</CODE> is <CODE>yes</CODE>. If not
|
||||
specified, the default is "named.memstats".
|
||||
|
||||
<DT><CODE>pid-file</CODE>
|
||||
<DD>
|
||||
The pathname of the file the server writes its process ID in. If not
|
||||
specified, the default is operating system dependent, but is usually
|
||||
"/var/run/named.pid" or "/etc/named.pid". The pid-file is used by
|
||||
programs like "ndc" that want to send signals to the running
|
||||
nameserver.
|
||||
|
||||
<DT><CODE>statistics-file</CODE>
|
||||
<DD>
|
||||
The pathname of the file the server appends statistics to when it
|
||||
receives <CODE>SIGILL</CODE> signal (<CODE>ndc stats</CODE>). If not
|
||||
specified, the default is "named.stats".
|
||||
</DL>
|
||||
|
||||
<A name="BooleanOptions"><H4>Boolean Options</H4></A>
|
||||
|
||||
<DL>
|
||||
<DT><CODE>auth-nxdomain</CODE>
|
||||
<DD>
|
||||
If <CODE>yes</CODE>, then the <CODE>AA</CODE> bit is always set on
|
||||
NXDOMAIN responses, even if the server is not actually authoritative.
|
||||
The default is <CODE>yes</CODE>. Do not turn off
|
||||
<CODE>auth-nxdomain</CODE> unless you are sure you know what you are
|
||||
doing, as some older software won't like it.
|
||||
|
||||
<DT><CODE>deallocate-on-exit</CODE>
|
||||
<DD>
|
||||
If <CODE>yes</CODE>, then when the server exits it will painstakingly
|
||||
deallocate every object it allocated, and then write a memory usage report to
|
||||
the <CODE>memstatistics-file</CODE>. The default is <CODE>no</CODE>, because
|
||||
it is faster to let the operating system clean up.
|
||||
<CODE>deallocate-on-exit</CODE> is handy for detecting memory leaks.
|
||||
|
||||
<DT><CODE>fake-iquery</CODE>
|
||||
<DD>
|
||||
If <CODE>yes</CODE>, the server will simulate the obsolete DNS query type
|
||||
IQUERY. The default is <CODE>no</CODE>.
|
||||
|
||||
<DT><CODE>fetch-glue</CODE>
|
||||
<DD>
|
||||
If <CODE>yes</CODE> (the default), the server will fetch "glue" resource
|
||||
records it doesn't have when constructing the additional data section of
|
||||
a response. <CODE>fetch-glue no</CODE> can be used in conjunction with
|
||||
<CODE>recursion no</CODE> to prevent the server's cache from growing or
|
||||
becoming corrupted (at the cost of requiring more work from the client).
|
||||
|
||||
<DT><CODE>multiple-cnames</CODE>
|
||||
<DD>
|
||||
If <CODE>yes</CODE>, then multiple CNAME resource records will be
|
||||
allowed for a domain name. The default is <CODE>no</CODE>. Allowing
|
||||
multiple CNAME records is against standards and is not recommended.
|
||||
Multiple CNAME support is available because previous versions of BIND
|
||||
allowed multiple CNAME records, and these records have been used for load
|
||||
balancing by a number of sites.
|
||||
|
||||
<DT><CODE>notify</CODE>
|
||||
<DD>
|
||||
If <CODE>yes</CODE> (the default), DNS NOTIFY messages are sent when a
|
||||
zone the server is authoritative for changes. The use of NOTIFY
|
||||
speeds convergence between the master and its slaves. Slave servers
|
||||
that receive a NOTIFY message and understand it will contact the
|
||||
master server for the zone and see if they need to do a zone transfer, and
|
||||
if they do, they will initiate it immediately. The <CODE>notify</CODE>
|
||||
option may also be specified in the <CODE>zone</CODE> statement, in which
|
||||
case it overrides the <CODE>options notify</CODE> statement.
|
||||
|
||||
<DT><CODE>recursion</CODE>
|
||||
<DD>
|
||||
If <CODE>yes</CODE>, and a DNS query requests recursion, then the
|
||||
server will attempt to do all the work required to answer the query.
|
||||
If recursion is not on, the server will return a referral to the
|
||||
client if it doesn't know the answer. The default is <CODE>yes</CODE>.
|
||||
See also <CODE>fetch-glue</CODE> above.
|
||||
</DL>
|
||||
|
||||
<H4>Forwarding</H4>
|
||||
|
||||
<P>The forwarding facility can be used to create a large sitewide
|
||||
cache on a few servers, reducing traffic over links to external
|
||||
nameservers. It can also be used to allow queries by servers that do
|
||||
not have direct access to the Internet, but wish to look up exterior
|
||||
names anyway. Forwarding occurs only on those queries for which the
|
||||
server is not authoritative and does not have the answer in its cache.
|
||||
|
||||
<DL>
|
||||
<DT><CODE>forward</CODE>
|
||||
<DD>
|
||||
This option is only meaningful if the <CODE>forwarders</CODE> list is
|
||||
not empty. A value of <CODE>first</CODE>, the default, causes the
|
||||
server to query the forwarders first, and if that doesn't answer the
|
||||
question the server will then look for the answer itself. If
|
||||
<CODE>only</CODE> is specified, the server will only query the
|
||||
forwarders.
|
||||
|
||||
<DT><CODE>forwarders</CODE>
|
||||
<DD>
|
||||
Specifies the IP addresses to be used for forwarding. The default is the
|
||||
empty list (no forwarding).
|
||||
</DL>
|
||||
|
||||
<P>Future versions of BIND 8 will provide a more powerful forwarding
|
||||
system. The syntax described above will continue to be supported.
|
||||
|
||||
<a name="NameChecking"><H4>Name Checking</H4></a>
|
||||
|
||||
<P>The server can check domain names based upon their expected client contexts.
|
||||
For example, a domain name used as a hostname can be checked for compliance
|
||||
with the RFCs defining valid hostnames.
|
||||
|
||||
<P>Three checking methods are available:
|
||||
|
||||
<DL>
|
||||
<DT><CODE>ignore</CODE>
|
||||
<DD>
|
||||
No checking is done.
|
||||
|
||||
<DT><CODE>warn</CODE>
|
||||
<DD>
|
||||
Names are checked against their expected client contexts. Invalid names are
|
||||
logged, but processing continues normally.
|
||||
|
||||
<DT><CODE>fail</CODE>
|
||||
<DD>
|
||||
Names are checked against their expected client contexts. Invalid names are
|
||||
logged, and the offending data is rejected.
|
||||
</DL>
|
||||
|
||||
<P>The server can check names three areas: master zone files, slave
|
||||
zone files, and in responses to queries the server has initiated. If
|
||||
<CODE>check-names response fail</CODE> has been specified, and
|
||||
answering the client's question would require sending an invalid name
|
||||
to the client, the server will send a REFUSED response code to the
|
||||
client.
|
||||
|
||||
<P>The defaults are:
|
||||
|
||||
<PRE>
|
||||
check-names master fail;
|
||||
check-names slave warn;
|
||||
check-names response ignore;
|
||||
</PRE>
|
||||
|
||||
<P><CODE>check-names</CODE> may also be specified in the <CODE>zone</CODE>
|
||||
statement, in which case it overrides the <CODE>options check-names</CODE>
|
||||
statement. When used in a <CODE>zone</CODE> statement, the area is not
|
||||
specified (because it can be deduced from the zone type).
|
||||
|
||||
<A name="AccessControl"><H4>Access Control</H4></A>
|
||||
|
||||
<P>Access to the server can be restricted based on the IP address of the
|
||||
requesting system. See
|
||||
<VAR><A HREF="address_list.html">address_match_list</A></VAR> for details
|
||||
on how to specify IP address lists.
|
||||
|
||||
<DL>
|
||||
<DT><CODE>allow-query</CODE>
|
||||
<DD>
|
||||
Specifies which hosts are allowed to ask ordinary questions.
|
||||
<CODE>allow-query</CODE> may also be specified in the
|
||||
<CODE>zone</CODE> statement, in which case it overrides the
|
||||
<CODE>options allow-query</CODE> statement. If not specified, the default is
|
||||
to allow queries from all hosts.
|
||||
|
||||
<DT><CODE>allow-transfer</CODE>
|
||||
<DD>
|
||||
Specifies which hosts are allowed to receive zone transfers from the
|
||||
server. <CODE>allow-transfer</CODE> may also be specified in the
|
||||
<CODE>zone</CODE> statement, in which case it overrides the
|
||||
<CODE>options allow-transfer</CODE> statement. If not specified, the default
|
||||
is to allow transfers from all hosts.
|
||||
</DL>
|
||||
|
||||
<H4>Interfaces</H4>
|
||||
|
||||
<P>The interfaces and ports that the server will answer queries from may
|
||||
be specified using the <CODE>listen-on</CODE> option. <CODE>listen-on</CODE>
|
||||
takes an optional port, and an
|
||||
<VAR><A HREF="address_list.html">address_match_list</A></VAR>. The server will
|
||||
listen on all interfaces allowed by the address match list. If a port is
|
||||
not specified, port 53 will be used.
|
||||
|
||||
<P>Multiple <CODE>listen-on</CODE> statements are allowed. For example,
|
||||
|
||||
<PRE>
|
||||
listen-on { 5.6.7.8; };
|
||||
listen-on port 1234 { !1.2.3.4; 1.2/16; };
|
||||
</PRE>
|
||||
|
||||
<P>If no <CODE>listen-on</CODE> is specified, the server will listen on port
|
||||
53 on all interfaces.
|
||||
|
||||
<H4>Query Address</H4>
|
||||
|
||||
<P>If the server doesn't know the answer to a question, it will query
|
||||
other nameservers. <CODE>query-source</CODE> specifies the address
|
||||
and port used for such queries. If <CODE>address</CODE> is
|
||||
<CODE>*</CODE> or is omitted, a wildcard IP address
|
||||
(<CODE>INADDR_ANY</CODE>) will be used. If <CODE>port</CODE> is
|
||||
<CODE>*</CODE> or is omitted, a random unprivileged port will be used.
|
||||
The default is
|
||||
|
||||
<PRE>
|
||||
query-source address * port *;
|
||||
</PRE>
|
||||
|
||||
<P>Note: <CODE>query-source</CODE> currently applies only to UDP queries;
|
||||
TCP queries always use a wildcard IP address and a random unprivileged
|
||||
port.
|
||||
|
||||
<A name="ZoneTransfers"><H4>Zone Transfers</H4></A>
|
||||
|
||||
<DL>
|
||||
<DT><CODE>max-transfer-time-in</CODE>
|
||||
<DD>
|
||||
Inbound zone transfers (<CODE>named-xfer</CODE> processes) running
|
||||
longer than this many minutes will be terminated. The default is 120
|
||||
minutes (2 hours).
|
||||
|
||||
<DT><CODE>transfer-format</CODE>
|
||||
<DD>
|
||||
The server supports two zone transfer methods.
|
||||
<CODE>one-answer</CODE> uses one DNS message per resource record
|
||||
transferred. <CODE>many-answers</CODE> packs as many resource records
|
||||
as possible into a message. <CODE>many-answers</CODE> is more
|
||||
efficient, but is only known to be understood by BIND 8.1 and patched
|
||||
versions of BIND 4.9.5. The default is <CODE>one-answer</CODE>.
|
||||
<CODE>transfer-format</CODE> may be
|
||||
overridden on a per-server basis by using the <CODE>server</CODE> statement.
|
||||
|
||||
<DT><CODE>transfers-in</CODE>
|
||||
<DD>
|
||||
The maximum number of inbound zone transfers that can be running
|
||||
concurrently. The default value is 10. Increasing
|
||||
<CODE>transfers-in</CODE> may speed up the convergence of slave zones,
|
||||
but it also may increase the load on the local system.
|
||||
|
||||
<DT><CODE>transfers-out</CODE>
|
||||
<DD>
|
||||
This option will be used in the future to limit the number of
|
||||
concurrent outbound zone transfers. It is checked for syntax, but is
|
||||
otherwise ignored.
|
||||
|
||||
<DT><CODE>transfers-per-ns</CODE>
|
||||
<DD>
|
||||
The maximum number of inbound zone transfers (<CODE>named-xfer</CODE>
|
||||
processes) that can be concurrently transferring from a given remote
|
||||
nameserver. The default value is 2. Increasing
|
||||
<CODE>transfers-per-ns</CODE> may speed up the convergence of slave
|
||||
zones, but it also may increase the load on the remote nameserver.
|
||||
<CODE>transfers-per-ns</CODE> may be overridden on a per-server basis
|
||||
by using the <CODE>transfers</CODE> phrase of the <CODE>server</CODE>
|
||||
statement.
|
||||
</DL>
|
||||
|
||||
<H4>Resource Limits</H4>
|
||||
|
||||
<P>The server's usage of many system resources can be limited. Some
|
||||
operating systems don't support some of the limits. On such systems,
|
||||
a warning will be issued if the unsupported limit is used. Some
|
||||
operating systems don't support limiting resources, and on these systems
|
||||
a <CODE>cannot set resource limits on this system</CODE> message will
|
||||
be logged.
|
||||
|
||||
<P>Scaled values are allowed when specifying resource limits. For
|
||||
example, <CODE>1G</CODE> can be used instead of
|
||||
<CODE>1073741824</CODE> to specify a limit of one gigabyte.
|
||||
<CODE>unlimited</CODE> requests unlimited use, or the maximum
|
||||
available amount. <CODE>default</CODE> uses the limit that was in
|
||||
force when the server was started. See
|
||||
<VAR><AHREF="docdef.html">size_spec</A></VAR> for more details.
|
||||
|
||||
<DL>
|
||||
<DT><CODE>coresize</CODE>
|
||||
<DD>
|
||||
The maximum size of a core dump. The default is <CODE>default</CODE>.
|
||||
|
||||
<DT><CODE>datasize</CODE>
|
||||
<DD>
|
||||
The maximum amount of data memory the server may use. The default is
|
||||
<CODE>default</CODE>.
|
||||
|
||||
<DT><CODE>files</CODE>
|
||||
<DD>
|
||||
The maximum number of files ther server may have open concurrently.
|
||||
The default is <CODE>unlimited</CODE>. <I>Note:</I> on some operating
|
||||
systems the server cannot set an unlimited value and cannot determine
|
||||
the maximum number of open files the kernel can support. On such
|
||||
systems, choosing <CODE>unlimited</CODE> will cause the server to use
|
||||
the larger of the <CODE>rlim_max</CODE> for <CODE>RLIMIT_NOFILE</CODE>
|
||||
and the value returned by <CODE>sysconf(_SC_OPEN_MAX)</CODE>. If the
|
||||
actual kernel limit is larger than this value, use <CODE>limit
|
||||
files</CODE> to specify the limit explicitly.
|
||||
|
||||
<DT><CODE>stacksize</CODE>
|
||||
<DD>
|
||||
The maximum amount of stack memory the server may use. The default is
|
||||
<CODE>default</CODE>.
|
||||
</DL>
|
||||
|
||||
<H4>Periodic Task Intervals</H4>
|
||||
|
||||
<DL>
|
||||
<DT><CODE>cleaning-interval</CODE>
|
||||
<DD>
|
||||
The server will remove expired resource records from the cache every
|
||||
<CODE>cleaning-interval</CODE> minutes. The default is 60 minutes. If set
|
||||
to 0, no periodic cleaning will occur.
|
||||
|
||||
<DT><CODE>interface-interval</CODE>
|
||||
<DD>
|
||||
The server will scan the network interface list every
|
||||
<CODE>interface-interval</CODE> minutes. The default is 60 minutes.
|
||||
If set to 0, interface scanning will only occur when the configuration
|
||||
file is loaded. After the scan, listeners will be started on any new
|
||||
interfaces (provided they are allowed by the <CODE>listen-on</CODE>
|
||||
configuration). Listeners on interfaces that have gone away will be
|
||||
cleaned up.
|
||||
|
||||
<DT><CODE>statistics-interval</CODE>
|
||||
<DD>
|
||||
Nameserver statisitics will be logged every <CODE>statistics-interval</CODE>
|
||||
minutes. The default is 60. If set to 0, no statistics will be logged.
|
||||
</DL>
|
||||
|
||||
<H4>Topology</H4>
|
||||
|
||||
<P>All other things being equal, when the server chooses a nameserver
|
||||
to query from a list of nameservers, it prefers the one that is
|
||||
topologically closest to itself. The <CODE>topology</CODE> statement
|
||||
takes an <VAR><A HREF="address_list.html">address_match_list</A></VAR>
|
||||
and interprets it in a special way. Each top-level list element is
|
||||
assigned a distance. Non-negated elements get a distance based on
|
||||
their position in the list, where the closer the match is to the start
|
||||
of the list, the shorter the distance is between it and the server. A
|
||||
negated match will be assigned the maximum distance from the server.
|
||||
If there is no match, the address will get a distance which is further
|
||||
than any non-negated list element, and closer than any negated
|
||||
element. For example,
|
||||
|
||||
<PRE>
|
||||
topology {
|
||||
10/8;
|
||||
!1.2.3/24;
|
||||
{ 1.2/16; 3/8; };
|
||||
};
|
||||
</PRE>
|
||||
|
||||
<P>will prefer servers on network 10 the most, followed by hosts on
|
||||
network 1.2.0.0 (netmask 255.255.0.0) and network 3, with the exception
|
||||
of hosts on network 1.2.3 (netmask 255.255.255.0), which is preferred least
|
||||
of all.
|
||||
|
||||
<P>The default topology is
|
||||
|
||||
<PRE>
|
||||
topology { localhost; localnets; };
|
||||
</PRE>
|
||||
|
||||
<HR>
|
||||
|
||||
<CENTER><P>[ <A HREF="config.html">BIND Config. File</A>
|
||||
| <A HREF="http://www.vix.com/isc/bind.html">BIND Home</A>
|
||||
| <A HREF="http://www.isc.org">ISC</A> ]</P></CENTER>
|
||||
|
||||
<HR>
|
||||
<ADDRESS>
|
||||
Last Updated: $Id: options.html,v 1.9 1998/03/21 01:02:59 halley Exp $
|
||||
</ADDRESS>
|
||||
</BODY>
|
||||
</HTML>
|
||||
62
contrib/bind/doc/html/server.html
Normal file
62
contrib/bind/doc/html/server.html
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>BIND server Statement</TITLE>
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<H2>BIND Configuration File Guide--<CODE>server</CODE> Statement</H2>
|
||||
|
||||
<HR>
|
||||
|
||||
<A NAME="Syntax"><H3>Syntax</H3></A>
|
||||
|
||||
<PRE>
|
||||
server <VAR><A HREF="docdef.html">ip_addr</A></VAR> {
|
||||
[ bogus <VAR><A HREF="docdef.html">yes_or_no</A></VAR>; ]
|
||||
[ transfers <VAR><A HREF="docdef.html">number</A></VAR>; ]
|
||||
[ transfer-format ( one-answer | many-answers ); ]
|
||||
[ keys { <VAR><A HREF="key.html">key_id</A></VAR> [<VAR>key_id</VAR> ... ] }; ]
|
||||
};
|
||||
</PRE>
|
||||
|
||||
<HR>
|
||||
|
||||
<A NAME="Usage"><H3>Definition and Usage</H3></A>
|
||||
|
||||
<P>The server statement defines the characteristics to be
|
||||
associated with a remote name server.</P>
|
||||
|
||||
<P>If you discover that a server is giving out bad data, marking it as
|
||||
<CODE>bogus</CODE> will prevent further queries to it. The default value of
|
||||
<CODE>bogus</CODE> is <CODE>no</CODE>.
|
||||
|
||||
<P>The server supports two zone transfer methods. The first,
|
||||
<CODE>one-answer</CODE>, uses one DNS message per resource record
|
||||
transferred. <CODE>many-answers</CODE> packs as many resource records
|
||||
as possible into a message. <CODE>many-answers</CODE> is more
|
||||
efficient, but is only known to be understood by BIND 8.1 and patched
|
||||
versions of BIND 4.9.5. You can specify which method to use for a
|
||||
server with the <CODE>transfer-format</CODE> option. If
|
||||
<CODE>transfer-format</CODE> is not specified, the <CODE>transfer-format</CODE>
|
||||
specified by the <CODE>options</CODE> statement will be used.
|
||||
|
||||
<P>The <CODE>transfers</CODE> will be used in a future release of the server
|
||||
to limit the number of concurrent in-bound zone transfers from the specified
|
||||
server. It is checked for syntax but is otherwise ignored.
|
||||
|
||||
<P>The <CODE>keys</CODE> statement is intended for future use by the
|
||||
server. It is checked for syntax but is otherwise ignored.
|
||||
|
||||
<HR>
|
||||
|
||||
<CENTER><P>[ <A HREF="config.html">BIND Config. File</A>
|
||||
| <A HREF="http://www.vix.com/isc/bind.html">BIND Home</A>
|
||||
| <A HREF="http://www.isc.org">ISC</A> ]</P></CENTER>
|
||||
|
||||
<HR>
|
||||
<ADDRESS>
|
||||
Last Updated: $Id: server.html,v 1.6 1998/03/21 01:03:13 halley Exp $
|
||||
</ADDRESS>
|
||||
</BODY>
|
||||
</HTML>
|
||||
140
contrib/bind/doc/html/zone.html
Normal file
140
contrib/bind/doc/html/zone.html
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>BIND zone Statement</TITLE>
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<H2>BIND Configuration File Guide--<CODE>zone</CODE> Statement</H2>
|
||||
|
||||
<HR>
|
||||
|
||||
<A NAME="Syntax"><H3>Syntax</H3></A>
|
||||
|
||||
<PRE>
|
||||
zone <VAR><A HREF="docdef.html">domain_name</A></VAR> [ ( in | hs | hesiod | chaos ) ] {
|
||||
type master;
|
||||
file <VAR><A HREF="docdef.html">path_name</A></VAR>;
|
||||
[ check-names ( warn | fail | ignore ); ]
|
||||
[ allow-update { <VAR><A NAME="address_list.html">address_match_list</A></VAR> }; ]
|
||||
[ allow-query { <VAR><A NAME="address_list.html">address_match_list</A></VAR> }; ]
|
||||
[ allow-transfer { <VAR><A NAME="address_list.html">address_match_list</A></VAR> }; ]
|
||||
[ notify <VAR><A HREF="docdef.html">yes_or_no</A></VAR>; ]
|
||||
[ also-notify { <VAR><A HREF="docdef.html">ip_addr</A></VAR>; [ <VAR>ip_addr</VAR>; ... ] };
|
||||
};
|
||||
|
||||
zone <VAR><A HREF="docdef.html">domain_name</A></VAR> [ ( in | hs | hesiod | chaos ) ] {
|
||||
type ( slave | stub );
|
||||
[ file <VAR><A HREF="docdef.html">path_name</A></VAR>; ]
|
||||
masters { <VAR><A HREF="docdef.html">ip_addr</A></VAR>; [ <VAR>ip_addr</VAR>; ... ] };
|
||||
[ check-names ( warn | fail | ignore ); ]
|
||||
[ allow-update { <VAR><A NAME="address_list.html">address_match_list</A></VAR> }; ]
|
||||
[ allow-query { <VAR><A NAME="address_list.html">address_match_list</A></VAR> }; ]
|
||||
[ allow-transfer { <VAR><A NAME="address_list.html">address_match_list</A></VAR> }; ]
|
||||
[ max-transfer-time-in <VAR>number</VAR>; ]
|
||||
[ notify <VAR><A HREF="docdef.html">yes_or_no</A></VAR>; ]
|
||||
[ also-notify { <VAR><A HREF="docdef.html">ip_addr</A></VAR>; [ <VAR>ip_addr</VAR>; ... ] };
|
||||
};
|
||||
|
||||
zone "." [ ( in | hs | hesiod | chaos ) ] {
|
||||
type hint;
|
||||
file <VAR><A HREF="docdef.html">path_name</A></VAR>;
|
||||
[ check-names ( warn | fail | ignore ); ]
|
||||
};
|
||||
</PRE>
|
||||
|
||||
<HR>
|
||||
|
||||
<A NAME="Usage"><H3>Definition and Usage</H3></A>
|
||||
|
||||
<H4>Zone Types</H4>
|
||||
|
||||
<DL>
|
||||
<DT><CODE>master</CODE>
|
||||
<DD>
|
||||
The master copy of the data in a zone.
|
||||
|
||||
<DT><CODE>slave</CODE>
|
||||
<DD>
|
||||
A <CODE>slave</CODE> zone is a replica of a master zone. The
|
||||
<CODE>masters</CODE> list specifies one or more IP addresses that the
|
||||
slave contacts to update its copy of the zone. If <CODE>file</CODE>
|
||||
is specified, then the replica will be written to the file. Use of
|
||||
<CODE>file</CODE> is recommended, since it often speeds server startup
|
||||
and eliminates a needless waste of bandwidth.
|
||||
|
||||
<DT><CODE>stub</CODE>
|
||||
<DD>
|
||||
A <CODE>stub</CODE> zone is like a slave zone, except that it replicates
|
||||
only the NS records of a master zone instead of the entire zone.
|
||||
|
||||
<DT><CODE>hint</CODE>
|
||||
<DD>
|
||||
The initial set of root nameservers is specified using a
|
||||
<CODE>hint</CODE> zone. When the server starts up, it uses the root hints
|
||||
to find a root nameserver and get the most recent list of root nameservers.
|
||||
</DL>
|
||||
|
||||
<P>Note: previous releases of BIND used the term <EM>primary</EM> for a
|
||||
master zone, <EM>secondary</EM> for a slave zone, and <EM>cache</EM> for
|
||||
a hint zone.</P>
|
||||
|
||||
<H4>Class</H4>
|
||||
|
||||
<P>The zone's name may optionally be followed by a class. If a class is not
|
||||
specified, class <CODE>in</CODE> is used.
|
||||
|
||||
<H4>Options</H4>
|
||||
|
||||
<DL>
|
||||
<DT><CODE>check-names</CODE>
|
||||
<DD>
|
||||
See <A HREF="options.html#NameChecking">Name Checking</A>.
|
||||
|
||||
<DT><CODE>allow-query</CODE>
|
||||
<DD>
|
||||
See the description of <CODE>allow-query</CODE> in the
|
||||
<A HREF="options.html#AccessControl">Access Control</A> section.
|
||||
|
||||
<DT><CODE>allow-update</CODE>
|
||||
<DD>
|
||||
Specifies which hosts are allowed to submit Dynamic DNS updates to the
|
||||
server. The default is to deny updates from all hosts.
|
||||
|
||||
<DT><CODE>allow-transfer</CODE>
|
||||
<DD>
|
||||
See the description of <CODE>allow-transfer</CODE> in
|
||||
the <A HREF="options.html#AccessControl">Access Control</A> section.
|
||||
|
||||
<DT><CODE>max-transfer-time-in</CODE>
|
||||
<DD>
|
||||
See the description of <CODE>max-transfer-time-in</CODE> in
|
||||
the <A HREF="options.html#ZoneTransfers">Zone Transfers</A> section.
|
||||
|
||||
<DT><CODE>notify</CODE>
|
||||
<DD>
|
||||
See the description of <CODE>notify</CODE> in
|
||||
the <A HREF="options.html#BooleanOptions">Boolean Options</A> section.
|
||||
|
||||
<DT><CODE>also-notify</CODE>
|
||||
<DD>
|
||||
<CODE>also-notify</CODE> is only meaningful if <CODE>notify</CODE> is
|
||||
active for this zone. The set of machines that will receive a DNS
|
||||
NOTIFY message for this zone is made up of all the listed nameservers
|
||||
for the zone (other than the primary master) plus any IP addresses
|
||||
specified with <CODE>also-notify</CODE>. <CODE>also-notify</CODE> is not
|
||||
meaningful for <CODE>stub</CODE> zones. The default is the empty list.
|
||||
</DL>
|
||||
|
||||
<HR>
|
||||
|
||||
<CENTER><P>[ <A HREF="config.html">BIND Config. File</A>
|
||||
| <A HREF="http://www.vix.com/isc/bind.html">BIND Home</A>
|
||||
| <A HREF="http://www.isc.org">ISC</A> ]</P></CENTER>
|
||||
|
||||
<HR>
|
||||
<ADDRESS>
|
||||
Last Updated: $Id: zone.html,v 1.6 1998/03/21 01:03:14 halley Exp $
|
||||
</ADDRESS>
|
||||
</BODY>
|
||||
</HTML>
|
||||
385
contrib/bind/doc/man/Makefile
Normal file
385
contrib/bind/doc/man/Makefile
Normal file
|
|
@ -0,0 +1,385 @@
|
|||
## Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
##
|
||||
## 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, and that
|
||||
## the name of Digital Equipment Corporation not be used in advertising or
|
||||
## publicity pertaining to distribution of the document or software without
|
||||
## specific, written prior permission.
|
||||
##
|
||||
## THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
## WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
## CORPORATION 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.
|
||||
|
||||
## Portions Copyright (c) 1996 by Internet Software Consortium
|
||||
##
|
||||
## 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
## ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
## OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
## CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
## SOFTWARE.
|
||||
|
||||
#
|
||||
# Makefile to install the BIND 4.9 manual entries.
|
||||
#
|
||||
# Default Configuration:
|
||||
# There are a set of default assignments immediately following this
|
||||
# note. These defaults are for BSD4.4, BSD/386, other net2-alikes,
|
||||
# and will install manual entries with following characteristics:
|
||||
# o They will be catable (i.e., passed through nroff)
|
||||
# o They will be installed in the directories
|
||||
# /usr/share/man/catN, where N is 1, 3, 5, 7, 8
|
||||
# o They will have an extension of `.0'
|
||||
#
|
||||
# Don't change these defaults. Instead, following the default configuration
|
||||
# are sets of commented values for particular systems that can be used
|
||||
# to override the default values.
|
||||
#
|
||||
|
||||
#
|
||||
# Target directory for the manual directory tree. Eg., may be used to
|
||||
# specify the path of an NFS-mounted directory for common files.
|
||||
#
|
||||
DESTDIR=
|
||||
|
||||
#
|
||||
# Default location for manual section directories.
|
||||
#
|
||||
DESTMAN= /usr/share/man
|
||||
|
||||
#
|
||||
# Install manuals in ${MANDIR}N. For systems that generate catable manual
|
||||
# entries on the fly, use
|
||||
# MANDIR = man
|
||||
#
|
||||
MANDIR = cat
|
||||
|
||||
#
|
||||
# Default extension for manual entries. To install the manual entries under
|
||||
# their `real' extensions use
|
||||
# CATEXT = $$N
|
||||
#
|
||||
CATEXT = 0
|
||||
|
||||
#
|
||||
# Command to install manual entries
|
||||
#
|
||||
INSTALL= install
|
||||
|
||||
#
|
||||
# `install' options to set Owner and Group for manual entries. Eg. for
|
||||
# BSD `install' use
|
||||
# MAN_OWNER = -o bin
|
||||
# MAN_GROUP = -g bin
|
||||
#
|
||||
MAN_OWNER =
|
||||
MAN_GROUP =
|
||||
|
||||
SHELL= /bin/sh
|
||||
|
||||
INDOT=
|
||||
XFER_INDOT=
|
||||
#
|
||||
# Uppercase versions of the above variables (`INDOT_U' and `XFER_INDOT_U')
|
||||
# are defined for use in `.TH' lines.
|
||||
#
|
||||
|
||||
#
|
||||
# Command used to generate a manual entry. By default this produces catable
|
||||
# manual entries.
|
||||
#
|
||||
# For systems that store manuals in MDOC form (eg modern BSD systems) and
|
||||
# can generate catable manual entries on the fly the following assignment
|
||||
# can be used.
|
||||
# MANROFF = cat
|
||||
#
|
||||
MANROFF = ( tbl | nroff -mandoc )
|
||||
|
||||
#
|
||||
# Default extensions for installed manual entries. The following variables
|
||||
# have been defined to allow BIND's manual entries to be installed in the
|
||||
# right place for a given platform.
|
||||
#
|
||||
# CMD_EXT = extension for user commands (eg, dig)
|
||||
# LIB_NETWORK_EXT = extension for network library routines (eg,
|
||||
# gethostbyname)
|
||||
# FORMAT_EXT = extension for files describing file formats
|
||||
# (eg, resolver)
|
||||
# DESC_EXT = extension for descriptive files (eg, mailaddr)
|
||||
# SYS_OPS_EXT = extension system operation and maintenance commands
|
||||
# and applications. (eg, named, named-xfer, syslog)
|
||||
#
|
||||
# Associated with each variable is an additional variable with the suffix
|
||||
# `_DIR' that specifies the suffix to ${MANDIR}. It's needed because on
|
||||
# some systems, eg., Ultrix, multiple subsections (eg 3x, 3m 3n) are
|
||||
# stored in generic manual section directories (eg., man3).
|
||||
#
|
||||
# Associated with each variable is an additional variable with the suffix
|
||||
# `_U' which gives the upper case form of the variable for use in `.TH'
|
||||
# commands. Useful for platforms (such as Solaris 2) that include letters
|
||||
# in manual sections.
|
||||
#
|
||||
CMD_EXT = 1
|
||||
CMD_EXT_DIR = ${CMD_EXT}
|
||||
LIB_NETWORK_EXT = 3
|
||||
LIB_NETWORK_EXT_DIR = ${LIB_NETWORK_EXT}
|
||||
FORMAT_EXT = 5
|
||||
FORMAT_EXT_DIR = ${FORMAT_EXT}
|
||||
DESC_EXT = 7
|
||||
DESC_EXT_DIR = ${DESC_EXT}
|
||||
SYS_OPS_EXT = 8
|
||||
SYS_OPS_EXT_DIR = ${SYS_OPS_EXT}
|
||||
|
||||
#
|
||||
# Additional variables are defined for cross-references within manual
|
||||
# entries:
|
||||
# SYSCALL_EXT = extension for system calls
|
||||
# BSD_SYSCALL_EXT = extension for BSD-specifc system calls. On some
|
||||
# systems (eg Ultrix) these appear in section 2.
|
||||
# On other system (eg SunOS 5) these are implemented
|
||||
# via a BSD-compatibility library and appear in
|
||||
# section 3.
|
||||
# LIB_C_EXT = extension for C library routines (eg, signal)
|
||||
#
|
||||
SYSCALL_EXT = 2
|
||||
SYSCALL_EXT_DIR = ${SYSCALL_EXT}
|
||||
BSD_SYSCALL_EXT = 2
|
||||
BSD_SYSCALL_EXT_DIR = ${BSD_SYSCALL_EXT}
|
||||
LIB_C_EXT = 3
|
||||
LIB_C_EXT_DIR = ${LIB_C_EXT}
|
||||
|
||||
######################################################################
|
||||
#
|
||||
# No user changes needed past this point.
|
||||
#
|
||||
######################################################################
|
||||
#
|
||||
# This sed command is used to update the manual entries so they refer to
|
||||
# the appropriate section of the manual for a given platform.
|
||||
#
|
||||
EXT_SED_CMD = INDOT_U=`echo "${INDOT}"|tr "[a-z]" "[A-Z]"`; \
|
||||
export INDOT_U; \
|
||||
XFER_INDOT_U=`echo "${XFER_INDOT}"|tr "[a-z]" "[A-Z]"`; \
|
||||
export XFER_INDOT_U; \
|
||||
CMD_EXT_U=`echo "${CMD_EXT}"|tr "[a-z]" "[A-Z]"`; \
|
||||
export CMD_EXT_U; \
|
||||
SYS_OPS_EXT_U=`echo "${SYS_OPS_EXT}"|tr "[a-z]" "[A-Z]"`; \
|
||||
export SYS_OPS_EXT_U; \
|
||||
LIB_NETWORK_EXT_U=`echo "${LIB_NETWORK_EXT}"|tr "[a-z]" "[A-Z]"`; \
|
||||
export LIB_NETWORK_EXT_U; \
|
||||
FORMAT_EXT_U=`echo "${FORMAT_EXT}"|tr "[a-z]" "[A-Z]"`; \
|
||||
export FORMAT_EXT_U; \
|
||||
DESC_EXT_U=`echo "${DESC_EXT}"|tr "[a-z]" "[A-Z]"`; \
|
||||
export DESC_EXT_U; \
|
||||
SYSCALL_EXT_U=`echo "${SYSCALL_EXT}"|tr "[a-z]" "[A-Z]"`; \
|
||||
export SYSCALL_EXT_U; \
|
||||
BSD_SYSCALL_EXT_U=`echo "${BSD_SYSCALL_EXT}"|tr "[a-z]" "[A-Z]"`; \
|
||||
export BSD_SYSCALL_EXT_U; \
|
||||
LIB_C_EXT_U=`echo "${LIB_C_EXT}"|tr "[a-z]" "[A-Z]"`; \
|
||||
export LIB_C_EXT_U; \
|
||||
sed -e "s/@INDOT@/${INDOT}/g" \
|
||||
-e "s/@INDOT_U@/$${INDOT_U}/g" \
|
||||
-e "s/@XFER_INDOT@/${XFER_INDOT}/g" \
|
||||
-e "s/@XFER_INDOT_U@/$${XFER_INDOT_U}/g" \
|
||||
-e "s/@CMD_EXT@/${CMD_EXT}/g" \
|
||||
-e "s/@CMD_EXT_U@/$${CMD_EXT_U}/g" \
|
||||
-e "s/@LIB_NETWORK_EXT@/${LIB_NETWORK_EXT}/g" \
|
||||
-e "s/@LIB_NETWORK_EXT_U@/$${LIB_NETWORK_EXT_U}/g" \
|
||||
-e "s/@FORMAT_EXT@/${FORMAT_EXT}/g" \
|
||||
-e "s/@FORMAT_EXT_U@/$${FORMAT_EXT_U}/g" \
|
||||
-e "s/@DESC_EXT@/${DESC_EXT}/g" \
|
||||
-e "s/@DESC_EXT_U@/$${DESC_EXT_U}/g" \
|
||||
-e "s/@SYS_OPS_EXT@/${SYS_OPS_EXT}/g" \
|
||||
-e "s/@SYS_OPS_EXT_U@/$${SYS_OPS_EXT_U}/g" \
|
||||
-e "s/@SYSCALL_EXT@/${SYSCALL_EXT}/g" \
|
||||
-e "s/@SYSCALL_EXT_U@/$${SYSCALL_EXT_U}/g" \
|
||||
-e "s/@BSD_SYSCALL_EXT@/${BSD_SYSCALL_EXT}/g" \
|
||||
-e "s/@BSD_SYSCALL_EXT_U@/$${BSD_SYSCALL_EXT_U}/g" \
|
||||
-e "s/@LIB_C_EXT@/${LIB_C_EXT}/g" \
|
||||
-e "s/@LIB_C_EXT_U@/$${LIB_C_EXT_U}/g"
|
||||
|
||||
#
|
||||
# Command used to produce manual entries
|
||||
#
|
||||
MK_MANFILE = ( ${EXT_SED_CMD} | ${MANROFF} )
|
||||
|
||||
#
|
||||
# Extensions for the generated manual entries
|
||||
#
|
||||
OUT_EXT = lst
|
||||
CMD_OUT_EXT = ${OUT_EXT}${CMD_EXT}
|
||||
LIB_NETWORK_OUT_EXT = ${OUT_EXT}${LIB_NETWORK_EXT}
|
||||
FORMAT_OUT_EXT = ${OUT_EXT}${FORMAT_EXT}
|
||||
DESC_OUT_EXT = ${OUT_EXT}${DESC_EXT}
|
||||
SYS_OPS_OUT_EXT = ${OUT_EXT}${SYS_OPS_EXT}
|
||||
|
||||
#
|
||||
# User command manual entries
|
||||
#
|
||||
CMD_BASE = dig host dnsquery
|
||||
CMD_SRC_EXT = 1
|
||||
CMD_SRC = dig.${CMD_SRC_EXT} \
|
||||
host.${CMD_SRC_EXT} \
|
||||
dnsquery.${CMD_SRC_EXT} \
|
||||
dnskeygen.${CMD_SRC_EXT} \
|
||||
dnssigner.${CMD_SRC_EXT}
|
||||
CMD_OUT = dig.${CMD_OUT_EXT} \
|
||||
host.${CMD_OUT_EXT} \
|
||||
dnsquery.${CMD_OUT_EXT} \
|
||||
dnskeygen.${CMD_OUT_EXT} \
|
||||
dnssigner.${CMD_OUT_EXT}
|
||||
|
||||
#
|
||||
# named manual entries
|
||||
#
|
||||
NAMED_BASE = named ndc
|
||||
SYS_OPS_SRC_EXT = 8
|
||||
NAMED_SRC = named.${SYS_OPS_SRC_EXT} ndc.${SYS_OPS_SRC_EXT}
|
||||
NAMED_OUT = named.${SYS_OPS_OUT_EXT} ndc.${SYS_OPS_OUT_EXT}
|
||||
|
||||
#
|
||||
# named-xfer manual entry
|
||||
#
|
||||
NAMED_XFER_BASE = named-xfer
|
||||
NAMED_XFER_SRC = named-xfer.${SYS_OPS_SRC_EXT}
|
||||
NAMED_XFER_OUT = named-xfer.${SYS_OPS_OUT_EXT}
|
||||
|
||||
#
|
||||
# nslookup manual entry
|
||||
#
|
||||
NSLOOKUP_BASE = nslookup
|
||||
NSLOOKUP_SRC = nslookup.${SYS_OPS_SRC_EXT}
|
||||
NSLOOKUP_OUT = nslookup.${SYS_OPS_OUT_EXT}
|
||||
|
||||
#
|
||||
# Network library routines manual entries
|
||||
#
|
||||
LIB_NETWORK_BASE = gethostbyname resolver getnetent
|
||||
LIB_NETWORK_SRC_EXT = 3
|
||||
LIB_NETWORK_SRC = gethostbyname.${LIB_NETWORK_SRC_EXT} \
|
||||
resolver.${LIB_NETWORK_SRC_EXT} \
|
||||
getnetent.${LIB_NETWORK_SRC_EXT}
|
||||
LIB_NETWORK_OUT = gethostbyname.${LIB_NETWORK_OUT_EXT} \
|
||||
resolver.${LIB_NETWORK_OUT_EXT} \
|
||||
getnetent.${LIB_NETWORK_OUT_EXT}
|
||||
|
||||
#
|
||||
# File format manual entries
|
||||
#
|
||||
FORMAT_BASE = resolver irs.conf
|
||||
FORMAT_SRC_EXT = 5
|
||||
FORMAT_SRC = resolver.${FORMAT_SRC_EXT} \
|
||||
irs.conf.${FORMAT_SRC_EXT}
|
||||
FORMAT_OUT = resolver.${FORMAT_OUT_EXT} \
|
||||
irs.conf.${FORMAT_OUT_EXT}
|
||||
|
||||
#
|
||||
# Feature Description manual entries
|
||||
#
|
||||
DESC_BASE = hostname mailaddr
|
||||
DESC_SRC_EXT = 7
|
||||
DESC_SRC = hostname.${DESC_SRC_EXT} mailaddr.${DESC_SRC_EXT}
|
||||
DESC_OUT = hostname.${DESC_OUT_EXT} mailaddr.${DESC_OUT_EXT}
|
||||
|
||||
.SUFFIXES: .${CMD_SRC_EXT} .${CMD_OUT_EXT} \
|
||||
.${SYS_OPS_SRC_EXT} .${SYS_OPS_OUT_EXT} \
|
||||
.${LIB_NETWORK_SRC_EXT} .${LIB_NETWORK_OUT_EXT} \
|
||||
.${FORMAT_SRC_EXT} .${FORMAT_OUT_EXT} \
|
||||
.${DESC_SRC_EXT} .${DESC_OUT_EXT}
|
||||
|
||||
.${CMD_SRC_EXT}.${CMD_OUT_EXT}:
|
||||
@echo "$*.${CMD_SRC_EXT} -> $*.${CMD_OUT_EXT}"
|
||||
@${MK_MANFILE} <$*.${CMD_SRC_EXT} >$*.${CMD_OUT_EXT}
|
||||
|
||||
.${SYS_OPS_SRC_EXT}.${SYS_OPS_OUT_EXT}:
|
||||
@echo "$*.${SYS_OPS_SRC_EXT} -> $*.${SYS_OPS_OUT_EXT}"
|
||||
@${MK_MANFILE} <$*.${SYS_OPS_SRC_EXT} >$*.${SYS_OPS_OUT_EXT}
|
||||
|
||||
.${LIB_NETWORK_SRC_EXT}.${LIB_NETWORK_OUT_EXT}:
|
||||
@echo "$*.${LIB_NETWORK_SRC_EXT} -> $*.${LIB_NETWORK_OUT_EXT}"
|
||||
@${MK_MANFILE} <$*.${LIB_NETWORK_SRC_EXT} >$*.${LIB_NETWORK_OUT_EXT}
|
||||
|
||||
.${FORMAT_SRC_EXT}.${FORMAT_OUT_EXT}:
|
||||
@echo "$*.${FORMAT_SRC_EXT} -> $*.${FORMAT_OUT_EXT}"
|
||||
@${MK_MANFILE} <$*.${FORMAT_SRC_EXT} >$*.${FORMAT_OUT_EXT}
|
||||
|
||||
.${DESC_SRC_EXT}.${DESC_OUT_EXT}:
|
||||
@echo "$*.${DESC_SRC_EXT} -> $*.${DESC_OUT_EXT}"
|
||||
@${MK_MANFILE} <$*.${DESC_SRC_EXT} >$*.${DESC_OUT_EXT}
|
||||
|
||||
OUTFILES = ${CMD_OUT} ${NAMED_OUT} ${NAMED_XFER_OUT} ${NSLOOKUP_OUT} \
|
||||
${LIB_NETWORK_OUT} ${FORMAT_OUT} ${DESC_OUT}
|
||||
|
||||
all: ${OUTFILES}
|
||||
|
||||
install: ${OUTFILES} \
|
||||
${DESTDIR}${DESTMAN}/${MANDIR}${CMD_EXT_DIR} \
|
||||
${DESTDIR}${DESTMAN}/${MANDIR}${SYS_OPS_EXT_DIR} \
|
||||
${DESTDIR}${DESTMAN}/${MANDIR}${LIB_NETWORK_EXT_DIR} \
|
||||
${DESTDIR}${DESTMAN}/${MANDIR}${FORMAT_EXT_DIR} \
|
||||
${DESTDIR}${DESTMAN}/${MANDIR}${DESC_EXT_DIR}
|
||||
@set -x; N=${CMD_EXT}; for f in ${CMD_BASE}; do \
|
||||
${INSTALL} -c -m 444 ${MAN_OWNER} ${MAN_GROUP} \
|
||||
$${f}.${CMD_OUT_EXT} \
|
||||
${DESTDIR}${DESTMAN}/${MANDIR}${CMD_EXT_DIR}/$${f}.${CATEXT}; \
|
||||
done
|
||||
@set -x; N=${SYS_OPS_EXT}; for f in ${NAMED_BASE}; do \
|
||||
${INSTALL} -c -m 444 ${MAN_OWNER} ${MAN_GROUP} \
|
||||
$${f}.${SYS_OPS_OUT_EXT} \
|
||||
${DESTDIR}${DESTMAN}/${MANDIR}${SYS_OPS_EXT_DIR}/${INDOT}$${f}.${CATEXT}; \
|
||||
done
|
||||
@set -x; N=${SYS_OPS_EXT}; for f in ${NAMED_XFER_BASE}; do \
|
||||
${INSTALL} -c -m 444 ${MAN_OWNER} ${MAN_GROUP} \
|
||||
$${f}.${SYS_OPS_OUT_EXT} \
|
||||
${DESTDIR}${DESTMAN}/${MANDIR}${SYS_OPS_EXT_DIR}/${XFER_INDOT}$${f}.${CATEXT}; \
|
||||
done
|
||||
@set -x; N=${SYS_OPS_EXT}; for f in ${NSLOOKUP_BASE}; do \
|
||||
${INSTALL} -c -m 444 ${MAN_OWNER} ${MAN_GROUP} \
|
||||
$${f}.${SYS_OPS_OUT_EXT} \
|
||||
${DESTDIR}${DESTMAN}/${MANDIR}${SYS_OPS_EXT_DIR}/$${f}.${CATEXT}; \
|
||||
done
|
||||
@set -x; N=${LIB_NETWORK_EXT}; for f in ${LIB_NETWORK_BASE}; do \
|
||||
${INSTALL} -c -m 444 ${MAN_OWNER} ${MAN_GROUP} \
|
||||
$${f}.${LIB_NETWORK_OUT_EXT} \
|
||||
${DESTDIR}${DESTMAN}/${MANDIR}${LIB_NETWORK_EXT_DIR}/$${f}.${CATEXT}; \
|
||||
done
|
||||
@set -x; N=${FORMAT_EXT}; for f in ${FORMAT_BASE}; do \
|
||||
${INSTALL} -c -m 444 ${MAN_OWNER} ${MAN_GROUP} \
|
||||
$${f}.${FORMAT_OUT_EXT} \
|
||||
${DESTDIR}${DESTMAN}/${MANDIR}${FORMAT_EXT_DIR}/$${f}.${CATEXT}; \
|
||||
done
|
||||
@set -x; N=${DESC_EXT}; for f in ${DESC_BASE}; do \
|
||||
${INSTALL} -c -m 444 ${MAN_OWNER} ${MAN_GROUP} \
|
||||
$${f}.${DESC_OUT_EXT} \
|
||||
${DESTDIR}${DESTMAN}/${MANDIR}${DESC_EXT_DIR}/$${f}.${CATEXT}; \
|
||||
done
|
||||
|
||||
${DESTDIR}${DESTMAN}/${MANDIR}${CMD_EXT_DIR} \
|
||||
${DESTDIR}${DESTMAN}/${MANDIR}${SYS_OPS_EXT_DIR} \
|
||||
${DESTDIR}${DESTMAN}/${MANDIR}${LIB_NETWORK_EXT_DIR} \
|
||||
${DESTDIR}${DESTMAN}/${MANDIR}${FORMAT_EXT_DIR} \
|
||||
${DESTDIR}${DESTMAN}/${MANDIR}${DESC_EXT_DIR}:
|
||||
mkdir $@
|
||||
|
||||
links: FRC
|
||||
@set -ex; ln -s SRC/*.[0-9] .
|
||||
|
||||
depend:
|
||||
|
||||
clean:
|
||||
rm -f *~ *.BAK *.CKP *.orig
|
||||
rm -f ${OUTFILES}
|
||||
|
||||
FRC:
|
||||
680
contrib/bind/doc/man/dig.1
Normal file
680
contrib/bind/doc/man/dig.1
Normal file
|
|
@ -0,0 +1,680 @@
|
|||
.\" $Id: dig.1,v 8.3 1998/03/21 01:01:23 halley Exp $
|
||||
.\"
|
||||
.\" ++Copyright++ 1993
|
||||
.\" -
|
||||
.\" Copyright (c) 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
.\" 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.
|
||||
.\" 3. All advertising materials mentioning features or use of this software
|
||||
.\" must display the following acknowledgement:
|
||||
.\" This product includes software developed by the University of
|
||||
.\" California, Berkeley and its contributors.
|
||||
.\" 4. Neither the name of the University nor the names of its contributors
|
||||
.\" may be used to endorse or promote products derived from this software
|
||||
.\" without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
|
||||
.\" -
|
||||
.\" Portions Copyright (c) 1993 by Digital Equipment Corporation.
|
||||
.\"
|
||||
.\" 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, and that
|
||||
.\" the name of Digital Equipment Corporation not be used in advertising or
|
||||
.\" publicity pertaining to distribution of the document or software without
|
||||
.\" specific, written prior permission.
|
||||
.\"
|
||||
.\" THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
|
||||
.\" WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
|
||||
.\" OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
|
||||
.\" CORPORATION 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--
|
||||
.\"
|
||||
.\" Distributed with 'dig' version 2.0 from University of Southern
|
||||
.\" California Information Sciences Institute (USC-ISI).
|
||||
.\"
|
||||
.\" dig.1 2.0 (USC-ISI) 8/30/90
|
||||
.\"
|
||||
.Dd August 30, 1990
|
||||
.Dt DIG @CMD_EXT_U@
|
||||
.Os BSD 4
|
||||
.Sh NAME
|
||||
.Nm dig
|
||||
.Nd send domain name query packets to name servers
|
||||
.Sh SYNOPSIS
|
||||
.Nm dig
|
||||
.Op Ic @ Ns Ar server
|
||||
.Ar domain
|
||||
.Op Aq Ar query-type
|
||||
.Op Aq Ar query-class
|
||||
.Op Ic + Ns Aq Ar query-option
|
||||
.Op Fl Aq Ar dig-option
|
||||
.Op Ar %comment
|
||||
.Sh DESCRIPTION
|
||||
.Ic Dig
|
||||
(domain information groper) is a flexible command line tool
|
||||
which can be used to gather information from the Domain
|
||||
Name System servers.
|
||||
.Ic Dig
|
||||
has two modes: simple interactive mode
|
||||
for a single query, and batch mode which executes a query for
|
||||
each in a list of several query lines. All query options are
|
||||
accessible from the command line.
|
||||
.Pp
|
||||
The usual simple use of
|
||||
.Ic dig
|
||||
will take the form:
|
||||
.Pp
|
||||
.Bd -ragged -offset indent-two
|
||||
.Ic dig @ Ns Ar server domain query-type query-class
|
||||
.Ed
|
||||
.Pp
|
||||
where:
|
||||
.Bl -tag -width Fl
|
||||
.It Ar server
|
||||
may be either a domain name or a dot-notation
|
||||
Internet address. If this optional field is omitted,
|
||||
.Ic dig
|
||||
will attempt to use the default name server for your machine.
|
||||
.sp 1
|
||||
.Em Note:
|
||||
If a domain name is specified, this will be resolved
|
||||
using the domain name system resolver (i.e., BIND). If your
|
||||
system does not support DNS, you may
|
||||
.Em have
|
||||
to specify a
|
||||
dot-notation address. Alternatively, if there is a server
|
||||
at your disposal somewhere, all that is required is that
|
||||
.Pa /etc/resolv.conf
|
||||
be present and indicate where the default
|
||||
name servers reside, so that
|
||||
.Ar server
|
||||
itself can be resolved. See
|
||||
.Xr resolver @FORMAT_EXT@
|
||||
for information on
|
||||
.Pa /etc/resolv.conf .
|
||||
.Sy WARNING:
|
||||
Changing
|
||||
.Pa /etc/resolv.conf
|
||||
will affect both the standard resolver library and
|
||||
.Pq potentially
|
||||
several programs which use it.
|
||||
As an option, the user may set the
|
||||
environment variable
|
||||
.Ev LOCALRES
|
||||
to name a file which is to
|
||||
be used instead of
|
||||
.Pa /etc/resolv.conf
|
||||
.Po Ns Ev LOCALRES
|
||||
is specific to the
|
||||
.Ic dig
|
||||
resolver and is not referenced by the standard resolver
|
||||
.Pc .
|
||||
If the
|
||||
.Ev LOCALRES
|
||||
variable is not set or the specified file
|
||||
is not readable, then
|
||||
.Pa /etc/resolv.conf
|
||||
will be used.
|
||||
.It Ar domain
|
||||
is the domain name for which you are requesting information.
|
||||
See the
|
||||
.Fl x
|
||||
option (documented in the
|
||||
.Sx OTHER OPTIONS
|
||||
subsection of this section) for convenient way to specify inverse address
|
||||
query.
|
||||
.It Ar query-type
|
||||
is the type of information (DNS query type) that
|
||||
you are requesting. If omitted, the default is
|
||||
.Dq Ar a
|
||||
.Pq Dv T_A = Ar address .
|
||||
The following types are recognized:
|
||||
.Pp
|
||||
.Bl -hang -width "hinfo T_HINFO " -compact
|
||||
.It Ar a\ \ \ \ \ \ Dv T_A
|
||||
network address
|
||||
.It Ar any\ \ \ \ Dv T_ANY
|
||||
all/any information about specified domain
|
||||
.It Ar mx\ \ \ \ \ Dv T_MX
|
||||
mail exchanger for the domain
|
||||
.It Ar ns\ \ \ \ \ Dv T_NS
|
||||
name servers
|
||||
.It Ar soa\ \ \ \ Dv T_SOA
|
||||
zone of authority record
|
||||
.It Ar hinfo\ \ Dv T_HINFO
|
||||
host information
|
||||
.It Ar axfr\ \ \ Dv T_AXFR
|
||||
zone transfer (must ask an authoritative server)
|
||||
.It Ar txt\ \ \ \ Dv T_TXT
|
||||
arbitrary number of strings
|
||||
.El
|
||||
.Pp
|
||||
(See RFC 1035 for the complete list.)
|
||||
.It Ar query-class
|
||||
is the network class requested in the query. If
|
||||
omitted, the default is
|
||||
.Dq Ar in
|
||||
.Pq Dv C_IN = Ar Internet .
|
||||
The following classes are recognized:
|
||||
.Pp
|
||||
.Bl -tag -width "hinfo T_HINFO " -compact
|
||||
.It Ar in\ \ \ \ \ Dv C_IN
|
||||
Internet class domain
|
||||
.It Ar any\ \ \ \ Dv C_ANY
|
||||
all/any class information
|
||||
.El
|
||||
.Pp
|
||||
(See RFC 1035 for the complete list.)
|
||||
.Pp
|
||||
.Em Note:
|
||||
.Dq Ar Any
|
||||
can be used to specify a
|
||||
.Em class
|
||||
and/or a
|
||||
.Em type
|
||||
of query.
|
||||
.Ic Dig
|
||||
will parse the first occurrence of
|
||||
.Dq Ar any
|
||||
to mean
|
||||
.Ar query-type = Dv T_ANY .
|
||||
To specify
|
||||
.Ar query-class = Dv C_ANY ,
|
||||
you must either specify
|
||||
.Dq any
|
||||
twice, or set
|
||||
.Ar query-class
|
||||
using the
|
||||
.Fl c
|
||||
option (see below).
|
||||
.El
|
||||
.Ss OTHER OPTIONS
|
||||
.Bl -tag -width Fl
|
||||
.It % Ns Ar ignored-comment
|
||||
.Dq %
|
||||
is used to included an argument that is simply not
|
||||
parsed. This may be useful if running
|
||||
.Ic dig
|
||||
in batch
|
||||
mode. Instead of resolving every
|
||||
.Ar @server-domain-name
|
||||
in a list of queries, you can avoid the overhead of doing
|
||||
so, and still have the domain name on the command line
|
||||
as a reference. Example:
|
||||
.Pp
|
||||
.Bd -ragged -offset indent-two
|
||||
.Ic dig @128.9.0.32 %venera.isi.edu mx isi.edu
|
||||
.Ed
|
||||
.Pp
|
||||
.It Fl Aq Ar dig option
|
||||
.Dq Fl
|
||||
is used to specify an option which affects the operation of
|
||||
.Ic dig .
|
||||
The following options are currently
|
||||
available (although not guaranteed to be useful):
|
||||
.Bl -tag -width Fl
|
||||
.It Fl x Ar dot-notation-address
|
||||
Convenient form to specify inverse address mapping.
|
||||
Instead of
|
||||
.Dq Ic dig 32.0.9.128.in-addr.arpa ,
|
||||
one can simply
|
||||
.Dq Ic dig -x 128.9.0.32 .
|
||||
.It Fl f Ar file
|
||||
File for
|
||||
.Ic dig
|
||||
batch mode. The file contains a list
|
||||
of query specifications
|
||||
(
|
||||
.Ns Ic dig
|
||||
command lines) which are to be executed successively. Lines beginning with
|
||||
.Sq \&; ,
|
||||
.Sq # ,
|
||||
or
|
||||
.Sq \en
|
||||
are ignored. Other options
|
||||
may still appear on command line, and will be in
|
||||
effect for each batch query.
|
||||
.It Fl T Ar time
|
||||
Time in seconds between start of successive
|
||||
queries when running in batch mode. Can be used
|
||||
to keep two or more batch
|
||||
.Ic dig
|
||||
commands running
|
||||
roughly in sync. Default is zero.
|
||||
.It Fl p Ar port
|
||||
Port number. Query a name server listening to a
|
||||
non-standard port number. Default is 53.
|
||||
.It Fl P Ns Bq Ar ping-string
|
||||
After query returns, execute a
|
||||
.Xr ping @SYS_OPS_EXT@
|
||||
command for response time comparison. This rather
|
||||
unelegantly makes a call to the shell. The last
|
||||
three lines of statistics is printed for the
|
||||
command:
|
||||
.Pp
|
||||
.Bd -ragged -offset indent-two
|
||||
.Ic ping Fl s server_name 56 3
|
||||
.Ed
|
||||
.Pp
|
||||
If the optional
|
||||
.Dq Ar ping_string
|
||||
is present, it
|
||||
replaces
|
||||
.Dq Ic ping Fl s
|
||||
in the shell command.
|
||||
.It Fl t Ar query-type
|
||||
Specify type of query. May specify either an
|
||||
integer value to be included in the type field
|
||||
or use the abbreviated mnemonic as discussed
|
||||
above (i.e.,
|
||||
.Ar mx = Dv T_MX ) .
|
||||
.It Fl c Ar query-class
|
||||
Specify class of query. May specify either an
|
||||
integer value to be included in the class field
|
||||
or use the abbreviated mnemonic as discussed
|
||||
above (i.e., in = C_IN).
|
||||
.It Fl envsav
|
||||
This flag specifies that the
|
||||
.Ic dig
|
||||
environment
|
||||
(defaults, print options, etc.), after
|
||||
all of the arguments are parsed, should be saved
|
||||
to a file to become the default environment.
|
||||
This is useful if you do not like the standard set of
|
||||
defaults and do not desire to include a
|
||||
large number of options each time
|
||||
.Ic dig
|
||||
is used. The environment consists of resolver state
|
||||
variable flags, timeout, and retries as well as the flags detailing
|
||||
.Ic dig
|
||||
output (see below).
|
||||
If the shell environment variable
|
||||
.Ev LOCALDEF
|
||||
is set to the name of a file, this is where the default
|
||||
.Ic dig
|
||||
environment is saved. If not, the file
|
||||
.Dq Pa DiG.env
|
||||
is created in the current working directory.
|
||||
.Pp
|
||||
.Em Note:
|
||||
.Ev LOCALDEF
|
||||
is specific to the
|
||||
.Ic dig
|
||||
resolver,
|
||||
and will not affect operation of the standard
|
||||
resolver library.
|
||||
.Pp
|
||||
Each time
|
||||
.Ic dig
|
||||
is executed, it looks for
|
||||
.Dq Pa ./DiG.env
|
||||
or the file specified by the shell environment variable
|
||||
.Ev LOCALDEF .
|
||||
If such file exists and is readable, then the
|
||||
environment is restored from this file before any arguments are parsed.
|
||||
.It Fl envset
|
||||
This flag only affects batch query runs. When
|
||||
.Dq Fl envset
|
||||
is specified on a line in a
|
||||
.Ic dig
|
||||
batch file, the
|
||||
.Ic dig
|
||||
environment after the arguments are parsed
|
||||
becomes the default environment for the duration of
|
||||
the batch file, or until the next line which specifies
|
||||
.Dq Fl envset .
|
||||
.It Xo
|
||||
.Fl Op Cm no
|
||||
.Ns Cm stick
|
||||
.Xc
|
||||
This flag only affects batch query runs.
|
||||
It specifies that the
|
||||
.Ic dig
|
||||
environment (as read initially
|
||||
or set by
|
||||
.Dq Fl envset
|
||||
switch) is to be restored before each query (line) in a
|
||||
.Ic dig
|
||||
batch file.
|
||||
The default
|
||||
.Dq Fl nostick
|
||||
means that the
|
||||
.Ic dig
|
||||
environment does not stick, hence options specified on a single line
|
||||
in a
|
||||
.Ic dig
|
||||
batch file will remain in effect for
|
||||
subsequent lines (i.e. they are not restored to the
|
||||
.Dq sticky
|
||||
default).
|
||||
.El
|
||||
.It Ic + Ns Aq Ar query-option
|
||||
.Dq +
|
||||
is used to specify an option to be changed in the query packet or to change
|
||||
.Ic dig
|
||||
output specifics. Many of these are the same parameters accepted by
|
||||
.Xr nslookup @SYS_OPS_EXT@ .
|
||||
If an option requires a parameter, the form is as follows:
|
||||
.Pp
|
||||
.Bd -ragged -offset indent-two
|
||||
.Ic +
|
||||
.Ns Ar keyword
|
||||
.Ns Op = Ns Ar value
|
||||
.Ed
|
||||
.Pp
|
||||
Most keywords can be abbreviated. Parsing of the
|
||||
.Dq +
|
||||
options is very simplistic \(em a value must not be
|
||||
separated from its keyword by white space. The following
|
||||
keywords are currently available:
|
||||
.Pp
|
||||
Keyword Abbrev. Meaning [default]
|
||||
.Pp
|
||||
.Bl -tag -width "[no]primary (ret) " -compact
|
||||
.It Xo
|
||||
.Op Cm no
|
||||
.Ns Cm debug\ \ \ \
|
||||
.Pq Cm deb
|
||||
.Xc
|
||||
turn on/off debugging mode
|
||||
.Bq Cm deb
|
||||
.It Xo
|
||||
.Op Cm no
|
||||
.Ns Cm d2\ \ \ \ \ \ \ \ \ \
|
||||
.Xc
|
||||
turn on/off extra debugging mode
|
||||
.Bq Cm nod2
|
||||
.It Xo
|
||||
.Op Cm no
|
||||
.Ns Cm recurse\ \
|
||||
.Pq Cm rec
|
||||
.Xc
|
||||
use/don't use recursive lookup
|
||||
.Bq Cm rec
|
||||
.It Xo
|
||||
.Cm retry= Ns Ar #
|
||||
.Cm \ \ \ \ \
|
||||
.Pq Cm ret
|
||||
.Xc
|
||||
set number of retries to #
|
||||
.Bq 4
|
||||
.It Xo
|
||||
.Cm time= Ns Ar #
|
||||
.Cm \ \ \ \ \ \
|
||||
.Pq Cm ti
|
||||
.Xc
|
||||
set timeout length to # seconds
|
||||
.Bq 4
|
||||
.It Xo
|
||||
.Op Cm no
|
||||
.Ns Cm ko
|
||||
.Xc
|
||||
keep open option (implies vc)
|
||||
.Bq Cm noko
|
||||
.It Xo
|
||||
.Op Cm no
|
||||
.Ns Cm vc
|
||||
.Xc
|
||||
use/don't use virtual circuit
|
||||
.Bq Cm novc
|
||||
.It Xo
|
||||
.Op Cm no
|
||||
.Ns Cm defname\ \
|
||||
.Pq Cm def
|
||||
.Xc
|
||||
use/don't use default domain name
|
||||
.Bq Cm def
|
||||
.It Xo
|
||||
.Op Cm no
|
||||
.Ns Cm search\ \ \
|
||||
.Pq Cm sea
|
||||
.Xc
|
||||
use/don't use domain search list
|
||||
.Bq Cm sea
|
||||
.It Xo
|
||||
.Cm domain= Ns Ar NAME\ \
|
||||
.Pq Cm do
|
||||
.Xc
|
||||
set default domain name to
|
||||
.Ar NAME
|
||||
.It Xo
|
||||
.Op Cm no
|
||||
.Ns Cm ignore\ \ \
|
||||
.Pq Cm i
|
||||
.Xc
|
||||
ignore/don't ignore trunc. errors
|
||||
.Bq Cm noi
|
||||
.It Xo
|
||||
.Op Cm no
|
||||
.Ns Cm primary\ \
|
||||
.Pq Cm pr
|
||||
.Xc
|
||||
use/don't use primary server
|
||||
.Bq Cm nopr
|
||||
.It Xo
|
||||
.Op Cm no
|
||||
.Ns Cm aaonly\ \ \
|
||||
.Pq Cm aa
|
||||
.Xc
|
||||
authoritative query only flag
|
||||
.Bq Cm noaa
|
||||
.It Xo
|
||||
.Op Cm no
|
||||
.Ns Cm cmd
|
||||
.Xc
|
||||
echo parsed arguments
|
||||
.Bq Cm cmd
|
||||
.It Xo
|
||||
.Op Cm no
|
||||
.Ns Cm stats\ \ \ \
|
||||
.Pq Cm st
|
||||
.Xc
|
||||
print query statistics
|
||||
.Bq Cm st
|
||||
.It Xo
|
||||
.Op Cm no
|
||||
.Ns Cm Header\ \ \
|
||||
.Pq Cm H
|
||||
.Xc
|
||||
print basic header
|
||||
.Bq Cm H
|
||||
.It Xo
|
||||
.Op Cm no
|
||||
.Ns Cm header\ \ \
|
||||
.Pq Cm he
|
||||
.Xc
|
||||
print header flags
|
||||
.Bq Cm he
|
||||
.It Xo
|
||||
.Op Cm no
|
||||
.Ns Cm ttlid\ \ \ \
|
||||
.Pq Cm tt
|
||||
.Xc
|
||||
print TTLs
|
||||
.Bq Cm tt
|
||||
.It Xo
|
||||
.Op Cm no
|
||||
.Ns Cm cl
|
||||
.Xc
|
||||
print class info
|
||||
.Bq Cm nocl
|
||||
.It Xo
|
||||
.Op Cm no
|
||||
.Ns Cm qr
|
||||
.Xc
|
||||
print outgoing query
|
||||
.Bq Cm noqr
|
||||
.It Xo
|
||||
.Op Cm no
|
||||
.Ns Cm reply\ \ \ \
|
||||
.Pq Cm rep
|
||||
.Xc
|
||||
print reply
|
||||
.Bq Cm rep
|
||||
.It Xo
|
||||
.Op Cm no
|
||||
.Ns Cm ques\ \ \ \ \
|
||||
.Pq Cm qu
|
||||
.Xc
|
||||
print question section
|
||||
.Bq Cm qu
|
||||
.It Xo
|
||||
.Op Cm no
|
||||
.Ns Cm answer\ \ \
|
||||
.Pq Cm an
|
||||
.Xc
|
||||
print answer section
|
||||
.Bq Cm an
|
||||
.It Xo
|
||||
.Op Cm no
|
||||
.Ns Cm author\ \ \
|
||||
.Pq Cm au
|
||||
.Xc
|
||||
print authoritative section
|
||||
.Bq Cm au
|
||||
.It Xo
|
||||
.Op Cm no
|
||||
.Ns Cm addit\ \ \ \
|
||||
.Pq Cm ad
|
||||
.Xc
|
||||
print additional section
|
||||
.Bq Cm ad
|
||||
.It Cm pfdef
|
||||
set to default print flags
|
||||
.It Cm pfmin
|
||||
set to minimal default print flags
|
||||
.It Cm pfset= Ns Ar #
|
||||
set print flags to #
|
||||
(# can be hex/octal/decimal)
|
||||
.It Cm pfand= Ns Ar #
|
||||
bitwise and print flags with #
|
||||
.It Cm pfor= Ns Ar #
|
||||
bitwise or print flags with #
|
||||
.El
|
||||
.Pp
|
||||
The
|
||||
.Cm retry
|
||||
and
|
||||
.Cm time
|
||||
options affect the retransmission strategy used by the resolver
|
||||
library when sending datagram queries. The algorithm is as follows:
|
||||
.Pp
|
||||
.Bd -literal -offset indent
|
||||
for i = 0 to retry - 1
|
||||
for j = 1 to num_servers
|
||||
send_query
|
||||
wait((time * (2**i)) / num_servers)
|
||||
end
|
||||
end
|
||||
.Ed
|
||||
.Pp
|
||||
(Note:
|
||||
.Ic dig
|
||||
always uses a value of 1 for
|
||||
.Dq Li num_servers . )
|
||||
.El
|
||||
.Ss DETAILS
|
||||
.Ic Dig
|
||||
once required a slightly modified version of the BIND
|
||||
.Xr resolver @LIB_NETWORK_EXT@
|
||||
library. As of BIND 4.9, BIND's resolver has been augmented to work
|
||||
properly with
|
||||
.Ic dig .
|
||||
Essentially,
|
||||
.Ic dig
|
||||
is a straight-forward
|
||||
(albeit not pretty) effort of parsing arguments and setting appropriate
|
||||
parameters.
|
||||
.Ic Dig
|
||||
uses
|
||||
.Xr resolver @LIB_NETWORK_EXT@
|
||||
routines
|
||||
.Fn res_init ,
|
||||
.Fn res_mkquery ,
|
||||
.Fn res_send
|
||||
as well as accessing the
|
||||
.Ft _res
|
||||
structure.
|
||||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width "LOCALRES " -compact
|
||||
.It Ev LOCALRES
|
||||
file to use in place of Pa /etc/resolv.conf
|
||||
.It Ev LOCALDEF
|
||||
default environment file
|
||||
.El
|
||||
.Pp
|
||||
See also the explanation of the
|
||||
.Fl envsav ,
|
||||
.Fl envset ,
|
||||
and
|
||||
.Xo
|
||||
.Fl Op Cm no
|
||||
.Ns Cm stick
|
||||
.Xc
|
||||
options, above.
|
||||
.Sh FILES
|
||||
.Bl -tag -width "/etc/resolv.conf " -compact
|
||||
.It Pa /etc/resolv.conf
|
||||
initial domain name and name server addresses
|
||||
.It Pa \./DiG.env
|
||||
default save file for default options
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr @INDOT@named @SYS_OPS_EXT@ ,
|
||||
.Xr resolver @LIB_NETWORK_EXT@ ,
|
||||
.Xr resolver @FORMAT_EXT@ ,
|
||||
.Xr nslookup @SYS_OPS_EXT@ .
|
||||
.Sh STANDARDS
|
||||
RFC 1035.
|
||||
.Sh AUTHOR
|
||||
Steve Hotz
|
||||
hotz@isi.edu
|
||||
.Sh ACKNOWLEDGMENTS
|
||||
.Ic Dig
|
||||
uses functions from
|
||||
.Xr nslookup @SYS_OPS_EXT@
|
||||
authored by Andrew Cherenson.
|
||||
.Sh BUGS
|
||||
.Ic Dig
|
||||
has a serious case of "creeping featurism" -- the result of
|
||||
considering several potential uses during it's development. It would
|
||||
probably benefit from a rigorous diet. Similarly, the print flags
|
||||
and granularity of the items they specify make evident their
|
||||
rather ad hoc genesis.
|
||||
.Pp
|
||||
.Ic Dig
|
||||
does not consistently exit nicely (with appropriate status)
|
||||
when a problem occurs somewhere in the resolver
|
||||
.Po Sy NOTE:
|
||||
most of the common exit cases are handled
|
||||
.Pc .
|
||||
This is particularly annoying when running in
|
||||
batch mode. If it exits abnormally (and is not caught), the entire
|
||||
batch aborts; when such an event is trapped,
|
||||
.Ic dig
|
||||
simply
|
||||
continues with the next query.
|
||||
175
contrib/bind/doc/man/dnskeygen.1
Normal file
175
contrib/bind/doc/man/dnskeygen.1
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
.\" Copyright (c) 1996 by Internet Software Consortium
|
||||
.\"
|
||||
.\" 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
.\" ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
.\" OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
.\" CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
.\" DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
.\" PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
.\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
.\" SOFTWARE.
|
||||
.\"
|
||||
.\" $Id: dnskeygen.1,v 8.2 1997/03/14 02:29:41 vixie Exp $
|
||||
.\"
|
||||
.Dd October 25, 1996
|
||||
.Dt DNSKEYGEN @CMD_EXT_U@
|
||||
.Os BSD 4
|
||||
.Sh NAME
|
||||
.Nm dnskeygen
|
||||
.Nd generate and display public and private RSA keys for DNS
|
||||
.Sh SYNOPSIS
|
||||
.Nm dnskeygen
|
||||
.Bo Fl g Ns Op Ar size
|
||||
.Op Fl f
|
||||
.Bc
|
||||
.Bo Fl z
|
||||
|
|
||||
.Fl e
|
||||
|
|
||||
.Fl u
|
||||
.Bc
|
||||
.Op Fl i
|
||||
.Op Fl m
|
||||
.Op Fl p Ns Ar #
|
||||
.Op Fl s Ns Ar #
|
||||
.Op Fl x
|
||||
.Ar name
|
||||
.Sh DESCRIPTION
|
||||
.Ic Dnskeygen
|
||||
(DNS Key Generator) is a tool to generate and maintain RSA keys
|
||||
for DNS (Domain Name System).
|
||||
.Bl -tag -width Fl
|
||||
.It Fl g Ns Op Ar size
|
||||
.Ic Dnskeygen
|
||||
will generate a new key when
|
||||
the
|
||||
.Dq Fl g
|
||||
flag is specified. If the
|
||||
.Dq Fl g
|
||||
flag is not specified, then it
|
||||
will attempt to display an existing key that is stored in the current
|
||||
directory. If no
|
||||
.Ar size
|
||||
is specified after the
|
||||
.Dq Fl g
|
||||
flag, a key of 512 bits
|
||||
will be generated; otherwise,
|
||||
.Ar size
|
||||
is the size of the modulus in the newly-generated key.
|
||||
.It Fl f
|
||||
flag can only be specified with the
|
||||
.Dq Fl g
|
||||
flag; this changes the
|
||||
exponent used on the key. If
|
||||
.Dq Fl f
|
||||
is specified, the exponent is 65537,
|
||||
which is suitable for encryption keys. If
|
||||
.Dq Fl f
|
||||
is not specified,
|
||||
the exponent is 3, which is suitable for signatures and
|
||||
verification of public data such as DNS records. Signing and
|
||||
verifying with exponent of 65537 takes significantly more CPU time than
|
||||
with exponent of 3.
|
||||
.It Fl z Fl e Fl u
|
||||
These flags define the type of key being generated: Zone (DNS
|
||||
validation) key, End Entity (host or service) key or User (e.g. email) key,
|
||||
respectively.
|
||||
Each key is only allowed to be one of these. When
|
||||
keys are displayed, the type of key can be changed.
|
||||
.It Fl i
|
||||
Indicates that the key can be used for IPSEC (Internet Protocol Security
|
||||
services).
|
||||
.It Fl m
|
||||
Indicates that the key can be used for secure email.
|
||||
.It Fl p Ns Ar #
|
||||
Indicates that the key can be used for protocol number
|
||||
.Ar # .
|
||||
A value of
|
||||
.Ar 0
|
||||
denies the use of the key for
|
||||
.Em any
|
||||
protocol (other than those specified by other option flags like
|
||||
.Fl m ) .
|
||||
A value of
|
||||
.Ar 255
|
||||
allows it to be used with
|
||||
.Em all
|
||||
protocols.
|
||||
These protocol numbers will be assigned in the latest Assigned Numbers
|
||||
RFC from the Internet Assigned Numbers Authority (IANA).
|
||||
.It Fl s Ns Ar #
|
||||
Strength value; this value is only used when key is signing.
|
||||
Interpretation of this field is to be specified later. Default value is 7.
|
||||
.It Fl x
|
||||
Experimental key. This indicates that software should not assume
|
||||
that it should use secure protocols when talking to this zone, host, or user.
|
||||
Instead, the key is being published experimentally, to debug the software
|
||||
to be used to run the secure protocols, for example.
|
||||
Data signed by Experimental keys will not be treated as trusted by DNS servers.
|
||||
.It Ar name
|
||||
The DNS name the key is for. This can be any valid DNS name.
|
||||
.El
|
||||
.Ss DETAILS
|
||||
.Ic Dnskeygen
|
||||
uses two files for each key:
|
||||
.Pa <name>.priv
|
||||
and
|
||||
.Pa <name>.public .
|
||||
File
|
||||
.Pa <name>.public
|
||||
contains the public key in the pubkey format:
|
||||
.Pp
|
||||
.D1 Ar <flags> <algorithm> <protocol> <exponent|modulus>
|
||||
.Pp
|
||||
.Ic Dnskeygen
|
||||
.Ar name
|
||||
displays the public key in both DNS RR format and pubkey format.
|
||||
.Ic Dnskeygen
|
||||
can display the key with different flags on subsequent runs.
|
||||
The contents of the public key file will not be changed.
|
||||
.Pa <name>.priv
|
||||
stores the private key, in either a password-protected
|
||||
format file or in a open file. The advantage of
|
||||
a password-protected file is that it is harder to use the key if the file is
|
||||
stolen. The disadvantage is that the password has to be given each time
|
||||
the key is read. If the key is to be stored in a safe off-line place,
|
||||
and only used for signing zones, then local policy may allow storing the
|
||||
key in an unencrypted format.
|
||||
.Sh ENVIRONMENT
|
||||
No environmental variables are used.
|
||||
.Sh SEE ALSO
|
||||
RSAREF documentation,
|
||||
.Em RFC 2065
|
||||
on secure DNS.
|
||||
.Sh AUTHOR
|
||||
Olafur Gudmundsson (ogud@tis.com).
|
||||
.Sh ACKNOWLEDGMENTS
|
||||
The underlying cryptographic math is done by the RSAREF or BSAFE libraries.
|
||||
.Sh BUGS
|
||||
.Ic Dnskeygen
|
||||
renames old keys in such a way that only one
|
||||
.Dq previous
|
||||
key for a given name is kept; older keys are overwritten. (For example,
|
||||
the third time a key is generated for a given name, the second key is kept
|
||||
as the
|
||||
.Dq previous
|
||||
key, while the first key is lost. If a key is generated
|
||||
.Em again
|
||||
for this name--i.e., if the fourth key is generated--then the third key
|
||||
will become the
|
||||
.Dq previous
|
||||
key and the second key will be lost.)
|
||||
.Ic Dnskeygen
|
||||
will not overwrite existing keys.
|
||||
Only one key for each name can be stored in the current directory. If you
|
||||
want to keep your old keys, rename the files before running
|
||||
.Ic dnskeygen .
|
||||
Otherwise you must delete them before running
|
||||
.Ic dnskeygen .
|
||||
.Pp
|
||||
Portability of Private key file must be better tested between
|
||||
different implementations of RSA.
|
||||
178
contrib/bind/doc/man/dnsquery.1
Normal file
178
contrib/bind/doc/man/dnsquery.1
Normal file
|
|
@ -0,0 +1,178 @@
|
|||
.\" $Id: dnsquery.1,v 8.2 1997/03/14 02:29:41 vixie Exp $
|
||||
.\"
|
||||
.\"Copyright (c) 1995, 1996 by Internet Software Consortium
|
||||
.\"
|
||||
.\"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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
.\"ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
.\"OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
.\"CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
.\"DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
.\"PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
.\"ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
.\"SOFTWARE.
|
||||
.\"
|
||||
.Dd March 10, 1990
|
||||
.Dt DNSQUERY @CMD_EXT_U@
|
||||
.Os BSD 4
|
||||
.Sh NAME
|
||||
.Nm dnsquery
|
||||
.Nd query domain name servers using resolver
|
||||
.Sh SYNOPSIS
|
||||
.Nm dnsquery
|
||||
.Op Fl n Ar nameserver
|
||||
.Op Fl t Ar type
|
||||
.Op Fl c Ar class
|
||||
.Op Fl r Ar retry
|
||||
.Op Fl p Ar period
|
||||
.Op Fl d
|
||||
.Op Fl s
|
||||
.Op Fl v
|
||||
.Ar host
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Ic dnsquery
|
||||
program is a general interface to nameservers via
|
||||
BIND resolver library calls. The program supports
|
||||
queries to the nameserver with an opcode of QUERY.
|
||||
This program is intended to be a replacement or
|
||||
supplement to programs like nstest, nsquery and
|
||||
nslookup. All arguments except for
|
||||
.Ar host
|
||||
and
|
||||
.Ar nameserver
|
||||
are treated without case-sensitivity.
|
||||
.Sh OPTIONS
|
||||
.Bl -tag -width Fl
|
||||
.It Fl n Ar nameserver
|
||||
The nameserver to be used in the query. Nameservers can appear as either
|
||||
Internet addresses of the form
|
||||
.Ar w.x.y.z
|
||||
or can appear as domain names.
|
||||
(Default: as specified in
|
||||
.Pa /etc/resolv.conf . )
|
||||
.It Fl t Ar type
|
||||
The type of resource record of interest. Types include:
|
||||
.Bl -tag -width "AFSDB " -compact -offset indent
|
||||
.It Ar A
|
||||
address
|
||||
.It Ar NS
|
||||
nameserver
|
||||
.It Ar CNAME
|
||||
canonical name
|
||||
.It Ar PTR
|
||||
domain name pointer
|
||||
.It Ar SOA
|
||||
start of authority
|
||||
.It Ar WKS
|
||||
well-known service
|
||||
.It Ar HINFO
|
||||
host information
|
||||
.It Ar MINFO
|
||||
mailbox information
|
||||
.It Ar MX
|
||||
mail exchange
|
||||
.It Ar RP
|
||||
responsible person
|
||||
.It Ar MG
|
||||
mail group member
|
||||
.It Ar AFSDB
|
||||
DCE or AFS server
|
||||
.It Ar ANY
|
||||
wildcard
|
||||
.El
|
||||
.Pp
|
||||
Note that any case may be used. (Default:
|
||||
.Ar ANY . )
|
||||
.It Fl c Ar class
|
||||
The class of resource records of interest.
|
||||
Classes include:
|
||||
.Bl -tag -width "CHAOS " -compact -offset indent
|
||||
.It Ar IN
|
||||
Internet
|
||||
.It Ar HS
|
||||
Hesiod
|
||||
.It Ar CHAOS
|
||||
Chaos
|
||||
.It Ar ANY
|
||||
wildcard
|
||||
.El
|
||||
.Pp
|
||||
Note that any case may be used. (Default:
|
||||
.Ar IN . )
|
||||
.It Fl r Ar retry
|
||||
The number of times to retry if the nameserver is
|
||||
not responding. (Default: 4.)
|
||||
.It Fl p Ar period
|
||||
Period to wait before timing out. (Default:
|
||||
.Dv RES_TIMEOUT . )
|
||||
.It Fl d
|
||||
Turn on debugging. This sets the
|
||||
.Dv RES_DEBUG
|
||||
bit of the resolver's
|
||||
.Ft options
|
||||
field. (Default: no debugging.)
|
||||
.It Fl s
|
||||
Use a
|
||||
.Em stream
|
||||
rather than a packet. This uses a TCP stream connection with
|
||||
the nameserver rather than a UDP datagram. This sets the
|
||||
.Dv RES_USEVC
|
||||
bit of the resolver's
|
||||
.Ft options
|
||||
field. (Default: UDP datagram.)
|
||||
.It Fl v
|
||||
Synonym for the
|
||||
.Dq Fl s
|
||||
flag.
|
||||
.It Ar host
|
||||
The name of the host (or domain) of interest.
|
||||
.El
|
||||
.Sh FILES
|
||||
.Bl -tag -width "<arpa/nameser.h> " -compact
|
||||
.It Pa /etc/resolv.conf
|
||||
to get the default ns and search lists
|
||||
.It Pa <arpa/nameser.h>
|
||||
list of usable RR types and classes
|
||||
.It Pa <resolv.h>
|
||||
list of resolver flags
|
||||
.El
|
||||
.Sh DIAGNOSTICS
|
||||
If the resolver fails to answer the query and debugging has not been
|
||||
turned on,
|
||||
.Ic dnsquery
|
||||
will simply print a message like:
|
||||
.Dl Query failed (rc = 1) : Unknown host
|
||||
.Pp
|
||||
The value of the return code is supplied by
|
||||
.Ft h_errno .
|
||||
.Sh SEE ALSO
|
||||
.Xr nslookup @SYS_OPS_EXT@ ,
|
||||
.Xr nstest @CMD_EXT@ ,
|
||||
.Xr nsquery @CMD_EXT@ ,
|
||||
.Xr named @SYS_OPS_EXT@ ,
|
||||
.Xr resolver @FORMAT_EXT@ .
|
||||
.Sh AUTHOR
|
||||
Bryan Beecher
|
||||
.Sh BUGS
|
||||
Queries of a class other than
|
||||
.Ar IN
|
||||
can have interesting results
|
||||
since ordinarily a nameserver only has a list of root nameservers
|
||||
for class
|
||||
.Ar IN
|
||||
resource records.
|
||||
.Pp
|
||||
.Ic Dnsquery
|
||||
uses a call to
|
||||
.Fn inet_addr
|
||||
to determine if the argument
|
||||
for the
|
||||
.Dq Fl n
|
||||
option is a valid Internet address. Unfortunately,
|
||||
.Fn inet_addr
|
||||
seems to cause a segmentation fault with some (bad)
|
||||
IP addresses (e.g., 1.2.3.4.5).
|
||||
213
contrib/bind/doc/man/dnssigner.1
Normal file
213
contrib/bind/doc/man/dnssigner.1
Normal file
|
|
@ -0,0 +1,213 @@
|
|||
.\" Copyright (c) 1996 by Internet Software Consortium
|
||||
.\"
|
||||
.\" 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
|
||||
.\" ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
.\" OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
|
||||
.\" CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
.\" DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
||||
.\" PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
||||
.\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
.\" SOFTWARE.
|
||||
.\"
|
||||
.\" $Id: dnssigner.1,v 8.2 1997/03/14 02:29:42 vixie Exp $
|
||||
.\"
|
||||
.Dd October 25, 1996
|
||||
.Dt DNSSIGNER @CMD_EXT_U@
|
||||
.Os BSD 4
|
||||
.Sh NAME
|
||||
.Nm dnssigner
|
||||
.Nd add signatures to DNS zone files
|
||||
.Sh SYNOPSIS
|
||||
.Nm dnssigner
|
||||
.Op Cm signer-name Ar default_signer
|
||||
.Op Cm boot-file Ar file
|
||||
.Op Cm debug-file Ar file
|
||||
.Op Cm out-dir Ar directory
|
||||
.Op Cm seq-no Ar number
|
||||
.Oo
|
||||
.Cm expiration-time
|
||||
.Oo Po Cm +
|
||||
.Ns \&|
|
||||
.Ns Cm =
|
||||
.Pc Oc
|
||||
.Ns Ar time
|
||||
.Oc
|
||||
.Op Cm hide
|
||||
.Op Cm noaxfr
|
||||
.Op Cm nosign
|
||||
.Op Cm verify
|
||||
.Op Cm update-zonekey
|
||||
.Op Fl d Ns Ar level
|
||||
.Sh DESCRIPTION
|
||||
.Ic Dnssigner
|
||||
(Sign DNS zone database) is a tool to generate signatures
|
||||
for DNS (Domain Name System) resource records. It also generates
|
||||
NXT records for each zone.
|
||||
.Pp
|
||||
.Bl -tag -width Fl
|
||||
.It Cm signer-name Ar default_signer
|
||||
Specifies a name of the key to use if no signer is defined using the
|
||||
.Em Li $SIGNER
|
||||
directive in the boot files.
|
||||
.It Cm boot-file Ar file
|
||||
Specifies the control file for
|
||||
.Ic dnssigner ,
|
||||
which is in the same format as the BIND-4
|
||||
.Pa named.boot
|
||||
file.
|
||||
.It Cm debug-file Ar file
|
||||
Redirect debug output to the specified
|
||||
.Ar file ;
|
||||
default is
|
||||
.Pa signer_out
|
||||
in the current directory.
|
||||
.It Cm out-dir Ar directory
|
||||
Write signed files to thie specified
|
||||
.Ar directory ;
|
||||
default is to use
|
||||
.Pa /tmp .
|
||||
.Pp
|
||||
.Sy NOTE :
|
||||
Specify the full path to this directory; relative paths may not work.
|
||||
.It Xo Cm expiration-time
|
||||
.Oo Po Cm +
|
||||
.Ns \&|
|
||||
.Ns Cm =
|
||||
.Pc Oc
|
||||
.Ns Ar time
|
||||
.Xc
|
||||
Time when the signature records are to
|
||||
expire. Using either
|
||||
.Dq Cm =
|
||||
or
|
||||
.Em no
|
||||
sign before the
|
||||
.Ar time
|
||||
argument
|
||||
.Po i.e.,
|
||||
.Do Op Cm =
|
||||
.Ns Ar time
|
||||
.Dc
|
||||
.Pc ,
|
||||
the
|
||||
.Ar time
|
||||
is interpreted as an absolute time in seconds when the records will expire.
|
||||
.Po Sy NOTE :
|
||||
All such times are interpreted as Universal Times.
|
||||
.Pc
|
||||
With
|
||||
.Dq Cm +
|
||||
specified
|
||||
.Pq i.e., Dq Cm + Ns Ar time ,
|
||||
the
|
||||
.Ar time
|
||||
time is interpreted as an offset into the future.
|
||||
.Pp
|
||||
If not specified on the command line, the default
|
||||
.Cm expiration-time
|
||||
is 3600*24*30 sec (30 days).
|
||||
.It Cm seq-no Ar number
|
||||
Force the serial number in the SOA records to the specified value.
|
||||
If this parameter is not set, the serial number will be set to a value
|
||||
based on the current time.
|
||||
.It Cm hide
|
||||
This flag will cause NXT records in zones with wildcard
|
||||
records to point to
|
||||
.Li *.<zone>
|
||||
as the next host. The purpose of this
|
||||
flag is to hide all information about valid names in a zone.
|
||||
.It Cm noaxfr
|
||||
Turn of generation of zone transfer signature records,
|
||||
which validate the transfer of an entire zone.
|
||||
.It Cm nosign
|
||||
When this flag is specified, the boot files are read, NXT
|
||||
records are generated and zone file is written to the output
|
||||
directory. No SIG records are generated. This flag is useful for
|
||||
quickly checking the format of the data in the boot files, and to
|
||||
have boot files sorted into DNSSEC order.
|
||||
.It Cm verify
|
||||
When this flag is present,
|
||||
.Ic dnssigner
|
||||
will verify all
|
||||
signed records and print out a confirmation message for each SIG
|
||||
verified. The main use of this flag is to see how long it takes to
|
||||
generate each signature.
|
||||
.It Cm update-zonekey
|
||||
If this flag is specified, then the zonekeys used
|
||||
to sign files will be updated with new records. Specify this flag if
|
||||
one or more of the keys have been updated. If there are no zonekeys
|
||||
specified in the boot files, this flag will insert them. Omitting
|
||||
zonekeys will cause primary nameservers to reject the zone.
|
||||
.It Fl d Ns Ar level
|
||||
Debug level to use for running
|
||||
.Ic dnssigner ;
|
||||
these levels are the same as those used by
|
||||
.Xr @INDOT_U@NAMED @SYS_OPS_EXT_U@
|
||||
.El
|
||||
.Ss DETAILS
|
||||
.Ic Dnssigner
|
||||
reads BIND-4
|
||||
.Pa named.boot
|
||||
and zone files, adds SIG and NXT
|
||||
records and writes out the records (to one file per zone, regardless of
|
||||
how many include files the original zone was in). The files generated by
|
||||
.Ic dnssigner
|
||||
are ordinary textual zone files and are then normally
|
||||
loaded by
|
||||
.Xr @INDOT_U@NAMED @SYS_OPS_EXT_U@
|
||||
to serve the zone.
|
||||
.Ic Dnssigner
|
||||
\fBrequires that the PRIVATE key(s) reside in the input directory\fP.
|
||||
.Pp
|
||||
Making manual changes to the output files is hazardous, because most
|
||||
changes will invalidate one or more signatures contained therein. This
|
||||
will cause the zone to fail to load into
|
||||
.Xr @INDOT_U@NAMED @SYS_OPS_EXT_U@ ,
|
||||
or will cause subsequent
|
||||
failures in retrieving records from the zone. It is far better to make
|
||||
changes in
|
||||
.Ic dnssigner's
|
||||
input files, and rerun
|
||||
.Ic dnssigner .
|
||||
.Pp
|
||||
When
|
||||
.Ic dnssigner
|
||||
detects a delegation point, it creates a special file
|
||||
.Pa <zone_name>.PARENT
|
||||
which contains the RR's the parent zone signs for the
|
||||
child zone (NS, KEY, NXT). The intent is that the child will include this
|
||||
file when loading primary nameservers. Similarly, each zone file ends
|
||||
with the
|
||||
.Dq Li #include <zone_name>.PARENT
|
||||
command. The records
|
||||
in the
|
||||
.Pa .PARENT
|
||||
files are omitted from the SIG(AXFR) calculations as these
|
||||
records usualy are on a different signing cycle.
|
||||
.Pp
|
||||
The
|
||||
.Em Li Dq $SIGNER Op Ar keyname
|
||||
directive can be used to change signers in a
|
||||
zone. If
|
||||
.Ar keyname
|
||||
is omitted, signing is turned off. Keys are loaded the
|
||||
first time the keys are accessed. Only records that are signed by the
|
||||
zone signer (the key that signs the SOA) are included in the SIG(AXFR)
|
||||
calculation. It is not generally recommended that multiple keys sign
|
||||
records in the same zone, unless this is useful for dynamic updates.
|
||||
.Sh ENVIRONMENT
|
||||
No environmental variables are used.
|
||||
.Sh SEE ALSO
|
||||
.Xr @INDOT_U@NAMED @SYS_OPS_EXT_U@ ,
|
||||
RSAREF documentation,
|
||||
Internet-Draft
|
||||
.Em draft-ietf-dnssec-secext-10.txt
|
||||
on Secure DNS, or its successor.
|
||||
.Sh AUTHOR
|
||||
Olafur Gudmundsson (ogud@tis.com)
|
||||
.Sh ACKNOWLEDGMENTS
|
||||
The underlying crypto math is done by the RSAREF or BSAFE libraries.
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue