Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-4]: src/dist/bind/bin/named Pull up revisions 1.1-1.4 (new) (re...



details:   https://anonhg.NetBSD.org/src/rev/82724f39c8f5
branches:  netbsd-1-4
changeset: 469788:82724f39c8f5
user:      he <he%NetBSD.org@localhost>
date:      Sat Dec 04 16:55:07 1999 +0000

description:
Pull up revisions 1.1-1.4 (new) (requested by christos and veego):
  Update to BIND 8.2.2-P5.

diffstat:

 dist/bind/bin/named/ns_main.c |  2741 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 2741 insertions(+), 0 deletions(-)

diffs (truncated from 2745 to 300 lines):

diff -r 22b9197cb8df -r 82724f39c8f5 dist/bind/bin/named/ns_main.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/dist/bind/bin/named/ns_main.c     Sat Dec 04 16:55:07 1999 +0000
@@ -0,0 +1,2741 @@
+/*     $NetBSD: ns_main.c,v 1.4.2.2 1999/12/04 16:55:07 he Exp $       */
+
+#if !defined(lint) && !defined(SABER)
+static const char sccsid[] = "@(#)ns_main.c    4.55 (Berkeley) 7/1/91";
+static const char rcsid[] = "Id: ns_main.c,v 8.117 1999/11/08 23:01:38 vixie 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-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 !defined(lint) && !defined(SABER)
+char copyright[] =
+"@(#) Copyright (c) 1986, 1989, 1990 The Regents of the University of California.\n"
+"portions Copyright (c) 1993 Digital Equipment Corporation\n"
+"portions Copyright (c) 1995-1999 Internet Software Consortium\n"
+"portions Copyright (c) 1999 Check Point Software Technologies\n"
+"All rights reserved.\n";
+#endif /* not lint */
+
+/*
+ * Internet Name server (see RCF1035 & others).
+ */
+
+#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>
+#include <sys/un.h>
+#ifdef SVR4    /* XXX */
+# include <sys/sockio.h>
+#else
+# include <sys/mbuf.h>
+#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"
+
+#ifdef HAVE_GETRUSAGE          /* XXX */
+#include <sys/resource.h>
+#endif
+
+#define MAIN_PROGRAM
+#include "named.h"
+#undef MAIN_PROGRAM
+
+                               /* list of interfaces */
+static LIST(struct _interface) iflist;
+static int                     iflist_initialized = 0;
+static int                     iflist_dont_rescan = 0;
+
+static const int               drbufsize = 32 * 1024,  /* UDP rcv buf size */
+                               dsbufsize = 48 * 1024,  /* UDP snd buf size */
+                               sbufsize = 16 * 1024,   /* TCP snd buf size */ 
+                               nudptrans = 20,         /* #/udps per select */
+                               listenmax = 50;
+
+static u_int16_t               nsid_state;
+static u_int16_t               *nsid_pool;  /* optional query id pool */
+static u_int16_t               *nsid_vtable;  /* optional shuffle table */
+static u_int32_t               nsid_hash_state;
+static u_int16_t               nsid_a1, nsid_a2, nsid_a3;
+static u_int16_t               nsid_c1, nsid_c2, nsid_c3;
+static u_int16_t               nsid_state2;
+static int                     nsid_algorithm;
+
+typedef void (*handler)(void);
+static int                     needs = 0;
+static handler                 handlers[main_need_num];
+
+static struct qstream          *sq_add(void);
+static int                     opensocket_d(interface *),
+                               opensocket_s(interface *);
+static void                    sq_query(struct qstream *),
+                               dq_remove(interface *);
+static int                     sq_dowrite(struct qstream *);
+static void                    use_desired_debug(void);
+static void                    stream_write(evContext, void *, int, int);
+
+static interface *             if_find(struct in_addr, u_int16_t port);
+
+static int                     sq_here(struct qstream *);
+
+static void                    deallocate_everything(void),
+                               stream_accept(evContext, void *, int,
+                                             const void *, int,
+                                             const void *, int),
+                               stream_getlen(evContext, void *, int, int),
+                               stream_getmsg(evContext, void *, int, int),
+                               datagram_read(evContext, void *, int, int),
+                               dispatch_message(u_char *, int, int,
+                                                struct qstream *,
+                                                struct sockaddr_in, int,
+                                                interface *);
+static void                    stream_send(evContext, void *, int,
+                                              const void *, int,
+                                              const void *, int);
+static int                     only_digits(const char *);
+
+static void                    init_needs(void),
+                               handle_need(void);
+
+#ifndef HAVE_CUSTOM
+static void                    custom_init(void),
+                               custom_shutdown(void);
+#endif
+
+static void
+usage() {
+       fprintf(stderr,
+"Usage: named [-d #] [-q] [-r] [-v] [-f] [-p port] [[-b|-c] configfile]\n");
+#ifdef CAN_CHANGE_ID
+       fprintf(stderr,
+"             [-u (username|uid)] [-g (groupname|gid)]\n");
+#endif
+#ifdef HAVE_CHROOT
+       fprintf(stderr,
+"             [-t directory]\n");
+#endif
+       exit(1);
+}
+
+static char bad_p_option[] =
+"-p remote/local obsolete; use 'listen-on' in config file to specify local";
+
+static char bad_directory[] = "chdir failed for directory '%s': %s";
+
+/*ARGSUSED*/
+int
+main(int argc, char *argv[], char *envp[]) {
+       int n;
+       char *p;
+       int ch;
+       struct passwd *pw;
+       struct group *gr;
+
+#ifdef _AUX_SOURCE
+       set42sig();
+#endif
+       debugfile = savestr(_PATH_DEBUG, 1);
+
+       user_id = getuid();
+       group_id = getgid();
+
+       ns_port = htons(NAMESERVER_PORT);
+       desired_debug = debug;
+
+       /* BSD has a better random number generator but it's not clear
+        * that we need it here.
+        */
+       gettime(&tt);
+       srand(((unsigned)getpid()) + (unsigned)tt.tv_usec);
+
+       (void) umask(022);
+
+       /* Save argv[] before getopt() destroys it -- needed for execvp(). */
+       saved_argv = malloc(sizeof(char *) * (argc + 1));
+       INSIST(saved_argv != NULL);
+       for (n = 0; n < argc; n++) {
+               saved_argv[n] = strdup(argv[n]);
+               INSIST(saved_argv[n] != NULL);
+       }
+       saved_argv[argc] = NULL;
+       /* XXX we need to free() this for clean shutdowns. */
+
+       while ((ch = getopt(argc, argv, "b:c:d:g:p:t:u:vw:qrf")) != -1) {
+               switch (ch) {
+               case 'b':
+               case 'c':
+                       if (conffile != NULL)
+                               freestr(conffile);
+                       conffile = savestr(optarg, 1);
+                       break;
+
+               case 'd':
+                       desired_debug = atoi(optarg);
+                       if (desired_debug <= 0)
+                               desired_debug = 1;
+                       break;
+
+               case 'p':
+                       /* use nonstandard port number.
+                        * usage: -p remote/local
+                        * remote is the port number to which
+                        * we send queries.  local is the port
+                        * on which we listen for queries.
+                        * local defaults to same as remote.
+                        */
+                       ns_port = htons((u_int16_t) atoi(optarg));
+                       p = strchr(optarg, '/');
+                       if (p) {
+                               syslog(LOG_WARNING, bad_p_option);
+                               fprintf(stderr, bad_p_option);
+                               fputc('\n', stderr);
+                       }
+                       break;
+
+               case 'w':
+                       if (chdir(optarg) < 0) {
+                               syslog(LOG_CRIT, bad_directory, optarg,



Home | Main Index | Thread Index | Old Index