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/irpd Pull up revision 1.1 (new) (requeste...



details:   https://anonhg.NetBSD.org/src/rev/a36ca85978fb
branches:  netbsd-1-4
changeset: 469779:a36ca85978fb
user:      he <he%NetBSD.org@localhost>
date:      Sat Dec 04 16:52:48 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/irpd/irpd.c |  2254 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 2254 insertions(+), 0 deletions(-)

diffs (truncated from 2258 to 300 lines):

diff -r d49069b6486f -r a36ca85978fb dist/bind/bin/irpd/irpd.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/dist/bind/bin/irpd/irpd.c Sat Dec 04 16:52:48 1999 +0000
@@ -0,0 +1,2254 @@
+/*     $NetBSD: irpd.c,v 1.1.1.1.2.2 1999/12/04 16:52:48 he Exp $      */
+
+/*
+ * 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.
+ */
+
+/* Notes. */
+
+#if 0
+
+I have to use an AF_INET. Ctl_server should probably take a AF arugment.
+
+The server has no way to issue any other greeting than HELLO. E.g., would
+like to be able to drop connection on greeting if client is not comming
+from 127.0.0.1.
+
+Need to fix client to handle response with body.
+
+should add iovec with body to the struct ctl_sess?
+
+should we close connections on some errors (like marshalling errors)?
+
+getnetbyname falls back to /etc/networks when named not running. Does not
+seem to be so for getnetbyaddr
+
+#endif
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static const char rcsid[] = "Id: irpd.c,v 1.7 1999/10/13 16:26:23 vixie Exp";
+#endif /* LIBC_SCCS and not lint */
+
+/* Imports. */
+
+#include "port_before.h"
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <arpa/nameser.h>
+
+#include <assert.h>
+#include <ctype.h>
+#include <ctype.h>
+#include <errno.h>
+#include <grp.h>
+#include <netdb.h>
+#include <pwd.h>
+#include <pwd.h>
+#include <resolv.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <syslog.h>
+#include <unistd.h>
+#include <utmp.h>
+
+#ifdef EMPTY
+/* Digital UNIX utmp.h defines this. */
+#undef EMPTY
+#endif
+
+#include <isc/ctl.h>
+#include <isc/assertions.h>
+#include <isc/list.h>
+#include <isc/memcluster.h>
+#include <isc/logging.h>
+
+#include <irs.h>
+#include <irp.h>
+#include <isc/irpmarshall.h>
+#include <irs_data.h>
+
+#include "port_after.h"
+
+/* Macros. */
+
+#define ALLDIGITS(s) (strspn((s), "0123456789") == strlen((s)))
+
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 256
+#endif
+
+#define MAXNETNAMELEN 256
+
+#if !defined(SUN_LEN)
+#define SUN_LEN(su) \
+       (sizeof (*(su)) - sizeof ((su)->sun_path) + strlen((su)->sun_path))
+#endif
+
+/*
+ * This macro is used to initialize a specified field of a net_data struct.
+ * If the initialization fails then an error response code is sent with a
+ * description of which field failed to be initialized.
+ *
+ * This is only meant for use at the start of the various verb functions.
+ */
+
+#define ND_INIT(nd, field, sess, respcode)                                  \
+       do{ if ((nd)->field == 0) {                                          \
+               (nd)->field = (*(nd)->irs->field ## _map)(nd->irs);          \
+               if ((nd)->field == 0) {                                      \
+                   char *msg = "net_data " #field " initialization failed"; \
+                   ctl_response(sess, respcode, msg, CTL_EXIT, NULL,        \
+                                NULL, NULL, NULL, 0);                       \
+                   return;                                                  \
+                }                                                           \
+           }                                                                \
+       } while (0)
+
+/* Data structures. */
+
+struct arg_s  {
+       struct iovec *          iov;
+       int                     iovlen;
+};
+
+struct response_buff {
+       char *                  buff;
+       size_t                  bufflen;
+};
+
+struct client_ctx {
+       struct net_data *       net_data;
+};
+
+/* Forwards. */
+
+static struct response_buff *newbuffer(u_int length);
+static void release_buffer(struct response_buff *b);
+static struct arg_s *split_string(const char *string);
+static void free_args(struct arg_s *args);
+static int is_all_digits(char *p);
+static struct client_ctx *make_cli_ctx(void);
+static struct net_data *get_net_data(struct ctl_sess *sess);
+
+static void irpd_gethostbyname(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                              const struct ctl_verb *verb, const char *rest,
+                              u_int respflags, void *respctx, void *uctx);
+static void irpd_gethostbyname2(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                               const struct ctl_verb *verb, const char *rest,
+                               u_int respflags, void *respctx, void *uctx);
+static void irpd_gethostbyaddr(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                              const struct ctl_verb *verb, const char *rest,
+                              u_int respflags, void *respctx, void *uctx);
+static void irpd_gethostent(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                           const struct ctl_verb *verb, const char *rest,
+                           u_int respflags, void *respctx, void *uctx);
+static void irpd_sethostent(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                           const struct ctl_verb *verb, const char *rest,
+                           u_int respflags, void *respctx, void *uctx);
+static void irpd_getpwnam(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                         const struct ctl_verb *verb, const char *rest,
+                         u_int respflags, void *respctx, void *uctx);
+static void irpd_getpwuid(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                         const struct ctl_verb *verb, const char *rest,
+                         u_int respflags, void *respctx, void *uctx);
+static void irpd_getpwent(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                         const struct ctl_verb *verb, const char *rest,
+                         u_int respflags, void *respctx, void *uctx);
+static void irpd_setpwent(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                         const struct ctl_verb *verb, const char *rest,
+                         u_int respflags, void *respctx, void *uctx);
+static void irpd_getnetbyname(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                             const struct ctl_verb *verb, const char *rest,
+                             u_int respflags, void *respctx, void *uctx);
+static void irpd_getnetbyaddr(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                             const struct ctl_verb *verb, const char *rest,
+                             u_int respflags, void *respctx, void *uctx);
+static void irpd_getnetent(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                          const struct ctl_verb *verb, const char *rest,
+                          u_int respflags, void *respctx, void *uctx);
+static void irpd_setnetent(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                          const struct ctl_verb *verb, const char *rest,
+                          u_int respflags, void *respctx, void *uctx);
+static void irpd_getgrnam(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                         const struct ctl_verb *verb, const char *rest,
+                         u_int respflags, void *respctx, void *uctx);
+static void irpd_getgrgid(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                         const struct ctl_verb *verb, const char *rest,
+                         u_int respflags, void *respctx, void *uctx);
+static void irpd_getgrent(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                         const struct ctl_verb *verb, const char *rest,
+                         u_int respflags, void *respctx, void *uctx);
+static void irpd_setgrent(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                         const struct ctl_verb *verb, const char *rest,
+                         u_int respflags, void *respctx, void *uctx);
+static void irpd_getservbyname(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                              const struct ctl_verb *verb, const char *rest,
+                              u_int respflags, void *respctx, void *uctx);
+static void irpd_getservbyport(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                              const struct ctl_verb *verb, const char *rest,
+                              u_int respflags, void *respctx, void *uctx);
+static void irpd_getservent(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                           const struct ctl_verb *verb, const char *rest,
+                           u_int respflags, void *respctx, void *uctx);
+static void irpd_setservent(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                           const struct ctl_verb *verb, const char *rest,
+                           u_int respflags, void *respctx, void *uctx);
+static void irpd_getprotobyname(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                               const struct ctl_verb *verb, const char *rest,
+                               u_int respflags, void *respctx, void *uctx);
+static void irpd_getprotobynumber(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                                 const struct ctl_verb *verb, const char *rest,
+                                 u_int respflags, void *respctx, void *uctx);
+static void irpd_getprotoent(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                            const struct ctl_verb *verb, const char *rest,
+                            u_int respflags, void *respctx, void *uctx);
+static void irpd_setprotoent(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                            const struct ctl_verb *verb, const char *rest,
+                            u_int respflags, void *respctx, void *uctx);
+static void irpd_getnetgrent(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                            const struct ctl_verb *verb, const char *rest,
+                            u_int respflags, void *respctx, void *uctx);
+static void irpd_innetgr(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                        const struct ctl_verb *verb, const char *rest,
+                        u_int respflags, void *respctx, void *uctx);
+static void irpd_setnetgrent(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                            const struct ctl_verb *verb, const char *rest,
+                            u_int respflags, void *respctx, void *uctx);
+static void irpd_endnetgrent(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                            const struct ctl_verb *verb, const char *rest,
+                            u_int respflags, void *respctx, void *uctx);
+static void irpd_quit(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                     const struct ctl_verb *verb, const char *rest,
+                     u_int respflags, void *respctx, void *uctx);
+static void irpd_help(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                     const struct ctl_verb *verb, const char *rest,
+                     u_int respflags, void *respctx, void *uctx);
+static void irpd_accept(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                       const struct ctl_verb *verb, const char *rest,
+                       u_int respflags, void *respctx, void *uctx);
+static void irpd_abort(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                      const struct ctl_verb *verb, const char *rest,
+                      u_int respflags, void *respctx, void *uctx);
+
+static void irpd_done(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                     void *param);
+static void response_done(struct ctl_sctx *ctx, struct ctl_sess *sess,
+                         void *uap);
+static void logger(enum ctl_severity, const char *fmt, ...);
+
+/* Constants. */
+
+static const u_int hello_code = IRPD_WELCOME_CODE;
+static const char hello_msg[] = "Welcome to IRPD (v 1)";
+static const u_int unkncode = 500;
+static const u_int timeoutcode = 501;
+static const u_int irpd_quit_ok = 201;
+static const u_int timeout = IRPD_TIMEOUT;
+
+/* Globals. */
+
+static int main_needs_exit = 0;
+static evContext ev;
+
+struct ctl_verb verbs [] = {
+       { "gethostbyname", irpd_gethostbyname },
+       { "gethostbyname2", irpd_gethostbyname2 },
+       { "gethostbyaddr", irpd_gethostbyaddr },
+       { "gethostent", irpd_gethostent },
+       { "sethostent", irpd_sethostent },
+#ifdef WANT_IRS_PW
+       { "getpwnam", irpd_getpwnam },
+       { "getpwuid", irpd_getpwuid },
+       { "getpwent", irpd_getpwent },
+       { "setpwent", irpd_setpwent },
+#endif
+       { "getnetbyname", irpd_getnetbyname },
+       { "getnetbyaddr", irpd_getnetbyaddr },
+       { "getnetent", irpd_getnetent },
+       { "setnetent", irpd_setnetent },
+#ifdef WANT_IRS_GR
+       { "getgrnam", irpd_getgrnam },
+       { "getgrgid", irpd_getgrgid },
+       { "getgrent", irpd_getgrent },
+       { "setgrent", irpd_setgrent },
+#endif
+       { "getservbyname", irpd_getservbyname },
+       { "getservbyport", irpd_getservbyport },



Home | Main Index | Thread Index | Old Index