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 revision 1.1 (new) (request...
details: https://anonhg.NetBSD.org/src/rev/3d2089166474
branches: netbsd-1-4
changeset: 469785:3d2089166474
user: he <he%NetBSD.org@localhost>
date: Sat Dec 04 16:54:19 1999 +0000
description:
Pull up revision 1.1 (new) (requested by christos and veego):
Update to BIND 8.2.2-P5.
diffstat:
dist/bind/bin/named/ns_ctl.c | 868 ++++++++++++++++++++++++++++
dist/bind/bin/named/ns_defs.h | 880 ++++++++++++++++++++++++++++
dist/bind/bin/named/ns_forw.c | 1271 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 3019 insertions(+), 0 deletions(-)
diffs (truncated from 3031 to 300 lines):
diff -r 5b6f1254bf29 -r 3d2089166474 dist/bind/bin/named/ns_ctl.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dist/bind/bin/named/ns_ctl.c Sat Dec 04 16:54:19 1999 +0000
@@ -0,0 +1,868 @@
+/* $NetBSD: ns_ctl.c,v 1.1.1.1.2.2 1999/12/04 16:54:19 he Exp $ */
+
+#if !defined(lint) && !defined(SABER)
+static const char rcsid[] = "Id: ns_ctl.c,v 8.28 1999/10/13 16:39:04 vixie Exp";
+#endif /* not lint */
+
+/*
+ * Copyright (c) 1997-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.
+ */
+
+/* Extern. */
+
+#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 <ctype.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 <unistd.h>
+#include <fcntl.h>
+
+#include <isc/eventlib.h>
+#include <isc/logging.h>
+#include <isc/memcluster.h>
+
+#include "port_after.h"
+
+#include "named.h"
+
+/* Defs. */
+
+#define CONTROL_FOUND 0x0001 /* for mark and sweep. */
+#define MAX_STR_LEN 500
+
+struct control {
+ LINK(struct control) link;
+ enum { t_dead, t_inet, t_unix } type;
+ struct ctl_sctx *sctx;
+ u_int flags;
+ union {
+ struct {
+ struct sockaddr_in in;
+ ip_match_list allow;
+ } v_inet;
+ struct {
+ struct sockaddr_un un;
+ mode_t mode;
+ uid_t owner;
+ gid_t group;
+ } v_unix;
+ } var;
+};
+
+/* Forward. */
+
+static struct ctl_sctx *mksrvr(control, const struct sockaddr *, size_t);
+static control new_control(void);
+static void free_control(controls *, control);
+static void free_controls(controls *);
+static int match_control(control, control);
+static control find_control(controls, control);
+static void propagate_changes(const control, control);
+static void install(control);
+static void install_inet(control);
+static void install_unix(control);
+static void logger(enum ctl_severity, const char *fmt, ...);
+static void verb_connect(struct ctl_sctx *, struct ctl_sess *,
+ const struct ctl_verb *,
+ const char *, u_int, void *, void *);
+static void verb_getpid(struct ctl_sctx *, struct ctl_sess *,
+ const struct ctl_verb *,
+ const char *, u_int, void *, void *);
+static void getpid_closure(struct ctl_sctx *, struct ctl_sess *,
+ void *);
+static void verb_status(struct ctl_sctx *, struct ctl_sess *,
+ const struct ctl_verb *,
+ const char *, u_int, void *, void *);
+static void status_closure(struct ctl_sctx *, struct ctl_sess *,
+ void *);
+static void verb_stop(struct ctl_sctx *, struct ctl_sess *,
+ const struct ctl_verb *,
+ const char *, u_int, void *, void *);
+static void verb_exec(struct ctl_sctx *, struct ctl_sess *,
+ const struct ctl_verb *,
+ const char *, u_int, void *, void *);
+static void verb_reload(struct ctl_sctx *, struct ctl_sess *,
+ const struct ctl_verb *,
+ const char *, u_int, void *, void *);
+static void verb_reconfig(struct ctl_sctx *, struct ctl_sess *,
+ const struct ctl_verb *,
+ const char *, u_int, void *, void *);
+static void verb_dumpdb(struct ctl_sctx *, struct ctl_sess *,
+ const struct ctl_verb *,
+ const char *, u_int, void *, void *);
+static void verb_stats(struct ctl_sctx *, struct ctl_sess *,
+ const struct ctl_verb *,
+ const char *, u_int, void *, void *);
+static void verb_trace(struct ctl_sctx *, struct ctl_sess *,
+ const struct ctl_verb *,
+ const char *, u_int, void *, void *);
+static void trace_closure(struct ctl_sctx *, struct ctl_sess *,
+ void *);
+static void verb_notrace(struct ctl_sctx *, struct ctl_sess *,
+ const struct ctl_verb *,
+ const char *, u_int, void *, void *);
+static void verb_querylog(struct ctl_sctx *, struct ctl_sess *,
+ const struct ctl_verb *,
+ const char *, u_int, void *, void *);
+static void verb_help(struct ctl_sctx *, struct ctl_sess *,
+ const struct ctl_verb *,
+ const char *, u_int, void *, void *);
+static void verb_quit(struct ctl_sctx *, struct ctl_sess *,
+ const struct ctl_verb *,
+ const char *, u_int, void *, void *);
+
+/* Private data. */
+
+static controls server_controls;
+
+static struct ctl_verb verbs[] = {
+ { "", verb_connect, ""},
+ { "getpid", verb_getpid, "getpid"},
+ { "status", verb_status, "status"},
+ { "stop", verb_stop, "stop"},
+ { "exec", verb_exec, "exec"},
+ { "reload", verb_reload, "reload [zone] ..."},
+ { "reconfig", verb_reconfig, "reconfig (just sees new/gone zones)"},
+ { "dumpdb", verb_dumpdb, "dumpdb"},
+ { "stats", verb_stats, "stats"},
+ { "trace", verb_trace, "trace [level]"},
+ { "notrace", verb_notrace, "notrace"},
+ { "querylog", verb_querylog, "querylog"},
+ { "qrylog", verb_querylog, "qrylog"},
+ { "help", verb_help, "help"},
+ { "quit", verb_quit, "quit"},
+ { NULL, NULL, NULL}
+};
+
+/* Public functions. */
+
+void
+ns_ctl_initialize(void) {
+ INIT_LIST(server_controls);
+}
+
+void
+ns_ctl_shutdown(void) {
+ if (!EMPTY(server_controls))
+ free_controls(&server_controls);
+}
+
+void
+ns_ctl_defaults(controls *list) {
+ ns_ctl_add(list, ns_ctl_new_unix(_PATH_NDCSOCK, 0600, 0, 0));
+}
+
+void
+ns_ctl_add(controls *list, control new) {
+ if (!find_control(*list, new))
+ APPEND(*list, new, link);
+}
+
+control
+ns_ctl_new_inet(struct in_addr saddr, u_int sport, ip_match_list allow) {
+ control new = new_control();
+
+ INIT_LINK(new, link);
+ new->type = t_inet;
+ memset(&new->var.v_inet.in, 0, sizeof new->var.v_inet.in);
+ new->var.v_inet.in.sin_family = AF_INET;
+ new->var.v_inet.in.sin_addr = saddr;
+ new->var.v_inet.in.sin_port = sport;
+ new->var.v_inet.allow = allow;
+ return (new);
+}
+
+control
+ns_ctl_new_unix(char *path, mode_t mode, uid_t owner, gid_t group) {
+ control new = new_control();
+
+ INIT_LINK(new, link);
+ new->type = t_unix;
+ memset(&new->var.v_unix.un, 0, sizeof new->var.v_unix.un);
+ new->var.v_unix.un.sun_family = AF_UNIX;
+ strncpy(new->var.v_unix.un.sun_path, path,
+ sizeof new->var.v_unix.un.sun_path - 1);
+ new->var.v_unix.mode = mode;
+ new->var.v_unix.owner = owner;
+ new->var.v_unix.group = group;
+ return (new);
+}
+
+void
+ns_ctl_install(controls *new) {
+ control ctl, old, next;
+
+ /* Find all the controls which aren't new or deleted. */
+ for (ctl = HEAD(server_controls); ctl != NULL; ctl = NEXT(ctl, link))
+ ctl->flags &= ~CONTROL_FOUND;
+ for (ctl = HEAD(*new); ctl != NULL; ctl = next) {
+ next = NEXT(ctl, link);
+ old = find_control(server_controls, ctl);
+ if (old != NULL) {
+ old->flags |= CONTROL_FOUND;
+ propagate_changes(ctl, old);
+ if (old->sctx == NULL)
+ free_control(&server_controls, old);
+ free_control(new, ctl);
+ }
+ }
+
+ /* Destroy any old controls which weren't found. */
+ for (ctl = HEAD(server_controls); ctl != NULL; ctl = next) {
+ next = NEXT(ctl, link);
+ if ((ctl->flags & CONTROL_FOUND) == 0)
+ free_control(&server_controls, ctl);
+ }
+
+ /* Add any new controls which were found. */
+ for (ctl = HEAD(*new); ctl != NULL; ctl = next) {
+ next = NEXT(ctl, link);
+ APPEND(server_controls, ctl, link);
+ install(ctl);
+ if (ctl->sctx == NULL)
+ free_control(&server_controls, ctl);
+ }
+}
+
+/* Private functions. */
+
+static struct ctl_sctx *
+mksrvr(control ctl, const struct sockaddr *sa, size_t salen) {
+ return (ctl_server(ev, sa, salen, verbs, 500, 222,
+ 600, 5, 10, logger, ctl));
+}
+
+static control
+new_control(void) {
+ control new = memget(sizeof *new);
+
+ if (new == NULL)
+ panic("memget failed in new_control()", NULL);
+ new->type = t_dead;
+ new->sctx = NULL;
+ return (new);
+}
+
+static void
+free_control(controls *list, control this) {
+ int was_live = 0;
+ struct stat sb;
+
+ if (this->sctx != NULL) {
+ ctl_endserver(this->sctx);
+ this->sctx = NULL;
+ was_live = 1;
+ }
+ switch (this->type) {
+ case t_inet:
+ if (this->var.v_inet.allow != NULL) {
+ free_ip_match_list(this->var.v_inet.allow);
+ this->var.v_inet.allow = NULL;
+ }
+ break;
+ case t_unix:
+ /* XXX Race condition. */
+ if (was_live &&
+ stat(this->var.v_unix.un.sun_path, &sb) == 0 &&
Home |
Main Index |
Thread Index |
Old Index