Compare commits

...
778 Commits
Author SHA1 Message Date
Simon L. B. Nielsen 8723db212b Correct multiple vulnerabilities in OpenSSH.
Security:	FreeBSD-SA-06:22.openssh
Approved by:	so (simon)
2006-09-30 19:58:07 +00:00
Colin Percival eae9de64eb Correct problem in the 2006-09-28 patch concerning the handling of
excessively large DH moduli.

Reported by:	Steve Kiernan (Juniper SIRT)
Security:	FreeBSD-SA-06:23.openssl
Approved by:	so (cperciva)
2006-09-29 13:46:41 +00:00
Colin Percival 3ad2363949 Correct multiple vulnerabilities in crypto(3).
Limit the size of public keys used in order to protect applications
from a denial of service via insane key sizes.

Security:	FreeBSD-SA-06:23.openssl
Approved by:	so (cperciva)
2006-09-28 13:06:23 +00:00
Simon L. B. Nielsen 5bd46f35d7 Correct multiple vulnerabilities in gzip(1).
Security:	FreeBSD-SA-06:21.gzip
Approved by:	so (simon)
2006-09-19 14:13:53 +00:00
Simon L. B. Nielsen 518f8407ec Correct incorrect PKCS#1 v1.5 padding validation in crypto(3). [1]
Correct multiple denial-of-service vulnerabilities in BIND related to
SIG Query Processing and Excessive Recursive Queries. [2]

Security:	FreeBSD-SA-06:19.openssl [1]
Security:	FreeBSD-SA-06:20.bind [2]
Approved by:	so (simon)
2006-09-06 21:23:16 +00:00
Colin Percival 86fcd2acb8 Correct buffer overflow in the handling of LCP options in ppp(4)
Security:	FreeBSD-SA-06:18.ppp
Approved by:	so (cperciva)
2006-08-23 22:06:40 +00:00
Colin Percival 6c2f24c880 Correct a bug in the handling of multipart messages by sendmail(8)
which can allow a malformed message to crash a sendmail queue
processing process.

Security:	FreeBSD-SA-06:17.sendmail
Approved by:	so (cperciva)
2006-06-14 16:01:20 +00:00
Colin Percival 9d247711af Enable inadvertantly disabled "securenet" access controls in ypserv. [1]
Correct a bug in the handling of backslash characters in smbfs which can
allow an attacker to escape from a chroot(2). [2]

Approved by:	so (cperciva)
Security:	FreeBSD-SA-06:15.ypserv [1]
Security:	FreeBSD-SA-06:16.smbfs [2]
2006-05-31 22:33:41 +00:00
Colin Percival 69e48a4731 MFC: Correct a local information leakage bug affecting AMD FPUs.
Security:	FreeBSD-SA-06:14.fpu
Approved by:	so (cperciva)
2006-04-19 07:03:14 +00:00
Colin Percival 2c82120cef Add missing code needed for the detection of IPSec packet replays. [1]
Correctly identify the user running opiepasswd(1) when the login name
differs from the account name. [2]

Modify timeout handling logic in sendmail(8) to correct a reported
signal handling race condition. [3]

Approved by:	so (cperciva)
Security:	FreeBSD-SA-06:11.ipsec [1]
Security:	FreeBSD-SA-06:12.opie [2]
Security:	FreeBSD-SA-06:13.sendmail [3]
2006-03-22 16:03:25 +00:00
Simon L. B. Nielsen 7393d7b5b5 Correct a remote DoS in OpenSSH when using PAM and privilege
separation. [06:09]

Submitted by:	des

Correct a remote kernel panic when processing zero-length RPC records
via TCP. [06:10]

Security:	FreeBSD-SA-06:09.openssh
Security:	FreeBSD-SA-06:10.nfs
Approved by:	so (cperciva)
2006-03-01 14:24:52 +00:00
Colin Percival 1cdc31cf59 MFRELENG_5 sys/netinet/tcp_sack.c rev. 1.3.2.10:
Avoid an infinite loop in sack scoreboard processing when the per-hole
  limits or global scoreboard limits are reached, or when memory
  exhaustion occurs. This can occur when an existing hole fails to be
  split due to limits or memory exhaustion.

Security:	FreeBSD-SA-06:08.sack
Approved by:	so (cperciva)
2006-02-01 19:43:36 +00:00
Colin Percival 79315b47bd MFC rev. 1.16 of sys/contrib/pf/net/pf_norm.c: Correct an error in pf
handling of IP packet fragments which could result in a kernel panic.

Security:	FreeBSD-SA-06:07.pf
Approved by:	so (cperciva)
2006-01-25 10:02:27 +00:00
Colin Percival a0b6de1c4f Correct insecure temporary file usage in texindex. [06:01]
Correct insecure temporary file usage in ee. [06:02]
Correct a race condition when setting file permissions, sanitize file
names by default, and fix a buffer overflow when handling files
larger than 4GB in cpio. [06:03]

Security:	FreeBSD-SA-06:01.texindex
Security:	FreeBSD-SA-06:02.ee
Security:	FreeBSD-SA-06:03.cpio
Approved by:	so (cperciva)
2006-01-11 08:08:08 +00:00
Colin Percival 6a0d191c9c Correct a man-in-the-middle SSL version rollback vulnerability.
Security:       FreeBSD-SA-05:21.openssl
Approved by:    so@ (cperciva)
2005-10-11 11:52:28 +00:00
Colin Percival 7f30c17915 Fix an additional temporary file usage bogon which was apparently fixed
but not MFCed to RELENG_5_3 earlier.

Approved by:	so (cperciva)
Security:	FreeBSD-SA-05:20.cvsbug
2005-09-09 19:26:19 +00:00
Colin Percival 8ad39d2c89 MFC: Correct insecure temporary file usage.
Security:	FreeBSD-SA-05:20.cvsbug
Approved by:	so (cperciva)
2005-09-07 13:44:36 +00:00
Colin Percival bd990f4896 Correct a buffer overflow which can occur when decompressing a
carefully crafted deflated data stream. [1]

Correct problems in the AES-XCBC-MAC IPsec authentication algorithm. [2]

Submitted by:   suz [2]
Security:       FreeBSD-SA-05:18.zlib [1], FreeBSD-SA-05:19.ipsec [2]
Approved by:	so (cperciva)
2005-07-27 08:42:37 +00:00
Simon L. B. Nielsen fb3ea47225 MFC rev 1.116 of src/sys/fs/devfs/devfs_vnops.c:
Correct devfs ruleset bypass.

Correct typo in p18 entry, zlib advisory was FreeBSD-SA-05:16.zlib.

Submitted by:	csjp
Reviewed by:	phk
Security:	FreeBSD-SA-05:17.devfs
Approved by:	so (cperciva)
2005-07-20 13:37:27 +00:00
Colin Percival d87c3541fe MFC rev. 1.6 of src/lib/libz/inftrees.c:
Correct a buffer overflow which occurred in the handling of some
  particularly corrupt deflated data streams.

Security:	FreeBSD-SA-05:16.zlib
Approved by:	so (cperciva)
2005-07-06 14:01:52 +00:00
Simon L. B. Nielsen 681614024c Correct bzip2 denial of service and permission race vulnerabilities.
Obtained from:	Redhat, Steve Grubb via RedHat
Security:	CAN-2005-0953, CAN-2005-1260
Security:	FreeBSD-SA-05:14.bzip2
Approved by:	obrien

Correct TCP connection stall denial-of-service vulnerabilities.

MFC: rev 1.270 of tcp_input.c, rev 1.25 of tcp_seq.h by ps: When a TCP
packets containing a timestamp is received, inadequate checking of
sequence numbers is performed, allowing an attacker to artificially
increase the internal "recent" timestamp for a connection.

A TCP packets with the SYN flag set is accepted for established
connections, allowing an attacker to overwrite certain TCP options.

Security:	CAN-2005-0356, CAN-2005-2068
Security:	FreeBSD-SA-05:15.tcp

Approved by:	so (cperciva)
2005-06-29 21:46:15 +00:00
Simon L. B. Nielsen e12769c3cf Correct several denial-of-service vulnerabilities in tcpdump.
Security:	FreeBSD-SA-05:10.tcpdump
Security:	CAN-2005-1267, CAN-2005-1278, CAN-2005-1279, CAN-2005-1280
Obtained from:	tcpdump.org

Correct directory traversal and race condition vulnerabilities in gzip.

Security:	FreeBSD-SA-05:11.gzip
Security:	CAN-2005-0988, CAN-2005-1228
Obtained from:	Steve Grubb via RedHat, Debian

Correct BIND 9 DNSSEC remote denial of service vulnerability.

Security:	FreeBSD-SA-05:12.bind9
Security:	CAN-2005-0034
Obtained from:	ISC
Submitted by:	trhodes

Approved by:	so (nectar, cperciva)
2005-06-08 21:29:15 +00:00
Jacques Vidrine 0661094c6f Add a knob for disabling/enabling HTT, "machdep.hyperthreading_allowed".
Default off due to information disclosure on multi-user systems.

Submitted by:	cperciva
Reviewed by:	jhb
Approved by:	security-officer
2005-05-13 00:02:47 +00:00
Colin Percival 8ce93286c3 MFC: Fix two issues which were missed in FreeBSD-SA-05:08.kmem.
Reported by:	Uwe Doering
Approved by:	so (cperciva)
2005-05-08 10:23:51 +00:00
Colin Percival 9be1408548 If we are going to
1. Copy a NULL-terminated string into a fixed-length buffer, and
2. copyout that buffer to userland,
we really ought to
0. Zero the entire buffer
first.

Security: FreeBSD-SA-05:08.kmem
Approved by: so (cperciva)
2005-05-06 02:50:35 +00:00
Colin Percival 87c0973d9e Correctly validate inputs to the i386_get_ldt syscall.
Security: FreeBSD-SA-05:07.ldt
Approved by: so (cperciva)
2005-05-06 02:40:32 +00:00
Colin Percival e0b23d9f85 Correct improper permissions on /dev/iir. The earlier permissions
of 0644 allowed for people to do Evil Things via ioctl(2).

Security: FreeBSD-SA-05:06.iir
Approved by: so (cperciva)
2005-05-06 02:34:01 +00:00
Simon L. B. Nielsen d90b28be41 MFC:
Correct multiple security related errors: a buffer overflow, NULL
pointer dereferences, possible use of uninitialized variables, and
memory leaks.

Security:	CAN-2005-0753
Security:	FreeBSD-SA-05:05.cvs
Approved by:	so (cperciva)
2005-04-22 18:07:10 +00:00
Colin Percival 0752f9e3ef Zero the ifr.ifr_name buffer in ifconf() in order to avoid
accidental disclosure of kernel memory to userland.

Security:	FreeBSD-SA-05:04.ifconf
Approved by:	so (cperciva)
2005-04-15 01:53:14 +00:00
Colin Percival cfba578f82 Fully initialize the required TSS fields so that the io permission
bitmap is set correctly.

Patch from:	peter
Security:	FreeBSD-SA-05:03.amd64
Approved by:	so (cperciva)
2005-04-06 01:06:44 +00:00
Colin Percival 1eb4f66564 MFC revision 1.103.
Security:	FreeBSD-SA-05:02.sendfile
Approved by:	so (nectar)
2005-04-04 23:54:33 +00:00
Jacques Vidrine 3ba520e893 MFC src/contrib/telnet/telnet.c 1.16: Correct buffer overflows in
telnet(1).
Security: CAN-2005-0468, CAN-2005-0469
Approved by:	security-officer
2005-03-28 15:50:17 +00:00
Ken Smith 59ca7ea8d6 MFR5 for FreeBSD-EN-05:03.ipi
From commit to RELENG_5:
  MFC IPI panic fix done by Stephan Uphoff:
          sys/i386/i386/apic_vector.s     1.101 -> 1.102
          sys/i386/i386/mp_machdep.c      1.241 -> 1.243
          sys/i386/include/apicvar.h      1.8 -> 1.9
          sys/i386/include/smp.h          1.78 -> 1.79

  To quote the original commit message:
          Avoid more than two pending IPI interrupt vectors per local APIC
          as this may cause deadlocks.

          This should fix kern/72123.

          Discussed with: jhb
          Tested by: Nik Azim Azam, Andy Farkas, Flack Man, Aykut KARA
                     Izzet BESKARDES, Jens Binnewies, Karl Keusgen

  Discussed with: ups
  Reviewed by:    jhb

Versions being merged from RELENG_5:

  src/sys/i386/i386/apic_vector.s	1.101.2.1
  src/sys/i386/i386/mp_machdep.c	1.235.2.4
  src/sys/i386/include/apicvar.h	1.8.2.1
  src/sys/i386/include/smp.h		1.78.2.1

Approved by:	so (nectar)
2005-01-16 08:29:13 +00:00
Jacques Vidrine b4bd4006ca Merge from RELENG_5 if_sk.c 1.83.2.3 1.83.2.4, if_skreg.h 1.20.2.3:
Correct bugs in the sk(4) network driver that could result in
data corruption and system crashes on SMP systems.

Approved by:	so, re
2005-01-06 17:54:47 +00:00
Ken Smith a750b6376a MFC of src/sys/nfsserver/nfs_serv.c rev 1.147.2.3:
Merge nfs_serv.c:1.151 from HEAD to RELENG_5:

    date: 2004/11/11 21:30:52;  author: rwatson;  state: Exp;  lines: +52 -38
    Correct a bug in nfsrv_create() where a call to nfsrv_access() might
    be made holding the NFS server mutex.  To clean this up, introduce a
    version of the function, nfsrv_access_withgiant(), that expects the
    NFS server mutex to already have been dropped and Giant acquired.
    Wrap nfsrv_access() around this.  This permits callers to more
    efficiently check access if they're in a code block performing VFS
    operations, and can be substitited for the nfsrv_access() call that
    triggered this bug.

    PR:             73807, 73208

Approved by:	so (nectar)
Work done by:	rwatson
Errata Notice:	FreeBSD-EN-05:01.nfs
2005-01-05 03:35:00 +00:00
Colin Percival 79cea67456 FreeBSD-SA-04:17.procfs:
MFC revision 1.54 of src/sys/fs/procfs/procfs_status.c
MFC revision 1.86 of src/sys/compat/linprocfs/linprocfs.c

Approved by:	so (nectar)
2004-12-01 21:34:43 +00:00
Colin Percival 20e46ec32e FreeBSD-SA-04:16.fetch:
MFC revision 1.75 of src/usr.bin/fetch/fetch.c
Bump newvers.sh and document in UPDATING.

Approved by:	so
2004-11-18 12:06:51 +00:00
Scott Long f8d4987d72 Oops, correct date for 5.3
Approved by: re
2004-11-04 19:12:41 +00:00
Scott Long b9cef19b93 Update the BSD Family tree for OpenBSD 3.6 and the new 5.3 date
Approved by: re
2004-11-04 19:11:55 +00:00
Scott Long fff5c2eb7b New date for 5.3-RELEASE
Approved by: re
2004-11-04 18:52:55 +00:00
Scott Long 891921eee7 Move back up to 5.3-RELEASE
Approved by: re
2004-11-04 18:51:30 +00:00
Ken Smith 3d85fb0d3f MFC of Rev. 1.103:
> revision 1.103
> date: 2004/11/03 18:26:06;  author: kensmith;  state: Exp;  lines: +7 -0
> Update the list of package names/descriptions.

Approved by:	re (scottl)
2004-11-04 05:04:53 +00:00
Robert Watson 80083f9e6f Merged uipc_socket.c:1.216 from HEAD to RELENG_5_3:
date: 2004/11/02 17:15:13;  author: rwatson;  state: Exp;  lines: +1 -0
  Acquire the accept mutex in soabort() before calling sotryfree(), as
  that is now required.

  RELENG_5_3 candidate.

  Foot provided by:       Dikshie <dikshie at ppk dot itb dot ac dot id>

Approved by:	re (kensmith)
2004-11-04 01:17:31 +00:00
Hiroki Sato aea51f27c2 Fix a lot of grammatical errors.
Submitted by:	Eric van Gyzen (vangyzen at stat dot duke dot edu)
Approved by:	re
2004-11-03 10:12:51 +00:00
Simon L. B. Nielsen e84dac32d3 MFC 1.260:
Add an "old-style" entry for the hptmv(4) until it gets a manual page.

Approved by:	re (scottl)
2004-11-03 00:18:51 +00:00
Ken Smith a554298d88 Get ready for RC2 builds.
Approved by: re (implicit)
2004-10-30 22:07:06 +00:00
Robert Watson fa859363fe Merge if.c:.211 and if_var.h:1.88 from HEAD to RELENG_5_3:
date: 2004/10/30 09:39:13;  author: rwatson;  state: Exp;  lines: +25 -0
  Move if_handoff() from an inline in if_var.h to a function to if.c
  in orden to harden the ABI for 5.x; this will permit us to modify
  the locking in the ifnet packet dispatch without requiring drivers
  to be recompiled.

  MFC after:      3 days
  Discussed at:   EuroBSDCon Developer's Summit

Approved by:    re (kensmith)
2004-10-30 22:01:43 +00:00
Robert Watson 63f872fa99 Merge if_var.h:1.87 from HEAD to RELENG_5_3:
date: 2004/10/30 08:45:13;  author: rwatson;  state: Exp;  lines: +5 -0
  Add additional "spare" fields to 'struct ifnet' in order to improve
  the resistance of the network driver ABI to changes that will be
  required as we optimize locking.

  MFC after:      3 days
  Discussed at:   Developer Summit

Approved by:    re (kensmith)
2004-10-30 21:59:58 +00:00
Robert Watson 69769f91f1 Merge kern_mac.c:1.114 from HEAD to RELENG_5:
date: 2004/10/30 14:20:59;  author: rwatson;  state: Exp;  lines: +21 -0
  Disable use of synchronization early in the boot by the MAC Framework;
  for modules linked into the kernel or loaded very early, panics will
  result otherwise, as the CV code it calls will panic due to its use
  of a mutex before it is initialized.

Approved by:	re (kensmith)
2004-10-30 21:06:07 +00:00
Robert Watson 82d4c1675e Merge tcp_output:1.104 from HEAD to RELENG_5_3:
date: 2004/10/30 12:02:50;  author: rwatson;  state: Exp;  lines: +2 -2
  Correct a bug in TCP SACK that could result in wedging of the TCP stack
  under high load: only set function state to loop and continuing sending
  if there is no data left to send.

  RELENG_5_3 candidate.

  Feet provided:  Peter Losher <Peter underscore Losher at isc dot org>
  Diagnosed by:   Aniel Hartmeier <daniel at benzedrine dot cx>
  Submitted by:   mohan <mohans at yahoo-inc dot com>

Approved by:	re (kensmith)
2004-10-30 20:50:06 +00:00
Alfred Perlstein ca8592a606 MFC: 1.295 (clear procfs STOPEVENTS on reciept of SIGKILL)
Approved by: re
2004-10-30 02:57:28 +00:00
Peter Wemm a936ce1f0e MFC: rev 1.45: increase MAXDSIZ from 8MB to 32MB.
(I believe there will be a tag slide for this)

Approved by:  re (kensmith)
2004-10-30 00:11:41 +00:00
Peter Wemm ab74188ed6 MFC: rev 1.13 fix brk(3) on amd64
(I believe there will be a tag slide for this)

Approved by:  re (kensmith)
2004-10-30 00:08:46 +00:00
Alfred Perlstein a90991d829 Backout 1.289.2.3 (MFC of fix for truss problems).
Approved by: re
2004-10-29 08:26:58 +00:00
Maxim Konovalov 2d32bfc09e MFC rev. 1.139: fix a typo in a comparison.
Prodded by:     bms
Approved by:    re (kensmith)
2004-10-28 20:04:14 +00:00
Warner Losh 8ef493b6bc MF RELENG_5 1.9.2.4: another fdc resource layout
The RELENG_5_3_0_RELEASE tag will be slid forward to include this change.

Approved by: re@ (kensmith)
Forgtten by: imp@
Reminded by: bmah
2004-10-28 19:40:40 +00:00
Bruce M Simpson 2cadbb916e MFC of rev 1.99:
Fix a panic during shutdown on SMP machines, by forcing interrupts to
be disabled, and avoiding recursive acquisition of the driver mutex.

CVS tag slip pending by kensmith@.

Approved by:	re@
Tested by:	seb at struchtrup dot com
PR:		kern/62889
2004-10-28 17:51:33 +00:00
Giorgos Keramidas 2b44df41d5 MFC: etc/defaults/rc.conf 1.226
share/man/man5/rc.conf.5	1.229, 1.230

: Introduce root_rw_mount as a new variable in defaults/rc.conf to
: unbreak /etc/rc.d/root for diskless systems that get their root
: filesystem from a read-only NFS mount.
:
: PR:             conf/72927
: Submitted by:   Ralf Wenk <[email protected]>
: Reviewed by:    brooks

Approved by:	re (kensmith)
2004-10-28 13:59:44 +00:00
Ken Smith a424f330df MFC of Rev 1.251. From commit log:
> revision 1.251
> date: 2004/10/23 11:20:26;  author: davidxu;  state: Exp;  lines: +1 -1
> Remove P_STOPPED_TRACE bit if debugger dies without a chance to
> detach debugged process.

Work by:	davidxu
Approved by:	re (kensmith approved davidxu but he asked me to commit)
Note:		RELENG_5_0_3_RELEASE tag will be slid to include this.
2004-10-28 02:49:32 +00:00
Ken Smith 215cd1e94a Since the release has been postponed for an undetermined amount of
time and we have been telling testers about RELENG_5_3 change this
back to RC1 for now.

Approved by:	re (implicit)
2004-10-26 19:07:17 +00:00
Bruce M Simpson ae78dbb3d2 MFC r1.131:
Check that rt_mask(rt) is non-NULL before dereferencing it, in the
RTM_ADD case, thus avoiding a panic.

PR:		kern/42030
Submitted by:	Iasen Kostov
Approved by:	re@
2004-10-26 17:28:36 +00:00
Ken Smith c19ac7f749 Change tag to point at RELENG_5_3.
Requested by:	kuriyama
Approved by:	re (scottl)
2004-10-26 02:58:54 +00:00
Scott Long 1197436f1f Mark the ULE scheduler as broken. Please do not use it when testing 5.3
If you are using it and encounter a problem, please stop using it.

Approved by: re
2004-10-26 02:22:54 +00:00
Hiroki Sato f1d4b4220a Catch up with the English version.
Submitted by:	delphij
Approved by:	re (implicitly)
2004-10-24 18:45:17 +00:00
Scott Long 8e935883b3 Note 5.3-RELEASE in UPDATING.
Approved by: re
2004-10-24 18:28:47 +00:00
Scott Long 09df75ee8e MFC: Hook the hptmv driver to the build
Approved by: re
2004-10-24 18:02:52 +00:00
Hiroki Sato 49fdbbfb0e Update release notes: tzdata2004e.
Approved by:	re (implicitly)
2004-10-24 17:59:57 +00:00
Justin T. Gibbs aeb3936fe4 MFC: Skip probe attempts for ISA PnP devices.
Approved by: re
2004-10-24 17:10:57 +00:00
Hiroki Sato 8141e3844b Merge the following from the English version:
1.256 -> 1.259	hardware/common/dev.sgml

Submitted by:	Ryusuke Suzuki (ryusuke at nucl.sci.hokudai.ac.jp)
Approved by:	re (implicitly)
2004-10-24 15:00:52 +00:00
Hiroki Sato ef622a479c Merge the following from the English version:
1.7 -> 1.8.2.1.2.1	share/sgml/release.dsl

Approved by:	re (implicitly)
2004-10-24 14:51:38 +00:00
Hiroki Sato 71b9c515ce Add a Japanese override of dev-auto.sgml.
Based on work by:	Ryusuke Suzuki (ryusuke at nucl.sci.hokudai.ac.jp)
Approved by:	re (implicitly)
2004-10-24 14:46:48 +00:00
cvs2svn 1666d9d51f This commit was manufactured by cvs2svn to create branch 'RELENG_5_3'. 2004-10-24 14:31:29 +00:00
Hiroki Sato 5ffeeec163 Use URL_ABSOLUTE=yes for making release documentation.
Approved by:	re (implicitly)
2004-10-24 12:43:26 +00:00
Hiroki Sato fb031efd86 Unbreak the build.
Submitted by:	delphij
Approved by:	re (implicitly)
2004-10-24 12:19:05 +00:00
Hiroki Sato 2ee36fda29 Use "relnotes/5.3-RELEASE" for ${RDIR} instead of "relnotes/5-STABLE".
Approved by:	re (implicitly)
2004-10-24 11:05:49 +00:00
Hiroki Sato 15e3d4c64e s/Early Adoptor's Guide/Migration Guide/
Approved by:	re (implicitly)
2004-10-24 10:48:07 +00:00
Hiroki Sato 8730a0b39f Remove an unnecessary part.
Approved by:	re (implicitly)
2004-10-24 10:47:01 +00:00
Hiroki Sato b2c1163ace Bump the version numbers and fix several entities for 5.3R.
Approved by:	re (implicitly)
2004-10-24 10:45:59 +00:00
Scott Long 3be9b7094a MFC: Update the family tree.
Approved by: re
2004-10-24 10:12:03 +00:00
Scott Long 25a37d4a42 Update for 5.3-RELEASE
Approved by: re
2004-10-24 10:01:40 +00:00
Scott Long c514221a8d 5-current packages need to track post 5.3, not post 5.2.
Approved by: re
2004-10-24 09:41:12 +00:00
Scott Long 09369e8c22 Welcome to 5.3-RELEASE
Approved by: re
2004-10-24 09:39:03 +00:00
Scott Long db3d677568 MF5: Update the mdoc to reflect 5.3
Approved by: re
2004-10-24 09:37:09 +00:00
Scott Long 0e07fcb33b MFC:
Do not retry on requests that has lost thier device during reinit.

Should fix hangs on IBM's etc with the fake slave problem.

Approved by: re
2004-10-24 09:31:25 +00:00
Scott Long 8972517206 Use the RELENG_5_3 branch.
Approved by: re
2004-10-24 09:24:25 +00:00
cvs2svn 5ec0ccb230 This commit was manufactured by cvs2svn to create branch 'RELENG_5_3'. 2004-10-24 09:23:09 +00:00
Scott Long 819c44ef93 MFC: Update for 5-STABLE
Approved by: re
2004-10-24 09:18:18 +00:00
Ken Smith e59706e664 MFR5 shifting GENERIC back to UP instead of MP which should be a little
safer for installs and gives the majority of users the correct (faster)
     kernel.

Revs MFR5'd:

> Revision   Changes    Path
> 1.421.2.5  +0 -2      src/sys/amd64/conf/GENERIC
> 1.1.2.1    +9 -0      src/sys/amd64/conf/SMP (new)
> 1.413.2.7  +0 -2      src/sys/i386/conf/GENERIC
> 1.5.2.1    +9 -0      src/sys/i386/conf/SMP (new)

Discussed by:	re@
Approved by:	re (scottl)
2004-10-23 20:04:00 +00:00
Scott Long 81dbbd4a0c MFC: Use gnome2-lite for x86, add ltmdm.
Approved by: re
2004-10-23 19:57:26 +00:00
Scott Long 3b23b9351e MFC: PCI Id for the 21610SA
Approved by: re
2004-10-23 19:22:22 +00:00
Robert Watson 492ec059cf Merge if.c:1.210, if_var.h:1.85 from HEAD to RELENG_5_3:
Define IFF_LOCKGIANT() and IFF_UNLOCKGIANT() macros, which conditionally
  acquire Giant if the passed interface has IFF_NEEDSGIANT set on it.
  Modify calls into (ifp)->if_ioctl() in if.c to use these macros in order
  to ensure that Giant is held.

  MFC after:      3 days
  Bumped into by: jmg

Approved by:    re (kensmith, scottl)
2004-10-23 19:18:05 +00:00
Lukas Ertl bd00f0f74e MFC rev. 1.27:
Return the unit number of a channel instead of a hardcoded '1' from
  the ATA pccard locking function.  This makes pccard devices like
  Compact Flash cards work again.

  PR:             kern/72805
  Submitted by:   James E. Flemer <[email protected]>

Approved by:  re@ (scottl)
2004-10-23 19:05:17 +00:00
Lukas Ertl 9803afcf5c MFC rev. 1.71:
Drop the NDIS lock before returning from ndis_start().

  PR:             i386/72795
  Submitted by:   Frank Mayhar <[email protected]>

Approved by:  re@ (scottl)
2004-10-23 18:58:53 +00:00
John-Mark Gurney 56a8ff8f67 MFR5: if_de.c v1.159:
>  fix (for me) the problems where if_de gets really slow after time
>  (usually taking 20 seconds to transmit a packet).. no longer fall back
>  to only transmitting one packet (instead of the entire queue) after we
>  have processed the entire send queue...  I have no idea why we didn't
>  start seeing this problem ~6 years ago when this code was introduced...

Approved by: re (scottl)
2004-10-23 03:12:33 +00:00
Ken Smith fc5d102fb2 MFR5 of Time Zone update tzdata2004e.
Versions being MFR5-ed:

>   Revision   Changes    Path
>   1.304.2.3  +2 -0      src/etc/mtree/BSD.usr.dist
>   1.24.4.1   +74 -23    src/share/zoneinfo/asia
>   1.27.4.1   +25 -20    src/share/zoneinfo/europe
>   1.10.4.1   +11 -9     src/share/zoneinfo/leapseconds
>   1.23.4.1   +61 -35    src/share/zoneinfo/northamerica
>   1.22.4.1   +184 -27   src/share/zoneinfo/southamerica
>   1.16.4.1   +13 -6     src/share/zoneinfo/zone.tab

Work done by:	wollman
Approved by:	re (scottl)
2004-10-23 03:10:49 +00:00
Ken Smith 19fd54b49e Forced commit to note tags were slid to make the Simplified Chinese
Translation release docs part of RELENG_5 and RELENG_5_3 so they
will be included in the 5.3-RELEASE.

Requested by:	Xin LI <delphij (at) frontfree (dot) net>
Approved by:	re (scottl)
2004-10-22 22:31:13 +00:00
Marcel Moolenaar 2fed94e845 MF5: rev 1.64.2.3:
MFC: rev 1.65:
Don't put devel/gdb6 on disc1 for non-i386 platforms. We have gdb6 in
the base-system. Adding the port for ia64 on disc1 is especially bogus,
because the port doesn't even build on ia64. It also doesn't support
libthread_db.

MFC: rev 1.68:
Seperate ia64 from the pack. The disc1 is overflowing to such extend
that most packages can not be included. It's much easier to list those
that we do want on disc1 for ia64. We only need to list 11 of them.

Approved by: re (scottl)
2004-10-22 20:09:34 +00:00
Scott Long 0013210c70 MFC: Wake up the pager from critical_exit if the process being switched to
needs to be swapped in.

Approved by: re
2004-10-22 19:13:07 +00:00
Mark Murray e9461d4fe1 MFR_5. Make the loadable module have the same content as the
compiled-in mem device. This means the Module has MTRR for
i386 and amd64.

Approved by:	re(scottl)
2004-10-21 19:32:15 +00:00
Poul-Henning Kamp 16bbcfcff1 MFC:
Close a possible race which could prevent geom classes from being unloaded
on SMP machines due to traffic counters getting out of whack.

Approved by:	re::scottl
2004-10-21 17:49:45 +00:00
Colin Percival 221edcfcad MFS revision 1.6.8.1: Fix a buffer overflow.
Approved by:	re (scottl)
2004-10-21 17:05:08 +00:00
Robert Watson 689a28d661 Merge kern_descrip.c:1.246, uipc_socket.c:1.214, uipc_usrreq.c:1.141,
raw_cb.c:1.30, raw_usrreq.c:1.35, ddp_pcb.c:1.45, atm_socket.c:1.21,
ng_btsocket_hci_raw.c:1.16, ng_btsocket_l2cap.c:1.14,
ng_btsocket_l2cap_raw.c:1.13, ng_btsocket_rfcomm.c:1.13, in_pcb.c:1.156,
tcp_subr.c:1.205, in6_pcb.c:1.61, ipx_pcb.c:1.29, ipx_usrreq.c:1.41,
natm.c:1.35, socketvar.h:1.135 from HEAD to RELENG_5_3:

  Push acquisition of the accept mutex out of sofree() into the caller
  (sorele()/sotryfree()):

  - This permits the caller to acquire the accept mutex before the socket
    mutex, avoiding sofree() having to drop the socket mutex and re-order,
    which could lead to races permitting more than one thread to enter
    sofree() after a socket is ready to be free'd.

  - This also covers clearing of the so_pcb weak socket reference from
    the protocol to the socket, preventing races in clearing and
    evaluation of the reference such that sofree() might be called more
    than once on the same socket.

  This appears to close a race I was able to easily trigger by repeatedly
  opening and resetting TCP connections to a host, in which the
  tcp_close() code called as a result of the RST raced with the close()
  of the accepted socket in the user process resulting in simultaneous
  attempts to de-allocate the same socket.  The new locking increases
  the overhead for operations that may potentially free the socket, so we
  will want to revise the synchronization strategy here as we normalize
  the reference counting model for sockets.  The use of the accept mutex
  in freeing of sockets that are not listen sockets is primarily
  motivated by the potential need to remove the socket from the
  incomplete connection queue on its parent (listen) socket, so cleaning
  up the reference model here may allow us to substantially weaken the
  synchronization requirements.

  RELENG_5_3 candidate.

  MFC after:      3 days
  Reviewed by:    dwhite
  Discussed with: gnn, dwhite, green
  Reported by:    Marc UBM Bocklet <ubm at u-boot-man dot de>
  Reported by:    Vlad <marchenko at gmail dot com>

Approved by:    re (scottl)
2004-10-21 09:30:48 +00:00
Robert Watson 47a63880ae Merge nfs_serv.c:1.149 (RELENG_5 1.147.2.2) from HEAD to RELENG_5_3:
date: 2004/10/18 11:23:11;  author: rwatson;  state: Exp;  lines: +61 -13
  Correct several instances where calls to vfs_getvfs() resulting in
  failure in the NFS server would result in a leaked instance of the NFS
  server subsystem lock.  Liberally sprinkle assertions in all target
  labels for error unwinding to assert the desired locking state.

  RELENG_5_3 candidate.

  MFC after:      3 days
  Reported by:    Wilkinson, Alex <alex dot wilkinson at dsto dot defence dot
                  gov dot au>

Approved by:	re (scottl)
2004-10-21 09:01:02 +00:00
Scott Long bbdf1d5a08 Move up to 5.3-RC1
Approved by: re
2004-10-16 19:17:03 +00:00
cvs2svn 5c5cd6c8e7 This commit was manufactured by cvs2svn to create branch 'RELENG_5_3'. 2004-10-16 08:43:07 +00:00
Søren Schmidt 9f37b70b3f MFC:
latest locking updates/fixes.

Approved by: re@ (scottl)
2004-10-16 08:43:06 +00:00
Pawel Jakub Dawidek 20553be303 Do not remove swap partitions by default as it cause some problems.
Instead, add 'swapoff' variable to rc.conf (turned off by default),
so users who use gmirror and swap-on-mirror configuration still can
turn it on and avoid problems with dirty mirror components on next
boot.

Idea from:	NetBSD
Approved by:	re (scottl)
2004-10-16 08:13:19 +00:00
Scott Long 19a139fcd0 MFC:
When harvesting entropy from an ethernet mbuf, do so before freeing the
  mbuf.

Submitted by: rwatson
Approved by: re
2004-10-16 07:04:49 +00:00
Alexander Kabaev 7d8d75eaf7 MFC r1.15:
Use a taskqueue rather than an swi to handle deferred notifications.
Obtained from:  same change for umct(4) driver.

Approved by:	re(scottl)
2004-10-16 03:38:41 +00:00
Alexander Kabaev 263f139a1f MFC r1.1.1.2.
Import a patch from GCC PR c/16999 to stop quoting already quoted ident
strings.

Approved by:	re(scottl)
2004-10-16 03:34:49 +00:00
Stephan Uphoff 98609fcf7f MFC: rev 1.12
Directly modifying the priority of a thread that may be on the runqueue
can break the sorting order of the ksegp run queue.

Approved by:    re (kensmith)
2004-10-16 02:17:54 +00:00
cvs2svn e06b1220a2 This commit was manufactured by cvs2svn to create branch 'RELENG_5_3'. 2004-10-16 02:17:03 +00:00
Stephan Uphoff fce542146e MFC: rev 1.99, rev 1.101
Prevent preemption in slot_fill.
Implement preemption between threads in the same ksegp in out of slot
situations to prevent priority inversion.
Fix maybe_preempt_in_ksegrp for !SMP.

Approved by:    re (kensmith)
2004-10-16 02:17:02 +00:00
Stephan Uphoff 42b4c9a38a MFC: rev 1.150
Force MUTEX_WAKE_ALL.
A race condition in single thread wakeup may break priority
inheritance.

Approved by:    re (kensmith)
2004-10-16 02:14:59 +00:00
Brian Feldman 185be6a972 MFC uma_dbg.c r1.16, uma_core.c r1.106-1.107: critical stability/leak fixes
(for MBUF clusters) implemented by UMA.

Approved by:	re
2004-10-16 01:41:34 +00:00
Christian Brueffer 055c411970 MFC: rev. 1.27, 1.28
- we use /etc/pam.d/login nowadays
- bump document date

Approved by:	re (kensmith)
2004-10-16 00:54:51 +00:00
Brian Feldman 79ccfda5c9 MFC r1.149-r1.151: add IFF_NEEDSGIANT when IS_GIANT and add ALTQ support.
Approved by:	re
2004-10-16 00:53:44 +00:00
Simon L. B. Nielsen 29a3a29747 - PAM configuration is now in /etc/pam.d/su.
- Bump document date.

Approved by:	re (kensmith)
2004-10-15 22:31:56 +00:00
Tony Ackerman e4f50cc9a8 MFC
Added support for Intel PRO/1000 GT Desktop Adapter(Device ID 8086 107C)
Removed support for Intel 82541ER
Added fix for 82547 which corrects an issue with Jumbo frames larger than 10k.
Added fix for vlan tagged frames not being properly bridged.
Corrected TBI workaround.
Corrected incorrect LED operation issues
Fix typeo. Should read ***!***IFQ_DRV_IS_EMPTY.
This might fix some of the trouble around em(4) filling up its buffers.
Don't count RNBC (internal buffer full) towards the RX error count since it's
not really an error.

Approved by:	re[scott long]
2004-10-15 22:12:59 +00:00
John-Mark Gurney 05479a2356 MFC: kern_event.c v1.8[34]:
>  fix a bug where signal events didn't set the flags for attach/detach..
>  PR:             72234

Approved by:	re (scottl)
2004-10-15 21:58:35 +00:00
John-Mark Gurney 32fff7bf29 MFC: uipc_mbuf.c v1.136:
>  improve the mbuf m_print function..  Only pull length from pkthdr if there
>  is one, detect mbuf loops and stop, add an extra arg so you can only print
>  the first x bytes of the data per mbuf (print all if arg is -1), print
>  flags using %b (bitmask)...

musycc.c v1.34:
>  Add -1 to this non-existent use of m_print in the source tree so LINT
>  compiles again :-)

Approved by:	re (scottl)
2004-10-15 21:45:13 +00:00
Giorgos Keramidas dd87d9ed57 MFC 1.3:
Add the necessary magic to make the thousands separator work for
floating-point formats in the Greek locale.

Approved by:	re (kensmith)
2004-10-15 19:46:44 +00:00
Nate Lawson 9462332e2e MFC: Set device flags before probing.
Approved by:	re (kensmith)
2004-10-15 16:03:19 +00:00
Nate Lawson 8f2c005f6c MFC: Print flags options for acpi devices.
* Note, previous commit message should have been:
Set device description for devices that attach via isa_pnp_probe().

Approved by:	re (kensmith)
2004-10-15 16:02:43 +00:00
Ken Smith c90829029e MFC of v1.18, from that log entry:
> date: 2004/09/14 21:58:30;  author: tegge;  state: Exp;  lines: +1 -1
> Correct polarity of packet mode bit.
>
> Problem discovered when 'boot0cfg -B -v -o packet -s 2 ad4' turned off
> packet mode while reporting it as being enabled.

Reviewed by:	tegge
Approved by:	re (scottl)
2004-10-15 15:59:26 +00:00
cvs2svn 38c321d26d This commit was manufactured by cvs2svn to create branch 'RELENG_5_3'. 2004-10-15 06:43:50 +00:00
cvs2svn aa951cbffb This commit was manufactured by cvs2svn to create branch 'RELENG_5'. 2004-10-15 06:43:49 +00:00
Pawel Jakub Dawidek 7baefd1c1d - There don't have to be a lock file.
- Be more userfriendly and allow to specify gbde device name in those forms:
	device
	device.bde
	/dev/device
	/dev/device.bde
- Fix stop routine:
	+ There don't have to be file system mounted on gbde device,
	  so ignore errors from umount(8).
	+ Only detach existing gbde devices.

Approved by:	re (kensmith)
2004-10-15 06:14:43 +00:00
cvs2svn ff9b961e77 This commit was manufactured by cvs2svn to create branch 'RELENG_5_3'. 2004-10-15 06:13:11 +00:00
Pawel Jakub Dawidek 638b61200f - Set maximum request size to MAXPHYS (128kB), instead of DFLPHYS (64kB).
- Set minimum request size to sectorsize, instead of 512 bytes.

Approved by:	re (kensmith)
2004-10-15 06:13:10 +00:00
Pawel Jakub Dawidek b0a2e65f0c Deny invalid I/O requests which comes from userland here, because later
we'll get a panic.

Approved by:	re (kensmith)
2004-10-15 06:12:29 +00:00
Pawel Jakub Dawidek e9aabbae95 - There is no need to skip providers with 0 sectorsize in taste routine
anymore.
- Avoid race while synchronizing components.
- Decrease timeout to 4 seconds.
- Just use MAXPHYS as maximum I/O request size, instead of using my own
  #define for this purpose.

Approved by:	re (kensmith)
2004-10-15 06:11:28 +00:00
Pawel Jakub Dawidek 752ec5cffa - Just use MAXPHYS as maximum I/O request size, instead of using my own
#define for this purpose.
- Before root file system is mounted, wait for mirrors in degraded state.
- Be sure to always return 0 for negative access requests.

Approved by:	re (kensmith)
2004-10-15 06:10:12 +00:00
Pawel Jakub Dawidek cd21f49289 Only allow for unloading when there are no geoms in LABEL GEOM class.
We have to use our own destroy_geom method, because default one, which
is a part of geom_slice is broken.

Approved by:	re (kensmith)
2004-10-15 06:08:14 +00:00
Nate Lawson 0cd9c85b15 MFC: print flags values in device announcement.
Approved by:	re (kensmith)
2004-10-15 05:20:20 +00:00
Nate Lawson 6a16abfad2 MFC: Add acpi attachments for the PNP devices.
Approved by:	re (kensmith)
2004-10-15 05:14:10 +00:00
Warner Losh 5e3b4d5e06 MFC 1.42:
hw.acpi.host_start_mem and revert back to old default.

Approved by: re@ (scottl)
2004-10-14 23:52:21 +00:00
Warner Losh 36b768ef90 MFC 1.115
Refert to using 0x800000 as start address.  hw.pci.host_start_mem
  tunable overrides

Approved by: re@ (scottl)
2004-10-14 23:47:00 +00:00
Andre Oppermann 9dc161731f MFC 1.15: Correctly unregister netisr's.
Approved by:	re (scottl)
2004-10-14 19:19:24 +00:00
Maxime Henrion bdaf0e69b1 Merge if_dc.c:1.152 from HEAD to RELENG_5:
date: 2004/10/01 15:23:31;  author: mux;  state: Exp;  lines: +4 -4
  Read the MAC address in the EEPROM in the correct byte order.  This
  is a no-op on little endian architectures, but fixes getting the MAC
  address for some dc(4) cards on big endian architectures.

Approved by:	re (scottl)
2004-10-14 18:37:01 +00:00
Brooks Davis b9323a6215 MFC rev 1.33:
A power failure left the temporary /var/.diskless directory
  on my system, and since then my /var was always created as
  MFS which was very surprising.  Fix this for /tmp and /var.

Approved by:    re (kensmith)
2004-10-14 14:38:49 +00:00
Robert Watson 3cb254ea13 Merge udp_usrreq.c:1.167 from HEAD to RELENG_5:
date: 2004/10/12 20:03:56;  author: rwatson;  state: Exp;  lines: +3 -3
  Don't release the udbinfo lock until after the last use of  UDP inpcb
  in udp_input(), since the udbinfo lock is used to prevent removal of
  the inpcb while in use (i.e., as a form of reference count) in the
  in-bound path.

  RELENG_5 candidate.

Approved by:	re (scottl)
2004-10-14 11:49:25 +00:00
Robert Watson 2c3c9533c8 Merge i4b_ipr.c:1.30 and i4b_isppp.c:1.27 from HEAD to RELENG_5:
date: 2004/10/12 09:25:52;  author: rwatson;  state: Exp;  lines: +2 -0
  date: 2004/10/12 09:25:52;  author: rwatson;  state: Exp;  lines: +2 -0
  Mark i4b IPR and SPPP drivers as NET_NEEDS_GIANT(), as they both
  interface with the network stack but are not yet sufficiently
  synchronized to run without the Giant lock.  It migh be possible
  to mark the interfaces as IFF_NEEDSGIANT, but I'm unable to test
  that configuration and am unfamiliar with the architecture of
  i4b.

Approved by:	re (scottl)
2004-10-14 11:48:05 +00:00
Robert Watson 95b65b8064 Merge raw_ip.c:1.145 from HEAD to RELENG_5:
date: 2004/10/12 16:47:25;  author: rwatson;  state: Exp;  lines: +41 -20
  When the access control on creating raw sockets was modified so that
  processes in jail could create raw sockets, additional access control
  checks were added to raw IP sockets to limit the ways in which those
  sockets could be used.  Specifically, only the socket option IP_HDRINCL
  was permitted in rip_ctloutput().  Other socket options were protected
  by a call to suser().  This change was required to prevent processes
  in a Jail from modifying system properties such as multicast routing
  and firewall rule sets.

  However, it also introduced a regression: processes that create a raw
  socket with root privilege, but then downgraded credential (i.e., a
  daemon giving up root, or a setuid process switching back to the real
  uid) could no longer issue other unprivileged generic IP socket option
  operations, such as IP_TOS, IP_TTL, and the multicast group membership
  options, which prevented multicast routing daemons (and some other
  tools) from operating correctly.

  This change pushes the access control decision down to the granularity
  of individual socket options, rather than all socket options, on raw
  IP sockets.  When rip_ctloutput() doesn't implement an option, it will
  now pass the request directly to in_control() without an access
  control check.  This should restore the functionality of the generic
  IP socket options for raw sockets in the above-described scenarios,
  which may be confirmed with the ipsockopt regression test.

  RELENG_5 candidate.

  Reviewed by:    csjp

Approved by:	re (scottl)
2004-10-14 11:45:26 +00:00
cvs2svn e86ddd2dee This commit was manufactured by cvs2svn to create branch 'RELENG_5_3'. 2004-10-14 11:43:17 +00:00
Robert Watson 83c262f9e5 Merge uipc_socket.c:1.213 from HEAD to RELENG_5:
date: 2004/10/11 08:11:26;  author: rwatson;  state: Exp;  lines: +19 -5
  Rework sofree() logic to take into account a possible race with accept().
  Sockets in the listen queues have reference counts of 0, so if the
  protocol decides to disconnect the pcb and try to free the socket, this
  triggered a race with accept() wherein accept() would bump the reference
  count before sofree() had removed the socket from the listen queues,
  resulting in a panic in sofree() when it discovered it was freeing a
  referenced socket.  This might happen if a RST came in prior to accept()
  on a TCP connection.

  The fix is two-fold: to expand the coverage of the accept mutex earlier
  in sofree() to prevent accept() from grabbing the socket after the "is it
  really safe to free" tests, and to expand the logic of the "is it really
  safe to free" tests to check that the refcount is still 0 (i.e., we
  didn't race).

  RELENG_5 candidate.

  Much discussion with and work by:       green
  Reported by:    Marc UBM Bocklet <ubm at u-boot-man dot de>
  Reported by:    Vlad <marchenko at gmail dot com>

Note that this fix is not yet confirmed by submitters to correct the
specific symptom they are seeing, but does correct a known problem.

Approved by:	re (scottl)
2004-10-14 11:43:16 +00:00
Tom Rhodes 8aee1e03d2 MFC: Bring in the startup files to permit loading of mac_bsdextended(4)
rules on system initialization.

Remove requirement on FreeBSD keyword.

Approved by:	re (kensmith)
2004-10-14 04:36:15 +00:00
Brian Feldman f6ebdf929c MFC r1.78: further rule verification (against corrupt rules added by root).
Approved by:	re
2004-10-13 22:07:05 +00:00
Christian Brueffer 8f10d45525 MFC: rev. 1.18
- D-Link DFE-500TX verified to work
- remove the 'Asante' entry which isn't very helpful

Approved by:	re (kensmith)
2004-10-13 21:54:14 +00:00
Max Laier 71b4941454 MFC build fix:
Fix compiler warnings, when __stdcall is #defined, by adding explicit
  casts. These normally only manifest if the ndis compat module is
  statically compiled into a kernel image by way of 'options NDISAPI'.

  Submitted by:	Dmitri Nikulin
  Approved by:	wpaul
  PR:		kern/71449

Approved by:	re (kensmith)
2004-10-13 19:23:33 +00:00
Xin LI 7f7385c91c MFC revision 1.41
date: 2004/09/08 11:25:41;  author: tjr;  state: Exp;  lines: +18 -3
Merge from NetBSD:
Fix a problem in previous: we can't blindly assume that we have
wincnt entries available at the offset the file has been found. If the dos
directory entry is not preceded by appropriate number of long name
entries (happens e.g. when the filesystem is corrupted, or when
the filename complies to DOS rules and doesn't use any long name entry),
we would overwrite random directory entries.

There are still some problems, the whole thing has to be revisited and solved
right.

Approved by:	re (scottl)
Approved by:	murray (mentor)
2004-10-13 16:28:40 +00:00
Xin LI ce5cbe3110 MFC revision 1.36
date: 2004/09/08 10:57:09;  author: tjr;  state: Exp;  lines: +5 -0
Merge from NetBSD:
Fix a panic that occurred when trying to traverse a corrupt msdosfs
filesystem.  With this particular corruption, the code in pcbmap()
would compute an offset into an array that was way out of bounds,
so check the bounds before trying to access and return an error if
the offset would be out of bounds.

Approved by:	re (scottl)
Approved by:	murray (mentor)
2004-10-13 16:27:27 +00:00
Takanori Watanabe c72cf713dc MFC: uhid.c:1.74
Don't use matchlvl attach arg. It seems to be not initialized
in FreeBSD probe mechanism.

Approved by: re(scottl)
2004-10-13 00:51:01 +00:00
John-Mark Gurney df9cff8adf MFC:
if_re.c v1.35, if_rlreg.h v1.48:
>  fix jumbo frames as much as they can be fixed for re.  We now cap the MTU
>  to 7422 since it appears that the 8169S can't transmit anything larger..
>  The 8169S can receive full jumbo frames, but we don't have an mru to let
>  the upper layers know this...
>
>  add fixup so that this driver should work on alignment constrained
>  platforms
>  (!i386 && !amd64)

re.4 v1.9 & v1.10:
>  document the limit on jumbo frame size..                                     and bump document date

Approved by:	re (scottl)
2004-10-12 21:51:20 +00:00
Robert Watson 1f9bc317de Merge tcp_output.c:1.103 from HEAD to RELENG_5:
date: 2004/10/09 16:48:51;  author: rwatson;  state: Exp;  lines: +14 -2
  Acquire the send socket buffer lock around tcp_output() activities
  reaching into the socket buffer.  This prevents a number of potential
  races, including dereferencing of sb_mb while unlocked leading to
  a NULL pointer deref (how I found it).  Potentially this might also
  explain other "odd" TCP behavior on SMP boxes (although  haven't
  seen it reported).

Approved by:	re (kensmith)
2004-10-12 17:36:45 +00:00
Robert Watson aebb1d386e Merge socketvar.h:1.134 from HEAD to RELENG_5:
date: 2004/10/09 16:42:57;  author: rwatson;  state: Exp;  lines: +1 -0
  Add SOCKBUF_UNLOCK_ASSERT(), which asserts that the current thread does
  not hold the mutex for a socket buffer.

This change is a dependency to merge tcp_output.c:1.103.

Approved by:	re (kensmith)
2004-10-12 17:34:13 +00:00
Julian Elischer 64eaf74c00 MFC: remove duplicate slot release.
Approved by:	re (scottl)
2004-10-12 05:33:33 +00:00
Christian Brueffer f280b9cff1 MFC: rev. 1.14
vge(4) supports polling

Approved by:	re (rwatson)
2004-10-12 00:08:02 +00:00
Matt Jacob 81db75342c MFC fixes for working with PAE kernels.
Approved by:	re
2004-10-11 23:59:03 +00:00
Julian Elischer 38629e467a MFC:
Capture calls to execve() to make sure that the
	signal mask is set correctly on the thread that is going to
	continue in the new process. Required for Posix compliance.
	This is not perfect and better fixes may happen after 5.3
	is released.

Approved by: re (scottl)
2004-10-11 20:04:59 +00:00
Brian Feldman 202a0686f4 This means that traffic may be dropped unconditionally for a short period
of time.

Approved by:	re
2004-10-11 18:42:12 +00:00
Denis Peplin 8458030113 Fix typo.
Approved by: re (hrs)
2004-10-11 13:09:51 +00:00
Denis Peplin 537561cd79 Merge from English version 1.761.2.11
Approved by: re (hrs)
2004-10-11 12:59:07 +00:00
Brian Feldman e7e4a1c2e4 MFC r1.46: Do not recurse the routing code.
Approved by:	re
2004-10-11 03:46:38 +00:00
Brian Feldman e4d22827fe MFC r1.11: fail closed when lock acquisition would block.
Approved by:	re
2004-10-11 03:45:57 +00:00
Brian Feldman a56aeb1e8c MFC r1.137: reorder code to respect lock non-recursion.
Approved by:	re
2004-10-11 03:45:21 +00:00
Peter Edwards aec9a222f0 MFC of 1.296:
Fix off-by-one error in fd_native_types that results in a panic
    on boot for machines with 2.88M floppies.

Reviewed by: phk
Approved by: re (scottl@)
2004-10-10 23:49:38 +00:00
Alan Cox c559df2d8b MFC revisions 1.5 and 1.6:
- Update to reflect recent changes such as the fields for O(log n) address
   space allocation.
 - Document the flags field.

Approved by: re (scottl)
2004-10-10 19:53:16 +00:00
Alan Cox 267b92e122 MFC multiple pmap changes
amd64 and i386
 - Remove unnecessary checks for curthread == NULL and pmap == NULL.
 - Release the page queues lock earlier in pmap_protect() and pmap_remove()
   in order to reduce contention.
 - Remove an outdated assertion from _pmap_allocpte().
 - Simplify the reference counting of page table pages.  Specifically, use
   the page table page's wired count rather than its hold count to contain
   the reference count.
 - Prevent the unexpected deallocation of a page table page while
   performing pmap_copy().
 - Eliminate the unnecessary masking of the page offset bits from the
   physical address that is stored in the vm_page.
 - Undo revision 1.251.  This change was a performance pessimizing work-
   around that is no longer required.  Now, if the preexisting PTE is
   invalid, pmap_enter() does not call pmap_invalidate_page() to update
   the TLB(s).
 - Make pte_load_store() an atomic operation in all cases, not just i386
   PAE.
 - Restructure pmap_enter() to prevent the loss of a page modified (PG_M)
   bit in a race between processors.  (This restructuring assumes the newly
   atomic pte_load_store() for correct operation.)

amd64 only
 - It is now an error to call pmap_unuse_pt without the paddr of the pde
   that contained the pte.
 - Remove an unused declaration.

i386 only
 - Modify pmap_pte() to support its use on non-current, non-kernel pmaps
   without holding Giant.

Approved by: re (scottl)
2004-10-10 19:08:00 +00:00
Peter Wemm 4633ee43ac MFi386: Fix breakpoint handling.
Approved by:  re
2004-10-10 18:54:30 +00:00
Mike Makonnen 65279a2aa9 RCS file: /home/ncvs/src/UPDATING,v
----------------------------
revision 1.372
date: 2004/10/07 14:51:23;  author: mtm;  state: Exp;  lines: +0 -0
Make a note in UPDATING about the recent change regarding
the FreeBSD keyword.
=============================================================================

o Add additional information on how to cope with this change.
o Fix the date for the previous libthr change to correctly reflect
  the date it was MFCed on.

Approved by: re/assumed because of approval for the actual src change
2004-10-10 16:16:31 +00:00
Søren Schmidt 5479451b43 MFC:
Pull ATA up to -current levels minus PC98 geometry changes:

Fix the serverworks modesetting code, of mask offset was wrong.
Always set half'n'half mode on ICH* chips.
Fix the PC98 lockups on boot.
Add SHARP to the pool of drives that doesn not need byteswapping.
Add support for the ICH6 in legacy mode.
Dont sleep with lock held.

Approved by:	re@ (scottl)
2004-10-10 15:01:47 +00:00
Scott Long 38345c1381 MFC: Disable MTU feedback on fragmented IPv6 packets.
Submitted by: dwhite
Approved by: re
2004-10-10 13:59:39 +00:00
Mike Makonnen d172341696 RCS file: /home/ncvs/src/etc/rc,v
----------------------------
revision 1.335
date: 2004/10/08 14:23:49;  author: mtm;  state: Exp;  lines: +0 -1
Remove an unused variable.

Submitted by: Pawel Worach <[email protected]>
----------------------------
revision 1.334
date: 2004/10/07 13:55:25;  author: mtm;  state: Exp;  lines: +1 -1
Remove the requirement for the FreeBSD keyword as it no longer
makes any sense.

Discussed with: dougb, brooks
MFC after: 3 days
=============================================================================
RCS file: /home/ncvs/src/etc/rc.d/nsswitch,v
----------------------------
revision 1.4
date: 2004/09/16 17:03:12;  author: keramida;  state: Exp;  lines: +1 -1
Fix requirement of `network' to `NETWORK' because the former isn't
provided by any rc.d script.

Approved by:	mtm
=============================================================================
RCS file: /home/ncvs/src/etc/rc.d/pflog,v
----------------------------
revision 1.3
date: 2004/09/16 17:04:20;  author: keramida;  state: Exp;  lines: +1 -1
We don't have any providers of `beforenetlkm' in FreeBSD.  Remove the
dependency to it from our rc.d scripts.

Approved by:	mtm
=============================================================================

Approved by: re/scottl
2004-10-10 09:50:54 +00:00
Warner Losh 1dbd1d711a MFC: 1.41
Top 32MB rather than top 2G to better match old hardware.

Approved by: re@
2004-10-10 04:47:05 +00:00
Warner Losh 8da0d088ff MFC 1.113, 1.114
Restrict unrestricted memory resources by default.

Approved by: re@
2004-10-10 04:38:52 +00:00
Nate Lawson bf6fa6f9e7 MFC: Only disable the timer for the ASUS P5A and -B.
Approved by:	re (scottl)
2004-10-10 03:15:45 +00:00
Christian S.J. Peron 5d1e011ac8 Log:
Add a note to the man page warning users about possible lock order
  reversals+system lock ups if they are using ucred based rules
  while running with debug.mpsafenet=1.

  I am working on merging a shared locking mechanism into ipfw which
  should take care of this problem, but it still requires a bit more                                                                                        testing and review.

Approved by:	re@ (hrs)
2004-10-10 00:57:23 +00:00
Doug Barton d64cde7e8c MFC improvements to the /etc/namedb symlink issue, NO_BIND_MTREE knob,
and updated make.conf(5).

Approved by:	re (scottl)
2004-10-09 18:38:58 +00:00
David Schultz 9d0490b436 MFC src/sys/nfsclient/nfs_bio.c, v1.136
| nfsclient/nfs_bio.c has a PHOLD() without a PRELE().  Neither should
| be necessary here.  Also, use killproc() instead of psignal().

Approved by:	re (scottl)
2004-10-09 17:11:22 +00:00
David Schultz e2fff36150 MFC src/sys/fs/procfs/procfs_dbregs.c, v1.25 src/sys/fs/procfs/procfs_fpregs.c, v 1.31 src/sys/fs/procfs/procfs_regs.c, v1.30
| Don't PHOLD() the target process in procfs, since this is already done
| in pseudofs.  Moreover, PHOLD() may block between the p_candebug()
| access check and the actual operation.

Approved by:	re (scottl)
2004-10-09 17:11:08 +00:00
David Schultz 1c35693966 MFC src/sys/i386/linux/linux_ptrace.c, v1.14
| Fix the following race:
|
|   1. Process p1 is currently being swapped in.
|   2. Process p2 calls linux_ptrace(PTRACE_GETFPXREGS, p1_pid, ...)
|   3. After acquiring a reference to FIRST_THREAD_IN_PROC(p1),
|      p2 blocks in faultin() while p1 finishes being swapped in.
|      This means p2 won't get back the lock on p1 until after p1's
|      threads are runnable.
|   4. After p1 is swapped in, the first thread in p1 exits.
|   5. p2 now uses its dangling reference to p1's first thread.

Approved by:	re (scottl)
2004-10-09 17:10:48 +00:00
Mike Makonnen 902f60828b MFC:
RCS file: /home/ncvs/src/UPDATING,v
----------------------------
revision 1.370
date: 2004/10/07 05:45:39;  author: mtm;  state: Exp;  lines: +5 -0
Note libthr ABI breakage.
=============================================================================

Approved by: re/assumed because of libthr abi change already approved
2004-10-09 15:58:51 +00:00
Mike Makonnen 199531033f ----------------------------
revision 1.41
date: 2004/09/16 13:55:46;  author: mtm;  state: Exp;  lines: +21 -0
Implement cancellation points in libc interfaces, as specified by POSIX.
=============================================================================

Approved by: re/scottl
2004-10-09 15:37:42 +00:00
Max Laier 89a256681a MFC:
Add a minimal altq.4 manpage to tell about the kernel options and where
  to find more information. Also move the "SUPPORTED DEVICES" section from
  altq.9 to altq.4, where is belongs.

  Requested by:   green

AND

  Rename the QUEUEING section of pf.conf(5) to QUEUEING/ALTQ to make it
  easier to find the appropiate section when redirected from ALTQ(4).

Approved by:	re (scottl)
2004-10-09 15:29:14 +00:00
Mike Makonnen 4e8e4b2f0c Regen for the thr_exit() syscall change.
Approved by: re/scottl
2004-10-09 15:25:41 +00:00
Max Laier 23db2fa1df MFC:
Fix sis, bfe and ndis in the same way dc was fixed:
    Do not tell the hardware to send when there were no packets enqueued.

  Found and reviewed by: green

Approved by:	re (scottl)
2004-10-09 15:20:18 +00:00
Mike Makonnen 8bc61b56c6 ----------------------------
revision 1.32
date: 2004/09/22 18:51:16;  author: mtm;  state: Exp;  lines: +1 -14
Remove vestiges of libthr's signal mangling past. This fixes that last
known problem with mysql on libthr: not being able to kill mysqld.
----------------------------
revision 1.31
date: 2004/09/22 16:53:23;  author: mtm;  state: Exp;  lines: +6 -27
The SUSv3 function say that the affected functions MAY FAIL, if the
specified mutex is invalid. In spec parlance 'MAY FAIL' means it's
up to the implementor. So, remove the check for NULL pointers for two
reasons:
	1. A mutex may be invalid without necessarily being NULL.
	2. If the pointer to the mutex is NULL core-dumping in the
	   vicinity of the problem is much much much better than failing
	   in some other part of the code (especially when the application
	   doesn't check the return value of the function that you oh so
	   helpfully set to EINVAL).
=============================================================================

Approved by: re/scottl
2004-10-09 15:13:50 +00:00
Mike Makonnen 101596b827 MFC:
----------------------------
revision 1.15
date: 2004/10/08 14:48:02;  author: mtm;  state: Exp;  lines: +1 -4
Remove a reference to a non-existent syscall: _thr_exit(). The
actual name is thr_exit(). How this ever worked is beyond me.
----------------------------
revision 1.14
date: 2004/10/06 14:20:57;  author: mtm;  state: Exp;  lines: +2 -3
Close a race between a thread exiting and the freeing of it's stack.
After some discussion the best option seems to be to signal the thread's
death from within the kernel. This requires that thr_exit() take an
argument.

Discussed with: davidxu, deischen, marcel
MFC after: 3 days
=============================================================================

Approved by: re/scottl
2004-10-09 15:12:33 +00:00
Robert Watson ec63867897 Merge ip_mroute.c:1.109 to RELENG_5:
date: 2004/10/07 14:13:35;  author: rwatson;  state: Exp;  lines: +7 -4
  When running with debug.mpsafenet=0, initialize IP multicast routing
  callouts as non-CALLOUT_MPSAFE.  Otherwise, they may trigger an
  assertion regarding Giant if they enter other parts of the stack from
  the callout.

  MFC after:      3 days
  Reported by:    Dikshie < dikshie at ppk dot itb dot ac dot id >

Approved by:	re (scottl)
2004-10-09 15:12:04 +00:00
Mike Makonnen 8cf0e32cc8 MFC:
lib/Makefile:
----------------------------
revision 1.1
date: 2004/08/19 23:41:12;  author: davidxu;  state: Exp;
Add AMD64 support code.
=============================================================================

RCS file: /home/ncvs/src/lib/libthr/arch/i386/i386/_setcurthread.c,v
----------------------------
revision 1.15
date: 2004/08/19 23:49:04;  author: davidxu;  state: Exp;  lines: +10 -3
Adjust code to support AMD64, on AMD64, thread needs to set fsbase by
itself before it can execute any other code, so new thread should be
created with all signals are masked until after fsbase is set.
=============================================================================

RCS file: /home/ncvs/src/lib/Makefile,v
----------------------------
revision 1.190
date: 2004/08/19 23:51:42;  author: davidxu;  state: Exp;  lines: +1 -2
build libthr on amd64.
=============================================================================

Approved by: re/scottl
2004-10-09 15:07:20 +00:00
Julian Elischer 91ffc81a50 MFC (kind of):
part of a small change by davidxu that didn't exactly correspond to
a perfect MFC as it was a change to code that was removed from -current and
put back, where it was never removed from 5.x in the first place.

Approved by:	re (scottl)
2004-10-09 10:36:32 +00:00
David Xu e55314ae08 MFC 1.9:
Allocate red zone and stack space together and then split red zone from
allocated space, orignal code left red zone unallocated, but those space
can be allocated by user code, and result was providing no protection.

Approved by: re (scottl)
2004-10-09 10:21:19 +00:00
Julian Elischer 27e841da15 MFC:
Slight rearrangement of some code to get some locking
  more correct

  Revision  Changes    Path
  1.204     +27 -15    src/sys/kern/kern_kse.c

Approved by:	re (scottl)
2004-10-09 10:19:05 +00:00
Julian Elischer 42a57be305 MFC:
Fix whitespace botch that only showed up in the commit message diff :-/

  Revision  Changes    Path
  1.134     +1 -1      src/sys/kern/sched_ule.c

Approved by:	re (scottl)
2004-10-09 10:04:13 +00:00
cvs2svn e6cea8cec4 This commit was manufactured by cvs2svn to create branch 'RELENG_5'. 2004-10-09 07:31:04 +00:00
Julian Elischer b95b5a2615 MFC:
When preempting a thread, put it back on the HEAD of its run queue.
  (Only really implemented in 4bsd)

  Revision  Changes    Path
  1.97      +8 -6      src/sys/kern/kern_switch.c
  1.67      +28 -26    src/sys/kern/sched_4bsd.c
  1.133     +14 -6     src/sys/kern/sched_ule.c
  1.408     +2 -0      src/sys/sys/proc.h
  1.5       +1 -1      src/sys/sys/runq.h

Approved by:	re (scottl)
2004-10-09 05:25:22 +00:00
Julian Elischer bafd6c1297 MFC:
Fix breakpoint handling for i386.
  Also fixes small problems with examining some registers and
  some specific gdb transfer problems.

PR:             i386/71715
Submitted by:   Stephan Uphoff <[email protected]>

Approved by:	re (scottl)
2004-10-09 05:20:18 +00:00
Julian Elischer 407a8b0126 MFC:
Always start out with an initialised ksegrp structure.

  Revision  Changes    Path
  1.200     +3 -3      src/sys/kern/kern_thread.c

Approved by:	re (scottl)
2004-10-09 04:49:58 +00:00
Julian Elischer b36b34021c MFC:
Use some macros to track available scheduler slots to allow
  easier debugging.

  Revision  Changes    Path
  1.96      +8 -3      src/sys/kern/kern_switch.c
  1.66      +26 -4     src/sys/kern/sched_4bsd.c
  1.131     +30 -16    src/sys/kern/sched_ule.c
  1.132     +2 -0      src/sys/kern/sched_ule.c

Approved by:	re (scottl)
2004-10-09 04:47:37 +00:00
Julian Elischer 61914022cf MFC:
Break out to a separate function, the code to revert a multithreaded
  process back to officially being a non-threaded program.

  Revision  Changes    Path
  1.203     +1 -2      src/sys/kern/kern_kse.c
  1.201     +26 -14    src/sys/kern/kern_thread.c
  1.407     +1 -0      src/sys/sys/proc.h

Approved by:	re (scottl)
2004-10-09 04:42:41 +00:00
Julian Elischer 8bf9eef549 MFC:
1.254     +46 -12    src/sys/kern/kern_exec.c
 1.203     +60 -23    src/sys/kern/kern_thread.c
 1.409     +5 -3      src/sys/sys/proc.h

 In original kern_execve() code, at the start of the function, it forces
 all other threads to suicide, problem is execve() could be failed, and
 a failed execve() would change threaded process to unthreaded, this side
 effect is unexpected.
 The new code introduces a new single threading mode SINGLE_BOUNDARY, in
 the mode, all threads should suspend themself at user boundary except
 the singler. we can not use SINGLE_NO_EXIT because we want to start from
 a clean state if execve() is successful, suspending other threads at unknown
 point and later resuming them from there and forcing them to exit at user
 boundary may cause the process to start from a dirty state. If execve() is
 successful, current thread upgrades to SINGLE_EXIT mode and forces other
 threads to suicide at user boundary, otherwise, other threads will be resumed
 and their interrupted syscall will be restarted.

Submitted by:	davidxu
Approved by:	re (scottl)
2004-10-09 04:33:02 +00:00
Julian Elischer d50283a682 MFC 1.202:
Slight cleanup in the single threading code.

 needed to make the next MFC apply cleanly..

Approved by:	re (scottl)
2004-10-09 04:21:34 +00:00
Julian Elischer 935dc23b53 MFC 1.28:
Close a race between thr_create and sysctl -w, the thr_scope_sys could
    be changed when thr_create is running, and we tested it for several times.

Submitted by:	davidxu
Approved by:	re (scottl)
2004-10-09 04:13:58 +00:00
Scott Long 43dd15c596 MFC: Increase NKPT to allow for up to 16GB on i386/PAE and amd64.
Approved by: re
2004-10-09 03:00:17 +00:00
Scott Long 8c6692c2d8 MFC locking fixed from HEAD
Approved by: re
2004-10-08 23:56:36 +00:00
Alan Cox 3b64e3a9ce MFC
Add a SOCKBUF_LOCK() to a rarely executed path in do_sendfile().

Approved by: re (scottl)
2004-10-08 23:37:19 +00:00
Simon L. B. Nielsen 3a747a825e Quote sound device names which contain numbers.
Note that this change does not apply to -CURRENT, because config(8)
there has been modified not to require the quoting.

Noticed by:	Martin Faxer <[email protected]>
mdoc(7) advise:	ru
Approved by:	re (hrs)
2004-10-08 20:29:35 +00:00
John Baldwin 975988841c MFC: Add a critical section to close a priority inversion race found by
ups@.

Approved by:	re (scottl)
2004-10-08 19:47:23 +00:00
Nate Lawson e0b3822434 MFC rev 1.8: Override all SSDTs with an empty table when overriding the DSDT.
Approved by:	re (scottl)
2004-10-08 18:09:36 +00:00
Nate Lawson 6c9c9885d4 MFC rev 1.40: Update the man page for overriding your AML.
Approved by:	re (scottl)
2004-10-08 18:08:13 +00:00
Nate Lawson 4bc0bb0d9c MFC: Update comments and man page for acpidump. No functional changes.
Approved by:	re (scottl)
2004-10-08 18:04:08 +00:00
Hiroki Sato f3b79d12bc Trim errata for RELENG_5.
Approved by:	re (implicitly)
2004-10-08 16:07:56 +00:00
Max Laier 35bb263cd0 MFC:
Make pflogd cope with module unload (and the sudden disappearing of
  pflog0). Instead of eating all the available CPU we now shutdown
  gracefully.

  Submitted by:   yongari

Approved by:	re (scottl)
2004-10-08 15:53:34 +00:00
Hiroki Sato e5e8534624 New release notes:
SA-04:15, and BIND update (8.3.1->9.3.0).

Update release notes:
	update a list of network interfaces which support polling(4), and
	fix a typo s/lukemftp/lukemftpd/.

Approved by:	re (implicitly)
2004-10-08 15:53:11 +00:00
Max Laier 07230173a0 MFC:
Remove obsolete references to PFIL_HOOKS and RANDOM_IP_ID

Approved by:	re (scottl)
2004-10-08 15:51:52 +00:00
Alfred Perlstein 1177d8025a MFC 1.291: Clear a process's procfs trace points upon delivery of SIGKILL.
Approved by: re (scottl)
2004-10-08 15:23:50 +00:00
Denis Peplin 22df69f32e Merge from English version 1.21.2.2 -> 1.21.2.4
Approved by:	re (hrs)
2004-10-08 09:26:12 +00:00
Julian Elischer fd683be6a0 MFC of kern_descrip.c 1.245
"Another case where we need to guard against a partially
  constructed process.
      Submitted by: Stephan Uphoff ( ups at tree.com  ) "

Approved by:	re (scottl)
2004-10-08 04:30:03 +00:00
Ken Smith ed1644befb MFC v1.114: On MP machines use a negative quality value for the timers
in the CPUs so they will not be chosen as the main timecounter.  Because
we don't even try to keep the timers in the CPUs synchronized using them
can result in time not monotonically increasing at the whims of which CPU
the timer is checked on.  On non-MP machines use a relatively high value
so the CPUs timer is more likely to be chosen as the main timecounter.

Approved by:	re (scottl)
2004-10-07 22:18:35 +00:00
Ken Smith cde8dc440b MFC of v1.7: Turn off getty for ttyu0/ttyu1 because they are not present
on a freshly installed machine.

Approved by:	re (scottl)
2004-10-07 22:07:31 +00:00
Paul Saab 65945eee6f MFC: rev 1.46 ICH6 support
Approved by:	re
2004-10-07 18:38:55 +00:00
Lukas Ertl 7b90437e8f MFC:
Make it possible to rebuild degraded RAID5 plexes.  Note that it is
currently not possible to do this while the volume is mounted.

Correctly skip the '/dev/' part when creating new drives and prefix
a drive's provider with '/dev/' when printing the config.

Don't allow to create a drive that already exists.

Approved by:  re@ (scottl)
2004-10-07 17:51:06 +00:00
MIHIRA Sanpei Yoshiro 67983d4fa3 MFC uscanner.4 1.18
Add a HARDWARE section which lists supported devices.
EPSON GT-8400UF(This product is same device id, 0x011f
as EPSON Perfection 1670 scanner)

Approved by: re (hrs)
2004-10-07 13:52:14 +00:00
David Xu 5d7337f641 MFC revision 1.292:
>Don't bother to turn off other P_STOPPED bits for SIGKILL, doing
>so would cause kernel to produce an unkillable process in some cases,
>especially, P_STOPPED_SINGLE has a singling thread, turning off the
>bit would mess the state

Approved by: re (jhb)
2004-10-06 23:44:16 +00:00
Peter Wemm f6e359d651 MFC: fix cvsbug to actually work, fix the version number cvs reports.
Approved by:  re (scottl)
2004-10-06 23:40:48 +00:00
Peter Wemm dcfd75385d MFC: jumbo update for build32.sh script
Approved by: re (kensmith, scottl)
2004-10-06 23:37:35 +00:00
Peter Wemm 45f7a05629 MFC: make libgnuregex not depend on -I overrides that conflict with the
build32.sh script.

Approved by:  re (kensmith, scottl)
2004-10-06 23:36:20 +00:00
Bruce A. Mah fce950a8b5 Mention the BIND 8 to BIND 9 transition. Largely based on system
update instructions originally written by dougb for src/UPDATING.

Reviewed by:	dougb, hrs
Approved by:	re (implicitly)
2004-10-06 05:55:51 +00:00
Max Laier fb51f417b5 MFC:
PFIL_HOOKS in no longer an optional item.

  Submitted by:   Anders Hanssen

Approved by:	re (hrs)
2004-10-05 20:44:24 +00:00
Max Laier 52258cdf39 MFC: pf.conf.5, rev 1.3:
Document a problem with user/group filtering. With debug.mpsafenet=1 this
  might result in a deadlock. The fix involves critical changes in the PF
  locking strategy (which will happen after 5.3R). For now advise users to
  set debug.mpsafenet=0 if they use this kind of filtering.

Approved by:	re (hrs)
2004-10-05 20:42:15 +00:00
Sheldon Hearn 4ab6959667 MFC rev 1.32: regen
Approved by:	re (hrs)
2004-10-05 20:12:15 +00:00
Ken Smith 3afbd543d1 MFC of v1.6: set tc_quality field of struct before calling tc_init(),
structure space had been obtained from malloc().

Approved by:	re (scottl)
2004-10-05 17:01:16 +00:00
cvs2svn 4c0c736c6f This commit was manufactured by cvs2svn to create branch 'RELENG_5_3'. 2004-10-05 16:53:59 +00:00
Ken Smith eb46786666 MFC of v1.66: Remove print/acroread4 from the Alpha disc1 since it is
no longer available.

Approved by:	re (scottl)
2004-10-05 16:53:58 +00:00
Brooks Davis 7e4406e1bc MFC: 1.207
Log the renaming of an interface.  This should make it easier to follow
kernel log files.

Approved by:	re (scottl)
2004-10-04 22:57:10 +00:00
Dag-Erling Smørgrav 18daca5ed7 MFC: (1.136) turn VM_KMEM_SIZE_MAX and VM_KMEM_SIZE_SCALE into tunables
Approved by:	re (scottl)
2004-10-03 23:44:31 +00:00
Max Laier e28dbfbc37 MFC pfil API change:
Add an additional struct inpcb * argument to pfil(9) in order to enable
  passing along socket information. This is required to work around a LOR
  with the socket code which results in an easy reproducible hard lockup
  with debug.mpsafenet=1. This commit does *not* fix the LOR, but enables us
  to do so later. The missing piece is to turn the filter locking into a
  leaf lock and will follow in a seperate (later) commit.

  Suggested by:           rwatson
  A lot of work by:       csjp
  LOR IDs:                14 - 17 (not fixed yet)

Approved by:	re (scottl)
2004-10-03 17:04:41 +00:00
Maksim Yevmenkin f4d2cf692b MFC: Make -t <tty> optional. If not specified use stdin/stdout.
Document this. These changes make it possible to write something like

	set device "!/usr/bin/rfcomm_sppd -a BD_ADDR"

inside the /etc/ppp/ppp.conf file. Very convenient for the users :)

Submitted by:	Konstantin Stepanenkov <kstepanenkov AT oilspace DOT com>
Approved by:	re (scottl)
2004-10-03 16:14:43 +00:00
MIHIRA Sanpei Yoshiro 62cba610e1 MFC ich.c 1.43 - 1.45:
Add support Nvidia nForce2(audio)
Add support nForce3 250 audio
Correct the capitalization of "nVidia".

Approved by:	re(hrs)
2004-10-02 22:33:51 +00:00
cvs2svn 831d4a7340 This commit was manufactured by cvs2svn to create branch 'RELENG_5_3'. 2004-10-02 14:17:45 +00:00
Scott Long 9a7ef35e6b Bump to BETA7
Approved by: re
2004-10-02 14:17:44 +00:00
Scott Long 3c1ac75bcb MFC: Fixes contigfree calls so that the driver no longer panics on boot
with INVARIANTS.

Submitted by: sos
Approved by: re
2004-10-02 14:14:27 +00:00
Sam Leffler 4b8fdd5f35 MFC various fixes:
o Correct handling of SADB_UPDATE and SADB_ADD requests.
o Add missing locking for secpolicy refcnt manipulations.
o Remove extraneous SECPOLICY_LOCK_DESTROY calls.

Submitted by:	Roselyn Lee
Approved by:	re (scottl)
2004-10-02 04:55:47 +00:00
Marcel Moolenaar 18e4890963 MFC rev 1.7: Trade slattach for gpt.
Approved by: re (blanket)
2004-10-02 04:16:30 +00:00
Scott Long 767028da93 MFC: Add in libhistory, libm, libopie, libpcap, and libreadline and update
libc, libc_r, and libperl.

Approved by: re
2004-10-02 02:01:51 +00:00
Scott Long 59a296cfd3 MFC: Add The following libraries:
libhistory.so.4
libm.so.2
libopie.so.2
libpcap.so.2
libreadline.so.4

Update the following libraries:
libc.so.4
libc_r.so.4
libperl.so.3

These changes were made by sliding the RELENG_5 and RELENG_5_BP labels.

Approved by: re
2004-10-01 23:16:59 +00:00
Scott Long c8f8fba370 MFC rev 1.68:
Merge netipsec/key.c:1.17 into KAME pfkey implementation:

    date: 2004/09/26 02:01:27;  author: sam;  state: Exp;  lines: +0 -5
    Correct handling of SADB_UPDATE and SADB_ADD requests.  key_align may
    split the mbuf due to use of m_pulldown.  Discarding the result because
    of this does not make sense as no subsequent code depends on the entire
    msg being linearized (only the individual pieces).  It's likely
    something else is wrong here but for now this appears to get things back
    to a working state.

    Submitted by:   Roselyn Lee

  This change was also made in the KAME CVS repository as key.c:1.337 by
  itojun.

Approved by: re
2004-10-01 19:18:55 +00:00
Max Laier b7a3cc40a0 MFC: if_em.c, rev 1.46:
Fix typeo. Should read ***!***IFQ_DRV_IS_EMPTY.
  This might fix some of the trouble around em(4) filling up its buffers.

  Submitted by:   mtm

This is a 5.3 TODO item.

PR:		misc/72183

Approved by:	re (scottl)
2004-10-01 18:51:11 +00:00
Ken Smith 94d10b137d MFC: Bump of library version numbers for:
/lib/{libm,libreadline}
	/usr/lib/{libhistory,libopie,libpcap}

Versions of effected files being MFC-ed from commit done to HEAD:

	Revision  Changes    Path
	1.367     +15 -0     src/UPDATING
	1.10      +1 -1      src/gnu/lib/libreadline/Makefile.inc
	1.19      +1 -1      src/lib/libopie/Makefile
	1.34      +1 -1      src/lib/libpcap/Makefile
	1.52      +1 -0      src/lib/msun/Makefile

Approved by:	re (scottl)
2004-10-01 16:32:06 +00:00
Ken Smith d00a8dfe6d MFC v1.865: Address ia64 disc2 overflow problem and fix to removal of
temp file left by 'make index'.

Approved by:	re (scottl)
2004-10-01 14:26:15 +00:00
Denis Peplin 29e240ed5e Merge from English version 1.761.2.9 -> 1.761.2.10
Approved by:	re (hrs)
2004-10-01 10:43:46 +00:00
David Schultz eadfc8bd2f MFC src/lib/libc/gen/isnan.c,v 1.2
| Remove __isnanl() to avoid conflicting with the same function in libm.
| __isnan() and __isnanf() must remain in libc for hysterical raisins.
| On the other hand, __isnanl() must live in libm because libm uses it
| internally and can't depend on older versions of libc to provide it.
| Fortunately, we don't need __isnanl() in both libraries.

Approved by:	re (scottl)
2004-10-01 06:33:00 +00:00
Philip Paeps 089c498f6c MFC: Introduction of hw.psm.synaptics_support tunable [1] and
documentation for the synaptics support in psm(4) [2].

[1] from psm.c r1.82
[2] from psm.4 r1.44

Approved by:	re (scottl)
2004-10-01 06:26:51 +00:00
Warner Losh dad92355de MFC: 1.46 Better handling of non-existent devices.
Approved by: re@ (scottl)
2004-10-01 06:20:23 +00:00
Warner Losh 16cc82ae62 MFC: 1.59. Fix nonexistant device support in init.
Approved by: re@ (scottl)
2004-10-01 06:08:38 +00:00
Ken Smith f0c7816e23 MFC of v1.17: Raise IPI_RETRIES to a value based on some feedback from
a test patch run by people experiencing a panic.

Approved by:	re (scottl)
2004-10-01 04:04:22 +00:00
John-Mark Gurney 5a538c424e MFC: if_rlreg.h: v1.46
>  comment requirement that rx/tx descriptor counts must be equal due to
>  shared code...
>  define rx descriptor count in terms of tx
>  align defines

v1.47:
>  fix misspelling of TX...

MFC: if_re.c: v1.32
>  pass in pointer to m_head to re_encap because m_defrag could free the
>  original mbuf causing a free'd mbuf passed to bpf later and panic'ing the
>  system..  This should only effect jumbo frames.

v1.33:
>  spell RX correctly
>  don't call re_rxeof a second time when we've already done the work
>  pull common code out from if and else clauses

v1.34:
>  trim trailing white space..
>  call the re mutex by it's name..

Approved by:	re (scottl)
2004-10-01 02:33:58 +00:00
Doug Barton 40f4a63f15 MFC the BIND 9 import and chroot-by-default work up to date.
This includes:
1. More granular NO_BIND_* make knobs.
2. WITH_BIND_LIBS make knob.
3. Run in an automatically configured chroot dir by default.
4. Edit paths in man pages, and install man pages for liblwres.
5. Improve named.conf and make it work with the new structure.
6. Install the bind9 docs.
7. A few Makefile style fixes.

Approved by:	re (scottl)
2004-09-30 23:36:11 +00:00
Søren Schmidt eddb6c4dfe MFC:
Remove the old ATA_*LOCK_CH macros that used atomic ops and use
mutexes instead.
This closes the last (known) race issues in ATA which should fix
the various hangs etc seen on heavy loaded systems.

Change from using timeout functions to using callout functions in
the timeout code. This together with above closes the race that could
happen if timeout and device interrupt occured simultaniously.

Also fix the possible recursion in ata_reinit() on very dodgy
devices that could take us down in the probe.

Approved by: re@ (scottl)
2004-09-30 21:29:19 +00:00
Max Laier f53011f81c MFC from pfvar.h, rev. 1.9 and keydb.h, rev. 1.4
>   Protect sockaddr_union definitions with a protecting define. This allows
>   to build kernels with FAST_IPSEC and PF. This is the least disruptive
>   fix.
>
>   PR:             kern/71836
>   Reviewed by:    bms, various mailing lists

Approved by:	re (scottl)
2004-09-30 20:11:46 +00:00
Max Laier 0d0f7ad215 MFC from pfil.c, rev. 1.9:
>   Switch order for mtx_unlock and cv_signal as (condvar(9)) sez:
>
>        A thread must hold mp while calling cv_signal(), cv_broadcast(), or
>        cv_broadcastpri() even though it isn't passed as an argument.
>
>   and is right with this claim.
>
>   While here remove a "\" from the macro -> __inline conversion.
>
>   Found by:       csjp

Approved by:	re (scottl)
2004-09-30 20:08:35 +00:00
John Baldwin dc4bdce238 MFC: Fix the fdc_acpi attach function to only fall back to enumerating
drives via hints if the _FDE enumeration fails but earlier steps all
succeeded.

Approved by:	re (scottl)
2004-09-30 20:04:56 +00:00
Simon L. B. Nielsen 7bf4601022 MFC 1.259:
- Auto generate device listings for the following drivers: urio, ulpt,
  and umct.

Approved by:	re (hrs)
2004-09-30 18:38:29 +00:00
Simon L. B. Nielsen 0aed82619b MFC 1.10:
- Add a HARDWARE section which lists supported devices based on the
  Hardware Notes.
- Update some text to fit better now that this driver support
  multiple different device types.

Approved by:	re (hrs)
2004-09-30 18:37:21 +00:00
Simon L. B. Nielsen 982dd1f437 MFC 1.7:
Add a HARDWARE section which lists supported devices based on the
Hardware Notes.

Approved by:	re (hrs)
2004-09-30 18:36:33 +00:00
Simon L. B. Nielsen 58f4ac2371 MFC 1.42+1.43:
- Add amd64 for cnw.
- Add ulpt(4) and urio(4).

Approved by:	re (hrs)
2004-09-30 18:34:58 +00:00
John-Mark Gurney bd458ee118 MFC: v1.241:
add MLINKs for the mbuf.9 man page..
and v1.242:
  Sort MAN and MLINKS in dictionary order ignoring case.

Approved by:	re (hrs)
2004-09-30 18:27:13 +00:00
Jacques Vidrine ae105f029c MFC 1.429: Disallow negative coordinates and sizes in the syscons
CONS_SCRSHOT ioctl.

Approved by:	re
2004-09-30 17:49:15 +00:00
Ken Smith 7d5d9d24e2 MFC of v1.67:
Initialize the count of saved register windows to 0 in the pcb created
for the new thread.  The rest of the fields in the pcb wind up being
written to before they're read as a normal part of the pcb usage but
this field may be read upon return to userland, having it be uninitialized
garbage is bad.

Approved by:	re (scottl)
2004-09-30 17:26:51 +00:00
cvs2svn 11b1149885 This commit was manufactured by cvs2svn to create branch 'RELENG_5'. 2004-09-30 05:25:01 +00:00
Dag-Erling Smørgrav 5aa47f29a4 MFC: unsetting an undefined variable or function is not an error.
PR:		standards/45738
Submitted by:	Matthias Andree <[email protected]>
Approved by:	re (scottl)
2004-09-30 04:41:55 +00:00
Brooks Davis 075812e1be MFC: refer to bsdlabel, not disklabel.
Approved by:	re (hrs)
2004-09-30 04:33:52 +00:00
Paul Saab d03c7f1236 MFC: Add support for the 5750/5751
Approved by:	re
2004-09-29 14:31:49 +00:00
Paul Saab 1c9205d5b1 MFC: rev 1.73 supress spurious link change events.
Approved by:	re
2004-09-29 14:29:48 +00:00
Warner Losh 2980b924b0 MFC: Merge case 8 into the resource allocation from 1.15:
>>revision 1.15
>>date: 2004/09/20 06:12:19;  author: imp;  state: Exp;  lines: +14 -4
>>das@ has a ACPI bios that lists 0x3f0-0x3f1, 0x3f2-0x3f3, 0x3f4-0x3f5
>>and 0x3f7.  fdc_isa_alloc_resource() didn't work right in this case
>>(it accessed FDOUT correctly due to an overflow of the first resource.
>>It accesed FDSTS and FDDATA incorrectly via the second resource (which
>>wound up accessing FDOUT and the tape register at 0x3f3) and badly for
>>the CTL register (at location 0x3f4).  This is a minimal fix that just
>>'eats' the first one if it covers two locations and has an offset of
>>0.  This confusion lead the floppy driver to think there'd been a disk
>>change, which uncovered a deadlock in the floppy/geom code which lead
>>to a panic.  These changes fix that by fixing the underlying resource
>>problem, but doesn't address the potential deadlock issue that might
>>still be there.
>>
>>This is a minimal fix so it can more safely be merged into 5 w/o risk
>>for known working configurations (hence the use of the ugly goto,
>>which reduces case 8 to case 6 w/o affecting cases 1-7).  A more
>>invasive fix that will handle more ACPI resource list diversity is in
>>the pipeline that should kill these issues once and for all, while
>>staying within the resources that we allocate.
>>
>>Tested/Reported by: das
>>Reviewed by: njl
>>MFC before: re->next_release_name(5.3-BETA5);

If you get floppy hangs on boot, please try after this patch and let
me know if they are solved.

Approved by: re@ (scottl)
2004-09-29 05:17:26 +00:00
Pawel Jakub Dawidek 87cbbb528b MFC: According to module(9), when command is unrecognized, the module should
return EOPNOTSUPP.

Approved by:	re (scottl)
2004-09-28 18:27:28 +00:00
Pawel Jakub Dawidek 864638b2cf MFC: Fix '-s' option for large disks and fix printing maximum file system size.
Approved by:	re (scottl)
2004-09-28 18:25:48 +00:00
Pawel Jakub Dawidek 7ca614564a MFC: There is no humanize_number(9) manual page in FreeBSD.
Approved by:	re (scottl)
2004-09-28 18:24:50 +00:00
Pawel Jakub Dawidek 45c00a9c9b MFC: Take the lastest fixes from NetBSD.
Approved by:	re (scottl)
2004-09-28 18:24:10 +00:00
Pawel Jakub Dawidek 6c4df367e9 MFC:
- Avoid race while synchronizing components. It is very hard to bump into,
  but it is possible:
  1. Read data from good component for synchronization.
  2. Write data to the same area.
  3. Write synchronization data, which are now stale.
- Decrease kern.geom.mirror.timeout to 4, so it is smaller than
  vfs.root.mountdelay by default.
- Don't skip providers with 0 sectorsize.

Approved by:	re (scottl)
2004-09-28 18:23:14 +00:00
Pawel Jakub Dawidek 3e2b1e8029 MFC: There is no need to skip providers with 0 sectorsize in taste
routine, it is now forced by GEOM.
     Actually, it can even cause some problems, because GEOM requires
     sectorsize to be greater than 0 on first access, not on provider
     creation, so we can skip valid providers by doing this check in
     taste method.

Approved by:	re (scottl)
2004-09-28 18:22:15 +00:00
Pawel Jakub Dawidek 16a37a0c80 MFC: Make kern.geom.debugflags sysctl tunable from /boot/loader.conf.
It will help to debug problems when booting.

Approved by:	re (scottl)
2004-09-28 18:16:51 +00:00
Pawel Jakub Dawidek 43b9d77d53 MFC: Teach swap1 script how to remove added swap devices on system shutdown.
Without this change, if one had a swap-on-mirror configuration, gmirror
     will rebuild mirror component(s) on boot, because they are dirty (they
     were open on shutdown).

Approved by:	re (scottl)
2004-09-28 18:16:05 +00:00
Pawel Jakub Dawidek afbc624eb4 MFC: Don't allow to specify wrong stripe size.
Approved by:	re (scottl)
2004-09-28 18:15:19 +00:00
Pawel Jakub Dawidek 81201e86ad MFC: Document '-p' flag for 'insert' command correctly.
Approved by:	re (scottl)
2004-09-28 18:14:29 +00:00
Pawel Jakub Dawidek 6ed001f09d MFC: Do not exit after printing usage, give geom(8) a chance to show
standard commands.

Approved by:	re (scottl)
2004-09-28 18:13:39 +00:00
Pawel Jakub Dawidek 3ee69ec107 MFC: - Show all commands in usage, even if those commands are not available.
- When command is not available, just say it, instead of says, that
       command is unknown. Old behaviour seems to be too confusing.

Approved by:	re (scottl)
2004-09-28 18:12:32 +00:00
Pawel Jakub Dawidek 64ed36026a MFC: We have now so many GEOM classes that it is better to just skip unknown
classes than exiting.

Approved by:	re (scottl)
2004-09-28 18:11:24 +00:00
Pawel Jakub Dawidek ee9c05f424 MFC: Fix/clean up return values checking.
Approved by:	re (scottl)
2004-09-28 18:10:20 +00:00
Pawel Jakub Dawidek 0cecbc6d45 MFC: Allow to setup gbde on providers which have '/' in their names.
Approved by:	re (scottl)
2004-09-28 18:08:32 +00:00
John Baldwin b2d4521e84 MFC: Improve the panic message for a busted MP table with conflicting
entries for the same PCI interrupt.

Approved by:	re (scottl)
2004-09-28 16:24:09 +00:00
Colin Percival afbcd7ff3c RELENG_5 != current, so call this "... for FreeBSD stable users" instead
of "... for FreeBSD current users".

Pointed out by:	Thierry Herbelot via freebsd-current
Approved by:	re (scottl)
2004-09-28 06:54:02 +00:00
Wes Peters 5a3eb174dc p invalid sector size 0 in disk probe, refusing to add such a
device to the list.  This prevents crashes on /0 errors in 'lsdev'
et al.

Submitted by:	Nicko Dehaine <[email protected]>
Reviewed by:	jhb@
Approved by:	re@
2004-09-27 07:16:47 +00:00
David Schultz 4ecfa4c49b MFC src/sys/vm/swap_pager.c,v 1.257
| Don't look for swap blocks in objects that aren't swap-backed.
| I expect that this will fix the following panic, reported by Jun:
|	swap_pager_isswapped: failed to locate all swap meta blocks

Approved by:	re (scottl)
2004-09-27 04:53:18 +00:00
Dag-Erling Smørgrav 9614790463 MFC: (1.2) document the upgrade procedure
Approved by:	re (implicitly)
2004-09-27 00:29:59 +00:00
Dag-Erling Smørgrav e32cddc5e0 MFC: (1.13) don't create rndc.key if rndc.conf exists.
Approved by:	re (implicitly)
2004-09-26 10:52:35 +00:00
Scott Long 583d94860f Use the gnome2 meta-package instead of gnome2-lite. We have enough room on
the CD for it.  Unfortunately, not all of the KDE pieces are building yet,
and even the pieces that are there now overflow the ISO image.

Approved by: re
2004-09-26 08:09:28 +00:00
Nate Lawson fda7ada791 MFC rev 1.52: Properly initialize the tz flags. This MFC leaves in the
commented out code instead of removing it.

Approved by:	re (scottl)
2004-09-26 06:39:35 +00:00
Maxim Konovalov 0b6599ed28 MFC rev. 1.65, 1.66 loader.8 and rev. 1.29 boot.common: retire
hw.pci.allow_unsupported_io_range.

Approved by:	re (scottl)
2004-09-26 06:32:03 +00:00
Warner Losh 9fcb683ee2 MFC: detach before delete_child.
Approved by: re@
2004-09-26 05:54:28 +00:00
Dag-Erling Smørgrav cf78e84cf2 MFC: BIND 9 and related bits.
Approved by:	re
2004-09-26 03:10:20 +00:00
Maxime Henrion 9d8ad05697 MFC revision 1.218:
Add support for the fxp(4) based card in ICH6 (i915) chipsets.

  Submitted by:   Mike Tancsa <[email protected]>

Approved by:	re@ (scottl)
2004-09-25 22:21:09 +00:00
Marius Strobl d409cd1ce4 MFC: mk48txx.c 1.4; mk48txxreg.h 1.2, 1.3
- Only use the desired bits in the time related registers leaving bits
  with different meaning alone.
- Fix two off-by-one errors in the handling of the day of week. This
  makes the date being stored in the same format Sun/Solaris uses.
- Check the state of the battery on mk48txx that support this in the
  attach function.
- Add a note that use of the century bit should be implemented but isn't
  required at the moment because it isn't used on sparc64.

Approved by:	re (scottl)
2004-09-25 20:53:44 +00:00
Poul-Henning Kamp ba3c188c63 MFC: Use floppy drive unit number, not floppy controller unit number
for creating /dev entries.

Approved by:	re::scottl
2004-09-25 14:39:38 +00:00
Scott Long ad45983508 Bump to BETA6
Approved by: re
2004-09-25 14:31:37 +00:00
Alan Cox a26d6cf4da MFC
Correct a long-standing error in _pmap_unwire_pte_hold() affecting
 multiprocessors.  Specifically, the error is conditioning the call to
 pmap_invalidate_page() on whether the pmap is active on the current CPU.
 This call must be unconditional.

Approved by: re (kensmith)
2004-09-25 06:35:42 +00:00
cvs2svn 7dfe289ead This commit was manufactured by cvs2svn to create branch 'RELENG_5'. 2004-09-25 00:42:39 +00:00
Marius Strobl bd5f3ec4b9 MFC: 1.4
Don't call uart_bus_probe() for non-matching PnP-devices.

Approved by:	re (scottl)
2004-09-24 22:50:57 +00:00
Marius Strobl 8cdda268f6 MFC: vinumext.h 1.43, vinummemory.c 1.36
Fix compilation of vinum(4) when VINUMDEBUG is not defined.

Approved by:	re (scottl)
2004-09-24 22:40:01 +00:00
Brooks Davis a5be299352 MFC: 1.208, 1.209
Fix a LOR where ifconf() used copyout while holding a mutex.  This LOR
was seen when configuring addresses on interfaces using ifconfig.  This
patch has been verified to work with over eight thousand addresses
assigned to an interface.

Approved by:	re (scottl)
LOR id:		031
2004-09-24 22:36:51 +00:00
Simon L. B. Nielsen 8eae629e32 MFC:
Auto generate device listings for the snd_ess(4) driver.

Approved by:	re (blanket)
2004-09-24 19:42:14 +00:00
Simon L. B. Nielsen 5a4d5a1efd MFC the snd_ess(4) manual page.
Approved by:	re (blanket)
2004-09-24 19:39:14 +00:00
cvs2svn 66ca21b807 This commit was manufactured by cvs2svn to create branch 'RELENG_5'. 2004-09-24 18:42:06 +00:00
Ken Smith bb0588b613 MFC rev 1.864: Fix-ups for problems reported with how ports get packaged
for the release.

Approved by:	re (scottl)
2004-09-24 16:34:08 +00:00
Lukas Ertl 9a7db3558d Big geom_vinum MFC:
geom_vinum.c:
   MFC rev. 1.10, 1.11

geom_vinum.h:
   MFC rev. 1.3, 1.4, 1.5, 1.6

geom_vinum_drive.c:
   MFC rev. 1.10, 1.11, 1.12, 1.13, 1.14

geom_vinum_init.c:
   MFC rev. 1.3, 1.4, 1.5

geom_vinum_plex.c:
   MFC rev. 1.9, 1.10

geom_vinum_raid5.c:
   MFC rev. 1.6, 1.7

geom_vinum_raid5.h:
   MFC rev. 1.3

geom_vinum_rm.c:
   MFC rev. 1.2, 1.3, 1.4, 1.5

geom_vinum_state.c:
   MFC rev. 1.3, 1.4, 1.5

geom_vinum_subr.c:
   MFC rev. 1.7, 1.8, 1.9, 1.10

geom_vinum_var.h:
   MFC rev. 1.2, 1.3

geom_vinum_volume.c:
   MFC rev. 1.5, 1.6

Approved by:  re@ (scottl)
2004-09-24 16:23:17 +00:00
Roman Kurakin e6f37f7d0c MFC revision 1.238 to 1.239
date: 2004/09/23 16:06:27;  author: rik;  state: Exp;  lines: +7 -3
	Invalidate cache after changing pte entry.

	Discussed with: jhp and njl

Approved by:	re (scottl)
2004-09-24 15:02:33 +00:00
Peter Pentchev ff53e7433f MFC adduser.sh 1.25: only print /usr/sbin/nologin once when updating
the master.passwd file.

Approved by:	re (scottl)
2004-09-24 14:18:16 +00:00
Maxim Konovalov a2685fbbb8 MFC rev. 1.290: turn net.inet.ip.check_interface sysctl off by default.
Approved by:	re (scottl)
2004-09-24 12:20:34 +00:00
John Baldwin 180903d464 MFC: Force a redraw if all dists are selected.
Approved by:	re (kensmith)
2004-09-23 18:23:42 +00:00
Hiroki Sato a47070a438 New release notes:
SA-04:14.

Approved by:	re (implicitly)
2004-09-23 16:59:39 +00:00
Andre Oppermann 0a220c3523 MFC 1.289: Proper bounds checking when initializing the ip_protox[] array.
Approved by:	re (kensmith)
2004-09-23 16:44:21 +00:00
Andre Oppermann ab4bbc5742 MFC: Store IP source routing options in mtag instead of global variable.
Approved by:	re (kensmith)
2004-09-23 16:38:53 +00:00
Bruce A. Mah 2966b552b3 Fix a couple of minor inconsistencies in the text that discusses
branchpoints for RELENG_*.  I'm not 100% happy with my change, but
it's better than it was.

Pointed out by:	den
Approved by:	re (implicitly)
2004-09-23 15:39:50 +00:00
Denis Peplin bb99f8d5c3 Remove items that are not applicable to RELENG_5.
Noticed by:	hrs
Approved by:	re (hrs)
2004-09-23 08:20:58 +00:00
Denis Peplin 307fb30b32 Merge from HEAD
Approved by:    re (kensmith)
Obtained from:  The FreeBSD Russian Documentation Project
2004-09-23 06:12:03 +00:00
Denis Peplin 02a6768365 Update early-adopters translation to Migration Guide
Approved by:	re (kensmith)
Obtained from:	The FreeBSD Russian Documentation Project
2004-09-23 06:02:09 +00:00
Andre Oppermann 091f761e09 MFC: Make PFIL_HOOKS a permanent part of the kernel and remove the associated
kernel compile option.

Approved by:	re (scottl)
2004-09-22 20:41:31 +00:00
Andre Oppermann 2df97dc1ef Undo incrementing __FreeBSD_version and have IPFILTER check against 503000
instead.  This works just as well because it didn't check before for this
at all.

Pointed out by:	ceri
Approved by:	re (implicit)
2004-09-22 19:51:03 +00:00
Andre Oppermann 906924251e MFC: Make PFIL_HOOKS a permanent part of the kernel and remove the associated
kernel compile option.

Approved by:	re (scottl)
2004-09-22 19:23:39 +00:00
Ruslan Ermilov 88c2867de0 MFC: Makefile.inc1,v 1.440 and gnu/usr.bin/cc/cc_tools/Makefile,v 1.80.
Ensure that .depend file in cc_tools has correct libraries and headers
(host versions, not target).

Approved by:	re (kensmith)
2004-09-22 07:11:46 +00:00
Brooks Davis 081fbeda64 MFC: Makefile:1.240 microtime.9:1.8 microuptime.9:1.6 time.9:1.13
Bring kernel time variable and access function docs up to date by
updating the list of variables and mentioning the bin(up)time functions.

Approved by:	re (kensmith)
2004-09-22 04:43:33 +00:00
Brooks Davis d7023b21b4 MFC: 1.44
Document the struct if_data members ifi_datalen, ifi_epoch, and
ifi_link_state.

Approved by:	re (kensmith)
2004-09-22 04:40:21 +00:00
Christian Brueffer 570beb56a9 MFC: rev. 1.256
Autogenerate device listings for cnw(4)

Approved by:	re (blanket)
2004-09-22 00:42:32 +00:00
Christian Brueffer ac87519da9 MFC: rev. 1.39
Add cnw(4)

Approved by:	re (blanket)
2004-09-22 00:41:00 +00:00
Christian Brueffer 5555d4ff84 MFC: rev. 1.13
Re-formulate the first sentence for better readability

Approved by:	re (blanket)
2004-09-22 00:37:08 +00:00
Bruce A. Mah ae8e67f5a9 Fix gramm-o.
Translators can probably ignore this.

Pointed out by:	Matthew George < mdg at securenetworks dot net >
Approved by:	re (implicitly)
2004-09-21 18:37:16 +00:00
Ruslan Ermilov e0b30b76dc MFC: 1.152: Get ready for 5.x becoming -STABLE soon.
Approved by:	re (hrs)
2004-09-21 15:57:06 +00:00
Tim Kientzle 2f1adf5f66 MFC 1.18: Use pax extensions for uid/gid >= 1<<18, but clip
values that must remain ustar compatible to less than this limit.
This fixes an internal assertion failure triggered by large uid/gid.
Approved by: re (Scott Long)
2004-09-21 03:38:06 +00:00
Stefan Eßer a45c9b3aa4 MFC: Add module dependency on CAM.
Approved by:	re
2004-09-20 20:57:37 +00:00
Ruslan Ermilov b920345dd3 MFC: Make sure we use the correct make(1) binary in newvers.sh.
Approved by:	re (scottl)
2004-09-20 17:39:02 +00:00
Max Laier b31d7d7b9d MFC: boot order change:
Move pf* init from SI_SUB_PSEUDO to SI_SUB_PROTO_IFATTACHDOMAIN where it
  is save to call if_attachdomain from if_attach() (as done for if_loop.c).
  We will now end up with a properly initialized if_afdata array and the nd6
  callout will no longer try to deref a NULL pointer.

  Still this is a temp workaround and the locking for if_afdata should be
  revisited at a later point.

  Requested by:                   rwatson
  Discussed with and tested by:   yongari (a while ago)
  PR:                             kern/70393

Approved by:	re (scottl)
2004-09-20 15:25:57 +00:00
Max Laier cc11402a79 MFC: pf_ioctl.c, rev. 1.15:
Break out altq_enable/disable from DIOC{START,STOP}ALTQ into seprate
   functions that can be called from enable/disable pf as well. This
   improves switching from non-altq ruleset to altq ruleset (and the other
   way 'round) by a great deal and makes pfctl act like the user would
   except it to.

   PR:		kern/71746
   Tested by:	Aurilien "beorn" Rougemont (PR submitter)

Approved by:	re (scottl)
2004-09-20 15:15:58 +00:00
Denis Peplin 6407b85f54 MFC ru_RU release documentation
Approved by: re (hrs)
2004-09-20 08:16:11 +00:00
Brooks Davis 68ae0f75ae MFC 1.3: Fix a LOR where copyout was called while holding a lock when
listing available cloners (running "ifconfig -C").

Approved by:	re (scottl)
Reported by:	rwatson
LOR id:		039
2004-09-20 07:12:21 +00:00
Brooks Davis 59667fbaec MFC revs 1.860 and 1.861:
Add 'hint.atkbd.0.flags="0x1"' back to /boot/device.hints on the
install media on i386 and amd64.  While the current default is very
useful in server environments, the ability to use USB keyboards is
vastly more important then the ability to use PS/2 keyboards the admin
forgot to plug in during the install process.

Approved by:	re (scottl)
PR:		kern/71443 kern/71568 (probably others)
2004-09-20 07:06:56 +00:00
Max Khon 433166bbb7 MFC: Use correct malloc type when freeing memory allocated by g_read_data.
PR:		71431
Submitted by:	daichi
Approved by:	re
2004-09-20 06:07:19 +00:00
Nate Lawson e2f1d06379 MFC rev 1.30: Remove an unnecessary printf and fix a spelling error.
Approved by:	re (scottl)
2004-09-20 05:52:19 +00:00
Robert Watson 014bcdcd02 Merge if_tap.c:1.47 to RELENG_5:
date: 2004/09/17 03:55:50;  author: rwatson;  state: Exp;  lines: +2 -0
  Destroy global tapmtx when the if_tap module is unloaded.

  RELENG_5 candidated.

Approved by:	re (scottl)
2004-09-20 05:49:40 +00:00
MIHIRA Sanpei Yoshiro 792ce47108 MFC umass.c 1.113:
Add support Western Digital External USB HDD
	ONSPEC entry are sorted

Approved by:	re(kensmith)
2004-09-20 05:28:08 +00:00
MIHIRA Sanpei Yoshiro 5cc0bb100b MFC usb_quirks.c 1.40
Add support Qualcomm CDMA modem

Approved by:	re(kensmith)
2004-09-20 05:18:04 +00:00
MIHIRA Sanpei Yoshiro 094b7dea2e MFC uscanner.c in 1.58
Add support Nikon CoolScan LS40 ED

Approved by:	re(kensmith)
2004-09-20 05:03:28 +00:00
MIHIRA Sanpei Yoshiro fdc7477127 MFC uplcom.c 1.21:
add support ELECOM UC-SGT(minor change version)
http://www2.elecom.co.jp/products/UC-SGT.html

Approved by:	re(kensmith)
2004-09-20 04:46:41 +00:00
Marcel Moolenaar 48b449941a MFC rev 1.104: cred_free_thread() removal.
Forgotten by: julian
Approved by: re (blanket)
2004-09-19 21:04:28 +00:00
Max Khon 0416dc070c MFC: rev 1.11
g_nop_create: Destroy correct provider in case of errors.

Approved by:	re
2004-09-19 10:38:57 +00:00
Yoshihiro Takahashi 518f8f2412 MFC: Add -fno-unit-at-a-time to CFLAGS.
Approved by:	re (scottl)
2004-09-19 05:28:13 +00:00
Christian Brueffer ae2577258c MFC: rev. 1.257
Autogenerate device listings for ed(4)

Approved by:	re (blanket)
2004-09-19 02:32:31 +00:00
Christian Brueffer cf0c52297b MFC: rev. 1.40
Add ed(4)

Approved by:	re (blanket)
2004-09-19 02:30:53 +00:00
Christian Brueffer 9804b9acaf MFC: rev. 1.37
- add a HARDWARE section based on the hardware notes
- capitalize Ethernet
- minor fixes

Approved by:	re (blanket)
2004-09-19 02:28:29 +00:00
Christian Brueffer c77ffd3815 MFC: rev. 1.17
Adaptec ANA-6944/TX is supported

Approved by:	re (blanket)
2004-09-19 02:27:24 +00:00
Matt Jacob 59ffe07149 MFC: Make module depend on cam && pci.
Approved by:	re
2004-09-19 01:07:23 +00:00
Bruce A. Mah 08499ac1bd MFC: Fix a misspelling and delete an extra word.
new.sgml	1.777 -> 1.778

Translators can probably ignore this.

Approved by:	re (hrs)
2004-09-18 19:30:24 +00:00
Scott Long a1aad6f869 MFC: Bring fdformat and fdread up to the new fd driver
Approved by: re
2004-09-18 17:40:51 +00:00
Xin LI cd6225a233 MFC revision 1.153
date: 2004/09/15 08:19:03;  author: delphij;  state: Exp;  lines: +7 -1
Clear all "active partition" bits before we set a new one.

This adds a safebelt that prevents users to mark more than
one "active" partitions, which will lead to a unbootable
machine, especially in multi-boot configurations.

Approved by:	re (scottl), mentor (murray)
2004-09-18 16:57:39 +00:00
Scott Long bc5c63e4d4 Move to BETA5
Approved by: re
2004-09-18 16:50:03 +00:00
Scott Long 21d600c925 MFC: Update fdcontrol to the new fdc driver changes.
Approved by: re
2004-09-18 16:41:29 +00:00
Bruce A. Mah 6614e43718 Track the installed name (MIGRATE5.*) for the Migration Guide on
the release media.

Approved by:	re (implicitly)
2004-09-18 07:14:53 +00:00
Bruce A. Mah 2684ee6037 Give the Migration Guide an appropriate 8.3 name (MIGRATE5.*) on
release media.

Approved by:	re (implicitly)
2004-09-18 07:13:31 +00:00
Hiroki Sato f7320def1a MFC from rev.1.777:
Reorganize the "Kernel Changes" section, including:
	- Add "Hardware Support" section and move device driver-related
	  items there.
	- Move "Multimedia Support" and "Network Interface Support" into
	  the "Hardware Support" section as sub-sections.
	- Move Netgraph-related items to "Network Protocols".

For translators: many items are moved but the contents
are not changed.

Approved by:	re (implicitly)
2004-09-18 07:03:40 +00:00
Warner Losh a74ff8b7aa MFC: Merge in phk's new floppy driver.
Approved by: re@
2004-09-18 04:57:55 +00:00
Warner Losh c03c61d1fe MFC: BIO_CMD0
Approved by: re (as part of fdc merge)
2004-09-18 04:56:06 +00:00
Alan Cox 1190cc3302 MFC
Use atomic ops in pmap_clear_ptes() and pmap_protect() to prevent the loss
 of a page modified (PG_M) bit in a race between processors.

Approved by: re (scottl)
PR: i386/61852
2004-09-18 04:27:00 +00:00
Julian Elischer 0005e2b297 Cumulative MFC of patches applied to -current to get preemption
support to a non-instantly-crashing state.
Also includes some cosmetic changes to keep the diffs to a minimum and
an experimental option (followon) in sched_4bsd. (turned off but
included to keep diffs to a mimimum)

Approved by:	re (scottl)
2004-09-18 04:11:36 +00:00
Jun Kuriyama ae0a866cea MFC: Fix a condition where the hole would be inserted in the wrong
place during a split.

     Obtained from:	NetBSD

Approved by:	re (scottl)
2004-09-18 03:57:38 +00:00
Gleb Smirnoff f38019d8e1 MFC 1.129:
Check flag do_bridge always, even if kernel was compiled without
   BRIDGE support. This makes dynamic bridge.ko working.

Approved by:	re (scottl)
2004-09-17 19:50:27 +00:00
Gleb Smirnoff c6bcdd00f4 MFC 1.180:
Do not call xl_init_locked() unconditionally when we are bringed UP. Call
   it only if we weren't UP before. In some cases xl_init causes long media
   re-negotiation, and ppp(8) fails to open PPPoE connection because it sets
   IFF_UP every time before opening PPPoE connection.

Approved by:    re (scottl)
2004-09-17 19:46:40 +00:00
Marcel Moolenaar dae045f54a MFC: switch to the 4BSD scheduler as the default scheduler.
Approved by: re (blanket)
2004-09-17 19:01:28 +00:00
Max Laier e287dce8fa MFC pf examples:
Bring in some examples (and create space for future work here):
   - Add OpenBSD example rulesets as advertised in etc/pf.conf and
     pf.conf(5)
   - Tweak the pointer to fit the FreeBSD default location share/examples/pf
   - Account for the new directory in BSD.usr.dist (no hier(7) change
     required as share/examples is an opaque item there).

  Obtained from:  OpenBSD
  Reminded by:    Thomas T. Veldhouse
  PR:             docs/71691

Approved by:	re (scottl)
2004-09-17 18:27:15 +00:00
Max Laier ba744977cd MFC pf.c, rev. 1.19:
One more round on the H/W supported checksum code: Fix NICs that can't do
  the pseudo header. We really need the TCP packet length here. This happens
  to end up in ip->ip_len in tcp_input.c, but here we should get it from the
  len function variable instead.

  Submitted by:	yongari
  Tested by:	Nicolas Linard, yongari (sparc64 + hme)

Approved by:	re (scottl)
2004-09-17 18:11:09 +00:00
John-Mark Gurney 45491ecc39 MFC: v1.82
>  unlock global lock in kqueue_scan before msleep'ing to prevent dead
>  lock..  we didn't unlock global lock earlier to prevent just having
>  to reaquire it again..

Approved by:	re (scottl)
2004-09-17 17:53:16 +00:00
Bruce A. Mah 8b080d54dd Reflect the "Early Adopters Guide" to "Migration Guide" change.
Approved by:	re (implicitly)
2004-09-17 16:28:58 +00:00
Bruce A. Mah 9272e696ca Turn the "Early Adopters Guide" into the "Migration Guide". This change
is really more of a rewrite than a set of edits, but basically the
focus is now on "how to help 4.X users switch to 5.3" rather than on
the "why users should (or should not) run 5.X".  There were also a lot
of content updates, and the "source upgrade" section now includes an
annotated version of the steps from src/UPDATING.

This is a direct commit to RELENG_5 since technically it doesn't apply
to HEAD.  Subsequent commits will (after testing) rename the rendered
output files on the release media and fix the document title in
sysinstall(8).

Many helpful comments were provided by reviewers via the doc and
current lists.

Approved by:	re (scottl)
Reviewed by:	trhodes, scottl, imp, hrs, marcus, brooks, keramida, brueffer,
		Michel TALON < talon at lpthe dot jussieu dot fr >,
		Len Zettel < zettel at acm dot org >
2004-09-17 15:47:16 +00:00
Christian S.J. Peron c098407bf3 MFC v1.58
Currently when ipfw(8) generates the micro-instructions for rules which
contain O_UID, O_GID and O_JAIL opcodes, the F_NOT or F_OR logical
operator bits get clobbered. Making it impossible to use the ``NOT'' or
``OR'' operators with uid, gid and jail based constraints.

The ipfw_insn instruction template contains a ``len'' element which
stores two pieces of information, the size of the instruction
(in 32-bit words) in the low 6 bits of "len" with the 2 remaining
bits to implement OR and NOT.

The current code clobbers the OR and NOT bits by initializing the
``len'' element to the size, rather than OR'ing the bits. This change
fixes this by changing the initialization of cmd->len to an OR operation
for the O_UID, O_GID and O_JAIL opcodes.

Approved by:	re@ (scottl)
PR:		kern/63961 (partially)
2004-09-17 14:49:08 +00:00
Gleb Smirnoff 6fcc17644d MFC 1.234:
Remove layer intermixing. Device driver should pass the frame to
   ether_input(), and do not play with bridge itself.

Approved by:	re (scottl)
2004-09-17 10:14:49 +00:00
Nate Lawson 9c55cc61b3 MFC rev 1.50: Don't change the state of the system in acpi_tz_establish().
Turning off fans on some systems generates a notify saying the zone needs
to be re-evaluated, producing an infinite loop.

Approved by:	re (scottl)
2004-09-17 04:22:02 +00:00
Nate Lawson 700a0c3e62 MFC rev 1.27: Instead of trusting _STA from power resources, cache the
first value returned and then infer the state from calls to _ON/_OFF.

Approved by:	re (scottl)
2004-09-17 04:20:31 +00:00
Maksim Yevmenkin d5f9ccf669 MFC: Add missing #include
Bump WARNS level to 2

PR:		bin/71668
Submitted by:	Dan Lukes <[email protected]>
Approved by:	re (scottl)
2004-09-17 03:45:24 +00:00
Simon L. B. Nielsen 557d539d81 MFC 1.251-1.253:
- Auto generate device listings for the ubsa(4), ubser(4), uftdi(4),
  and uplcom(4) drivers.
- Auto generate device listing for the uvisor driver.
- Auto generate device listings for the fwohci(4), hifh(4), safe(4),
  and ubsec(4) drivers.

Approved by:	re (blanket)
2004-09-16 22:48:18 +00:00
Simon L. B. Nielsen ed2d6c2907 MFC 1.8+1.9:
- Change DESCRIPTION section to a HARDWARE section.
- Sync list of supported devices with source code.
- Bump document date.

Approved by:	re (blanket)
2004-09-16 22:41:58 +00:00
Simon L. B. Nielsen 39a7ee8a8f MFC:
- Add a HARDWARE section which lists supported devices.

Approved by:	re (blanket)
2004-09-16 22:38:44 +00:00
Simon L. B. Nielsen 6f75bb7b79 MFC 1.5:
- Add a HARDWARE section which lists supported devices based on the
  FreeBSD Hardware Notes, source code and cvs comments from
  FreeBSD and NetBSD.
- Update page title and DESCRIPTION section to reflect the fact that
  this driver supports much more than Handspring Visor now.

Approved by:	re (blanket)
2004-09-16 22:23:14 +00:00
Simon L. B. Nielsen df30dc6d13 MFC 1.9:
- Move HARDWARE section to after DESCRIPTION like in the other FreeBSD
  section 4 manual pages.

Approved by:	re (blanket)
2004-09-16 22:22:03 +00:00
Simon L. B. Nielsen 98a7fa0d18 MFC:
- Move HARDWARE section to after DESCRIPTION like in the other FreeBSD
  section 4 manual pages.
- Sort device list.

Approved by:	re (blanket)
2004-09-16 22:16:30 +00:00
Simon L. B. Nielsen d5ceef605b MFC 1.3:
Change DESCRIPTION section to a HARDWARE section.

Approved by:	re (blanket)
2004-09-16 22:11:46 +00:00
Christian Brueffer 5d78bd5889 MFC: rev. 1.7, 1.8
- add a HARDWARE section
- grammar fixes
- wording improvements
- bump document date

Approved by:	re (blanket)
2004-09-16 22:09:52 +00:00
Simon L. B. Nielsen 31c480f8c5 MFC 1.15+1.28,1.30,1.31,1.34-1.36,(part of 1.38):
- Auto generate device listings for the following drivers: snd_ad1816,
  snd_cmi, snd_cs4281, snd_ds1, snd_emu10k1, snd_es137x, and snd_solo.
- Add vge(4) to the Hardware Notes.
- Add snd_csa(4) and snd_gusc(4).
- Add ubser(4).
- Auto generate device listing for the uvisor driver.
- Add fwohci, hifn, safe, sbp, and ubsec.
- note ia64 support for several drivers.

Approved by:	re (blanket)
2004-09-16 21:47:34 +00:00
Ruslan Ermilov 3673e1850d MFC: 1.1276: Fixed sound-related hints.
Approved by:	re (scottl, hrs)
2004-09-16 20:20:04 +00:00
Ruslan Ermilov ef07017573 MFC: Reflect July 2004 code changes in manpages.
Approved by:	re (scottl, hrs)
2004-09-16 20:18:15 +00:00
Christian Brueffer ddfca1f496 MFC: rev. 1.250, 1.254, 1.255
- autogenerate device listings for em(4) and gx(4)
- fix an entity
- autogenerate device listings for lnc(4), ng_ubt(4) and pcn(4)

Approved by:	re (blanket)
2004-09-16 19:37:49 +00:00
Christian Brueffer 4f616cc117 MFC: rev. 1.32, 1.33
Add em(4) and gx(4)

Approved by:	re (blanket)
2004-09-16 19:19:29 +00:00
Don Lewis 9bd3617a3b MFC sys/dev/sound/isa/sb16.c 1.88
Change sb_lock() calls to sbc_lockassert() and remove the sb_unlock()
  calls in sb_cmd2() and sb_getmixer().  The lock has already be grabbed
  before these functions are called.

PR:		71189
Submitted by:	stephane
Approved by:	re (scottl)
2004-09-16 19:02:50 +00:00
Christian Brueffer 84dfbb4d3a MFC: rev. 1.37, 1.38
- note ia64 support for several drivers
- remove drivers that work on all supported architectures
- add lnc(4), ng_ubt(4) and pcn(4)

Approved by:	re (blanket)
2004-09-16 19:02:28 +00:00
Christian Brueffer 3a4a30ca26 MFC: rev. 1.22
- remove device count
- add a HARDWARE section
- bump document date

Approved by:	re (blanket)
2004-09-16 18:42:22 +00:00
Christian Brueffer 891000d3ed MFC: rev. 1.10
- fix capitalization
- add HARDWARE section based on the hardware notes
- bump document date

Approved by:	re (blanket)
2004-09-16 18:41:41 +00:00
Andre Oppermann ef863641fd MFC 1.76: Return EINVAL when IPFIREWALL_FORWARD is not compiled into the kernel.
Approved by:	re (scottl)
2004-09-16 18:02:22 +00:00
Andre Oppermann 05f508e403 MFC 1.9: Don't prepend an already existing tag again.
Approved by:	re (scottl)
2004-09-16 17:59:35 +00:00
Andre Oppermann e685a2b8de MFC 1.20: Fix ip_input() fallback for the destination modified cases.
Approved by:	re (scottl)
2004-09-16 17:57:04 +00:00
Andre Oppermann e4caf644a8 MFC: Make 'ipfw tee' behave as intended and designed.
Approved by:	re (scottl)
2004-09-16 17:53:23 +00:00
Hiroki Sato ec00f1ce85 MFC from rev.1.5.
Approved by:	re (implicitly)
2004-09-16 17:27:32 +00:00
Hiroki Sato fe2366221b MFC from rev.1.35.
Approved by:	re (implicitly)
2004-09-16 17:23:16 +00:00
John Baldwin 6861e85ed1 MFC: Teach the stack trace code how to walk across a double fault.
Approved by:	re (scottl)
2004-09-16 17:21:46 +00:00
Mike Makonnen 4c2400db0c MFC:
----------------------------
revision 1.24
date: 2004/08/28 14:32:10;  author: mtm;  state: Exp;  lines: +2 -1
Also, match the full path to the special nologin shell.
Previously, it would recognize it as a valid shell only
if the basename (nologin) was specified. Now, it will
recognize both the basename and the full path.

NOTE: The full path as adduser(8) understands it is /usr/sbin/nologin.
      There is a symlink, /sbin/nologin, but that's deprecated and
      only there for backwards compatibility.
=============================================================================

Approved by:	re (scottl)
2004-09-16 13:41:20 +00:00
Scott Long eb15d69f4e MFC: Program the sbus interface with the correct frequency
Approved by: re
2004-09-16 03:48:43 +00:00
Andre Oppermann 605f292ed9 Fix mismerge of previous MFC.
Found by:	brooks
Approved by:	re (implicit)
2004-09-15 18:38:32 +00:00
Andre Oppermann c29d01eeb3 MFC: Apply error and success logic consistently to the function netisr_queue()
and its users.

Approved by:	re (kensmith)
2004-09-15 15:14:19 +00:00
Andre Oppermann 088248bfcb MFC 1.229: Replace ifunit("lo0") with direct 'loif' pointer.
Approved by:	re (kensmith)
2004-09-15 15:07:09 +00:00
Andre Oppermann c5bdd4707c MFC 1.133: Change the array of char to an array of struct pollfd.
Approved by:	re (kensmith)
2004-09-15 14:56:26 +00:00
Andre Oppermann 4765a4b42a MFC 1.1265: Properly document and enable the IPFIREWALL_FORWARD option.
Approved by:	re (kensmith)
2004-09-15 14:52:31 +00:00
Bill Paul 8257b2d6bd Merge the vge(4) driver from the HEAD. Also add nge(4) and lge(4) to
GENERIC for x86.

Approved by:	re (scottl)
2004-09-14 21:22:34 +00:00
Christian Brueffer 470a3bd12b Connect cnw(4) manpage to the build
Approved by:	re (blanket)
2004-09-14 16:21:41 +00:00
Pawel Jakub Dawidek 5c7e31ecd0 Connect gmirror.8 manual page to the build.
Approved by:	re (scottl)
2004-09-14 16:11:00 +00:00
cvs2svn eb8cf9e06f This commit was manufactured by cvs2svn to create branch 'RELENG_5'. 2004-09-14 16:08:14 +00:00
Pawel Jakub Dawidek 9fa2abb294 Fix 'show' command for pipes and queues.
PR:		bin/70311
Submitted by:	Pawel Malachowski <[email protected]>
Approved by:	re (scottl)
2004-09-14 16:07:16 +00:00
Pawel Jakub Dawidek 9d9ed367f3 Allocate memory when dumping pipes with M_WAITOK flag.
On a system with huge number of pipes, M_NOWAIT failes almost always,
because of memory fragmentation.
My fix is different than the patch proposed by Pawel Malachowski,
because in FreeBSD 5.x we cannot sleep while holding dummynet mutex
(in 4.x there is no such lock).

PR:		kern/46557
Submitted by:	Eugene Grosbein <[email protected]>
Reviewed by:	mlaier
Approved by:	re (scottl)
2004-09-14 16:05:06 +00:00
Pawel Jakub Dawidek f491148e57 Add a tool for testing performance of storage devices.
Approved by:	re (scottl)
2004-09-14 16:02:32 +00:00
Pawel Jakub Dawidek 9b0a98356b Add regression tests for "round-robin" and "verify" modes.
Approved by:	re (scottl)
2004-09-14 15:53:51 +00:00
Pawel Jakub Dawidek db0995da74 Update manual page.
Approved by:	re (scottl)
2004-09-14 15:52:00 +00:00
Pawel Jakub Dawidek 788dc74519 Add manual page for graid3(8).
Approved by:	re (scottl)
2004-09-14 15:50:51 +00:00
Pawel Jakub Dawidek 7b86e0ed24 Add manual page for gmirror(8).
Approved by:	re (scottl)
2004-09-14 15:49:30 +00:00
Pawel Jakub Dawidek 002e4c4141 - Add warnings support.
- Fix command name printing in case of version desynch.

Approved by:	re (scottl)
2004-09-14 15:48:01 +00:00
Pawel Jakub Dawidek ff1a1f03a2 - Add support for 'round-robin' and 'verify' modes.
- Make kern.geom.raid3.debug sysctl tunable.
- Add warnings.
- Bump version number and add version history.
- Don't handle spoiling for synchronization geom.
- Skip providers with 0 sectorsize.

Approved by:	re (scottl)
2004-09-14 15:47:03 +00:00
Pawel Jakub Dawidek 95295864fd - Make kern.geom.mirror.debug and kern.geom.mirror.timeout sysctls tunable.
- Don't handle spoiling for synchronization geom.
- Skip providers with 0 sectorsize.
- Some other fixes.

Approved by:	re (scottl)
2004-09-14 15:44:55 +00:00
Pawel Jakub Dawidek 9f4f8af6e3 Improve usage a bit.
Approved by:	re (scottl)
2004-09-14 15:43:25 +00:00
Pawel Jakub Dawidek 64ccf2d9b2 Add a warning when we are not going to use whole provider's space.
Approved by:	re (scottl)
2004-09-14 15:42:23 +00:00
Pawel Jakub Dawidek dadcccfcb1 - Skip providers with 0 sectorsize.
- Dump disk number.
- Make kern.geom.stripe.debug sysctl tunable.

Approved by:	re (scottl)
2004-09-14 15:40:23 +00:00
Pawel Jakub Dawidek 86bd0bf390 Do not handle spoiling!
Approved by:	re (scottl)
2004-09-14 15:39:24 +00:00
Pawel Jakub Dawidek d9bc81284e - Skip providers with 0 sectorsize.
- Make kern.geom.label.debug sysctl tunable.

Approved by:	re (scottl)
2004-09-14 15:34:35 +00:00
Pawel Jakub Dawidek 7d1d8c5cb8 - Skip providers with 0 sectorsize.
- Make kern.geom.concat.debug sysctl tunable.

Approved by:	re (scottl)
2004-09-14 15:33:22 +00:00
Don Lewis 3a1523a3cc MFC sndstat.c 1.18
>   Convert sndstat_lock from a mutex to an sx lock.  sndstat_read()
>   holds sndstat_lock across a call to uiomove(), which is not legal
>   to do with a  mutex because of the possibility that the data transfer
>   could sleep because of a page fault.  It is not possible to just
>   unlock the mutex for the uiomove() call without introducing another
>   locking mechanism to prevent the body of sndstat_read() from being
>   re-entered.  Converting sndstat_lock to an sx lock is the least
>   complicated change.

LOR:		030
Approved by:	re (scottl)
2004-09-14 06:43:46 +00:00
Poul-Henning Kamp cde96b5955 MFC:
Fix an datatype issue which could result in key-sectors being
	overwritten if less than the full complement of keys (4) were
	configured.

Approved by:	re:scottl
2004-09-14 05:59:12 +00:00
Poul-Henning Kamp 10f3b14993 Add three spare fields to reserve room so we can MFC the in-progress
work on safe device removal at a later date without breaking binary
compatibility on the RELENG_5 branch.

Approved by:	re::scottl
2004-09-14 05:49:18 +00:00
Scott Long 4c4c887c5f Add missing semicolons.
Approved by: re (implicit)
2004-09-14 05:47:14 +00:00
Hiroki Sato a95b55520c Merge from rev.1.775.
Approved by:	re (implicitly)
2004-09-14 05:40:44 +00:00
John-Mark Gurney a03863ace2 MFC: v1.34
>   remove XXX comment now that the kernel is fixed, there isn't any obvious
>   reason to enable this as performance didn't significantly change...

Approved by:	re (kensmith)
2004-09-14 03:52:51 +00:00
John-Mark Gurney 63a988ddd7 MFC: subr_witness.c v1.179
>   make witness it's own sysctl branch instead of using _ to do this.  I have
>   left the old tunables in to give people a few days to transition their
>   loader.conf and sysctl.conf's over to the new names..

MFC: witness.4 1.6, UPDATING 1.356
>   document the recent change to debug.witness.*
>   fix spelling of debug.witness.kdb

Approved by:	re (kensmith)
2004-09-14 03:51:21 +00:00
John-Mark Gurney 499da048df MFC:
kern_event.c: v1.80, if.c: v1.205
>   don't call f_detach if the filter has alread removed the knote.. This
>   happens when a proc exits, but needs to inform the user that this has
>   happened..  This also means we can remove the check for detached from
>   proc and sig f_detach functions as this is doing in kqueue now...

kern_event.c: v1.81
>  remove giant required from kqueue_close..

Approved by:	re (kensmith, scottl)
2004-09-14 03:46:43 +00:00
Brooks Davis 30211e0e22 MFC: The disk labels generated by bsdlabel can no address more than
0xffffffff sectors.  Document this limit and avoid installing bogus
labels on disks with more sectors (by refusing to install one at all).

Approved by:	re (scottl)
2004-09-14 03:44:58 +00:00
John-Mark Gurney cc209855ae MFC: v1.230
>   revert comment from rev1.158 now that rev1.225 backed it out..

Approved by:	re (kensmith)
2004-09-14 03:42:46 +00:00
John-Mark Gurney e54a448ebf MFC: v1.34
>   add support for documented readonly option...
>   also print out the option that is unknow so that the user knows what (s)he
>   did wrong..

Approved by:	re (kensmith)
2004-09-14 03:32:21 +00:00
John-Mark Gurney e87d45ff1e MFC: v1.30
>   merge in if_rl locking because if_re was originally based upon if_rl.
>   This essentially merges revs 1.143-1.1445 of sys/pci/if_rl.c.
>   This now marks the interrupt MPSAFE along with making the mutex
>   non-recursive.

Approved by:	re (kensmith)
2004-09-14 03:30:47 +00:00
Robert Watson 7adcca8152 Merge subr_witness.c:1.180 to RELENG_5:
date: 2004/09/09 05:01:37;  author: rwatson;  state: Exp;  lines: +7 -0
  Hard code witness lock order for BPF locks.

Approved by:	re (scottl)
2004-09-14 03:01:06 +00:00
Robert Watson 44c386b4d6 Merge bpf.c:1.134-1.136, bpfdesc.h:1.28 to RELENG_5:
date: 2004/09/09 04:11:12;  author: rwatson;  state: Exp;  lines: +20 -11
  Reformulate bpf_dettachd() to acquire the BIF_LOCK() as well as
  BPFD_LOCK() when removing a descriptor from an interface descriptor
  list.  Hold both over the operation, and do a better job at
  maintaining the invariant that you can't find partially connected
  descriptors on an active interface descriptor list.

  This appears to close a race that resulted in the kernel performing
  a NULL pointer dereference when BPF sessions are detached during
  heavy network activity on SMP systems.

  RELENG_5 candidate.

  date: 2004/09/09 00:19:27;  author: rwatson;  state: Exp;  lines: +20 -35
  date: 2004/09/09 00:19:27;  author: rwatson;  state: Exp;  lines: +4 -3
  Reformulate use of linked lists in 'struct bpf_d' and 'struct bpf_if'
  to use queue(3) list macros rather than hand-crafted lists.  While
  here, move to doubly linked lists to eliminate iterating lists in
  order to remove entries.  This change simplifies and clarifies the
  list logic in the BPF descriptor code as a first step towards revising
  the locking strategy.

  RELENG_5 candidate.

  Reviewed by:    fenner

  date: 2004/09/09 00:11:50;  author: rwatson;  state: Exp;  lines: +3 -3
  Compare/set pointers using NULL not 0.

Approved by:	re (scottl)
2004-09-14 02:59:20 +00:00
Max Laier 5ac5ca6a0e The pflog format change has been MFC'ed so the note about the format change
(for 64 bit archs) belongs here as well.

Requested by:	scottl
Approved by:	re (scottl)
2004-09-14 02:45:13 +00:00
Christian Brueffer 0309e87755 MFC: rev. 1.29
nge(4) works on alpha as well

Approved by:	re (blanket)
2004-09-14 01:17:05 +00:00
Christian Brueffer eb74eca7cd MFC:
Add a manpage for the cnw(4) driver, adopted from NetBSD.

Approved by:	re (blanket)
2004-09-14 01:14:30 +00:00
cvs2svn 4d99136918 This commit was manufactured by cvs2svn to create branch 'RELENG_5'. 2004-09-14 01:07:20 +00:00
Wilko Bulte 46be224b52 MFC:
revision 1.19
date: 2004/09/10 05:00:27;  author: marcel;  state: Exp;  lines: +14 -62
The previous commit, roughly one and a half years ago removed the
branch prediction optimization for LINT, because the kernel was too
large. This commit now removes it altogether since it causes build
failures for GENERIC kernels and the various applicable trends are
such that one can expect that it these failure will cause more
problems than they're worth in the future. These trends include:
1. Alpha was demoted from tier 1 to tier 2 due to lack of active
   support. The number of people willing to fix build breakages
   is not likely to increase and those developers that do have the
   gumption to test MI changes on alpha are not likely to spend
   time fixing unexpected build failures first.
2. The kernel will only increase in size. Even though stripped-down
   kernels do link without problems now, compiler optimizations (like
   inlining) and new (non-optional) functionality will likely cause
   stripped-down kernels to break in the future as well.

So, with my asbestos suit on, get rid of potential problems before
they happen.

Approved by: re (scottl)
2004-09-13 21:52:04 +00:00
Wilko Bulte 9c9e80578a Note the removal of TurboLaser support from GENERIC.
Approved by: re (scottl; implicitely)
2004-09-13 21:20:13 +00:00
Wilko Bulte 75ff176185 Match reality: remove support for TurboLaser as it no longer works. Nor
is it likely it will be fixed given the big-iron nature of the machine.

Approved by:	re (scottl)
2004-09-13 21:15:05 +00:00
Tom Rhodes b71457fff5 MT5 or whatever: Set the first match ability as the default and remove the
debugging sysctl.

Approved by:	re (kensmith)
Supported by:	rwatson (in email and phone conversation)
2004-09-13 20:21:32 +00:00
Maksim Yevmenkin b614ccc836 Shame on me. I screwed up product ID for the 3COM Bluetooth PC-Card.
It's 0x0040 not 0x0400.

Approved by:	re (kensmith)
2004-09-13 16:47:00 +00:00
Max Laier 4f51bf59c2 MFC pflog rev. 1.2
Don't rely on properly setup linker.hints to figure out that pflog is now
  part of the pf module.
  While here fix a comment that was c'n'ped from rc.d/pf

  PR:             bin/71096 (partly)
  Submitted by:   Ville-Pertti Keinonen

Approved by:	re (kensmith)
2004-09-13 11:40:59 +00:00
Max Laier 1e51a43e80 MFC pflogd.c rev. 1.6:
Make pflogd(8) store pcap_sf_pkthdr instead of MD timeval contaminated
  pcap_pkthdr. This makes /var/log/pflog standart compliant on 64bit archs.

  OpenBSD has fixed this by changing the bpf timeval to 32bit in the kernel,
  so no need to report this over (again).

  PR:             bin/71096 (w/ changes)
  Submitted by:   Ville-Pertti Keinonen
  Tested by:      amd64(submitter), sparc64(yongari), i386(myself)

Approved by:	re (kensmith)
2004-09-13 11:39:09 +00:00
Maxim Konovalov a5f762227c MFC rev.1.75: recover normal behavior: return EINVAL to attempt
to add a divert rule when module is built without IPDIVERT.

Approved by:	re (kensmith)
2004-09-13 07:19:55 +00:00
Poul-Henning Kamp 4bb5e8f0f7 MFC:
For removable devices without media we set a zero mediasize but a non-zero
   sectorsize in order to avoid a lot of checks around various divisions etc.
   Enforce the sectorsize being > 0 with a KASSERT on successful open.
   Fix scsi_cd.c to return 2k sectors when no media inserted.

Approved by:	re::kensmith
2004-09-13 06:26:57 +00:00
Brooks Davis fdc5041768 MFC the addition of ifi_epoch to struct if_data. The ifi_unused
variable has been replaced with ifi_epoch (and additionally, ifi_timepad
on alpha) so no ABI change has occured.

Approved by:	re (kensmith)
2004-09-13 05:11:40 +00:00
Warner Losh 2739847920 MFC: usb_subr.c 1.70
Add comments and don't free subdevs in the failure case.

Approved by: re@
2004-09-13 03:01:56 +00:00
Warner Losh 4dcc4bdcc3 MFC: uhub.c 1.63: remove child_deleted routine because we don't need it.
Approved by: re@
2004-09-13 03:00:06 +00:00
Christian Brueffer 5d52260d42 MFC: rev. 1.4
Remove spare ")"

Approved by:	re (blanket)
2004-09-13 01:34:46 +00:00
Christian Brueffer d30d78c5bc MFC: rev. 1.4
- grammar fixes
- fix path to a source file

Approved by:	re (blanket)
2004-09-13 01:34:03 +00:00
Pawel Jakub Dawidek 41c53ad350 Fix build on !i386 archs.
Approved by:	re (scottl)
2004-09-12 19:54:10 +00:00
Bruce A. Mah 826733a10b MFC: Minor grammar and wording fixups.
new.sgml	1.769 -> 1.770

Approved by:	re (hrs)
Reminded by:	hrs
2004-09-12 16:01:41 +00:00
Christian Brueffer 97a66196ca MFC: rev. 1.14
- add a HARDWARE section based on the driver README
- capitalization fixes
- bump document date

Approved by:	re (blanket)
2004-09-12 15:10:12 +00:00
Christian Brueffer 8acd78faaf MFC: rev. 1.21
We don't need device counts anymore.  Also remove device.hints entries
for ie1, to be in line with the other manpages.

Approved by:	re (blanket)
2004-09-12 15:09:20 +00:00
Christian Brueffer a6038a202c MFC: rev. 1.31
We don't need device counts anymore

Approved by:	re (blanket)
2004-09-12 15:07:57 +00:00
Wilko Bulte 086d41ae98 Document that tga(4) will not be in GENERIC for 5.3 on Alpha. It panics
the system on boot and needs major surgery to solve this.

Requested by: scottl
Approved by: re (scottl)
2004-09-11 20:45:41 +00:00
Scott Long ed191906f2 MFC: Revert the previous round of scheduler changes as they cause instant
panics on boot.

Approved by: re (implicit)
2004-09-11 10:28:42 +00:00
Hiroki Sato e7310c68db Removal of DA_OLD_QUIRKS option should be in "Disks and Storage"
section.

Pointed out by:	Xin LI (delphij at frontfree dot net)
Approved by:	re (implicitly)
2004-09-11 08:29:33 +00:00
Hiroki Sato 6f68b7a73f Unbreak the build.
Approved by:	re (implicitly)
2004-09-11 07:50:00 +00:00
Scott Long 8a4fdb58b2 Revert a mistake in the previous commit.
Approved by: re
2004-09-11 04:28:39 +00:00
Tim J. Robbins 4e3f8d7d39 MFC rev. 1.28: Ensure that struct defid is no larger than struct fid on
LP64 platforms, fixing NFS exports of msdos filesystems on at least amd64.

PR:		71173
Approved by:	re (scottl)
2004-09-11 03:19:31 +00:00
Scott Long 041694b017 Move into BETA4
Approved by: re
2004-09-11 01:26:28 +00:00
Scott Long 8957bf0f48 MFC the fix for PR 71509. This might not be the final fix, but it's good
enough for warrant wider testing.

Submitted by: tegge, julian
Approved by: re
2004-09-11 01:09:32 +00:00
Julian Elischer 4776820aad Bring in a change from jeffr for the preemption case.
MFC: 1.122

Approved by:	re (scottl)
2004-09-11 00:22:02 +00:00
Nate Lawson af5afe2fad MFC rev 1.9: Don't enter the debugger for AML breakpoint opcodes if
ACPI_DEBUG is not defined.

Approved by:	re (scottl)
2004-09-10 22:14:08 +00:00
Nate Lawson 4ca8103d1b MFC rev 1.29: Disable links after getting the possible resources instead
of before.

Approved by:	re (scottl)
2004-09-10 22:12:40 +00:00
John-Mark Gurney 5f0e790ab2 MFC v1.52:
document that m_free returns m_next of the free'd mbuf

Approved by:	re (hrs)
2004-09-10 20:59:38 +00:00
Ken Smith 01e25adc2e MFC of v1.41. From that Log entry:
Better fix the busdma problem exposed by ATA. With the CMD 646 for
  example the maximum segment size is 64K while the boundary is set
  to 8K due to controller limitations. It is impossible to NOT cross
  the boundary for any segment size that's larger than the boundary.
  So, once we inherited the boundary from the parent tag, make sure
  to reduce the maximum segment size to the boundary if it was larger.

Work done by:	marcel
Approved by:	re (scottl) [ Sooner than normal, needed for BETA4... ]
2004-09-10 20:22:50 +00:00
Max Laier 766fd5aa5d MFC if.c, rev. 1.203:
Fix an assertion when if_down()ing a ALTQ managed interface. The lock
  should have been in place all the time the mtx_assert in the ALTQ code
  just discovered the shortcoming.

  PR:             i386/71195
  Tested by:      Bettan (PR originator), myself

Approved by:	re (scottl)
2004-09-10 19:43:47 +00:00
Max Khon 211e6e1706 MFC: Do not compile in zlib.c. Add a dependency on module instead.
Approved by:	re
2004-09-10 07:00:38 +00:00
Wilko Bulte b4d5f155fb tga(4) is sufficiently broken that bandaids won't work. Given that
it panics systems on boot remove it from GENERIC so that tga(4)
equipped systems can get installed with 5.3.

This needs documenting in the 5.3 release notes.

Discussed with:	marcel, -alpha@
Approved by:	re (scottl)
2004-09-10 06:46:32 +00:00
Gleb Smirnoff c263fb4249 MFC 1.16:
Add axe(4) to ethernet-nic-regex.

Approved by:	re (scottl)
2004-09-10 06:23:23 +00:00
Gleb Smirnoff d3efcab04e MFC 1.34:
Increase PPTP_MAX_TIMEOUT up to 3 seconds. 10 proved too much for high
   packet
   loss links, and 1 second appeared to be too small for high latency links.

Approved by:	re (scottl)
2004-09-10 06:16:34 +00:00
Tim Kientzle 38d5bbcf51 MFC 1.27: The "regular-file-plus-trailing-slash-equals-dir" convention
should be checked only after the full header is read, including any
extensions; otherwise regular files in GNU tar archives with '/' as the
100th char get treated as directories.
Approved by: re@ (Ken Smith)
2004-09-10 04:30:24 +00:00
Scott Long 69ba7f5969 MFC: Turn PREEMPTION into a kernel option. It is NOT enabled at this time.
Approved by: re
2004-09-10 00:04:18 +00:00
Scott Long 9a18838a2b MFC rev 1.33: Sync busdma code with i386.
Submitted by: marcel
Approved by: re
2004-09-09 23:45:10 +00:00
Scott Long 61baafe02c Switch to the 4BSD scheduler for RELENG_5
Approved by: re
2004-09-09 23:10:49 +00:00
Ken Smith 3e1e27e576 MFC v1.25: Backout v1.24 on HEAD which had also been MFC-ed. Removing a
hack that hardcoded setting "hw.ata.ata_dma=0" because of DMA issues
on sparc64.  A fix is being done to bus_machdep.c that makes this
unnecessary now.

Approved by:	re (scottl)
2004-09-09 23:06:55 +00:00
Scott Long 152806cc30 MFC: Fix boundary inheritance in busdma.
Approved by: re
2004-09-09 23:05:01 +00:00
Simon L. B. Nielsen 735ae3ffee MFC v. 1.24-1.25:
Auto generate device listings for the following drivers: ctau, uhci.

Approved by:	re (blanket)
2004-09-09 19:22:01 +00:00
Simon L. B. Nielsen e566188a20 MFC v. 1.245-1.247:
- Auto generate device listings for the following drivers: cp, ct,
  ctau, uhci.
- Remove listing for NCR5380/NCR53400 and UltraStor 14F/24F/3F4;
  the drivers were removed over 5 years ago.
- Note that WD7000 is supported by the wds(4) driver and move it
  to the generic SCSI section, since it was converted to CAM some time ago.
- Remove section about non-CAM drivers, since there are none left in
  the section.

Approved by:	re (blanket)
2004-09-09 19:18:06 +00:00
Simon L. B. Nielsen 41ea0fb9ee MFC v. 1.15+1.16:
- Add a HARDWARE section which lists supported devices.
- Bump document date.

Approved by:	re (blanket)
2004-09-09 19:09:53 +00:00
Simon L. B. Nielsen 231bcb4dc9 MFC v. 1.17:
Reword/reorganize a bit to make it more clear that all OHCI v1.0
compliant controllers are supported.

Approved by:	re (blanket)
2004-09-09 19:05:34 +00:00
Simon L. B. Nielsen bd2d744509 MFC v. 1.5:
Add a HARDWARE section which lists supported devices based on the
Hardware Notes.

Approved by:	re (blanket)
2004-09-09 19:03:40 +00:00
Christian Brueffer b15a933694 MFC: rev. 1.61
Fix a couple of typos in comments

Approved by:	re (kensmith)
2004-09-09 13:19:39 +00:00
Ruslan Ermilov 6049dd52f4 MFC: Tweak the shell arithmetic to work with older /bin/sh (4.x and 5.1).
Approved by:	re (kensmith)
2004-09-09 12:20:47 +00:00
Yaroslav Tykhiy acf211c2c8 MFC fixes of list_net_interfaces().
1.155:
	Fix a typo in a variable name.

1.156:
	Avoid double appearing of cloned interfaces in the output
	from list_net_interfaces() when network_interfaces=auto.

Approved by:	re (kensmith)
2004-09-09 11:46:07 +00:00
Christian Brueffer f9d23bab62 MFC: rev. 1.4
- move list of supported devices into a HARDWARE section
- fix a device name
- various language fixes
- bump document date

Approved by:	re (blanket)
2004-09-09 11:43:12 +00:00
Christian Brueffer c8e6cd3c03 MFC: rev. 1.5
Add a missing 's'

Approved by:	re (blanket)
2004-09-09 11:42:16 +00:00
Julian Elischer 345c71eefb MFC: allow libthr to use process or system scope threads.
Approved by: re (scottl)
2004-09-09 10:39:01 +00:00
Julian Elischer c09dea4baa MFC: Make debug printf less threatenning and make it only print out once.
Approved by: re (scottl)
2004-09-09 10:23:02 +00:00
Julian Elischer 631a78a6b9 MFC of:
Give libthr a choice (per system) of scope_system  or scope_thread
  scheduling.

  Revision  Changes    Path
  1.26      +37 -10    src/sys/kern/kern_thr.c

Approved by: re (scottl)
2004-09-09 10:19:52 +00:00
Julian Elischer aa8d040b6a MFC of:
Don't do IPIs on behalf of interrupt threads.
  just punt straight on through to the preemption code.
  Make a KASSSERT out of a condition that can no longer occur.

Approved by: re (scottl)
2004-09-09 10:15:53 +00:00
Julian Elischer bc53cd71f6 MFC: slight code cleanup
Approved by: re (scottl)
2004-09-09 10:10:37 +00:00
Julian Elischer 1bf70e5e30 MFC: turn on IPIs for 4bsd scheduler by default.
Approved by: re (scottl)
2004-09-09 10:08:50 +00:00
Julian Elischer 292f4f3c4a MFC of:
Refactor a bunch of scheduler code to give basically the same behaviour
  but with slightly cleaned up interfaces.
(2004-09-05 02:09:54 UTC)
  see version 1.16 of sched.h for the original commit message.

Approved by: re (scottl)
2004-09-09 10:03:21 +00:00
Julian Elischer ab9b1e86a3 MFC of:
Give the 4bsd scheduler the ability to wake up idle processors
   when there is new work to be done.
   ( 2004-09-01 06:42:02 UTC)

Approved by: re (scottl)
2004-09-09 09:56:59 +00:00
Julian Elischer 22d3d6d45b MFC of:
Give setrunqueue() and sched_add() more of a clue as to
   where they are coming from and what is expected from them.
   (  2004-09-01 02:11:28 UTC )

Approved by:    re (scottl)
2004-09-09 09:45:27 +00:00
Tim Kientzle be5742d42c MFC: Correct the handling of the dynamically-generated .h file
Approved by: re (Ken Smith)
2004-09-09 05:42:22 +00:00
Scott Long 44d74aa93c MFC rev 1.11 of iir.c. This allows it to compile with PAE by removing some
bogus code.

Approved by: re
2004-09-08 19:54:36 +00:00
Marcel Moolenaar 232d436df4 MFC rev. 1.6: The IA32 option was renamed to COMPAT_IA32.
Approved by: re (blanket)
2004-09-08 17:41:31 +00:00
Christian Brueffer 3ec1c97ea9 MFC: rev. 1.244
Autogenerate device listings for el(4), ep(4) and sn(4)

Approved by:	re (blanket)
2004-09-08 15:09:39 +00:00
Christian Brueffer 6dd135995d MFC: rev. 1.23
Add el(4), ep(4) and sn(4)

Approved by:	re (blanket)
2004-09-08 15:08:05 +00:00
Christian Brueffer 18fe52f978 MFC: rev. 1.7
- add a HARDWARE section
- some capitalization fixes
- bump document date

Approved by:	re (blanket)
2004-09-08 15:01:52 +00:00
Christian Brueffer 4cfbf8b65f MFC: rev. 1.12
ixgb(4) supports polling as well

Approved by:	re (blanket)
2004-09-08 14:59:10 +00:00
Christian Brueffer a4a90ebd9d MFC: rev. 1.4
Remove dublicate words

Approved by:	re (blanket)
2004-09-08 14:57:54 +00:00
Christian Brueffer f42281b08e MFC: rev. 1.31
- move list of supported devices into a HARDWARE section
- sort the hardware list
- misc fixes
- bump document date

Approved by:	re (blanket)
2004-09-08 14:57:01 +00:00
Christian Brueffer 479045bba7 MFC: rev. 1.17
- add a HARDWARE section
- misc fixes
- bump document date

Approved by:	re (blanket)
2004-09-08 14:56:04 +00:00
Christian Brueffer 0fb4284cf4 MFC: rev. 1.5
- add a HARDWARE section
- bump document date

Approved by:	re (blanket)
2004-09-08 14:55:20 +00:00
Christian Brueffer 95bacb62ac MFC: rev. 1.30 + 1.31
Add the SMC EZ Card 1233A-TX as supported

Approved by:	re (blanket)
2004-09-08 14:54:24 +00:00
Roman Kurakin 98b193d337 MFC: mark cx(4) and ctau(4) as non MPSAFE.
Approved by:	re (scottl)
2004-09-08 12:38:23 +00:00
Scott Long 3ba69f0503 Remove the big scary paragraph about 5.x being slow due to enabled debugging
code.  Replace it with a friendly paragraph about how the debugging code
was disabled recently.

Submitted by: Xin Li (who really is in dire need of a commit bit!)
Approved by: re
2004-09-08 04:48:21 +00:00
Tim J. Robbins 6b3505f430 MFC rev. 1.5: Correctly check the return value of kldload() to determine
whether an error occurred.

Approved by:	re (scottl)
2004-09-08 04:47:56 +00:00
Tim J. Robbins caf16af507 MFC rev. 1.33: Fixes to handling of bracket expressions in regexes compiled
with REG_ICASE.

PR:		71367
Approved by:	re (scottl)
2004-09-08 04:42:46 +00:00
Scott Long 5ce26d28c9 Remove the kernel debugging options from GENERIC.
Approved by: re
2004-09-07 23:49:58 +00:00
Robert Watson 44c39b2035 Merge nd6.c:1.45 to RELENG_5:
date: 2004/09/05 17:27:54;  author: rwatson;  state: Exp;  lines: +1 -0
  Call callout_init() on nd6_slowtimo_ch before setting it going; otherwise,
  the flags field will be improperly initialized resulting in inconsistent
  operation (sometimes with Giant, sometimes without, et al).

  RELENG_5 candidate.

Approved by:	re (scottl)
2004-09-07 23:29:26 +00:00
Robert Watson 6817c14401 Merge uipc_socket.c:1.212 to RELENG_5:
date: 2004/09/05 14:33:21;  author: rwatson;  state: Exp;  lines: +4 -4
  Expand the scope of the socket buffer locks in sopoll() to include the
  state test as well as set, or we risk a race between a socket wakeup
  and registering for select() or poll() on the socket.  This does
  increase the cost of the poll operation, but can probably be optimized
  some in the future.

  This appears to correct poll() "wedges" experienced with X11 on SMP
  systems with highly interactive applications, and might affect a plethora
  of other select() driven applications.

  RELENG_5 candidate.

  Problem reported by:    Maxim Maximov <mcsi at mcsi dot pp dot ru>
  Debugged with help of:  dwhite

Approved by:	re (scottl)
2004-09-07 23:27:07 +00:00
Brooks Davis ff92be2bfc MFC 1.15:
When an USB keyboard is plugged in to a machine with a builtin
    keyboard, cause the USB keyboard to take over from the builtin one.

Approved by:	re (scottl)
PR:		kern/71354 (partial workaround only)
2004-09-07 23:26:52 +00:00
Brooks Davis df09f37367 MFC: if.c:1.202 if.h:1.90 ifconfig.c:1.107
Use a spare byte in struct if_data to store the structure size without
increasing it.  Add code to ifconfig to use this size to find the
sockaddr_dl after the struct if_data in the routing message.  This
allows struct if_data to grow (up to 255 bytes) without breaking
ifconfig.

Approved by:	re (scottl)
2004-09-07 23:21:10 +00:00
Robert Watson 46d669b180 Merge ng_ksocket.c:1.47 to RELENG_5:
date: 2004/09/02 19:53:13;  author: rwatson;  state: Exp;  lines: +3 -3
  In FreeBSD 5.x, curthread is always defined, so we don't need to to test
  and optionally use &thread0 if it's NULL.

  Spotted by:     julian

Approved by:	re (scottl)
2004-09-07 23:09:37 +00:00
Simon L. B. Nielsen 2905d562ef MFC 1.242:
- Auto generate device listings for the ex and ie drivers.

Approved by:	re (blanket)
2004-09-07 18:44:43 +00:00
Simon L. B. Nielsen b620ee0a5b MFC 1.21:
- Auto generate device listings for the ex and ie drivers.

Approved by:	re (blanket)
2004-09-07 18:43:55 +00:00
Simon L. B. Nielsen 34f8a51ad0 MFC 1.9:
Make sure ampersand is encoded as &amp; since jade seems to be confused
when it is encoded as &#38; inside an entity.

Approved by:	re (blanket)
2004-09-07 18:39:24 +00:00
Simon L. B. Nielsen 3e0b157d74 MFC 1.19+1.20:
- Properly capitalize Ethernet.
- Add a HARDWARE section which lists supported devices.
- Add a standard 2 clause BSD license.

Approved by:	re (blanket)
2004-09-07 18:36:50 +00:00
Simon L. B. Nielsen fef2e1cab2 MFC 1.20:
- Add a HARDWARE section which lists supported devices.

Approved by:	re (blanket)
2004-09-07 18:34:45 +00:00
Christian Brueffer 633a11001d MT5: rev. 1.231
Document a couple of build knobs

PR:             misc/71032 (partly)
Submitted by:   Divacky Roman <[email protected]>
Reviewed by:    ru
Approved by:	re (scottl)
2004-09-07 16:20:26 +00:00
Scott Long 72fc3a09fa Turn off malloc debugging for RELENG_5. This is intended to be off for the
remainder of the RELENG_5/5-STABLE lifespan.  It remains on in HEAD/6-CURRENT.

Approved by: re
2004-09-07 15:38:34 +00:00
Yaroslav Tykhiy a18b42013c MT5: Add an if_start handler to the SLIP driver so that
it is working again and doesn't panic the system.

Approved by:	re (scottl)
2004-09-07 09:48:27 +00:00
Peter Pentchev 414966098b MFC sockstat.c rev. 1.10 and sockstat.1 rev. 1.19:
Do not display bogus entries for sockets in the TIME_WAIT or similar
  states that no longer have a corresponding file descriptor - until now,
  sockstat would mostly randomly match null kern.file.*.xf_data fields
  with the first mostly-closed socket.

Approved by:	re (rwatson)
2004-09-07 07:53:38 +00:00
Maxim Konovalov 9e70475186 MFC rev. 1.56: restore a historical ipfw1 logamount behaviour: rules
with 'log' keyword but without 'logamount' limit the amount of their
log messages by net.inet.ip.fw.verbose_limit sysctl value.

Approved by:	re (scottl)
2004-09-07 06:37:09 +00:00
Christian Brueffer cbe6275995 Forced commit to not that the last message was supposed to be:
MT5: rev. 1.20 and 1.22

Add re, sis and snc

Approved by:	re (blanket)
2004-09-07 00:54:52 +00:00
Christian Brueffer 0cdc5f02b1 MT5: rev. 1.243
Autogenerate device listings for re, sis and snc

Approved by:	re (blanket)
2004-09-07 00:51:38 +00:00
Christian Brueffer f97eaf9988 Add snc, re and sis
Approved by:	re (blanket)
2004-09-07 00:48:28 +00:00
Christian Brueffer c4f959448c MT5: rev. 1.17
- move list of supported devices into a HARDWARE section
- mention which chip the devices use (where known)
- bump document date

Approved by:	re (blanket)
2004-09-07 00:45:13 +00:00
Christian Brueffer ee72ccd524 MT5: rev. 1.8
- move list of supported devices into a HARDWARE section
- fix spacing in the Corega entry
- bump document date

Approved by:	re (blanket)
2004-09-07 00:44:10 +00:00
Christian Brueffer 26d96cec4a MT5: rev. 1.2 - 1.4
- replace the ERRORS section with a DIAGNOSTICS section
- move list of supported adapters into a HARDWARE section
- sort the device list
- some minor fixes

Approved by:	re (blanket)
2004-09-07 00:41:50 +00:00
Christian Brueffer 7e514ae93d MT5: rev. 1.14
Properly capitalize Gigabit Ethernet

Approved by:	re (blanket)
2004-09-07 00:33:31 +00:00
Thomas Quinot 75d6e45ca3 MFC to RELENG_5 rev. 1.9:
Fix positional parameter reference to ${10}.
Fix target location for generation of fstab.

Approved by:	re (scottl)
PR:		bin/70795
2004-09-06 20:57:28 +00:00
Thomas Quinot 293edd811d MFC to RELENG_5 rev. 1.5:
Skip entries for GBDE swap devices if they are commented out in /etc/fstab.

Approved by:	re (scottl)
2004-09-06 20:55:03 +00:00
Robert Watson f200fb18f8 Merge pseudofs_vnops.c:1.46 to RELENG_5:
date: 2004/09/02 16:04:09;  author: rwatson;  state: Exp;  lines: +0 -11
  Back out pseudo_vnops.c:1.45, which was a workaround for pfind()
  returning incompletely initialized processes.  This problem was
  eliminated by kern_proc.c:1.215, which causes pfind() not to
  return processes in the PRS_NEW state.

Approved by:	re (scottl)
2004-09-06 19:38:01 +00:00
Robert Watson e80df11f01 Merge key.c:1.67 to RELENG_5:
date: 2004/09/02 20:14:03;  author: rwatson;  state: Exp;  lines: +0 -22
  The KAME IPSEC implementation at one point used its own pseudo-random
  number generator, which was re-seeded via a timeout.  Now centralized
  randomness/entropy is used, we can garbage collect the timeout and
  re-seeding code (which was largely a no-op).

  Discussed with: itojun, suz, JINMEI Tatuya < jinmei at isl dot rdc dot
  toshiba dot co dot jp >

Approved by:	re (scottl)
2004-09-06 19:36:40 +00:00
Søren Schmidt 39a323d20e Update ATA to -current level. Summary:
Fix the handling of "inflight" requests when doing reinit's.

Always pick up giant before returning from an ioctl call.

Sii_reset needs to wait up to 1 second to get slow disks with it.

Set and reset the right bit for UDMA enable/disable on the ICH* chips.

Only call dmainit() if there is a valid busmaster resource.

Workaround devices that responds with registers as *both* master & slave.

Introduce ata_udelay() that uses tsleep instead of DELAY if possible.

Properly check malloc returns.

Approved by: re@
2004-09-06 19:36:26 +00:00
Robert Watson 8c4db076ba Merge vfs_aio.c:1.175 to RELENG_5:
date: 2004/09/03 03:19:14;  author: rwatson;  state: Exp;  lines: +2 -0
  Tag AIO as requiring Giant over the network stack using
  NET_NEEDS_GIANT().

  RELENG_5 candidate.

Approved by:	re (scottl)
2004-09-06 19:32:00 +00:00
Stefan Farfeleder e505962ca3 MFC rev. 1.2, 1.3, 1.4:
date: 2004/09/03 23:26:55;  author: stefanf;  state: Exp;  lines: +1 -1
  Embarrassing typo: s/nextbyint/nearbyint/

  date: 2004/09/03 23:31:28;  author: stefanf;  state: Exp;  lines: +4 -4
  Use the keyword '_Complex' rather than the macro 'complex' since
  applications are allowed to undefine the latter.

  date: 2004/09/03 23:44:09;  author: stefanf;  state: Exp;  lines: +2 -1
  Add a workaround to recognise I/_Complex_I as complex arguments.  Although
  the GCC manual claims that the expression 1.0fi has type float _Complex,
  __builtin_types_compatible_p(float _Complex, __typeof__(1.0fi))) yields 0.

Approved by:	re (scottl)
2004-09-06 16:58:25 +00:00
Christian Brueffer 2fb71ebed1 MT5: rev. 1.239 - 1.241
Autogenerate device listings for nge, ste, ti, tl and wb

Approved by:	re (blanket)
2004-09-06 16:09:03 +00:00
Christian Brueffer 4209fafb30 MT5: rev. 1.17 - 1.19
Add nge, ste, ti, tl, ubsa, uftdi, uplcom

Approved by:	re (blanket)
2004-09-06 16:05:39 +00:00
Christian Brueffer 09e74c5391 MT5: rev. 1.5
Grammar fix

Approved by:	re (blanket)
2004-09-06 15:49:35 +00:00
Christian Brueffer cc1307ecae MT5: rev. 1.23
Properly capitalize Ethernet

Approved by:	re (blanket)
2004-09-06 15:48:51 +00:00
Christian Brueffer 6036b5df8d MT5: rev. 1.3
- change layout of the hardware list to the one used by other manpages
- grammar fixes

Approved by:	re (blanket)
2004-09-06 15:47:13 +00:00
Christian Brueffer c6d58104ab MT5: rev. 1.4
- change layout of the hardware list to the one used by other manpages
- add a missing word

Approved by:	re (blanket)
2004-09-06 15:45:05 +00:00
Christian Brueffer bde114cec5 MT5: rev. 1.8
- change layout of the hardware list to the one used by other manpages
- fix spacing of one hardware entry
- grammar fix

Approved by:	re (blanket)
2004-09-06 15:39:11 +00:00
Christian Brueffer e35509ebd2 MT5: rev. 1.17
- move list of supported adapters into a HARDWARE section
- properly capitalize (Fast) Ethernet
- bump document date

Approved by:	re (blanket)
2004-09-06 15:37:57 +00:00
Christian Brueffer 4f46c95bdd MT5: rev. 1.19
- move list of supported adapters into a HARDWARE section
- properly capitalize (Fast) Ethernet
- bump document date

Approved by:	re (blanket)
2004-09-06 15:37:15 +00:00
Christian Brueffer 1607cb9b00 MT5: rev. 1.28
- move list of supported adapters into a HARDWARE section
- list the Digital EtherWORKS adapter as supported [1]
- properly capitalize (Fast|Gigabit) Ethernet
- bump document date

Obtained from:  NetBSD [1]
Approved by:	re (blanket)
2004-09-06 15:36:23 +00:00
Christian Brueffer 091f6197ed MT5: rev. 1.16
- move list of supported adapters into a HARDWARE section
- properly capitalize (Fast) Ethernet
- bump document date

Approved by:	re (blanket)
2004-09-06 15:35:08 +00:00
Christian Brueffer 6394edbe97 MT5: rev. 1.14
- move list of supported adapters into a HARDWARE section
- properly capitalize Fast/Gigabit Ethernet
- bump document date

Approved by:	re (blanket)
2004-09-06 15:34:11 +00:00
Warner Losh 7b2ee40615 MFC: 1.157
Clear the description when detaching a driver from a node in the tree.

Approved by: re@
2004-09-06 04:29:40 +00:00
Martin Blapp ff417efc44 MFC r1.41:
Add special case for the german whois nameserver.

Approved by:	re (ken)
2004-09-06 00:21:42 +00:00
Hiroki Sato 79e75bb1aa Remove an unnecessary article.
Pointed out by:	bmah
Approved by:	re (implicitly)
2004-09-05 17:23:54 +00:00
Hiroki Sato 8edc6a6bf0 Various update for 5.3:
- Add &release.manpath.xorg;.
	- Bump &release.manpath.xfree86;.
	- Bump &release.manpath.freebsd;.
	- Fix a mail address in ($email-footer$).

Approved by:	re (implicitly)
2004-09-05 14:11:17 +00:00
Hiroki Sato 3e47c1221a Merge from rev.1.768.
Approved by:	re (implicitly)
2004-09-05 14:10:45 +00:00
Ken Smith 6cecded8c3 Forced commit to help with approvecheck debugging. Extra debugging
is turned on for cfg_local.pm.
2004-09-05 05:02:16 +00:00
Ken Smith 3889a464df Sorry - trying one last thing before I give up. :-/ 2004-09-05 04:44:20 +00:00
Ken Smith 91c32bf803 Forced commit to see if approvecheck works since I was one of the
ones it seemed to be failing for.
2004-09-05 04:36:34 +00:00
Tim J. Robbins b6579cbd62 MFC: Symlink missing lt_LT.ISO8859-4 LC_MONETARY, LC_MESSAGES and LC_NUMERIC
data files to the ISO8859-13 versions.

Approved by:	re (scottl)
2004-09-05 04:21:07 +00:00
Tim J. Robbins 17d4a0f84d MFC rev. 1.127, 1.128: Improve the robustness of MSDOSFSMNT_KICONV handling.
Approved by:	re (scottl)
2004-09-05 03:23:36 +00:00
Tim J. Robbins b6f818b6d1 MFC rev. 1.2: Fix conversion error in nostr.
Approved by:	re (scottl)
2004-09-05 01:47:33 +00:00
Christian Brueffer 4b6a0516dc MT5: rev. 1.16
aac works on ia64, twe and twa seem to work on amd64 (though not officially
supported by 3ware)

Approved by:	re (blanket)
2004-09-05 01:42:24 +00:00
MIHIRA Sanpei Yoshiro 6006529f5f MFC if_re.c 1.29, if_rlreg.h 1.45, re.4 1.7:
Add support Corega CG-LAPCIGT Gigabit Ethernet(8169S)

Approved by:	re (scott)
2004-09-04 22:32:32 +00:00
Simon L. B. Nielsen b19be55c83 MFC 1.236+1.238:
- Auto generate device listing for ath(4).
- Remove the listing for the Seagate ST01/02 and the Future Domain
  8xx/950 SCSI controllers.

Approved by:	re (blanket)
2004-09-04 19:34:26 +00:00
Simon L. B. Nielsen a091bc3d86 MFC:
- Add a HARDWARE section which lists supported devices.
- Mark up each item in the device list with .It, as per mdoc(7) and to
  make it simpler for auto generated Hardware Notes to parse the manual
  page.
- Bump document date.

Approved by:	re (blanket)
2004-09-04 19:26:08 +00:00
Dag-Erling Smørgrav c5a96d10b8 MFC: (1.16) add PCI ID for the BCM4401-B0
Approved by:	re (scottl)
2004-09-04 19:24:17 +00:00
Dag-Erling Smørgrav c7c2c2c99f MFC: (1.4) add PCI ID for the BCM4401-B0
Approved by:	re (scottl)
2004-09-04 19:23:54 +00:00
Simon L. B. Nielsen 8485cf1abd MFC 1.14:
- Auto generate device listing for ath(4).

Approved by:	re (blanket)
2004-09-04 19:21:56 +00:00
Simon L. B. Nielsen 5f413aa136 MFC 1.5-1.8:
- Support column lists, by only extracting the first column.
- s/_/./g for an entity name.
- For column lists: ignore first item when it is likely to be a header.
- Clean up and improve handling of trailing punctuation characters.
- Handle the Pa macro.
- Give a warning when ignoring unimplemented mdoc commands.
- Improve handling of trailing punctuation characters for the Xr macro.

Approved by:	re (blanket)
2004-09-04 19:15:00 +00:00
Ruslan Ermilov 2a70c9aa08 See if it also works for me. 2004-09-04 15:00:49 +00:00
David Xu b797728961 MFC: Add code to support statically linked binary and .core file of
threaded program.

Approved by: re (scottl)
2004-09-04 09:56:03 +00:00
David Xu c8572d7518 MFC: Only compile fbsd-thread.c on amd64 and i386.
Approved by: re (scottl)
2004-09-04 09:54:42 +00:00
Marcel Moolenaar 88dcd5eb01 MFC rev 1.3: return the dst argument.
Approved by: re (blanket)
2004-09-04 00:33:05 +00:00
Ken Smith 807af07c3b Another forced commit with no approval line, hoping this time it fails. 2004-09-04 00:23:10 +00:00
Marcel Moolenaar d9f18728d4 MFC rev 1.3: return the dst argument.
Approved by: re (blanket)
2004-09-04 00:17:50 +00:00
Ken Smith 3b5693d1cc Forced commit being done without an approval line to verify that the
check is failing.
2004-09-04 00:15:47 +00:00
Scott Long 08bd148c0e Update to 5.3-BETA3
Approved by: re
2004-09-03 23:23:51 +00:00
Ian Dowse ab3462326f MFC: 1.87; Add support for completing the installation of ELF
relocatable object format modules that were read in by the loader.

Approved by:	re
2004-09-03 20:06:24 +00:00
Ian Dowse 7c7515754d MFC: 1.87; fix two cases where a successful return from usbd_transfer()
would be treated as an error and cause a transfer to be freed twice.

Approved by:	re
2004-09-03 20:01:32 +00:00
Ian Dowse 53ec2be364 MFC: 1.27; Prevent vm_page_zero_idle_wakeup() from attempting to
wake up the page zeroing thread before it has been created.

Approved by:	re
2004-09-03 19:58:00 +00:00
Ian Dowse 56c038053c MFC: 1.114; fix the logic for trying each linker class in turn with
a preloaded module.

Approved by:	re
2004-09-03 19:49:25 +00:00
Ian Dowse bfba777dba MFC: add loader(8) support for preloading ELF relocatable object
format modules.

Approved by:	re
2004-09-03 19:25:40 +00:00
Ian Dowse 6d8298727f MFC: Add support for reading the ELF relocatable object format
modules that are use on the amd64 platform.

Approved by:	re
2004-09-03 18:38:47 +00:00
Ian Dowse 242bb9f6dc MFC: 1.39; add MODINFOMD_SHDR for passing section header tables
from the loader to the kernel.

Approved by:	re
2004-09-03 18:32:24 +00:00
Nate Lawson 649e5e0536 MFC rev 1.4, 1.5: Fix _FDE and _FDI probing.
Approved by:	re (scottl)
2004-09-03 16:54:41 +00:00
Alexander Kabaev f132146a87 MFC r1.76:
Reintroduce slightly modified patch from kern/69964.
  Check for LK_HAVE_EXL in both acquire invocations.

Approved by:	re (scottl)
2004-09-03 15:45:31 +00:00
John Baldwin 683a7ba55d MFC: Regenerate after fcntl() changes.
Approved by:	re (scottl)
2004-09-03 15:33:00 +00:00
John Baldwin 1f15a28a91 MFC: Fix the ABI wrappers to use kern_fcntl() rather than calling
fcntl() directly and mark related ABI syscalls as MP safe.

Approved by:	re (scottl)
2004-09-03 15:30:21 +00:00
John Baldwin 3aabf91be8 MFC: Generalize the UFS bad magic value so that it applies to both UFS1 and
UFS2.

Approved by:	re (scottl)
2004-09-03 15:19:06 +00:00
John Baldwin e2d62cc52e MFC: Further refine sleepqueue interface and consolidate duplicated code.
This also appears to fix some select/poll races by more sanely handling
TDF_SINTR.

Approved by:	re (scottl)
2004-09-03 15:14:15 +00:00
John Baldwin bffabda316 MFC: Remove some dead code.
Approved by:	re (scottl)
2004-09-03 15:06:54 +00:00
John Baldwin db0a650c5a MFC: Correct arguments to kern_sigaltstack().
Approved by:	re (scottl)
2004-09-03 15:05:49 +00:00
Ruslan Ermilov b9d08cf8b5 MFC: Fixed the doc build.
Tested by:	hrs
Approved by:	re (hrs)
2004-09-03 12:08:56 +00:00
Julian Elischer bd04aba61f fix mismerge of two MFCs 2004-09-03 10:47:49 +00:00
Julian Elischer e2689070ce MFC
remove #if 0'd  code

Approved by:	re (scottl)
2004-09-03 08:34:48 +00:00
Julian Elischer 1ee968c296 MFC:
>  Remove an unneeded argument..
>  The removed argument could trivially be derived from the remaining one.
>  That in turn should be the same as curthread, but it is possible that
>  curthread could be expensive to derive on some systems so leave it as an
>  argument.
>  Having both proc and thread as an argument just gives an opportunity for
>  them to get out sync.
>
>
>  Revision  Changes    Path
>  1.120     +1 -1      src/sys/alpha/alpha/trap.c
>  1.281     +2 -2      src/sys/amd64/amd64/trap.c
>  1.269     +2 -2      src/sys/i386/i386/trap.c
>  1.105     +1 -1      src/sys/ia64/ia64/trap.c
>  1.197     +2 -2      src/sys/kern/kern_kse.c
>  1.290     +1 -1      src/sys/kern/kern_sig.c
>  1.272     +1 -1      src/sys/kern/subr_trap.c
>  1.49      +1 -1      src/sys/powerpc/powerpc/trap.c
>  1.72      +1 -1      src/sys/sparc64/sparc64/trap.c
>  1.395     +1 -1      src/sys/sys/proc.h
2004-09-03 06:40:26 +00:00
Julian Elischer 8ae7881d15 MFC:
Remove TDP_USTATCLOCK, we no longer need it because we now always
 update tick count for userland in thread_userret. This change
 also removes a "no upcall owned" panic because fuword() schedules
 an upcall under heavily loaded, and code assumes there is no upcall
 can occur.

 Reported and Tested by: Peter Holm <[email protected]>

 Revision  Changes    Path
 1.198     +30 -55    src/sys/kern/kern_kse.c
 1.396     +0 -1      src/sys/sys/proc.h
----
 Note free bit.. as per the flags word.

 MFC after:      2 days

 Revision  Changes    Path
 1.397     +1 -0      src/sys/sys/proc.h

Approved by:	re (scottl)
2004-09-03 06:26:28 +00:00
Julian Elischer 6a3e188652 MFC:
> 1. try to use existing mailbox address in thread_update_usr_ticks.
> 2. remove '\n' in KASSERT.
>
> Revision  Changes    Path
> 1.196     +6 -4      src/sys/kern/kern_kse.c

Approved by:	re (scottl)
2004-09-03 06:18:47 +00:00
Julian Elischer 8afb903bde MFC
> Remove sched_free_thread() which was only used
> in diagnostics. It has outlived its usefulness and has started
> causing panics for people who turn on DIAGNOSTIC, in what is otherwise
> good code.
>
> MFC after:      2 days
>
> Revision  Changes    Path
> 1.119     +0 -6      src/sys/alpha/alpha/trap.c
> 1.280     +0 -6      src/sys/amd64/amd64/trap.c
> 1.7       +0 -3      src/sys/amd64/ia32/ia32_syscall.c
> 1.268     +0 -6      src/sys/i386/i386/trap.c
> 1.104     +0 -10     src/sys/ia64/ia64/trap.c
> 1.235     +0 -3      src/sys/kern/kern_fork.c
> 1.188     +0 -13     src/sys/kern/kern_prot.c
> 1.271     +0 -3      src/sys/kern/subr_trap.c
> 1.48      +0 -3      src/sys/powerpc/powerpc/trap.c
> 1.71      +0 -6      src/sys/sparc64/sparc64/trap.c
> 1.50      +0 -3      src/sys/sys/ucred.h

Approved by:	re (scottl)
2004-09-03 06:11:59 +00:00
Julian Elischer 1c3d4ccd17 MFC:
> Only test return_instead if P_SINGLE_EXIT is set, otherwise a fork()
> syscall can interrupt other thread's syscall in sleepq_catch_signals().
> Current, all callers know thread_suspend_check may suspend thread
> itself, so we need't to check return_instead for normal suspension
> flags (no P_SINGLE_EXIT set).
>
> Tested by: deischen
> Reported by: Maarten L. Hekkelman <[email protected]>
>
> Revision  Changes    Path
> 1.195     +1 -1      src/sys/kern/kern_thread.c

Approved by:	re (scottl)
2004-09-03 05:58:20 +00:00
Julian Elischer 3f77e4d948 MFC:
> Move TDF_CAN_UNBIND to thread private flags td_pflags, this eliminates
> need of sched_lock in some places. Also in thread_userret, remove
> spare thread allocation code, it is already done in thread_user_enter.
>    Reviewed by: julian
>      Revision  Changes    Path
> 1.195     +4 -19     src/sys/kern/kern_kse.c
> 1.394     +3 -4      src/sys/sys/proc.h
>
Approved by:	re (scottl)
2004-09-03 05:55:06 +00:00
Julian Elischer 2373981121 MFC 1.50 Use some macros to reduce diff to upcoming commits
Approved by:	re (scottl)
2004-09-03 05:49:05 +00:00
Robert Watson 8f204636b9 Merge UPDATING:1.351 to RELENG_5:
date: 2004/08/28 17:08:30;  author: rwatson;  state: Exp;  lines: +13 -0
  Add an updating entry for the recent change in network stack locking
  default for debug.mpsafenet, pointing at the recent announcement and
  things to try if instability is experienced.

Approved by:	re (scottl)
2004-09-03 03:17:14 +00:00
Robert Watson bbee142b17 Merge sys/netgraph/ng_tty.c:1.30, sys/netinet6/ipsec.c:1.37,
sys/netipx/ipx.c:1.27 to RELENG_5:

  Mark Netgraph TTY, KAME IPSEC, and IPX/SPX as requiring Giant for correct
  operation using NET_NEEDS_GIANT().  This will result in a boot-time
  restoration of Giant-enabled network operation, or run-time warning on
  dynamic load (applicable only to the Netgraph component).  Additional
  components will likely need to be marked with this in the future.

Approved by:	re (scottl, kensmith)
2004-09-03 03:12:58 +00:00
Robert Watson 226a384ac3 Merge sys/conf/options:1.478, sys/net/netisr.c:1.12, and
sys/sys/kernel.h:1.118 to RELENG_5:

  Change the default disposition of debug.mpsafenet from 0 to 1, which
  will cause the network stack to operate without the Giant lock by
  default.  This change has the potential to improve performance by
  increasing parallelism and decreasing latency in network processing.

  Due to the potential exposure of existing or new bugs, the following
  compatibility functionality is maintained:

  - It is still possible to disable Giant-free operation by setting
    debug.mpsafenet to 0 in loader.conf.

  - Add "options NET_WITH_GIANT", which will restore the default value of
    debug.mpsafenet to 0, and is intended for use on systems compiled with
    known unsafe components, or where a more conservative configuration is
    desired.

  - Add a new declaration, NET_NEEDS_GIANT("componentname"), which permits
    kernel components to declare dependence on Giant over the network
    stack.  If the declaration is made by a preloaded module or a compiled
    in component, the disposition of debug.mpsafenet will be set to 0 and
    a warning concerning performance degraded operation printed to the
    console.  If it is declared by a loadable kernel module after boot, a
    warning is displayed but the disposition cannot be changed.  This is
    implemented by defining a new SYSINIT() value, SI_SUB_SETTINGS, which
    is intended for the processing of configuration choices after tunables
    are read in and the console is available to generate errors, but
    before much else gets going.

  This compatibility behavior will go away when we've finished the last
  of the locking work and are confident that operation is correct.

Approved by:	re (scottl, kensmith)
2004-09-03 03:09:55 +00:00
Robert Watson 0ffe4a33d8 Merge raw_ip6.c:1.46 to RELENG_5:
date: 2004/09/02 20:18:02;  author: rwatson;  state: Exp;  lines: +1 -1
  Unlock rather than lock the ripcbinfo lock at the end of rip6_input().

  RELENG_5 candidate.

  Foot provided by:       Patrick Guelat <pg at imp dot ch>

Approved by:	re (scottl) (accelerated schedule for BETA3)
2004-09-02 21:18:09 +00:00
Robert Watson f15b0466fa Merge if_pcn.c:1.60, if_sf.c:1.73, if_ti.c:1.97, if_tl.c:1.94,
if_wb.c:1.74 to RELENG_5:

  Tag a last set of PCI network interfaces as IFF_NEEDSGIANT until they
  are either locked down or demonstrated MPSAFE.

Approved by:	re (scottl)
2004-09-02 20:57:40 +00:00
Colin Percival 05ba583756 MFC rev. 1.129. (Attempt #2 to fix this problem without breaking
anything else.)

When creating a new md, g_waitidle() to make sure the /dev entry gets
created before mdconfig(8) returns, *but only if it's not a preloaded
md*.

Approved by:	re (kensmith)
2004-09-02 20:08:41 +00:00
Marcel Moolenaar c4a4217ea1 MFC rev 1.67: remove asr(4),
rev 1.69: add aac(4) and aacp(4).

Approved by: re (blanket)
2004-09-02 19:01:48 +00:00
Robert Watson 0bb5c1d3fb Merge ng_socket.c:1.54 to RELENG_5:
date: 2004/08/30 14:41:25;  author: rwatson;  state: Exp;  lines: +2 -0
  Acquire Giant arounds calls into the linker from Netgraph sockets.
  We now no longer hold Giant in send(), so it isn't inheritted by the
  linker, which calls into VFS.

  Reported by:    glebius
  Discussed with: glebius, bz

Approved by:	re (kensmith)
2004-09-02 15:41:44 +00:00
Justin T. Gibbs e2867b05ae MFC: Correct a spelling error in a comment.
Approved by: re
2004-09-02 15:36:04 +00:00
Justin T. Gibbs 9c077ee25d MFC: Correct polarity of logic to avoid unecessary bus resets
during timeout recovery.

Approved by: re
2004-09-02 15:33:15 +00:00
Justin T. Gibbs a96ee3d394 MFC: Remove stale EISA constants from initial port from the aic7xxx driver
Approved by: re
2004-09-02 15:32:05 +00:00
Justin T. Gibbs 951d35d8bb MFC: Set AHD_BUSFREEREV_BUG in the bugs, not features, field of our softc.
Approved by: re
2004-09-02 15:31:21 +00:00
Justin T. Gibbs 692bfb5b28 MFC: Correct argument order in PCI config space operations used to handle
PCI error interrupts.

Approved by: re
2004-09-02 15:29:39 +00:00
Justin T. Gibbs 07261a9cf0 MFC: Improve sync error recovery (revs 1.80 and 1.81).
Approved by: re
2004-09-02 15:24:38 +00:00
Bruce A. Mah 9ad35d0cf5 Update the version number in the release documentation to reflect the
current pre-5.3 state of this branch and change the upload location
for relnotesNG snapshots.

Approved by:	re (hrs)
2004-09-02 14:51:18 +00:00
Christian S.J. Peron 10f1868849 MFC net/route.c v1.107
When a prison is given the ability to create raw sockets (when the
security.jail.allow_raw_sockets sysctl MIB is set to 1) where privileged
access to jails is given out, it is possible for prison root to manipulate
various network parameters which effect the host environment. This commit
plugs a number of security holes associated with the use of raw sockets
and prisons.

This commit makes the following changes:

- Add a comment to rtioctl warning developers that if they add
  any ioctl commands, they should use super-user checks where necessary,
  as it is possible for PRISON root to make it this far in execution.
- Add super-user checks for the execution of the SIOCGETVIFCNT
  and SIOCGETSGCNT IP multicast ioctl commands.
- Add a super-user check to rip_ctloutput(). If the calling cred
  is PRISON root, make sure the socket option name is IP_HDRINCL,
  otherwise deny the request.

Although this patch corrects a number of security problems associated
with raw sockets and prisons, the warning in jail(8) should still
apply, and by default we should keep the default value of
security.jail.allow_raw_sockets MIB to 0 (or disabled) until
we are certain that we have tracked down all the problems.

Looking forward, we will probably want to eliminate the
references to curthread.

Approved by:	re (kensmith)
2004-09-02 14:49:34 +00:00
Christian S.J. Peron 518a9fdb22 MFC netinet/ip_mroute.c v.1.107
MFC netinet/raw_ip.c v1.143

When a prison is given the ability to create raw sockets (when the
security.jail.allow_raw_sockets sysctl MIB is set to 1) where privileged
access to jails is given out, it is possible for prison root to manipulate
various network parameters which effect the host environment. This commit
plugs a number of security holes associated with the use of raw sockets
and prisons.

This commit makes the following changes:

- Add a comment to rtioctl warning developers that if they add
  any ioctl commands, they should use super-user checks where necessary,
  as it is possible for PRISON root to make it this far in execution.
- Add super-user checks for the execution of the SIOCGETVIFCNT
  and SIOCGETSGCNT IP multicast ioctl commands.
- Add a super-user check to rip_ctloutput(). If the calling cred
  is PRISON root, make sure the socket option name is IP_HDRINCL,
  otherwise deny the request.

Although this patch corrects a number of security problems associated
with raw sockets and prisons, the warning in jail(8) should still
apply, and by default we should keep the default value of
security.jail.allow_raw_sockets MIB to 0 (or disabled) until
we are certain that we have tracked down all the problems.

Looking forward, we will probably want to eliminate the
references to curthread.

Approved by:	re (kensmith)
2004-09-02 14:47:37 +00:00
Jacques Vidrine 995c28950b MFC infback.c 1.2, inflate.c 1.5: Correct a denial-of-service
vulnerability in zlib.

Approved by:	re (scottl)
2004-09-02 14:34:28 +00:00
Giorgos Keramidas 2542e8ec5a Minor wordsmithing of the fixit media login message.
Approved by:	re
2004-09-02 13:45:24 +00:00
Marcel Moolenaar e3d998abca MFC rev 1.9 & 1.10:
Do not match TGA2 adapters. They are not compatible with TGA adapters,
nor are they 3D accelarators as the description would like us to
believe. Since the TGA2 adapter has a VGA mode (unlike the TGA adapter),
one can use the VGA driver instead.

Remove redundant _FBSDID.

Approved by: re (scottl)
2004-09-02 06:14:42 +00:00
Marcel Moolenaar f8ca9a36b7 MFC rev 1.35:
In alpha_pci_alloc_resource(), when allocating a memory resource,
do not set the virtual address to the bus address when the bus
doesn't have either of the PCI_RF_DENSE or PCI_RF_BWX flags set.
The TGA driver uses the virtual address to access the registers,
which on some machines can cause a memory management fault.  Map
the bus address as K0SEG virtual memory instead. Note that with
some hardware combinations involving the TGA2 adapter this change
merely results that the memory management fault is replaced by a
machine check.

Approved by: re (scottl)
2004-09-02 06:12:19 +00:00
Tim Kientzle 09b4ca36cb MFC lib/version-etc.c 1.4: correctly clean up va_list variable
Approved by: re (Ken Smith)
2004-09-02 04:32:26 +00:00
Tim Kientzle 18206eb7c1 MFC: Recognize and ignore pax 'x' and 'g' extension entries.
In particular, don't create "PaxHeader" dirs when extracting archives
created by newer tar and pax implementations.

Approved by: re (Ken Smith)
2004-09-02 04:18:17 +00:00
Tim Kientzle 0cd77e3704 MFC: support -O with -t, where it means "send list to stderr", as in gtar
Approved by: re (Ken Smith)
2004-09-02 04:09:46 +00:00
Tim Kientzle b44abde8b0 MFC write.c 1.34: Fix -T/-I to correctly use updated -C machinery.
Approved by: re (Ken Smith)
2004-09-02 04:06:00 +00:00
Tim Kientzle 3f59b86286 MFC archive_read_extract.c 1.35:
Cache uid-from-uname and gid-from-gname lookups during extraction
Approved by: re (Ken Smith)
2004-09-02 04:00:12 +00:00
Robert Watson 18a7add041 Merge uipc_usrreq.c:1.140 to RELENG_5:
date: 2004/08/25 21:24:36;  author: rwatson;  state: Exp;  lines: +15 -8
  Don't hold the UNIX domain socket subsystem lock over the body of the
  UNIX domain socket garbage collection implementation, as that risks
  holding the mutex over potentially sleeping operations (as well as
  introducing some nasty lock order issues, etc).  unp_gc() will hold
  the lock long enough to do necessary deferal checks and set that it's
  running, but then release it until it needs to reset the gc state.

  Discussed with: alfred

Approved by:	re (kensmith)
2004-09-02 03:21:39 +00:00
Ken Smith 6acac06358 MFC of the X server configuration removal from sysinstall. Versions
being MFC-ed:

	config.c	V1.226
	dispatch.c	V1.47
	install.c	V1.359
	menus.c		V1.400
	sysinstall.8	V1.65
	sysinstall.h	V1.262

Discussed on:	freebsd-current@
Approved by:	re (scottl)
2004-09-02 01:55:00 +00:00
Christian S.J. Peron dd894fd77c MFC v1.243:
Currently, if the secure level is low enough, system flags can
be manipulated by prison root. In 4.x prison root can not manipulate
system flags, regardless of the security level. This behavior
should remain consistent to avoid any surprises which could lead
to security problems for system administrators which give out
privileged access to jails.

This commit changes suser_cred's flag argument from SUSER_ALLOWJAIL
to 0. This will prevent prison root from being able to manipulate
system flags on files.

Approved by:	re (kensmith)
2004-09-02 01:12:20 +00:00
Ken Smith 50c5fbddf2 MFC v1.11: Protect command flags set in the rc.conf files in case they're
more than one word, adding some quotes.

Reviewed by:	mtm
Approved by:	re (scottl)
2004-09-01 16:31:43 +00:00
Peter Pentchev 5dcb7e5fa5 MFC mpool.3 rev. 1.13: remove the misleading documentatin of the unused
'key' argument to mpool_open(3).

Approved by:	re (kensmith)
MFC after:	3 days
2004-08-31 07:04:41 +00:00
Poul-Henning Kamp c1ad05d25f MFC:
Introduce g_alloc_bio() as a waiting variant of g_new_bio().

	Use in places where we can sleep and where we previously
	failed to check for a NULL pointer.

Approved by:	re(ken)
2004-08-31 06:14:03 +00:00
Nate Lawson 15c54a5c94 MFC: Rework sysresource allocation to merge all resources presented by
sysresource objects before allocating.  This includes adding a
bus_get_resource_list() method to all archs as well.  Includes:

    Revision  Changes    Path
    1.189     +82 -7     src/sys/dev/acpica/acpi.c
    1.31      +59 -115   src/sys/dev/acpica/acpi_resource.c
    1.81      +0 -2      src/sys/dev/acpica/acpivar.h

Approved by:	re (scottl)
2004-08-31 05:26:37 +00:00
Dag-Erling Smørgrav 994dea634c MFC: don't forget to va_end() after va_copy().
Approved by:	re (kensmith)
2004-08-31 05:20:43 +00:00
Dag-Erling Smørgrav 47d4a517de MFC: (1.73) the check for r_flag was accidentally removed in 1.72.
Approved by:	re (kensmith)
2004-08-31 05:18:33 +00:00
Tim Kientzle 98e9f47def MFC:
archive_string_sprintf.c 1.5: don't reuse va_list variable
   archive_read_extract.c 1.34: don't change permissions on existing dirs
Approved by: re@ (Ken Smith)
2004-08-31 05:10:36 +00:00
Tim Kientzle 5a238fce1c MFC:
1.53: Enable already-implemented -I option
  1.54: Permit -P as a no-op when used with -t
Approved by: re@ (Ken Smith)
2004-08-31 05:04:17 +00:00
Tom Rhodes 263b16ce45 Catch up with CURRENT which documents the new features in mac_bsdextended(4).
Approved by:	re (kensmith)
2004-08-31 04:51:35 +00:00
Tom Rhodes 756b5e9447 MT5: 1.20 Allow mac_bsdextended(4) to log policy violations via
syslog(3)'s AUTHPRIV facility.  Default is disabled but this can
be altered with the mac_bsdextended_logging sysctl.

Approved by:	re (kensmith)
2004-08-31 04:50:35 +00:00
Tom Rhodes 40a8901f07 MT5: 1.19 The ability to match first rule in place of all rules.
Add the mac_bsdextended_firstmatch_enabled sysctl to permit the
enable/disable of this feature.  Default is disabled.

Approved by:	re (kensmith)
2004-08-31 04:48:04 +00:00
Tom Rhodes a1827b1cd5 Catch hfa.4 and rc.4 manual pages up to the ones in CURRENT.
Approved by:	re (kensmith)
2004-08-31 04:37:31 +00:00
Christian Brueffer 937a276639 MT5: rev. 1.230 - 1.235
Autogenerate device listings for the following drivers:

ixgb, sf, sk, lge, vx, axe, rue, cue, kue

Approved by: re (blanket)
2004-08-30 23:49:53 +00:00
Christian Brueffer 5c1ab3ca52 MT5: rev. 1.7 - 1.9, 1.11 - 1.13
Add ixgb, sf, sk, lge, vx, axe, rue, cue, kue
Remove isp and mpt (work on all supported platforms)

Approved by: re (blanket)
2004-08-30 23:39:17 +00:00
Christian Brueffer fd57ea57e3 MT5: rev. 1.27
- use .Nm
- fix some grammar and spelling mistakes

Approved by:	re (blanket)
2004-08-30 23:27:04 +00:00
Christian Brueffer a1ba67e437 MT5: rev. 1.20
- move the list of supported adapters into a HARDWARE section
- sort the list of adapters
- add the 3Com 3c460 HomeConnect Ethernet USB Adapter [1]
- properly capitalize Ethernet
- replace a misleading 'adapter' with 'chipset'
- bump document date

Obtained from:  NetBSD [1]
Approved by:	re (blanket)
2004-08-30 23:25:41 +00:00
Christian Brueffer 96c0da5e7f MT5: rev. 1.19
- move the list of supported adapters into a HARDWARE section
- properly capitalize Ethernet
- replace a misleading 'adapter' with 'chipset'
- bump document date

Approved by:	re (blanket)
2004-08-30 23:24:14 +00:00
Christian Brueffer 0fbc30b1be MT5: rev. 1.8
- move list of supported adapters into a HARDWARE section
- fix capitalization of a "to"
- bump document date

Approved by:	re (blanket)
2004-08-30 23:23:15 +00:00
Christian Brueffer 0664539edf MT5: rev. 1.7
- put the list of supported adapters into a HARDWARE section
- make the Buffalo entry look better
- properly capitalize Ethernet and Fast Ethernet
- bump document date

Approved by:	re (blanket)
2004-08-30 23:22:12 +00:00
Christian Brueffer 2f77e00d8b MT5: rev. 1.19
- move the list of supported devices into a HARDWARE section
- bump document date

Approved by:	re (blanket)
2004-08-30 23:20:28 +00:00
Christian Brueffer 3ec024f402 MT5: rev. 1.8 + 1.9
1.8:
- move device listing and hardware notes into a HARDWARE section
- properly capitalize Gigabit Ethernet
- bump document date

1.9:
Move a paragraph from the HARDWARE section back into the
DESCRIPTION section.  Also adapt it to make it fit in better.

Approved by:	re (blanket)
2004-08-30 23:18:53 +00:00
Christian Brueffer aa0d3a68cc MT5: rev. 1.23
- move the list of supported adapters to a HARDWARE section
- correct entry for the Belkin card
- properly capitalize Gigabit Ethernet
- wordsmithing on a sentence
- bump document date

Approved by:	re (blanket)
2004-08-30 23:15:24 +00:00
Christian Brueffer 173d5d7457 MT5: rev. 1.18 + 1.19
- move list of supported adapters into a HARDWARE section
- correctly capitalize Fast Ethernet
- correct two typos
- correct the link to the AIC-6915 programmer's manual
- bump document date

Approved by:	re (blanket)
2004-08-30 23:12:10 +00:00
Christian Brueffer a4f5df9443 MT5: rev. 1.3 + 1.4
Add a HARDWARE section and bump the document date

Approved by:	re (blanket)
2004-08-30 23:09:05 +00:00
Brooks Davis 82219f6dbb MFC 1.200:
When detaching an interface, don't leave an obsolete pointer to the
  soon to be deleted struct ifnet around.

PR:		kern/52260
Approved by:	re (scottl)
2004-08-30 22:15:07 +00:00
cvs2svn ebd3ecd4ba This commit was manufactured by cvs2svn to create branch 'RELENG_5_3'. 2004-08-30 22:02:58 +00:00
Robert Watson 8f57ee5f80 Merge nfs_serv.c:1.148 to RELENG_5:
date: 2004/08/25 16:52:59;  author: rwatson;  state: Exp;  lines: +1 -1
  Convert a mtx_lock(&Giant) to a mtx_unlock(&Giant) in nfsrv_link() to
  prevent leakage of Giant.  With INVARIANTS, this results in an
  assertion failure following execution of the RPC.  Without INVARIANTS,
  it could result in problems if the NFS server is killed causing nfsd
  to return to user space holding Giant.

  Feet provided by:       brueffer

Approved by:	re (scottl)
2004-08-30 22:02:57 +00:00
Robert Watson 58f73d5a80 Merge nfs_socket.c:1.115 to RELENG_5:
date: 2004/08/25 01:23:38;  author: rwatson;  state: Exp;  lines: +2 -4
  In nfs_timer(), pass curthread rather than &thread0 into the protocol
  send routine.  In IPv6 UDP, the thread will be passed to suser(), which
  asserts that if a thread is used for a super user check, it be
  curthread.  Many of these protocol entry points probably need to
  accept credentials instead of threads.

  MT5 candidate.

  Noticed/tested by:      kuriyama

Approved by:	re (scottl)
2004-08-30 21:58:31 +00:00
Wilko Bulte 1c3f901675 MFC:
- Now that I discovered that 164SX SRM recognises Intel 8255x NICs and allows
  them to be net booted lets document that fact.
- Note that Adaptec 3940UW won't be recognised by the 164sx SRM
- Warn that 164SX is a picky customer with regards to DIMMs.

Approved by: re (kensmith)
2004-08-30 19:09:58 +00:00
Robert Watson 438b1408f1 Merge kern_socket.c:1.211 to RELENG_5:
date: 2004/08/24 05:28:18;  author: rwatson;  state: Exp;  lines: +16 -35
  Conditional acquisition of socket buffer mutexes when testing socket
  buffers with kqueue filters is no longer required: the kqueue framework
  will guarantee that the mutex is held on entering the filter, either
  due to a call from the socket code already holding the mutex, or by
  explicitly acquiring it.  This removes the last of the conditional
  socket locking.

Approved by:	re (scottl)
2004-08-30 17:54:57 +00:00
Robert Watson 44651eda08 Merge udp_usrreq.c:1.164 and udp_usrreq.c:1.165 to RELENG_5:
revision 1.165
  date: 2004/08/22 01:32:48;  author: rwatson;  state: Exp;  lines: +3 -1
  When sliding the m_data pointer forward, update m_pktrhdr.len as well
  as m_len, or the pkthdr length will be inconsistent with the actual
  length of data in the mbuf chain.  The symptom of this occuring was
  "out of data" warnings from in_cksum_skip() on large UDP packets sent
  via the loopback interface.

  revision 1.164
  date: 2004/08/21 16:14:04;  author: rwatson;  state: Exp;  lines: +7 -4
  When prepending space onto outgoing UDP datagram payloads to hold the
  UDP/IP header, make sure that space is also allocated for the link
  layer header.  If an mbuf must be allocated to hold the UDP/IP header
  (very likely), then this will avoid an additional mbuf allocation at
  the link layer.  This trick is also used by TCP and other protocols to
  avoid extra calls to the mbuf allocator in the ethernet (and related)
  output routines.

Approved by:    re (Scottl)
2004-08-30 16:22:23 +00:00
Sheldon Hearn f06e159db1 MFC rev 1.31: regen 2004-08-30 15:51:34 +00:00
Don Lewis 06d368af39 MFC kern_module.c 1.46
>   Don't bother calling the module event handlers from module_shutdown()
>   in the shutdown_final state if the RB_NOSYNC flag is set.
>
>   The specific motivation in this case is that a system panic in an
>   interrupt context results in a call to module_shutdown(), which
>   calls g_modevent(), which calls g_malloc(..., M_WAITOK), which
>   results in a second panic.   While g_modevent() could be fixed to
>   not call malloc() for MOD_SHUTDOWN events (which it doesn't handle
>   in any case), it is probably also a good idea to entirely skip the
>   execution of the module shutdown handlers after a panic.

Approved by:	re (kensmith)
2004-08-30 08:11:03 +00:00
Don Lewis 0cb8fd6b22 MFC vfs_subr.c 1.523
>   Don't attempt to trigger the syncer thread final sync code in the
>   shutdown_pre_sync state if the RB_NOSYNC flag is set.  This is the
>   likely cause of hangs after a system panic that are keeping crash
>   dumps from being done.

Approved by:	re (kensmith)
2004-08-30 08:09:06 +00:00
Peter Pentchev 051efa7a1b MFC rtsock.c 1.116: typo fix - attacked -> attached.
Approved by:	re (kensmith)
2004-08-30 06:31:55 +00:00
Max Laier 65cdc248f8 MT5:
Document supported devices here (for lack of a better place). Users
  interested in ALTQ are likely to type in "man altq" at some point and
  maybe they will scroll down to the bottom as well.

Approved by:	re (hrs)
2004-08-30 01:34:01 +00:00
Nate Lawson 1f00bb32bc MFC rev 1.27: Remove code to initialize the lid state at boot.
Approved by:	re (kensmith)
2004-08-29 23:24:33 +00:00
Nate Lawson d9d851b84d MFC rev 1.26-1.28: When ignoring an invalid _CRS response, be sure to
set a status of success.  Also moves a printf under bootverbose.

Approved by:	re (kensmith)
2004-08-29 23:23:37 +00:00
Brian Feldman 93495516da MFC r1.24: fix totally broken memory allocation exposed by new contigmalloc.
Approved by:	re
2004-08-29 20:50:32 +00:00
Max Laier e2ab11b1af MT5:
Fix securelevel handling for tables:

  Loopback a fix from Cedric Berger:
          Fix table add/replace commands with securelevel=2.
          Reported by James J. Lippard.

and

  Use securelevel_gt instead of reading global securelevel unprotected.

Approved by:	re (kensmith)
2004-08-29 11:51:07 +00:00
Maxim Sobolev 7f6cdd5d49 MFC: CPU_DISABLE_CMPXCHG is no longer necessary with VmWare 4.x.
Approved by:	re@
2004-08-29 11:23:59 +00:00
Tim J. Robbins 0fdacc2ca0 MFC rev. 1.12: Build a dummy opt_compat.h header.
Approved by:	re (kensmith)
2004-08-29 06:15:44 +00:00
Tim J. Robbins 013564995c MFC: Better ftw() and nftw() implementations from OpenBSD.
Approved by:	re (kensmith)
2004-08-29 06:10:53 +00:00
Tim J. Robbins 5e3f006a10 MFC rev. 1.2: Re-generate from sl_SI.ISO8859-2.src rev. 1.8 (lowercase
month/weekday names).

Approved by:	re (kensmith)
2004-08-29 05:58:11 +00:00
Tim J. Robbins 37c923c53c MFC rev. 1.7: Begin month and weekday names with a lowercase letter.
PR:		65317
Approved by:	re (kensmith)
2004-08-29 05:55:58 +00:00
Ken Smith d38bc58c5a s/5.2/5.3/
Approved by:	re (scottl)
2004-08-29 05:37:20 +00:00
Doug White a60267028d MFC: Pick up changes in rev 1.8 of src/sys/dev/ic/mpt_netbsd.c from NetBSD.
Set the DMA SGL length correctly if the DMA request must be chained because
it is too large to fit in one SGL.

Approved by:	re
2004-08-29 04:56:38 +00:00
cvs2svn 6355e714bc This commit was manufactured by cvs2svn to create branch 'RELENG_5'. 2004-08-29 00:48:43 +00:00
Ken Smith 297c82c367 Back out the MFC done as rev 1.127.2.1. It seems to fix the problem of
mdconfig returning before the device's name appears in /dev but it seems
to cause a worse problem.  When booting the installation media (CD or
boot floppies) the system hangs after the device probes, at the point
it should be trying to mount a MD-based filesystem as its root filesystem.
Backing out this patch solves that problem, allowing it to proceed to
the sysinstall menu.

Approved by:	re (rwatson)
2004-08-28 19:54:50 +00:00
Simon L. B. Nielsen 8401c4c7a2 MFC 1.22: Fix grammar nit.
Approved by:	re (blanket)
2004-08-27 20:06:55 +00:00
Doug Rabson fb0f2d1d89 MFC: Fix variant I tls initialisation for static binaries
Approved by: re (scottl)
2004-08-27 16:57:28 +00:00
Matt Jacob 772718e237 MFC 1.103- turn of sleeping in top half due to conflicts with geom design.
Approved by:	re
2004-08-27 15:46:56 +00:00
Scott Long bdba4ec4db Start the 5.2-BETA2 phase
Approved by:	re
2004-08-27 05:32:03 +00:00
Robert Watson 83ad145904 Merge removal of in6_prefix to RELENG_5 from HEAD:
Remove in6_prefix.[ch] and the contained router renumbering capability.
  The prefix management code currently resides in nd6, leaving only the
  unused router renumbering capability in the in6_prefix files.  Removing
  it will make it easier for us to provide locking for the remainder of
  IPv6 by reducing the number of objects requiring synchronized access.

  This functionality has also been removed from NetBSD and OpenBSD.

  Submitted by:   George Neville-Neil <gnn at neville-neil.com>
  Discussed with/approved by:     suz, keiichi at kame.net, core at kame.net

  Revision  Changes    Path
  1.944     +0 -1      src/sys/conf/files
  1.48      +0 -7      src/sys/netinet6/in6.c
  1.24      +0 -3      src/sys/netinet6/in6_ifattach.c
  1.11      +0 -1199   src/sys/netinet6/in6_prefix.c (dead)
  1.6       +0 -91     src/sys/netinet6/in6_prefix.h (dead)
  1.30      +0 -1      src/sys/netinet6/in6_proto.c
  1.76      +0 -5      src/sys/netinet6/ip6_input.c
  1.44      +0 -21     src/sys/netinet6/nd6.c

Approved by:	re (scottl)
2004-08-27 04:46:27 +00:00
Alan Cox 3b566faf6a MFC the fix for cross-ipi smp deadlocks. This includes:
Revision  Path
  1.243     amd64/amd64/mp_machdep.c
  1.492     amd64/amd64/pmap.c
  1.236     i386/i386/mp_machdep.c
  1.495     i386/i386/pmap.c
  1.189     kern/subr_smp.c
  1.78      sys/smp.h

Approved by: re (scottl)
2004-08-27 02:50:58 +00:00
Nate Lawson 84720dbdcc MFC rev 1.4: Unlock the sx lock when exiting the sysctl function.
Approved by:	re (scottl)
2004-08-27 00:54:30 +00:00
Julian Elischer 8e2a6e7ee6 MFC of field alignment change and a filed size change.
5.3 seems the last change to get this in before we freeze the ABI
for a while.
 MFC'd from:
>  1.345     +7 -0      src/UPDATING
>  1.6       +1 -6      src/sys/netgraph/bluetooth/include/ng_btsocket.h
>  1.44      +1 -1      src/sys/netgraph/netgraph.h
>  1.24      +5 -3      src/sys/netgraph/ng_message.h

Submitted by:	jdp, emax
Approved by:	re (scottl)
2004-08-26 20:58:46 +00:00
Simon L. B. Nielsen 3d3f509a49 MFC 1.6+1.10:
- Auto generate device listings for the following drivers: ncr, sym,
  umodem, and uscanner.
- asr(4) is currently i386 only.

Approved by:	re (blanket)
2004-08-26 15:05:57 +00:00
Ruslan Ermilov e3cc39760c Fix a standalone module build.
Approved by:	re (scottl)
2004-08-26 14:41:43 +00:00
Dag-Erling Smørgrav b9ce284c1b MFC: (1.52) only translate control message if we're sure it's valid.
Approved by:	re (scottl)
2004-08-26 06:32:23 +00:00
Ken Smith b9842735ab MFC rev 1.60 - Remove sleep command because the underlying problem
with mdconfig should be fixed now.

Approved by:	re (scottl)
2004-08-26 02:28:22 +00:00
Alexander Kabaev f6ecb8c7ca Back out rev. 1.74. A better fix is available and will be MFCed later
once properly tested in -current.

Approved by:	re (scottl, kensmith)
2004-08-26 00:00:18 +00:00
John-Mark Gurney ca0f222e6c MFC: fix LOR in if_sk
v1.86	if_sk.c
v1.22	if_skreg.h

Approved by:	re@ (scottl)
2004-08-25 21:19:06 +00:00
John-Mark Gurney 8478e1329a MFC: adding Belkin F5D5005 gige card, and minor style change
leave the 10k typo since future man page changes should be merged too

v1.8[45] if_sk.c
v1.21	if_skreg.h
v1.22	sk.4

Approved by:	re@ (scottl)
2004-08-25 21:15:38 +00:00
John-Mark Gurney 57a0f89fec MFC: add options to adjust MPROF buffers and hash size
v1.7	MUTEX_PROFILING.9
v1.1262	NOTES
v1.476	options
v1.147	kern_mutex.c

Approved by: re@ (scottl)
2004-08-25 21:05:42 +00:00
Colin Percival 56e1d5b0f4 MFC rev. 1.128: Insert a g_waitidle() call in order to ensure that new
memory disks appear in /dev before mdconfig(8) returns.

Approved by:	re (kensmith)
2004-08-25 20:20:00 +00:00
Alan Cox 4b94139fe7 MT5 i386/i386/uio_machdep.c:1.6 and sparc64/sparc64/uio_machdep.c:1.7:
Properly free the temporary sf_buf in uiomove_fromphys() if a copyin or
  copyout fails.

  Obtained from: DragonFlyBSD

Approved by:	re (kensmith)
2004-08-25 18:49:56 +00:00
Maxime Henrion 0adea32d6e MFC revision 1.35:
Pass a correct lowaddr to bus_dma_tag_create(), lnc(4) cards can only
  deal with 24-bit addresses.  While the two other attachments, namely
  isa and cbus, do it properly, the PCI attachment was passing
  BUS_SPACE_MAXADDR instead of BUS_SPACE_MAXADDR_24BIT.  This bug
  became apparent with the new contigmalloc() code.

  This fixes the problem reported with lnc(4) interfaces inside VMWare,
  and should theoritically also fix any user of a PCI lnc(4) card.  It
  is a RELENG_5 MFC candidate.

Approved by:	re@
2004-08-25 17:30:36 +00:00
Vinod Kashyap bddc00305f Merged from HEAD, twa changes for amd64 support.
Reviewed by:re
Approved by:re
2004-08-25 17:15:26 +00:00
Robert Watson c98b14ff25 MT5 subr_kdb.c:1.6:
date: 2004/08/22 15:10:52;  author: rwatson;  state: Exp;  lines: +1 -0
  Make debug.kdb.stop_cpus also a TUNABLE() so it can be set prior to boot
  to help debug early nasty hangs.

Approved by:	re (scottl)
2004-08-25 03:29:43 +00:00
Robert Watson 2e7e0a541c MT5 rtsock.c:1.113 and rtsock.c:1.114:
date: 2004/08/21 21:45:40;  author: rwatson;  state: Exp;  lines: +3 -1
  If a tunable for the routing socket netisr queue max is defined, allow it
  to override the default value, rather than the default value overriding
  the tunable.

  date: 2004/08/21 21:20:06;  author: rwatson;  state: Exp;  lines: +6 -1
  Allow the size of the routing socket netisr queue to be configured using
  the tunable or sysctl 'net.route.netisr_maxqlen'.  Default the maximum
  depth to 256 rather than IFQ_MAXLEN due to the downsides of dropping
  routing messages.

Approved by:	re (scottl)
2004-08-25 02:50:18 +00:00
Simon L. B. Nielsen 25c1cd280a MFC: 1.228+1.229:
- Move listing of DTC 3290 to aha(4).
- Remove note about device listings going away.
- Add a note about possibility for duplicate listing of devices.
- Auto generate device listings for the following drivers: ncr, sym,
  umodem, and uscanner

Approved by:	re (blanket)
2004-08-24 21:25:54 +00:00
Simon L. B. Nielsen 77ac826188 MFC: Fix hard sentence breaks.
Approved by:	re (jhb)
2004-08-24 20:43:10 +00:00
Simon L. B. Nielsen 6bfb601ea6 MFC: Add a HARDWARE section which lists supported devices.
Approved by:	re (blanket)
2004-08-24 18:24:19 +00:00
Simon L. B. Nielsen 4260b7d878 MFC v. 1.25:
Move listing of DTC 3290 to aha(4).

Approved by:	re (blanket)
2004-08-24 18:07:16 +00:00
Robert Watson 8c287bc943 MT5 if_fwsubr.c:1.6:
date: 2004/08/22 14:48:55;  author: rwatson;  state: Exp;  lines: +0 -2
  Don't need to assert Giant in fw_output(), only in the firewire start
  routine.

Approved by:	re (scottl)
2004-08-24 14:19:33 +00:00
Nate Lawson 48071798f9 MFC rev 1.26: Fix irq programming on resume.
Approved by:	re (kensmith)
2004-08-24 02:27:57 +00:00
Simon L. B. Nielsen a0bfcdf3a5 MFC v. 1.19:
Add a HARDWARE section to the example section 4 manual page.

Approved by:	re (hrs)
2004-08-23 16:06:33 +00:00
Ruslan Ermilov b8fc5ee458 MFC: 1.394: Build Netgraph modules on all architectures.
Approved by:	re (kensmith)
2004-08-23 14:16:15 +00:00
Doug Rabson 94e0e2ab72 MFC: fix static threaded programs.
Approved by: re
2004-08-23 08:17:46 +00:00
David E. O'Brien 2b4977857a Set vendor to a non-fun, but non-controversial one for the release.
Approved by:	re(kensmith)
2004-08-23 07:13:51 +00:00
Warner Losh 8f4099bd65 ifndef PC98 the opt_agp.h files, per extensive discussions with
nyan-san, obrien, rwatson, and scottl.

Approved by: re
2004-08-23 05:23:16 +00:00
Nate Lawson 7ae76fabdd MFC rev 1.38: Disable irqs after pmap_enter().
Approved by:	re (kensmith)
2004-08-23 05:14:18 +00:00
Nate Lawson 69960b5121 MFC rev 1.36,1.37: Add debugging print to rman_manage_region().
Approved by:	re (kensmith)
2004-08-23 05:12:36 +00:00
Nate Lawson 24c3bfd048 MFC rev 1.11: Remove too-strict register offset check.
Approved by:	re (kensmith)
2004-08-23 05:11:05 +00:00
Marcel Moolenaar 66cdc59f0e MFC of alpha boot fixes for binutils 2.15 and gcc-3.4.2.
Revisions:
	alpha/Makefile.inc		1.10
	alpha/common/Makefile.common	1.19
	alpha/common/ldscript		1.1
	ficl/Makefile			1.38

Approved by: re (kensmith)
2004-08-23 04:26:55 +00:00
David E. O'Brien 32258d2705 Enter the great FreeBSD 5.3!
Approved by:	re(kensmith)
2004-08-23 03:28:01 +00:00
Robert Watson 48c6f8857d MT5 in6_pcb.c:1.60:
date: 2004/08/21 17:38:48;  author: rwatson;  state: Exp;  lines: +5 -3
  When notifying protocol components of an event on an in6pcb, use the
  result of the notify() function to decide if we need to unlock the
  in6pcb or not, rather than always unlocking.  Otherwise, we may unlock
  and already unlocked in6pcb.

  Reported by:    kuriyama, Gordon Bergling <gbergling at 0xfce3.net>
  Tested by:      kuriyama, Gordon Bergling <gbergling at 0xfce3.net>
  Discussed with: mdodd

Approved by:	re (kensmith)
2004-08-22 20:07:50 +00:00
Robert Watson 1957b76ac6 MT5 kern_descrip.c:1.244:
date: 2004/08/19 14:59:51;  author: rwatson;  state: Exp;  lines: +0 -2
  Remove GIANT_REQUIRED from setugidsafety() as knote_fdclose() no longer
  requires Giant.

Approved by:	re (kensmith)
2004-08-22 20:06:19 +00:00
Robert Watson 137359b142 MT5 uipc_usrreq.c:1.139:
date: 2004/08/19 01:45:16;  author: rwatson;  state: Exp;  lines: +10 -2
  Add UNP_UNLOCK_ASSERT() to asser that the UNIX domain socket subsystem
  lock is not held.

  Rather than annotating that the lock is released after calls to
  unp_detach() with a comment, annotate with an assertion.

  Assert that the UNIX domain socket subsystem lock is not held when
  unp_externalize() and unp_internalize() are called.

Approved by:	re (kensmith)
2004-08-22 20:04:56 +00:00
Robert Watson 230c15f4dc MT5 udp_usrreq.c:1.163:
date: 2004/08/19 01:13:10;  author: rwatson;  state: Exp;  lines: +35 -25
  Push down pcbinfo and inpcb locking from udp_send() into udp_output().
  This provides greater context for the locking and allows us to avoid
  locking the pcbinfo structure if not binding operations will take
  place (i.e., already bound, connected, and no expliti sendto()
  address).

Approved by:	re (kensmith)
2004-08-22 20:02:54 +00:00
Robert Watson 504a359052 MT5 in_pcb.c:1.154:
date: 2004/08/19 01:11:17;  author: rwatson;  state: Exp;  lines: +1 -1
  In in_pcbrehash(), do assert the inpcb lock as well as the pcbinfo lock.

Approved by:	re (kensmith)
2004-08-22 20:01:01 +00:00
cvs2svn f516b2168e This commit was manufactured by cvs2svn to create branch 'RELENG_5'. 2004-08-22 16:26:10 +00:00
Dag-Erling Smørgrav edab4dc37e MFC: add NO_BOOT knob to disable building the boot blocks and loader.
Approved by:	re (kensmith)
2004-08-22 14:19:53 +00:00
Dag-Erling Smørgrav 0434278e1e MFC: (1.16) quote variables used as command-line arguments.
Approved by:	re (kensmith)
2004-08-22 14:19:03 +00:00
Ken Smith 64441263db MFC v1.17: Back out call to _init_tls() until it can be fixed. This
is currently causing all static executables to fail.

Work done by:	dfr
Approved by:	re (rwatson)
2004-08-21 16:36:21 +00:00
David E. O'Brien e7f3346566 MFC: rev 1.15: turn on the FreeBSD login user capabilities database support.
Approved by:	re(kensmith)
2004-08-21 03:46:39 +00:00
David E. O'Brien 9e40a6a64c MFC: Import of LukeM's ftpd taken from the NetBSD CVS repo on 9-Aug-2004.
Approved by:	re(kensmith)
2004-08-21 03:45:51 +00:00
Ken Smith 7b2806c921 We're ready to begin the BETA1 builds.
Approved by:	re (scottl)
2004-08-20 15:31:44 +00:00
Ken Smith 4e8277362c MFC rev 1.24: temporarily have loader set hw.ata.ata_dma=0 on sparc64
only.  This is a temporary hack needed until kernel support for DMA
buffer alignment support is added.  The newer ATA code expects this
support and it has been added to each arch except for sparc64.  This
commit will be backed out when the support is added.

Approved by:	re (scottl)
2004-08-20 05:33:37 +00:00
Ken Smith 493e51b106 Fix 'make update' to look for RELENG_5 tag.
Submitted by:	eik
Approved by:	re (scottl)
2004-08-20 02:57:07 +00:00
Ken Smith 541e468618 Almost an oops, local mirror hadn't caught up with the last version
of this file yet...

MFC of rev. 1.73 - definitely stop callout.

Work done by:		andre
Noticed my oops:	andre
Approved by:		re
2004-08-20 02:02:05 +00:00
Ken Smith 7e012e7ce2 Last nit to MFC, rev 1.5: fix typo (extra semi-colon).
Work done by:	andre
Approved by:	re
2004-08-20 01:43:50 +00:00
Ken Smith 906ba70bcc MFC balance of ipfw fixes. Revs being MFC-ed:
ip_fw.h rev 1.90
	ip_fw2.c rev 1.71-1.73
	ip_fw_pfil.c rev 1.2-1.3
	ip_input.c rev 1.285
	tcp_subr.c rev 1.202

Work done by:	andre
Approved by:	re
2004-08-20 01:40:42 +00:00
Ken Smith 449c31a012 MFC of v1.1263, Add comment that IPFIREWALL now requires option
PFIL_HOOKS.

Work done by:	andre
Approved by:	re
2004-08-20 00:42:35 +00:00
Ken Smith e9321d3dbd MFC of v1.30 - Note that IPFIREWAll depends on PFIL_HOOKS compiled into
the kernel as well.

Work done by:	andre
Approved by:	re
2004-08-20 00:36:44 +00:00
Ken Smith cc8aee3c73 MFC of v1.343 and v1.344, add note about ipfw to pfil_hooks conversion
and requirement of having that in the kernel to be able to use ipfw.

Work done by:	andre@
Approved by:	re
2004-08-20 00:30:59 +00:00
Scott Long 0972ec5e1f Track RELENG_5
Submitted by: kuriyama
Approved by: re
2004-08-19 23:02:06 +00:00
Nate Lawson db1420c3fa MFC: rev 1.25, Don't bail out on _CRS failure.
Approved by:	re (scottl)
2004-08-19 19:19:40 +00:00
Nate Lawson 0bc877a749 MFC: rev 1.188, Use original order in resuming.
Approved by:	re (scottl)
2004-08-19 19:15:30 +00:00
Nate Lawson 26f8d10781 MFC: rev 1.27, Skip, don't bail out on tables with invalid checksums.
Approved by:	re (scottl)
2004-08-19 19:12:11 +00:00
Nate Lawson cafb646a91 MFC: rev 1.19, Update supported table types.
Approved by:	re (scottl)
2004-08-19 19:10:52 +00:00
Nate Lawson 559a3f8117 MFC: Remove the ACPIIO_ENABLE and ACPIIO_DISABLE ioctls. Includes:
Revision     Path
  1.187        src/sys/dev/acpica/acpi.c
  1.11         src/sys/dev/acpica/acpiio.h
  1.80         src/sys/dev/acpica/acpivar.h
  1.14         src/usr.sbin/acpi/acpiconf/acpiconf.8
  1.16         src/usr.sbin/acpi/acpiconf/acpiconf.c

Approved by:	re (scottl)
2004-08-19 19:08:58 +00:00
Ken Smith 6f218ff374 Prepare for the first 5.3 snapshot builds. There are enough significant
issues re@ feels this warrants being called ALPHA.

Approved by:	re
2004-08-19 18:52:37 +00:00
Poul-Henning Kamp 782b39c1fe MFC: Don't override class provided dumpconf function. 2004-08-19 06:56:50 +00:00
Marcel Moolenaar a4446fcbbf MFC rev 1.4: unbreak the startup code by restoring a clobbered GP.
Approved by: re (blanket)
2004-08-19 05:52:09 +00:00
Scott Long 9a49abc426 MFC: Fix the kernel compile when not using PFIL_HOOKS and IPSEC.
Submitted by: rwatson, peter
Approved by: re
2004-08-18 23:27:42 +00:00
Justin T. Gibbs 66ffd88f6b MFC: Remove ISA attachment's dependency on eisaconf.h and fix iobase
printout in diagnostics during failed ISA probes.

Approved by: re
2004-08-18 22:16:38 +00:00
cvs2svn 55de171837 This commit was manufactured by cvs2svn to create branch 'RELENG_5_3'. 2004-08-18 16:37:07 +00:00
cvs2svn 33b165b331 This commit was manufactured by cvs2svn to create branch 'RELENG_5_3'. 2004-08-18 16:37:06 +00:00
cvs2svn 3c9270175d This commit was manufactured by cvs2svn to create branch 'RELENG_5'. 2004-08-18 16:37:05 +00:00
3535 changed files with 561678 additions and 447290 deletions

No files matched your search

+14 -2
View File
@@ -276,6 +276,10 @@ _worldtmp:
mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
-p ${WORLDTMP}/usr/include >/dev/null
ln -sf ${.CURDIR}/sys ${WORLDTMP}
.if defined(WITH_BIND_LIBS) && !defined(NO_BIND)
mtree -deU -f ${.CURDIR}/etc/mtree/BIND.include.dist \
-p ${WORLDTMP}/usr/include >/dev/null
.endif
_legacy:
@echo
@echo "--------------------------------------------------------------"
@@ -662,7 +666,7 @@ update:
@echo "--------------------------------------------------------------"
@echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
@echo "--------------------------------------------------------------"
cd ${.CURDIR}; ${CVS} -R -q update -A -P -d
cd ${.CURDIR}; ${CVS} -R -q update -rRELENG_5_3 -P -d
.endif
#
@@ -788,7 +792,6 @@ build-tools:
bin/csh \
bin/sh \
${_rescue} \
gnu/usr.bin/cc/cc_tools \
lib/libncurses \
${_share} \
${_aicasm} \
@@ -801,6 +804,7 @@ build-tools:
${MAKE} DIRPRFX=${_tool}/ build-tools
.endfor
.for _tool in \
gnu/usr.bin/cc/cc_tools \
${_kerberos5_tools}
${_+_}@${ECHODIR} "===> ${_tool}"; \
cd ${.CURDIR}/${_tool}; \
@@ -906,6 +910,14 @@ _prebuild_libs+= lib/libcom_err lib/libcrypt lib/libexpat \
lib/libopie__L lib/libtacplus__L: lib/libmd__L
.if !defined(NO_BIND)
.if ${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH} == "sparc64"
_prebuild_libs+= lib/libc_r
.else
_prebuild_libs+= lib/libpthread
.endif
.endif
_generic_libs+= lib
.if !defined(NOCRYPT)
+300 -13
View File
@@ -1,4 +1,4 @@
Updating Information for FreeBSD current users
Updating Information for FreeBSD stable users
This file is maintained and copyrighted by M. Warner Losh
<[email protected]>. See end of file for further details. For commonly
@@ -8,18 +8,305 @@ Items affecting the ports and packages system can be found in
/usr/ports/UPDATING. Please read that file before running
portupgrade. Important recent entries: 20040724 (default X changes).
NOTE TO PEOPLE WHO THINK THAT FreeBSD 5.x IS SLOW:
FreeBSD 5.x has many debugging features turned on, in
both the kernel and userland. These features attempt to detect
incorrect use of system primitives, and encourage loud failure
through extra sanity checking and fail stop semantics. They
also substantially impact system performance. If you want to
do performance measurement, benchmarking, and optimization,
you'll want to turn them off. This includes various WITNESS-
related kernel options, INVARIANTS, malloc debugging flags
in userland, and various verbose features in the kernel. Many
developers choose to disable these features on build machines
to maximize performance.
20060930: p37 FreeBSD-SA-06:22.openssh
Correct multiple vulnerabilities in sshd(8).
20060929: p36 FreeBSD-SA-06:23.openssl
Correct problem in the 2006-09-28 patch concerning the handling of
excessively large DH moduli.
20060928: p35 FreeBSD-SA-06:23.openssl
Correct multiple vulnerabilities in crypto(3).
Limit the size of public keys used in order to protect applications
from a denial of service via insane key sizes.
20060919: p34 FreeBSD-SA-06:21.gzip
Correct multiple vulnerabilities in gzip(1).
20060906: p33 FreeBSD-SA-06:19.openssl, FreeBSD-SA-06:20.bind
Correct incorrect PKCS#1 v1.5 padding validation in
crypto(3). [06:19]
Correct multiple denial-of-service vulnerabilities in BIND related to
SIG Query Processing and Excessive Recursive Queries. [06:20]
20060823: p32 FreeBSD-SA-06:18.ppp
Correct buffer overflow in the handling of LCP options in ppp(4).
20060614: p31 FreeBSD-SA-06:17.sendmail
Correct a bug in the handling of multipart messages by sendmail(8)
which can allow a malformed message to crash a sendmail queue
processing process.
20060531: p30 FreeBSD-SA-06:15.ypserv, FreeBSD-SA-06:16.smbfs
Enable inadvertantly disabled "securenet" access controls in
ypserv. [06:15]
Correct a bug in the handling of backslash characters in smbfs
which can allow an attacker to escape from a chroot(2). [06:16]
20060419: p29 FreeBSD-SA-06:14.fpu
Correct a local information leakage bug affecting AMD FPUs.
20060322: p28 FreeBSD-SA-06:11.ipsec, FreeBSD-SA-06:12.opie,
FreeBSD-SA-06:13.sendmail
Add missing code needed for the detection of IPSec packet
replays. [06:11]
Correctly identify the user running opiepasswd(1) when the login
name differs from the account name. [06:12]
Modify timeout handling logic in sendmail(8) to correct a reported
signal handling race condition. [06:13]
20060301: p27 FreeBSD-SA-06:09.openssh, FreeBSD-SA-06:10.nfs
Correct a remote DoS in OpenSSH when using PAM and privilege
separation. [06:09]
Correct a remote kernel panic when processing zero-length RPC
records via TCP. [06:10]
20060201: p26 FreeBSD-SA-06:08.sack
Avoid an infinite loop in sack scoreboard processing which can
result from memory exhaustion.
20060125: p25 FreeBSD-SA-06:07.pf
Correct an error in pf handling of IP packet fragments which
could result in a kernel panic. [06:07]
20060111: p24 FreeBSD-SA-06:01.texindex, FreeBSD-SA-06:02.ee,
FreeBSD-SA-06:03.cpio
Correct insecure temporary file usage in texindex. [06:01]
Correct insecure temporary file usage in ee. [06:02]
Correct a race condition when setting file permissions,
sanitize file names by default, and fix a buffer overflow
when handling files larger than 4GB in cpio. [06:03]
20051011: p23 FreeBSD-SA-05:21.openssl
Correct a man-in-the-middle SSL version rollback vulnerability.
20050909: p22 FreeBSD-SA-05:20.cvsbug [revised]
Correct additional temporary file usage issues.
20050907: p21 FreeBSD-SA-05:20.cvsbug
Correct insecure temporary file usage.
20050727: p20 FreeBSD-SA-05:18.zlib, FreeBSD-SA-05:19.ipsec
Correct buffer overflow when handling certain deflated data
streams.
Correct errors in the implementation of the AES-XCBC-MAC IPsec
authentication algorithm.
20050720: p19 FreeBSD-SA-05:17.devfs
Correct devfs ruleset bypass.
20050706: p18 FreeBSD-SA-05:16.zlib
Correct buffer overflow when handling corrupt deflated data streams.
20050629: p17 FreeBSD-SA-05:14.bzip2, FreeBSD-SA-05:15.tcp
Correct bzip2 denial of service and permission race vulnerabilities.
Correct TCP connection stall denial of service vulnerabilities.
20050608: p16 FreeBSD-SA-05:10.tcpdump, FreeBSD-SA-05:11.gzip,
FreeBSD-SA-05:12.bind9
Correct several denial-of-service vulnerabilities in tcpdump.
Correct directory traversal and race condition vulnerabilities in gzip.
Correct BIND 9 DNSSEC remote denial of service vulnerability.
20050513: p15 FreeBSD-SA-05:09.htt
Add a knob for disabling/enabling HTT. Default off due to information
disclosure on multi-user systems.
20050508: p14 FreeBSD-SA-05:08.kmem
Correct two issues which were missed from the earlier commit.
20050506: p13 FreeBSD-SA-05:08.kmem
Correct several local kernel memory disclosure bugs.
20050506: p12 FreeBSD-SA-05:07.ldt
Correctly validate inputs to the i386_get_ldt syscall.
20050506: p11 FreeBSD-SA-05:06.iir
Correct overly liberal permissions on /dev/iir.
20050422: p10 FreeBSD-SA-05:05.cvs
Correct several vulnerabilities in CVS.
20050414: p9 FreeBSD-SA-05:04.ifconf
Zero a buffer in ifconf() in order to avoid accidental
disclosure of kernel memory to userland.
20050406: p8 FreeBSD-SA-05:03.amd64
Correctly initialize the I/O permission bitmap on amd64.
20050404: p7 FreeBSD-SA-05:02.sendfile
Correct kernel memory disclosure bug in sendfile(2).
20050328: p6 FreeBSD-SA-05:01.telnet
Correct buffer overflows in telnet(1).
20050114: p5 FreeBSD-EN-05:03.ipi
Avoid more than two pending IPI interrupt vectors per local
APIC as this may cause deadlocks.
20050106: p4 FreeBSD-EN-05:02.sk
Correct bugs in the sk(4) network driver that could result in
data corruption and system crashes on SMP systems.
20050103: p3 FreeBSD-EN-05:01.nfs
Correct a bug in nfsrv_create() where a call to nfsrv_access()
might be made while holding the NFS server mutex, which resulted
in kernel panics under certain load patterns.
20041201: p2 FreeBSD-SA-04:17.procfs
Fix a tainted pointer dereference in procfs(5) and linprocfs(5)
which could allow a local attacker to panic a system and/or read
from kernel memory.
20041118: p1 FreeBSD-SA-04:16.fetch
Correct a buffer overflow in fetch(1) which could allow a
mallicious server to execute arbitrary code on the client.
20041104:
FreeBSD 5.3-RELEASE
20041010:
The FreeBSD keyword is no longer a requirement for a valid
rc.d script. The rc(8) and rc.shutdown(8) scripts no longer check
for the existence of this keyword when ordering rc.d scripts.
This change touches most of the file in /etc/rc.d; therefore,
if you have not modified any files in that directory it may
be easier to rm -rf /etc/rc.d and then use the -i switch with
mergemaster(8).
20041009:
One of the syscalls the 1:1 threading library libthr uses has
changed, thus breaking ABI compatibility. Make sure you rebuild
this library with the kernel.
20041003:
The pfil API has gained an additional argument to pass an inpcb.
You should rebuild all pfil consuming modules: ipfw, ipfilter
and pf.
20041001:
The following libraries had their version number bumped up:
/lib/libm.so.2 -> libm.so.3
/lib/libreadline.so.4 -> libreadline.so.5
/usr/lib/libhistory.so.4 -> libhistory.so.5
/usr/lib/libopie.so.2 -> libopie.so.3
/usr/lib/libpcap.so.2 -> libpcap.so.3
FreeBSD 4.10 versions of these libraries will be added to the
compat4x collection. If you expect to be able to run old 4.X
executables you will need to remove the old versions of these
libraries. However note that any 5.X executables you have built
will stop working once you remove those old libraries. You should
have all your ports/packages rebuilt before removing the old
libraries.
20040928:
If enabled, the default is now to run named in a chroot
"sandbox." For users with existing configurations in
/etc/namedb the migration should be simple. Upgrade your
world as usual, then after installworld but before
mergemaster do the following:
If named is running: /etc/rc.d/named stop
cd /etc
mv namedb namedb.bak
mkdir -p /var/named/etc/namedb
cp -Rp namedb.bak/* /var/named/etc/namedb/
mergemaster (with your usual options)
If using the generated localhost* files:
cd /var/named/etc/namedb
/bin/sh make-localhost
rm -f localhost-v6.rev localhost.rev
/etc/rc.d/syslogd restart
/etc/rc.d/named start
If you are using a custom configuration, or if you have
customised the named_* variables in /etc/rc.conf[.local]
then you may have to adjust the instructions accordingly.
It is suggested that you carefully examine the new named
variables in /etc/defaults/rc.conf and the options in
/var/named/etc/namedb/named.conf to see if they might
now be more suitable.
20040925:
BIND 9 has been imported into the base, and is now fully
functional. BIND 8 has now been removed. There are numerous
differences between BIND 8 and 9, and users with critical
named installations should read the migration documentation
in /usr/share/doc/bind9/misc/migration. There is also a
new instruction manual in /usr/share/doc/bind9/arm.
The key differences that most users will experience are in
how picky BIND 9 is about zone file format. If you are using
named as a resolving (caching) name server, you will likely
not have trouble.
The following files are part of the old BIND 8 installation
and should be removed:
/usr/bin/dnskeygen /usr/bin/dnsquery /usr/libexec/named-xfer
/usr/sbin/named.restart /usr/sbin/ndc
The following files have moved to /usr/bin, and should be
removed from their old locations:
/usr/sbin/nslookup /usr/sbin/nsupdate
20040922:
PFIL_HOOKS are a fixed part of the network stack now and do not
need to be specified in the kernel configuration file anymore.
Remove 'options PFIL_HOOKS' from your kernel config file.
20040914:
The format of the pflogd(8) logfile "/var/log/pflog" has changed for
architectures that have a 64 bit long type to make it compatible to
the standard pcap format. In order to prevent corruption move away
any old logfile before using a new pflogd(8).
20040913:
debug.witness_* has been renamed to debug.witness.*. There are
compatibility tunables left in for a few days. Update loader.conf
as necessary.
20040907:
The kernel and userland debugging options have been turned off
by default.
20040902:
The default configuration for the network stack has been changed
such that it now runs without the Giant lock unless configured
otherwise. If you experience network-related instability, you
may wish to try setting "debug.mpsafenet=0" or compiling the
kernel with "options NET_WITH_GIANT". Details on the netperf
project may be found at:
http://www.watson.org/~robert/freebsd/netperf/
Including the 20040828 announcement of configuration change
details.
20040826:
Netgraph changed its message format slightly to align the data
portion well on 64 bit machines.
Netgraph using utilities (e.g. ngctl, nghook, ppp, mpd,
pppoed, bluetooth, ATM) should be recompiled when a new kernel
is installed.
20040817:
IPFW has been converted to use PFIL_HOOKS. This change is
transparent to userland and preserves the ipfw ABI. The ipfw
core packet inspection and filtering functions have not been
changed, only how ipfw is invoked is different. Note that
"option PFIL_HOOKS" is required to use IPFIREWALL compiled
into the kernel or as KLD.
20040814:
The RANDOM_IP_ID option has been replaced by the sysctl
-166
View File
@@ -1,166 +0,0 @@
/* config.h. Generated by configure. */
/*
* config.h -- configure various defines for tcsh
*
* All source files should #include this FIRST.
*
* Edit this to match your system type.
*/
/* $FreeBSD$ */
#ifndef _h_config
#define _h_config
/****************** System dependant compilation flags ****************/
/*
* POSIX This system supports IEEE Std 1003.1-1988 (POSIX).
*/
#define POSIX
/*
* POSIXJOBS This system supports the optional IEEE Std 1003.1-1988 (POSIX)
* job control facilities.
*/
#define POSIXJOBS
/*
* POSIXSIGS Use the POSIX signal facilities to emulate BSD signals.
*/
/* #undef POSIXSIGS */
/*
* VFORK This machine has a vfork().
* It used to be that for job control to work, this define
* was mandatory. This is not the case any more.
* If you think you still need it, but you don't have vfork,
* define this anyway and then do #define vfork fork.
* I do this anyway on a Sun because of yellow pages brain damage,
* [should not be needed under 4.1]
* and on the iris4d cause SGI's fork is sufficiently "virtual"
* that vfork isn't necessary. (Besides, SGI's vfork is weird).
* Note that some machines eg. rs6000 have a vfork, but not
* with the berkeley semantics, so we cannot use it there either.
*/
#define VFORK
/*
* BSDJOBS You have BSD-style job control (both process groups and
* a tty that deals correctly
*/
#define BSDJOBS
/*
* BSDSIGS You have 4.2-style signals, rather than USG style.
* Note: POSIX systems should not define this unless they
* have sigvec() and friends (ie: 4.3BSD-RENO, HP-UX).
*/
#define BSDSIGS
/*
* BSDTIMES You have BSD-style process time stuff (like rusage)
* This may or may not be true. For example, Apple Unix
* (OREO) has BSDJOBS and BSDSIGS but not BSDTIMES.
*/
#define BSDTIMES
/*
* BSDLIMIT You have BSD-style resource limit stuff (getrlimit/setrlimit)
*/
#define BSDLIMIT
/*
* BSDNICE Your system uses setpriority() instead of nice, to
* change a processes scheduling priority
*/
#define BSDNICE
/*
* TERMIO You have struct termio instead of struct sgttyb.
* This is usually the case for SYSV systems, where
* BSD uses sgttyb. POSIX systems should define this
* anyway, even though they use struct termios.
*/
#define TERMIO
/*
* SYSVREL Your machine is SYSV based (HPUX, A/UX)
* NOTE: don't do this if you are on a Pyramid -- tcsh is
* built in a BSD universe.
* Set SYSVREL to 1, 2, 3, or 4, depending the version of System V
* you are running. Or set it to 0 if you are not SYSV based
*/
#define SYSVREL 0
/*
* YPBUGS Work around Sun YP bugs that cause expansion of ~username
* to send command output to /dev/null
*/
/* #undef YPBUGS */
/*
* SIGVOID Define this if your signal handlers return void. On older
* systems, signal returns int, but on newer ones, it returns void.
*/
#define SIGVOID
/*
* HAVEDUP2 Define this if your system supports dup2().
*/
#define HAVEDUP2
/*
* UTHOST Does the utmp file have a host field?
*/
#define UTHOST
/*
* DIRENT Your system has <dirent.h> instead of <sys/dir.h>
*/
#define DIRENT
/****************** local defines *********************/
/****************** configurable hacks ****************/
#include <stdlib.h>
/* have been moved to config_f.h */
#include "config_f.h"
#if defined(__FreeBSD__)
#define NLS_BUGS
/* we want to use the system malloc when we install as /bin/csh */
#define SYSMALLOC
#define BSD_STYLE_COLORLS
#endif
#if defined(__NetBSD__)
#include <sys/param.h>
#if __NetBSD_Version__ >= 106030000 /* NetBSD 1.6C */
#define HAVEUTMPX
#endif
#endif
#if defined(__bsdi__)
/*
* _PATH_TCSHELL if you've change the installation location (vix)
*/
#include <sys/param.h>
# ifdef _BSDI_VERSION >= 199701
# define _PATH_TCSHELL "/bin/tcsh"
/* # undef SYSMALLOC */
# define SYSMALLOC
# else
# define _PATH_TCSHELL "/usr/contrib/bin/tcsh"
# endif
/* # undef NLS */
/* # undef NLS_CATALOGS */
#elif defined(__APPLE__)
# define SYSMALLOC
#else
# define NLS_CATALOGS
#endif
#endif /* _h_config */
/* config.h.in. Generated automatically from configure.in by autoheader. */
+1 -1
View File
@@ -701,7 +701,7 @@ unsetfunc(char *name)
delete_cmd_entry();
return (0);
}
return (1);
return (0);
}
/*
+1 -1
View File
@@ -761,7 +761,7 @@ unsetvar(char *s)
}
}
return (1);
return (0);
}
-6
View File
@@ -1,6 +0,0 @@
# $FreeBSD$
PROG= uuidgen
WARNS?= 6
.include <bsd.prog.mk>
-79
View File
@@ -1,79 +0,0 @@
.\" Copyright (c) 2002 Marcel Moolenaar
.\" 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.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
.\"
.\" $FreeBSD$
.\"
.Dd May 23, 2002
.Dt UUIDGEN 1
.Os
.Sh NAME
.Nm uuidgen
.Nd generate universally unique identifiers
.Sh SYNOPSIS
.Nm
.Op Fl 1
.Op Fl n Ar count
.Op Fl o Ar filename
.Sh DESCRIPTION
The
.Nm
utility by default generates a single universally unique identifier (UUID),
also known as a globally unique identifier (GUID).
The UUID is written to stdout by default.
The following options can be used to change the behaviour of
.Nm :
.Bl -tag -width indent
.It Fl 1
This option only has effect if multiple identifiers are to be generated and
instructs
.Nm
to not generate them in batch, but one at a time.
.It Fl n
This option controls the number of identifiers generated.
By default, multiple
identifiers are generated in batch.
.It Fl o
Redirect output to
.Ar filename
instead of stdout.
.El
.Pp
Batched generation yields a dense set of identifiers in such a way that there
is no identifier that is larger than the smallest identifier in the set and
smaller than the largest identifier in the set and that is not already in the
set.
.Pp
When generating the identifiers one at a time, the identifiers will be close
to each other, but operating system latency and processing time will be
reflected in the distance between two successive identifiers.
.Sh DIAGNOSTICS
.Ex -std
.Sh SEE ALSO
.Xr uuidgen 2 ,
.Xr uuid 3
.Sh HISTORY
The
.Nm
command first appeared in
.Fx 5.0 .
-113
View File
@@ -1,113 +0,0 @@
/*
* Copyright (c) 2002 Marcel Moolenaar
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <uuid.h>
static void
usage(void)
{
(void)fprintf(stderr, "usage: uuidgen [-1] [-n count] [-o filename]\n");
exit(1);
}
int
main(int argc, char *argv[])
{
FILE *fp;
uuid_t *store, *uuid;
char *p;
int ch, count, i, iterate;
count = -1; /* no count yet */
fp = stdout; /* default output file */
iterate = 0; /* not one at a time */
while ((ch = getopt(argc, argv, "1n:o:")) != -1)
switch (ch) {
case '1':
iterate = 1;
break;
case 'n':
if (count > 0)
usage();
count = strtol(optarg, &p, 10);
if (*p != 0 || count < 1)
usage();
break;
case 'o':
if (fp != stdout)
errx(1, "multiple output files not allowed");
fp = fopen(optarg, "w");
if (fp == NULL)
err(1, "fopen");
break;
default:
usage();
}
argv += optind;
argc -= optind;
if (argc)
usage();
if (count == -1)
count = 1;
store = (uuid_t*)malloc(sizeof(uuid_t) * count);
if (store == NULL)
err(1, "malloc()");
if (!iterate) {
/* Get them all in a single batch */
if (uuidgen(store, count) != 0)
err(1, "uuidgen()");
} else {
uuid = store;
for (i = 0; i < count; i++) {
if (uuidgen(uuid++, 1) != 0)
err(1, "uuidgen()");
}
}
uuid = store;
while (count--) {
uuid_to_string(uuid++, &p, NULL);
fprintf(fp, "%s\n", p);
free(p);
}
free(store);
if (fp != stdout)
fclose(fp);
return (0);
}
-4157
View File
File diff suppressed because it is too large. Load diff
-39
View File
@@ -1,39 +0,0 @@
$Id: DNSSEC,v 8.2 1999/10/12 18:23:27 ogud Exp $
DNSSEC Notes:
This file contains description of two interoperabilty problems related
to DNSSEC that only affect sites using DNSSEC.
1. All versions of bind-8 older than 8.2.2
Between versions 8.2.1 and 8.2.2 the printed format of SIG records
changed. As a result, using a signer, named and named-xfer of
differrent versions will cause parsing errors on signed zonefiles.
Included is an AWK program that converts old signed zone files to new
new format, see contrib/dns_signer/add_labels.awk
Usage: awk -f <path>/contrib/dns_signer/add_labels.awk <signed_zone >fixed_zone
2. BIND-8.1 BIND-8.1.1 BIND-8.1.2 Interoperability
If you wish to use BIND-8.1.x as a master server (either primary or
secondary) for DNSSEC signed zone you MUST apply the following patch
to the file src/bin/named/db_load.c. It fixes a bug that rejects
valid RSA signatures on load.
You can patch the file by running following command from this directory
patch -d bin/named <DNSSEC
--- db_load.c.old Mon Oct 11 15:21:24 1999
+++ db_load.c Mon Oct 11 15:21:38 1999
@@ -1123,9 +1123,6 @@
ERRTO("Signature too short");
if (siglen > (NS_MD5RSA_MAX_BITS + 7) / 8)
ERRTO("Signature too long");
- /* We rely on cp from parse */
- if (*cp == 0)
- ERRTO("Signature starts with zeroes");
break;
case NS_ALG_EXPIRE_ONLY:
-24
View File
@@ -1,24 +0,0 @@
$FreeBSD$
1. Create clean import directory.
2. Un-tar bind-{src|doc}.tar.gz.
3. rm Makefile; mv doc src/
(Don't un-tar doc in src, you'll spam the real Makefile.)
4. while read pattern; do rm -r src/${pattern} ; done < FREEBSD-Xlist
5. find . -name .cvsignore -delete
6. chmod 644 src/LICENSE
7. Create another clean directory.
8. cvs export -rHEAD src/contrib/bind
9. diff -ur the two directories and look for 'Only in' to see if
there are any new files, or anything gone missing.
10. Once you're satisfied, do the import. Replace version strings appropriately:
cvs import -m"Import of ISC BIND version 8.3.3" src/contrib/bind ISC v8_3_3
11. Resolve conflicts as needed.
cvs checkout -jISC:yesterday -jISC src/contrib/bind
Note: bin/nslookup/commands.l needs a different patch for the command line
editing customization in -current and RELENG_4.
-42
View File
@@ -1,42 +0,0 @@
$FreeBSD$
.cvsignore
LICENSE_RSA
OLD*
bin/named/ns_parser.[ch]
bin/nslookup/commands.c
conf*
doc/bog
doc/notes
doc/old
doc/rfc
doc/tmac
doc/*/*.[lp]s[ft][0-9]
doc/misc/*.ps
lib/bsd*
lib/cylink*
lib/dnssafe*
port/aix32*
port/aix4*
port/aux3*
port/bsdos*
port/cygwin*
port/darwin*
port/decunix*
port/hpux*
port/irix*
port/linux*
port/lynxos*
port/mpe*
port/netbsd*
port/next*
port/openbsd*
port/qnx*
port/rhapsody*
port/sco*
port/solaris*
port/sunos*
port/ultrix*
port/unixware20*
port/unixware212*
port/unixware7*
port/winnt*
-340
View File
@@ -1,340 +0,0 @@
Systems it is known to compile and run on:
BSD/OS 3.1, 4.0.1
FreeBSD 3.3, 3.4
RH Linux 5.2 (don't use "make links" when building, though)
Debian GNU/Linux 2.2.9 ("unreleased")
Digital UNIX 3.2C, 4.0, 5.0
NetBSD/i386 1.3.2, 1.4
Darwin 1.x (Mac OS X)
SunOS 5.6 (Solaris 2.6), SunOS 5.7 (Solaris 7)
SCO UnixWare 7.0, 7.0.1, 7.1
IRIX 6.5
Systems it has been known in the past to compile and run on:
AIX 4.x
A/UX 3.1.1
Digital ULTRIX 4.5 (without Compaq's Y2K kit installed)
HP MPE
HP-UX 9.x, 10.20
IRIX 5.3, 6.2, 6.4
LynxOS
FreeBSD 3.1, 3.2
NetBSD 1.2, 1.3
OpenBSD 2.1
QNX
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)
See port/README for information on porting BIND 8 to other systems.
Building
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.
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.
If you want to build outside the source pool, then
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
NOTE: "make depend" is a NO-OP for some platforms, but always harmless.
Finally,
make all
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. (for non-root installs;
not equivalent to autoconf's --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
DESTMAN man file location
DESTETC configuration file
DESTRUN PID file location and "ndc" control
channel location. This cannot be the
same directory as DESTSBIN.
These variables should be specified in the Makefile.set for your
port (e.g. if you use Solaris, in src/port/solaris/Makefile.set).
Before doing 'make install', 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
AIX
Build problems have been reported with the AIX "make".
We recommend using GNU "make" instead.
AIX4 with Linux Compatibility API
May need to define HAVE_STRNDUP in
port/aix4/include/port_after.h.
FreeBSD, NetBSD, OpenBSD and BSDI
The kit should compile even if you have intalled the KAME
IPv6 kit.
HPUX
If you are using gcc you may have to remove the '-ansi'
flag. This is gcc version dependent.
HPUX 10.20 early versions of the HP C/ANSI C compiler do
not work, version B.10.20.15 in known to work.
IRIX
build problems have been reported w/ IRIX 6.3, res_debug.c
and #include <stdlib.h>. You may need to comment out
the #include <stdlib.h> and declare
"void *malloc(size_t size)" to get named to compile on 6.3.
Linux
"make links" and "make stdlinks" cause problems on
some Linux kernels because there are too many levels of
symbolic links.
QNX
Read src/port/qnx/README before trying to build.
SCO 5.0.x
To build using gcc, copy "port/sco50/Makefile.set.gcc" to
"port/sco50/Makefile.set". To go back to using SCO's
compilers, copy "port/sco50/Makefile.set.sco" to
"port/sco50/Makefile.set".
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 to
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.
SunOS 4.1.4
An ANSI/ISO C compiler is required; we used gcc 2.7.2.1.
NeXT
Read src/port/next/README.FIRST before trying to build.
MPE/iX IPv6 is *not* supported. src/port/mpe/recvfrom.c needs to
be re-written to support IPv6 if and when the OS supports
IPv6.
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".
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 using
bin/named-bootconf/named-bootconf.
e.g.
named-bootconf < /etc/named.boot > /etc/named.conf
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
[email protected]
-22
View File
@@ -1,22 +0,0 @@
## Copyright (c) 1993-2000 by Internet Software Consortium, Inc.
##
## 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.
Internet Software Consortium
950 Charter Street
Redwood City, CA 94063
Tel: 1-888-868-1001 (toll free in U.S.)
Tel: 1-650-779-7091
Fax: 1-650-779-7055
Email: <[email protected]>
-68
View File
@@ -1,68 +0,0 @@
## Copyright (c) 1996,1999 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.52 2000/11/21 12:54:37 marka Exp $
TOP=
SUBDIRS= include port lib bin
SH=sh
default: all
all clean depend install distclean:: FRC
@set -e; \
version=`cat ${TOP}Version`; \
systype=`${SH} ${TOP}port/systype ${TOP}.systype`; \
if [ $$systype = "unknown" ]; then \
echo "There is no BIND port for this system in this kit."; \
else \
settings=`${SH} ${TOP}port/settings ${TOP}.settings \
< ${TOP}port/$$systype/Makefile.set`; \
PATH=`pwd`/port/$$systype/bin:$$PATH; export PATH; \
for x in ${SUBDIRS}; do \
( cd $$x; pwd; \
eval "${MAKE} $$settings ${MARGS} SYSTYPE=$$systype \
VER=$$version \
$@"; \
) || exit 1; \
done \
fi
clean distclean::
rm -f .systype .settings
links: FRC
@set -e; mkdir ${DST}; cd ${DST}; pwd; ln -s ${SRC} SRC; \
ln -s SRC/Version .; cp SRC/Makefile .; chmod +w Makefile; \
systype=`${SH} SRC/port/systype`; \
for x in ${SUBDIRS} ; do \
( mkdir $$x; cd $$x; pwd; ln -s ../SRC/$$x SRC; \
cp SRC/Makefile Makefile; chmod +w Makefile; \
${MAKE} ${MARGS} SYSTYPE=$$systype links; \
) || exit 1; \
done
stdlinks: FRC
if [ ! -d /var/obj ]; then \
mkdir /var/obj; \
fi
${MAKE} ${MARGS} SRC=`pwd` DST=/var/obj/bind links
uplinks: FRC
@set -e; systype=`${SH} ${TOP}port/systype`; pwd=`pwd`; \
${MAKE} ${MARGS} SRC=../`basename $$pwd` "DST=../$$systype" links
FRC:
-259
View File
@@ -1,259 +0,0 @@
This is the source portion of BIND version 8. Its companions are "doc" and
"contrib" so you are probably not missing anything.
See the CHANGES file for a detailed listing of all changes. See the INSTALL
file for information on building and installing BIND.
See the SUPPORT file for information on obtaining commercial support for ISC
artifacts including BIND, INN, and DHCP.
Note that BIND 8 is in "end-of-life", having been replaced by BIND 9. See
http://www.isc.org/ for more details.
BIND 8.3.7 Highlights
Security release.
BIND 8.3.6 Highlights
Maintenance release.
BIND 8.3.5 Highlights
Maintenance release.
BIND 8.3.4 Highlights
Security Fix DoS and buffer overrun.
BIND 8.3.3 Highlights
Security Fix libbind. All applications linked against libbind
need to relinked.
'rndc restart' now preserves named's arguements
BIND 8.3.2 Highlights
dig, nslookup, host and nsupdate have improved IPv6 support.
BIND 8.3.1 Highlights
Critical bug fix to prevent DNS storms. If you have BIND 8.3.0 you
need to upgrade.
BIND 8.3.0 Highlights
IPv6 transport support in resolver (from KAME).
Opaque rdata support.
EDNS0 support.
Glue ordering to help non-ENDS0 aware clients (servers) cope with
larger responses as a result of IPv6 by allowing A records to be added
first to the additional section. IPv6 capable clients are expected to
use EDNS0 to allow larger responses to be sent.
Bug Fixes, includes BIND 8.2.5 changes.
BIND 8.2.4 Highlights
NSAP processing was not RFC 1706 compliant. NOTE: OLD MASTER FILES
NEED TO BE CORRECTED AND CACHE FILES REMOVED.
Fixes long-standing protocol incompatibility in DNSSEC support.
Avoids fwd'ing to root name servers if response will be rejected.
new port/cygwin contributed by [email protected].
new contrib/mdnkit (V1.3) from author.
new contrib/adm from official ftp site.
new contrib/host from author.
new contrib/dnsp from author.
fixed file descriptor leak in resolver.
fixed a major memory leak in the processing of dynamic updates.
numerous portability improvements.
numerous bug fixes.
BIND 8.2.3 Highlights
Improved support for Windows NT and Windows 2000.
Host stats are no longer required to track the source of a record.
IXFR improvements.
Forwarders track and use RTT to select fastest.
Unix domain sockets implementions that require the directory
to be secure, are now secured.
Many minor problems fixed.
Linux DoS removed.
BIND 8.2.2 patchlevel 5 Highlights
Bug in named-xfer (from patchlevel 4).
Portability to IPv6 versions of FreeBSD, OpenBSD, NetBSD.
Portability improvements (A/UX, AIX, IRIX, NetBSD, SCO, MPE/IX, NT).
"also-notify" option could cause memory allocation errors.
IXFR improvements (though client-side is still disabled).
Contributed software upgraded (including TIS's "dns_signer").
Several latent denial-of-service bugs fixed (from audits, not abuse).
New "make noesw" top-level target for removing encumbered components.
BIND 8.2.2 Highlights
Interoperability with MS-Win2K has been improved.
Server-side IXFR is now known to work even under high load.
Support for Windows/NT (thanks to BayNetworks).
More fixes, especially to DNSSEC, TSIG, IXFR, and selective forwarding.
More portability improvements and lint removal (A/UX 3.1.1, SCO 5.0).
Better NOTIFY behaviour, especially with large update volume.
Better UPDATE handling, including SRV RR support and RFC compliance.
Fix for "ndc reload ZONENAME" (specific zone reload) problems.
Fix for round robin when multiple CNAMEs are in use.
New "min-roots" (MINROOTS) and "serial-queries" (MAXQSERIAL) options.
Log files are no longer auto-rotated every time the server starts up.
New "ndc reconfig" command only finds new/deleted zones, no stat()ing.
New global options for "transfer-source" and "also-notify".
$GENERATE now supports more record types, and options.
BIND 8.2.1 Highlights
Bug fixes, especially to DNSSEC, TSIG, IXFR, and selective forwarding.
Portability improvements and lint removal.
Use best SOA rather than first-better when selecting an AXFR master.
$TTL now accepts symbolic time values (such as "$TTL 1h30m").
"ndc reload" now accepts a zone argument, for single-zone reloads.
ndc is better behaved; is verbose or quiet when appropriate.
event and error reporting improvements.
BIND 8.2 Highlights
RFC 2308 (Negative Caching)
RFC 2181 (DNS Clarifications)
RFC 2065 (DNS Security)
TSIG (Transaction SIGnatures)
support for multiple virtual name servers
NDC uses a "control channel" now (no more signals)
"Split DNS" via zone type "forward".
Many bug fixes
Documentation improvements
Performance enhancements
BIND 8.1.2 Highlights
Security fixes for a number of problems including:
An attacker could overwrite the stack if inverse query support
was enabled.
A number of denial of service attacks where malformed packets
could cause the server to crash.
The server was willing to answer queries on its forwarding
sockets.
Several memory leaks have been plugged.
The server no longer panics if a periodic interface scan fails due
to no file descriptors being available.
Updates to a number of ports. New ports for QNX, LynxOS, HP-UX 9.x,
and HP MPE.
"files unlimited" now works as expected on systems where setting
an infinite rlim_max for RLIMIT_NOFILE works.
Adding and deleting the same record in the same dynamic update no
longer crashes the server.
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
Kits, Questions, Comments, and Bug Reports
<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
<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
<URL:mailto:[email protected]> gw'd to u:c.p.d.bind
<URL:mailto:[email protected]> gw'd to u:c.p.d.std
<URL:mailto:[email protected]> code warriors only please
<URL:http://www.isc.org/bind.html> the BIND home page
<URL:mailto:[email protected]> bug reports
To Support the Effort
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.
The Internet Software Consortium has also commissioned a DHCP server
implementation, has taken over official support/release of the INN
system, and has supported 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/>.
-9
View File
@@ -1,9 +0,0 @@
The Internet Software Consortium offers, through certified providers, support,
training, and consulting for BIND and DHCP. These programs are documented on
our web page at:
http://www.isc.org/support.html
Discussion about programs to meet your needs is welcome at [email protected].
Please forward your questions there or call us at +1 650 779-7018 to speak
with the Director of Client Services.
-27
View File
@@ -1,27 +0,0 @@
These are not in priority order.
-> "make" should work in any subdirectory as it does in the top level.
-> "make distclean" should remove .depend files, "make clean" shouldn't.
-> NT port
-> DNS Security (RFC 2065)
-> IXFR
-> Enhanced forwarding
-> Command protocol
-> IPv6 transport
-> named-xfer elimination
-> asynchronous resolver
-> new database -- DB 2.0?
-> move man pages from doc/man/* into src/.
-> fix dynamic DNS delegation loss problem
-1
View File
@@ -1 +0,0 @@
8.3.7-REL
-94
View File
@@ -1,94 +0,0 @@
## Copyright (c) 1996,1999 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 2001/08/14 05:57:57 marka Exp $
DESTDIR=
CC= cc
SHELL= /bin/sh
CDEBUG= -g -Wall
#(net2 and its descendents)
SYSTYPE = freebsd
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
DESTBIN = /usr/local/bin
DESTSBIN = /usr/local/sbin
DESTEXEC = /usr/local/libexec
DESTMAN = /usr/share/man
DESTHELP= /usr/share/misc
AR= ar cru
INSTALL_EXEC=
INSTALL_LIB=-o bin -g bin
LDFLAGS=
MARGS = "SYSTYPE=${SYSTYPE}" "SHELL=${SHELL}" "A=${A}" "O=${O}" \
"CC=${CC}" "LEX=${LEX}" "YACC=${YACC}" "CDEBUG=${CDEBUG}" \
"SYSLIBS=${SYSLIBS}" "LDFLAGS=${LDFLAGS}" \
"DESTDIR=${DESTDIR}" "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}" "EXE=${EXE}" \
"LIBBIND=../${LIBBIND}" "LIBPORT=../${LIBPORT}" \
"INSTALL=${INSTALL}" "TOP=../${TOP}" \
"VER=${VER}" "STRIP=${STRIP}" "PS=${PS}" "INSTALL_LIB=${INSTALL_LIB}" \
"INSTALL_EXEC=${INSTALL_EXEC}" "BOUNDS=${BOUNDS}"
CFLAGS= ${CDEBUG}
CPPFLAGS= -I${PORTINCL} -I${INCL}
SUBDIRS = addr nslookup dig dnsquery host named named-xfer ndc nsupdate \
mkservdb irpd dnskeygen named-bootconf
all:
@for x in ${SUBDIRS}; do \
(cd $$x; pwd; ${MAKE} ${MARGS} $@) || exit 1; \
done
install depend tags clean distclean::
@for x in ${SUBDIRS}; do \
(cd $$x; pwd; ${MAKE} ${MARGS} $@) || exit 1; \
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; \
) || exit 1; \
done
FRC:
# DO NOT DELETE THIS LINE -- mkdep uses it.
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
-85
View File
@@ -1,85 +0,0 @@
## Copyright (c) 1996,1999 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.27 2000/12/23 08:02:49 vixie Exp $
DESTDIR=
CC= cc
SHELL= /bin/sh
CDEBUG= -g -Wall
#(net2 and its descendents)
SYSTYPE = freebsd
TOP = ../..
INCL = ${TOP}/include
PORTINCL = ${TOP}/port/${SYSTYPE}/include
LIBBIND = ${TOP}/lib/libbind.a
A=a
O=o
EXE=
LEX = lex -I
SYSLIBS = -ll -lutil
DESTBIN = /usr/local/bin
DESTSBIN = /usr/local/sbin
DESTEXEC = /usr/local/libexec
DESTMAN = /usr/share/man
DESTHELP= /usr/share/misc
STRIP=-s
INSTALL_EXEC=
INSTALL_LIB=-o bin -g bin
LDFLAGS=
CFLAGS= ${CDEBUG}
CPPFLAGS= -I${PORTINCL} -I${INCL}
PROG= addr
SRCS= ${PROG}.c
OBJS= ${PROG}.${O}
all: ${PROG}${EXE}
${PROG}${EXE}: ${OBJS} ${LIBBIND} Makefile
${CC} ${CDEBUG} ${LDFLAGS} ${BOUNDS} -o ${PROG}${EXE} ${OBJS} \
${LIBBIND} ${SYSLIBS}
.c.${O}:
${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} -c $*.c
distclean: clean
clean: FRC
rm -f ${PROG}${EXE} ${OBJS} core .depend
rm -f *.BAK *.CKP *~ *.orig
depend: ${SRCS}
mkdep ${CPPFLAGS} -I${INCL} -I${PORTINCL} ${SRCS}
${DESTDIR}${DESTBIN}:
mkdir -p ${DESTDIR}${DESTBIN}
install: ${DESTDIR}${DESTBIN} ${PROG}${EXE}
${INSTALL} ${STRIP} -c ${INSTALL_EXEC} -m 755 ${PROG}${EXE} ${DESTDIR}${DESTBIN}/${PROG}${EXE}
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.
-168
View File
@@ -1,168 +0,0 @@
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "$Id: addr.c,v 8.9 2002/05/21 02:26:21 marka Exp $";
#endif /* not lint */
/*
* Copyright (c) 1996,1999 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(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(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, some;
prog = argv[0];
af = AF_INET;
len = INADDRSZ;
some = 0;
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);
some++;
break;
case 'p':
if (inet_pton(af, optarg, addr) <= 0) {
fprintf(stderr, "bad address: \"%s\"\n",
optarg);
usage();
/* NOTREACHED */
}
display(optarg, af, addr, len);
some++;
break;
default:
usage();
/* NOTREACHED */
}
}
if (!some)
usage();
exit(0);
/* NOTREACHED */
}
-89
View File
@@ -1,89 +0,0 @@
## Copyright (c) 1996,1999 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.27 2000/12/23 08:02:50 vixie Exp $
DESTDIR=
CC= cc
SHELL= /bin/sh
CDEBUG= -g -Wall
#(net2 and its descendents)
SYSTYPE = freebsd
TOP = ../..
INCL = ${TOP}/include
PORTINCL = ${TOP}/port/${SYSTYPE}/include
LIBBIND = ${TOP}/lib/libbind.a
A=a
O=o
EXE=
LEX = lex -I
SYSLIBS = -ll -lutil
DESTBIN = /usr/local/bin
DESTSBIN = /usr/local/sbin
DESTEXEC = /usr/local/libexec
DESTMAN = /usr/share/man
DESTHELP= /usr/share/misc
STRIP=-s
INSTALL_EXEC=
INSTALL_LIB=-o bin -g bin
LDFLAGS=
CFLAGS= ${CDEBUG}
CPPFLAGS= -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}${EXE}
${PROG}${EXE}: ${OBJS} ${NSLOOKUP_OBJS} ${LIBBIND} Makefile
${CC} ${CDEBUG} ${LDFLAGS} ${BOUNDS} -o ${PROG}${EXE} ${OBJS} \
${NSLOOKUP_OBJS} ${LIBBIND} ${SYSLIBS}
.c.${O}:
${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} -c $*.c
distclean: clean
clean: FRC
rm -f ${PROG}${EXE} ${OBJS} core .depend
rm -f *.BAK *.CKP *~ *.orig
depend: ${SRCS}
mkdep ${CPPFLAGS} -I${INCL} -I${PORTINCL} ${SRCS}
${DESTDIR}${DESTBIN}:
mkdir -p ${DESTDIR}${DESTBIN}
install: ${DESTDIR}${DESTBIN} ${PROG}${EXE}
${INSTALL} ${STRIP} -c ${INSTALL_EXEC} -m 755 ${PROG}${EXE} ${DESTDIR}${DESTBIN}/${PROG}${EXE}
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.
File diff suppressed because it is too large. Load diff
-86
View File
@@ -1,86 +0,0 @@
## Copyright (c) 1996,1999 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.7 2000/12/23 08:02:50 vixie Exp $
DESTDIR=
CC= cc
SHELL= /bin/sh
CDEBUG= -g -Wall
#(net2 and its descendents)
SYSTYPE = freebsd
TOP = ../..
INCL = ${TOP}/include
PORTINCL = ${TOP}/port/${SYSTYPE}/include
LIBBIND = ${TOP}/lib/libbind.a
A=a
O=o
LEX = lex -I
SYSLIBS = -ll -lutil
DESTBIN = /usr/local/bin
DESTSBIN = /usr/local/sbin
DESTEXEC = /usr/local/libexec
DESTMAN = /usr/share/man
DESTHELP= /usr/share/misc
AR= ar cru
INSTALL= install
STRIP=-s
INSTALL_EXEC=
INSTALL_LIB=-o bin -g bin
PS=ps
LDFLAGS=
CFLAGS= ${CDEBUG}
CPPFLAGS= -I${PORTINCL} -I${INCL}
PROG= dnskeygen
SRCS= dnskeygen.c
OBJS= dnskeygen.${O}
all: ${PROG}${EXE}
${PROG}${EXE}: ${OBJS} ${LIBBIND} Makefile
${CC} ${CDEBUG} ${LDFLAGS} ${BOUNDS} -o ${PROG}${EXE} ${OBJS} \
${LIBBIND} ${SYSLIBS}
.c.${O}:
${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} -c $*.c
distclean: clean
clean: FRC
rm -f ${PROG}${EXE} ${OBJS} core .depend
rm -f *.BAK *.CKP *~ *.orig
depend: ${SRCS}
mkdep ${CPPFLAGS} -I${INCL} -I${PORTINCL} ${SRCS}
${DESTDIR}${DESTEXEC}:
mkdir -p ${DESTDIR}${DESTEXEC}
install: ${DESTDIR}${DESTEXEC} ${PROG}${EXE}
${INSTALL} ${STRIP} -c ${INSTALL_EXEC} -m 755 ${PROG}${EXE} ${DESTDIR}${DESTEXEC}/${PROG}${EXE}
links: FRC
@set -e; ln -s SRC/*.[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.
-321
View File
@@ -1,321 +0,0 @@
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "$Id: dnskeygen.c,v 1.14 2001/09/25 04:50:14 marka Exp $";
#endif /* not lint */
/*
* Portions Copyright (c) 1995-1999 by TISLabs at Network Associates, Inc.
*
* 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 NETWORK ASSOCIATES
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* TRUSTED INFORMATION SYSTEMS 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 THE SOFTWARE.
*/
#include "port_before.h"
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "arpa/nameser.h"
#include <isc/dst.h>
#include "port_after.h"
#define PRINT_SUPPORTED 2
#ifndef PATH_SEP
#define PATH_SEP '/'
#endif
static void usage(const char *str, int full);
static short dsa_sizes[] = {512, 576, 640, 704, 768, 832, 896, 960, 1024, 0};
static char *prog;
int
main(int argc, char **argv) {
DST_KEY *pubkey;
char *name=NULL;
int ch;
char str[128];
int alg = 0;
int zone_key = 0, user_key = 0, end_key = 0, key_type = 0;
int size = -1, exp = 0;
int no_auth = 0, no_conf = 0;
int sign_val = 0, flags = 0, protocol = -1;
int i, err = 0;
extern char *optarg;
dst_init();
if ((prog = strrchr(argv[0], PATH_SEP)) == NULL)
prog = strdup(argv[0]);
else
prog = strdup(++prog);
/* process input arguments */
while ((ch = getopt(argc, argv, "achiuzn:s:p:D:H:R:F"))!= -1) {
switch (ch) {
case 'a':
no_auth = NS_KEY_NO_AUTH;
break;
case 'c':
no_conf = NS_KEY_NO_CONF;
break;
case 'F':
exp=1;
break;
case 'n':
if (optarg)
name = strdup(optarg);
else
usage("-n not followed by name", 0);
i = strlen(name);
if (name[i-1] != '.') {
printf("** Adding dot to the name to make it"
" fully qualified domain name**\n");
free(name);
name = malloc(i+2);
strcpy(name, optarg);
strcat(name, ".");
}
break;
case 'p':
if (optarg && isdigit(optarg[0]))
protocol = atoi(optarg);
else
usage("-p flag not followed by a number", 0);
break;
case 's':
/* Default: not signatory key */
if (optarg && isdigit(optarg[0]))
sign_val = (int) atoi(optarg);
else
usage("-s flag requires a value",0);
break;
case 'h':
end_key = NS_KEY_NAME_ENTITY;
key_type++;
break;
case 'u' :
user_key = NS_KEY_NAME_USER;
key_type++;
break ;
case 'z':
zone_key = NS_KEY_NAME_ZONE;
key_type++;
break;
case 'H':
if (optarg && isdigit(optarg[0]))
size = (int) atoi(optarg);
else
usage("-H flag requires a size",0);
if (alg != 0)
usage("Only ONE alg can be specified", 1);
alg = KEY_HMAC_MD5;
if (!dst_check_algorithm(alg))
usage("Algorithm HMAC-MD5 not available",
PRINT_SUPPORTED);
break;
case 'R':
if (optarg && isdigit(optarg[0]))
size = (int) atoi(optarg);
else
usage("-R flag requires a size",0);
if (alg != 0)
usage("Only ONE alg can be specified", 1);
alg = NS_ALG_MD5RSA;
if (!dst_check_algorithm(alg))
usage("Algorithm RSA not available",
PRINT_SUPPORTED);
break;
case 'D':
if (optarg && isdigit(optarg[0]))
size = (int) atoi(optarg);
else
usage("-D flag requires a size", 0);
if (alg != 0)
usage("Only ONE alg can be specified", 1);
alg = NS_ALG_DSS;
if (dst_check_algorithm(alg) == 0)
usage("Algorithm DSS not available",
PRINT_SUPPORTED);
break;
default:
err++;
} /* switch */
} /* while (getopt) */
/*
* Command line parsed make sure required parameters are present
*/
if (name == NULL)
usage("No key name specified -n <name>", 1);
if (alg == 0)
usage("No algorithm specififed -{DHR}", 1);
if (key_type == 0)
usage("Key type -{zhu} must be specified", 1);
else if (key_type > 1)
usage("Only one key type -{zhu} must be specified", 1);
if (alg == NS_ALG_DSS)
no_conf = NS_KEY_NO_CONF; /* dss keys can not encrypt */
if (protocol == -1) {
if (zone_key || end_key)
protocol = NS_KEY_PROT_DNSSEC;
else
protocol = NS_KEY_PROT_EMAIL;
}
if (protocol < 0 || protocol > 255)
usage("Protocol value out of range [0..255]", 0);
if (sign_val < 0 || sign_val > 15) {
sprintf(str, "%s: Signatory value %d out of range[0..15]\n",
prog, sign_val);
usage(str, 0);
}
/* if any of bits 321 is set bit 0 can not be set*/
if (sign_val & 0xe)
sign_val &= 0xe;
/* if a zone key make sure at least one of the signer flags is set */
if ((protocol == NS_KEY_PROT_DNSSEC) && (sign_val == 0))
sign_val = 0x01;
if (no_auth && no_conf) { /* null key specified */
if (sign_val > 0)
sign_val = 0x0; /* null key can not sign */
if (size > 0)
size = 0; /* null key must have size 0 */
}
if (size > 0) {
if (alg == NS_ALG_MD5RSA){
if (size < 512 || size > 4096)
usage("Size out of range", 1);
}
else if (exp)
usage("-F can only be specified with -R", 0);
if (alg == NS_ALG_DSS) {
for (i = 0; dsa_sizes[i]; i++)
if (size <= dsa_sizes[i])
break;
if (size != dsa_sizes[i])
usage("Invalid DSS key size", 1);
}
}
else if (size < 0)
usage("No size specified", 0);
else /* size == 0 */
sign_val = 0;
if (err)
usage("errors encountered/unknown flag", 1);
flags = no_conf | no_auth | end_key | user_key | zone_key | sign_val;
/* process defaults */
#ifdef WARN_NONZONE_SIGNER
if (signer && (user_key | end_key))
printf("Warning: User/End key is allowed to sign\n");
#endif
/* create a public/private key pair */
if (alg == NS_ALG_MD5RSA)
printf("Generating %d bit RSA Key for %s\n\n",size, name);
else if (alg == NS_ALG_DSS)
printf("Generating %d bit DSS Key for %s\n\n",size, name);
else if (alg == KEY_HMAC_MD5)
printf("Generating %d bit HMAC-MD5 Key for %s\n\n",
size, name);
/* Make the key
* dst_generate_key_pair will place result in files that it
* knows about K<name><foot>.public and K<name><foot>.private
*/
pubkey = dst_generate_key(name, size, exp, flags, protocol, alg);
if (pubkey == NULL) {
printf("Failed generating key for %s\n", name);
exit(12);
}
if (dst_write_key(pubkey, DST_PRIVATE) < 0) {
printf ("Failed to write private key for %s %d %d\n",
name, pubkey->dk_id, pubkey->dk_alg);
exit(12);
}
if (dst_write_key(pubkey, DST_PUBLIC) <= 0) {
if (access(name, F_OK))
printf("Not allowed to overwrite existing file\n");
else
printf("Failed to write public key for %s %d %d\n",
name, pubkey->dk_id, pubkey->dk_alg);
exit(12);
}
printf("Generated %d bit Key for %s id=%d alg=%d flags=%d\n\n",
size, name, pubkey->dk_id, pubkey->dk_alg,
pubkey->dk_flags);
exit(0);
}
static void
usage(const char *str, int flag) {
int i;
printf("\nNo key generated\n");
if (*str != '\0')
printf("Usage:%s: %s\n",prog, str);
printf("Usage:%s -{DHR} <size> [-F] -{zhu} [-ac] [-p <no>]"
" [-s <no>] -n name\n", prog);
if (flag == 0)
exit(2);
printf("\t-D generate DSA/DSS KEY: size must be one of following:\n");
printf("\t\t");
for(i = 0; dsa_sizes[i] > 0; i++)
printf(" %d,", dsa_sizes[i]);
printf("\n");
printf("\t-H generate HMAC-MD5 KEY: size in the range [1..512]:\n");
printf("\t-R generate RSA KEY: size in the range [512..4096]\n");
printf("\t-F RSA KEYS only: use large exponent\n");
printf("\t-z Zone key \n");
printf("\t-h Host/Entity key \n");
printf("\t-u User key \n");
printf("\t-a Key CANNOT be used for authentication\n");
printf("\t-c Key CANNOT be used for encryption\n");
printf("\t-p Set protocol field to <no>\n");
printf("\t\t default: 2 (email) for Host keys, 3 (dnssec) for all others\n");
printf("\t-s Strength value this key signs DNS records with\n");
printf("\t\t default: 1 for Zone keys, 0 for all others\n");
printf("\t-n name: the owner of the key\n");
if (flag == PRINT_SUPPORTED) {
printf("Available algorithms are:");
if (dst_check_algorithm(NS_ALG_MD5RSA) == 1)
printf(" RSA");
if (dst_check_algorithm(NS_ALG_DSS) == 1)
printf(" DSS");
if (dst_check_algorithm(KEY_HMAC_MD5) == 1)
printf(" HMAC-MD5");
printf("\n");
}
exit (3);
}
-85
View File
@@ -1,85 +0,0 @@
## Copyright (c) 1996,1999 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.26 2000/12/23 08:02:51 vixie Exp $
DESTDIR=
CC= cc
SHELL= /bin/sh
CDEBUG= -g -Wall
#(net2 and its descendents)
SYSTYPE = freebsd
TOP = ../..
INCL = ${TOP}/include
PORTINCL = ${TOP}/port/${SYSTYPE}/include
LIBBIND = ${TOP}/lib/libbind.a
A=a
O=o
EXE=
LEX = lex -I
SYSLIBS = -ll -lutil
DESTBIN = /usr/local/bin
DESTSBIN = /usr/local/sbin
DESTEXEC = /usr/local/libexec
DESTMAN = /usr/share/man
DESTHELP= /usr/share/misc
STRIP=-s
INSTALL_EXEC=
INSTALL_LIB=-o bin -g bin
LDFLAGS=
CFLAGS= ${CDEBUG}
CPPFLAGS= -I${PORTINCL} -I${INCL}
PROG= dnsquery
SRCS= ${PROG}.c
OBJS= ${PROG}.${O}
all: ${PROG}${EXE}
${PROG}${EXE}: ${OBJS} ${LIBBIND} Makefile
${CC} ${CDEBUG} ${LDFLAGS} ${BOUNDS} -o ${PROG}${EXE} ${OBJS} \
${LIBBIND} ${SYSLIBS}
.c.${O}:
${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} -c $*.c
distclean: clean
clean: FRC
rm -f ${PROG}${EXE} ${OBJS} core .depend
rm -f *.BAK *.CKP *~ *.orig
depend: ${SRCS}
mkdep ${CPPFLAGS} -I${INCL} -I${PORTINCL} ${SRCS}
${DESTDIR}${DESTBIN}:
mkdir -p ${DESTDIR}${DESTBIN}
install: ${DESTDIR}${DESTBIN} ${PROG}${EXE}
${INSTALL} ${STRIP} -c ${INSTALL_EXEC} -m 755 ${PROG}${EXE} ${DESTDIR}${DESTBIN}/${PROG}${EXE}
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.
-232
View File
@@ -1,232 +0,0 @@
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "$Id: dnsquery.c,v 8.19.10.1 2003/06/02 09:15:45 marka Exp $";
#endif /* not lint */
/*
* Copyright (c) 1996,1999 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "port_after.h"
#include <resolv.h>
extern int errno;
extern int h_errno;
extern char *h_errlist[];
struct __res_state res;
static int
newserver(char *srv, union res_sockaddr_union *u, int ns, int max) {
struct addrinfo *answer = NULL;
struct addrinfo *cur = NULL;
struct addrinfo hint;
short port = htons(NAMESERVER_PORT);
memset(&hint, 0, sizeof(hint));
hint.ai_socktype = SOCK_DGRAM;
if (!getaddrinfo(srv, NULL, &hint, &answer)) {
for (cur = answer; cur != NULL; cur = cur->ai_next) {
if (ns >= max)
break;
switch (cur->ai_addr->sa_family) {
case AF_INET6:
u[ns].sin6 =
*(struct sockaddr_in6*)cur->ai_addr;
u[ns++].sin6.sin6_port = port;
break;
case AF_INET:
u[ns].sin = *(struct sockaddr_in*)cur->ai_addr;
u[ns++].sin6.sin6_port = port;
break;
}
}
freeaddrinfo(answer);
} else {
fprintf(stderr, "Bad nameserver (%s)\n", srv);
exit(1);
}
return (ns);
}
int
main(int argc, char *argv[]) {
char name[MAXDNAME];
u_char answer[8*1024];
int c, n;
int nameservers = 0, class, type, len;
union res_sockaddr_union q_nsaddr[MAXNS];
extern int optind;
extern char *optarg;
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")) != -1) {
switch (c) {
case 'r' : res.retry = atoi(optarg);
break;
case 'p' : res.retrans = atoi(optarg);
break;
case 'h' : if (strlen(optarg) >= sizeof(name)) {
fprintf(stderr,
"Domain name too long (%s)\n", optarg);
exit(1);
} else
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_ninit(&res) == -1) {
fprintf(stderr,
"res_ninit() failed\n"
);
exit(1);
}
nameservers = newserver(optarg, q_nsaddr,
nameservers, MAXNS);
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) {
if (strlen(argv[optind]) >= sizeof(name)) {
fprintf(stderr,
"Domain name too long (%s)\n", argv[optind]);
exit(1);
} else {
strcpy(name, argv[optind]);
}
}
len = sizeof(answer);
if (!(res.options & RES_INIT))
if (res_ninit(&res) == -1) {
fprintf(stderr, "res_ninit() failed\n");
exit(1);
}
/*
* set these here so they aren't set for a possible call to
* gethostbyname above
*/
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_setservers(&res, q_nsaddr, nameservers);
/*
* 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_nquery(&res, 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_nsearch(&res, name, class, type,
answer, len)) < 0) {
fprintf(stderr, "Query failed (h_errno = %d) : %s\n",
h_errno, h_errlist[h_errno]);
exit(1);
}
res_pquery(&res, answer, n, stdout);
exit(0);
}
-85
View File
@@ -1,85 +0,0 @@
## Copyright (c) 1996,1999 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.26 2000/12/23 08:02:51 vixie Exp $
DESTDIR=
CC= cc
SHELL= /bin/sh
CDEBUG= -g -Wall
#(net2 and its descendents)
SYSTYPE = freebsd
TOP = ../..
INCL = ${TOP}/include
PORTINCL = ${TOP}/port/${SYSTYPE}/include
LIBBIND = ${TOP}/lib/libbind.a
A=a
O=o
EXE=
LEX = lex -I
SYSLIBS = -ll -lutil
DESTBIN = /usr/local/bin
DESTSBIN = /usr/local/sbin
DESTEXEC = /usr/local/libexec
DESTMAN = /usr/share/man
DESTHELP= /usr/share/misc
STRIP=-s
INSTALL_EXEC=
INSTALL_LIB=-o bin -g bin
LDFLAGS=
CFLAGS= ${CDEBUG}
CPPFLAGS= -I${PORTINCL} -I${INCL}
PROG= host
SRCS= ${PROG}.c
OBJS= ${PROG}.${O}
all: ${PROG}${EXE}
${PROG}${EXE}: ${OBJS} ${LIBBIND} Makefile
${CC} ${CDEBUG} ${LDFLAGS} ${BOUNDS} -o ${PROG}${EXE} ${OBJS} \
${LIBBIND} ${SYSLIBS}
.c.${O}:
${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} -c $*.c
distclean: clean
clean: FRC
rm -f ${PROG}${EXE} ${OBJS} core .depend
rm -f *.BAK *.CKP *~ *.orig
depend: ${SRCS}
mkdep ${CPPFLAGS} -I${INCL} -I${PORTINCL} ${SRCS}
${DESTDIR}${DESTBIN}:
mkdir -p ${DESTDIR}${DESTBIN}
install: ${DESTDIR}${DESTBIN} ${PROG}${EXE}
${INSTALL} ${STRIP} -c ${INSTALL_EXEC} -m 755 ${PROG}${EXE} ${DESTDIR}${DESTBIN}/${PROG}${EXE}
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.
File diff suppressed because it is too large. Load diff
-101
View File
@@ -1,101 +0,0 @@
## 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 1.7 2000/12/23 08:02:52 vixie Exp $
DESTDIR=
CC= cc
SHELL= /bin/sh
CDEBUG= -g -Wall
#(net2 and its descendents)
SYSTYPE = freebsd
TOP = ../..
INCL = ${TOP}/include
PORTINCL = ${TOP}/port/${SYSTYPE}/include
LIBBIND = ${TOP}/lib/libbind.a
A=a
O=o
EXE=
LEX = lex -I
YACC = yacc -d
SYSLIBS = -ll -lutil
DESTBIN = /usr/local/bin
DESTSBIN = /usr/local/sbin
DESTEXEC = /usr/local/libexec
DESTMAN = /usr/share/man
DESTHELP= /usr/share/misc
DESTETC= /etc
DESTRUN= /var/run
AR= ar cru
INSTALL= install
STRIP=-s
PS=ps
LDFLAGS=
CFLAGS= ${CDEBUG}
CPPFLAGS= -I${PORTINCL} -I${INCL} -I${TOP}/lib/irs ${DEFS}
VER= LOCAL-`date +%y%m%d.%H%M%S`
HOSTNAMECMD= hostname || uname -n
PROG= irpd
HDRS=
SRCS= irpd.c
OBJS= irpd.${O}
all: ${PROG}${EXE}
${PROG}${EXE}: irpd.${O} tmp_version.${O} ${LIBBIND}
${CC} ${CDEBUG} ${LDFLAGS} -o ${PROG}${EXE} ${OBJS} tmp_version.${O} \
${LIBBIND} ${SYSLIBS}
.c.${O}:
${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} -c $*.c
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); sleep 1
distclean: clean
clean: FRC
rm -f ${PROG}${EXE} ${OBJS} core .depend
rm -f *.BAK *.CKP *~ *.orig
rm -f tmp_version.c tmp_version.${O}
depend: ${SRCS}
mkdep ${CPPFLAGS} -I${INCL} -I${PORTINCL} -I${TOP}/lib/irs ${DEFS} ${SRCS}
${DESTDIR}${DESTSBIN}:
mkdir -p ${DESTDIR}${DESTSBIN}
install: ${DESTDIR}${DESTSBIN} ${PROG}${EXE}
${INSTALL} ${STRIP} -c -m 755 ${PROG}${EXE} ${DESTDIR}${DESTSBIN}/${PROG}${EXE}
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.
File diff suppressed because it is too large. Load diff
-11
View File
@@ -1,11 +0,0 @@
# Private irs config file for irpd so that it doesn't get configured to
# talk to itself.
passwd local
group local
services local
protocols local
hosts dns continue
hosts local
networks dns continue
networks local
netgroup local
-25
View File
@@ -1,25 +0,0 @@
/*
* 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.
*/
#ifndef lint
char sccsid[] = "@(#)named %VERSION% %WHEN% %WHOANDWHERE%";
char rcsid[] = "$Id: version.c,v 1.1 1999/01/18 07:47:17 vixie Exp $";
#endif /* not lint */
char Version[] = "named %VERSION% %WHEN%\n\t%WHOANDWHERE%";
char ShortVersion[] = "%VERSION%";
-84
View File
@@ -1,84 +0,0 @@
## Copyright (c) 1998,1999 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.8 2000/12/23 08:02:52 vixie Exp $
DESTDIR=
CC= cc
SHELL= /bin/sh
CDEBUG= -g -Wall
#(net2 and its descendents)
SYSTYPE = freebsd
TOP = ../..
INCL = ${TOP}/include
PORTINCL = ${TOP}/port/${SYSTYPE}/include
LIBBIND = ${TOP}/lib/libbind.a
A=a
O=o
LEX = lex -I
SYSLIBS = -ll -lutil
DESTBIN = /usr/local/bin
DESTSBIN = /usr/local/sbin
DESTEXEC = /usr/local/libexec
DESTMAN = /usr/share/man
DESTHELP= /usr/share/misc
STRIP=-s
INSTALL_EXEC=
INSTALL_LIB=-o bin -g bin
LDFLAGS=
CFLAGS= ${CDEBUG}
CPPFLAGS= -I${PORTINCL} -I${INCL}
PROG= mkservdb
SRCS= ${PROG}.c
OBJS= ${PROG}.${O}
all: ${PROG}${EXE}
${PROG}${EXE}: ${OBJS} ${LIBBIND} Makefile
${CC} ${CDEBUG} ${LDFLAGS} ${BOUNDS} -o ${PROG}${EXE} ${OBJS} \
${LIBBIND} ${SYSLIBS}
.c.${O}:
${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} -c $*.c
distclean: clean
clean: FRC
rm -f ${PROG}${EXE} ${OBJS} core .depend
rm -f *.BAK *.CKP *~ *.orig
depend: ${SRCS}
mkdep ${CPPFLAGS} -I${INCL} -I${PORTINCL} ${SRCS}
${DESTDIR}${DESTBIN}:
mkdir -p ${DESTDIR}${DESTBIN}
install: ${DESTDIR}${DESTBIN} ${PROG}${EXE}
${INSTALL} ${STRIP} -c ${INSTALL_EXEC} -m 755 ${PROG}${EXE} ${DESTDIR}${DESTBIN}/${PROG}${EXE}
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.
-176
View File
@@ -1,176 +0,0 @@
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "$Id: mkservdb.c,v 1.10 2001/06/18 14:42:46 marka Exp $";
#endif /* not lint */
/*
* Copyright (c) 1998,1999 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 <resolv.h>
#include <ctype.h>
#ifdef IRS_LCL_SV_DB
#include <db.h>
#include <err.h>
#endif
#include <fcntl.h>
#include <limits.h>
#include <netdb.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "../../include/irs.h"
#include "../../lib/irs/irs_p.h"
#include "../../include/isc/misc.h"
#include "port_after.h"
#ifdef SPRINTF_CHAR
# define SPRINTF(x) strlen(sprintf/**/x)
#else
# define SPRINTF(x) ((size_t)sprintf x)
#endif
#ifndef IRS_LCL_SV_DB
main(int argc, char **argv) {
fprintf(stderr, "%s: not supported on this architecture\n", argv[0]);
exit(1);
}
#else
#define _PATH_SERVICES_DB_TMP _PATH_SERVICES_DB ".new"
struct servent *getnextent(FILE *);
int
main(int argc, char **argv) {
DB *db;
DBT key;
DBT data;
const char *filename = _PATH_SERVICES;
const char *tmpdatabase = _PATH_SERVICES_DB_TMP;
const char *database = _PATH_SERVICES_DB;
char dbuf[1024];
char kbuf[512];
u_short *ports;
struct lcl_sv lcl_sv;
struct servent *sv;
int n, r;
char *p;
unlink(tmpdatabase);
if (argc > 1)
filename = argv[1];
lcl_sv.fp = fopen(filename, "r");
if (lcl_sv.fp == NULL)
err(1, "%s", filename);
db = dbopen(tmpdatabase, O_CREAT|O_RDWR, 0444, DB_BTREE, NULL);
if (db == NULL)
err(1, "%s", tmpdatabase);
while ((sv = irs_lclsv_fnxt(&lcl_sv)) != NULL) {
if (sv->s_proto == NULL)
continue;
key.data = kbuf;
data.data = dbuf;
/* Note that (sizeof "/") == 2. */
if (strlen(sv->s_name) + sizeof "/" + strlen(sv->s_proto)
> sizeof kbuf)
continue;
key.size = SPRINTF((kbuf, "%s/%s", sv->s_name, sv->s_proto))+1;
((u_short *)dbuf)[0] = sv->s_port;
p = dbuf;
p += sizeof(u_short);
if (sv->s_aliases)
for (n = 0; sv->s_aliases[n]; ++n) {
strcpy(p, sv->s_aliases[n]);
p += strlen(p) + 1;
}
data.size = p - dbuf;
if ((r = db->put(db, &key, &data, R_NOOVERWRITE))) {
if (r < 0)
errx(1, "failed to write %s", (char *)key.data);
else
warnx("will not overwrite %s", (char *)key.data);
}
for (n = 0; sv->s_aliases[n]; ++n) {
if (strlen(sv->s_aliases[n]) + sizeof "/"
+ strlen(sv->s_proto) > sizeof kbuf)
continue;
key.size = SPRINTF((kbuf, "%s/%s",
sv->s_aliases[n], sv->s_proto))+1;
if ((r = db->put(db, &key, &data, R_NOOVERWRITE))) {
if (r < 0)
errx(1, "failed to write %s",
(char *)key.data);
else
warnx("will not overwrite %s",
(char *)key.data);
}
}
ports = (u_short *)kbuf;
ports[0] = 0;
ports[1] = sv->s_port;
strcpy((char *)(ports+2), sv->s_proto);
key.size = sizeof(u_short) * 2 + strlen((char *)(ports+2)) + 1;
if (strlen(sv->s_name) + sizeof "/" + strlen(sv->s_proto)
> sizeof dbuf)
continue;
p = dbuf;
p += SPRINTF((p, "%s/%s", sv->s_name, sv->s_proto)) + 1;
if (sv->s_aliases != NULL)
for (n = 0; sv->s_aliases[n] != NULL; n++)
if ((p + strlen(sv->s_aliases[n]) + 1) - dbuf
<= (int)sizeof dbuf) {
strcpy(p, sv->s_aliases[n]);
p += strlen(p) + 1;
}
data.size = p - dbuf;
if ((r = db->put(db, &key, &data, R_NOOVERWRITE))) {
if (r < 0)
errx(1, "failed to write %d/%s",
ntohs(sv->s_port), sv->s_proto);
else
warnx("will not overwrite %d/%s",
ntohs(sv->s_port), sv->s_proto);
}
}
db->close(db);
if (isc_movefile(tmpdatabase, database))
err(1, "rename %s -> %s", tmpdatabase, database);
exit(0);
}
#endif
@@ -1,324 +0,0 @@
#!/usr/bin/perl
## Copyright (c) 1996-1999 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 1.2 1999/01/08 19:27:35 vixie 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";
}
-77
View File
@@ -1,77 +0,0 @@
## Copyright (c) 1999 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.3 2000/12/23 08:02:53 vixie Exp $
DESTDIR=
CC= cc
SHELL= /bin/sh
CDEBUG= -g -Wall
#(net2 and its descendents)
SYSTYPE = freebsd
TOP = ../..
INCL = ${TOP}/include
PORTINCL = ${TOP}/port/${SYSTYPE}/include
LIBBIND = ${TOP}/lib/libbind.a
A=a
O=o
LEX = lex -I
SYSLIBS = -ll -lutil
DESTBIN = /usr/local/bin
DESTSBIN = /usr/local/sbin
DESTEXEC = /usr/local/libexec
DESTMAN = /usr/share/man
DESTHELP= /usr/share/misc
STRIP=-s
INSTALL_EXEC=
INSTALL_LIB=-o bin -g bin
LDFLAGS=
CFLAGS= ${CDEBUG}
CPPFLAGS= -I${PORTINCL} -I${INCL}
PROG= named-bootconf
all: ${PROG}
${PROG}: ${PROG}.sh Makefile
cp ${PROG}.sh ${PROG}
chmod +x ${PROG}
distclean: clean
clean: FRC
rm -f ${PROG}
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:
# DO NOT DELETE THIS LINE -- mkdep uses it.
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
@@ -1,321 +0,0 @@
#!/bin/sh
#
# $NetBSD: named-bootconf.sh,v 1.5 1998/12/15 01:00:53 tron Exp $
#
# Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
# All rights reserved.
#
# This code is derived from software contributed to The NetBSD Foundation
# by Matthias Scheler.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the NetBSD
# Foundation, Inc. and its contributors.
# 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
## Copyright (c) 1999 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.
if [ ${OPTIONFILE-X} = X ]; then
OPTIONFILE=/tmp/.options.`date +%s`.$$
ZONEFILE=/tmp/.zones.`date +%s`.$$
COMMENTFILE=/tmp/.comments.`date +%s`.$$
export OPTIONFILE ZONEFILE COMMENTFILE
touch $OPTIONFILE $ZONEFILE $COMMENTFILE
DUMP=1
else
DUMP=0
fi
while read CMD ARGS; do
class=
CMD=`echo "${CMD}" | tr '[A-Z]' '[a-z]'`
case $CMD in
\; )
echo \# $ARGS >>$COMMENTFILE
;;
cache )
set - X $ARGS
shift
if [ $# -eq 2 ]; then
(echo ""
cat $COMMENTFILE
echo "zone \"$1\" {"
echo " type hint;"
echo " file \"$2\";"
echo "};") >>$ZONEFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
fi
;;
directory )
set - X $ARGS
shift
if [ $# -eq 1 ]; then
(cat $COMMENTFILE
echo " directory \"$1\";") >>$OPTIONFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
DIRECTORY=$1
export DIRECTORY
fi
;;
forwarders )
(cat $COMMENTFILE
echo " forwarders {"
for ARG in $ARGS; do
echo " $ARG;"
done
echo " };") >>$OPTIONFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
;;
include )
if [ "$ARGS" != "" ]; then
(cd ${DIRECTORY-.}; cat $ARGS) | $0
fi
;;
limit )
ARGS=`echo "${ARGS}" | tr '[A-Z]' '[a-z]'`
set - X $ARGS
shift
if [ $# -eq 2 ]; then
cat $COMMENTFILE >>$OPTIONFILE
case $1 in
datasize | files | transfers-in | transfers-per-ns )
echo " $1 $2;" >>$OPTIONFILE
;;
esac
rm -f $COMMENTFILE
touch $COMMENTFILE
fi
;;
options )
ARGS=`echo "${ARGS}" | tr '[A-Z]' '[a-z]'`
cat $COMMENTFILE >>$OPTIONFILE
for ARG in $ARGS; do
case $ARG in
fake-iquery )
echo " fake-iquery yes;" >>$OPTIONFILE
;;
forward-only )
echo " forward only;" >>$OPTIONFILE
;;
no-fetch-glue )
echo " fetch-glue no;" >>$OPTIONFILE
;;
no-recursion )
echo " recursion no;" >>$OPTIONFILE
;;
no-round-robin ) # HP extention
echo " rrset-order {" >>$OPTIONFILE
echo " class ANY type ANY name \"*\" order fixed;" >>$OPTIONFILE
echo " };" >>$OPTIONFILE
;;
esac
done
rm -f $COMMENTFILE
touch $COMMENTFILE
;;
primary|primary/* )
case $CMD in
primary/chaos )
class="chaos "
;;
primary/hs )
class="hesiod "
;;
esac
set - X $ARGS
shift
if [ $# -eq 2 ]; then
(echo ""
cat $COMMENTFILE
echo "zone \"$1\" ${class}{"
echo " type master;"
echo " file \"$2\";"
echo "};") >>$ZONEFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
fi
;;
secondary|secondary/* )
case $CMD in
secondary/chaos )
class="chaos "
;;
secondary/hs )
class="hesiod "
;;
esac
set - X $ARGS
shift
if [ $# -gt 1 ]; then
ZONE=$1
shift
PRIMARIES=""
while [ $# -gt 1 ]; do
PRIMARIES="$PRIMARIES $1"
shift
done
(echo ""
cat $COMMENTFILE
echo "zone \"$ZONE\" ${class}{"
echo " type slave;"
if expr x"$1" : '^x[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$' > /dev/null
then
PRIMARIES="$PRIMARIES $1"
else
echo " file \"$1\";"
fi
echo " masters {"
for PRIMARY in $PRIMARIES; do
echo " $PRIMARY;"
done
echo " };"
echo "};") >>$ZONEFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
fi
;;
stub|stub/* )
case $CMD in
stub/chaos )
class="chaos "
;;
stub/hs )
class="hesiod "
;;
esac
set - X $ARGS
shift
if [ $# -gt 1 ]; then
ZONE=$1
shift
PRIMARIES=""
while [ $# -gt 1 ]; do
PRIMARIES="$PRIMARIES $1"
shift
done
(echo ""
cat $COMMENTFILE
echo "zone \"$ZONE\" ${class}{"
echo " type stub;"
if expr x"$1" : '^x[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$' > /dev/null
then
PRIMARIES="$PRIMARIES $1"
else
echo " file \"$1\";"
fi
echo " masters {"
for PRIMARY in $PRIMARIES; do
echo " $PRIMARY;"
done
echo " };"
echo "};") >>$ZONEFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
fi
;;
slave )
cat $COMMENTFILE >>$OPTIONFILE
echo " forward only;" >>$OPTIONFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
;;
sortlist )
(cat $COMMENTFILE
echo " topology {"
for ARG in $ARGS; do
case $ARG in
*.0.0.0 )
echo " $ARG/8;"
;;
*.0.0 )
echo " $ARG/16;"
;;
*.0 )
echo " $ARG/24;"
;;
* )
echo " $ARG;"
;;
esac
done
echo " };") >>$OPTIONFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
;;
tcplist | xfrnets )
(cat $COMMENTFILE
echo " allow-transfer {"
for ARG in $ARGS; do
case $ARG in
*.0.0.0 )
echo " $ARG/8;"
;;
*.0.0 )
echo " $ARG/16;"
;;
*.0 )
echo " $ARG/24;"
;;
* )
echo " $ARG;"
;;
esac
done
echo " };") >>$OPTIONFILE
rm -f $COMMENTFILE
touch $COMMENTFILE
;;
esac
done
if [ $DUMP -eq 1 ]; then
echo ""
echo "options {"
cat $OPTIONFILE
echo "};"
cat $ZONEFILE $COMMENTFILE
rm -f $OPTIONFILE $ZONEFILE $COMMENTFILE
fi
exit 0
-30
View File
@@ -1,30 +0,0 @@
directory /var/named
forwarders 1.2.3.4 1.2.3.5
limit datasize 10000000
limit files 1000
limit transfers-in 100
limit transfers-per-ns 20
; no-round-robin in HP specific
options no-round-robin fake-iquery forward-only no-fetch-glue no-recursion
slave
tcplist 10.0.0.1
xfrnets 10.0.0.2
cache . rootservers
primary example.net example.net.db
secondary example.com 127.0.0.1 example.com.db
stub example.org 127.0.0.1 example.org.db
primary/IN example.net example.net.db
secondary/IN example.com 127.0.0.1 example.com.db
stub/IN example.org 127.0.0.1 example.org.db
secondary/IN example.com 127.0.0.1
stub/IN example.org 127.0.0.1
primary/CHAOS example.net example.net.db
secondary/CHAOS example.com 127.0.0.1 example.com.db
stub/CHAOS example.org 127.0.0.1 example.org.db
secondary/CHAOS example.com 127.0.0.1
stub/CHAOS example.org 127.0.0.1
primary/HS example.net example.net.db
secondary/HS example.com 127.0.0.1 example.com.db
stub/HS example.org 127.0.0.1 example.org.db
secondary/HS example.com 127.0.0.1
stub/HS example.org 127.0.0.1
-90
View File
@@ -1,90 +0,0 @@
## Copyright (c) 1996,1999 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 2000/12/23 08:02:54 vixie Exp $
DESTDIR=
CC= cc
SHELL= /bin/sh
CDEBUG= -g -Wall
#(net2 and its descendents)
SYSTYPE = freebsd
TOP = ../..
INCL = ${TOP}/include
PORTINCL = ${TOP}/port/${SYSTYPE}/include
LIBBIND = ${TOP}/lib/libbind.a
A=a
O=o
EXE=
LEX = lex -I
SYSLIBS = -ll -lutil
DESTBIN = /usr/local/bin
DESTSBIN = /usr/local/sbin
DESTEXEC = /usr/local/libexec
DESTMAN = /usr/share/man
DESTHELP= /usr/share/misc
AR= ar cru
INSTALL= install
STRIP=-s
INSTALL_EXEC=
INSTALL_LIB=-o bin -g bin
PS=ps
LDFLAGS=
CFLAGS= ${CDEBUG}
CPPFLAGS= -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}${EXE}
${PROG}${EXE}: ${OBJS} ${NAMED_OBJS} ${LIBBIND} Makefile
${CC} ${CDEBUG} ${LDFLAGS} ${BOUNDS} -o ${PROG}${EXE} ${OBJS} ${NAMED_OBJS} \
${LIBBIND} ${SYSLIBS}
.c.${O}:
${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} -c $*.c
distclean: clean
clean: FRC
rm -f ${PROG}${EXE} ${OBJS} core .depend
rm -f *.BAK *.CKP *~ *.orig
depend: ${SRCS}
mkdep ${CPPFLAGS} -I${INCL} -I${PORTINCL} ${SRCS}
${DESTDIR}${DESTEXEC}:
mkdir -p ${DESTDIR}${DESTEXEC}
install: ${DESTDIR}${DESTEXEC} ${PROG}${EXE}
${INSTALL} ${STRIP} -c ${INSTALL_EXEC} -m 755 ${PROG}${EXE} ${DESTDIR}${DESTEXEC}/${PROG}${EXE}
links: FRC
@set -e; ln -s SRC/*.[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.
File diff suppressed because it is too large. Load diff
-134
View File
@@ -1,134 +0,0 @@
## Copyright (c) 1996-2000 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.51 2000/12/23 08:02:53 vixie Exp $
# $FreeBSD$
DESTDIR=
CC= cc
SHELL= /bin/sh
CDEBUG= -g -Wall
#(net2 and its descendents)
SYSTYPE = freebsd
TOP = ../..
INCL = ${TOP}/include
PORTINCL = ${TOP}/port/${SYSTYPE}/include
LIBBIND = ${TOP}/lib/libbind.a
A=a
O=o
EXE=
YACC = yacc -d
SYSLIBS = -ll -lutil
DESTBIN = /usr/local/bin
DESTSBIN = /usr/local/sbin
DESTEXEC = /usr/local/libexec
DESTMAN = /usr/share/man
DESTHELP= /usr/share/misc
DESTETC= /etc
DESTRUN= /var/run
AR= ar cru
INSTALL= install
STRIP=-s
INSTALL_EXEC=
INSTALL_LIB=-o bin -g bin
PS=ps
LDFLAGS=
CFLAGS= ${CDEBUG}
CPPFLAGS= -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 db_ixfr.c db_sec.c db_tsig.c \
ns_parser.c ns_lexer.c ns_parseutil.c ns_ctl.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 ns_ixfr.c ns_signal.c \
ns_sort.c ns_notify.c
OBJS= db_dump.${O} db_load.${O} db_lookup.${O} db_save.${O} db_update.${O} \
db_glue.${O} db_ixfr.${O} db_sec.${O} db_tsig.${O} \
ns_parser.${O} ns_lexer.${O} ns_parseutil.${O} ns_ctl.${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} ns_ixfr.${O} ns_signal.${O} \
ns_sort.${O} ns_notify.${O}
all: ${PROG}${EXE}
${PROG}${EXE}: pathnames.h ${OBJS} ${LIBBIND} Makefile tmp_version.${O}
${CC} ${CDEBUG} ${LDFLAGS} ${BOUNDS} -o ${PROG}${EXE} ${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); sleep 1
pathnames.h: ${TOP}/.settings Makefile pathtemplate.h
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
ns_signal.${O}: ns_signal.c
${CC} ${CPPFLAGS} ${CFLAGS} -c $*.c
.c.${O}:
${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} -c $*.c
distclean: clean
rm -f ns_parser.c ns_parser.h
clean: FRC
rm -f ${PROG}${EXE} ${OBJS} core .depend
rm -f *.BAK *.CKP *~ *.orig
rm -f tmp_version.c tmp_version.${O}
rm -f pathnames.h 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}${EXE}
${INSTALL} ${STRIP} -c ${INSTALL_EXEC} -m 755 ${PROG}${EXE} ${DESTDIR}${DESTSBIN}/${PROG}${EXE}
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.
-341
View File
@@ -1,341 +0,0 @@
/*
* from db.h 4.16 (Berkeley) 6/1/90
* $Id: db_defs.h,v 8.48 2002/11/17 14:51:50 marka 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-2000 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.
*/
/* max length of data in RR data field */
#define MAXDATA (3*MAXDNAME + 5*INT32SZ)
/* max length of data in a TXT RR segment */
#define MAXCHARSTRING 255
#define DB_ROOT_TIMBUF 3600
#define TIMBUF 300
#define DICT_INDEXBITS 24
#define DICT_MAXLENGTH 127
#define DICT_INSERT_P 0x0001
/* Average hash chain depths. */
#define AVGCH_MARSHAL 5
#define AVGCH_NLOOKUP 3
/* Nonstandard maximum class to force better packing. */
#define ZONE_BITS 24
#define CLASS_BITS 8
#define ZONE_MAX ((1<<ZONE_BITS)-1)
#define CLASS_MAX ((1<<CLASS_BITS)-1)
/*
* Hash table structures.
*/
/*
* XXX
* For IPv6 transport support we need a seperate reference counted
* database of source addresses and d_addr should become a union with
* a pointer into that database. A bit can be robbed from d_rode to
* indicate what the union is being used for. This should require less
* memory than making d_addr a union of struct in6_addr and struct in_addr.
*/
#ifdef CHECK_MAGIC
#define DATABUF_MAGIC (('D'<<24)|('A'<<16)|('T'<<8)|'A')
#endif
struct databuf {
#ifdef CHECK_MAGIC
u_int32_t d_magic; /* magic number */
#endif
struct databuf *d_next; /* linked list */
struct in_addr d_addr; /* 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
* master and slave zones),
* d_ttl is the time to live.
*/
unsigned d_zone :ZONE_BITS; /* zone number or 0 for the cache */
unsigned d_class :CLASS_BITS; /* class number (nonstandard limit) */
unsigned d_flags :4; /* DB_F_{??????} */
unsigned d_secure :2; /* DB_S_{??????} */
unsigned d_cred :3; /* DB_C_{??????} */
unsigned d_clev :6;
unsigned d_rcode :4; /* rcode for negative caching */
unsigned d_mark :3; /* place to mark data */
unsigned d_noedns :1; /* this server does not support edns */
int16_t d_type; /* type number */
int16_t d_size; /* size of data area */
u_int32_t d_rcnt;
#ifdef HITCOUNTS
u_int32_t d_hitcnt; /* Number of requests for this data. */
#endif /* HITCOUNTS */
u_int16_t d_nstime; /* NS response time, milliseconds */
u_char d_data[sizeof(void*)]; /* dynamic (padded) */
};
#define BIND_DATASIZE(n) (sizeof(struct databuf) - sizeof(void*) + n)
#ifdef HITCOUNTS
extern u_int32_t db_total_hits;
#endif /* HITCOUNTS */
#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 */
#define DB_F_LAME 0x08 /* databuf may refer to lame server */
/*
* 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 */
/*
* d_secure definitions
*/
#define DB_S_SECURE 2 /* secure (verified) data */
#define DB_S_INSECURE 1 /* insecure data */
#define DB_S_FAILED 0 /* data that failed a security check */
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 */
union {
char _n_name[sizeof(void*)];
unsigned char _n_len[sizeof(void*)];
} _n; /* Counted str (dynamic). */
};
#define NAMESIZE(n) (sizeof(struct namebuf) - sizeof(void*) + 1 + n + 1)
#define NAMELEN(nb) ((((nb)._n._n_len))[0])
#define NAME(nb) ((nb)._n._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
#define HASHROTATE(v) \
(((v) << HASHSHIFT) | ((v) >> ((sizeof(v) * 8) - HASHSHIFT)))
#define HASHLOWER(c) ((isascii(c) && isupper(c)) ? tolower(c) : (c))
#define HASHIMILATE(v,c) ((v) = (HASHROTATE(v)) + (HASHLOWER(c) & HASHMASK))
#define TSIG_BUF_SIZE 640
#define TSIG_SIG_SIZE 20
struct tsig_record {
u_int8_t sig[TSIG_SIG_SIZE];
struct dst_key *key;
int siglen;
int tsig_size;
};
struct sig_record {
u_int16_t sig_type_n;
u_int8_t sig_alg_n, sig_labels_n;
u_int32_t sig_ottl_n, sig_exp_n, sig_time_n;
u_int16_t sig_keyid_n;
};
/* This is the wire format size of "struct sig_record", i.e., no padding. */
#define SIG_HDR_SIZE 18
struct dnode {
struct databuf *dp;
struct dnode *dn_next;
int line;
const char *file;
};
typedef struct dnode * dlist;
struct db_rrset {
dlist rr_list;
dlist rr_sigs;
char *rr_name;
int16_t rr_class;
int16_t rr_type;
struct db_rrset *rr_next;
};
#define DBHASHSIZE(s) (sizeof(struct hashbuf) + \
(s-1) * sizeof(struct db_rrset *))
#define SIG_COVERS(dp) (ns_get16(dp->d_data))
/*
* 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_MERGE 0x40 /* make no control on rr in db_update (for ixfr) */
#define DB_REPLACE 0x80 /* replace data if it exists */
#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
#define CNAMEANDOTHER (-12)
#define DNSSECFAIL (-13) /* db_set_update */
#define NONGLUE (-14)
/*
* 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 */
/*
* db_load() options
*/
#define ISNOTIXFR 0
#define ISIXFR 1
#define ISAXFRIXFR 2
/*
* Database access abstractions.
*/
#define foreach_rr(dp, np, ty, cl, zn) \
for ((dp) = (np)->n_data; (dp) != NULL; (dp) = (dp)->d_next) \
if (!match(dp, (cl), (ty))) \
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)
#define ISVALIDGLUE(xdp) ((xdp)->d_type == T_NS || (xdp)->d_type == T_A \
|| (xdp)->d_type == T_AAAA || (xdp)->d_type == ns_t_a6)
-702
View File
@@ -1,702 +0,0 @@
#if !defined(lint) && !defined(SABER)
static const char sccsid[] = "@(#)db_dump.c 4.33 (Berkeley) 3/3/91";
static const char rcsid[] = "$Id: db_dump.c,v 8.51 2001/06/18 14:42:49 marka 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-2000 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/un.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 <isc/misc.h>
#include "port_after.h"
#include "named.h"
#ifdef HITCOUNTS
u_int32_t db_total_hits;
#endif /* HITCOUNTS */
static const char *MkCredStr(int);
static int fwd_dump(FILE *fp);
/*
* Dump current data base in a format similar to RFC 883.
*/
void
doadump(void) {
FILE *fp;
ns_notice(ns_log_db, "dumping nameserver data");
if ((fp = write_open(server_options->dump_filename)) == NULL)
return;
gettime(&tt);
#ifdef HITCOUNTS
if (NS_OPTION_P(OPTION_HITCOUNT))
fprintf(fp, "; Total hits: %d\n",db_total_hits);
#endif /* HITCOUNTS */
fprintf(fp, "; Dumped at %s", ctimel(tt.tv_sec));
if (zones != NULL && nzones != 0)
zt_dump(fp);
if (fwddata != NULL && fwddata_count != 0)
fwd_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[0]; zp < &zones[nzones]; zp++) {
const char *pre;
char 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, xaddrcnt=%d, state=%04x, pid=%d\n",
(u_long)zp->z_ftime, zp->z_xaddrcnt,
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, ";\tupdate source [%s]\n",
inet_ntoa(zp->z_axfr_src));
}
fprintf(fp, ";; --zone table--\n");
return (0);
}
static int
fwd_dump(FILE *fp) {
int i;
fprintf(fp, ";; ++forwarders table++\n");
for (i = 0; i < fwddata_count; i++) {
if (fwddata[i] != NULL)
fprintf(fp,"; %s rtt=%d\n",
inet_ntoa(fwddata[i]->fwdaddr.sin_addr),
fwddata[i]->nsdata->d_nstime);
}
fprintf(fp, ";; --forwarders table--\n");
return (0);
}
int
db_dump(struct hashbuf *htp, FILE *fp, int zone, const char *origin) {
struct databuf *dp = NULL;
struct namebuf *np;
struct namebuf **npp, **nppend;
char dname[MAXDNAME];
u_int32_t n;
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, *certdata;
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)
fprintf(fp, "%u\t", dp->d_ttl);
else
fprintf(fp, "%u\t",
zones[dp->d_zone].z_minimum);
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);
n = *cp++;
fprintf(fp, "\"%.*s\"", (int)n, cp);
cp += n;
n = *cp++;
fprintf(fp, "\"%.*s\"", (int)n, cp);
cp += n;
n = *cp++;
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) */
fprintf(fp, "%d ", *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;
case ns_t_cert:
certdata = cp;
NS_GET16(n,cp);
fprintf(fp, "%d ", n); /* cert type */
NS_GET16(n,cp);
fprintf(fp, "%d %d ", n, *cp++); /* tag & alg */
/* Certificate (base64 of any length) */
i = b64_ntop(cp,
dp->d_size - (cp - certdata),
temp_base64, sizeof(temp_base64));
if (i < 0)
fprintf(fp, "; BAD BASE64");
else
fprintf(fp, "%s", temp_base64);
break;
default:
fprintf(fp, "\\# %u", dp->d_size);
if (dp->d_size != 0) {
fputs(" ( ", fp);
isc_puthexstring(fp, dp->d_data,
dp->d_size, 40, 48,
"\n\t\t\t\t");
fputs(" ) ", fp);
}
}
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 = " ";
}
if ((dp->d_flags & DB_F_LAME) != 0) {
time_t when;
getname(np, dname, sizeof(dname));
when = db_lame_find(dname, dp);
if (when != 0 && when > tt.tv_sec) {
fprintf(fp, "%sLAME=%ld",
sep, when - tt.tv_sec);
sep = " ";
}
}
eoln:
if (dp->d_addr.s_addr != htonl(0)) {
fprintf(fp, "%s[%s]",
sep, inet_ntoa(dp->d_addr));
sep = " ";
}
#ifdef HITCOUNTS
if (NS_OPTION_P(OPTION_HITCOUNT)) {
fprintf(fp, "%shits=%d", sep, dp->d_hitcnt);
sep=" ";
}
#endif /* HITCOUNTS */
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);
}
-211
View File
@@ -1,211 +0,0 @@
/*
* 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-2000 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.
*/
/*
* Portions Copyright (c) 1999 by Check Point Software Technologies, Inc.
*
* 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 Check Point Software Technologies Incorporated 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 CHECK POINT SOFTWARE TECHNOLOGIES
* INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
* IN NO EVENT SHALL CHECK POINT SOFTWARE TECHNOLOGIES INCORPRATED
* 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.46 2001/06/18 14:42:51 marka Exp $
*/
/* ++from db_update.c++ */
int db_update(const char *name,
struct databuf *odp,
struct databuf *newdp,
struct databuf **savedpp,
int flags,
struct hashbuf *htp,
struct sockaddr_in from);
int db_cmp(const struct databuf *, const struct databuf *);
int findMyZone(struct namebuf *np, int class);
void fixttl(struct databuf *dp);
/* --from db_update.c-- */
/* ++from db_save.c++ */
struct namebuf * savename(const char *, int);
struct databuf * savedata(int, int, u_int32_t, u_char *, int);
struct hashbuf * savehash(struct hashbuf *);
/* --from db_save.c-- */
/* ++from db_dump.c++ */
int db_dump(struct hashbuf *, FILE *, int, const char *),
zt_dump(FILE *);
void doadump(void);
/* --from db_dump.c-- */
/* ++from db_load.c++ */
int makename_ok(char *name, const char *origin, int class,
struct zoneinfo *zp,
enum transport transport,
enum context context,
const char *owner, const char *filename,
int lineno, int size);
void endline(FILE *);
int getword(char *, size_t, FILE *, int);
int getttl(FILE *, const char *, int, u_int32_t *, int *);
int getnum(FILE *, const char *, int, int *);
int db_load(const char *, const char *, struct zoneinfo *,
const char *, int);
int getnonblank(FILE *, const char *, int);
int getservices(int, char *, FILE *, const char *);
char getprotocol(FILE *, const char *);
int makename(char *, const char *, int);
void db_err(int, char *, int, const char *, int);
int parse_sec_rdata(char *inp, int inp_len, int inp_full,
u_char *data, int data_len,
FILE *fp, struct zoneinfo *zp,
char *domain, u_int32_t ttl,
int type, enum context context,
enum transport transport,
const char **errmsg);
/* --from db_load.c-- */
/* ++from db_glue.c++ */
void buildservicelist(void);
void destroyservicelist(void);
void buildprotolist(void);
void destroyprotolist(void);
void getname(struct namebuf *, char *, int);
int servicenumber(const char *);
int protocolnumber(const char *);
int get_class(const char *);
u_int nhash(const char *);
const char * protocolname(int);
const char * servicename(u_int16_t, const char *);
struct databuf * rm_datum(struct databuf *,
struct namebuf *,
struct databuf *,
struct databuf **);
struct namebuf * rm_name(struct namebuf *,
struct namebuf **,
struct namebuf *);
void rm_hash(struct hashbuf *);
void db_detach(struct databuf **);
void db_lame_add(char *zone, char *server, time_t when);
time_t db_lame_find(char *zone, struct databuf *dp);
void db_lame_clean(void);
void db_lame_destroy(void);
/* --from db_glue.c-- */
/* ++from db_lookup.c++ */
struct namebuf * nlookup(const char *, struct hashbuf **,
const char **, int);
struct namebuf * np_parent(struct namebuf *);
int match(struct databuf *, int, int),
nxtmatch(const char *, struct databuf *,
struct databuf *),
rrmatch(const char *, struct databuf *,
struct databuf *);
/* --from db_lookup.c-- */
/* ++from db_ixfr.c++ */
ns_deltalist * ixfr_get_change_list(struct zoneinfo *, u_int32_t,
u_int32_t);
int ixfr_have_log(struct zoneinfo *, u_int32_t,
u_int32_t);
/* --from db_ixfr.c++ */
/* ++from db_sec.c++ */
int add_trusted_key(const char *name, const int flags,
const int proto, const int alg,
const char *str);
int db_set_update(char *name, struct databuf *dp,
void **state, int flags,
struct hashbuf **htp,
struct sockaddr_in from,
int *rrcount, int line,
const char *file);
/* --from db_sec.c-- */
/* ++from db_tsig.c++ */
const char * tsig_alg_name(int value);
int tsig_alg_value(char *name);
struct dst_key * tsig_key_from_addr(struct in_addr addr);
struct tsig_record * new_tsig(struct dst_key *key, u_char *sig, int siglen);
void free_tsig(struct tsig_record *tsig);
/* --from db_tsig.c-- */
-104
View File
@@ -1,104 +0,0 @@
/*
* from db.h 4.16 (Berkeley) 6/1/90
* $Id: db_glob.h,v 8.14 2000/04/21 06:54:02 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-2000 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 INIT(0);
/* root hash table */
DECL struct hashbuf *hashtab INIT(NULL);
/* hash table of cache read from file */
DECL struct hashbuf *fcachetab INIT(NULL);
/* state of ns_reload() and ns_reconfig(). */
DECL int reloading INIT(0);
DECL int reconfiging INIT(0);
DECL int noexpired INIT(0);
DECL const int hashsizes[]
#ifdef MAIN_PROGRAM
= { 2, 11, 113, 337, 977, 2053, 4073, 8011, 16001, 99887, 0 }
#endif
;
-642
View File
@@ -1,642 +0,0 @@
#if !defined(lint) && !defined(SABER)
static const char sccsid[] = "@(#)db_glue.c 4.4 (Berkeley) 6/1/90";
static const char rcsid[] = "$Id: db_glue.c,v 8.47 2002/05/18 01:02:54 marka 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-2000 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 <sys/socket.h>
#include <sys/un.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;
slp->name = freestr(slp->name);
slp->proto = freestr(slp->proto);
memput(slp, sizeof *slp);
}
servicelist = NULL;
}
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;
plp->name = freestr(plp->name);
memput(plp, sizeof *plp);
}
protolist = NULL;
}
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;
if (savedpp != NULL) {
/* mark deleted or pending deletion */
dp->d_mark |= D_MARK_DELETED;
dp->d_next = *savedpp;
DRCNTINC(dp);
*savedpp = dp;
} else
dp->d_next = NULL;
dp->d_flags &= ~DB_F_ACTIVE;
db_detach(&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 != NULL && (msg = "data") != NULL)
|| (np->n_hash != NULL && (msg = "hash") != NULL)
) {
ns_panic(ns_log_db, 1, "rm_name(%p(%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) {
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';
}
/* u_int
* nhash(name)
* compute hash for this name and return it; ignore case differences
* note:
* this logic is intended to produce the same result as nlookup()'s.
*/
u_int
nhash(const char *name) {
u_char ch;
u_int hval;
hval = 0;
while ((ch = (u_char)*name++) != (u_char)'\0')
HASHIMILATE(hval, ch);
return (hval);
}
static void
db_freedata(struct databuf *dp) {
int bytes = BIND_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;
#ifdef CHECK_MAGIC
dp->d_magic = 0;
#endif
memput(dp, bytes);
}
void
db_detach(struct databuf **dpp) {
struct databuf *dp;
INSIST(dpp != NULL && *dpp != NULL);
dp = *dpp;
#ifdef CHECK_MAGIC
INSIST(dp->d_magic == DATABUF_MAGIC);
#endif
DRCNTDEC(dp);
if (dp->d_rcnt == 0)
db_freedata(dp);
*dpp = NULL;
}
struct lame_hash {
struct lame_hash *next;
char *zone;
char *server;
time_t when;
unsigned int hval;
} **lame_hash = NULL;
static int lame_hash_size = 0;
static int lame_hash_cnt = 0;
void
db_lame_add(char *zone, char *server, time_t when) {
unsigned int hval = nhash(zone);
struct lame_hash *last, *this;
struct lame_hash **new;
int n;
int newsize;
db_lame_clean();
/* grow / initalise hash table */
if (lame_hash_cnt >= lame_hash_size) {
if (lame_hash_size == 0)
newsize = hashsizes[0];
else {
for (n = 0; (newsize = hashsizes[n++]) != 0; (void)NULL)
if (lame_hash_size == newsize) {
newsize = hashsizes[n];
break;
}
if (newsize == 0)
newsize = lame_hash_size * 2 + 1;
}
new = memget(newsize * sizeof this);
if (new == NULL)
return;
memset(new, 0, newsize * sizeof this);
for (n = 0 ; n < lame_hash_size; n++) {
this = lame_hash[n];
while (this) {
last = this;
this = this->next;
last->next = new[hval%newsize];
new[hval%newsize] = last;
}
}
if (lame_hash != NULL)
memput(lame_hash, lame_hash_size * sizeof this);
lame_hash = new;
lame_hash_size = newsize;
}
last = NULL;
this = lame_hash[hval%lame_hash_size];
while (this) {
if ((ns_samename(this->server, server) == 1) &&
(ns_samename(this->zone, zone) == 1)) {
this->when = when;
return;
}
last = this;
this = this->next;
}
this = memget(sizeof *this);
if (this == NULL)
return;
this->server = savestr(server, 0);
this->zone = savestr(zone, 0);
if (this->server == NULL || this->zone == NULL) {
if (this->server != NULL)
this->server = freestr(this->server);
if (this->zone != NULL)
this->zone = freestr(this->zone);
memput(this, sizeof *this);
return;
}
this->when = when;
this->hval = hval;
this->next = NULL;
if (last != NULL)
last->next = this;
else
lame_hash[hval%lame_hash_size] = this;
lame_hash_cnt++;
}
time_t
db_lame_find(char *zone, struct databuf *dp) {
unsigned int hval = nhash(zone);
struct lame_hash *this;
if (lame_hash_size == 0) {
/* db_lame_destroy() must have been called. */
dp->d_flags &= ~DB_F_LAME;
return (0);
}
db_lame_clean(); /* Remove expired record so that we can
* clear DB_F_LAME when there are no
* additions. */
this = lame_hash[hval % lame_hash_size];
while (this) {
if ((ns_samename(this->server, (char*)dp->d_data) == 1) &&
(ns_samename(this->zone, zone) == 1))
return (this->when);
this = this->next;
}
dp->d_flags &= ~DB_F_LAME;
return (0);
}
void
db_lame_clean(void) {
int i;
struct lame_hash *last, *this;
for (i = 0 ; i < lame_hash_size; i++) {
last = NULL;
this = lame_hash[i];
while (this != NULL) {
if (this->when < tt.tv_sec) {
this->zone = freestr(this->zone);
this->server = freestr(this->server);
if (last != NULL) {
last->next = this->next;
memput(this, sizeof *this);
this = last->next;
} else {
lame_hash[i] = this->next;
memput(this, sizeof *this);
this = lame_hash[i];
}
lame_hash_cnt--;
} else {
last = this;
this = this->next;
}
}
}
}
void
db_lame_destroy(void) {
int i;
struct lame_hash *last, *this;
if (lame_hash_size == 0)
return;
for (i = 0 ; i < lame_hash_size; i++) {
this = lame_hash[i];
while (this != NULL) {
last = this;
this = this->next;
last->zone = freestr(last->zone);
last->server = freestr(last->server);
memput(last, sizeof *this);
}
}
memput(lame_hash, lame_hash_size * sizeof this);
lame_hash_cnt = 0;
lame_hash_size = 0;
lame_hash = NULL;
}
-984
View File
@@ -1,984 +0,0 @@
#if !defined(lint) && !defined(SABER)
static char rcsid[] = "$Id: db_ixfr.c,v 8.32 2002/07/08 06:26:04 marka Exp $";
#endif
/*
* Portions Copyright (c) 1999 by Check Point Software Technologies, Inc.
*
* 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 Check Point Software Technologies Incorporated 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 CHECK POINT SOFTWARE TECHNOLOGIES
* INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
* IN NO EVENT SHALL CHECK POINT SOFTWARE TECHNOLOGIES INCORPRATED
* 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.
*/
/*
* Manage ixfr transaction log
*/
#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 <ctype.h>
#include <errno.h>
#include <netdb.h>
#include <resolv.h>
#include <res_update.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/misc.h>
#include "port_after.h"
#include "named.h"
#define DBIXFR_ERROR (-1)
#define DBIXFR_FOUND_RR 2
#define DBIXFR_END 3
static int ixfr_getdelta(struct zoneinfo *, FILE *, const char *, char *,
ns_updque *, u_int32_t *, u_int32_t *);
ns_deltalist *
ixfr_get_change_list(struct zoneinfo *zp,
u_int32_t from_serial, u_int32_t to_serial)
{
FILE * fp = NULL;
u_int32_t old_serial, new_serial;
char origin[MAXDNAME];
ns_deltalist *dlhead = NULL;
int ret;
ns_updrec *uprec;
ns_delta *dl;
if (SEQ_GT(from_serial, to_serial))
return (NULL);
dlhead = memget(sizeof(*dlhead));
if (dlhead == NULL)
return (NULL);
INIT_LIST(*dlhead);
if ((fp = fopen(zp->z_ixfr_base, "r")) == NULL) {
ns_warning(ns_log_db, "%s: %s",
zp->z_ixfr_base, strerror(errno));
goto cleanup;
}
strcpy(origin, zp->z_origin);
lineno = 1;
old_serial = new_serial = 0;
for (;;) {
dl = memget(sizeof *dl);
if (dl == NULL) {
ns_warning(ns_log_db,
"ixfr_get_change_list: out of memory");
goto cleanup;
}
INIT_LINK(dl, d_link);
INIT_LIST(dl->d_changes);
ret = ixfr_getdelta(zp, fp, zp->z_ixfr_base, origin,
&dl->d_changes, &old_serial, &new_serial);
switch (ret) {
case DBIXFR_ERROR:
ns_warning(ns_log_db, "Logical error in %s: unlinking",
zp->z_ixfr_base);
if (fp != NULL) {
(void) my_fclose(fp);
fp = NULL;
}
unlink(zp->z_ixfr_base);
goto cleanup;
case DBIXFR_FOUND_RR:
ns_debug(ns_log_default, 4,
"ixfr_getdelta DBIXFR_FOUND_RR (%s)",
zp->z_origin);
if (EMPTY(*dlhead)) {
/* skip updates prior to the one we want */
uprec = HEAD(dl->d_changes);
INSIST(uprec != NULL);
if (SEQ_LT(uprec->r_zone, from_serial) ||
SEQ_GT(uprec->r_zone, to_serial))
{
while ((uprec = HEAD(dl->d_changes)) != NULL) {
UNLINK(dl->d_changes, uprec, r_link);
if (uprec->r_dp != NULL)
db_detach(&uprec->r_dp);
res_freeupdrec(uprec);
}
memput(dl, sizeof *dl);
break;
}
else if (uprec->r_zone > from_serial) {
/* missed the boat */
ns_debug(ns_log_default, 3,
"ixfr_getdelta first SOA is %d, asked for %d (%s)",
uprec->r_zone,
from_serial,
zp->z_origin);
goto cleanup;
}
}
ns_debug(ns_log_default, 4,
"adding to change list (%s)",
zp->z_origin);
APPEND(*dlhead, dl, d_link);
break;
case DBIXFR_END:
ns_debug(ns_log_default, 4,
"ixfr_getdelta DBIXFR_END (%s)",
zp->z_origin);
(void) my_fclose(fp);
memput(dl, sizeof *dl);
return (dlhead);
default:
(void) my_fclose(fp);
if (dl != NULL)
memput(dl, sizeof *dl);
return (NULL);
}
}
cleanup:
if (fp != NULL)
(void) my_fclose(fp);
while ((dl = HEAD(*dlhead)) != NULL) {
UNLINK(*dlhead, dl, d_link);
while ((uprec = HEAD(dl->d_changes)) != NULL) {
UNLINK(dl->d_changes, uprec, r_link);
if (uprec->r_dp != NULL)
db_detach(&uprec->r_dp);
uprec->r_dp = NULL;
res_freeupdrec(uprec);
}
memput(dl, sizeof *dl);
}
memput(dlhead, sizeof *dlhead);
return (NULL);
}
/*
* int ixfr_have_log(struct zoneinfo *zp,u_int32_t from_serial,
* u_int32_t to_serial)
*
* verify that ixfr transaction log contains changes
* from from_serial to to_serial
*
* returns:
* 0 = serial number is up to date
* 1 = transmission is possible
* -1 = error while opening the ixfr transaction log
* -2 = error in parameters
* -3 = logical error in the history file
*/
int
ixfr_have_log(struct zoneinfo *zp, u_int32_t from_serial, u_int32_t to_serial)
{
FILE *fp;
u_int32_t old_serial = 0, new_serial = 0;
u_int32_t last_serial = 0;
u_int32_t first_serial = 0;
char buf[BUFSIZ];
char *cp;
struct stat st;
int nonempty_lineno = -1, prev_pktdone = 0, cont = 0,
inside_next = 0;
int err;
int first = 0;
int rval = 0;
int id, rcode = NOERROR;
if (SEQ_GT(from_serial, to_serial))
return (-2);
if (from_serial == to_serial)
return (0);
/* If there is no log file, just return. */
if (zp->z_ixfr_base == NULL || zp->z_updatelog == NULL)
return (-1);
if (zp->z_serial_ixfr_start > 0) {
if (from_serial >= zp->z_serial_ixfr_start)
return (1);
}
if (stat(zp->z_ixfr_base, &st) < 0) {
if (errno != ENOENT)
ns_error(ns_log_db,
"unexpected stat(%s) failure: %s",
zp->z_ixfr_base, strerror(errno));
return (-1);
}
if ((fp = fopen(zp->z_ixfr_base, "r")) == NULL) {
ns_warning(ns_log_db, "%s: %s",
zp->z_ixfr_base, strerror(errno));
return (-1);
}
if (fgets(buf, sizeof(buf), fp) == NULL) {
ns_error(ns_log_update, "fgets() from %s failed: %s",
zp->z_ixfr_base, strerror(errno));
fclose(fp);
return (-1);
}
if (strcmp(buf, LogSignature) != 0) {
ns_error(ns_log_update, "invalid log file %s",
zp->z_ixfr_base);
fclose(fp);
return (-3);
}
lineno = 1;
first = 1;
for (;;) {
if (getword(buf, sizeof buf, fp, 0)) {
nonempty_lineno = lineno;
} else {
if (lineno == (nonempty_lineno + 1))
continue;
inside_next = 0;
prev_pktdone = 1;
cont = 1;
}
if (!strcasecmp(buf, "[DYNAMIC_UPDATE]") ||
!strcasecmp(buf, "[IXFR_UPDATE]")) {
err = 0;
rcode = NOERROR;
cp = fgets(buf, sizeof buf, fp);
if (cp != NULL)
lineno++;
if (cp == NULL || !sscanf((char *) cp, "id %d", &id))
id = -1;
inside_next = 1;
prev_pktdone = 1;
cont = 1;
} else if (!strcasecmp(buf, "serial")) {
cp = fgets(buf, sizeof buf, fp);
if (cp != NULL)
lineno++;
if (sscanf((char *) cp, "%u", &old_serial)) {
if (first == 1) {
first = 0;
first_serial = old_serial;
}
last_serial = old_serial;
if (from_serial >= old_serial) {
rval = 1;
}
}
prev_pktdone = 1;
cont = 1;
} else if (!strcasecmp(buf, "[INCR_SERIAL]")) {
/* XXXRTH not enough error checking here */
cp = fgets(buf, sizeof buf, fp);
if (cp != NULL)
lineno++;
if (cp == NULL ||
sscanf((char *) cp, "from %u to %u",
&old_serial, &new_serial) != 2) {
rval = -3;
break;
} else if (from_serial >= old_serial) {
if (first == 1) {
first = 0;
first_serial = old_serial;
}
last_serial = old_serial;
rval = 1;
}
}
if (prev_pktdone) {
prev_pktdone = 0;
if (feof(fp))
break;
}
}
fclose(fp);
if (last_serial +1 < zp->z_serial) {
ns_warning(ns_log_db,
"%s: File Deleted. Found gap between serial:"
" %d and current serial: %d",
zp->z_ixfr_base, last_serial, zp->z_serial);
(void) unlink(zp->z_ixfr_base);
rval = -3;
}
if (from_serial < first_serial || from_serial > last_serial)
rval = -3;
if (rval == 1)
zp->z_serial_ixfr_start = first_serial;
return (rval);
}
/* from db_load.c */
static struct map m_section[] = {
{"zone", S_ZONE},
{"prereq", S_PREREQ},
{"update", S_UPDATE},
{"reserved", S_ADDT},
};
#define M_SECTION_CNT (sizeof(m_section) / sizeof(struct map))
/* from ns_req.c */
static struct map m_opcode[] = {
{"nxdomain", NXDOMAIN},
{"yxdomain", YXDOMAIN},
{"nxrrset", NXRRSET},
{"yxrrset", YXRRSET},
{"delete", DELETE},
{"add", ADD},
};
#define M_OPCODE_CNT (sizeof(m_opcode) / sizeof(struct map))
/* XXXRTH workaround map difficulties */
#define M_CLASS_CNT m_class_cnt
#define M_TYPE_CNT m_type_cnt
/*
* read a line from the history of a zone.
*
* returns:
*
* DBIXFR_ERROR = an error occured
* DBIXFR_FOUND_RR = a rr encountered
* DBIXFR_END = end of file
*/
static int
ixfr_getdelta(struct zoneinfo *zp, FILE *fp, const char *filename, char *origin,
ns_updque *listuprec, u_int32_t *old_serial,
u_int32_t *new_serial)
{
char data[MAXDATA], dnbuf[MAXDNAME], sclass[3];
char *dname, *cp, *cp1;
char buf[MAXDATA];
long unsigned lutmp;
u_int32_t serial = 0, ttl;
u_int32_t current_serial = 0;
int nonempty_lineno = -1, prev_pktdone = 0, cont = 0,
inside_next = 0;
int id;
int i, c, section, opcode, matches, zonenum, err, multiline;
int type, class;
u_int32_t n;
enum transport transport;
struct map *mp;
int zonelist[MAXDNAME];
struct in_addr ina;
int datasize;
ns_updrec * rrecp;
u_long l;
#define ERRTO(msg) if (1) { errtype = msg; goto err; } else (void)NULL
err = 0;
transport = primary_trans;
lineno = 1;
zonenum = 0;
/*
* Look for serial if "first" call othewise use new_serial to
* for current_serial.
*/
if (*old_serial == *new_serial && *old_serial == 0)
current_serial = 0;
else
current_serial = *new_serial;
for (;;) {
dname = NULL;
if (!getword(buf, sizeof buf, fp, 0)) {
if (lineno == (nonempty_lineno + 1) && !(feof(fp))) {
/*
* End of a nonempty line inside an update
* packet or not inside an update packet.
*/
continue;
}
/*
* Empty line or EOF.
*/
if (feof(fp))
break;
inside_next = 0;
cont = 1;
} else {
nonempty_lineno = lineno;
}
if (!strcasecmp(buf, "[DYNAMIC_UPDATE]") ||
!strcasecmp(buf, "[IXFR_UPDATE]")) {
cp = fgets(buf, sizeof buf, fp);
if (cp != NULL)
lineno++;
if (cp == NULL || !sscanf((char *) cp, "id %d", &id))
id = -1;
inside_next = 1;
cont = 1;
} else if (!strcasecmp(buf, "[INCR_SERIAL]")) {
/* XXXRTH not enough error checking here */
cp = fgets(buf, sizeof buf, fp);
if (cp != NULL)
lineno++;
if (cp == NULL ||
sscanf((char *) cp, "from %u to %u",
old_serial, new_serial) != 2) {
ns_error(ns_log_update,
"incr_serial problem with %s",
zp->z_updatelog);
} else {
serial = get_serial(zp);
}
cont = 1;
} else if (!strcasecmp(buf, "[END_DELTA]")) {
prev_pktdone = 1;
cont = 1;
lineno++;
}
if (prev_pktdone) {
if (!EMPTY(*listuprec)) {
n++;
return (DBIXFR_FOUND_RR);
}
prev_pktdone = 0;
}
if (cont) {
cont = 0;
continue;
}
if (!inside_next)
continue;
/*
* inside the same update packet, continue accumulating
* records.
*/
section = -1;
n = strlen(buf);
if (buf[n - 1] == ':')
buf[--n] = '\0';
for (mp = m_section; mp < m_section + M_SECTION_CNT; mp++)
if (!strcasecmp(buf, mp->token)) {
section = mp->val;
break;
}
ttl = 0;
type = -1;
class = zp->z_class;
n = 0;
data[0] = '\0';
opcode = -1;
switch (section) {
case S_ZONE:
cp = fgets(buf, sizeof buf, fp);
if (!cp)
*buf = '\0';
n = sscanf(cp, "origin %s class %s serial %lu",
origin, sclass, &lutmp);
serial = lutmp;
if (current_serial == 0)
current_serial = serial;
else if (current_serial != serial) {
ns_debug(ns_log_update, 1,
"%s:line %d serial # askew %d %d",
filename, lineno, serial,
current_serial);
current_serial = serial;
err++;
}
if (n != 3 || ns_samename(origin, zp->z_origin) != 1)
err++;
if (cp)
lineno++;
if (!err && inside_next) {
int success;
dname = origin;
type = T_SOA;
class = res_nametoclass(sclass, &success);
if (!success) {
err++;
break;
}
matches = findzone(dname, class, 0,
zonelist, MAXDNAME);
if (matches)
zonenum = zonelist[0];
else
err++;
}
break;
case S_PREREQ:
case S_UPDATE:
/* Operation code. */
if (!getword(buf, sizeof buf, fp, 0)) {
err++;
break;
}
if (buf[0] == '{') {
n = strlen(buf);
for (i = 0; (u_int32_t) i < n; i++)
buf[i] = buf[i + 1];
if (buf[n - 2] == '}')
buf[n - 2] = '\0';
}
for (mp = m_opcode; mp < m_opcode + M_OPCODE_CNT; mp++)
if (!strcasecmp(buf, mp->token)) {
opcode = mp->val;
break;
}
if (opcode == -1) {
err++;
break;
}
/* Owner's domain name. */
if (!getword((char *) dnbuf, sizeof dnbuf, fp, 0)) {
err++;
break;
}
n = strlen((char *) dnbuf) - 1;
if (dnbuf[n] == '.')
dnbuf[n] = '\0';
dname = dnbuf;
ttl = 0;
type = -1;
class = zp->z_class;
n = 0;
data[0] = '\0';
(void) getword(buf, sizeof buf, fp, 1);
if (isdigit(buf[0])) { /* ttl */
if (ns_parse_ttl(buf, &l) < 0) {
err++;
break;
}
ttl = l;
(void) getword(buf, sizeof buf, fp, 1);
}
/* possibly class */
if (buf[0] != '\0') {
int success;
int maybe_class;
maybe_class = res_nametoclass(buf, &success);
if (success) {
class = maybe_class;
(void) getword(buf, sizeof buf, fp, 1);
}
}
/* possibly type */
if (buf[0] != '\0') {
int success;
int maybe_type;
maybe_type = res_nametotype(buf, &success);
if (success) {
type = maybe_type;
(void) getword(buf, sizeof buf, fp, 1);
}
}
if (buf[0] != '\0') /* possibly rdata */
/*
* Convert the ascii data 'buf' to the proper
* format based on the type and pack into
* 'data'.
*
* XXX - same as in db_load(), consolidation
* needed
*/
switch (type) {
case T_A:
if (!inet_aton(buf, &ina)) {
err++;
break;
}
n = ntohl(ina.s_addr);
cp = data;
PUTLONG(n, cp);
n = INT32SZ;
break;
case T_HINFO:
case T_ISDN:
n = strlen(buf);
data[0] = n;
memcpy(data + 1, buf, n);
n++;
if (!getword(buf, sizeof buf, fp, 0)) {
i = 0;
} else {
endline(fp);
i = strlen(buf);
}
data[n] = i;
n++;
memcpy(data + n + 1, buf, i);
n += i;
break;
case T_SOA:
case T_MINFO:
case T_RP:
(void) strcpy(data, buf);
cp = data + strlen(data) + 1;
if (!getword((char *) cp,
sizeof data - (cp - data),
fp, 1)) {
err++;
break;
}
cp += strlen((char *) cp) + 1;
if (type != T_SOA) {
n = cp - data;
break;
}
if (class != zp->z_class ||
ns_samename(dname, zp->z_origin) != 1) {
err++;
break;
}
c = getnonblank(fp, zp->z_updatelog, 0);
if (c == '(') {
multiline = 1;
} else {
multiline = 0;
ungetc(c, fp);
}
n = getnum(fp, zp->z_updatelog, GETNUM_SERIAL,
&multiline);
if (getnum_error) {
err++;
break;
}
if (opcode == ADD)
*new_serial = n;
current_serial = n;
PUTLONG(n, cp);
for (i = 0; i < 4; i++) {
if (!getword(buf, sizeof buf, fp, 1)) {
err++;
break;
}
if (ns_parse_ttl(buf, &l) < 0) {
err++;
break;
}
n = l;
PUTLONG(n, cp);
}
if (multiline) {
c = getnonblank(fp, zp->z_updatelog, 1);
if (c != ')') {
ungetc(c, fp);
err++;
break;
}
}
endline(fp);
n = cp - data;
break;
case T_WKS:
if (!inet_aton(buf, &ina)) {
err++;
break;
}
n = ntohl(ina.s_addr);
cp = data;
PUTLONG(n, cp);
*cp = (char) getprotocol(fp, zp->z_updatelog);
n = INT32SZ + sizeof(char);
n = getservices((int) n, data,
fp, zp->z_updatelog);
break;
case T_NS:
case T_CNAME:
case T_MB:
case T_MG:
case T_MR:
case T_PTR:
(void) strcpy(data, buf);
if (makename(data, origin,
sizeof(data)) == -1) {
err++;
break;
}
n = strlen(data) + 1;
break;
case T_MX:
case T_AFSDB:
case T_RT:
n = 0;
cp = buf;
while (isdigit(*cp))
n = n * 10 + (*cp++ - '0');
/* catch bad values */
cp = data;
PUTSHORT((u_int16_t) n, cp);
if (!getword(buf, sizeof(buf), fp, 1)) {
err++;
break;
}
(void) strcpy((char *) cp, buf);
if (makename((char *) cp, origin,
sizeof(data) - (cp - data)) == -1)
{
err++;
break;
}
/* advance pointer to end of data */
cp += strlen((char *) cp) + 1;
/* now save length */
n = (cp - data);
break;
case T_PX:
n = 0;
data[0] = '\0';
cp = buf;
while (isdigit(*cp))
n = n * 10 + (*cp++ - '0');
cp = data;
PUTSHORT((u_int16_t) n, cp);
for (i = 0; i < 2; i++) {
if (!getword(buf, sizeof(buf), fp, 0))
{
err++;
break;
}
(void) strcpy((char *) cp, buf);
cp += strlen((char *) cp) + 1;
}
n = cp - data;
break;
case T_TXT:
case T_X25:
i = strlen(buf);
cp = data;
datasize = sizeof data;
cp1 = buf;
while (i > MAXCHARSTRING) {
if (datasize <= MAXCHARSTRING) {
ns_error(ns_log_update,
"record too big");
return (-1);
}
datasize -= MAXCHARSTRING;
*cp++ = (char)MAXCHARSTRING;
memcpy(cp, cp1, MAXCHARSTRING);
cp += MAXCHARSTRING;
cp1 += MAXCHARSTRING;
i -= MAXCHARSTRING;
}
if (datasize < i + 1) {
ns_error(ns_log_update,
"record too big");
return (-1);
}
*cp++ = i;
memcpy(cp, cp1, i);
cp += i;
n = cp - data;
endline(fp);
/* XXXVIX: segmented texts 4.9.5 */
break;
case T_NSAP:
n = inet_nsap_addr(buf, (u_char *) data,
sizeof data);
endline(fp);
break;
case T_LOC:
cp = buf + (n = strlen(buf));
*cp = ' ';
cp++;
while ((i = getc(fp), *cp = i, i != EOF)
&& *cp != '\n' && (n < MAXDATA))
{
cp++;
n++;
}
if (*cp == '\n')
ungetc(*cp, fp);
*cp = '\0';
n = loc_aton(buf, (u_char *) data);
if (n == 0) {
err++;
break;
}
endline(fp);
break;
case ns_t_sig:
case ns_t_nxt:
case ns_t_key:
case ns_t_cert:{
const char *errmsg = NULL;
n = parse_sec_rdata(buf, sizeof(buf), 1,
(u_char *) data,
sizeof(data),
fp, zp, dname, ttl,
type, domain_ctx,
transport, &errmsg);
if (errmsg) {
err++;
endline(fp);
n = 0;
}
break;
}
default:
if (strcmp(buf, "\\#") != 0) {
err++;
break;
}
if (!getword(buf, sizeof buf, fp, 0) ||
!isdigit((unsigned char)buf[0])) {
err++;
break;
}
errno = 0;
n = strtoul(buf, &cp, 10);
if (errno != 0 || n > 0xffff || *cp != '\0') {
err++;
break;
}
multiline = 0;
i = isc_gethexstring((u_char *)data,
sizeof(data), n, fp,
&multiline);
if (i == -1) {
err++;
break;
}
if (multiline) {
c = getnonblank(fp, zp->z_updatelog, 1);
if (c != ')') {
ungetc(c, fp);
err++;
break;
}
multiline = 0;
}
endline(fp);
}
if (section == S_PREREQ) {
ttl = 0;
if (opcode == NXDOMAIN) {
class = C_NONE;
type = T_ANY;
n = 0;
} else if (opcode == YXDOMAIN) {
class = C_ANY;
type = T_ANY;
n = 0;
} else if (opcode == NXRRSET) {
class = C_NONE;
n = 0;
} else if (opcode == YXRRSET) {
if (n == 0)
class = C_ANY;
}
} else {/* section == S_UPDATE */
if (opcode == DELETE) {
if (n == 0) {
class = C_ANY;
if (type == -1)
type = T_ANY;
} else {
class = zp->z_class;
}
}
}
break;
case S_ADDT:
default:
ns_debug(ns_log_update, 1,
"cannot interpret section: %d", section);
inside_next = 0;
err++;
}
if (err) {
inside_next = 0;
ns_debug(ns_log_update, 1,
"merge of update id %d failed due to error at line %d",
id, lineno);
return (DBIXFR_ERROR);
}
rrecp = res_mkupdrec(section, dname, class, type, ttl);
if (section != S_ZONE) {
struct databuf *dp;
dp = savedata(class, type, ttl, (u_char *) data, n);
dp->d_zone = zonenum;
dp->d_cred = DB_C_ZONE;
dp->d_clev = nlabels(zp->z_origin);
rrecp->r_dp = dp;
rrecp->r_opcode = opcode;
} else {
rrecp->r_zone = zonenum;
rrecp->r_opcode = opcode;
}
/* remove add/delete pairs */
if (section == S_UPDATE) {
ns_updrec *arp;
int foundmatch;
arp = TAIL(*listuprec);
foundmatch = 0;
while (arp) {
if (arp->r_section == S_UPDATE &&
((arp->r_opcode == DELETE &&
opcode == ADD) ||
(opcode == DELETE &&
arp->r_opcode == ADD)) &&
arp->r_dp->d_type == rrecp->r_dp->d_type &&
arp->r_dp->d_class == rrecp->r_dp->d_class &&
arp->r_dp->d_ttl == rrecp->r_dp->d_ttl &&
ns_samename(arp->r_dname, dname) == 1 &&
db_cmp(arp->r_dp, rrecp->r_dp) == 0) {
db_detach(&rrecp->r_dp);
db_detach(&arp->r_dp);
UNLINK(*listuprec, arp, r_link);
res_freeupdrec(arp);
res_freeupdrec(rrecp);
foundmatch = 1;
break;
}
arp = PREV(arp, r_link);
}
if (foundmatch)
continue;
}
APPEND(*listuprec, rrecp, r_link);
/* Override zone number with current zone serial number */
rrecp->r_zone = serial;
}
if (err)
return (DBIXFR_ERROR);
return (DBIXFR_END);
}
File diff suppressed because it is too large. Load diff
-341
View File
@@ -1,341 +0,0 @@
#if !defined(lint) && !defined(SABER)
static const char sccsid[] = "@(#)db_lookup.c 4.18 (Berkeley) 3/21/91";
static const char rcsid[] = "$Id: db_lookup.c,v 8.27 2001/06/18 14:42:55 marka 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-2000 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 <sys/un.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;
}
HASHIMILATE(hval, c);
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 * AVGCH_NLOOKUP)) {
*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_axfr.c
*/
struct namebuf *
np_parent(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 != NULL; np = np->n_next) {
if (NAME(*np)[0] == '\0')
/* found the root namebuf */
return (np);
}
/* there are no RR's with a owner name of "." yet */
return (NULL);
}
}
/* Try the hints. */
if (htp == hashtab) {
htp = fcachetab;
goto try_again;
}
ns_debug(ns_log_db, 1, "np_parent(0x%lx) couldn't find 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 && dp->d_type != T_SIG && type != T_ANY)
return (0);
if (type != T_SIG && dp->d_type == T_SIG && (int)SIG_COVERS(dp) != type)
return (0);
return (1);
}
/* static int
* nxtlower(name, dp)
* Is the NXT/SIG NXT record 'lower'?
* return value:
* boolean
*/
static int
nxtlower(const char *name, struct databuf *dp) {
/* An NXT is a lower NXT iff the SOA bit is set in the bitmap */
if (dp->d_type == T_NXT) {
u_char *nxtbitmap = dp->d_data + strlen((char *)dp->d_data) + 1;
return (NS_NXT_BIT_ISSET(T_SOA, nxtbitmap) ? 1 : 0);
}
/* If it's not an NXT, it's a SIG NXT. An NXT record must be signed
* by the zone, so the signer name must be the same as the owner.
*/
return (ns_samename(name, (char *)dp->d_data + SIG_HDR_SIZE) != 1 ? 0 : 1);
}
/* int
* nxtmatch(name, dp1, dp2)
* Do NXT/SIG NXT records `dp1' and `dp2' belong to the same NXT set?
* return value:
* boolean
*/
int
nxtmatch(const char *name, struct databuf *dp1, struct databuf *dp2) {
int dp1_lower, dp2_lower;
int type1, type2;
if (dp1->d_type == ns_t_sig)
type1 = SIG_COVERS(dp1);
else
type1 = dp1->d_type;
if (dp2->d_type == ns_t_sig)
type2 = SIG_COVERS(dp2);
else
type2 = dp2->d_type;
if (type1 != ns_t_nxt || type2 != ns_t_nxt)
return (0);
dp1_lower = nxtlower(name, dp1);
dp2_lower = nxtlower(name, dp2);
return (dp1_lower == dp2_lower);
}
/* int
* rrmatch(name, dp1, dp2)
* Do data records `dp1' and `dp2' match in class and type?
* If both are NXTs, do they belong in the same NXT set?
* If both are SIGs, do the covered types match?
* If both are SIG NXTs, do the covered NXTs belong in the same set?
* Why is DNSSEC so confusing?
* return value:
* boolean
*/
int
rrmatch(const char *name, struct databuf *dp1, struct databuf *dp2) {
if (dp1->d_class != dp2->d_class &&
dp1->d_class != C_ANY && dp2->d_class != C_ANY)
return(0);
if (dp1->d_type != dp2->d_type &&
dp1->d_type != T_ANY && dp2->d_type != T_ANY)
return(0);
if (dp1->d_type == T_NXT)
return(nxtmatch(name, dp1, dp2));
if (dp1->d_type != T_SIG)
return(1);
if (SIG_COVERS(dp1) == SIG_COVERS(dp2)) {
if (SIG_COVERS(dp1) == ns_t_nxt)
return(nxtmatch(name, dp1, dp2));
else
return(1);
}
return(0);
}
-215
View File
@@ -1,215 +0,0 @@
#if !defined(lint) && !defined(SABER)
static const char sccsid[] = "@(#)db_save.c 4.16 (Berkeley) 3/21/91";
static const char rcsid[] = "$Id: db_save.c,v 8.30 2002/05/18 01:02:56 marka 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-2000 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 <sys/un.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 = BIND_DATASIZE(size);
dp = (struct databuf *)memget(bytes);
if (dp == NULL)
panic("savedata: memget", NULL);
if (class > CLASS_MAX)
panic("savedata: bad class", 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_secure = DB_S_INSECURE;
dp->d_rcode = NOERROR;
dp->d_addr.s_addr = htonl(0);
dp->d_nstime = 0;
dp->d_rcnt = 1;
#ifdef CHECK_MAGIC
dp->d_magic = DATABUF_MAGIC;
#endif
memcpy(dp->d_data, data, dp->d_size);
return (dp);
}
/*
* 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);
}
File diff suppressed because it is too large. Load diff
-158
View File
@@ -1,158 +0,0 @@
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "$Id: db_tsig.c,v 8.8 2002/05/21 02:34:32 marka 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-2000 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/un.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <ctype.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 <isc/memcluster.h>
#include <isc/tree.h>
#include <isc/dst.h>
#include "port_after.h"
#include "named.h"
typedef struct {
DST_KEY *key;
void *ctx;
} tsig_axfr_state;
#define TSIG_ALG_MD5 "HMAC-MD5.SIG-ALG.REG.INT"
#define TSIG_ALG_MD5_SHORT "hmac-md5"
const char *
tsig_alg_name(int value) {
if (value == KEY_HMAC_MD5)
return(TSIG_ALG_MD5);
else
return(NULL);
}
int
tsig_alg_value(char *name) {
if (ns_samename(name, TSIG_ALG_MD5) == 1 ||
strcasecmp(name, TSIG_ALG_MD5_SHORT) == 0)
return (KEY_HMAC_MD5);
else
return (-1);
}
DST_KEY *
tsig_key_from_addr(struct in_addr addr) {
server_info si = find_server(addr);
if (si == NULL || si->key_list == NULL || si->key_list->first == NULL)
return(NULL);
return(si->key_list->first->key);
}
struct tsig_record *
new_tsig(DST_KEY *key, u_char *sig, int siglen) {
struct tsig_record *tsig;
if (siglen > TSIG_SIG_SIZE)
return(NULL);
tsig = memget(sizeof(struct tsig_record));
if (tsig == NULL)
return(NULL);
tsig->key = key;
tsig->siglen = siglen;
memcpy(tsig->sig, sig, siglen);
return(tsig);
}
void
free_tsig(struct tsig_record *tsig) {
if (tsig == NULL)
return;
memput(tsig, sizeof(struct tsig_record));
}
File diff suppressed because it is too large. Load diff
-462
View File
@@ -1,462 +0,0 @@
/*
* 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!
key sample_key { // for TSIG
algorithm hmac-md5; // hmac-md5 is the supported algorithm
secret "abcdefgh"; // base 64 encoded secret
};
key key2 {
algorithm hmac-md5;
secret "87654321";
};
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 no;
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)
// notify explicit; // only sent the notifies to the
// also-notify list
serial-queries 4; // number of parallel SOA queries
// we can have outstanding for master
// zone change testing purposes
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
/*
* IXFR options
*/
maintain-ixfr-base no; // If yes, keep transaction log file for IXFR
max-ixfr-log-size 20; // Not implemented, maximum size the
// IXFR transaction log file to grow
};
/*
* Control listeners, for "ndc". Every nameserver needs at least one.
*/
controls {
inet * port 52 allow { any; }; // a bad idea
unix "/var/run/ndc" perm 0600 owner 0 group 0; // the default
};
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.
// notify explicit; // only sent the notifies to the
// also-notify list
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";
ixfr-base "slave.demo.zone.ixfr"; // File name for IXFR transaction log file
masters {
1.2.3.4; // where to zone transfer from
5.6.7.8 key key2;
};
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";
pubkey 257 255 1 "AQP2fHpZ4VMpKo/jc9Fod821uyfY5p8j5h/Am0V/KpBTMZjdXmp9QJe6yFRoIIzkaNCgTIftASdpXGgCwFB2j2KXP/rick6gvEer5VcDEkLR5Q==";
};
trusted-keys {
. 257 255 1 "AQP2fHpZ4VMpKo/jc9Fod821uyfY5p8j5h/Am0V/KpBTMZjdXmp9QJe6yFRoIIzkaNCgTIftASdpXGgCwFB2j2KXP/rick6gvEer5VcDEkLR5Q==";
};
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;
};
};
acl key_acl { key sample_key; }; // a request signed with sample_key
server 1.2.3.4 {
edns no; // if no, we won't send ends queries
// to this server
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; sign requests to this
// server with this key
support-ixfr yes; // for IXFR supported by server
// if yes, the listed server talks IXFR
};
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"; // note: stderr is used instead
* // of "named.run" if the server
* // is started with the "-f"
* // option.
* 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
-67
View File
@@ -1,67 +0,0 @@
/*
* Copyright (c) 1996-2000 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.32 2002/03/15 00:58:16 vixie Exp $
*/
/* Options. Change them at your peril. */
#undef NXDOMAIN_ON_DENIAL
#define DEBUG
#define ADDAUTH
#define STUBS
#define RETURNSOA
#define BOGUSNS
#define TRACEROOT
#define XFRNETS
#define QRYLOG
#undef YPKLUDGE
#define RENICE
#define BIND_IXFR
#define BIND_NOTIFY
#define BIND_UPDATE
#define WANT_PIDFILE
#define FWD_LOOP
#define DOTTED_SERIAL
#define SENSIBLE_DOTS
#define ROUND_ROBIN
#define DNS_SECURITY
#undef RSAREF
#undef BSAFE
#define ALLOW_LONG_TXT_RDATA
#define STRICT_RFC2308
#undef BIND_ZXFR
#undef LOG_TSIG_BUG
#define NOADDITIONAL
#undef FORWARD_ALLOWS /* enable allow-query for forward zones. */
#include <isc/assertions.h>
#include <isc/list.h>
#include <isc/ctl.h>
#include <res_update.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"
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
-935
View File
@@ -1,935 +0,0 @@
/*
* from ns.h 4.33 (Berkeley) 8/23/90
* $Id: ns_defs.h,v 8.124.6.1 2003/06/02 09:56:34 marka 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-2000 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.
*/
/*
* Portions Copyright (c) 1999 by Check Point Software Technologies, Inc.
*
* 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 Check Point Software Technologies Incorporated 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 CHECK POINT SOFTWARE TECHNOLOGIES
* INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
* IN NO EVENT SHALL CHECK POINT SOFTWARE TECHNOLOGIES INCORPRATED
* 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 NEWZONES 64 /* how many zones to grow the zone table by */
#define INITIALZONES NEWZONES /* how many zones are allocated initially */
#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 slave */
/* 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 MAX_REFRESH 2419200 /* perform a refresh query at least */
/* every 4 weeks*/
#define MAX_RETRY 1209600 /* perform a retry after no more than 2 weeks */
#define MAX_EXPIRE 31536000 /* expire a zone if we have not talked to */
/* the primary in 1 year */
#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 MAX_SYNCDELAY 3 /* Presumed timeout in use by our clients. */
#define MAX_SYNCDRAIN 100000 /* How long we'll spin in drain_all_rcvbuf. */
#define MAX_SYNCSTORE 500
#define NS_MAX_DISTANCE 3 /* maximum nameserver chaining before failure */
/* maximum time to cache negative answers */
#define DEFAULT_MAX_NCACHE_TTL (3*60*60)
#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? */
typedef enum need {
main_need_zreload = 0, /* ns_zreload() needed. */
main_need_reload, /* ns_reload() needed. */
main_need_reconfig, /* ns_reconfig() needed. */
main_need_endxfer, /* endxfer() needed. */
main_need_zoneload, /* loadxfer() needed. */
main_need_dump, /* doadump() needed. */
main_need_statsdump, /* ns_stats() needed. */
main_need_statsdumpandclear, /* ns_stats() needed. */
main_need_exit, /* exit() needed. */
main_need_qrylog, /* toggle_qrylog() needed. */
main_need_debug, /* use_desired_debug() needed. */
main_need_restart, /* exec() needed. */
main_need_reap, /* need to reap dead children. */
main_need_noexpired, /* ns_reconfig() needed w/ noexpired set. */
main_need_tryxfer, /* attemt to start a zone transfer. */
main_need_num /* MUST BE LAST. */
} main_need;
/* What global options are set? */
#define OPTION_NORECURSE 0x00000001 /* Don't recurse even if asked. */
#define OPTION_NOFETCHGLUE 0x00000002 /* Don't fetch missing glue. */
#define OPTION_FORWARD_ONLY 0x00000004 /* Don't use NS RR's, just forward. */
#define OPTION_FAKE_IQUERY 0x00000008 /* Fake up bogus response to IQUERY. */
#ifdef BIND_NOTIFY
/* #define OPTION_NONOTIFY 0x00000010 */ /* Turn off notify */
#define OPTION_SUPNOTIFY_INITIAL 0x00000020 /* Supress initial notify */
#endif
#define OPTION_NONAUTH_NXDOMAIN 0x00000040 /* Generate non-auth NXDOMAINs? */
#define OPTION_MULTIPLE_CNAMES 0x00000080 /* Allow a name to have multiple
* CNAME RRs */
#define OPTION_HOSTSTATS 0x00000100 /* Maintain per-host statistics? */
#define OPTION_DEALLOC_ON_EXIT 0x00000200 /* Deallocate everything on exit? */
#define OPTION_NODIALUP 0x00000400 /* Turn off dialup support */
#define OPTION_NORFC2308_TYPE1 0x00000800 /* Prevent type1 respones (RFC 2308)
* to cached negative respones */
#define OPTION_USE_ID_POOL 0x00001000 /* Use the memory hogging query ID */
#define OPTION_TREAT_CR_AS_SPACE 0x00002000 /* Treat CR in zone files as
* space */
#define OPTION_USE_IXFR 0x00004000 /* Use by default ixfr in zone
* transfer */
#define OPTION_MAINTAIN_IXFR_BASE 0x00008000 /* Part of IXFR file name logic. */
#define OPTION_HITCOUNT 0x00010000 /* Keep track of each time an
* RR gets hit in the database */
#define DEFAULT_OPTION_FLAGS (OPTION_NODIALUP|OPTION_NONAUTH_NXDOMAIN|\
OPTION_USE_ID_POOL|OPTION_NORFC2308_TYPE1)
#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
#define HEARTBEAT_TIMER 0x08
/* 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 SEQ_LT(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_ZOPTION_P(zp, option) \
(((zp) != NULL && (((zp)->z_optset & option) != 0)) ? \
(((zp)->z_options & option) != 0) : NS_OPTION_P(option))
#define NS_ZFWDTAB(zp) (((zp) == NULL) ? \
server_options->fwdtab : (zp)->z_fwdtab)
#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 };
#ifdef BIND_NOTIFY
enum notify { notify_use_default=0, notify_yes, notify_no, notify_explicit };
#endif
enum zdialup { zdialup_use_default=0, zdialup_yes, zdialup_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;
};
struct ip_match_key {
struct dst_key *key;
};
typedef enum { ip_match_pattern, ip_match_indirect, ip_match_localhost,
ip_match_localnets, ip_match_key } 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;
struct ip_match_key key;
} 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_addr[NSMAX]; /* list of master servers for zone */
struct dst_key * z_keys[NSMAX]; /* tsig key associated with master */
u_char z_addrcnt; /* number of entries in z_addr[] */
struct in_addr z_xaddr[NSMAX]; /* list of master servers for xfer */
u_char z_xaddrcnt; /* number of entries in z_xaddr[] */
u_char z_type; /* type of zone; see below */
u_int32_t z_flags; /* state bits; see below */
pid_t z_xferpid; /* xfer child pid */
u_int z_options; /* options set specific to this zone */
u_int z_optset; /* which opts override global opts */
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 */
#ifdef BIND_NOTIFY
enum notify z_notify; /* Notify mode */
struct in_addr *z_also_notify; /* More nameservers to notify */
int z_notify_count;
#endif
enum zdialup z_dialup; /* secondaries over a dialup link */
char *z_ixfr_base; /* where to find the history of the zone */
char *z_ixfr_tmp; /* tmp file for the ixfr */
int z_maintain_ixfr_base;
long z_max_log_size_ixfr;
u_int32_t z_serial_ixfr_start;
evTimerID z_timer; /* maintenance timer */
ztimer_info z_timerinfo; /* UAP associated with timer */
time_t z_nextmaint; /* time of next maintenance */
u_int16_t z_port; /* perform AXFR to this port */
struct fwdinfo *z_fwdtab; /* zone-specific forwarders */
LINK(struct zoneinfo) z_freelink; /* if it's on the free list. */
LINK(struct zoneinfo) z_reloadlink; /* if it's on the reload list. */
};
/* zone types (z_type) */
enum zonetype { z_nil, z_master, z_slave, z_hint, z_stub, z_forward,
z_cache, 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_cache /* XXX */
#define Z_STUB z_stub /* XXX */
#define Z_FORWARD z_forward /* XXX */
#define Z_ANY z_any /* XXX*2 */
/* zone state bits (32 bits) */
#define Z_AUTH 0x00000001 /* zone is authoritative */
#define Z_NEED_XFER 0x00000002 /* waiting to do xfer */
#define Z_XFER_RUNNING 0x00000004 /* asynch. xfer is running */
#define Z_NEED_RELOAD 0x00000008 /* waiting to do reload */
#define Z_SYSLOGGED 0x00000010 /* have logged timeout */
#define Z_QSERIAL 0x00000020 /* sysquery()'ing for serial number */
#define Z_FOUND 0x00000040 /* found in boot file when reloading */
#define Z_INCLUDE 0x00000080 /* set if include used in file */
#define Z_DB_BAD 0x00000100 /* errors when loading file */
#define Z_TMP_FILE 0x00000200 /* backup file for xfer is temporary */
#ifdef BIND_UPDATE
#define Z_DYNAMIC 0x00000400 /* allow dynamic updates */
#define Z_NEED_DUMP 0x00000800 /* zone has changed, needs a dump */
#define Z_NEED_SOAUPDATE 0x00001000 /* soa serial number needs increment */
#endif /* BIND_UPDATE */
#define Z_XFER_ABORTED 0x00002000 /* zone transfer has been aborted */
#define Z_XFER_GONE 0x00004000 /* zone transfer process is gone */
#define Z_TIMER_SET 0x00008000 /* z_timer contains a valid id */
#ifdef BIND_NOTIFY
#define Z_NOTIFY 0x00010000 /* has an outbound notify executing */
#endif
#define Z_NEED_QSERIAL 0x00020000 /* we need to re-call qserial() */
#define Z_PARENT_RELOAD 0x00040000 /* we need to reload this as parent */
#define Z_FORWARD_SET 0x00080000 /* has forwarders been set */
#define Z_EXPIRED 0x00100000 /* expire timer has gone off */
#define Z_NEEDREFRESH 0x00200000 /* need to perform a refresh check */
/* 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 */
#define XFER_SUCCESSAXFR 4 /* named-xfr recived a xfr */
#define XFER_SUCCESSIXFR 5 /* named-xfr recived a ixfr */
#define XFER_SUCCESSAXFRIXFRFILE 6 /* named-xfr received AXFR for IXFR */
#define XFER_REFUSED 7 /* one master returned REFUSED */
#define XFER_ISAXFR -1 /* the last XFR is AXFR */
#define XFER_ISIXFR -2 /* the last XFR is IXFR */
#define XFER_ISAXFRIXFR -3 /* the last XFR is AXFR but we must create IXFR base */
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 */
unsigned int forwarder:1; /* this entry is for a forwarder */
unsigned int noedns:1; /* don't try edns */
unsigned int lame:1; /* this server was lame, try it last */
unsigned int nretry:29; /* # of times addr retried */
u_int32_t serial; /* valid if Q_ZSERIAL */
};
/*
* 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 */
u_int16_t q_udpsize; /* UDP message size */
int q_distance; /* distance this query is from the
* original query that the server
* received. */
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
struct dst_key *q_keys[NSMAX]; /* keys to use with this address */
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) */
struct zoneinfo *q_fzone; /* Forwarding zone, if any */
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 another notify()
* when the reply to this comes in.
*/
#endif
struct tsig_record *q_tsig; /* forwarded query's TSIG record */
struct tsig_record *q_nstsig; /* forwarded query's TSIG record */
};
/* 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_EDNS 0x10 /* add edns opt record to answer */
#define Q_NEXTADDR(qp,n) (&(qp)->q_addr[n].ns_addr)
#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 ns_delta {
LINK(struct ns_delta) d_link;
ns_updque d_changes;
} ns_delta;
typedef LIST(ns_delta) ns_deltalist;
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, s_x_adding,
s_x_deleting, s_x_addsoa, s_x_deletesoa }
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. */
type, /* type of XFR. */
id, /* id of an XFR. */
opcode; /* opcode of an XFR. */
u_int zone; /* zone being XFR'd. */
union {
struct namebuf *axfr; /* top np of an AXFR. */
ns_deltalist *ixfr; /* top udp of an IXFR. */
} top;
int ixfr_zone;
u_int32_t serial; /* serial number requested in IXFR */
ns_tcp_tsig_state *tsig_state; /* used by ns_sign_tcp */
int tsig_skip; /* skip calling ns_sign_tcp
* during the next flush */
int tsig_size; /* need to reserve this space
* for the tsig. */
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 STREAM_AXFRIXFR 0x40
#define ALLOW_NETS 0x0001
#define ALLOW_HOSTS 0x0002
#define ALLOW_ALL (ALLOW_NETS | ALLOW_HOSTS)
struct fwddata {
struct sockaddr_in
fwdaddr; /* address of NS */
struct databuf *ns; /* databuf for NS record */
struct databuf *nsdata; /* databuf for server address */
int ref_count; /* how many users of this */
};
struct fwdinfo {
struct fwdinfo *next;
struct fwddata *fwddata;
};
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 */
nssRcvdUQ, /* sent us an unapproved query */
nssRcvdURQ, /* sent us an unapproved recursive query */
nssRcvdUXFR, /* sent us an unapproved AXFR or IXFR */
nssRcvdUUpd, /* sent us an unapproved update */
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 */
u_int8_t xfers; /* #/xfers running right now */
#endif
};
enum transport { primary_trans, secondary_trans, response_trans, update_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;
struct control;
typedef struct control *control;
typedef LIST(struct control) controls;
enum ordering { unknown_order, fixed_order, cyclic_order, random_order };
#define DEFAULT_ORDERING cyclic_order
typedef struct rrset_order_element {
int class;
int type;
char *name;
enum ordering order;
struct rrset_order_element *next;
} *rrset_order_element ;
typedef struct rrset_order_list {
rrset_order_element first;
rrset_order_element last;
} *rrset_order_list;
typedef struct options {
u_int32_t flags;
char *hostname;
char *version;
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;
int serial_queries;
int max_log_size_ixfr;
enum axfr_format transfer_format;
long max_transfer_time_in;
struct sockaddr_in query_source;
struct in_addr axfr_src;
#ifdef BIND_NOTIFY
int notify_count;
struct in_addr *also_notify;
#endif
ip_match_list query_acl;
ip_match_list recursion_acl;
ip_match_list transfer_acl;
ip_match_list blackhole_acl;
ip_match_list topology;
ip_match_list sortlist;
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;
rrset_order_list ordering;
int heartbeat_interval;
u_int max_ncache_ttl;
u_int max_host_stats;
u_int lame_ttl;
int minroots;
u_int16_t preferred_glue;
u_int16_t edns_udp_size;
enum notify notify;
} *options;
typedef struct key_list_element {
struct dst_key *key;
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
#define SERVER_INFO_SUPPORT_IXFR 0x02
#define SERVER_INFO_EDNS 0x04
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 */
const 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,
#ifdef BIND_NOTIFY
ns_log_notify,
#endif
ns_log_cname,
ns_log_security,
ns_log_os,
ns_log_insist,
ns_log_maint,
ns_log_load,
ns_log_resp_checks,
ns_log_control,
ns_log_update_security,
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 {
const char * token;
int val;
};
#define NOERROR_NODATA 15 /* only used internally by the server, used for
* -ve $ing non-existence of records. 15 is not
* a code used as yet anyway.
*/
#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 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
#define EDNS_MESSAGE_SZ 4096
File diff suppressed because it is too large. Load diff
-528
View File
@@ -1,528 +0,0 @@
/*
* 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-2000 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.
*/
/*
* Portions Copyright (c) 1999 by Check Point Software Technologies, Inc.
*
* 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 Check Point Software Technologies Incorporated 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 CHECK POINT SOFTWARE TECHNOLOGIES
* INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
* IN NO EVENT SHALL CHECK POINT SOFTWARE TECHNOLOGIES INCORPRATED
* 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.120.8.1 2003/06/02 05:19:56 marka Exp $
*/
/* ++from ns_glue.c++ */
struct in_addr ina_get(const u_char *data);
const char * sin_ntoa(struct sockaddr_in);
int ns_wouldlog(int category, int level);
void ns_debug(int, int, const char *, ...) ISC_FORMAT_PRINTF(3, 4);
void ns_info(int, const char *, ...) ISC_FORMAT_PRINTF(2, 3);
void ns_notice(int, const char *, ...) ISC_FORMAT_PRINTF(2, 3);
void ns_warning(int, const char *, ...) ISC_FORMAT_PRINTF(2, 3);
void ns_error(int, const char *, ...) ISC_FORMAT_PRINTF(2, 3);
void ns_critical(int, const char *, ...) ISC_FORMAT_PRINTF(2, 3);
void ns_panic(int, int, const char *, ...) ISC_FORMAT_PRINTF(3, 4);
void ns_assertion_failed(const char *file, int line,
assertion_type type,
const char *cond, int print_errno);
void panic(const char *, const void *);
void gettime(struct timeval *);
int nlabels(const char *);
int my_close(int);
int my_fclose(FILE *);
void * __freestr(char *);
char * __newstr(size_t, int);
char * __savestr(const char *, int);
const char * checked_ctime(const time_t *t);
const char * ctimel(long);
void * __freestr_record(char *, const char *, int);
char * __newstr_record(size_t, int, const char *, int);
char * __savestr_record(const char *, int, const char *, int);
u_char * ina_put(struct in_addr ina, u_char *data);
u_char * savebuf(const u_char *, size_t, int);
#ifdef DEBUG_STRINGS
char * debug_newstr(size_t, int, const char *, int);
char * debug_savestr(const char *, int, const char *, int);
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
#ifdef RECORD_STRINGS
#define newstr(l, n) __newstr_record((l), (n), __FILE__, __LINE__)
#define savestr(s, n) __savestr_record((s), (n), __FILE__, __LINE__)
#define freestr(s) __freestr_record((s), __FILE__, __LINE__)
#else
#define newstr(l, n) __newstr((l), (n))
#define savestr(s, n) __savestr((s), (n))
#define freestr(s) __freestr((s))
#endif
#endif /* DEBUG_STRINGS */
/* --from ns_glue.c-- */
/* ++from ns_notify.c++ */
#ifdef BIND_NOTIFY
void ns_notify(const char *, ns_class, ns_type);
void notify_afterload(void);
void ns_unnotify(void);
void ns_stopnotify(const char *, ns_class);
#endif
/* --from ns_notify.c-- */
/* ++from ns_resp.c++ */
void ns_resp(u_char *, int, struct sockaddr_in,
struct qstream *);
void prime_cache(void);
void delete_all(struct namebuf *, int, int);
int delete_stale(struct namebuf *);
struct qinfo * sysquery(const char *, int, int,
struct in_addr *, struct dst_key **keys,
int, u_int16_t, int, int);
int doupdate(u_char *, u_char *, struct databuf **,
int, int, int, u_int, struct sockaddr_in);
int send_msg(u_char *, int, struct qinfo *);
int findns(struct namebuf **, int,
struct databuf **, int *, int);
int finddata(struct namebuf *, int, int, HEADER *,
char **, int *, int *, int, int);
int add_data(struct namebuf *,
struct databuf **,
u_char *, int, int *);
int trunc_adjust(u_char *, int, int);
/* --from ns_resp.c-- */
/* ++from ns_req.c++ */
int ns_get_opt(u_char *msg, u_char *eom,
u_int8_t *versionp, u_int16_t *rcodep,
u_int16_t *flagp, u_int16_t *bufsizep,
u_char **optionsp, size_t *optsizep);
int ns_add_opt(u_char *msg, u_char *cp, size_t buflen,
u_int8_t version, u_int16_t rcode,
u_int16_t size, u_int16_t flags,
u_char *options, size_t optlen);
void ns_req(u_char *, int, int,
struct qstream *,
struct sockaddr_in,
int);
void free_addinfo(void);
void free_nsp(struct databuf **);
int stale(struct databuf *);
int make_rr(const char *, struct databuf *,
u_char *, int, int,
u_char **, u_char **, int);
int doaddinfo(HEADER *, u_char *, int);
int doaddauth(HEADER *, u_char *, int,
struct namebuf *,
struct databuf *);
#ifdef BIND_NOTIFY
int findZonePri(const struct zoneinfo *,
const struct sockaddr_in);
#endif
int drop_port(u_int16_t);
/* --from ns_req.c-- */
/* ++from ns_xfr.c++ */
void ns_xfr(struct qstream *qsp, struct namebuf *znp,
int zone, int class, int type,
int id, int opcode, u_int32_t serial_ixfr,
struct tsig_record *in_tsig);
void ns_stopxfrs(struct zoneinfo *);
void ns_freexfr(struct qstream *);
void sx_newmsg(struct qstream *qsp);
void sx_sendlev(struct qstream *qsp);
void sx_sendsoa(struct qstream *qsp);
/* --from ns_xfr.c-- */
/* ++from ns_ctl.c++ */
void ns_ctl_initialize(void);
void ns_ctl_shutdown(void);
void ns_ctl_defaults(controls *);
void ns_ctl_add(controls *, control);
control ns_ctl_new_inet(struct in_addr, u_int, ip_match_list);
#ifndef NO_SOCKADDR_UN
control ns_ctl_new_unix(const char *, mode_t, uid_t, gid_t);
#endif
void ns_ctl_install(controls *);
/* --from ns_ctl.c-- */
/* ++from ns_ixfr.c++ */
void sx_send_ixfr(struct qstream *);
int ixfr_log_maint(struct zoneinfo *);
/* --from ns_ixfr.c-- */
/* ++from ns_forw.c++ */
time_t retrytime(struct qinfo *);
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,
struct tsig_record *in_tsig);
int haveComplained(u_long, u_long);
int nslookup(struct databuf *nsp[],
struct qinfo *qp,
const char *syslogdname,
const char *sysloginfo);
int qcomp(struct qserv *, struct qserv *);
void schedretry(struct qinfo *, time_t);
void unsched(struct qinfo *);
void reset_retrytimer(void);
void retrytimer(evContext ctx, void *uap,
struct timespec due, struct timespec ival);
void retry(struct qinfo *, int);
void qflush(void);
void qremove(struct qinfo *);
void ns_freeqns(struct qinfo *);
void ns_freeqry(struct qinfo *);
void freeComplaints(void);
void nsfwdadd(struct qinfo *, struct fwdinfo *);
struct qinfo * qfindid(u_int16_t);
struct qinfo * qnew(const char *, int, int, int);
/* --from ns_forw.c-- */
/* ++from ns_main.c++ */
void toggle_qrylog(void);
struct in_addr net_mask(struct in_addr);
void sq_remove(struct qstream *);
void sq_flushw(struct qstream *);
void sq_flush(struct qstream *allbut);
void dq_remove_gen(time_t gen);
void dq_remove_all(void);
void sq_done(struct qstream *);
void ns_setproctitle(char *, int);
void getnetconf(int);
void nsid_init(void);
void ns_setoption(int option);
void writestream(struct qstream *, const u_char *, int);
void ns_need_unsafe(enum need);
void ns_need(enum need);
void opensocket_f(void);
void nsid_hash(u_char *, size_t);
u_int16_t nsid_next(void);
int sq_openw(struct qstream *, int);
int sq_writeh(struct qstream *, sq_closure);
int sq_write(struct qstream *, const u_char *, int);
int tcp_send(struct qinfo *);
int aIsUs(struct in_addr);
/* --from ns_main.c-- */
/* ++from ns_maint.c++ */
void zone_maint(struct zoneinfo *);
void sched_zone_maint(struct zoneinfo *);
void ns_cleancache(evContext ctx, void *uap,
struct timespec due,
struct timespec inter);
void clean_cache_from(char *dname, struct hashbuf *htp);
void remove_zone(struct zoneinfo *, const char *);
void purge_zone(struct zoneinfo *, struct hashbuf *);
void loadxfer(void);
void qserial_retrytime(struct zoneinfo *, time_t);
void qserial_query(struct zoneinfo *);
void qserial_answer(struct qinfo *);
#ifdef DEBUG
void printzoneinfo(int, int, int);
#endif
void endxfer(void);
void tryxfer(void);
void addxfer(struct zoneinfo *);
void ns_zreload(void);
void ns_reload(void);
void ns_reconfig(void);
void ns_noexpired(void);
#if 0
int reload_all_unsafe(void);
#endif
int zonefile_changed_p(struct zoneinfo *);
int reload_master(struct zoneinfo *);
const char * deferred_reload_unsafe(struct zoneinfo *);
struct namebuf * purge_node(struct hashbuf *htp, struct namebuf *np);
int clean_cache(struct hashbuf *, int);
void reapchild(void);
const char * zoneTypeString(unsigned int);
void ns_heartbeat(evContext ctx, void *uap,
struct timespec, struct timespec);
void make_new_zones(void);
void free_zone(struct zoneinfo *);
struct zoneinfo * find_auth_zone(const char *, ns_class);
int purge_nonglue(struct zoneinfo *, struct hashbuf *htp,
int log);
/* --from ns_maint.c-- */
/* ++from ns_sort.c++ */
void sort_response(u_char *, u_char *, int,
struct sockaddr_in *);
/* --from ns_sort.c-- */
/* ++from ns_init.c++ */
void ns_refreshtime(struct zoneinfo *, time_t);
void ns_retrytime(struct zoneinfo *, time_t);
time_t ns_init(const char *);
enum context ns_ptrcontext(const char *owner);
enum context ns_ownercontext(int type, enum transport);
int ns_nameok(const struct qinfo *qry, const char *name,
int class, struct zoneinfo *zp,
enum transport, enum context,
const char *owner,
struct in_addr source);
int ns_wildcard(const char *name);
void zoneinit(struct zoneinfo *);
void do_reload(struct zoneinfo *, int);
void ns_shutdown(void);
/* --from ns_init.c-- */
/* ++from ns_ncache.c++ */
void cache_n_resp(u_char *, int, struct sockaddr_in,
const char *, int, int);
/* --from ns_ncache.c-- */
/* ++from ns_udp.c++ */
void ns_udp(void);
/* --from ns_udp.c-- */
/* ++from ns_stats.c++ */
void ns_stats(void);
void ns_stats_dumpandclear(void);
void ns_freestats(void);
void ns_logstats(evContext ctx, void *uap,
struct timespec, struct timespec);
void qtypeIncr(int qtype);
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++ */
struct databuf * findzonesoa(struct zoneinfo *);
void free_rrecp(ns_updque *, int rcode, struct sockaddr_in);
int findzone(const char *, int, int, int *, int);
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, char *logname);
int zonedump(struct zoneinfo *zp, int isixfr);
void dynamic_about_to_exit(void);
enum req_action req_update(HEADER *hp, u_char *cp, u_char *eom,
u_char *msg, struct sockaddr_in from,
struct tsig_record *in_tsig);
void rdata_dump(struct databuf *dp, FILE *fp);
/* --from ns_update.c-- */
/* ++from ns_config.c++ */
void add_to_rrset_order_list(rrset_order_list,
rrset_order_element);
const char * p_order(int);
int set_zone_ixfr_file(zone_config, char *);
int set_zone_master_port(zone_config, u_short);
int set_zone_max_log_size_ixfr(zone_config, int);
int set_zone_dialup(zone_config, int);
int set_trusted_key(const char *, const int,
const int, const int, const char *);
int set_zone_ixfr_tmp(zone_config, char *);
void free_zone_timerinfo(struct zoneinfo *);
void free_zone_contents(struct zoneinfo *, int);
struct zoneinfo * find_zone(const char *, 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);
#ifdef BIND_NOTIFY
int set_zone_notify(zone_config, enum notify value);
#endif
int set_zone_maintain_ixfr_base(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_pubkey(zone_config, const int, const int,
const int, const char *);
int set_zone_transfer_time_in(zone_config, long);
int add_zone_master(zone_config, struct in_addr,
struct dst_key *);
#ifdef BIND_NOTIFY
int add_zone_notify(zone_config, struct in_addr);
#endif
void set_zone_forward(zone_config);
void add_zone_forwarder(zone_config, struct in_addr);
void set_zone_boolean_option(zone_config, int, int);
options new_options(void);
void free_options(options);
void free_rrset_order_list(rrset_order_list);
void set_global_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_short, ip_match_list);
FILE * write_open(char *filename);
void update_pid_file(void);
void set_options(options, int);
void use_default_options(void);
enum ordering lookup_ordering(const char *);
rrset_order_list new_rrset_order_list(void);
rrset_order_element new_rrset_order_element(int, int, char *, enum ordering);
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_key(struct dst_key *dst_key);
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,
const char *, const char *);
int ip_match_address(ip_match_list, struct in_addr);
int ip_match_addr_or_key(ip_match_list, struct in_addr,
struct dst_key *key);
int ip_address_allowed(ip_match_list, struct in_addr);
int ip_addr_or_key_allowed(ip_match_list iml,
struct in_addr,
struct dst_key *key);
int ip_match_network(ip_match_list, struct in_addr,
struct in_addr);
int ip_match_key_name(ip_match_list iml, char *name);
int distance_of_address(ip_match_list, struct in_addr);
int ip_match_is_none(ip_match_list);
#ifdef BIND_NOTIFY
void free_also_notify(options);
int add_global_also_notify(options, struct in_addr);
#endif
void add_global_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, struct dst_key *);
struct dst_key *new_key_info(char *, char *, char *);
void free_key_info(struct dst_key *);
struct dst_key *find_key(char *name, char *algorithm);
void dprint_key_info(struct dst_key *);
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, struct dst_key *);
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);
time_t load_configuration(const char *);
/* --from ns_config.c-- */
/* ++from parser.y++ */
ip_match_list lookup_acl(const char *);
void define_acl(const char *, ip_match_list);
struct dst_key *lookup_key(char *);
void define_key(const char *, struct dst_key *);
time_t parse_configuration(const char *);
void parser_initialize(void);
void parser_shutdown(void);
/* --from parser.y-- */
/* ++from ns_signal.c++ */
void init_signals(void);
void block_signals(void);
void unblock_signals(void);
/* --from ns_signal.c-- */
-347
View File
@@ -1,347 +0,0 @@
/*
* from ns.h 4.33 (Berkeley) 8/23/90
* $Id: ns_glob.h,v 8.59 2002/07/19 22:44:08 marka 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-2000 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.
*/
/* original argv[] from main() */
DECL char **saved_argv;
#ifdef DEBUG
DECL int debug INIT(0);
DECL int desired_debug INIT(0);
#endif
/* global event context */
DECL evContext ev;
/* global resolver context. */
DECL struct __res_state res;
/* 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;
/* configuration file name */
DECL char *conffile;
/* configuration file mtime */
DECL time_t confmtime;
/* default debug output file */
DECL char *debugfile;
/* zone information */
DECL struct zoneinfo *zones;
/* number of zones allocated */
DECL int nzones;
/* free list of unused zones[] elements. */
DECL LIST(struct zoneinfo) freezones;
/* list of zones that have a reload pending. */
DECL LIST(struct zoneinfo) reloadingzones;
/* 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*));
/* data about all forwarders */
DECL struct fwddata **fwddata;
/* how many forwarders are there in fwddata? */
DECL int fwddata_count;
/* number of names in addinfo */
DECL int addcount;
/* name of cache file */
DECL const char *cache_file;
#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);
DECL key_info_list secretkey_info INIT(NULL);
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" },
#ifdef BIND_NOTIFY
{ ns_log_notify, "notify" },
#endif
{ 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" },
{ ns_log_control, "control" },
{ ns_log_update_security, "update-security" },
{ 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 evTimerID heartbeat_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);
DECL char * working_dir INIT(NULL);
DECL int loading INIT(0);
DECL int xfers_running INIT(0);
DECL int xfers_deferred INIT(0);
DECL int qserials_running INIT(0);
DECL int initial_configuration INIT(1);
-469
View File
@@ -1,469 +0,0 @@
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "$Id: ns_glue.c,v 8.24 2002/01/07 02:54:37 marka Exp $";
#endif /* not lint */
/*
* Copyright (c) 1996-2000 by Internet Software Consortium, Inc.
*
* 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 <sys/un.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);
}
/*
* IP address to presentation format.
*/
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
*/
int
ns_wouldlog(int category, int level) {
if (log_ctx_valid)
return (log_check(log_ctx, category, level));
return (0);
}
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_critical(int category, 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);
}
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(const char *file, int line, assertion_type type,
const 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 should 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);
/*
* Tru64 UNIX V5.1 can return a spurious EINVAL after connect()
* failures.
*/
if (s < 0 && errno != EBADF && errno != EINVAL)
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: %s", 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);
}
char *
__newstr(size_t len, int needpanic) {
return (__newstr_record(len, needpanic, __FILE__, __LINE__));
}
char *
__savestr(const char *str, int needpanic) {
return (__savestr_record(str, needpanic, __FILE__, __LINE__));
}
void *
__freestr(char *str) {
__freestr_record(str, __FILE__, __LINE__);
return (NULL);
}
#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_record(len, needpanic, file, line));
}
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_record(str, needpanic, file, line));
}
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_record(str, file, line);
return (NULL);
}
#endif /* DEBUG_STRINGS */
/*
* Return a counted string buffer big enough for a string of length 'len'.
*/
char *
__newstr_record(size_t len, int needpanic, const char *file, int line) {
u_char *buf, *bp;
REQUIRE(len <= 65536);
buf = (u_char *)__memget_record(2/*Len*/ + len + 1/*Nul*/, file, line);
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_record(const char *str, int needpanic, const char *file, int line) {
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_record(len, needpanic, file, line);
memcpy(buf, str, len + 1);
return (buf);
}
void *
__freestr_record(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);
__memput_record(buf, 2/*Len*/ + len + 1/*Nul*/, file, line);
return (NULL);
}
const char *
checked_ctime(const time_t *t) {
const 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.
*/
const char *
ctimel(long l) {
time_t t = (time_t)l;
return (checked_ctime(&t));
}
#ifdef ultrix
/*
* Some library routines in libc need to be able to see the res_send
* and res_close symbols with out __ prefix otherwise we get multiply
* defined symbol errors when linking named.
*/
#undef res_send
int res_send(const u_char *buf, int buflen, u_char *ans, int anssiz) {
return __res_send(buf, buflen, ans, anssiz);
}
#undef _res_close
void _res_close(void) {
__res_close();
}
#endif
-593
View File
@@ -1,593 +0,0 @@
#if !defined(lint) && !defined(SABER)
static const char sccsid[] = "@(#)ns_init.c 4.38 (Berkeley) 3/21/91";
static const char rcsid[] = "$Id: ns_init.c,v 8.77.8.2 2003/09/04 04:09:09 marka 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-2000 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 <sys/un.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 <isc/dst.h>
#include "port_after.h"
#include "named.h"
#ifdef DEBUG
static void content_zone(int, int);
#endif
static void purgeandload(struct zoneinfo *zp);
/*
* 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;
if (zp->z_flags & Z_NEEDREFRESH) {
zp->z_flags &= ~Z_NEEDREFRESH;
zp->z_time = timebase;
} else
zp->z_time = timebase + half + (rand() % half);
}
/*
* Set new retry time for zone.
*/
void
ns_retrytime(struct zoneinfo *zp, time_t timebase) {
zp->z_flags &= ~Z_NEEDREFRESH;
zp->z_time = timebase + zp->z_retry;
}
/*
* Read configuration file and save it as internal state.
*/
time_t
ns_init(const char *conffile) {
struct zoneinfo *zp;
static int loads = 0; /* number of times loaded */
time_t mtime;
ns_debug(ns_log_config, 1, "ns_init(%s)", conffile);
gettime(&tt);
if (loads == 0) {
/* Init zone data. */
zones = NULL;
INIT_LIST(freezones);
INIT_LIST(reloadingzones);
nzones = 0;
make_new_zones();
/* Init cache. */
zones[0].z_type = z_cache;
zones[0].z_origin = savestr("", 1);
/* 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 other misc stuff. */
dst_init();
init_configuration();
} else {
/* Mark previous zones as not yet found in boot file. */
block_signals();
for (zp = &zones[1]; zp < &zones[nzones]; zp++)
if (zp->z_type != z_nil) {
zp->z_flags &= ~Z_FOUND;
if (LINKED(zp, z_reloadlink))
UNLINK(reloadingzones, zp,
z_reloadlink);
}
unblock_signals();
}
#ifdef DEBUG
if (debug >= 3) {
ns_debug(ns_log_config, 3, "content of zones before loading");
content_zone(nzones - 1, 3);
}
#endif
mtime = load_configuration(conffile);
/* Erase all old zones that were not found. */
for (zp = &zones[0]; zp < &zones[nzones]; zp++) {
if (zp->z_type == z_cache)
continue;
if (zp->z_type != z_nil && (zp->z_flags & Z_FOUND) == 0)
remove_zone(zp, "removed");
}
/* Reload parent zones of zones removed */
for (zp = &zones[0]; zp < &zones[nzones]; zp++) {
if (zp->z_type == z_cache)
continue;
if (zp->z_type != z_nil &&
(zp->z_flags & Z_PARENT_RELOAD) != 0) {
zp->z_flags &= ~Z_PARENT_RELOAD;
purgeandload(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++;
return (mtime);
}
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 == NULL)
return;
result = stat(zp->z_source, &sb);
if (result != -1) {
ns_stopxfrs(zp);
purge_zone(zp, hashtab);
}
if (result == -1 ||
db_load(zp->z_source, zp->z_origin, zp, NULL, ISNOTIXFR))
{
/*
* 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)) == 0) {
zp->z_time = tt.tv_sec;
sched_zone_maint(zp);
}
} else {
zp->z_flags |= Z_AUTH;
zp->z_flags &= ~(Z_NEED_RELOAD|Z_EXPIRED);
ns_refreshtime(zp, tt.tv_sec);
sched_zone_maint(zp);
}
}
/*
* Purge the zone and reload all parent zones. This needs to be done when
* we unload a zone, since the child zone will have stomped the parent's
* delegation to that child when it was first loaded.
*/
void
do_reload(struct zoneinfo *ozp, int mark) {
struct zoneinfo *zp;
const char *domain = ozp->z_origin;
int type = ozp->z_type;
int class = ozp->z_class;
ns_debug(ns_log_config, 1, "do_reload: %s %d %d %d",
*domain ? domain : ".", type, class, mark);
/*
* 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.
*/
zp = find_zone(domain, class);
if (zp != NULL &&
((type != z_master && zp->z_type == z_master) ||
(type != z_slave && zp->z_type == z_slave && zp->z_serial != 0) ||
(type != z_stub && zp->z_type == z_stub && zp->z_serial != 0)))
return;
/*
* Clean up any leftover data.
*/
ns_stopxfrs(zp);
if (type == z_hint || (type == z_stub && *domain == 0))
purge_zone(ozp, fcachetab);
else
purge_zone(ozp, hashtab);
/*
* 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 */
zp = find_zone(domain, class);
if (zp != NULL && zp->z_type != Z_HINT) {
ns_debug(ns_log_config, 1, "do_reload: matched %s",
*domain ? domain : ".");
if (mark)
zp->z_flags |= Z_PARENT_RELOAD;
else
purgeandload(zp);
break;
}
}
}
static void
purgeandload(struct zoneinfo *zp) {
#ifdef BIND_UPDATE
/*
* A dynamic zone might have changed, so we
* need to dump it before removing it.
*/
if (zp->z_type == Z_PRIMARY &&
(zp->z_flags & Z_DYNAMIC) != 0 &&
((zp->z_flags & Z_NEED_SOAUPDATE) != 0 ||
(zp->z_flags & Z_NEED_DUMP) != 0))
(void) zonedump(zp, ISNOTIXFR);
#endif
ns_stopxfrs(zp);
if (zp->z_type == Z_HINT)
purge_zone(zp, fcachetab);
else
purge_zone(zp, hashtab);
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, ISNOTIXFR) == 0)
zp->z_flags |= Z_AUTH;
break;
case Z_HINT:
case Z_CACHE:
(void)db_load(zp->z_source, zp->z_origin, zp, 0, ISNOTIXFR);
break;
}
}
#ifdef DEBUG
/* prints out the content of zones */
static void
content_zone(int end, int level) {
int i;
for (i = 0; i <= end; i++) {
printzoneinfo(i, ns_log_config, level);
}
}
#endif
enum context
ns_ptrcontext(owner)
const char *owner;
{
if (ns_samedomain(owner, "in-addr.arpa") ||
ns_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 update_trans:
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 struct qinfo *qry, 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 *q, *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] for [000.000.000.000]", 0);
if (s != NULL) {
if (transport == response_trans && qry != NULL) {
if ((qry->q_flags & Q_PRIMING) != 0) {
sprintf(s, "%s from [%s] for priming",
transport_strings[transport],
inet_ntoa(source));
} else if ((qry->q_flags & Q_ZSERIAL) != 0) {
sprintf(s, "%s from [%s] for soacheck",
transport_strings[transport],
inet_ntoa(source));
} else if ((qry->q_flags & Q_SYSTEM) != 0) {
sprintf(s, "%s from [%s] for sysquery",
transport_strings[transport],
inet_ntoa(source));
} else {
q=strdup(inet_ntoa(qry->q_from.sin_addr));
sprintf(s, "%s from [%s] for [%s]",
transport_strings[transport],
inet_ntoa(source),
q != NULL ? q : "memget failed");
free(q);
}
} else {
sprintf(s, "%s from [%s]",
(transport == response_trans)
? "query"
: transport_strings[transport],
inet_ntoa(source));
}
}
}
if (ns_samename(owner, name) == 1)
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) ||
(o == NULL) || (s == NULL) ||
( (qry != NULL) &&
(qry->q_flags & (Q_PRIMING|Q_ZSERIAL)) ) ?
log_warning : log_info,
"%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)
(void)freestr(s);
if (o != NULL)
(void)freestr(o);
}
return (ok);
}
int
ns_wildcard(const char *name) {
if (*name != '*')
return (0);
return (*++name == '\0');
}
void
ns_shutdown() {
struct zoneinfo *zp;
#ifdef BIND_NOTIFY
ns_unnotify();
#endif
/* Erase zones. */
for (zp = &zones[0]; zp < &zones[nzones]; zp++) {
if (zp->z_type) {
if (zp->z_type != z_hint && zp->z_type != z_cache) {
ns_stopxfrs(zp);
purge_zone(zp, hashtab);
} else if (zp->z_type == z_hint)
purge_zone(zp, fcachetab);
free_zone_contents(zp, 1);
}
}
/* Erase the cache. */
clean_cache(hashtab, 1);
hashtab->h_cnt = 0; /* ??? */
rm_hash(hashtab);
hashtab = NULL;
clean_cache(fcachetab, 1);
fcachetab->h_cnt = 0; /* ??? */
rm_hash(fcachetab);
fcachetab = NULL;
if (zones != NULL)
memput(zones, nzones * sizeof *zones);
zones = NULL;
freeComplaints();
shutdown_configuration();
}
-584
View File
@@ -1,584 +0,0 @@
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "$Id: ns_ixfr.c,v 8.33 2003/02/24 23:36:01 marka Exp $";
#endif /* not lint */
/*
* Portions Copyright (c) 1999 by Check Point Software Technologies, Inc.
*
* 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 Check Point Software Technologies Incorporated 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 CHECK POINT SOFTWARE TECHNOLOGIES
* INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
* IN NO EVENT SHALL CHECK POINT SOFTWARE TECHNOLOGIES INCORPRATED
* 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/stat.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 <res_update.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/misc.h>
#include "port_after.h"
#include "named.h"
static void sx_new_ixfrmsg(struct qstream * qsp);
void sx_send_ixfr(struct qstream * qsp);
static int sx_flush(struct qstream * qsp),
sx_addrr(struct qstream * qsp,
const char *dname,
struct databuf * dp);
/*
* u_char * sx_new_ixfrmsg(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_new_ixfrmsg(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->aa = 1;
hp->rcode = NOERROR;
qsp->xfr.ptrs[0] = qsp->xfr.msg;
qsp->xfr.ptrs[1] = NULL;
qsp->xfr.cp = qsp->xfr.msg + HFIXEDSZ;
if (qsp->xfr.ixfr_zone == 0) {
int count, n;
int buflen;
struct namebuf *np;
struct hashbuf *htp;
struct zoneinfo *zp;
const char * fname;
qsp->xfr.ixfr_zone = qsp->xfr.zone;
zp = &zones[qsp->xfr.zone];
n = dn_comp(zp->z_origin, qsp->xfr.cp,
XFER_BUFSIZE - (qsp->xfr.cp - qsp->xfr.msg), NULL, NULL);
qsp->xfr.cp += n;
PUTSHORT((u_int16_t) T_IXFR, qsp->xfr.cp);
PUTSHORT((u_int16_t) zp->z_class, qsp->xfr.cp);
hp->qdcount = htons(ntohs(hp->qdcount) + 1);
count = qsp->xfr.cp - qsp->xfr.msg;
htp = hashtab;
np = nlookup(zp->z_origin, &htp, &fname, 0);
buflen = XFER_BUFSIZE;
}
}
/*
* 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
if (qsp->xfr.tsig_state != NULL && qsp->xfr.tsig_skip == 0) {
int msglen = qsp->xfr.cp - qsp->xfr.msg;
ns_sign_tcp(qsp->xfr.msg, &msglen, qsp->xfr.eom - qsp->xfr.msg,
NOERROR, qsp->xfr.tsig_state,
qsp->xfr.state == s_x_done);
if (qsp->xfr.state == s_x_done) {
memput(qsp->xfr.tsig_state, sizeof(ns_tcp_tsig_state));
qsp->xfr.tsig_state = NULL;
}
qsp->xfr.cp = qsp->xfr.msg + msglen;
}
if (qsp->xfr.cp - qsp->xfr.msg > 0)
ret = sq_write(qsp, qsp->xfr.msg, qsp->xfr.cp - qsp->xfr.msg);
else {
ns_debug(ns_log_default, 3, " Flush negative number *********");
ret = -1;
}
if (ret >= 0) {
qsp->xfr.cp = NULL;
qsp->xfr.tsig_skip = 0;
}
else
qsp->xfr.tsig_skip = 1;
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 sq_write() 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_new_ixfrmsg(qsp);
n = make_rr(dname, dp, qsp->xfr.cp, qsp->xfr.eom - qsp->xfr.cp,
0, qsp->xfr.ptrs, edp, 0);
if (n < 0) {
if (sx_flush(qsp) < 0)
return (-1);
if (qsp->xfr.cp == NULL)
sx_new_ixfrmsg(qsp);
n = make_rr(dname, dp, qsp->xfr.cp, qsp->xfr.eom - qsp->xfr.cp,
0, qsp->xfr.ptrs, edp, 0);
INSIST(n >= 0);
}
hp->ancount = htons(ntohs(hp->ancount) + 1);
qsp->xfr.cp += n;
return (0);
}
void
sx_send_ixfr(struct qstream *qsp) {
char * cp;
struct zoneinfo *zp = NULL;
struct databuf *soa_dp;
struct databuf *old_soadp;
ns_delta *dp;
ns_updrec *rp;
int foundsoa;
zp = &zones[qsp->xfr.zone];
soa_dp = (struct databuf *) findzonesoa(zp);
if (soa_dp == NULL) {
/* XXX should be more graceful */
ns_panic(ns_log_update, 1,
"sx_send_ixfr: unable to locate soa");
}
old_soadp = memget(BIND_DATASIZE(soa_dp->d_size));
if (old_soadp == NULL)
ns_panic(ns_log_update, 1, "sx_send_ixfr: out of memory");
memcpy(old_soadp, soa_dp, BIND_DATASIZE(soa_dp->d_size));
again:
switch (qsp->xfr.state) {
case s_x_firstsoa:
ns_debug(ns_log_default, 3,
"IXFR: s_x_firstsoa (%s)", zp->z_origin);
if (sx_addrr(qsp, zp->z_origin, soa_dp) < 0)
goto cleanup;
qsp->xfr.state = s_x_deletesoa;
/* FALLTHROUGH */
case s_x_deletesoa:
ns_debug(ns_log_default, 3,
"IXFR: s_x_deletesoa (%s)", zp->z_origin);
dp = NULL;
if (qsp->xfr.top.ixfr != NULL && !EMPTY(*qsp->xfr.top.ixfr))
dp = HEAD(*qsp->xfr.top.ixfr);
if (dp != NULL) {
foundsoa = 0;
rp = HEAD(dp->d_changes);
while (rp != NULL) {
if (rp->r_opcode == DELETE &&
rp->r_dp != NULL &&
rp->r_dp->d_type == T_SOA) {
if (sx_addrr(qsp, rp->r_dname,
rp->r_dp) < 0)
goto cleanup;
db_detach(&rp->r_dp);
foundsoa = 1;
break;
}
rp = NEXT(rp, r_link);
}
if (!foundsoa) {
cp = (char *)findsoaserial(old_soadp->d_data);
PUTLONG(HEAD(dp->d_changes)->r_zone, cp);
if (sx_addrr(qsp, zp->z_origin, old_soadp) < 0)
goto cleanup;
}
}
qsp->xfr.state = s_x_deleting;
/* FALLTHROUGH */
case s_x_deleting:
ns_debug(ns_log_default, 3,
"IXFR: s_x_deleting (%s)", zp->z_origin);
dp = NULL;
if (qsp->xfr.top.ixfr != NULL && !EMPTY(*qsp->xfr.top.ixfr))
dp = HEAD(*qsp->xfr.top.ixfr);
if (dp != NULL) {
rp = HEAD(dp->d_changes);
while (rp != NULL) {
if (rp->r_opcode == DELETE &&
rp->r_dp != NULL) {
/*
* Drop any SOA deletes
*/
if (rp->r_dp->d_type != T_SOA &&
sx_addrr(qsp, rp->r_dname,
rp->r_dp) < 0)
goto cleanup;
db_detach(&rp->r_dp);
}
rp = NEXT(rp, r_link);
}
}
qsp->xfr.state = s_x_addsoa;
/* FALLTHROUGH */
case s_x_addsoa:
ns_debug(ns_log_default, 3,
"IXFR: s_x_addsoa (%s)", zp->z_origin);
dp = NULL;
if (qsp->xfr.top.ixfr != NULL && !EMPTY(*qsp->xfr.top.ixfr))
dp = HEAD(*qsp->xfr.top.ixfr);
if (dp != NULL) {
foundsoa = 0;
rp = HEAD(dp->d_changes);
while (rp != NULL) {
if (rp->r_opcode == ADD &&
rp->r_dp != NULL &&
rp->r_dp->d_type == T_SOA) {
if (sx_addrr(qsp, rp->r_dname,
rp->r_dp) < 0)
goto cleanup;
db_detach(&rp->r_dp);
foundsoa = 1;
break;
}
rp = NEXT(rp, r_link);
}
if (!foundsoa) {
cp = (char *)findsoaserial(old_soadp->d_data);
if (NEXT(dp, d_link) != NULL) {
PUTLONG(HEAD(dp->d_changes)->r_zone, cp);
if (sx_addrr(qsp, zp->z_origin,
old_soadp) < 0)
goto cleanup;
} else {
if (sx_addrr(qsp, zp->z_origin,
soa_dp) < 0)
goto cleanup;
}
}
}
qsp->xfr.state = s_x_adding;
/* FALLTHROUGH */
case s_x_adding:
ns_debug(ns_log_default, 3,
"IXFR: s_x_adding (%s)", zp->z_origin);
dp = NULL;
if (qsp->xfr.top.ixfr != NULL && !EMPTY(*qsp->xfr.top.ixfr)) {
dp = HEAD(*qsp->xfr.top.ixfr);
if (dp != NULL) {
/* see s_x_deleting */
rp = HEAD(dp->d_changes);
while (rp != NULL) {
if (rp->r_opcode == ADD &&
rp->r_dp != NULL &&
rp->r_dp->d_type != T_SOA) {
if (sx_addrr(qsp, rp->r_dname,
rp->r_dp) < 0)
goto cleanup;
db_detach(&rp->r_dp);
}
rp = NEXT(rp, r_link);
}
/* move to next update */
UNLINK(*qsp->xfr.top.ixfr, dp, d_link);
/* clean up old update */
while ((rp = HEAD(dp->d_changes)) != NULL) {
UNLINK(dp->d_changes, rp, r_link);
if (rp->r_dp != NULL)
db_detach(&rp->r_dp);
res_freeupdrec(rp);
}
memput(dp, sizeof (*dp));
if (HEAD(*qsp->xfr.top.ixfr) != NULL) {
qsp->xfr.state = s_x_deletesoa;
goto again;
}
}
}
qsp->xfr.state = s_x_lastsoa;
/* FALLTHROUGH */
case s_x_lastsoa:
ns_debug(ns_log_default, 3,
"IXFR: s_x_lastsoa (%s)", zp->z_origin);
if (qsp->xfr.ixfr_zone != 0)
sx_addrr(qsp, zp->z_origin, soa_dp);
break;
default:
break;
}
ns_debug(ns_log_default, 3, "IXFR: flushing %s", zp->z_origin);
qsp->xfr.state = s_x_done;
sx_flush(qsp);
sq_writeh(qsp, sq_flushw);
if (qsp->xfr.top.ixfr != NULL) {
if(!EMPTY(*qsp->xfr.top.ixfr)) {
while ((dp = HEAD(*qsp->xfr.top.ixfr)) != NULL) {
UNLINK(*qsp->xfr.top.ixfr, dp, d_link);
while ((rp = HEAD(dp->d_changes)) != NULL) {
UNLINK(dp->d_changes, rp, r_link);
if (rp->r_dp != NULL)
db_detach(&rp->r_dp);
res_freeupdrec(rp);
}
memput(dp, sizeof *dp);
}
}
memput(qsp->xfr.top.ixfr, sizeof *qsp->xfr.top.ixfr);
qsp->xfr.top.ixfr = NULL;
}
cleanup:
memput(old_soadp, BIND_DATASIZE(old_soadp->d_size));
}
#ifndef MAXBSIZE
#define MAXBSIZE 8192
#endif
/*
* int ixfr_log_maint(struct zoneinfo *zp, int fast_trim)
*
* zp - pointer to the zone information
*/
int
ixfr_log_maint(struct zoneinfo *zp) {
int fd, rcount, wcount;
int found = 0;
int error = 0;
long seek = 0;
FILE *to_fp, *from_fp, *db_fp;
char *tmpname;
int len;
struct stat db_sb;
struct stat sb;
size_t check_size;
static char buf[MAXBSIZE];
ns_debug(ns_log_default, 3, "ixfr_log_maint(%s)", zp->z_origin);
/* find out how big the zone db file is */
if ((db_fp = fopen(zp->z_source, "r")) == NULL) {
ns_warning(ns_log_db, "%s: %s",
zp->z_source, strerror(errno));
return (-1);
}
if (fstat(fileno(db_fp), &db_sb) < 0) {
ns_warning(ns_log_db, "%s: %s",
zp->z_source, strerror(errno));
(void) my_fclose(db_fp);
return (-1);
}
(void) my_fclose(db_fp);
ns_debug(ns_log_default, 3, "%s, size %ld",
zp->z_source, (long)db_sb.st_size);
/* open up the zone ixfr log */
if ((from_fp = fopen(zp->z_ixfr_base, "r")) == NULL) {
ns_warning(ns_log_db, "%s: %s",
zp->z_ixfr_base, strerror(errno));
return (-1);
}
if (fstat(fileno(from_fp), &sb) < 0) {
ns_warning(ns_log_db, "%s: %s",
zp->z_ixfr_base, strerror(errno));
(void) my_fclose(from_fp);
return (-1);
}
ns_debug(ns_log_default, 3, "%s, size %ld max %ld\n", zp->z_ixfr_base,
(long)sb.st_size, (long)zp->z_max_log_size_ixfr);
check_size = zp->z_max_log_size_ixfr;
if (!check_size)
check_size = db_sb.st_size / 2;
if (sb.st_size > check_size)
seek = (sb.st_size - check_size) + (check_size / 10);
else
seek = 0;
ns_debug(ns_log_default, 3, "seek: %ld", (long)seek);
if (seek < 1) {
ns_debug(ns_log_default, 3, "%s does not need to be reduced",
zp->z_ixfr_base);
(void) my_fclose(from_fp);
return (-1);
}
len = strlen(zp->z_ixfr_base) + sizeof(".XXXXXX") + 1;
tmpname = memget(len);
if (!tmpname) {
ns_warning(ns_log_default, "memget failed");
return (-1);
}
#ifdef SHORT_FNAMES
filenamecpy(tmpname, zp->z_ixfr_base);
#else
(void) strcpy(tmpname, zp->z_ixfr_base);
#endif /* SHORT_FNAMES */
(void) strcat(tmpname, ".XXXXXX");
if ((fd = mkstemp(tmpname)) == -1) {
ns_warning(ns_log_db, "can't make tmpfile (%s): %s",
tmpname, strerror(errno));
memput(tmpname, len);
(void) my_fclose(from_fp);
return (-1);
}
if ((to_fp = fdopen(fd, "r+")) == NULL) {
ns_warning(ns_log_db, "%s: %s",
tmpname, strerror(errno));
(void) unlink(tmpname);
memput(tmpname, len);
(void) my_fclose(from_fp);
(void) close(fd);
return (-1);
}
if (fgets(buf, sizeof(buf), from_fp) == NULL) {
ns_error(ns_log_update, "fgets() from %s failed: %s",
zp->z_ixfr_base, strerror(errno));
error++;
goto clean_up;
}
if (strcmp(buf, LogSignature) != 0) {
ns_error(ns_log_update, "invalid log file %s",
zp->z_ixfr_base);
error++;
goto clean_up;
}
if (fseek( from_fp, seek, 0) < 0) {
error++;
goto clean_up;
}
found = 0;
for (;;) {
if (getword(buf, sizeof buf, from_fp, 0)) {
if (strcasecmp(buf, "[END_DELTA]") == 0) {
if (!(fgets(buf, 2, from_fp) == NULL)) /* eat <cr><lf> */
found = 1;
break;
}
}
if (feof(from_fp))
break;
}
if (found) {
ns_debug(ns_log_default, 1,
"ixfr_log_maint(): found [END_DELTA]");
fprintf(to_fp, "%s", LogSignature);
while ((rcount = fread(buf, sizeof(char), MAXBSIZE, from_fp)) > 0) {
wcount = fwrite(buf, sizeof(char), rcount, to_fp);
if (rcount != wcount || wcount == -1) {
ns_warning(ns_log_default,
"ixfr_log_maint: error in writting copy");
break;
}
}
if (rcount < 0)
ns_warning(ns_log_default,
"ixfr_log_maint: error in reading copy");
}
clean_up:
(void) my_fclose(to_fp);
(void) my_fclose(from_fp);
if (error == 0) {
if (isc_movefile(tmpname, zp->z_ixfr_base) == -1) {
ns_warning(ns_log_default,
"can not rename %s to %s :%s",
tmpname, zp->z_ixfr_base, strerror(errno));
}
if ((from_fp = fopen(zp->z_ixfr_base, "r")) == NULL) {
ns_warning(ns_log_db, "%s: %s",
zp->z_ixfr_base, strerror(errno));
memput(tmpname, len);
return (-1);
}
if (fstat(fileno(from_fp), &sb) < 0) {
ns_warning(ns_log_db, "%s: %s",
zp->z_ixfr_base, strerror(errno));
memput(tmpname, len);
(void) my_fclose(from_fp);
return (-1);
}
if (sb.st_size <= 0)
(void) unlink(zp->z_ixfr_base);
else if (chmod(zp->z_ixfr_base, 0644) < 0)
ns_error(ns_log_update,
"chmod(%s,%o) failed, pressing on: %s",
zp->z_source, sb.st_mode, strerror(errno));
(void) my_fclose(from_fp);
}
(void) unlink(tmpname);
memput(tmpname, len);
/* signal to read for lowest serial number */
zp->z_serial_ixfr_start = 0;
ns_debug(ns_log_default, 3, "%s, size %ld max %ld\n", zp->z_ixfr_base,
(long)sb.st_size, (long)zp->z_max_log_size_ixfr);
if (error)
return(-1);
else
return (0);
}
-826
View File
@@ -1,826 +0,0 @@
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "$Id: ns_lexer.c,v 8.31.10.1 2003/06/02 09:56:35 marka Exp $";
#endif /* not lint */
/*
* Copyright (c) 1996-2000 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 <sys/un.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
#define LEXER_MAX_PUSHBACK 2
typedef struct lexer_file_context {
char * name;
FILE * stream;
int line_number;
LexerState state;
u_int flags;
int warnings;
int errors;
u_int pushback_count;
char pushback[LEXER_MAX_PUSHBACK];
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) ISC_FORMAT_PRINTF(3, 0);
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, "%s", message);
}
/*
* Keywords
*/
struct keyword {
const 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", T_ALLOW},
{"allow-query", T_ALLOW_QUERY},
{"allow-recursion", T_ALLOW_RECURSION},
{"allow-transfer", T_ALLOW_TRANSFER},
{"allow-update", T_ALLOW_UPDATE},
#ifdef BIND_NOTIFY
{"also-notify", T_ALSO_NOTIFY},
#endif
{"auth-nxdomain", T_AUTH_NXDOMAIN},
{"blackhole", T_BLACKHOLE},
{"bogus", T_BOGUS},
{"category", T_CATEGORY},
{"class", T_CLASS},
{"channel", T_CHANNEL},
{"check-names", T_CHECK_NAMES},
{"cleaning-interval", T_CLEAN_INTERVAL},
{"controls", T_CONTROLS},
{"coresize", T_CORESIZE},
{"datasize", T_DATASIZE},
{"deallocate-on-exit", T_DEALLOC_ON_EXIT},
{"debug", T_DEBUG},
{"default", T_DEFAULT},
{"dialup", T_DIALUP},
{"directory", T_DIRECTORY},
{"dump-file", T_DUMP_FILE},
{"dynamic", T_DYNAMIC},
{"edns", T_EDNS},
{"edns-udp-size", T_EDNS_UDP_SIZE},
{"explicit", T_EXPLICIT},
{"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},
{"group", T_GROUP},
{"has-old-clients", T_HAS_OLD_CLIENTS},
{"heartbeat-interval", T_HEARTBEAT},
{"hint", T_HINT},
#ifdef HITCOUNTS
{"hit-count", T_HITCOUNT},
#endif /* HITCOUNTS */
{"host-statistics", T_HOSTSTATS},
{"host-statistics-max", T_HOSTSTATSMAX},
{"hostname", T_HOSTNAME},
{"if-no-answer", T_IF_NO_ANSWER},
{"if-no-domain", T_IF_NO_DOMAIN},
{"ignore", T_IGNORE},
{"include", T_INCLUDE},
{"inet", T_INET},
{"interface-interval", T_INTERFACE_INTERVAL},
{"ixfr-base", T_FILE_IXFR},
{"ixfr-tmp-file", T_IXFR_TMP},
{"key", T_SEC_KEY},
{"keys", T_KEYS},
{"lame-ttl", T_LAME_TTL},
{"listen-on", T_LISTEN_ON},
{"logging", T_LOGGING},
{"maintain-ixfr-base", T_MAINTAIN_IXFR_BASE},
{"many-answers", T_MANY_ANSWERS},
{"master", T_MASTER},
{"masters", T_MASTERS},
{"max-ixfr-log-size", T_MAX_LOG_SIZE_IXFR},
{"max-ncache-ttl", T_MAX_NCACHE_TTL},
{"max-transfer-time-in", T_MAX_TRANSFER_TIME_IN},
{"memstatistics-file", T_MEMSTATS_FILE},
{"min-roots", T_MIN_ROOTS},
{"multiple-cnames", T_MULTIPLE_CNAMES},
{"name", T_NAME},
{"named-xfer", T_NAMED_XFER},
{"no", T_NO},
#ifdef BIND_NOTIFY
{"notify", T_NOTIFY},
#endif
{"null", T_NULL_OUTPUT},
{"one-answer", T_ONE_ANSWER},
{"only", T_ONLY},
{"order", T_ORDER},
{"options", T_OPTIONS},
{"owner", T_OWNER},
{"perm", T_PERM},
{"pid-file", T_PIDFILE},
{"port", T_PORT},
{"preferred-glue", T_PREFERRED_GLUE},
{"print-category", T_PRINT_CATEGORY},
{"print-severity", T_PRINT_SEVERITY},
{"print-time", T_PRINT_TIME},
{"pubkey", T_PUBKEY},
{"query-source", T_QUERY_SOURCE},
{"rfc2308-type1", T_RFC2308_TYPE1},
{"rrset-order", T_RRSET_ORDER},
{"recursion", T_RECURSION},
{"response", T_RESPONSE},
{"secret", T_SECRET},
{"serial-queries", T_SERIAL_QUERIES},
{"server", T_SERVER},
{"severity", T_SEVERITY},
{"size", T_SIZE},
{"slave", T_SLAVE},
{"sortlist", T_SORTLIST},
{"stacksize", T_STACKSIZE},
{"statistics-file", T_STATS_FILE},
{"statistics-interval", T_STATS_INTERVAL},
{"stub", T_STUB},
{"support-ixfr", T_SUPPORT_IXFR},
#ifdef BIND_NOTIFY
{"suppress-initial-notify", T_NOTIFY_INITIAL},
#endif
{"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},
{"treat-cr-as-space", T_TREAT_CR_AS_SPACE},
{"true", T_TRUE},
{"trusted-keys", T_TRUSTED_KEYS},
{"type", T_TYPE},
{"unix", T_UNIX},
{"unlimited", T_UNLIMITED},
{"use-id-pool", T_USE_ID_POOL},
{"use-ixfr", T_USE_IXFR},
{"version", T_VERSION},
{"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 = savestr(filename, 1);
lf->line_number = 1;
lf->state = scan;
lf->flags = 0;
lf->warnings = 0;
lf->errors = 0;
lf->pushback_count = 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);
freestr(lf->name);
memput(lf, sizeof *lf);
}
/*
* Character Input
*/
#define LEXER_GETC(c, cf) \
do { \
if ((cf)->pushback_count > 0) { \
(cf)->pushback_count--; \
(c) = (cf)->pushback[(cf)->pushback_count]; \
} else \
(c) = getc((cf)->stream); \
} while (0);
#define LEXER_UNGETC(c, cf) \
do { \
INSIST((cf)->pushback_count < LEXER_MAX_PUSHBACK); \
(cf)->pushback[(cf)->pushback_count++] = (c); \
} while (0);
static void
scan_to_comment_end(int c_plus_plus_style) {
int c;
int done = 0;
int prev_was_star = 0;
while (!done) {
LEXER_GETC(c, current_file);
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 */
LEXER_UNGETC(c, current_file);
done = 1;
} else {
current_file->line_number++;
}
prev_was_star = 0;
break;
default:
prev_was_star = 0;
}
}
}
static int
get_next_char(int comment_ok) {
int c, nc;
if (current_file->flags & LEX_EOF)
return (EOF);
LEXER_GETC(c, current_file);
if (comment_ok) {
while (c == '/' || c == '#') {
if (c == '#') {
scan_to_comment_end(1);
if (current_file->flags & LEX_EOF)
return (EOF);
LEXER_GETC(c, current_file);
} else {
LEXER_GETC(nc, current_file);
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);
LEXER_GETC(c, current_file);
break;
default:
LEXER_UNGETC(nc, current_file);
return ('/');
}
}
}
}
if (c == EOF)
current_file->flags |= LEX_EOF;
else if (c == '\n')
current_file->line_number++;
return (c);
}
static void
put_back_char(int c) {
if (c == EOF)
current_file->flags |= LEX_EOF;
else {
LEXER_UNGETC(c, current_file);
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 (c != EOF && 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;
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 (c != EOF && 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 = strtol(id->buffer, (char**)0, 0);
token = L_NUMBER;
}
break;
case identifier:
if (c != EOF && 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 (c != EOF && 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 lexer_initialize", 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));
id = NULL;
lexer_initialized = 0;
}
-45
View File
@@ -1,45 +0,0 @@
/*
* Copyright (c) 1996-2000 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 *, ...) ISC_FORMAT_PRINTF(2, 3);
int parser_error(int, const char *, ...) ISC_FORMAT_PRINTF(2, 3);
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 */
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
-269
View File
@@ -1,269 +0,0 @@
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "$Id: ns_ncache.c,v 8.30 2002/11/17 14:51:51 marka Exp $";
#endif /* not lint */
/*
* Copyright (c) 1996-2000 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 <sys/un.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,
const char *qname, int qclass, int qtype)
{
struct databuf *dp;
HEADER *hp;
u_char *cp, *eom, *rdatap;
char dname[MAXDNAME];
int n, type, class, flags;
u_int ancount, nscount, dlen;
#ifdef RETURNSOA
u_int32_t ttl;
u_int16_t atype;
u_char *sp, *cp1;
u_char data[MAXDATA];
u_char *eod = data + sizeof(data);
#endif
nameserIncr(from.sin_addr, nssRcvdNXD);
hp = (HEADER *)msg;
cp = msg + HFIXEDSZ;
eom = msg + msglen;
switch (ntohs(hp->qdcount)) {
case 0:
dname[sizeof dname - 1] = '\0';
strncpy(dname, qname, sizeof dname);
if (dname[sizeof dname - 1] != '\0') {
ns_debug(ns_log_ncache, 1,
"qp->qname too long (%d)", strlen(qname));
hp->rcode = FORMERR;
return;
}
class = qclass;
type = qtype;
break;
case 1:
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);
if (class > CLASS_MAX) {
ns_debug(ns_log_ncache, 1,
"bad class in cache_n_resp");
hp->rcode = FORMERR;
return;
}
break;
default:
ns_debug(ns_log_ncache, 1,
"QDCOUNT>1 (%d) in cache_n_resp", ntohs(hp->qdcount));
hp->rcode = FORMERR;
return;
}
ns_debug(ns_log_ncache, 1, "ncache: dname %s, type %d, class %d",
dname, type, class);
ancount = ntohs(hp->ancount);
nscount = ntohs(hp->nscount);
while (ancount--) {
u_int32_t ttl;
int atype, 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: not CNAME (%s) or wrong class (%s)",
p_type(atype), p_class(aclass));
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: bad cname target");
return;
}
cp += n;
if (cp != rdatap + dlen) {
ns_debug(ns_log_ncache, 3, "ncache: bad cname rdata");
return;
}
}
dp = NULL;
#ifdef RETURNSOA
while (nscount--) {
sp = cp;
/* 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(cp, msg + msglen);
if (n < 0) {
ns_debug(ns_log_ncache, 3, "ncache: form error");
return;
}
cp += n;
BOUNDS_CHECK(cp, 3 * INT16SZ + INT32SZ);
GETSHORT(atype, cp); /* type */
cp += INT16SZ; /* class */
GETLONG(ttl, cp); /* ttl */
GETSHORT(dlen, cp); /* dlen */
BOUNDS_CHECK(cp, dlen);
if (atype != T_SOA) {
ns_debug(ns_log_ncache, 3,
"ncache: type (%d) != T_SOA", atype);
cp += dlen;
continue;
}
rdatap = cp;
/* origin */
n = dn_expand(msg, msg + msglen, cp, (char*)data, eod - data);
if (n < 0) {
ns_debug(ns_log_ncache, 3,
"ncache: origin form error");
return;
}
cp += n;
n = strlen((char*)data) + 1;
cp1 = data + n;
/* mail */
n = dn_expand(msg, msg + msglen, cp, (char*)cp1, eod - cp1);
if (n < 0) {
ns_debug(ns_log_ncache, 3, "ncache: mail form error");
return;
}
cp += n;
n = strlen((char*)cp1) + 1;
cp1 += n;
n = 5 * INT32SZ;
if (n > (eod - cp1)) /* Can't happen. See MAXDATA. */
return;
BOUNDS_CHECK(cp, n);
memcpy(cp1, cp, n);
/* serial, refresh, retry, expire, min */
cp1 += n;
cp += n;
if (cp != 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, sp, (char*)cp1, eod - cp1);
if (n < 0) {
ns_debug(ns_log_ncache, 3, "ncache: form error 2");
return;
}
n = strlen((char*)cp1) + 1;
cp1 += n;
/*
* we only want to store these long enough so that
* ns_resp can find it.
*/
if (qtype == T_SOA && hp->rcode == NXDOMAIN)
ttl = 0;
dp = savedata(class, type,
MIN(ttl, server_options->max_ncache_ttl) +
tt.tv_sec, data,
cp1 - data);
break;
}
#endif
if (dp == NULL)
#ifdef STRICT_RFC2308
dp = savedata(class, type, tt.tv_sec, NULL, 0);
#else
dp = savedata(class, type, NTTL + tt.tv_sec, NULL, 0);
#endif
dp->d_zone = DB_Z_CACHE;
dp->d_cred = hp->aa ? DB_C_AUTH : DB_C_ANSWER;
dp->d_secure = DB_S_INSECURE; /* BEW - should be UNCHECKED */
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;
}
n = db_update(dname, dp, dp, NULL, flags, hashtab, from);
if (n != OK)
ns_debug(ns_log_ncache, 1,
"db_update failed (%d), cache_n_resp()", n);
else
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));
db_detach(&dp);
}
-462
View File
@@ -1,462 +0,0 @@
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "$Id: ns_notify.c,v 8.20 2002/04/25 05:27:12 marka Exp $";
#endif /* not lint */
/*
* Copyright (c) 1994-2000 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.
*/
/* Import. */
#include "port_before.h"
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/file.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <arpa/inet.h>
#include <errno.h>
#include <limits.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 <isc/dst.h>
#include "port_after.h"
#include "named.h"
#ifdef BIND_NOTIFY
/* Types. */
struct pnotify {
char * name;
ns_class class;
ns_type type;
evTimerID timer;
LINK(struct pnotify) link;
};
/* Forward. */
static void sysnotify(const char *, ns_class, ns_type);
static void sysnotify_slaves(const char *, const char *,
ns_class, ns_type, int, int *, int *);
static void sysnotify_ns(const char *, const char *,
ns_class, ns_type, int, int *, int *);
static void free_notify(struct pnotify *);
static void notify_timer(evContext, void *,
struct timespec, struct timespec);
/* Local. */
static LIST(struct pnotify) pending_notifies;
static LIST(struct pnotify) loading_notifies;
/* Public. */
/*
* ns_notify(dname, class, type)
* call this when a zone has changed and its slaves need to know.
*/
void
ns_notify(const char *dname, ns_class class, ns_type type) {
static const char no_room[] = "%s failed, cannot notify for zone %s";
int delay, max_delay;
struct zoneinfo *zp;
struct pnotify *ni;
zp = find_auth_zone(dname, class);
if (zp == NULL) {
ns_warning(ns_log_notify,
"no zone found for notify (\"%s\" %s %s)",
(dname && *dname) ? dname : ".",
p_class(class), p_type(type));
return;
}
if (ns_samename(dname, zp->z_origin) != 1) {
ns_warning(ns_log_notify,
"notify not called with top of zone (\"%s\" %s %s)",
(dname && *dname) ? dname : ".",
p_class(class), p_type(type));
return;
}
if ((zp->z_flags & Z_NOTIFY) != 0) {
ns_info(ns_log_notify,
"suppressing duplicate notify (\"%s\" %s %s)",
(dname && *dname) ? dname : ".",
p_class(class), p_type(type));
return;
}
ni = memget(sizeof *ni);
if (ni == NULL) {
ns_info(ns_log_notify, no_room, "memget", dname);
return;
}
ni->name = savestr(dname, 0);
if (ni->name == NULL) {
memput(ni, sizeof *ni);
ni = NULL;
ns_info(ns_log_notify, no_room, "memget", dname);
return;
}
ni->class = class;
ni->type = type;
INIT_LINK(ni, link);
evInitID(&ni->timer);
if (loading != 0) {
APPEND(loading_notifies, ni, link);
return;
}
/* Delay notification for from five seconds up to fifteen minutes. */
max_delay = MIN(nzones, 895);
max_delay = MAX(max_delay, 25);
delay = 5 + (rand() % max_delay);
if (evSetTimer(ev, notify_timer, ni,
evAddTime(evNowTime(), evConsTime(delay, 0)),
evConsTime(0, 0), &ni->timer) < 0) {
ns_error(ns_log_notify, "evSetTimer() failed: %s",
strerror(errno));
ni->name = freestr(ni->name);
memput(ni, sizeof *ni);
return;
}
zp->z_flags |= Z_NOTIFY;
APPEND(pending_notifies, ni, link);
ns_debug(ns_log_notify, 3,
"ns_notify(%s, %s, %s): ni %p, zp %p, delay %d",
(dname && *dname) ? dname : ".",
p_class(class), p_type(type),
ni, zp, delay);
}
void
notify_afterload() {
struct pnotify *ni;
INSIST(loading == 0);
while ((ni = HEAD(loading_notifies)) != NULL) {
UNLINK(loading_notifies, ni, link);
ns_notify(ni->name, ni->class, ni->type);
ni->name = freestr(ni->name);
memput(ni, sizeof *ni);
}
}
/*
* ns_unnotify()
* call this when all pending notifies are now considered junque.
*/
void
ns_unnotify(void) {
while (!EMPTY(pending_notifies)) {
struct pnotify *ni = HEAD(pending_notifies);
INSIST(LINKED(ni, link));
UNLINK(pending_notifies, ni, link);
free_notify(ni);
}
}
/*
* ns_stopnotify(const char *dname, ns_class class)
* stop notifies for this particular zone.
*/
void
ns_stopnotify(const char *dname, ns_class class) {
struct pnotify *ni;
ni = HEAD(pending_notifies);
while (ni != NULL &&
(ni->class != class || ns_samename(ni->name, dname) != 1))
ni = NEXT(ni, link);
if (ni != NULL) {
UNLINK(pending_notifies, ni, link);
free_notify(ni);
}
}
/* Private. */
/*
* sysnotify(dname, class, type)
* cause a NOTIFY request to be sysquery()'d to each slave server
* of the zone that "dname" is within.
*/
static void
sysnotify(const char *dname, ns_class class, ns_type type) {
const char *zname;
u_int32_t zserial;
int nns, na, i;
struct zoneinfo *zp;
struct in_addr *also_addr;
ns_debug(ns_log_notify, 3, "sysnotify(%s, %s, %s)",
dname, p_class(class), p_type(type));
zp = find_auth_zone(dname, class);
if (zp == NULL) {
ns_warning(ns_log_notify, "sysnotify: can't find \"%s\" (%s)",
dname, p_class(class));
return;
}
if (ns_samename(dname, zp->z_origin) != 1) {
ns_warning(ns_log_notify, "sysnotify: not auth for zone %s",
dname);
return;
}
if (zp->z_notify == notify_no ||
(zp->z_notify == notify_use_default &&
server_options->notify == notify_no))
return;
if (zp->z_type != z_master && zp->z_type != z_slave) {
ns_warning(ns_log_notify, "sysnotify: %s not master or slave",
dname);
return;
}
zname = zp->z_origin;
zserial = zp->z_serial;
nns = na = 0;
if (zp->z_notify == notify_yes ||
(zp->z_notify == notify_use_default &&
server_options->notify == notify_yes))
sysnotify_slaves(dname, zname, class, type,
zp - zones, &nns, &na);
/*
* Handle any global or zone-specific also-notify clauses
*/
if (zp->z_notify_count != 0) {
/* zone-specific also notify */
ns_debug(ns_log_notify, 3, "zone notify ns = %d",
zp->z_notify_count);
also_addr = zp->z_also_notify;
for (i = 0; i < zp->z_notify_count; i++) {
ns_debug(ns_log_notify, 4, "notifying %s",
inet_ntoa(*also_addr));
sysquery(dname, class, type, also_addr, NULL, 1,
ns_port, NS_NOTIFY_OP, 0);
also_addr++;
}
nns += zp->z_notify_count;
na += zp->z_notify_count;
} else if (server_options->notify_count != 0) {
ns_debug(ns_log_notify, 4, "global notify ns = %d",
server_options->notify_count);
also_addr = server_options->also_notify;
for (i = 0; i < server_options->notify_count; i++) {
ns_debug(ns_log_notify, 3, "notifying %s",
inet_ntoa(*also_addr));
sysquery(dname, class, type, also_addr, NULL, 1,
ns_port, ns_o_notify, 0);
also_addr++;
}
nns += server_options->notify_count;
na += server_options->notify_count;
}
if (nns != 0 || na != 0)
ns_info(ns_log_notify,
"Sent NOTIFY for \"%s %s %s %u\" (%s); %d NS, %d A",
dname, p_class(class), p_type(type), zserial, zname, nns, na);
}
static void
sysnotify_slaves(const char *dname, const char *zname,
ns_class class, ns_type type,
int zn, int *nns, int *na)
{
const char *mname, *fname;
struct hashbuf *htp;
struct namebuf *np;
struct databuf *dp;
/*
* Master.
*/
htp = hashtab;
np = nlookup(zname, &htp, &fname, 0);
if (np == NULL) {
ns_warning(ns_log_notify,
"sysnotify: found name \"%s\" but not zone",
dname);
return;
}
mname = NULL;
for (dp = np->n_data; dp != NULL; dp = dp->d_next) {
if (dp->d_zone == DB_Z_CACHE || !match(dp, class, ns_t_soa))
continue;
if (dp->d_type == ns_t_sig)
continue;
if (mname) {
ns_notice(ns_log_notify,
"multiple SOA's for zone \"%s\"?",
zname);
return;
}
mname = (char *) dp->d_data;
}
if (mname == NULL) {
ns_notice(ns_log_notify, "no SOA found for zone \"%s\"",
zname);
return;
}
for (dp = np->n_data; dp != NULL; dp = dp->d_next) {
if (dp->d_zone == DB_Z_CACHE || !match(dp, class, ns_t_ns))
continue;
if (dp->d_type == ns_t_sig)
continue;
if (ns_samename((char*)dp->d_data, mname) == 1)
continue;
sysnotify_ns(dname, (char *)dp->d_data, class, type,
zn, nns, na);
}
}
static void
sysnotify_ns(const char *dname, const char *aname,
ns_class class, ns_type type,
int zn, int *nns, int *na)
{
struct databuf *adp;
struct namebuf *anp;
const char *fname;
struct in_addr nss[NSMAX];
struct hashbuf *htp;
int is_us, nsc, auth6, neg;
int cname = 0;
htp = hashtab;
anp = nlookup(aname, &htp, &fname, 0);
nsc = 0;
is_us = 0;
auth6 = 0;
neg = 0;
if (anp != NULL)
for (adp = anp->n_data; adp; adp = adp->d_next) {
struct in_addr ina;
if (adp->d_class != class)
continue;
if (adp->d_rcode == NXDOMAIN) {
neg = 1;
break;
}
if (adp->d_type == T_CNAME && adp->d_rcode == 0) {
cname = 1;
ns_error(ns_log_notify,
"NS '%s' for '%s/%s' is a CNAME",
*aname ? aname : ".",
*dname ? dname : ".",
p_class(class));
break;
}
if ((adp->d_type == T_AAAA || adp->d_type == ns_t_a6) &&
(zones[adp->d_class].z_type == z_master ||
zones[adp->d_class].z_type == z_slave)) {
auth6 = 1;
continue;
}
if (!match(adp, class, T_A))
continue;
if (adp->d_rcode) {
neg = 1;
continue;
}
if (adp->d_type == ns_t_sig)
continue;
ina = ina_get(adp->d_data);
if (aIsUs(ina)) {
is_us = 1;
continue;
}
if (nsc < NSMAX)
nss[nsc++] = ina;
} /*next A*/
if (nsc == 0) {
if (!is_us && !cname && !auth6 && !neg &&
!NS_OPTION_P(OPTION_NOFETCHGLUE)) {
struct qinfo *qp;
qp = sysquery(aname, class, ns_t_a, NULL, NULL, 0,
ns_port, ns_o_query, 0);
if (qp != NULL)
qp->q_notifyzone = zn;
}
return;
}
sysquery(dname, class, type, nss, NULL, nsc, ns_port, ns_o_notify, 0);
(*nns)++;
*na += nsc;
}
static void
free_notify(struct pnotify *ni) {
struct zoneinfo *zp;
INSIST(!LINKED(ni, link));
zp = find_auth_zone(ni->name, ni->class);
if (zp != NULL && ns_samename(ni->name, zp->z_origin) == 1) {
INSIST((zp->z_flags & Z_NOTIFY) != 0);
zp->z_flags &= ~Z_NOTIFY;
}
if (evTestID(ni->timer)) {
evClearTimer(ev, ni->timer);
evInitID(&ni->timer);
}
ni->name = freestr(ni->name);
memput(ni, sizeof *ni);
}
static void
notify_timer(evContext ctx, void *uap,
struct timespec due,
struct timespec inter)
{
struct pnotify *ni = uap;
UNUSED(ctx);
UNUSED(due);
UNUSED(inter);
INSIST(evTestID(ni->timer));
evInitID(&ni->timer);
INSIST(LINKED(ni, link));
UNLINK(pending_notifies, ni, link);
sysnotify(ni->name, ni->class, ni->type);
free_notify(ni);
}
#endif /*BIND_NOTIFY*/
File diff suppressed because it is too large. Load diff
-243
View File
@@ -1,243 +0,0 @@
/*
* Copyright (c) 1996-2000 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 <sys/socket.h>
#include <sys/un.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) {
ste->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, const 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 = savestr(key, 1);
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 = savestr(key, 1);
ste->value = value;
ste->flags = flags;
}
}
void
undefine_symbol(symbol_table st, char *key, int type) {
int hash;
symbol_entry prev_ste, 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);
}
-64
View File
@@ -1,64 +0,0 @@
/*
* Copyright (c) 1996-2000 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_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, const 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 */
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
-297
View File
@@ -1,297 +0,0 @@
#if !defined(lint) && !defined(SABER)
static const char sccsid[] = "@(#)ns_main.c 4.55 (Berkeley) 7/1/91";
static const char rcsid[] = "$Id: ns_signal.c,v 8.15 2002/05/18 01:39:15 marka Exp $";
#endif /* not lint */
/*
* Copyright (c) 1986, 1989, 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-2000 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.
*/
/* Import. */
#include "port_before.h"
#include <sys/types.h>
#include <sys/param.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#ifdef SVR4 /* XXX */
# include <sys/sockio.h>
#else
#ifndef __hpux
# include <sys/mbuf.h>
#endif
#endif
#include <netinet/in.h>
#include <net/route.h>
#include <net/if.h>
#include <arpa/nameser.h>
#include <arpa/inet.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <grp.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <netdb.h>
#include <pwd.h>
#include <resolv.h>
#include <string.h>
#include <syslog.h>
#include <time.h>
#include <unistd.h>
#include <isc/eventlib.h>
#include <isc/logging.h>
#include <isc/memcluster.h>
#include <isc/list.h>
#include "port_after.h"
#include "named.h"
/* Forward. */
static SIG_FN onhup(int);
static SIG_FN onintr(int);
static SIG_FN setdumpflg(int);
static SIG_FN setIncrDbgFlg(int);
static SIG_FN setNoDbgFlg(int);
static SIG_FN setQrylogFlg(int);
static SIG_FN setstatsflg(int);
static SIG_FN discard_pipe(int);
static SIG_FN setreapflg(int);
/* Data. */
static struct {
int sig;
SIG_FN (*hand)(int);
} sighandlers[] = {
#ifdef DEBUG
{ SIGUSR1, setIncrDbgFlg },
{ SIGUSR2, setNoDbgFlg },
#endif
#if defined(SIGWINCH) && defined(QRYLOG)
{ SIGWINCH, setQrylogFlg },
#endif
#if defined(SIGXFSZ)
{ SIGXFSZ, onhup }, /* Wierd DEC Hesiodism, harmless. */
#endif
{ SIGINT, setdumpflg },
{ SIGILL, setstatsflg },
{ SIGHUP, onhup },
{ SIGCHLD, setreapflg },
{ SIGPIPE, discard_pipe },
{ SIGTERM, onintr }
};
static sigset_t mask;
static int blocked = 0;
/* Private. */
static SIG_FN
onhup(int sig) {
UNUSED(sig);
ns_need_unsafe(main_need_reload);
}
static SIG_FN
onintr(int sig) {
UNUSED(sig);
ns_need_unsafe(main_need_exit);
}
static SIG_FN
setdumpflg(int sig) {
UNUSED(sig);
ns_need_unsafe(main_need_dump);
}
#ifdef DEBUG
static SIG_FN
setIncrDbgFlg(int sig) {
UNUSED(sig);
desired_debug++;
ns_need_unsafe(main_need_debug);
}
static SIG_FN
setNoDbgFlg(int sig) {
UNUSED(sig);
desired_debug = 0;
ns_need_unsafe(main_need_debug);
}
#endif /*DEBUG*/
#if defined(QRYLOG) && defined(SIGWINCH)
static SIG_FN
setQrylogFlg(int sig) {
UNUSED(sig);
ns_need_unsafe(main_need_qrylog);
}
#endif /*QRYLOG && SIGWINCH*/
static SIG_FN
setstatsflg(int sig) {
UNUSED(sig);
ns_need_unsafe(main_need_statsdump);
}
static SIG_FN
discard_pipe(int sig) {
#ifdef SIGPIPE_ONE_SHOT
int saved_errno = errno;
struct sigaction sa;
UNUSED(sig);
memset(&sa, 0, sizeof sa);
sa.sa_mask = mask;
sa.sa_handler = discard_pipe;
if (sigaction(SIGPIPE, &sa, NULL) < 0)
ns_error(ns_log_os, "sigaction failed in discard_pipe: %s",
strerror(errno));
errno = saved_errno;
#else
UNUSED(sig);
#endif
}
static SIG_FN
setreapflg(int sig) {
UNUSED(sig);
ns_need_unsafe(main_need_reap);
}
/* Public. */
void
init_signals(void) {
size_t sh;
/* The mask of all our handlers will block all our other handlers. */
(void)sigemptyset(&mask);
for (sh = 0; sh < sizeof sighandlers / sizeof sighandlers[0]; sh++)
sigaddset(&mask, sighandlers[sh].sig);
/* Install our signal handlers with that shared mask. */
for (sh = 0; sh < sizeof sighandlers / sizeof sighandlers[0]; sh++) {
struct sigaction sa;
memset(&sa, 0, sizeof sa);
sa.sa_mask = mask;
sa.sa_handler = sighandlers[sh].hand;
if (sigaction(sighandlers[sh].sig, &sa, NULL) < 0)
ns_error(ns_log_os,
"sigaction failed in set_signal_handler(%d): %s",
sighandlers[sh].sig, strerror(errno));
}
/* Unblock all signals that we expect to handle. */
if (sigprocmask(SIG_UNBLOCK, &mask, NULL) < 0)
ns_panic(ns_log_os, 1, "sigblock failed: %s", strerror(errno));
}
void
block_signals(void) {
INSIST(!blocked);
if (sigprocmask(SIG_BLOCK, &mask, NULL) < 0)
ns_panic(ns_log_os, 1, "sigblock failed: %s", strerror(errno));
blocked = 1;
}
void
unblock_signals(void) {
INSIST(blocked);
if (sigprocmask(SIG_UNBLOCK, &mask, NULL) < 0)
ns_panic(ns_log_os, 1, "sigblock failed: %s", strerror(errno));
blocked = 0;
}
-414
View File
@@ -1,414 +0,0 @@
#if !defined(lint) && !defined(SABER)
static const char sccsid[] = "@(#)ns_sort.c 4.10 (Berkeley) 3/3/91";
static const char rcsid[] = "$Id: ns_sort.c,v 8.8 2001/09/25 04:50:22 marka 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-2000 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.
*/
/*
* Sorting should really be handled by the resolver, but:
* 1) There are too many brain dead resolvers out there that can't be replaced.
* 2) It would be a pain to individually configure all those resolvers anyway.
*
* Here's the scoop:
*
* To enable address sorting in responses, you need to supply the sortlist
* statement in the config file. The sortlist statement takes an
* address match list and interprets it even more specially than the
* topology statement does.
*
* Each top level statement in the sortlist must itself be an explicit
* address match list with one or two elements. The first element
* (which may be an IP address, an IP prefix, an ACL name or nested
* address match list) of each top level list is checked against the
* source address of the query until a match is found.
*
* Once the source address of the query has been matched, if the top level
* statement contains only one element, the actual primitive element that
* matched the source address is used to select the address in the response
* to move to the beginning of the response. If the statement is a list
* of two elements, then the second element is treated like the address
* match list in a topology statement. Each top level element is assigned
* a distance and the address in the response with the minimum distance is
* moved to the beginning of the response.
*
* In the following example, any queries received from any of the addresses
* of the host itself will get responses preferring addresses on any of
* the locally connected networks. Next most preferred are addresses on
* the 192.168.1/24 network, and after that either the 192.168.2/24 or
* 192.168.3/24 network with no preference shown between these two networks.
* Queries received from a host on the 192.168.1/24 network will prefer
* other addresses on that network to the 192.168.2/24 and 192.168.3/24
* networks. Queries received from a host on the 192.168.4/24 or the
* 192.168.5/24 network will only prefer other addresses on their
* directly connected networks.
*
* sortlist {
* {
* localhost;
* {
* localnets;
* 192.168.1/24;
* { 192,168.2/24; 192.168.3/24; };
* };
* };
* {
* 192.168.1/24;
* {
* 192.168.1/24;
* { 192.168.2/24; 192.168.3/24; };
* };
* };
* {
* 192.168.2/24;
* {
* 192.168.2/24;
* { 192.168.1/24; 192.168.3/24; };
* };
* };
* {
* 192.168.3/24;
* {
* 192.168.3/24;
* { 192.168.1/24; 192.168.2/24; };
* };
* };
* {
* { 192.168.4/24; 192.168.5/24; };
* };
* };
*
*
* The following example will give reasonable behaviour for the local host
* and hosts on directly connected networks. It is similar to the behavior
* of the address sort in BIND 4.9.x. Responses sent to queries from the
* local host will favor any of the directly connected networks. Responses
* sent to queries from any other hosts on a directly connected network will
* prefer addresses on that same network. Responses to other queries will
* not be sorted.
*
* sortlist {
* { localhost; localnets; };
* { localnets; };
* };
*
* XXX - it wouldb e nice to have an ACL called "source" that matched the
* source address of a query so that a host could be configured to
* automatically prefer itself, and an ACL called "sourcenet", that
* would return the primitive IP match element that matched the source
* address so that you could do:
* { localnets; { sourcenet; { other stuff ...}; };
* and automatically get similar behaviour to what you get with:
* { localnets; };
*
*/
#include "port_before.h"
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/file.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <syslog.h>
#include <resolv.h>
#include <string.h>
#include <isc/eventlib.h>
#include <isc/logging.h>
#include "port_after.h"
#include "named.h"
static int sort_rr(u_char *cp, u_char *eom, int ancount, ip_match_list iml);
static int ip_match_address_elt(ip_match_list, struct in_addr,
ip_match_element *);
void
sort_response(u_char *cp, u_char *eom, int ancount, struct sockaddr_in *from) {
struct in_addr address;
struct ip_match_element imelement;
ip_match_element imetl, imematch, imeprimitive;
struct ip_match_list imlist;
ip_match_list iml;
int indirect, matched;
if (server_options->sortlist == NULL)
return;
if (from->sin_family != AF_INET)
return;
address = from->sin_addr;
for (imetl = server_options->sortlist->first; imetl != NULL;
imetl = imetl->next) {
if (imetl->type == ip_match_indirect)
imematch = imetl->u.indirect.list->first;
else
/*
* allow a bare pattern as a top level statement
* and treat it like {pattern;};
*/
imematch = imetl;
switch (imematch->type) {
case ip_match_pattern:
indirect = 0;
break;
case ip_match_indirect:
indirect = 1;
break;
case ip_match_localhost:
imematch->u.indirect.list = local_addresses;
indirect = 1;
break;
case ip_match_localnets:
imematch->u.indirect.list = local_networks;
indirect = 1;
break;
default:
indirect = 0;
panic("unexpected ime type in ip_match_address()",
NULL);
}
if (indirect) {
imeprimitive = NULL;
matched = ip_match_address_elt(imematch->u.indirect.list,
address, &imeprimitive);
if (matched >= 0) {
if (imematch->flags & IP_MATCH_NEGATE)
/* Don't sort */
return;
} else
continue;
} else {
if (ina_onnet(address, imematch->u.direct.address,
imematch->u.direct.mask)) {
if (imematch->flags & IP_MATCH_NEGATE)
/* Don't sort */
return;
else
imeprimitive = imematch;
} else
continue;
}
if (imetl != imematch && imematch->next != NULL) {
/*
* Not a bare pattern at the top level, but a two
* element list
*/
switch (imematch->next->type) {
case ip_match_pattern:
case ip_match_localhost:
case ip_match_localnets:
imelement = *(imematch->next);
imelement.next = NULL;
iml = &imlist;
iml->first = iml->last = &imelement;
break;
case ip_match_indirect:
iml = imematch->next->u.indirect.list;
break;
default:
iml = NULL;
panic("unexpected ime type in ip_match_address()",
NULL);
}
} else if (imeprimitive) {
imelement = *imeprimitive;
imelement.next = NULL;
iml = &imlist;
iml->first = iml->last = &imelement;
} else {
/* Don't sort because we'd just use "any" */
return;
}
sort_rr(cp, eom, ancount, iml);
break;
}
return;
}
static int
sort_rr(u_char *cp, u_char *eom, int ancount, ip_match_list iml) {
int type, class, dlen, n, c, distance, closest = 0;
struct in_addr inaddr;
u_char *rr1 = NULL, *rrbest = NULL, *cpstart;
rr1 = NULL;
cpstart = cp;
for (c = ancount; c > 0; --c) {
n = dn_skipname(cp, eom);
if (n < 0)
return (1); /* bogus, stop processing */
cp += n;
if (cp + QFIXEDSZ > eom)
return (1);
GETSHORT(type, cp);
GETSHORT(class, cp);
cp += INT32SZ;
GETSHORT(dlen, cp);
if (dlen > eom - cp)
return (1); /* bogus, stop processing */
switch (type) {
case T_A:
switch (class) {
case C_IN:
case C_HS:
memcpy((char *)&inaddr, cp, INADDRSZ);
/* Find the address with the minimum distance */
if (rr1 == NULL) {
rr1 = cp;
rrbest = cp;
closest = distance_of_address(iml, inaddr);
} else {
distance = distance_of_address(iml, inaddr);
if (distance < closest) {
rrbest = cp;
closest = distance;
}
}
break;
}
break;
}
cp += dlen;
}
if (rr1 != rrbest && rr1 != NULL) {
memcpy((char *)&inaddr, rrbest, INADDRSZ);
memcpy(rrbest, rr1, INADDRSZ);
memcpy(rr1, (char *)&inaddr, INADDRSZ);
}
return (0);
}
/*
* Just like ip_match_address(), but also returns a pointer to the primitive
* element that matched.
*/
static int
ip_match_address_elt(ip_match_list iml, struct in_addr address,
ip_match_element *imep) {
ip_match_element ime;
int ret;
int indirect;
INSIST(iml != NULL);
for (ime = iml->first; ime != NULL; ime = ime->next) {
switch (ime->type) {
case ip_match_pattern:
indirect = 0;
break;
case ip_match_indirect:
indirect = 1;
break;
case ip_match_localhost:
ime->u.indirect.list = local_addresses;
indirect = 1;
break;
case ip_match_localnets:
ime->u.indirect.list = local_networks;
indirect = 1;
break;
default:
indirect = 0;
panic("unexpected ime type in ip_match_address()",
NULL);
}
if (indirect) {
ret = ip_match_address_elt(ime->u.indirect.list,
address, imep);
if (ret >= 0) {
if (ime->flags & IP_MATCH_NEGATE)
ret = (ret) ? 0 : 1;
return (ret);
}
} else {
if (ina_onnet(address, ime->u.direct.address,
ime->u.direct.mask)) {
*imep = ime;
if (ime->flags & IP_MATCH_NEGATE)
return (0);
else
return (1);
}
}
}
return (-1);
}
-452
View File
@@ -1,452 +0,0 @@
#if !defined(lint) && !defined(SABER)
static const char sccsid[] = "@(#)ns_stats.c 4.10 (Berkeley) 6/27/90";
static const char rcsid[] = "$Id: ns_stats.c,v 8.34 2001/08/09 13:17:21 marka 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-2000 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/un.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <arpa/inet.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 <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 void nameserStats(FILE *);
static u_int32_t ns_stats_cnt = 0;
static int ns_stats_disabled = 0;
void
ns_stats_dumpandclear() {
time_t timenow = time(NULL);
FILE *f;
ns_stats();
if (!(f = fopen(server_options->stats_filename, "a"))) {
ns_notice(ns_log_statistics, "cannot open stat file, \"%s\"",
server_options->stats_filename);
}
if (f != NULL) {
(void) fchown(fileno(f), user_id, group_id);
fprintf(f, "+++ Host Statistics Cleared +++ (%ld) %s",
(long)timenow, checked_ctime(&timenow));
(void) my_fclose(f);
}
ns_freestats();
}
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;
}
(void) fchown(fileno(f), user_id, group_id);
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++)
fprintf(f, "%lu\t%s queries\n", typestats[i], p_type(i));
/* name server statistics */
nameserStats(f);
fprintf(f, "--- Statistics Dump --- (%ld) %s",
(long)timenow, checked_ctime(&timenow));
(void) my_fclose(f);
/* Now do the memory statistics file */
if (!(f = fopen(server_options->memstats_filename, "a"))) {
ns_notice(ns_log_statistics, "cannot open memstat file, \"%s\"",
server_options->memstats_filename);
return;
}
(void) fchown(fileno(f), user_id, group_id);
fprintf(f, "+++ Memory 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));
fprintf(f, "++ Memory Statistics ++\n");
memstats(f);
fprintf(f, "-- Memory Statistics --\n");
fprintf(f, "--- Memory 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 */
"RUQ", /* sent us an unapproved query */
"RURQ", /* sent us an unapproved recursive query */
"RUXFR", /* sent us an unapproved AXFR or IXFR */
"RUUpd", /* sent us an unapproved update */
};
/*
* 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++;
ns_stats_cnt = 0;
ns_stats_disabled = 0;
}
dummy.addr = addr;
ns = (struct nameser *)tree_srch(&nameserTree, nameserCompar,
(tree_t)&dummy);
if (ns == NULL && (flags & NS_F_INSERT) != 0) {
if (server_options->max_host_stats != 0 &&
ns_stats_cnt > server_options->max_host_stats) {
if (!ns_stats_disabled)
ns_notice(ns_log_statistics,
"ns_stats_disabled: %s reached",
"host-statistics-max");
ns_stats_disabled = 1;
return (NULL);
}
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;
}
ns_stats_cnt++;
}
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);
if (ns_stats_disabled)
fprintf(f, "++ Host Statistics Incomplete ++\n");
}
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[128];
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))
UNUSED(ctx);
UNUSED(uap);
UNUSED(due);
UNUSED(inter);
getrusage(RUSAGE_SELF, &usage);
getrusage(RUSAGE_CHILDREN, &childu);
/*
* Get around a stupid compiler bug in gcc on solaris.
* There is a problem if three or more doubles are passed to
* sprintf.
* <http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=337&database=gcc>
*/
sprintf(buffer, "CPU=%gu/%gs CHILDCPU=", tv_float(usage.ru_utime),
tv_float(usage.ru_stime));
sprintf(header, "%gu/%gs", tv_float(childu.ru_utime),
tv_float(childu.ru_stime));
ns_info(ns_log_statistics, "USAGE %lu %lu %s%s", (u_long)timenow,
(u_long)boottime, buffer, header);
# 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]) {
sprintf(buffer2, " %s=%lu", p_type(i), typestats[i]);
if (strlen(buffer) + strlen(buffer2) >
sizeof(buffer) - 1) {
ns_info(ns_log_statistics, "%s", buffer);
strcpy(buffer, header);
}
strcat(buffer, buffer2);
}
}
ns_info(ns_log_statistics, "%s", 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, "%s", buffer);
strcpy(buffer, header);
}
strcat(buffer, buffer2);
}
ns_info(ns_log_statistics, "%s", 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;
ns_stats_cnt = 0;
ns_stats_disabled = 0;
}
-124
View File
@@ -1,124 +0,0 @@
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "$Id: ns_udp.c,v 8.9 2000/04/21 06:54:13 vixie Exp $";
#endif /* not lint */
/*
* Copyright (c) 1996-2000 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 <sys/un.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
}
File diff suppressed because it is too large. Load diff
-871
View File
@@ -1,871 +0,0 @@
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "$Id: ns_xfr.c,v 8.69 2002/06/05 03:53:49 marka Exp $";
#endif /* not lint */
/*
* Copyright (c) 1996-2000 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 <sys/un.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <resolv.h>
#include <res_update.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <time.h>
#include <unistd.h>
#include <isc/eventlib.h>
#include <isc/logging.h>
#include <isc/memcluster.h>
#include <isc/dst.h>
#include "port_after.h"
#include "named.h"
static struct qs_x_lev *sx_freelev(struct qs_x_lev *lev);
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);
static struct databuf *db_next(struct databuf *dp);
/*
* void
* ns_xfr(qsp, znp, zone, class, type, opcode, id, serial_ixfr, in_tsig)
* 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, u_int32_t serial_ixfr, struct tsig_record *in_tsig)
{
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_deltalist *changes;
switch (type) {
case ns_t_ixfr:
ns_info(ns_log_xfer_out,
"zone transfer (%s) of \"%s\" (%s) to %s serial %u -> %u",
p_type(type), zones[zone].z_origin, p_class(class),
sin_ntoa(qsp->s_from), serial_ixfr,
zones[zone].z_serial);
break;
case ns_t_axfr: /*FALLTHROUGH*/
#ifdef BIND_ZXFR
case ns_t_zxfr:
#endif
ns_info(ns_log_xfer_out,
"zone transfer (%s) of \"%s\" (%s) to %s serial %u",
p_type(type), zones[zone].z_origin, p_class(class),
sin_ntoa(qsp->s_from), zones[zone].z_serial);
break;
default:
ns_warning(ns_log_xfer_out,
"unsupported XFR (type %s) of \"%s\" (%s) to %s",
p_type(type), zones[zone].z_origin, p_class(class),
sin_ntoa(qsp->s_from));
goto abort;
}
#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,
(const 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,
(const char *)&sndlowat, sizeof sndlowat);
#endif
if (sq_openw(qsp, 64*1024) == -1) {
ns_error(ns_log_xfer_out, "ns_xfr: out of memory");
goto abort;
}
memset(&qsp->xfr, 0, sizeof qsp->xfr);
qsp->xfr.top.axfr = znp;
qsp->xfr.zone = zone;
qsp->xfr.class = class;
if (qsp->flags & STREAM_AXFRIXFR)
type = ns_t_axfr;
qsp->xfr.type = type;
qsp->xfr.id = id;
qsp->xfr.opcode = opcode;
qsp->xfr.msg = memget(XFER_BUFSIZE);
if (!qsp->xfr.msg) {
ns_error(ns_log_xfer_out, "ns_xfr: out of memory");
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;
#ifdef BIND_ZXFR
if (type == ns_t_zxfr) {
enum { rd = 0, wr = 1 };
int z[2];
pid_t p;
if (pipe(z) < 0) {
ns_error(ns_log_xfer_out, "pipe: %s", strerror(errno));
goto abort;
}
p = vfork();
if (p < 0) {
ns_error(ns_log_xfer_out, "vfork: %s", strerror(errno));
goto abort;
}
if (p == 0) {
/* Child. */
dup2(z[rd], STDIN_FILENO);
dup2(qsp->s_rfd, STDOUT_FILENO);
execlp("gzip", "gzip", NULL);
ns_error(ns_log_xfer_out, "execlp: %s", strerror(errno));
_exit(1);
}
ns_info(ns_log_xfer_out, "zxfr gzip pid %lu", p);
/* Parent. */
dup2(z[wr], qsp->s_rfd);
close(z[wr]);
close(z[rd]);
/* When a ZXFR completes, there can be no more requests. */
qsp->flags |= STREAM_DONE_CLOSE;
}
#endif
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 (in_tsig == NULL) {
qsp->xfr.tsig_state = NULL;
qsp->xfr.tsig_size = 0;
} else {
qsp->xfr.tsig_state = memget(sizeof(ns_tcp_tsig_state));
ns_sign_tcp_init(in_tsig->key, in_tsig->sig, in_tsig->siglen,
qsp->xfr.tsig_state);
qsp->xfr.tsig_skip = 0;
qsp->xfr.tsig_size = in_tsig->tsig_size;
}
if (type == ns_t_ixfr) {
changes = ixfr_get_change_list(&zones[zone], serial_ixfr,
zones[zone].z_serial);
ixfr_log_maint(&zones[zone]);
if (changes != NULL) {
qsp->xfr.serial = serial_ixfr;
qsp->xfr.top.ixfr = changes;
}
else {
qsp->xfr.top.ixfr = NULL;
goto abort;
}
} else {
if (sx_pushlev(qsp, znp) < 0) {
ns_error(ns_log_xfer_out, "ns_xfr: out of memory");
abort:
(void) shutdown(qsp->s_rfd, 2);
sq_remove(qsp);
return;
}
}
if (type != ns_t_ixfr) {
ns_debug(ns_log_default, 3, "sq_writeh sx_sendsoa (%s)",
zones[zone].z_origin);
(void) sq_writeh(qsp, sx_sendsoa);
} else {
ns_debug(ns_log_default, 3, "sq_writeh sx_send_ixfr (%s)",
zones[zone].z_origin);
(void) sq_writeh(qsp, sx_send_ixfr);
}
}
/*
* 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);
ns_debug(ns_log_default, 3, "ns_stopxfrs (%s)", zp->z_origin);
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) {
ns_delta *dp;
ns_updrec *rp;
if (qsp->xfr.msg != NULL) {
memput(qsp->xfr.msg, XFER_BUFSIZE);
qsp->xfr.msg = NULL;
}
if (qsp->xfr.type == ns_t_ixfr && qsp->xfr.top.ixfr != NULL) {
while ((dp = HEAD(*qsp->xfr.top.ixfr)) != NULL) {
UNLINK(*qsp->xfr.top.ixfr, dp, d_link);
while ((rp = HEAD(dp->d_changes)) != NULL) {
UNLINK(dp->d_changes, rp, r_link);
if (rp->r_dp != NULL)
db_detach(&rp->r_dp);
res_freeupdrec(rp);
}
memput(dp, sizeof *dp);
}
memput(qsp->xfr.top.ixfr, sizeof *qsp->xfr.top.ixfr);
qsp->xfr.top.ixfr = NULL;
}
while (qsp->xfr.lev)
qsp->xfr.lev = sx_freelev(qsp->xfr.lev);
if (qsp->xfr.tsig_state != NULL) {
memput(qsp->xfr.tsig_state, sizeof(ns_tcp_tsig_state));
qsp->xfr.tsig_state = NULL;
}
zones[qsp->xfr.zone].z_numxfrs--;
qsp->flags &= ~(STREAM_AXFR | STREAM_AXFRIXFR);
}
/*
* u_char *
* sx_newmsg(msg)
* init the header of a message, reset the compression pointers, and
* reset the write pointer to the first byte following the header.
*/
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;
qsp->xfr.eom = qsp->xfr.msg + XFER_BUFSIZE;
if (qsp->xfr.tsig_state != NULL)
qsp->xfr.eom -= TSIG_BUF_SIZE;
}
/*
* 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)
res_pquery(&res, qsp->xfr.msg, qsp->xfr.cp - qsp->xfr.msg,
log_get_stream(packet_channel));
#endif
if (qsp->xfr.tsig_state != NULL && qsp->xfr.tsig_skip == 0) {
int msglen = qsp->xfr.cp - qsp->xfr.msg;
ns_sign_tcp(qsp->xfr.msg, &msglen, qsp->xfr.eom - qsp->xfr.msg,
NOERROR, qsp->xfr.tsig_state,
qsp->xfr.state == s_x_done);
if (qsp->xfr.state == s_x_done) {
memput(qsp->xfr.tsig_state, sizeof(ns_tcp_tsig_state));
qsp->xfr.tsig_state = NULL;
}
qsp->xfr.cp = qsp->xfr.msg + msglen;
}
ret = sq_write(qsp, qsp->xfr.msg, qsp->xfr.cp - qsp->xfr.msg);
if (ret >= 0) {
qsp->xfr.cp = NULL;
qsp->xfr.tsig_skip = 0;
}
else
qsp->xfr.tsig_skip = 1;
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 *must* 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, type;
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);
/*
* Add question to first answer.
*/
if (qsp->xfr.state == s_x_firstsoa && dp->d_type == T_SOA) {
n = dn_comp(dname, qsp->xfr.cp, qsp->xfr.eom - qsp->xfr.cp,
qsp->xfr.ptrs, edp);
if (n > 0 && (qsp->xfr.cp + n + INT16SZ * 2) <= qsp->xfr.eom) {
qsp->xfr.cp += n;
if (qsp->xfr.type == ns_t_zxfr)
type = ns_t_axfr;
else if ((qsp->flags & STREAM_AXFRIXFR) != 0)
type = ns_t_ixfr;
else
type = qsp->xfr.type;
PUTSHORT((u_int16_t) type, qsp->xfr.cp);
PUTSHORT((u_int16_t) qsp->xfr.class, qsp->xfr.cp);
hp->qdcount = htons(ntohs(hp->qdcount) + 1);
}
}
n = make_rr(dname, dp, qsp->xfr.cp, qsp->xfr.eom - qsp->xfr.cp -
qsp->xfr.tsig_size, 0, qsp->xfr.ptrs, edp, 0);
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 - qsp->xfr.tsig_size,
0, qsp->xfr.ptrs, edp, 0);
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;
int added_soa = 0;
foreach_rr(dp, qsp->xfr.top.axfr, 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);
}
added_soa = 1;
break;
}
if (added_soa == 0)
ns_panic(ns_log_xfer_out, 1, "no SOA at zone top");
if (qsp->xfr.state == s_x_firstsoa) {
foreach_rr(dp, qsp->xfr.top.axfr, T_SIG, qsp->xfr.class,
qsp->xfr.zone)
{
if (SIG_COVERS(dp) != T_SOA)
continue;
if (sx_addrr(qsp, zones[qsp->xfr.zone].z_origin, dp) <
0)
{
/* RR wouldn't fit. Bail out. */
return (-1);
}
}
}
return (0);
}
/*
* int
* sx_nsrrs(qsp)
* add the NS RR's at the current level's current np to the assembly msg.
* This function also adds the SIG(NS), KEY, SIG(KEY), NXT, SIG(NXT),
* since these records are also part of the delegation (see DNSSEC).
* 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 class;
class = qsp->xfr.class;
top = qsp->xfr.top.axfr;
for ((void)NULL;
(dp = qsp->xfr.lev->dp) != NULL;
qsp->xfr.lev->dp = db_next(dp)) {
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 && dp->d_type != T_KEY &&
dp->d_type != T_NXT && dp->d_type != T_SIG)
continue;
if (dp->d_type == T_SIG && ((SIG_COVERS(dp) != T_NS) &&
(SIG_COVERS(dp) != T_KEY) && (SIG_COVERS(dp) != T_NXT)))
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);
}
if (dp->d_type != T_NS) /* no glue processing */
continue;
/* Remember we have found a zone cut */
if (qsp->xfr.top.axfr != qsp->xfr.lev->np)
qsp->xfr.lev->flags |= SXL_ZONECUT;
}
/*
* 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);
}
/* for IPv6 glue AAAA record transfer */
/* patched by [email protected], 1999/5/23 */
foreach_rr(gdp, gnp, T_AAAA, 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);
}
foreach_rr(gdp, gnp, ns_t_a6, 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 (0);
}
/*
* int
* sx_allrrs(qsp)
* add the non-(SOA,NS) RR's at the current level's current np,
* to the assembly message
* do not add the DNSSEC types KEY and NXT as the delegation check
* wrote these types out.
* 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;
struct namebuf *top;
int rrcount, class;
u_int zone;
class = qsp->xfr.class;
top = qsp->xfr.top.axfr;
zone = qsp->xfr.zone;
rrcount = 0;
for ((void)NULL;
(dp = qsp->xfr.lev->dp) != NULL;
qsp->xfr.lev->dp = db_next(dp)) {
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 ||
dp->d_type == T_NXT || dp->d_type == T_KEY)
continue;
if (dp->d_type == T_SIG &&
(SIG_COVERS(dp) == T_SOA || SIG_COVERS(dp) == T_NS ||
SIG_COVERS(dp) == T_KEY || SIG_COVERS(dp) == T_NXT))
continue;
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.
*/
void
sx_sendlev(struct qstream *qsp) {
struct qs_x_lev *lev;
again:
lev = qsp->xfr.lev;
switch (lev->state) {
case sxl_ns: {
while (lev->dp) {
/* Was the child zone reloaded under us? */
if ((lev->dp->d_flags & DB_F_ACTIVE) == 0) {
(void) shutdown(qsp->s_rfd, 2);
sq_remove(qsp);
return;
}
/* If we can't pack this one in, come back later. */
if (sx_nsrrs(qsp) < 0)
return;
}
/* 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;
if (lev->dp)
DRCNTINC(lev->dp);
goto again;
}
case sxl_all: {
while (lev->dp) {
/* Was a record updated under us? */
if ((lev->dp->d_flags & DB_F_ACTIVE) == 0) {
(void) shutdown(qsp->s_rfd, 2);
sq_remove(qsp);
return;
}
/* 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.
*/
void
sx_sendsoa(struct qstream *qsp) {
HEADER * hp = (HEADER *) qsp->xfr.msg;
if (sx_soarr(qsp) == -1)
return; /* No state change, come back here later. */
hp->aa = 1;
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. */
qsp->xfr.state = s_x_done;
(void)sx_flush(qsp);
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;
if (new->dp)
DRCNTINC(new->dp);
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;
if (lev->dp)
db_detach(&lev->dp);
memput(lev, sizeof *lev);
return (next);
}
static struct databuf *
db_next(struct databuf *dp) {
struct databuf *next = dp->d_next;
db_detach(&dp);
if (next)
DRCNTINC(next);
return (next);
}
-78
View File
@@ -1,78 +0,0 @@
/*
* $Id: pathtemplate.h,v 8.6 2000/04/21 06:54:15 vixie Exp $
*/
/*
* Copyright (c) 1996-2000 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_NDCSOCK
#ifdef NEED_SECURE_DIRECTORY
#define _PATH_NDCSOCK "%DESTRUN%/ndc.d/ndc"
#else
#define _PATH_NDCSOCK "%DESTRUN%/ndc"
#endif
#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
View File
@@ -1,11 +0,0 @@
$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.
@@ -1,10 +0,0 @@
$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
-45
View File
@@ -1,45 +0,0 @@
// 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;
deallocate-on-exit yes;
listen-on { 10.0.0.53; };
};
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";
};
logging {
channel xfer-log {
file "/var/tmp/bind-xfer.log" versions unlimited size 10m;
print-category yes;
print-severity yes;
print-time yes;
severity info;
};
category xfer-in { xfer-log; };
category xfer-out { xfer-log; };
category notify { xfer-log; };
category load { xfer-log; };
};
-37
View File
@@ -1,37 +0,0 @@
; <<>> 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
View File
@@ -1,89 +0,0 @@
/*
* @(#)Version.c 4.9 (Berkeley) 7/21/90
* $Id: version.c,v 8.3 1999/01/02 06:05:14 vixie Exp $
*/
#ifndef lint
char sccsid[] = "@(#)named %VERSION% %WHEN% %WHOANDWHERE%";
char rcsid[] = "$Id: version.c,v 8.3 1999/01/02 06:05:14 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 */
-96
View File
@@ -1,96 +0,0 @@
## Copyright (c) 1996,1999 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.17 2000/12/23 08:02:54 vixie Exp $
DESTDIR=
CC= cc
SHELL= /bin/sh
CDEBUG= -g -Wall
#(net2 and its descendents)
SYSTYPE = freebsd
TOP = ../..
INCL = ${TOP}/include
PORTINCL = ${TOP}/port/${SYSTYPE}/include
LIBBIND = ${TOP}/lib/libbind.a
A=a
O=o
LEX = lex -I
SYSLIBS = -ll -lutil
DESTBIN = /usr/local/bin
DESTSBIN = /usr/local/sbin
DESTEXEC = /usr/local/libexec
DESTMAN = /usr/share/man
DESTHELP= /usr/share/misc
AR= ar cru
INSTALL= install
STRIP=-s
INSTALL_EXEC=
INSTALL_LIB=-o bin -g bin
PS=ps
LDFLAGS=
CFLAGS= ${CDEBUG}
CPPFLAGS= -I${PORTINCL} -I${INCL} ${DEFS}
PROG= ndc
SRCS= ${PROG}.c
OBJS= ${PROG}.${O}
HDRS= pathnames.h
all: ${PROG}${EXE}
${PROG}${EXE}: ${HDRS} ${OBJS} ${LIBBIND} Makefile
${CC} ${CDEBUG} ${LDFLAGS} ${BOUNDS} -o ${PROG}${EXE} ${OBJS} ${LIBBIND} ${SYSLIBS}
.c.${O}:
${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} -c $*.c
pathnames.h: ${TOP}/.settings Makefile ../named/pathtemplate.h
rm -f pathnames.h
sed -e "s|%DESTSBIN%|${DESTSBIN}|" \
-e "s|%DESTEXEC%|${DESTEXEC}|" \
-e "s|%DESTETC%|${DESTETC}|" \
-e "s|%DESTRUN%|${DESTRUN}|" \
< ../named/pathtemplate.h > pathnames.h
distclean: clean
clean: FRC
rm -f ${PROG}${EXE} ${OBJS} core .depend
rm -f *.BAK *.CKP *~ *.orig
rm -f pathnames.h
depend: ${SRCS} pathnames.h
mkdep ${CPPFLAGS} -I${INCL} -I${PORTINCL} ${SRCS}
${DESTDIR}${DESTSBIN}:
mkdir -p ${DESTDIR}${DESTSBIN}
install: ${DESTDIR}${DESTSBIN} ${PROG}${EXE}
${INSTALL} ${INSTALL_EXEC} ${STRIP} -c -m 755 ${PROG}${EXE} ${DESTDIR}${DESTSBIN}/${PROG}${EXE}
links: FRC
@set -e; ln -s SRC/*.[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.
-913
View File
@@ -1,913 +0,0 @@
#if !defined(lint) && !defined(SABER)
static const char rcsid[] = "$Id: ndc.c,v 1.25 2003/04/03 05:42:10 marka Exp $";
#endif /* not lint */
/*
* Portions Copyright (c) 1999 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/file.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <arpa/inet.h>
#include <ctype.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <isc/eventlib.h>
#include <isc/ctl.h>
#include "port_after.h"
#include "pathnames.h"
#ifndef PATH_SEP
#define PATH_SEP '/'
#endif
typedef union {
struct sockaddr_in in;
#ifndef NO_SOCKADDR_UN
struct sockaddr_un un;
#endif
} sockaddr_t;
typedef void (*closure)(void *, const char *, int);
static const char * program = "amnesia";
static enum { e_channel, e_signals } mode = e_channel;
static const char * channel = _PATH_NDCSOCK;
static const char helpfmt[] = "\t%-16s\t%s\n";
static const char * pidfile = _PATH_PIDFILE;
static sockaddr_t client, server;
static int quiet = 0, tracing = 0, silent = 0, client_set = 0;
static int debug = 0, errors = 0, doneflag, exitflag;
static int logger_show = 1;
static evContext ev;
static char cmd[1000];
static const char * named_path = _PATH_NAMED;
static int slashcmd(void);
static void slashhelp(void);
static int builtincmd(void);
static void command(void);
static int running(int, pid_t *);
static void command_channel(void);
static void channel_loop(const char *, int, closure, void *);
static void getpid_closure(void *, const char *, int);
static void banner(struct ctl_cctx *, void *, const char *, u_int);
static void done(struct ctl_cctx *, void *, const char *, u_int);
static void logger(enum ctl_severity, const char *fmt, ...) ISC_FORMAT_PRINTF(2, 3);
static void command_signals(void);
static void stop_named(pid_t);
static void start_named(const char *, int);
static int fgetpid(const char *, pid_t *);
static int get_sockaddr(const char *, sockaddr_t *);
static size_t impute_addrlen(const struct sockaddr *);
static void vtrace(const char *, va_list) ISC_FORMAT_PRINTF(1, 0);
static void trace(const char *, ...) ISC_FORMAT_PRINTF(1, 2);
static void result(const char *, ...) ISC_FORMAT_PRINTF(1, 2);
static void fatal(const char *, ...) ISC_FORMAT_PRINTF(1, 2);
static void verror(const char *, va_list) ISC_FORMAT_PRINTF(1, 0);
static void error(const char *, ...) ISC_FORMAT_PRINTF(1, 2);
static void
usage(const char *fmt, ...) {
va_list args;
va_start(args, fmt);
fprintf(stderr, "%s: usage error: ", program);
vfprintf(stderr, fmt, args);
fputc('\n', stderr);
va_end(args);
fatal("usage: %s \
[-l localsock] [-c channel] [-p pidfile] [-n namedpath] \
[-dqst] [command [args]]\n\
",
program);
}
/* Public. */
int
main(int argc, char *argv[]) {
char *p;
int ch;
if ((program = strrchr(argv[0], PATH_SEP)) != NULL)
program++;
else
program = argv[0];
while ((ch = getopt(argc, argv, "c:p:l:n:dqst")) != -1) {
switch (ch) {
case 'c':
channel = optarg;
mode = e_channel;
break;
case 'p':
pidfile = optarg;
mode = e_signals;
break;
case 'l':
if (!get_sockaddr(optarg, &client))
usage("bad local socket (%s)", optarg);
client_set++;
break;
case 'n':
named_path = optarg;
break;
case 'd':
tracing++;
debug++;
break;
case 'q':
quiet++;
break;
case 's':
silent++;
break;
case 't':
tracing++;
break;
default:
usage("unrecognized command option (%c)", ch);
/* NOTREACHED */
}
}
if (mode != e_channel && client_set)
usage("the -l flag is only valid for control channels");
if (mode == e_channel) {
if (!get_sockaddr(channel, &server))
usage("bad channel name (%s)", channel);
if (evCreate(&ev) < 0)
fatal("evCreate - %s", strerror(errno));
}
*(p = cmd) = '\0';
for (argc -= optind, argv += optind;
argc > 0;
argc--, argv++) {
size_t t = strlen(*argv);
if ((p - cmd) + t + 2 > sizeof cmd)
usage("command too long");
strcpy(p, *argv);
p += t;
if (argv[1] != NULL)
*p++ = ' ';
*p = '\0';
}
if (cmd[0] != '\0') {
command();
} else {
if (!quiet)
result("Type help -or- /h if you need help.");
for (exitflag = 0; !exitflag; (void)NULL) {
if (!quiet) {
printf("%s> ", program);
fflush(stdout);
}
if (!fgets(cmd, sizeof cmd, stdin)) {
if (!quiet)
result("EOF");
exitflag++;
continue;
}
if (cmd[strlen(cmd) - 1] == '\n')
cmd[strlen(cmd) - 1] = '\0';
if (cmd[0] == '\0')
continue;
if (slashcmd())
continue;
command();
}
}
if (mode == e_channel)
evDestroy(ev);
exit(errors != 0);
}
/* Private. */
static int
slashcmd(void) {
if (strncasecmp(cmd, "/help", strlen(cmd)) == 0)
slashhelp();
else if (strncasecmp(cmd, "/exit", strlen(cmd)) == 0)
exitflag++;
else if (strncasecmp(cmd, "/trace", strlen(cmd)) == 0)
result("tracing now %s",
(tracing = !tracing) ? "on" : "off");
else if (strncasecmp(cmd, "/debug", strlen(cmd)) == 0)
result("debugging now %s",
(debug = !debug) ? "on" : "off");
else if (strncasecmp(cmd, "/quiet", strlen(cmd)) == 0)
result("%s is now %s", program,
(quiet = !quiet) ? "quiet" : "noisy");
else if (strncasecmp(cmd, "/silent", strlen(cmd)) == 0)
result("%s is now %s", program,
(silent = !silent)
? "silent" : "gregarious");
else
return (0);
return (1);
}
static void
slashhelp(void) {
printf(helpfmt, "/h(elp)", "this text");
printf(helpfmt, "/e(xit)", "leave this program");
printf(helpfmt, "/t(race)",
"toggle tracing (protocol and system events)");
printf(helpfmt, "/d(ebug)",
"toggle debugging (internal program events)");
printf(helpfmt, "/q(uiet)",
"toggle quietude (prompts and results)");
printf(helpfmt, "/s(ilent)",
"toggle silence (suppresses nonfatal errors)");
}
struct argv {
int argc;
char **argv;
int error;
};
static char hexdigits[] = "0123456789abcdef";
static void
getargs_closure(void *arg, const char *msg, int flags) {
struct argv *argv = arg;
int len;
int i;
const char *cp, *cp2;
char *tp, c;
UNUSED(flags);
if (argv->error)
return;
if (argv->argc == -1) {
i = atoi(msg + 4);
if (i < 1) {
argv->error = 1;
return;
}
argv->argc = i;
argv->argv = calloc((i+1), sizeof(char*));
return;
}
len = 0;
cp = msg + 4;
while (*cp != '\0') {
c = *cp;
if (c == '%') {
cp2 = strchr(hexdigits, cp[1]);
if (cp2 == NULL) {
argv->error = 1;
return;
}
c = (cp2-hexdigits) << 4;
cp2 = strchr(hexdigits, cp[2]);
if (cp2 == NULL) {
argv->error = 1;
return;
}
c += (cp2-hexdigits);
cp += 2;
}
if (!isalnum((unsigned)c)) {
switch (c) {
case '+': case '-': case '=': case '/': case '.':
break;
default:
len++;
}
}
len++;
cp++;
}
i = 0;
while (argv->argv[i] != NULL)
i++;
if (i >= argv->argc) {
argv->error = 1;
return;
}
argv->argv[i] = malloc(len + 1);
if (argv->argv[i] == NULL) {
argv->error = 1;
return;
}
cp = msg + 4;
tp = argv->argv[i];
while (*cp != '\0') {
c = *cp;
if (c == '%') {
cp2 = strchr(hexdigits, cp[1]);
if (cp2 == NULL) {
argv->error = 1;
return;
}
c = (cp2-hexdigits) << 4;
cp2 = strchr(hexdigits, cp[2]);
if (cp2 == NULL) {
argv->error = 1;
return;
}
c += (cp2-hexdigits);
cp += 2;
}
if (!isalnum((unsigned)c)) {
switch (c) {
case '+': case '-': case '=': case '/': case '.':
break;
default:
*tp = '\\';
}
}
*tp++ = c;
cp++;
}
}
static int
get_args(char **restp) {
struct argv argv;
int len, i;
char *rest, *p;
int result = 1;
argv.argc = -1;
argv.argv = NULL;
argv.error = 0;
channel_loop("args", 1, getargs_closure, &argv);
if (argv.error) {
result = 0;
goto err;
}
len = 0;
for (i = 1 ; i < argv.argc && argv.argv[i] != NULL; i++)
len += strlen(argv.argv[i]) + 1;
if (len == 0)
len = 1;
rest = malloc(len);
if (rest == NULL) {
result = 0;
goto err;
}
p = rest;
for (i = 1 ; i < argv.argc && argv.argv[i] != NULL; i++) {
strcpy(p, argv.argv[i]);
p += strlen(argv.argv[i]);
*p++ = ' ';
}
if (p != rest)
p--;
p[0] = '\0';
*restp = rest;
err:
if (argv.argv) {
for (i = 0 ; i < argv.argc && argv.argv[i] != NULL; i++)
free(argv.argv[i]);
free(argv.argv);
}
return (result);
}
static void
exec_closure(void *arg, const char *msg, int flags) {
int *result = arg;
UNUSED(flags);
if (atoi(msg) == 250)
*result = 1;
}
static int
try_exec(int local_quiet) {
int good = 0;
pid_t pid;
channel_loop("exec", 1, exec_closure, &good);
if (good) {
sleep(3);
if (!running(0, &pid))
error("name server has not restarted (yet?)");
else if (!local_quiet)
result("new pid is %ld", (long)pid);
}
return (good);
}
static int
builtincmd(void) {
static const char spaces[] = " \t";
char *rest, *syscmd;
pid_t pid;
int save_quiet = quiet;
int len;
int freerest = 0;
quiet = 1;
len = strcspn(cmd, spaces);
rest = cmd + len;
if (*rest != '\0')
rest += strspn(rest, spaces);
if (*rest == '\0' && !strncasecmp(cmd, "restart", len)) {
if (try_exec(save_quiet))
return (1);
freerest = get_args(&rest);
}
syscmd = malloc(strlen(named_path) + sizeof " " + strlen(rest));
if (syscmd == NULL)
fatal("malloc() failed - %s", strerror(errno));
strcpy(syscmd, named_path);
if (*rest != '\0') {
strcat(syscmd, " ");
strcat(syscmd, rest);
}
if (freerest)
free(rest);
if (strncasecmp(cmd, "start", len) == 0) {
if (running(debug, &pid))
error("name server already running? (pid %ld)",
(long)pid);
else
start_named(syscmd, save_quiet);
quiet = save_quiet;
free(syscmd);
return (1);
} else if (strncasecmp(cmd, "restart", len) == 0) {
if (!running(debug, &pid))
error("name server was not running (warning only)");
else
stop_named(pid);
start_named(syscmd, save_quiet);
quiet = save_quiet;
free(syscmd);
return (1);
}
quiet = save_quiet;
free(syscmd);
return (0);
}
static void
builtinhelp(void) {
const char *fmt;
switch (mode) {
case e_channel:
fmt = "(builtin) %s - %s\n";
break;
case e_signals:
fmt = helpfmt;
break;
default:
abort();
}
printf(fmt, "start", "start the server");
printf(fmt, "restart", "stop server if any, start a new one");
}
static void
command(void) {
if (builtincmd())
return;
switch (mode) {
case e_channel:
command_channel();
break;
case e_signals:
command_signals();
break;
default:
abort();
}
}
static int
running(int show, pid_t *pidp) {
pid_t pid;
switch (mode) {
case e_channel:
pid = 0;
channel_loop("getpid", show, getpid_closure, &pid);
if (pid != 0) {
if (tracing)
result("pid %ld is running", (long)pid);
*pidp = pid;
return (1);
}
break;
case e_signals:
if (fgetpid(pidfile, pidp)) {
if (tracing)
result("pid %ld is running", (long)pid);
return (1);
}
break;
default:
abort();
}
if (show)
error("pid not valid or server not running");
return (0);
}
static void
getpid_closure(void *uap, const char *text, int flags) {
pid_t *pidp = uap;
const char *cp;
flags = flags;
if ((cp = strchr(text, '<')) != NULL) {
long l = 0;
char ch;
while ((ch = *++cp) != '\0' && ch != '>' && isdigit(ch))
l *= 10, l += (ch - '0');
if (ch == '>') {
*pidp = (pid_t)l;
return;
}
}
error("response does not contain pid (%s)", text);
}
static void
command_channel(void) {
int helping = (strcasecmp(cmd, "help") == 0);
int save_quiet = quiet;
if (helping) {
quiet = 0;
builtinhelp();
}
channel_loop(cmd, !quiet, NULL, NULL);
quiet = save_quiet;
}
struct args {
const char *cmd;
closure cl;
void *ua;
};
static void
channel_loop(const char *cmdtext, int show, closure cl, void *ua) {
struct ctl_cctx *ctl;
struct sockaddr *client_addr;
struct args a;
evEvent e;
int save_logger_show = logger_show;
if (!client_set)
client_addr = NULL;
else
client_addr = (struct sockaddr *)&client;
a.cmd = cmdtext;
a.cl = cl;
a.ua = ua;
logger_show = show;
trace("command '%s'", cmdtext);
ctl = ctl_client(ev, client_addr, impute_addrlen(client_addr),
(struct sockaddr *)&server,
impute_addrlen((struct sockaddr *)&server),
banner, &a, 15, logger);
if (ctl == NULL) {
if (show)
error("cannot connect to command channel (%s)",
channel);
} else {
doneflag = 0;
while (evGetNext(ev, &e, EV_WAIT) == 0)
if (evDispatch(ev, e) < 0 || doneflag)
break;
ctl_endclient(ctl);
}
logger_show = save_logger_show;
}
static void
banner(struct ctl_cctx *ctl, void *uap, const char *msg, u_int flags) {
struct args *a = uap;
if (msg == NULL) {
trace("EOF");
doneflag = 1;
return;
}
trace("%s", msg);
if ((flags & CTL_MORE) != 0)
return;
if (ctl_command(ctl, a->cmd, strlen(a->cmd), done, a) < 0) {
error("ctl_command failed - %s", strerror(errno));
doneflag = 1;
}
}
static void
done(struct ctl_cctx *ctl, void *uap, const char *msg, u_int flags) {
struct args *a = uap;
UNUSED(ctl);
if (msg == NULL) {
trace("EOF");
doneflag = 1;
return;
}
if (!tracing && !quiet && strlen(msg) > 4)
result("%s", msg + 4);
trace("%s", msg);
if (a->cl)
(a->cl)(a->ua, msg, flags);
if ((flags & CTL_MORE) == 0)
doneflag = 1;
}
static void
logger(enum ctl_severity ctlsev, const char *format, ...) {
va_list args;
va_start(args, format);
switch (ctlsev) {
case ctl_debug:
/* FALLTHROUGH */
case ctl_warning:
if (debug)
vtrace(format, args);
break;
case ctl_error:
if (logger_show)
verror(format, args);
break;
default:
va_end(args);
abort();
}
va_end(args);
}
static struct cmdsig {
const char * cmd;
int sig;
const char * help;
} cmdsigs[] = {
{ "dumpdb", SIGINT, "dump cache database to a file" },
{ "reload", SIGHUP, "reload configuration file" },
{ "stats", SIGILL, "dump statistics to a file" },
{ "trace", SIGUSR1, "increment trace level" },
{ "notrace", SIGUSR2, "turn off tracing" },
#ifdef SIGWINCH
{ "querylog", SIGWINCH, "toggle query logging" },
{ "qrylog", SIGWINCH, "alias for querylog" },
#endif
{ NULL, 0, NULL }
};
static void
command_signals(void) {
struct cmdsig *cmdsig;
pid_t pid;
if (strcasecmp(cmd, "help") == 0) {
printf(helpfmt, "help", "this output");
printf(helpfmt, "status", "check for running server");
printf(helpfmt, "stop", "stop the server");
builtinhelp();
for (cmdsig = cmdsigs; cmdsig->cmd != NULL; cmdsig++)
printf(helpfmt, cmdsig->cmd, cmdsig->help);
} else if (strcasecmp(cmd, "status") == 0) {
if (!fgetpid(pidfile, &pid))
error("pid not valid or server not running");
else
result("pid %ld is running", (long)pid);
} else if (strcasecmp(cmd, "stop") == 0) {
if (!fgetpid(pidfile, &pid))
error("name server not running");
else
stop_named(pid);
} else {
for (cmdsig = cmdsigs; cmdsig->cmd != NULL; cmdsig++)
if (strcasecmp(cmd, cmdsig->cmd) == 0)
break;
if (cmdsig->cmd == NULL)
error("unrecognized command (%s)", cmd);
else if (!fgetpid(pidfile, &pid))
error("can't get pid (%s)", pidfile);
else if (kill(pid, cmdsig->sig) < 0)
error("kill() failed - %s", strerror(errno));
else
trace("pid %ld sig %d OK", (long)pid, cmdsig->sig);
}
}
static void
stop_named(pid_t pid) {
int n;
trace("stopping named (pid %ld)", (long)pid);
switch (mode) {
case e_signals:
if (kill(pid, SIGTERM) < 0) {
error("kill(%ld, SIGTERM) failed - %s",
(long)pid, strerror(errno));
return;
}
trace("SIGTERM ok, waiting for death");
break;
case e_channel:
channel_loop("stop", tracing, NULL, NULL);
break;
default:
abort();
}
for (n = 0; n < 10; n++) {
if (kill(pid, 0) != 0) {
trace("named (pid %ld) is dead", (long)pid);
return;
}
sleep(1);
}
error("named (pid %ld) didn't die", (long)pid);
}
static void
start_named(const char *syscmd, int local_quiet) {
pid_t pid;
if (system(syscmd) != 0)
error("could not start new name server (%s)", syscmd);
else {
sleep(3);
if (!running(0, &pid))
error("name server has not started (yet?)");
else if (!local_quiet)
result("new pid is %ld", (long)pid);
}
}
static int
fgetpid(const char *f, pid_t *pid) {
FILE *fp;
int try;
long t;
for (try = 0; try < 5; try++) {
trace("pidfile is \"%s\" (try #%d)", f, try + 1);
if ((fp = fopen(f, "r")) == NULL)
trace("pid file (%s) unavailable - %s",
f, strerror(errno));
else if (fscanf(fp, "%ld\n", &t) != 1)
trace("pid file (%s) format is bad", f);
else if (*pid = (pid_t)t, fclose(fp), kill(*pid, 0) < 0)
trace("pid file (%s) contains unusable pid (%d) - %s",
f, *pid, strerror(errno));
else {
trace("pid is %ld", (long)*pid);
return (1);
}
sleep(1);
}
trace("pid not found");
return (0);
}
static int
get_sockaddr(const char *name, sockaddr_t *addr) {
char *slash;
#ifndef NO_SOCKADDR_UN
if (name[0] == '/') {
memset(&addr->un, '\0', sizeof addr->un);
addr->un.sun_family = AF_UNIX;
strncpy(addr->un.sun_path, name, sizeof addr->un.sun_path - 1);
addr->un.sun_path[sizeof addr->un.sun_path - 1] = '\0';
} else
#endif
if ((slash = strrchr(name, '/')) != NULL) {
char *ibuf = malloc(slash - name + 1);
if (!ibuf)
usage("no memory for IP address (%s)", name);
memcpy(ibuf, name, slash - name);
ibuf[slash - name] = '\0';
memset(&addr->in, '\0', sizeof addr->in);
if (!inet_pton(AF_INET, ibuf, &addr->in.sin_addr))
usage("bad ip address (%s)", name);
if ((addr->in.sin_port = htons(atoi(slash+1))) == 0)
usage("bad ip port (%s)", slash+1);
addr->in.sin_family = AF_INET;
free (ibuf);
} else {
return (0);
}
return (1);
}
static size_t
impute_addrlen(const struct sockaddr *sa) {
if (sa == NULL)
return (0);
switch (sa->sa_family) {
case AF_INET:
return (sizeof(struct sockaddr_in));
#ifndef NO_SOCKADDR_UN
case AF_UNIX:
return (sizeof(struct sockaddr_un));
#endif
default:
abort();
}
/*NOTREACHED*/
}
static void
vtrace(const char *fmt, va_list ap) {
if (tracing) {
fprintf(stdout, "%s: [", program);
vfprintf(stdout, fmt, ap);
fputs("]\n", stdout);
}
}
static void
trace(const char *fmt, ...) {
va_list args;
va_start(args, fmt);
vtrace(fmt, args);
va_end(args);
}
static void
result(const char *fmt, ...) {
va_list args;
va_start(args, fmt);
vfprintf(stdout, fmt, args);
fputc('\n', stdout);
va_end(args);
}
static void
fatal(const char *fmt, ...) {
va_list args;
va_start(args, fmt);
fprintf(stderr, "%s: fatal error: ", program);
vfprintf(stderr, fmt, args);
fputc('\n', stderr);
va_end(args);
exit(1);
}
static void
verror(const char *fmt, va_list ap) {
fprintf(stderr, "%s: error: ", program);
vfprintf(stderr, fmt, ap);
fputc('\n', stderr);
errors++;
}
static void
error(const char *fmt, ...) {
va_list args;
va_start(args, fmt);
if (silent)
vtrace(fmt, args);
else
verror(fmt, args);
va_end(args);
}
-98
View File
@@ -1,98 +0,0 @@
## Copyright (c) 1996,1999 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.28 2002/05/21 00:44:59 marka Exp $
DESTDIR=
CC= cc
SHELL= /bin/sh
CDEBUG= -g -Wall
#(net2 and its descendents)
SYSTYPE = freebsd
TOP = ../..
INCL = ${TOP}/include
PORTINCL = ${TOP}/port/${SYSTYPE}/include
LIBBIND = ${TOP}/lib/libbind.a
A=a
O=o
EXE=
LEX = lex -I
SYSLIBS =-lutil
LIBL=-ll
DESTBIN = /usr/local/bin
DESTSBIN = /usr/local/sbin
DESTEXEC = /usr/local/libexec
DESTMAN = /usr/share/man
DESTHELP= /usr/share/misc
STRIP=-s
INSTALL_EXEC=
INSTALL_LIB=-o bin -g bin
LDFLAGS=
DEFS= -D_PATH_HELPFILE=\"${DESTHELP}/nslookup.help\"
CFLAGS= ${CDEBUG}
CPPFLAGS= -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}${EXE}
${PROG}${EXE}: ${OBJS} ${LIBBIND} Makefile
${CC} ${CDEBUG} ${LDFLAGS} ${BOUNDS} -o ${PROG}${EXE} ${OBJS} \
${LIBBIND} ${LIBL} ${SYSLIBS}
.c.${O}:
${CC} ${CPPFLAGS} ${CFLAGS} ${BOUNDS} -c $*.c
distclean: clean
rm -f commands.c
clean: FRC
rm -f ${PROG}${EXE} ${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}${EXE}
${INSTALL} ${STRIP} -c ${INSTALL_EXEC} -m 755 ${PROG}${EXE} ${DESTDIR}${DESTBIN}/${PROG}${EXE}
${INSTALL} -c ${INSTALL_LIB} -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.
-273
View File
@@ -1,273 +0,0 @@
%{
/* $FreeBSD$ */
/*
* 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
* 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 <netinet/in.h>
#include <histedit.h>
#include "port_after.h"
#include <resolv.h>
#include "res.h"
extern char rootServerName[];
extern void PrintHelp();
#define YY_INPUT(buf, result, max_size) \
{ \
nslookup_yy_input((char *)buf, &result, \
max_size, yy_current_buffer->yy_is_interactive); \
}
const char *
nslookup_prompt()
{
return ("> ");
}
int
nslookup_yy_input(buf, result, max_size, intr)
char * buf;
int * result;
int max_size;
int intr;
{
static EditLine *el = NULL;
static History *hist = NULL;
HistEvent he;
int num = 0;
const char *bp = NULL;
if (intr) {
if (!el) {
el = el_init("nslookup", yyin, yyout, stderr);
hist = history_init();
history(hist, &he, H_EVENT, 100);
el_set(el, EL_HIST, history, hist);
el_set(el, EL_EDITOR, "emacs");
el_set(el, EL_PROMPT, nslookup_prompt);
el_set(el, EL_SIGNAL, 1);
el_source(el, NULL);
}
if ((bp = el_gets(el, &num)) == NULL || num == 0) {
*result = 0;
return;
}
*result = (num > max_size) ? max_size : num;
strncpy(buf, bp, *result);
history(hist, &he, H_ENTER, bp);
} else {
if ( ((*result = fread( buf, 1, max_size, yyin )) == 0)
&& ferror( yyin ) )
yy_fatal_error( "input in flex scanner failed" );
}
return;
}
%}
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((char*)yytext, 0);
return(1);
}
^{WS}*lserver{WS}+{LET}{NAME}*{WS}*$ {
SetDefaultServer((char*)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((char*)yytext, 1);
return(1);
}
^{WS}*finger({WS}+{LET}{NAME}*)?{WS}*$ {
Finger((char*)yytext, 0);
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((char*)yytext, 1);
return(1);
}
^{WS}*ls{WS}+(("-a"|"-d"|"-h"|"-m"|"-s"){WS}+)?{LET}{NAME}*{WS}*$ {
ListHosts((char*)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((char*)yytext, 1);
return(1);
}
^{WS}*ls{WS}+-t{WS}+({LET}{NAME}*{WS}+)?{LET}{NAME}*{WS}*$ {
ListHostsByType((char*)yytext, 0);
return(1);
}
^{WS}*set{WS}+{NAME}+{WS}*$ {
SetOption((char*)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((char*)yytext, 1);
return(1);
}
^{WS}*{FLET}{NAME}*{WS}*$ {
LookupHost((char*)yytext, 0);
return(1);
}
^{WS}*{FLET}{NAME}*{WS}+{LET}{NAME}*{WS}+>>?{WS}*{NAME}+{WS}*$ {
/*
* 0 == output to stdout
* 1 == output to file
*/
LookupHostWithServer((char*)yytext, 1);
return(1);
}
^{WS}*{FLET}{NAME}*{WS}+{LET}{NAME}*{WS}*$ {
LookupHostWithServer((char*)yytext, 0);
return(1);
}
^{WS}*\n {
return(1);
}
^.*\n {
printf("Unrecognized command: %s",
(char*)yytext);
return(1);
}
\n { ; }
%%
-657
View File
@@ -1,657 +0,0 @@
/* $FreeBSD$ */
/*
* 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 const char sccsid[] = "@(#)debug.c 5.26 (Berkeley) 3/21/91";
static const char rcsid[] = "$Id: debug.c,v 8.19 2001/09/25 04:50:26 marka 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 <string.h>
#include "port_after.h"
#include "res.h"
/*
* Imported from res_debug.c
*/
#ifndef HAVE_DECL_RES_OPCODES
extern char *_res_opcodes[];
#endif
/*
* 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 = 0;
/*
* Print header fields.
*/
hp = (const 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", p_rcode(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((const u_char*)cp);
cp += INT16SZ;
class = ns_get16((const 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");
}
static 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((const 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((const u_char*)cp));
cp += INT16SZ;
fprintf(file,", preference = %u\n", ns_get16((const 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((const u_char*)cp));
cp += INT16SZ;
fprintf(file,", weight = %u", ns_get16((const u_char*)cp));
cp += INT16SZ;
fprintf(file,", port= %u\n", ns_get16((const u_char*)cp));
cp += INT16SZ;
fprintf(file,"\thost = ");
goto doname;
case T_PX:
BOUNDS_CHECK(cp, INT16SZ);
fprintf(file,"\tpreference = %u",ns_get16((const 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((const u_char*)cp));
cp += INT16SZ;
fprintf(file,", router = ");
goto doname;
case T_AFSDB:
BOUNDS_CHECK(cp, INT16SZ);
fprintf(file,"\tsubtype = %d",ns_get16((const 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((const u_char*)cp));
cp += INT32SZ;
ttl = ns_get32((const u_char*)cp);
fprintf(file,"\n\trefresh = %lu (%s)", ttl, p_time(ttl));
cp += INT32SZ;
ttl = ns_get32((const u_char*)cp);
fprintf(file,"\n\tretry = %lu (%s)", ttl, p_time(ttl));
cp += INT32SZ;
ttl = ns_get32((const u_char*)cp);
fprintf(file,"\n\texpire = %lu (%s)", ttl, p_time(ttl));
cp += INT32SZ;
ttl = ns_get32((const 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. */
char rrname[NS_MAXDNAME];
cp2 = p_fqnname(ocp, msg, NS_MAXCDNAME, rrname, sizeof rrname);
if (cp2 == NULL) {
fprintf(file, "(name truncated?)\n");
return (NULL); /* compression error */
}
if (ns_sprintrrf(msg, eom - msg, rrname, (ns_class)class,
(ns_type)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);
}
File diff suppressed because it is too large. Load diff
-705
View File
@@ -1,705 +0,0 @@
/*
* 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 const char sccsid[] = "@(#)list.c 5.23 (Berkeley) 3/21/91";
static const char rcsid[] = "$Id: list.c,v 8.27 2002/04/09 05:55:17 marka 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 <sys/types.h>
#include <sys/uio.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 *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
*
* 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, j, qtype, result;
/*
* Parse the command line. It maybe of the form "ls -t domain"
* or "ls -t type domain".
*/
/* simulate sscanf(string, " ls -t %s %s", option, name) */
i = matchString(" ls -t ", string);
if (i > 0) {
j = pickString(string + i, option, sizeof option);
if (j > 0) {
j = pickString(string + i + j, name, sizeof name);
if (j > 0)
i = 2;
else
i = 1;
} else {
i = 0;
}
}
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, j, qtype, result;
/*
* Parse the command line. It maybe of the form "ls domain",
* "ls -X domain".
*/
/* simulate i = sscanf(string, " ls %s %s", option, name) */
i = matchString(" ls ", string);
if (i > 0) {
j = pickString(string + i, option, sizeof option);
if (j > 0) {
j = pickString(string + i + j, name, sizeof name);
if (j > 0)
i = 2;
else
i = 1;
} else {
i = 0;
}
}
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_storage sa;
struct sockaddr_in *sin;
struct sockaddr_in6 *sin6;
HEADER *headerPtr;
int msglen, amtToRead, numRead, soacnt;
u_int len;
int numAnswers = 0;
int numRecords = 0;
u_char tmp[INT16SZ], *cp;
char soaname[2][NAME_LEN], file[PATH_MAX];
enum { NO_ERRORS, ERR_READING_LEN, ERR_READING_MSG, ERR_PRINTING }
error = NO_ERRORS;
struct iovec iov[2];
AddrInfo *AddrPtr;
int salen = 0;
/*
* Create a query packet for the requested domain name.
*/
msglen = res_nmkquery(&res, QUERY, domain, queryClass, T_AXFR,
NULL, 0, 0, buf.qb2, sizeof buf);
if (msglen < 0) {
if (_res.options & RES_DEBUG)
fprintf(stderr, "*** ls: res_nmkquery failed\n");
return (ERROR);
}
/*
* 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)
AddrPtr = defaultPtr->addrList[0];
else
AddrPtr = defaultPtr->servers[0]->addrList[0];
memset(&sa, 0, sizeof sa);
switch (AddrPtr->addrType) {
case AF_INET:
sin = (struct sockaddr_in *)&sa;
sin->sin_family = AddrPtr->addrType;
sin->sin_port = htons(nsport);
memcpy(&sin->sin_addr, AddrPtr->addr, AddrPtr->addrLen);
#ifdef HAVE_SA_LEN
sin->sin_len = sizeof(*sin);
#endif
salen = sizeof(struct sockaddr_in);
break;
case AF_INET6:
sin6 = (struct sockaddr_in6 *)&sa;
sin6->sin6_family = AddrPtr->addrType;
sin6->sin6_port = htons(nsport);
memcpy(&sin6->sin6_addr, AddrPtr->addr, AddrPtr->addrLen);
#ifdef HAVE_SA_LEN
sin6->sin6_len = sizeof(*sin6);
#endif
salen = sizeof(struct sockaddr_in6);
break;
}
/*
* Set up a virtual circuit to the server.
*/
sockFD = socket(AddrPtr->addrType, SOCK_STREAM, 0);
if (sockFD < 0) {
perror("ls: socket");
return (ERROR);
}
if (connect(sockFD, (struct sockaddr *)&sa, salen) < 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);
iov[0].iov_base = (char *)tmp;
iov[0].iov_len = INT16SZ;
iov[1].iov_base = (char *)buf.qb2;
iov[1].iov_len = msglen;
if (writev(sockFD, iov, 2) != INT16SZ + 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, sizeof 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') {
if (strcmp(name, ".") != 0)
strcpy(origin, name);
fprintf(filePtr, "$ORIGIN %s.\n", origin);
if (strcmp(name, ".") == 0)
strcpy(origin, name);
strcpy(name_ctx, "@");
}
if (qtype == T_ANY || (int)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);
numRecords++;
fputs(buf, filePtr);
fputc('\n', filePtr);
}
if (ns_rr_type(rr) == T_SOA) {
strcpy(soaname[soacnt], name);
if (soacnt == 0)
soacnt = 1;
else if (ns_samename(soaname[0],
soaname[1]) == 1) {
soacnt = 2;
/* This means we're finished.
* But we've to reset origin and
* name_ctx now ! */
origin[0] = name_ctx[0] ='\0';
}
}
}
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",
p_rcode(headerPtr->rcode),
ntohs(headerPtr->ancount), ntohs(headerPtr->nscount),
ntohs(headerPtr->arcount));
return (ERROR);
default:
return (ERROR);
}
}
/*
*******************************************************************************
*
* 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.
*
*******************************************************************************
*/
int
Finger(string, putToFile)
char *string;
int putToFile;
{
struct servent *sp;
struct sockaddr_storage sa;
struct sockaddr_in *sin;
struct sockaddr_in6 *sin6;
FILE *f;
int c;
int lastc;
char name[NAME_LEN];
char file[PATH_MAX];
int i;
int salen = 0;
/*
* We need a valid current host info to get an inet address.
*/
if (!curHostValid) {
fprintf(stderr, "Finger: no current host defined.\n");
return (ERROR);
}
/* simulate: sscanf("finger %s") ; */
i = matchString(" finger ", string);
if (i > 0) {
i = pickString(string + i, name, sizeof name);
if (i > 0) {
i = 1 ;
}
/* note that if the argument to the finger command is
bigger than sizeof name it will be treated as if there
was no argument. */
}
if (i == 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(&sa, 0, sizeof sa);
switch (curHostInfo.addrList[0]->addrType) {
case AF_INET:
sin = (struct sockaddr_in *)&sa;
sin->sin_family = curHostInfo.addrList[0]->addrType;
sin->sin_port = sp->s_port;
memcpy(&sin->sin_addr, curHostInfo.addrList[0]->addr,
curHostInfo.addrList[0]->addrLen);
#ifdef HAVE_SA_LEN
sin->sin_len = sizeof(*sin);
#endif
salen = sizeof(struct sockaddr_in);
break;
case AF_INET6:
sin6 = (struct sockaddr_in6 *)&sa;
sin6->sin6_family = curHostInfo.addrList[0]->addrType;
sin6->sin6_port = sp->s_port;
memcpy(&sin6->sin6_addr, curHostInfo.addrList[0]->addr,
curHostInfo.addrList[0]->addrLen);
#ifdef HAVE_SA_LEN
sin6->sin6_len = sizeof(*sin6);
#endif
salen = sizeof(struct sockaddr_in6);
break;
}
/*
* Set up a virtual circuit to the host.
*/
sockFD = socket(curHostInfo.addrList[0]->addrType, SOCK_STREAM, 0);
if (sockFD < 0) {
fflush(stdout);
perror("finger: socket");
return (ERROR);
}
if (connect(sockFD, (struct sockaddr *)&sa, salen) < 0) {
fflush(stdout);
perror("finger: connect");
close(sockFD);
sockFD = -1;
return (ERROR);
}
if (!putToFile) {
filePtr = stdout;
} else {
filePtr = OpenFile(string, file, sizeof 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);
}
void
ListHost_close(void) {
if (sockFD != -1) {
(void) close(sockFD);
sockFD = -1;
}
}
File diff suppressed because it is too large. Load diff
-33
View File
@@ -1,33 +0,0 @@
$Id: nslookup.help,v 8.5 2000/03/30 23:25:35 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.)
exit - exit the program, ^D also exits
-73
View File
@@ -1,73 +0,0 @@
/*
* ++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.2 2000/11/08 06:47:32 marka Exp $
*/
#define _PATH_NSLOOKUPRC "/.nslookuprc"
#ifndef _PATH_PAGERCMD
#define _PATH_PAGERCMD "more"
#endif
#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
-227
View File
@@ -1,227 +0,0 @@
/*
* ++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.10 2002/04/09 05:55:22 marka 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.
*
*/
#ifdef ERROR
#undef ERROR
#endif
#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 {
int addrType;
int addrLen;
char *addr;
} AddrInfo;
typedef struct {
char *name; /* official name of host */
char **domains; /* domains it serves */
AddrInfo **addrList; /* list of addresses from name server */
} ServerInfo;
typedef struct {
char *name; /* official name of host */
char **aliases; /* alias list */
AddrInfo **addrList; /* list of addresses from name server */
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;
/*
* Our resolver context.
*/
extern struct __res_state res;
/*
* External routines:
*/
/* XXX need prototypes */
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 FreeHostInfoPtr();
extern FILE *OpenFile();
extern int pickString(const char *, char *, size_t);
extern int GetHostInfoByName(union res_sockaddr_union *, int, int,
const char *, HostInfo *, Boolean, Boolean);
extern int GetHostDomain(union res_sockaddr_union *, int, int,
const char *, char *, HostInfo *, Boolean, Boolean);
extern int matchString(const char *, const char *);
extern int StringToType(char *, int, FILE *);
extern int StringToClass(char *, int, FILE *);
extern int SendRequest(union res_sockaddr_union *, const u_char *, int,
u_char *, u_int, int *);
extern void SendRequest_close(void);
extern int SetDefaultServer(char *, Boolean);
extern int Finger(char *, int);
void ListHostsByType(char *, int);
void ListHosts(char *, int);
void ListHost_close(void);
int SetOption(char *);
int LookupHost(char *, Boolean);
int LookupHostWithServer(char *, Boolean);
const char * DecodeType(int);
const char * DecodeError(int);
FILE * OpenFile(char *, char *, size_t);
void PrintHostInfo(FILE *, const char *, HostInfo *);
char * Calloc(int, int);
char * Malloc(int);
SIG_FN IntrHandler(int);
int ListSubr(int, char *, char *);
void FreeHostInfoPtr(HostInfo *);
unsigned char * res_skip(unsigned char *, int, unsigned char *);
extern Boolean IsAddr(const char *, union res_sockaddr_union *);
void PrintHelp(void);
int GetHostInfoByAddr(union res_sockaddr_union *, union res_sockaddr_union *,
HostInfo *);
Loaded 100 of 3535 files, more files were not shown because too many files have changed in this diff. Show more