home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-386-Vol-2of3.iso / b / bind481.zip / BIND481.DIF next >
Text File  |  1993-01-19  |  25KB  |  983 lines

  1. These are my patches to Berkeley bind version 4.8.1.
  2. Unshar, then apply all the patch files in the order implied by their
  3. names.
  4.  
  5. USE AT YOUR OWN RISK.
  6.  
  7. --apb
  8. Alan Barrett, Dept. of Electronic Eng., Univ. of Natal, Durban, South Africa
  9. RFC822: barrett@ee.und.ac.za             Bang: m2xenix!quagga!undeed!barrett
  10.  
  11. ------
  12. # This is a shell archive.  Remove anything before this line,
  13. # then unpack it by saving it in a file and typing "sh file".
  14. #
  15. # Wrapped by Alan P Barrett <barrett@undeed> on Sun Aug 11 18:28:03 1991
  16. #
  17. # This archive contains:
  18. #    apb-901127    apb-910129    apb-910130    
  19. #
  20.  
  21. LANG=""; export LANG
  22. PATH=/bin:/usr/bin:$PATH; export PATH
  23.  
  24. echo x - apb-901127
  25. sed 's/^@//' >apb-901127 <<'@EOF'
  26. Index: Makefile
  27. *** old/Makefile    Wed Dec  5 09:41:53 1990
  28. --- apb-901127/Makefile    Wed Dec  5 09:41:58 1990
  29. @@@ -16,23 +16,48 @@
  30.  #
  31.  #    @(#)Makefile    4.19 (Berkeley) 2/8/89
  32.  #
  33. -DEFINES= -DDEBUG -DSTATS
  34. +
  35. +# Put some of the following symbols into SYSDEFINES.  (The SYSV symbol
  36. +# used to control all this.)
  37. +#
  38. +#  HAVE_GETDTABLESIZE    # getdtablesize() is available (BSD)
  39. +#  HAVE_SIGVEC        # sigvec() and other BSD signal stuff is available (BSD)
  40. +#  HAVE_SETLINEBUF    # setlinebuf() is available (BSD)
  41. +#  HAVE_UTIMES        # utimes() is available (BSD)
  42. +#  HAVE_MKSTEMP        # mkstemp() is available (BSD)
  43. +#  HAVE_STRCASECMP    # strcasecmp() and strncasecmp() are available (BSD)
  44. +#  HAVE_WAIT3        # wait3() is available (BSD)
  45. +#  NEED_FCNTL_H        # fcntl.h must be included (SYSV)
  46. +#  NEED_UNISTD_H    # unistd.h must be included (SYSV)
  47. +#
  48. +# pure BSD
  49. +#SYSDEFINES=    -DHAVE_GETDTABLESIZE -DHAVE_SIGVEC -DHAVE_SETLINEBUF \
  50. +#        -DHAVE_UTIMES -DHAVE_MKSTEMP -DHAVE_STRCASECMP -DHAVE_WAIT3
  51. +# pure SYSV
  52. +#SYSDEFINES=    -DNEED_FCNTL_H -DNEED_UNISTD_H
  53. +#
  54. +# HP-UX 7.0
  55. +SYSDEFINES=    -DHAVE_SIGVEC -DHAVE_WAIT3 -DNEED_FCNTL_H -DNEED_UNISTD_H
  56. +
  57. +DEFINES= ${SYSDEFINES} -DDEBUG -DSTATS
  58.  ### -DALLOW_T_UNSPEC -Dmalloc=rt_malloc -Dfree=rt_free
  59.  ### ALLOC=storage.o
  60. -CFLAGS=    -O ${DEFINES}
  61. +DEBUG=    -g
  62. +OPTIMISE= # -O
  63. +CFLAGS=    ${OPTIMISE} ${DEBUG} ${DEFINES}
  64.  
  65.  RES=
  66. -LIBS=    ${RES}
  67. +LIBS=    -lBSD ${RES} 
  68.  LIBC=    /lib/libc.a
  69.  
  70.  SRCS=    db_dump.c db_load.c db_lookup.c db_reload.c db_save.c db_update.c \
  71.      ns_forw.c ns_init.c ns_main.c ns_maint.c ns_req.c ns_resp.c \
  72. -    ns_sort.c ns_stats.c db_glue.c xfer.c
  73. +    ns_sort.c ns_stats.c db_glue.c xfer.c misc.c
  74.  HDRS=    db.h ns.h
  75.  OBJS=    db_dump.o db_load.o db_lookup.o db_reload.o db_save.o db_update.o \
  76.      ns_forw.o ns_init.o ns_main.o ns_maint.o ns_req.o ns_resp.o \
  77. -    ns_sort.o ns_stats.o db_glue.o $(ALLOC)
  78. -XFEROBJ=   xfer.o db_glue.o
  79. +    ns_sort.o ns_stats.o db_glue.o misc.o $(ALLOC)
  80. +XFEROBJ=   xfer.o db_glue.o misc.o
  81.  
  82.  SUBDIR=    tools
  83.  MAN=    named.0
  84. @@@ -43,10 +68,10 @@
  85.  
  86.  named: ${OBJS} ${LIBC}
  87.      sh newvers.sh
  88. -    ${CC} -o $@ version.c ${OBJS} ${LIBS}
  89. +    ${CC} ${DEBUG} -o $@ version.c ${OBJS} ${LIBS}
  90.  
  91.  xfer:    ${XFEROBJ} ${LIBC}
  92. -    ${CC} -o $@ ${XFEROBJ} ${LIBS}
  93. +    ${CC} ${DEBUG} -o $@ ${XFEROBJ} ${LIBS}
  94.  
  95.  clean:
  96.      rm -f ${OBJS} ${XFEROBJ} core named xfer version.o version.c
  97.  
  98. Index: db_load.c
  99. *** old/db_load.c    Wed Dec  5 09:41:56 1990
  100. --- apb-901127/db_load.c    Wed Dec  5 09:42:03 1990
  101. @@@ -98,9 +98,10 @@
  102.   * Load the database from 'filename'. Origin is appended to all domain
  103.   * names in the file.
  104.   */
  105. -db_load(filename, in_origin, zp)
  106. +db_load(filename, in_origin, zp, including)
  107.      char *filename, *in_origin;
  108.      struct zoneinfo *zp;
  109. +    int including;
  110.  {
  111.      register u_char *cp;
  112.      register struct map *mp;
  113. @@@ -115,14 +116,15 @@
  114.          int read_soa = 0;    /* number of soa's read */
  115.      struct databuf *dp;
  116.      FILE *fp;
  117. -    int slineno, i, errs = 0, didinclude = 0;
  118. +    int slineno, i, errs = 0;
  119.      register u_long n;
  120.      struct stat sb;
  121.  
  122.  #ifdef DEBUG
  123.      if (debug)
  124. -        fprintf(ddt,"db_load(%s, %s, %d)\n",
  125. -            filename, in_origin, zp - zones);
  126. +        fprintf(ddt,"db_load(%s, %s, %d)%s\n",
  127. +            filename, in_origin, zp - zones,
  128. +            (including ? " include" : ""));
  129.  #endif
  130.  
  131.      (void) strcpy(origin, in_origin);
  132. @@@ -151,7 +153,9 @@
  133.      lineno = 1;
  134.      domain[0] = '\0';
  135.      class = C_IN;
  136. -    zp->z_state &= ~Z_INCLUDE;
  137. +    if (!including) {
  138. +        zp->z_state &= ~Z_INCLUDE;
  139. +    }
  140.      while ((c = gettoken(fp)) != EOF) {
  141.          switch (c) {
  142.          case INCLUDE:
  143. @@@ -163,9 +167,8 @@
  144.                  makename(tmporigin, origin);
  145.                  endline(fp);
  146.              }
  147. -            didinclude = 1;
  148.                          zp->z_state |= Z_INCLUDE;
  149. -            errs += db_load(buf, tmporigin, zp);
  150. +            errs += db_load(buf, tmporigin, zp, 1);
  151.              continue;
  152.  
  153.          case ORIGIN:
  154. @@@ -485,18 +488,22 @@
  155.              lineno++;
  156.      }
  157.      (void) fclose(fp);
  158. -    if (didinclude)
  159. +    if (zp->z_state & Z_INCLUDE)
  160.          zp->z_ftime = 0;
  161.      else
  162.          zp->z_ftime = sb.st_mtime;
  163.      zp->z_lastupdate = sb.st_mtime;
  164.      lineno = slineno;
  165. -        if (zp->z_type != Z_CACHE && read_soa != 1) {
  166. +        if (zp->z_type != Z_CACHE && !including && read_soa != 1) {
  167.          errs++;
  168.          if (read_soa == 0)
  169.              syslog(LOG_ERR, "%s: no SOA record", filename);
  170.          else
  171.              syslog(LOG_ERR, "%s: multiple SOA records", filename);
  172. +    }
  173. +        else if (zp->z_type != Z_CACHE && including && read_soa != 0) {
  174. +        errs++;
  175. +        syslog(LOG_ERR, "%s: SOA found in include file", filename);
  176.      }
  177.      return (errs);
  178.  }
  179.  
  180. ##### old/misc.c does not exist.
  181. Index: misc.c
  182. *** /dev/null    Wed Dec  5 09:43:06 1990
  183. --- apb-901127/misc.c    Wed Dec  5 09:42:13 1990
  184. @@@ -1,0 +1,51 @@
  185. +/* assorted stuff presumably found in BSD libraries?  --apb */
  186. +
  187. +#if defined(NEED_FCNTL_H)
  188. +#include <fcntl.h>
  189. +#endif
  190. +
  191. +#if !defined(HAVE_MKSTEMP)
  192. +int
  193. +mkstemp (template)
  194. +    char *template;
  195. +{
  196. +    extern char *mktemp();
  197. +    char *name = mktemp (template);
  198. +
  199. +    /* return 0 if failed to make name.
  200. +       This is silly, becase 0 is also a valid fd, but that is what
  201. +       xfer.c tests for. */
  202. +
  203. +    if (*name == '\0') return 0;
  204. +    return open (name, O_RDWR|O_CREAT, 0644);
  205. +}
  206. +#endif
  207. +
  208. +#if !(definedHAVE_STRCASECMP)
  209. +int
  210. +strcasecmp (s1, s2)
  211. +    char *s1, *s2;
  212. +{
  213. +    while (*s1 != '\0' && *s2 != '\0' && tolower(*s1) == tolower(*s2)) {
  214. +    s1++;
  215. +    s2++;
  216. +    }
  217. +    return (tolower(*s2) - tolower(*s1));
  218. +}
  219. +
  220. +int
  221. +strncasecmp (s1, s2, n)
  222. +    char *s1, *s2;
  223. +    int n;
  224. +{
  225. +    while (n > 0 &&
  226. +        *s1 != '\0' && *s2 != '\0' && tolower(*s1) == tolower(*s2))
  227. +    {
  228. +    n--;
  229. +    s1++;
  230. +    s2++;
  231. +    }
  232. +    if (n == 0) return 0;
  233. +    else return (tolower(*s2) - tolower(*s1));
  234. +}
  235. +#endif
  236.  
  237. Index: ns_init.c
  238. *** old/ns_init.c    Wed Dec  5 09:42:05 1990
  239. --- apb-901127/ns_init.c    Wed Dec  5 09:42:10 1990
  240. @@@ -239,7 +239,7 @@
  241.              if (debug)
  242.                  fprintf(ddt, "reloading zone\n");
  243.  #endif
  244. -            (void) db_load(zp->z_source, zp->z_origin, zp);
  245. +            (void) db_load(zp->z_source, zp->z_origin, zp, 0);
  246.              break;
  247.  
  248.          case Z_PRIMARY:
  249. @@@ -274,7 +274,7 @@
  250.              if (debug)
  251.                  fprintf(ddt, "reloading zone\n");
  252.  #endif
  253. -            if (db_load(zp->z_source, zp->z_origin, zp) == 0)
  254. +            if (db_load(zp->z_source, zp->z_origin, zp, 0) == 0)
  255.                  zp->z_auth = 1;
  256.  #ifdef ALLOW_UPDATES
  257.              /* Guarantee calls to ns_maint() */
  258. @@@ -416,7 +416,7 @@
  259.       * immediately.
  260.       */
  261.      if (zp->z_source == NULL ||
  262. -        db_load(zp->z_source, zp->z_origin, zp) != 0) {
  263. +        db_load(zp->z_source, zp->z_origin, zp, 0) != 0) {
  264.          /*
  265.           * Set zone to be refreshed immediately.
  266.           */
  267.  
  268. Index: ns_main.c
  269. *** old/ns_main.c    Wed Dec  5 09:42:06 1990
  270. --- apb-901127/ns_main.c    Wed Dec  5 09:42:10 1990
  271. @@@ -30,12 +30,14 @@
  272.  */
  273.  
  274.  #include <sys/param.h>
  275. -#if defined(SYSV)
  276. +/* #if defined(SYSV) */
  277. +#if defined(NEED_FCNTL_H)
  278.  #include <fcntl.h>
  279.  #endif SYSV
  280.  #include <sys/file.h>
  281.  #include <sys/time.h>
  282. -#if !defined(SYSV)
  283. +/* #if !defined(SYSV) */
  284. +#if defined(HAVE_WAIT3)
  285.  #include <sys/wait.h>
  286.  #endif !SYSV
  287.  #include <sys/resource.h>
  288. @@@ -132,7 +134,8 @@
  289.  
  290.  extern int errno;
  291.  
  292. -#if defined(SYSV)
  293. +/* #if defined(SYSV) */
  294. +#if !defined(HAVE_GETDTABLESIZE)
  295.  getdtablesize()
  296.  {
  297.      return(FD_SETSIZE);
  298. @@@ -153,7 +156,8 @@
  299.      u_long lasttime, maxctime;
  300.      u_long nnn, nm;
  301.      char buf[BUFSIZ];
  302. -#ifndef SYSV
  303. +/* #ifndef SYSV */
  304. +#ifdef HAVE_SIGVEC
  305.      struct sigvec vec;
  306.  #endif
  307.  
  308. @@@ -271,7 +275,8 @@
  309.      resettime = boottime;
  310.  
  311.      (void) signal(SIGHUP, onhup);
  312. -#if defined(SYSV)
  313. +/* #ifndef SYSV */
  314. +#if defined(HAVE_SIGVEC)
  315.      (void) signal(SIGCLD, endxfer);
  316.      (void) signal(SIGALRM, maint_alarm);
  317.  #else
  318. @@@ -283,7 +288,7 @@
  319.      vec.sv_handler = endxfer;
  320.      vec.sv_mask = sigmask(SIGALRM);
  321.      (void) sigvec(SIGCHLD, &vec, (struct sigvec *)NULL);
  322. -#endif SYSV
  323. +#endif HAVE_SIGVEC
  324.      (void) signal(SIGPIPE, SIG_IGN);
  325.      (void) signal(SIGSYS, sigprof);
  326.      (void) signal(SIGINT, setdumpflg);
  327. @@@ -537,7 +542,11 @@
  328.          (void)setsockopt(dqp->dq_dfd, SOL_SOCKET, SO_RCVBUF,
  329.              (char *)&rbufsize, sizeof(rbufsize));
  330.  #endif SO_RCVBUF
  331. +#ifdef O_NONBLOCK
  332. +        (void) fcntl(dqp->dq_dfd, F_SETFL, O_NONBLOCK);
  333. +#else
  334.          (void) fcntl(dqp->dq_dfd, F_SETFL, FNDELAY);
  335. +#endif
  336.  /*
  337.   *   NOTE: Some versions of SunOS have problems with the following
  338.   *   call to bind.  Bind still seems to function on these systems
  339. @@@ -573,7 +582,8 @@
  340.              (void) close(n);
  341.          n = open("/dev/tty", O_RDWR);
  342.          if (n > 0) {
  343. -#ifndef SYSV
  344. +/* #ifndef SYSV */
  345. +#ifdef TIOCNOTTY
  346.              (void) ioctl(n, TIOCNOTTY, (char *)NULL);
  347.  #else
  348.              setpgrp();
  349. @@@ -659,7 +669,7 @@
  350.          if (retryqp != NULL) {
  351.              gettime(&tt);
  352.              t.tv_sec = (long) retryqp->q_time - tt.tv_sec;
  353. -            if (t.tv_sec <= 0) {
  354. +            if ((int) t.tv_sec <= 0) {
  355.                  retry(retryqp);
  356.                  continue;
  357.              }
  358. @@@ -689,11 +699,15 @@
  359.                  if ((n = recvfrom(dqp->dq_dfd, buf, sizeof(buf), 0,
  360.                  (struct sockaddr *)&from_addr, &from_len)) < 0)
  361.                  {
  362. -                if ((n == -1) && (errno == EWOULDBLOCK))
  363. +                if ((n == -1) &&
  364. +                    (errno == EWOULDBLOCK || errno == EAGAIN))
  365.                      break;
  366.                  syslog(LOG_WARNING, "recvfrom: %m");
  367.                  break;
  368.                  }
  369. +                if (n == 0) {
  370. +                break;
  371. +                }
  372.  #ifdef STATS
  373.                  stats[S_INPKTS].cnt++;
  374.  #endif
  375. @@@ -722,6 +736,9 @@
  376.              rfd = accept(vs, (struct sockaddr *)&from_addr, &from_len);
  377.              gettime(&tt);
  378.              if (rfd < 0 && errno == EMFILE && streamq != NULL) {
  379. +                /* Out of file descriptors.  Close all streams
  380. +                   that have been idle for 15 minutes.  Also
  381. +                   determine which has been idle longest. */
  382.                  maxctime = 0;
  383.                  candidate = QSTREAM_NULL;
  384.                  for (sp = streamq; sp != QSTREAM_NULL;
  385. @@@ -729,8 +746,15 @@
  386.                      if (sp->s_refcnt != 0)
  387.                          continue;
  388.                      lasttime = tt.tv_sec - sp->s_time;
  389. -                    if (lasttime >= 900)
  390. +                    if (lasttime >= 900) {
  391. +#ifdef DEBUG
  392. +                        if (debug > 6) {
  393. +                        fprintf (ddt,
  394. +                            "sp x%x inactive\n",sp);
  395. +                        }
  396. +#endif
  397.                          sqrm(sp, &mask);
  398. +                    }
  399.                      else if (lasttime > maxctime) {
  400.                          candidate = sp;
  401.                          maxctime = lasttime;
  402. @@@ -739,6 +763,14 @@
  403.                  rfd = accept(vs, (struct sockaddr *)&from_addr, &from_len);
  404.                  if ((rfd < 0) && (errno == EMFILE) &&
  405.                      candidate != QSTREAM_NULL) {
  406. +                    /* still out of file descriptors.
  407. +                       close the least active stream. */
  408. +#ifdef DEBUG
  409. +                    if (debug > 6) {
  410. +                        fprintf (ddt,
  411. +                        "sp x%x inactive\n",sp);
  412. +                    }
  413. +#endif
  414.                      sqrm(candidate, &mask);
  415.                      rfd = accept(vs, (struct sockaddr *)&from_addr, &from_len);
  416.                  }
  417. @@@ -747,7 +779,11 @@
  418.                  syslog(LOG_WARNING, "accept: %m");
  419.                  continue;
  420.              }
  421. +#ifdef O_NONBLOCK
  422. +            (void) fcntl(rfd, F_SETFL, O_NONBLOCK);
  423. +#else
  424.              (void) fcntl(rfd, F_SETFL, FNDELAY);
  425. +#endif
  426.              (void) setsockopt(rfd, SOL_SOCKET, SO_KEEPALIVE,
  427.                  (char *)&on, sizeof(on));
  428.              if ((sp = sqadd()) == QSTREAM_NULL) {
  429. @@@ -800,9 +836,21 @@
  430.                          sp->s_bufp += n;
  431.                          size -= n;
  432.                      }
  433. -                    if ((n == -1) && (errno == EWOULDBLOCK))
  434. +                if ((n == -1) &&
  435. +                    (errno == EWOULDBLOCK || errno == EAGAIN))
  436.                          continue;
  437.                      if (n <= 0) {
  438. +#ifdef DEBUG
  439. +                        if (n == 0 && debug > 6) {
  440. +                        fprintf (ddt,
  441. +                            "sp x%x eof\n",sp);
  442. +                        }
  443. +                        else if (n < 0 && debug > 5) {
  444. +                        fprintf (ddt,
  445. +                            "sp x%x read errno=%d\n",
  446. +                            sp,errno);
  447. +                        }
  448. +#endif
  449.                          sp->s_refcnt = 0;
  450.                          sqrm(sp, &mask);
  451.                          continue;
  452. @@@ -863,9 +911,21 @@
  453.                      sizeof(HEADER));
  454.                      continue;
  455.                  }
  456. -                if ((n == -1) && (errno == EWOULDBLOCK))
  457. +                if ((n == -1) &&
  458. +                (errno == EWOULDBLOCK || errno == EAGAIN))
  459.                      continue;
  460.                  if (n <= 0) {
  461. +#ifdef DEBUG
  462. +                    if (n == 0 && debug > 6) {
  463. +                    fprintf (ddt,
  464. +                        "sp x%x eof\n",sp);
  465. +                    }
  466. +                    else if (n < 0 && debug > 5) {
  467. +                    fprintf (ddt,
  468. +                        "sp x%x read errno=%d\n",
  469. +                        sp,errno);
  470. +                    }
  471. +#endif
  472.                      sp->s_refcnt = 0;
  473.                      sqrm(sp, &mask);
  474.                      continue;
  475. @@@ -884,8 +944,7 @@
  476.                      continue;
  477.                  }
  478.              }
  479. -        }
  480. -    }
  481. +        } }
  482.      /* NOTREACHED */
  483.  }
  484.  
  485. @@@ -903,7 +962,8 @@
  486.  
  487.  onhup()
  488.  {
  489. -#if defined(SYSV)
  490. +/* #if defined(SYSV) */
  491. +#if !defined(HAVE_SIGVEC)
  492.      (void)signal(SIGHUP, onhup);
  493.  #endif SYSV
  494.      needreload = 1;
  495. @@@ -917,7 +977,8 @@
  496.  
  497.  maint_alarm()
  498.  {
  499. -#if defined(SYSV)
  500. +/* #if defined(SYSV) */
  501. +#if !defined(HAVE_SIGVEC)
  502.      (void)signal(SIGALRM, maint_alarm);
  503.  #endif SYSV
  504.      needmaint = 1;
  505. @@@ -943,7 +1004,8 @@
  506.   */
  507.  int setdumpflg()
  508.  {
  509. -#if defined(SYSV)
  510. +/* #if defined(SYSV) */
  511. +#if !defined (HAVE_SIGVEC)
  512.      (void)signal(SIGINT, setdumpflg);
  513.  #endif SYSV
  514.          needToDoadump = 1;
  515. @@@ -978,7 +1040,8 @@
  516.          if ( ddt == NULL)
  517.              syslog(LOG_WARNING, "can't open debug file: %m");
  518.          else {
  519. -#if defined(SYSV)
  520. +/* #if defined(SYSV) */
  521. +#ifndef HAVE_SETLINEBUF
  522.              setvbuf(ddt, NULL, _IOLBF, BUFSIZ);
  523.  #else
  524.              setlinebuf(ddt);
  525. @@@ -1006,7 +1069,8 @@
  526.  
  527.  setIncrDbgFlg()
  528.  {
  529. -#if defined(SYSV)
  530. +/* #if defined(SYSV) */
  531. +#if !defined (HAVE_SIGVEC)
  532.      (void)signal(SIGUSR1, setIncrDbgFlg);
  533.  #endif SYSV
  534.  #ifdef DEBUG
  535. @@@ -1027,7 +1091,8 @@
  536.  
  537.  setNoDbgFlg()
  538.  {
  539. -#if defined(SYSV)
  540. +/* #if defined(SYSV) */
  541. +#if !defined (HAVE_SIGVEC)
  542.      (void)signal(SIGUSR2, setNoDbgFlg);
  543.  #endif SYSV
  544.      setdebug(0);
  545. @@@ -1038,7 +1103,8 @@
  546.  */
  547.  setstatsflg()
  548.  {
  549. -#if defined(SYSV)
  550. +/* #if defined(SYSV) */
  551. +#if !defined (HAVE_SIGVEC)
  552.      (void)signal(SIGIOT, setstatsflg);
  553.  #endif SYSV
  554.      needStatsDump = 1;
  555. @@@ -1046,7 +1112,8 @@
  556.  
  557.  int setchkptflg()
  558.  {
  559. -#if defined(SYSV)
  560. +/* #if defined(SYSV) */
  561. +#if !defined (HAVE_SIGVEC)
  562.      (void)signal(SIGQUIT, setchkptflg);
  563.  #endif SYSV
  564.      needToChkpt = 1;
  565. @@@ -1061,7 +1128,8 @@
  566.  
  567.  sigprof()
  568.  {
  569. -#if defined(SYSV)
  570. +/* #if defined(SYSV) */
  571. +#if !defined (HAVE_SIGVEC)
  572.      (void)signal(SIGSYS, sigprof);
  573.  #endif SYSV
  574.  #ifdef DEBUG
  575.  
  576. Index: ns_maint.c
  577. *** old/ns_maint.c    Wed Dec  5 09:42:07 1990
  578. --- apb-901127/ns_maint.c    Wed Dec  5 09:42:11 1990
  579. @@@ -22,7 +22,8 @@
  580.  #include <sys/param.h>
  581.  #include <sys/socket.h>
  582.  #include <sys/time.h>
  583. -#if defined(SYSV)
  584. +/* #if defined(SYSV) */
  585. +#if defined (NEED_UNISTD_H)
  586.  #include <unistd.h>
  587.  #endif SYSV
  588.  #include <netinet/in.h>
  589. @@@ -200,7 +201,8 @@
  590.  #endif /* ECHOARGS */
  591.  #endif /* DEBUG */
  592.  
  593. -#ifdef SYSV
  594. +/* #ifdef SYSV */
  595. +#if !defined(HAVE_SIGVEC)
  596.  #define vfork fork
  597.  #else
  598.      omask = sigblock(sigmask(SIGCHLD));
  599. @@@ -211,7 +213,8 @@
  600.              fprintf(ddt, "xfer [v]fork: %d\n", errno);
  601.  #endif
  602.          syslog(LOG_ERR, "xfer [v]fork: %m");
  603. -#ifndef SYSV
  604. +/* #ifndef SYSV */
  605. +#if defined(HAVE_SIGVEC)
  606.          (void) sigsetmask(omask);
  607.  #endif
  608.          zp->z_time = tt.tv_sec + 10;
  609. @@@ -228,7 +231,8 @@
  610.          zp->z_xferpid = pid;
  611.          xfers_running++;
  612.          zp->z_time = tt.tv_sec + MAX_XFER_TIME;
  613. -#ifndef SYSV
  614. +/* #ifndef SYSV */
  615. +#if defined(HAVE_SIGVEC)
  616.          (void) sigsetmask(omask);
  617.  #endif
  618.      } else {
  619. @@@ -393,7 +397,8 @@
  620.      zp->z_time = tt.tv_sec + zp->z_retry;
  621.  }
  622.  
  623. -#ifdef SYSV
  624. +/* #ifdef SYSV */
  625. +#ifndef HAVE_WAIT3
  626.  union wait {
  627.      unsigned short    w_termsig:7;    /* termination signal */
  628.      unsigned short    w_coredump:1;    /* core dump indicator */
  629. @@@ -411,13 +416,16 @@
  630.      union wait status;
  631.  
  632.      gettime(&tt);
  633. -#if defined(SYSV)
  634. +/* #if defined(SYSV) */
  635. +#if !defined(HAVE_WAIT3)
  636.      { int stat;
  637.      pid = wait(&stat);
  638.      status.w_termsig = stat & 0x7f;
  639.      status.w_retcode = stat >> 8;
  640.      }
  641. +#if !defined(HAVE_SIGVEC)
  642.      (void)signal(SIGCLD, endxfer);
  643. +#endif
  644.  #ifdef DEBUG
  645.      if (debug > 1) 
  646.          fprintf(ddt, "child %d returned status=%d\n", pid, status);
  647. @@@ -453,7 +461,8 @@
  648.                      zp->z_lastupdate = tt.tv_sec;
  649.                      zp->z_time = tt.tv_sec + zp->z_refresh;
  650.                      if (zp->z_source) {
  651. -#if defined(SYSV)
  652. +/* #if defined(SYSV) */
  653. +#ifndef HAVE_UTIMES
  654.                          struct utimbuf t;
  655.  
  656.                          t.actime = tt.tv_sec;
  657. @@@ -505,7 +514,8 @@
  658.              }
  659.              break;
  660.          }
  661. -#ifndef SYSV
  662. +/* #ifndef SYSV */
  663. +#if defined(HAVE_WAIT3)
  664.      }
  665.  #endif /* SYSV */
  666.      for (zp = zones;
  667. @@@ -530,7 +540,7 @@
  668.          zp->z_state &= ~Z_NEED_RELOAD;
  669.          zp->z_auth = 0;
  670.          remove_zone(hashtab, zp - zones);
  671. -        if (db_load(zp->z_source, zp->z_origin, zp) == 0)
  672. +        if (db_load(zp->z_source, zp->z_origin, zp, 0) == 0)
  673.              zp->z_auth = 1;
  674.  
  675.          /*
  676.  
  677. Index: ns_req.c
  678. *** old/ns_req.c    Wed Dec  5 09:42:01 1990
  679. --- apb-901127/ns_req.c    Wed Dec  5 09:42:06 1990
  680. @@@ -1026,13 +1026,38 @@
  681.      }
  682.  
  683.      /* next do subdomains, unless delegated */
  684. -    if ((isroot == 0 && fndns) || np->n_hash == NULL)
  685. -        return;
  686. -    npp = np->n_hash->h_tab;
  687. -    nppend = npp + np->n_hash->h_size;
  688. +
  689. +    if (isroot == 0 && fndns) {
  690. +        return; /* subdomain is delegated */
  691. +    }
  692. +
  693. +    /* We find the subdomains by looking in the hash table for this
  694. +       domain, but the root domain needs special treatment, because
  695. +       the hash table pointed to by the global hashtab variable
  696. +       contains entries for the root domain (.)  and for all
  697. +       top-level domains, while the root domain itself doesn't have
  698. +       a hash table.
  699. +
  700. +       If we are not dealing with the root domain then we just set
  701. +       htp to point to the hash table for the current domain.
  702. +
  703. +       If we are dealing with the root domain, then we set htp to
  704. +       point to the global hash table, and take care not to
  705. +       re-process the entry for the root domain when it is found in
  706. +       the hash table.
  707. +    */
  708. +
  709. +    htp = ((dname[0] == '\0') ? hashtab : np->n_hash);
  710. +    if (htp == NULL) {
  711. +        return; /* no subdomains */
  712. +    }
  713. +    npp = htp->h_tab;
  714. +    nppend = npp + htp->h_size;
  715.      while (npp < nppend) {
  716.          for (np = *npp++; np != NULL; np = np->n_next) {
  717. +            if (np->n_dname[0] != '\0') { /* don't redo root domain */
  718.              doaxfr(np, rfp, 0);
  719. +            }
  720.          }
  721.      }
  722.  #ifdef DEBUG
  723. @@@ -1284,6 +1309,7 @@
  724.      if (debug >= 5)
  725.          fprintf(ddt,"startxfr()\n");
  726.  #endif
  727. +#ifndef NO_FORK_AXFR
  728.      /*
  729.       * child does the work while
  730.       * the parent continues
  731. @@@ -1293,17 +1319,27 @@
  732.          if (debug >= 5)
  733.              fprintf(ddt,"startxfr: child pid %d\n", getpid());
  734.  #endif
  735. +#endif /* NO_FORK_AXFR */
  736.          rfp = fdopen(qsp->s_rfd, "w");
  737. +#ifndef NO_FORK_AXFR
  738.          setproctitle("zone XFR to", qsp->s_rfd);
  739. +#endif /* NO_FORK_AXFR */
  740.          fdstat = fcntl(qsp->s_rfd, F_GETFL, 0);
  741.          if (fdstat != -1)
  742. +#ifdef O_NONBLOCK
  743. +            (void) fcntl(qsp->s_rfd, F_SETFL,
  744. +                    fdstat & ~(FNDELAY | O_NONBLOCK));
  745. +#else
  746.              (void) fcntl(qsp->s_rfd, F_SETFL, fdstat & ~FNDELAY);
  747. +#endif
  748.          fwritemsg(rfp, msg, msglen);
  749.          doaxfr(np, rfp, 1);
  750.          fwritemsg(rfp, msg, msglen);
  751.          (void) fflush(rfp);
  752. +#ifndef NO_FORK_AXFR
  753.          exit(0);
  754.      }
  755. +#endif /* NO_FORK_AXFR */
  756.      qsp->s_time = tt.tv_sec;
  757.      qsp->s_refcnt--;
  758.  }
  759.  
  760. Index: ns_resp.c
  761. *** old/ns_resp.c    Wed Dec  5 09:42:08 1990
  762. --- apb-901127/ns_resp.c    Wed Dec  5 09:42:12 1990
  763. @@@ -1360,6 +1360,9 @@
  764.      register struct    databuf **nspp;
  765.      struct hashbuf *htp = hashtab;
  766.      
  767. +    *countp = 0;
  768. +    nsp[0] = NULL;
  769. +
  770.      if (priming && (np == NULL || np->n_dname[0] == '\0'))
  771.          htp = fcachetab;
  772.  try_again:
  773.  
  774. @EOF
  775.  
  776. chmod 644 apb-901127
  777.  
  778. echo x - apb-910129
  779. sed 's/^@//' >apb-910129 <<'@EOF'
  780. Index: ns_init.c
  781. *** apb-901127/ns_init.c    Tue Jan 29 15:47:12 1991
  782. --- apb-910129/ns_init.c    Tue Jan 29 15:47:25 1991
  783. @@@ -311,10 +311,27 @@
  784.                  }
  785.              } while (getword(buf, sizeof(buf), fp));
  786.  #ifdef DEBUG
  787. -            if (debug)
  788. -                fprintf(ddt,"addrcnt = %d\n", zp->z_addrcnt);
  789. +            if (debug) {
  790. +                fprintf(ddt,"addrcnt = %d\n\tbackup file: %s\n",
  791. +                zp->z_addrcnt, (source ? source : "(none)"));
  792. +            }
  793.  #endif
  794. +
  795.              /*
  796. +             * Transfers don't work without a backup file
  797. +             * for secondary zones, because the named-xfer
  798. +             * program insists on a file name.
  799. +             *
  800. +             * XXX perhaps we could allocate a temp file for
  801. +             * this purpose?
  802. +             */
  803. +            if (! source) {
  804. +                syslog(LOG_ERR,
  805. +                "%s: line %d: no zone backup file\n",
  806. +                bootfile, lineno);
  807. +            }
  808. +
  809. +            /*
  810.               * If we had a backup file name, and it was changed,
  811.               * free old zone and start over.  If we don't have
  812.               * current zone contents, try again now in case
  813. @@@ -503,6 +520,8 @@
  814.  }
  815.  #endif ALLOW_UPDATES
  816.  
  817. +#if 0
  818. +/* xfer.c has its own soa_zinfo function, so this is unused.  --apb */
  819.  soa_zinfo(zp, cp, eom)
  820.      register struct zoneinfo *zp;
  821.      register u_char *cp;
  822. @@@ -520,6 +539,7 @@
  823.      GETLONG(zp->z_expire, cp);
  824.      GETLONG(zp->z_minimum, cp);
  825.  }
  826. +#endif
  827.  
  828.  get_forwarders(fp)
  829.      FILE *fp;
  830. @@@ -615,7 +635,7 @@
  831.   int  end;
  832.  {
  833.   int i;
  834. - for(i=1;i<=end;i++){
  835. + for(i=0;i<end;i++){
  836.       printzoneinfo(i) ;
  837.   }
  838.  }
  839.  
  840. Index: ns_maint.c
  841. *** apb-901127/ns_maint.c    Tue Jan 29 15:47:13 1991
  842. --- apb-910129/ns_maint.c    Tue Jan 29 15:47:28 1991
  843. @@@ -118,10 +118,28 @@
  844.          /*
  845.           * Find when the next refresh needs to be and set
  846.           * interrupt time accordingly.
  847. +         *
  848. +         * Just looking at z_time is not enough, because when
  849. +         * a zone transfer has just been started, z_time is set
  850. +         * to (current time + MAX_REFRESH_TIME), which is when when
  851. +         * a hung transfer needs to be aborted.  If the transfer
  852. +         * doesn't hang then endxfer() will set z_time to
  853. +         * (time when transfer ends + z_refresh) or to (time when
  854. +         * transfer ends + z_retry), and that might be a lot sooner
  855. +         * than (current time + MAX_REFRESH_TIME).
  856. +         *
  857. +         * So, if a transfer is running, and (current time + z_retry)
  858. +         * is sooner than the next maint interrupt would otherwise
  859. +         * occur, we shedule the next maint interrupt for (current
  860. +         * time + z_retry).
  861.           */
  862. +
  863.          if (next_refresh == 0 ||
  864.              (zp->z_time != 0 && next_refresh > zp->z_time))
  865.              next_refresh = zp->z_time;
  866. +        if ((zp->z_state & Z_XFER_RUNNING) &&
  867. +            (next_refresh > tt.tv_sec + zp->z_retry))
  868. +            next_refresh = tt.tv_sec + zp->z_retry;
  869.      }
  870.  
  871.          /*
  872. @@@ -130,7 +148,7 @@
  873.       */
  874.      bzero((char *)&ival, sizeof (ival));
  875.      ival.it_value.tv_sec = next_refresh - tt.tv_sec;
  876. -    if (ival.it_value.tv_sec < maint_interval)
  877. +    if ((long) ival.it_value.tv_sec < maint_interval)
  878.          ival.it_value.tv_sec = maint_interval;
  879.      (void) setitimer(ITIMER_REAL, &ival, (struct itimerval *)NULL);
  880.  #ifdef DEBUG
  881. @@@ -272,10 +290,12 @@
  882.      fprintf(ddt,", expire = %ld", zp->z_expire);
  883.      fprintf(ddt,", minimum = %ld", zp->z_minimum);
  884.      fprintf(ddt,", serial = %ld\n", zp->z_serial);
  885. -    fprintf(ddt,"z_time = %d", zp->z_time);
  886. -    fprintf(ddt,", now time : %d sec", tt.tv_sec);
  887. -    fprintf(ddt,", time left: %d sec; state %x\n", zp->z_time - tt.tv_sec,
  888. -        zp->z_state);
  889. +    fprintf(ddt,"lastupdate = %ld", (long) zp->z_lastupdate);
  890. +    fprintf(ddt,", z_time = %ld", (long) zp->z_time);
  891. +    fprintf(ddt,", now: %ld", (long) tt.tv_sec);
  892. +    fprintf(ddt,", time left: %ld sec",
  893. +            (long) zp->z_time - (long) tt.tv_sec);
  894. +    fprintf(ddt,"; state %x\n", zp->z_state);
  895.  }
  896.  #endif DEBUG
  897.  
  898.  
  899. @EOF
  900.  
  901. chmod 644 apb-910129
  902.  
  903. echo x - apb-910130
  904. sed 's/^@//' >apb-910130 <<'@EOF'
  905. Index: ns_init.c
  906. *** apb-910129/ns_init.c    Wed Jan 30 17:12:50 1991
  907. --- apb-910130/ns_init.c    Wed Jan 30 17:18:12 1991
  908. @@@ -186,12 +186,9 @@
  909.              zp->z_origin = savestr(obuf);
  910.              zp->z_type = type;
  911.          }
  912. -        zp->z_addrcnt = 0;
  913. -        zp->z_refresh = 0;    /* by default, no dumping */
  914.  
  915.          switch (type) {
  916.          case Z_CACHE:
  917.              source = savestr(buf);
  918. +            zp->z_refresh = 0;    /* by default, no dumping */
  919.  #ifdef DEBUG
  920.              if (debug)
  921.                  fprintf(ddt,", source = %s\n", source);
  922. @@@ -283,6 +282,7 @@
  923.              break;
  924.  
  925.          case Z_SECONDARY:
  926. +            zp->z_addrcnt = 0;
  927.              source = 0;
  928.  #ifdef DEBUG
  929.              if (debug)
  930. @@@ -332,28 +332,30 @@
  931.              }
  932.  
  933.              /*
  934. -             * If we had a backup file name, and it was changed,
  935. -             * free old zone and start over.  If we don't have
  936. -             * current zone contents, try again now in case
  937. -             * we have a new server on the list.
  938. +             * If we've loaded this file, and the file has
  939. +             * not been modified then there's no need to reload.
  940.               */
  941. -            if (zp->z_source &&
  942. -                (source == 0 || strcmp(source, zp->z_source))) {
  943. +            if (zp->z_source && source &&
  944. +                strcmp(source, zp->z_source) == 0 &&
  945. +                stat(zp->z_source, &f_time) == 0 &&
  946. +                zp->z_ftime == f_time.st_mtime) {
  947.  #ifdef DEBUG
  948.                  if (debug)
  949. -                    fprintf(ddt,"backup file changed\n");
  950. +                    fprintf(ddt, "zone is up to date\n");
  951.  #endif
  952. +                break; /* zone is already up to date */
  953. +            }
  954. +            if (zp->z_source) {
  955.                  free(zp->z_source);
  956. -                zp->z_source = 0;
  957. -                zp->z_auth = 0;
  958. -                            remove_zone(hashtab, zp - zones);
  959. +                remove_zone(hashtab, zp - zones);
  960.              }
  961. -            if (zp->z_source)
  962. -                free(source);
  963. -            else
  964. -                zp->z_source = source;
  965. -            if (zp->z_auth == 0)
  966. -                zoneinit(zp);
  967. +                        zp->z_source = source;
  968. +                        zp->z_auth = 0;
  969. +#ifdef DEBUG
  970. +            if (debug)
  971. +                fprintf(ddt, "reloading zone\n");
  972. +#endif
  973. +            zoneinit(zp);
  974.              break;
  975.  
  976.          }
  977.  
  978. @EOF
  979.  
  980. chmod 644 apb-910130
  981.  
  982. exit 0
  983.