Fix compilation on modern Linux platforms.
authorDaniel Drake <dan@reactivated.net>
Sat, 1 May 2010 08:17:09 +0000 (10:17 +0200)
committerRemco Rijnders <remmy@winter.webconquest.com>
Sat, 1 May 2010 08:17:09 +0000 (10:17 +0200)
Other operating systems should function as before, but Linux platforms
running glibc-2.1 or older will probably fail.
(we're talking glibc releases more than 10 years old)

Also fix a 64 bit typing error in the DNS resolution code.

Config
Makefile.dist
include/nameser.h
include/resolv.h
include/resolv_legacy.h [new file with mode: 0644]
src/Makefile
src/res.c
src/res_init.c
src/res_mkquery.c
src/s_bsd.c

diff --git a/Config b/Config
index 45d1f519825f76cdf6f4fc76a1de514f7a937984..69399c4ebb7e2a9454f7f9ade0b1513be8c3ddea 100755 (executable)
--- a/Config
+++ b/Config
@@ -738,11 +738,6 @@ if [ $? -ne 0 -o "$OSNAME" = "Linux RedHat 5.0" -o -n "$NEEDSKIPNAME" -o "$GLIBC
     sed -e "s@^RES=\(.*\)@RES=res_skipname.o@" Makefile > Makefile.tmp
     cp Makefile.tmp Makefile
     $RM -f Makefile.tmp
-else
-    $RM -f Makefile.tmp
-    sed -e "s@^RES=\(.*\)@RES=res_init.o@" Makefile > Makefile.tmp
-    cp Makefile.tmp Makefile
-    $RM -f Makefile.tmp
 fi
 $RM -f $EXEC $TMP
 cat > $TMP <<__EOF__
index 7a27634033f564f78e8ce0fde733cedf6c0e81fa..32c9656ebf9ba7cc449b2efb941bf3fa8aa1fe6d 100755 (executable)
@@ -91,10 +91,8 @@ IRCDDIR=/usr/local/lib/ircd
 #RES=res_init.o res_comp.o res_mkquery.o
 # BSDI systems want this.
 #RES=res_skipname.o
-# Recent Linux systems seem to expect this:
-RES=res_init.o
 # The rest are perfectly content with this.
-#RES=
+RES=
 
 # [CHANGEME]
 # If you get a compile-time error dealing with u_int32_t, comment out
index 9e06b9738e6e7703a911f4b73c9dfde61782395b..280828e2d4e5633a59b24742db0e350923574caa 100644 (file)
@@ -19,6 +19,9 @@
  *     @(#)nameser.h   5.24 (Berkeley) 6/1/90
  */
 
+#include <limits.h>
+#ifndef __GLIBC__
+
 /*
  * Define constants based on rfc883
  */
@@ -246,3 +249,6 @@ extern      u_long  _getlong();
        (cp)[0] = l >> 8; \
        (cp) += sizeof(u_long); \
 }
+
+#endif
+
index d9feb760c0cd4c3b6ec697c024e5c1b4053562f0..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,78 +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
- */
-
-/*
- * 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();
-
diff --git a/include/resolv_legacy.h b/include/resolv_legacy.h
new file mode 100644 (file)
index 0000000..845d5e0
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * 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 5dcd0f016997ccf34340599ed7a3ab3d3dd6a751..8fa24f0a2c5fe18cd839db5c7c3b262fdc1fdddd 100644 (file)
@@ -164,7 +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.h \
+ ../include/h.h ../include/nameser.h ../include/resolv_legacy.h \
  ../include/inet.h
 masking.o: masking.c ../include/struct.h ../include/config.h \
  ../include/setup.h  ../include/common.h \
@@ -176,7 +176,7 @@ s_bsd.o: s_bsd.c ../include/struct.h ../include/config.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.h ../include/sock.h ../include/h.h
+ ../include/resolv_legacy.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 dbfd0eb14549e42f3288f06856ea5d19d2a1add7..5b6b67b838ae0130b04623142ec2379e0a8c6489 100644 (file)
--- a/src/res.c
+++ b/src/res.c
 #include <signal.h>
 #include <sys/time.h>
 #include <sys/socket.h>
+#include <limits.h>
+#include <resolv.h>
 #include "nameser.h"
-#include "resolv.h"
+#include "resolv_legacy.h"
 #include "inet.h"                /* inet_addr() */
 
 #undef DEBUG                     /* because there is a lot of debug code in here :-) */
 
+#ifndef __GLIBC__
 extern int dn_expand PROTO ((char *, char *, char *, char *, int));
 extern int dn_skipname PROTO ((char *, char *));
 extern int res_mkquery PROTO ((int, char *, int, int, char *, int,
                               struct rrec *, char *, int));
+#endif
 
 extern int errno, h_errno;
 extern int highest_fd;
@@ -528,7 +532,7 @@ static int proc_answer (rptr, hptr, buf, eob)
        class = (int) _getshort (cp);
        cp += sizeof (short);
        rptr->ttl = _getlong (cp);
-       cp += sizeof (rptr->ttl);
+       cp += 4;
        dlen = (int) _getshort (cp);
        cp += sizeof (short);
        rptr->type = type;
index eb3133578c32db835a573d24b73f509cbb971a46..ca025dfeb1e8a865717ed98b6873ff16633dd2be 100644 (file)
 #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.h"
+#include "resolv_legacy.h"
 
 /*
  * Resolver state default settings
index c342fdcb52f354381a0c30ec311703e77ab0e3ef..c9c03e4922e8a2f49b44b3091033f18f51b7416a 100644 (file)
@@ -23,7 +23,7 @@
 #include "config.h"
 #include "sys.h"
 #include "nameser.h"
-#include "resolv.h"
+#include "resolv_legacy.h"
 
 /*
  * Form all types of queries.
index 7079253d782238090bae95b1fe54d9e017df4ddb..4dc016104fa1a6a6e749035c708cf9d6a8dbf106 100644 (file)
@@ -45,7 +45,7 @@
 #else
 #include "nameser.h"
 #endif
-#include "resolv.h"
+#include "resolv_legacy.h"
 #include "sock.h"                /* If FD_ZERO isn't define up to this point,  */
                        /* define it (BSD4.2 needs this) */
 #include "h.h"