Remove broken legacy resolv code
authorRemco Rijnders <remco@webconquest.com>
Wed, 22 Aug 2012 15:42:13 +0000 (17:42 +0200)
committerRemco Rijnders <remco@webconquest.com>
Wed, 22 Aug 2012 15:46:05 +0000 (17:46 +0200)
The IRCD shipped with two versions of its own resolv header files,
as well as a variety of res_*.c helper files. These are all no
longer needed on Linux and have been removed.

A lot of thanks to an anonymous contributor for helping to solve this
long standing issue!

12 files changed:
Makefile [new file with mode: 0755]
Makefile.dist
include/nameser.h [deleted file]
include/resolv.h [deleted file]
include/resolv_legacy.h [deleted file]
src/Makefile
src/res.c
src/res_comp.c [deleted file]
src/res_init.c [deleted file]
src/res_mkquery.c [deleted file]
src/res_skipname.c [deleted file]
src/s_bsd.c

diff --git a/Makefile b/Makefile
new file mode 100755 (executable)
index 0000000..906ed02
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,124 @@
+#/************************************************************************
+#*   IRC - Internet Relay Chat, Makefile
+#*   Copyright (C) 1990, Jarkko Oikarinen
+#*
+#*   This program is free software; you can redistribute it and/or modify
+#*   it under the terms of the GNU General Public License as published by
+#*   the Free Software Foundation; either version 1, or (at your option)
+#*   any later version.
+#*
+#*   This program is distributed in the hope that it will be useful,
+#*   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#*   GNU General Public License for more details.
+#*
+#*   You should have received a copy of the GNU General Public License
+#*   along with this program; if not, write to the Free Software
+#*   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#*/
+
+CC=gcc
+INCLUDEDIR=../include
+
+# [CHANGEME]
+# Default flags:
+# Change XCFLAGS if you don't like what Config puts there.  Same with
+# IRCDLIBS.
+#
+# If you are configuring by hand, try "-O -g" for XCFLAGS, and leave
+# IRCDLIBS blank.  If that fails, try recomendations below.
+#
+XCFLAGS=-O
+IRCDLIBS=-lcrypt -lresolv -lz
+
+# [CHANGEME]
+# IRCDMODE is the mode you want the binary to be.
+# The 4 at the front is important (allows for setuidness)
+#
+# WARNING: if you are making ircd SUID or SGID, check config.h to make sure
+#          you are not defining CMDLINE_CONFIG 
+IRCDMODE = 711
+
+# [CHANGEME]
+# IRCDDIR must be the same as DPATH in include/config.h
+#
+IRCDDIR=/usr/local/lib/ircd
+
+# [CHANGEME]
+# If you get a compile-time error dealing with u_int32_t, comment out
+# this line.
+# NEED_U_INT32_T=      -DNEED_U_INT32_T
+NEED_U_INT32_T=
+
+# [CHANGEME]
+# If you get a link-time error dealing with strtoul, comment out
+# this line.
+# STRTOUL=     strtoul.o
+STRTOUL=
+
+# [CHANGEME]
+# If you get crashes around a specific number of clients, and that client
+# load comes close or a little over the system-defined value of FD_SETSIZE,
+# override it here and see what happens.
+FD_SETSIZE=
+
+CFLAGS=-I$(INCLUDEDIR) $(XCFLAGS) $(NEED_U_INT32_T) $(FD_SETSIZE)
+
+SHELL=/bin/sh
+SUBDIRS=src
+BINDIR=$(IRCDDIR)
+MANDIR=/usr/local/man
+INSTALL=/usr/bin/install
+RM=rm
+CP=cp
+TOUCH=touch
+
+all:   build
+
+MAKEARGS =     'CFLAGS=${CFLAGS}' 'CC=${CC}' 'IRCDLIBS=${IRCDLIBS}' \
+               'LDFLAGS=${LDFLAGS}' 'IRCDMODE=${IRCDMODE}' \
+               'BINDIR=${BINDIR}' 'INSTALL=${INSTALL}' \
+               'INCLUDEDIR=${INCLUDEDIR}' 'IRCDDIR=${IRCDDIR}' \
+               'MANDIR=${MANDIR}' 'RM=${RM}' 'CP=${CP}' 'TOUCH=${TOUCH}' \
+               'RES=${RES}' 'SHELL=${SHELL}' 'STRTOUL=${STRTOUL}'
+
+server:
+
+build:
+       -@if [ ! -f include/setup.h ] ; then \
+               echo "You have not run Config..."; \
+               echo "Doing so now.."; \
+               sh Config; \
+       fi
+       @for i in $(SUBDIRS); do \
+               echo "Building $$i";\
+               ( cd $$i; ${MAKE} ${MAKEARGS} build; ) ; \
+       done
+       @echo ''
+       @echo 'Serene IRCD compiled!'
+       @echo ''
+
+clean:
+       @echo 'Cleaning Serene IRCD'
+       @for i in $(SUBDIRS); do \
+               echo "Cleaning $$i";\
+               ( cd $$i; ${MAKE} ${MAKEARGS} clean; ) ; \
+       done
+       @echo ''
+       @echo 'Cleaning complete.'
+       @echo ''
+
+distclean: clean
+       rm -rf include/setup.h Makefile Options .install
+       @echo ''
+       @echo 'Distribution is now fully cleaned.'
+       @echo ''
+depend:
+       @for i in $(SUBDIRS); do \
+               echo "Making dependencies in $$i";\
+               ( cd $$i; ${MAKE} ${MAKEARGS} depend; ) ; \
+       done
+
+install: all
+       @echo "Copying ircd to the right location."
+       ./.install
index fa33a69a0ec5de129bb229290807ef4bef079120..bc14d822bda466e082c2464efa56f3354a3d19b4 100755 (executable)
@@ -44,14 +44,6 @@ IRCDMODE = 711
 #
 IRCDDIR=/usr/local/lib/ircd
 
-# [CHANGEME]
-# Some SunOS versions want this.  Try it without first.
-#RES=res_init.o res_comp.o res_mkquery.o
-# BSDI systems want this.
-#RES=res_skipname.o
-# The rest are perfectly content with this.
-RES=
-
 # [CHANGEME]
 # If you get a compile-time error dealing with u_int32_t, comment out
 # this line.
diff --git a/include/nameser.h b/include/nameser.h
deleted file mode 100644 (file)
index 280828e..0000000
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Copyright (c) 1983, 1989 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that: (1) source distributions retain this entire copyright
- * notice and comment, and (2) distributions including binaries display
- * the following acknowledgement:  ``This product includes software
- * developed by the University of California, Berkeley and its contributors''
- * in the documentation or other materials provided with the distribution
- * and in all advertising materials mentioning features or use of this
- * software. 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- *     @(#)nameser.h   5.24 (Berkeley) 6/1/90
- */
-
-#include <limits.h>
-#ifndef __GLIBC__
-
-/*
- * Define constants based on rfc883
- */
-#define PACKETSZ       512             /* maximum packet size */
-#define MAXDNAME       256             /* maximum domain name */
-#define MAXCDNAME      255             /* maximum compressed domain name */
-#define MAXLABEL       63              /* maximum length of domain label */
-       /* Number of bytes of fixed size data in query structure */
-#define QFIXEDSZ       4
-       /* number of bytes of fixed size data in resource record */
-#define RRFIXEDSZ      10
-
-/*
- * Internet nameserver port number
- */
-#define NAMESERVER_PORT        53
-
-/*
- * Currently defined opcodes
- */
-#define QUERY          0x0             /* standard query */
-#define IQUERY         0x1             /* inverse query */
-#define STATUS         0x2             /* nameserver status query */
-/*#define xxx          0x3              0x3 reserved */
-       /* non standard */
-#define UPDATEA                0x9             /* add resource record */
-#define UPDATED                0xa             /* delete a specific resource record */
-#define UPDATEDA       0xb             /* delete all nemed resource record */
-#define UPDATEM                0xc             /* modify a specific resource record */
-#define UPDATEMA       0xd             /* modify all named resource record */
-
-#define ZONEINIT       0xe             /* initial zone transfer */
-#define ZONEREF                0xf             /* incremental zone referesh */
-
-/*
- * Currently defined response codes
- */
-#ifdef NOERROR                         /* defined by solaris2 in */
-#undef NOERROR                         /* <sys/stream.h> to be -1 */
-#endif
-#define NOERROR                0               /* no error */
-#define FORMERR                1               /* format error */
-#define SERVFAIL       2               /* server failure */
-#define NXDOMAIN       3               /* non existent domain */
-#define NOTIMP         4               /* not implemented */
-#define REFUSED                5               /* query refused */
-       /* non standard */
-#define NOCHANGE       0xf             /* update failed to change db */
-
-/*
- * Type values for resources and queries
- */
-#define T_A            1               /* host address */
-#define T_NS           2               /* authoritative server */
-#define T_MD           3               /* mail destination */
-#define T_MF           4               /* mail forwarder */
-#define T_CNAME                5               /* connonical name */
-#define T_SOA          6               /* start of authority zone */
-#define T_MB           7               /* mailbox domain name */
-#define T_MG           8               /* mail group member */
-#define T_MR           9               /* mail rename name */
-#define T_NULL         10              /* null resource record */
-#define T_WKS          11              /* well known service */
-#define T_PTR          12              /* domain name pointer */
-#define T_HINFO                13              /* host information */
-#define T_MINFO                14              /* mailbox information */
-#define T_MX           15              /* mail routing information */
-#define T_TXT          16              /* text strings */
-       /* non standard */
-#define T_UINFO                100             /* user (finger) information */
-#define T_UID          101             /* user ID */
-#define T_GID          102             /* group ID */
-#define T_UNSPEC       103             /* Unspecified format (binary data) */
-       /* Query type values which do not appear in resource records */
-#define T_AXFR         252             /* transfer zone of authority */
-#define T_MAILB                253             /* transfer mailbox records */
-#define T_MAILA                254             /* transfer mail agent records */
-#define T_ANY          255             /* wildcard match */
-
-/*
- * Values for class field
- */
-
-#define C_IN           1               /* the arpa internet */
-#define C_CHAOS                3               /* for chaos net at MIT */
-#define C_HS           4               /* for Hesiod name server at MIT */
-       /* Query class values which do not appear in resource records */
-#define C_ANY          255             /* wildcard match */
-
-/*
- * Status return codes for T_UNSPEC conversion routines
- */
-#define CONV_SUCCESS 0
-#define CONV_OVERFLOW -1
-#define CONV_BADFMT -2
-#define CONV_BADCKSUM -3
-#define CONV_BADBUFLEN -4
-
-#ifndef BYTE_ORDER
-#define        LITTLE_ENDIAN   1234    /* least-significant byte first (vax) */
-#define        BIG_ENDIAN      4321    /* most-significant byte first (IBM, net) */
-#define        PDP_ENDIAN      3412    /* LSB first in word, MSW first in long (pdp) */
-
-#if defined(vax) || defined(ns32000) || defined(sun386) || defined(MIPSEL) || \
-    defined(BIT_ZERO_ON_RIGHT) || defined(sequent) || defined(i386) ||\
-    defined(___vax__) || defined(__ns32000__) || defined(__sun386__) ||\
-    defined(__alpha)
-#define BYTE_ORDER     LITTLE_ENDIAN
-
-#endif
-#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
-    defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
-    defined(MIPSEB) || defined(__hpux) || defined(__convex__) || \
-    defined(__pyr__) || defined(__mc68000__) || defined(__sparc__) ||\
-    defined(_IBMR2) || defined (BIT_ZERO_ON_LEFT)
-#define BYTE_ORDER     BIG_ENDIAN
-#endif
-#endif /* BYTE_ORDER */
-
-#ifndef BYTE_ORDER
-/* you must determine what the correct bit order is for your compiler */
-       UNDEFINED_BIT_ORDER;
-#endif
-/*
- * Structure for query header, the order of the fields is machine and
- * compiler dependent, in our case, the bits within a byte are assignd 
- * least significant first, while the order of transmition is most 
- * significant first.  This requires a somewhat confusing rearrangement.
- */
-
-typedef struct {
-       u_short id;             /* query identification number */
-#if BYTE_ORDER == BIG_ENDIAN
-                       /* fields in third byte */
-       u_char  qr:1;           /* response flag */
-       u_char  opcode:4;       /* purpose of message */
-       u_char  aa:1;           /* authoritive answer */
-       u_char  tc:1;           /* truncated message */
-       u_char  rd:1;           /* recursion desired */
-                       /* fields in fourth byte */
-       u_char  ra:1;           /* recursion available */
-       u_char  pr:1;   /* primary server required (non standard) */
-       u_char  unused:2;       /* unused bits */
-       u_char  rcode:4;        /* response code */
-#endif
-#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
-                       /* fields in third byte */
-       u_char  rd:1;           /* recursion desired */
-       u_char  tc:1;           /* truncated message */
-       u_char  aa:1;           /* authoritive answer */
-       u_char  opcode:4;       /* purpose of message */
-       u_char  qr:1;           /* response flag */
-                       /* fields in fourth byte */
-       u_char  rcode:4;        /* response code */
-       u_char  unused:2;       /* unused bits */
-       u_char  pr:1;   /* primary server required (non standard) */
-       u_char  ra:1;           /* recursion available */
-#endif
-                       /* remaining bytes */
-       u_short qdcount;        /* number of question entries */
-       u_short ancount;        /* number of answer entries */
-       u_short nscount;        /* number of authority entries */
-       u_short arcount;        /* number of resource entries */
-} HEADER;
-
-/*
- * Defines for handling compressed domain names
- */
-#define INDIR_MASK     0xc0
-
-/*
- * Structure for passing resource records around.
- */
-struct rrec {
-       short   r_zone;                 /* zone number */
-       short   r_class;                /* class number */
-       short   r_type;                 /* type number */
-#ifdef __alpha
-       u_int   r_ttl;                  /* time to live */
-#else
-       u_long  r_ttl;                  /* time to live */
-#endif
-       int     r_size;                 /* size of data area */
-       char    *r_data;                /* pointer to data */
-};
-
-extern u_short _getshort();
-#ifdef __alpha
-extern u_int   _getlong();
-#else
-extern u_long  _getlong();
-#endif
-
-/*
- * Inline versions of get/put short/long.
- * Pointer is advanced; we assume that both arguments
- * are lvalues and will already be in registers.
- * cp MUST be u_char *.
- */
-#define GETSHORT(s, cp) { \
-       (s) = *(cp)++ << 8; \
-       (s) |= *(cp)++; \
-}
-
-#define GETLONG(l, cp) { \
-       (l) = *(cp)++ << 8; \
-       (l) |= *(cp)++; (l) <<= 8; \
-       (l) |= *(cp)++; (l) <<= 8; \
-       (l) |= *(cp)++; \
-}
-
-
-#define PUTSHORT(s, cp) { \
-       *(cp)++ = (s) >> 8; \
-       *(cp)++ = (s); \
-}
-
-/*
- * Warning: PUTLONG destroys its first argument.
- */
-#define PUTLONG(l, cp) { \
-       (cp)[3] = l; \
-       (cp)[2] = (l >>= 8); \
-       (cp)[1] = (l >>= 8); \
-       (cp)[0] = l >> 8; \
-       (cp) += sizeof(u_long); \
-}
-
-#endif
-
diff --git a/include/resolv.h b/include/resolv.h
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/include/resolv_legacy.h b/include/resolv_legacy.h
deleted file mode 100644 (file)
index 845d5e0..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 1983, 1987, 1989 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that: (1) source distributions retain this entire copyright
- * notice and comment, and (2) distributions including binaries display
- * the following acknowledgement:  ``This product includes software
- * developed by the University of California, Berkeley and its contributors''
- * in the documentation or other materials provided with the distribution
- * and in all advertising materials mentioning features or use of this
- * software. 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- *     @(#)resolv.h    5.10.1 (Berkeley) 6/1/90
- */
-
-#include <limits.h>
-#ifndef __GLIBC__
-
-/*
- * Resolver configuration file.
- * Normally not present, but may contain the address of the
- * inital name server(s) to query and the domain search list.
- */
-
-#ifndef        _PATH_RESCONF
-#define _PATH_RESCONF        "/etc/resolv.conf"
-#endif
-
-/*
- * Global defines and variables for resolver stub.
- */
-#define        MAXNS           3               /* max # name servers we'll track */
-#define        MAXDFLSRCH      3               /* # default domain levels to try */
-#define        MAXDNSRCH       6               /* max # domains in search path */
-#define        LOCALDOMAINPARTS 2              /* min levels in name that is "local" */
-#define MAXSERVICES    2               /* max # of services to search */
-
-#define        RES_TIMEOUT     5               /* min. seconds between retries */
-
-struct state {
-       int     retrans;                /* retransmition time interval */
-       int     retry;                  /* number of times to retransmit */
-       long    options;                /* option flags - see below. */
-       int     nscount;                /* number of name servers */
-       struct  sockaddr_in nsaddr_list[MAXNS]; /* address of name server */
-#define        nsaddr  nsaddr_list[0]          /* for backward compatibility */
-       unsigned short  id;                     /* current packet id */
-       char    defdname[MAXDNAME];     /* default domain */
-       char    *dnsrch[MAXDNSRCH+1];   /* components of domain to search */
-       unsigned short  order[MAXSERVICES+1];   /* search service order */
-};
-
-#define RES_SERVICE_NONE       0
-#define RES_SERVICE_BIND       1
-#define RES_SERVICE_LOCAL      2
-
-/*
- * Resolver options
- */
-#define RES_INIT       0x0001          /* address initialized */
-#define RES_DEBUG      0x0002          /* print debug messages */
-#define RES_AAONLY     0x0004          /* authoritative answers only */
-#define RES_USEVC      0x0008          /* use virtual circuit */
-#define RES_PRIMARY    0x0010          /* query primary server only */
-#define RES_IGNTC      0x0020          /* ignore trucation errors */
-#define RES_RECURSE    0x0040          /* recursion desired */
-#define RES_DEFNAMES   0x0080          /* use default domain name */
-#define RES_STAYOPEN   0x0100          /* Keep TCP socket open */
-#define RES_DNSRCH     0x0200          /* search up local domain tree */
-
-#define RES_DEFAULT    (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH)
-
-extern struct state _res;
-extern char *p_cdname(), *p_rr(), *p_type(), *p_class(), *p_time();
-
-#endif
-
index 8fa24f0a2c5fe18cd839db5c7c3b262fdc1fdddd..36bd035f19005f63d75d2de536e2d02146231a43 100644 (file)
@@ -164,8 +164,7 @@ res.o: res.c ../include/struct.h ../include/config.h \
  ../include/setup.h  ../include/common.h \
  ../include/sys.h ../include/class.h ../include/dbuf.h \
  ../include/whowas.h ../include/res.h ../include/numeric.h \
- ../include/h.h ../include/nameser.h ../include/resolv_legacy.h \
- ../include/inet.h
+ ../include/h.h ../include/inet.h
 masking.o: masking.c ../include/struct.h ../include/config.h \
  ../include/setup.h  ../include/common.h \
  ../include/sys.h ../include/class.h ../include/dbuf.h \
@@ -175,8 +174,8 @@ s_bsd.o: s_bsd.c ../include/struct.h ../include/config.h \
  ../include/setup.h  ../include/common.h \
  ../include/sys.h ../include/class.h ../include/dbuf.h \
  ../include/whowas.h ../include/res.h ../include/numeric.h \
- ../include/patchlevel.h ../include/inet.h ../include/nameser.h \
- ../include/resolv_legacy.h ../include/sock.h ../include/h.h
+ ../include/patchlevel.h ../include/inet.h \
+ ../include/sock.h ../include/h.h
 s_conf.o: s_conf.c ../include/struct.h ../include/config.h \
  ../include/setup.h  ../include/common.h \
  ../include/sys.h ../include/class.h ../include/dbuf.h \
index 5b6b67b838ae0130b04623142ec2379e0a8c6489..23f4fafb541adc4b15c3b22cf9e1084446d0b6d8 100644 (file)
--- a/src/res.c
+++ b/src/res.c
@@ -17,8 +17,8 @@
 #include <sys/socket.h>
 #include <limits.h>
 #include <resolv.h>
-#include "nameser.h"
-#include "resolv_legacy.h"
+#include <arpa/nameser.h>
+#include <arpa/nameser_compat.h>
 #include "inet.h"                /* inet_addr() */
 
 #undef DEBUG                     /* because there is a lot of debug code in here :-) */
@@ -287,8 +287,8 @@ void del_queries (cp)
 /*
  * sends msg to all nameservers found in the "_res" structure.
  * This should reflect /etc/resolv.conf. We will get responses
- * which arent needed but is easier than checking to see if nameserver
- * isnt present. Returns number of messages successfully sent to 
+ * which aren't needed but is easier than checking to see if nameserver
+ * isn't present. Returns number of messages successfully sent to
  * nameservers or -1 if no successful sends.
  */
 static int send_res_msg (msg, len, rcount)
diff --git a/src/res_comp.c b/src/res_comp.c
deleted file mode 100644 (file)
index a6266ec..0000000
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * Copyright (c) 1985 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted provided
- * that: (1) source distributions retain this entire copyright notice and
- * comment, and (2) distributions including binaries display the following
- * acknowledgement:  ``This product includes software developed by the
- * University of California, Berkeley and its contributors'' in the
- * documentation or other materials provided with the distribution and in
- * all advertising materials mentioning features or use of this software.
- * 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <sys/types.h>
-#include <stdio.h>
-#include "common.h"
-#include "sys.h"
-#include "nameser.h"
-
-static dn_find ();
-
-/*
- * Expand compressed domain name 'comp_dn' to full domain name.
- * 'msg' is a pointer to the begining of the message,
- * 'eomorig' points to the first location after the message,
- * 'exp_dn' is a pointer to a buffer of size 'length' for the result.
- * Return size of compressed name or -1 if there was an error.
- */
-dn_expand (msg, eomorig, comp_dn, exp_dn, length)
-     u_char *msg, *eomorig, *comp_dn, *exp_dn;
-     int length;
-{
-    register u_char *cp, *dn;
-    register int n, c;
-    u_char *eom;
-    int len = -1, checked = 0;
-
-    dn = exp_dn;
-    cp = comp_dn;
-    eom = exp_dn + length;
-    /*
-     * fetch next label in domain name
-     */
-    while (n = *cp++) {
-       /*
-        * Check for indirection
-        */
-       switch (n & INDIR_MASK) {
-       case 0:
-           if (dn != exp_dn) {
-               if (dn >= eom)
-                   return (-1);
-               *dn++ = '.';
-           }
-           if (dn + n >= eom)
-               return (-1);
-           checked += n + 1;
-           while (--n >= 0) {
-               if ((c = *cp++) == '.') {
-                   if (dn + n + 2 >= eom)
-                       return (-1);
-                   *dn++ = '\\';
-               }
-               *dn++ = c;
-               if (cp >= eomorig)      /* out of range */
-                   return (-1);
-           }
-           break;
-
-       case INDIR_MASK:
-           if (len < 0)
-               len = cp - comp_dn + 1;
-           cp = msg + (((n & 0x3f) << 8) | (*cp & 0xff));
-           if (cp < msg || cp >= eomorig)      /* out of range */
-               return (-1);
-           checked += 2;
-           /*
-            * Check for loops in the compressed name;
-            * if we've looked at the whole message,
-            * there must be a loop.
-            */
-           if (checked >= eomorig - msg)
-               return (-1);
-           break;
-
-       default:
-           return (-1);          /* flag error */
-       }
-    }
-    *dn = '\0';
-    if (len < 0)
-       len = cp - comp_dn;
-    return (len);
-}
-
-/*
- * Compress domain name 'exp_dn' into 'comp_dn'.
- * Return the size of the compressed name or -1.
- * 'length' is the size of the array pointed to by 'comp_dn'.
- * 'dnptrs' is a list of pointers to previous compressed names. dnptrs[0]
- * is a pointer to the beginning of the message. The list ends with NULL.
- * 'lastdnptr' is a pointer to the end of the arrary pointed to
- * by 'dnptrs'. Side effect is to update the list of pointers for
- * labels inserted into the message as we compress the name.
- * If 'dnptr' is NULL, we don't try to compress names. If 'lastdnptr'
- * is NULL, we don't update the list.
- */
-dn_comp (exp_dn, comp_dn, length, dnptrs, lastdnptr)
-     u_char *exp_dn, *comp_dn;
-     int length;
-     u_char **dnptrs, **lastdnptr;
-{
-    register u_char *cp, *dn;
-    register int c, l;
-    u_char **cpp, **lpp, *sp, *eob;
-    u_char *msg;
-
-    dn = exp_dn;
-    cp = comp_dn;
-    eob = cp + length;
-    if (dnptrs != NULL) {
-       if ((msg = *dnptrs++) != NULL) {
-           for (cpp = dnptrs; *cpp != NULL; cpp++);
-           lpp = cpp;            /* end of list to search */
-       }
-    }
-    else
-       msg = NULL;
-    for (c = *dn++; c != '\0';) {
-       /* look to see if we can use pointers */
-       if (msg != NULL) {
-           if ((l = dn_find (dn - 1, msg, dnptrs, lpp)) >= 0) {
-               if (cp + 1 >= eob)
-                   return (-1);
-               *cp++ = (l >> 8) | INDIR_MASK;
-               *cp++ = l % 256;
-               return (cp - comp_dn);
-           }
-           /* not found, save it */
-           if (lastdnptr != NULL && cpp < lastdnptr - 1) {
-               *cpp++ = cp;
-               *cpp = NULL;
-           }
-       }
-       sp = cp++;                /* save ptr to length byte */
-       do {
-           if (c == '.') {
-               c = *dn++;
-               break;
-           }
-           if (c == '\\') {
-               if ((c = *dn++) == '\0')
-                   break;
-           }
-           if (cp >= eob) {
-               if (msg != NULL)
-                   *lpp = NULL;
-               return (-1);
-           }
-           *cp++ = c;
-       }
-       while ((c = *dn++) != '\0');
-       /* catch trailing '.'s but not '..' */
-       if ((l = cp - sp - 1) == 0 && c == '\0') {
-           cp--;
-           break;
-       }
-       if (l <= 0 || l > MAXLABEL) {
-           if (msg != NULL)
-               *lpp = NULL;
-           return (-1);
-       }
-       *sp = l;
-    }
-    if (cp >= eob) {
-       if (msg != NULL)
-           *lpp = NULL;
-       return (-1);
-    }
-    *cp++ = '\0';
-    return (cp - comp_dn);
-}
-
-/*
- * Skip over a compressed domain name. Return the size or -1.
- */
-dn_skipname (comp_dn, eom)
-     u_char *comp_dn, *eom;
-{
-    register u_char *cp;
-    register int n;
-
-    cp = comp_dn;
-    while (cp < eom && (n = *cp++)) {
-       /*
-        * check for indirection
-        */
-       switch (n & INDIR_MASK) {
-       case 0:           /* normal case, n == len */
-           cp += n;
-           continue;
-       default:                  /* illegal type */
-           return (-1);
-       case INDIR_MASK:          /* indirection */
-           cp++;
-       }
-       break;
-    }
-    return (cp - comp_dn);
-}
-
-/*
- * Search for expanded name from a list of previously compressed names.
- * Return the offset from msg if found or -1.
- * dnptrs is the pointer to the first name on the list,
- * not the pointer to the start of the message.
- */
-static dn_find (exp_dn, msg, dnptrs, lastdnptr)
-     u_char *exp_dn, *msg;
-     u_char **dnptrs, **lastdnptr;
-{
-    register u_char *dn, *cp, **cpp;
-    register int n;
-    u_char *sp;
-
-    for (cpp = dnptrs; cpp < lastdnptr; cpp++) {
-       dn = exp_dn;
-       sp = cp = *cpp;
-       while (n = *cp++) {
-           /*
-            * check for indirection
-            */
-           switch (n & INDIR_MASK) {
-           case 0:               /* normal case, n == len */
-               while (--n >= 0) {
-                   if (*dn == '.')
-                       goto next;
-                   if (*dn == '\\')
-                       dn++;
-                   if (*dn++ != *cp++)
-                       goto next;
-               }
-               if ((n = *dn++) == '\0' && *cp == '\0')
-                   return (sp - msg);
-               if (n == '.')
-                   continue;
-               goto next;
-
-           default:              /* illegal type */
-               return (-1);
-
-           case INDIR_MASK:      /* indirection */
-               cp = msg + (((n & 0x3f) << 8) | *cp);
-           }
-       }
-       if (*dn == '\0')
-           return (sp - msg);
-      next:;
-    }
-    return (-1);
-}
-
-/*
- * Routines to insert/extract short/long's. Must account for byte
- * order and non-alignment problems. This code at least has the
- * advantage of being portable.
- *
- * used by sendmail.
- */
-
-u_short _getshort (msgp)
-     u_char *msgp;
-{
-    register u_char *p = (u_char *) msgp;
-#ifdef vax
-    /*
-     * vax compiler doesn't put shorts in registers
-     */
-    register u_long u;
-#else
-    register u_short u;
-#endif
-
-    u = *p++ << 8;
-    return ((u_short) (u | *p));
-}
-
-u_long _getlong (msgp)
-     u_char *msgp;
-{
-    register u_char *p = (u_char *) msgp;
-    register u_long u;
-
-    u = *p++;
-    u <<= 8;
-    u |= *p++;
-    u <<= 8;
-    u |= *p++;
-    u <<= 8;
-    return (u | *p);
-}
-
-
-putshort (s, msgp)
-     register u_short s;
-     register u_char *msgp;
-{
-
-    msgp[1] = s;
-    msgp[0] = s >> 8;
-}
-
-putlong (l, msgp)
-     register u_long l;
-     register u_char *msgp;
-{
-
-    msgp[3] = l;
-    msgp[2] = (l >>= 8);
-    msgp[1] = (l >>= 8);
-    msgp[0] = l >> 8;
-}
diff --git a/src/res_init.c b/src/res_init.c
deleted file mode 100644 (file)
index ca025df..0000000
+++ /dev/null
@@ -1,205 +0,0 @@
-
-/*-
- * Copyright (c) 1985, 1989 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted provided
- * that: (1) source distributions retain this entire copyright notice and
- * comment, and (2) distributions including binaries display the following
- * acknowledgement:  ``This product includes software developed by the
- * University of California, Berkeley and its contributors'' in the
- * documentation or other materials provided with the distribution and in
- * all advertising materials mentioning features or use of this software.
- * 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <stdio.h>
-#include <resolv.h>
-#include "config.h"              /* To get #define SOL20       Vesa */
-#include "sys.h"
-#include "common.h"
-#include "nameser.h"
-#include "resolv_legacy.h"
-
-/*
- * Resolver state default settings
- */
-
-struct state _res = {
-    RES_TIMEOUT,   /* retransmition time interval */
-    4,            /* number of times to retransmit */
-    RES_DEFAULT,   /* options flags */
-    1,            /* number of name servers */
-};
-
-/*
- * Set up default settings.  If the configuration file exist, the values
- * there will have precedence.  Otherwise, the server address is set to
- * INADDR_ANY and the default domain name comes from the gethostname().
- *
- * The configuration file should only be used if you want to redefine your
- * domain or run without a server on your machine.
- *
- * Return 0 if completes successfully, -1 on error
- */
-int res_init ()
-{
-    register FILE *fp;
-    register char *cp, *dp, **pp;
-    extern u_long inet_addr ();
-    register int n;
-    char buf[BUFSIZ];
-    extern char *getenv ();
-    int nserv = 0; /* number of nameserver records read from file */
-    int norder = 0;
-    int haveenv = 0;
-    int havesearch = 0;
-
-    _res.nsaddr.sin_addr.s_addr = INADDR_ANY;
-    _res.nsaddr.sin_family = AF_INET;
-    _res.nsaddr.sin_port = htons (NAMESERVER_PORT);
-    _res.nscount = 1;
-
-    /* Allow user to override the local domain definition */
-    if ((cp = getenv ("LOCALDOMAIN")) != NULL) {
-       (void) strncpy (_res.defdname, cp, sizeof (_res.defdname));
-       haveenv++;
-    }
-    if ((fp = fopen (_PATH_RESCONF, "r")) != NULL) {
-       /* read the config file */
-       while (fgets (buf, sizeof (buf), fp) != NULL) {
-           /* read default domain name */
-           if (!strncmp (buf, "domain", sizeof ("domain") - 1)) {
-               if (haveenv)      /* skip if have from environ */
-                   continue;
-               cp = buf + sizeof ("domain") - 1;
-               while (*cp == ' ' || *cp == '\t')
-                   cp++;
-               if ((*cp == '\0') || (*cp == '\n'))
-                   continue;
-               (void) strncpy (_res.defdname, cp,
-                               sizeof (_res.defdname) - 1);
-               if ((cp = index (_res.defdname, '\n')) != NULL)
-                   *cp = '\0';
-               havesearch = 0;
-               continue;
-           }
-           /* set search list */
-           if (!strncmp (buf, "search", sizeof ("search") - 1)) {
-               if (haveenv)      /* skip if have from environ */
-                   continue;
-               cp = buf + sizeof ("search") - 1;
-               while (*cp == ' ' || *cp == '\t')
-                   cp++;
-               if ((*cp == '\0') || (*cp == '\n'))
-                   continue;
-               (void) strncpy (_res.defdname, cp,
-                               sizeof (_res.defdname) - 1);
-               if ((cp = index (_res.defdname, '\n')) != NULL)
-                   *cp = '\0';
-               /*
-                * Set search list to be blank-separated strings
-                * on rest of line.
-                */
-               cp = _res.defdname;
-               pp = _res.dnsrch;
-               *pp++ = cp;
-               for (n = 0; *cp && pp < _res.dnsrch + MAXDNSRCH; cp++) {
-                   if (*cp == ' ' || *cp == '\t') {
-                       *cp = 0;
-                       n = 1;
-                   }
-                   else if (n) {
-                       *pp++ = cp;
-                       n = 0;
-                   }
-               }
-               /* null terminate last domain if there are excess */
-               while (*cp != '\0' && *cp != ' ' && *cp != '\t')
-                   cp++;
-               *cp = '\0';
-               *pp++ = 0;
-               havesearch = 1;
-               continue;
-           }
-           /* read nameservers to query */
-           if (!strncmp (buf, "nameserver", sizeof ("nameserver") - 1) &&
-               nserv < MAXNS) {
-               cp = buf + sizeof ("nameserver") - 1;
-               while (*cp == ' ' || *cp == '\t')
-                   cp++;
-               if ((*cp == '\0') || (*cp == '\n'))
-                   continue;
-               if ((_res.nsaddr_list[nserv].sin_addr.s_addr =
-                    inet_addr (cp)) == (unsigned) -1) {
-                   _res.nsaddr_list[nserv].sin_addr.s_addr = INADDR_ANY;
-                   continue;
-               }
-               _res.nsaddr_list[nserv].sin_family = AF_INET;
-               _res.nsaddr_list[nserv].sin_port = htons (NAMESERVER_PORT);
-               nserv++;
-               continue;
-           }
-           /* read service order */
-           if (!strncmp (buf, "order", sizeof ("order") - 1)) {
-               cp = buf + sizeof ("order") - 1;
-               while (*cp == ' ' || *cp == '\t')
-                   cp++;
-               if ((*cp == '\0') || (*cp == '\n'))
-                   continue;
-               norder = 0;
-               do {
-                   if ((dp = index (cp, ',')) != NULL)
-                       *dp = '\0';
-                   if (norder >= MAXSERVICES)
-                       continue;
-                   if (!strncmp (cp, "bind", sizeof ("bind") - 1))
-                       _res.order[norder++] = RES_SERVICE_BIND;
-                   else if (!strncmp (cp, "local", sizeof ("local") - 1))
-                       _res.order[norder++] = RES_SERVICE_LOCAL;
-                   cp = dp + 1;
-               }
-               while (dp != NULL);
-               _res.order[norder] = RES_SERVICE_NONE;
-               continue;
-           }
-       }
-       if (nserv > 1)
-           _res.nscount = nserv;
-       (void) fclose (fp);
-    }
-    if (_res.defdname[0] == 0) {
-       if (gethostname (buf, sizeof (_res.defdname)) == 0 &&
-           (cp = index (buf, '.')))
-           (void) strcpy (_res.defdname, cp + 1);
-    }
-    /* find components of local domain that might be searched */
-    if (havesearch == 0) {
-       pp = _res.dnsrch;
-       *pp++ = _res.defdname;
-       for (cp = _res.defdname, n = 0; *cp; cp++)
-           if (*cp == '.')
-               n++;
-       cp = _res.defdname;
-       for (; n >= LOCALDOMAINPARTS && pp < _res.dnsrch + MAXDFLSRCH; n--) {
-           cp = index (cp, '.');
-           *pp++ = ++cp;
-       }
-       *pp++ = 0;
-    }
-    /* default search order to bind only */
-    if (norder == 0) {
-       _res.order[0] = RES_SERVICE_BIND;
-       _res.order[1] = RES_SERVICE_NONE;
-    }
-    _res.options |= RES_INIT;
-    return (0);
-}
diff --git a/src/res_mkquery.c b/src/res_mkquery.c
deleted file mode 100644 (file)
index c9c03e4..0000000
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright (c) 1985 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that: (1) source distributions retain this entire copyright
- * notice and comment, and (2) distributions including binaries display
- * the following acknowledgement:  ``This product includes software
- * developed by the University of California, Berkeley and its contributors''
- * in the documentation or other materials provided with the distribution
- * and in all advertising materials mentioning features or use of this
- * software. 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include "config.h"
-#include "sys.h"
-#include "nameser.h"
-#include "resolv_legacy.h"
-
-/*
- * Form all types of queries.
- * Returns the size of the result or -1.
- */
-res_mkquery (op, dname, class, type, data, datalen, newrr, buf, buflen)
-     int op;      /* opcode of query */
-     char *dname;  /* domain name */
-     int class, type;  /* class and type of query */
-     char *data;   /* resource record data */
-     int datalen;  /* length of data */
-     struct rrec *newrr;       /* new rr for modify or append */
-     char *buf;           /* buffer to put query */
-     int buflen;   /* size of buffer */
-{
-    register HEADER *hp;
-    register char *cp;
-    register int n;
-    char *dnptrs[10], **dpp, **lastdnptr;
-
-#ifdef DEBUG
-    if (_res.options & RES_DEBUG)
-       printf ("res_mkquery(%d, %s, %d, %d)\n", op, dname, class, type);
-#endif /*DEBUG */
-    /*
-     * Initialize header fields.
-     */
-    if ((buf == NULL) || (buflen < sizeof (HEADER)))
-       return (-1);
-    bzero (buf, sizeof (HEADER));
-    hp = (HEADER *) buf;
-    hp->id = htons (++_res.id);
-    hp->opcode = op;
-    hp->pr = (_res.options & RES_PRIMARY) != 0;
-    hp->rd = (_res.options & RES_RECURSE) != 0;
-    hp->rcode = NOERROR;
-    cp = buf + sizeof (HEADER);
-    buflen -= sizeof (HEADER);
-    dpp = dnptrs;
-    *dpp++ = buf;
-    *dpp++ = NULL;
-    lastdnptr = dnptrs + sizeof (dnptrs) / sizeof (dnptrs[0]);
-    /*
-     * perform opcode specific processing
-     */
-    switch (op) {
-    case QUERY:
-       if ((buflen -= QFIXEDSZ) < 0)
-           return (-1);
-       if ((n = dn_comp (dname, cp, buflen, dnptrs, lastdnptr)) < 0)
-           return (-1);
-       cp += n;
-       buflen -= n;
-       putshort (type, cp);
-       cp += sizeof (u_short);
-       putshort (class, cp);
-       cp += sizeof (u_short);
-       hp->qdcount = htons (1);
-       if (op == QUERY || data == NULL)
-           break;
-       /*
-        * Make an additional record for completion domain.
-        */
-       buflen -= RRFIXEDSZ;
-       if ((n = dn_comp (data, cp, buflen, dnptrs, lastdnptr)) < 0)
-           return (-1);
-       cp += n;
-       buflen -= n;
-       putshort (T_NULL, cp);
-       cp += sizeof (u_short);
-       putshort (class, cp);
-       cp += sizeof (u_short);
-       putlong (0, cp);
-       cp += sizeof (u_long);
-       putshort (0, cp);
-       cp += sizeof (u_short);
-       hp->arcount = htons (1);
-       break;
-
-    case IQUERY:
-       /*
-        * Initialize answer section
-        */
-       if (buflen < 1 + RRFIXEDSZ + datalen)
-           return (-1);
-       *cp++ = '\0';             /* no domain name */
-       putshort (type, cp);
-       cp += sizeof (u_short);
-       putshort (class, cp);
-       cp += sizeof (u_short);
-       putlong (0, cp);
-       cp += sizeof (u_long);
-       putshort (datalen, cp);
-       cp += sizeof (u_short);
-       if (datalen) {
-           bcopy (data, cp, datalen);
-           cp += datalen;
-       }
-       hp->ancount = htons (1);
-       break;
-
-#ifdef ALLOW_UPDATES
-       /*
-        * For UPDATEM/UPDATEMA, do UPDATED/UPDATEDA followed by UPDATEA
-        * (Record to be modified is followed by its replacement in msg.)
-        */
-    case UPDATEM:
-    case UPDATEMA:
-
-    case UPDATED:
-       /*
-        * The res code for UPDATED and UPDATEDA is the same; user
-        * calls them differently: specifies data for UPDATED; server
-        * ignores data if specified for UPDATEDA.
-        */
-    case UPDATEDA:
-       buflen -= RRFIXEDSZ + datalen;
-       if ((n = dn_comp (dname, cp, buflen, dnptrs, lastdnptr)) < 0)
-           return (-1);
-       cp += n;
-       putshort (type, cp);
-       cp += sizeof (u_short);
-       putshort (class, cp);
-       cp += sizeof (u_short);
-       putlong (0, cp);
-       cp += sizeof (u_long);
-       putshort (datalen, cp);
-       cp += sizeof (u_short);
-       if (datalen) {
-           bcopy (data, cp, datalen);
-           cp += datalen;
-       }
-       if ((op == UPDATED) || (op == UPDATEDA)) {
-           hp->ancount = htons (0);
-           break;
-       }
-       /* Else UPDATEM/UPDATEMA, so drop into code for UPDATEA */
-
-    case UPDATEA:                /* Add new resource record */
-       buflen -= RRFIXEDSZ + datalen;
-       if ((n = dn_comp (dname, cp, buflen, dnptrs, lastdnptr)) < 0)
-           return (-1);
-       cp += n;
-       putshort (newrr->r_type, cp);
-       cp += sizeof (u_short);
-       putshort (newrr->r_class, cp);
-       cp += sizeof (u_short);
-       putlong (0, cp);
-       cp += sizeof (u_long);
-       putshort (newrr->r_size, cp);
-       cp += sizeof (u_short);
-       if (newrr->r_size) {
-           bcopy (newrr->r_data, cp, newrr->r_size);
-           cp += newrr->r_size;
-       }
-       hp->ancount = htons (0);
-       break;
-
-#endif /* ALLOW_UPDATES */
-    }
-    return (cp - buf);
-}
diff --git a/src/res_skipname.c b/src/res_skipname.c
deleted file mode 100644 (file)
index dc63c3a..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-
-#include <sys/types.h>
-#include <stdio.h>
-#include "nameser.h"
-
-/*
- * Skip over a compressed domain name. Return the size or -1.
- */
-dn_skipname (comp_dn, eom)
-     u_char *comp_dn, *eom;
-{
-    register u_char *cp;
-    register int n;
-
-    cp = comp_dn;
-    while (cp < eom && (n = *cp++)) {
-       /*
-        * check for indirection
-        */
-       switch (n & INDIR_MASK) {
-       case 0:           /* normal case, n == len */
-           cp += n;
-           continue;
-       default:                  /* illegal type */
-           return (-1);
-       case INDIR_MASK:          /* indirection */
-           cp++;
-       }
-       break;
-    }
-    return (cp - comp_dn);
-}
index f0b43f540ba7f9f0958ef2f91f107a9453cdb014..909db82a0f9fb02b5208c1540d659d0f2e4798e9 100644 (file)
@@ -36,8 +36,8 @@
 #include <stdio.h>
 #include <signal.h>
 #include <fcntl.h>
-#include "nameser.h"
-#include "resolv_legacy.h"
+//#include "nameser.h"
+#include <resolv.h>
 #include "sock.h"                /* If FD_ZERO isn't define up to this point,  */
                        /* define it (BSD4.2 needs this) */
 #include "h.h"