Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-4]: src/usr.sbin/amd/amd pull up rev 1.14 from trunk (requested...



details:   https://anonhg.NetBSD.org/src/rev/8d164c66b077
branches:  netbsd-1-4
changeset: 469430:8d164c66b077
user:      cgd <cgd%NetBSD.org@localhost>
date:      Tue Sep 21 04:55:20 1999 +0000

description:
pull up rev 1.14 from trunk (requested by christos):
  Upgrade amd(8) and related software to fix expoitable stack overflows
  in amq(8), as reported in BUGTRAQ and elsewhere.

diffstat:

 usr.sbin/amd/amd/info_nis.c |  77 ++++++++++++++++++++++++++++++++++++--------
 1 files changed, 63 insertions(+), 14 deletions(-)

diffs (169 lines):

diff -r 291ab0b7f118 -r 8d164c66b077 usr.sbin/amd/amd/info_nis.c
--- a/usr.sbin/amd/amd/info_nis.c       Tue Sep 21 04:55:15 1999 +0000
+++ b/usr.sbin/amd/amd/info_nis.c       Tue Sep 21 04:55:20 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: info_nis.c,v 1.13 1999/02/01 19:05:10 christos Exp $   */
+/*     $NetBSD: info_nis.c,v 1.13.2.1 1999/09/21 04:55:20 cgd Exp $    */
 
 /*
  * Copyright (c) 1997-1999 Erez Zadok
@@ -40,7 +40,7 @@
  *
  *      %W% (Berkeley) %G%
  *
- * Id: info_nis.c,v 1.3 1999/01/13 23:30:59 ezk Exp 
+ * Id: info_nis.c,v 1.5 1999/08/22 05:12:51 ezk Exp 
  *
  */
 
@@ -57,8 +57,12 @@
 
 /*
  * NIS+ servers in NIS compat mode don't have yp_order()
+ *
+ *     has_yp_order = 1        NIS server
+ *                  = 0        NIS+ server
+ *                  = -1       server is down
  */
-static int has_yp_order = FALSE;
+static int has_yp_order = -1;
 
 /* forward declarations */
 int nis_reload(mnt_map *m, char *map, void (*fn) (mnt_map *, char *, char *));
@@ -105,7 +109,9 @@
   }
   if (!*default_domain) {
     nis_not_running = 1;
+#ifdef DEBUG
     plog(XLOG_WARNING, "NIS domain name is not set.  NIS ignored.");
+#endif /* DEBUG */
     return ENOENT;
   }
   gopt.nis_domain = strdup(default_domain);
@@ -195,25 +201,52 @@
 {
   YP_ORDER_OUTORDER_TYPE order;
   int error;
+  char *master;
   static int last_status = 1;  /* assume up by default */
 
-  if (has_yp_order) {
+  switch (has_yp_order) {
+  case 1:
+    /*
+     * NIS server with yp_order
+     */
     error = yp_order(gopt.nis_domain, map, &order);
     if (error != 0) {
       plog(XLOG_ERROR,
-          "nis_isup: error getting the order of map of %s: %s",
+          "nis_isup: error getting the order of map %s: %s",
           map, yperr_string(ypprot_err(error)));
       last_status = 0;
       return 0;                        /* NIS is down */
     }
+    break;
+
+  case 0:
+    /*
+     * NIS+ server without yp_order
+     */
+    error = yp_master(gopt.nis_domain, map, &master);
+    if (error != 0) {
+      plog(XLOG_ERROR,
+          "nis_isup: error getting the master of map %s: %s",
+          map, yperr_string(ypprot_err(error)));
+      last_status = 0;
+      return 0;                        /* NIS+ is down */
+    }
+    break;
+
+  default:
+    /*
+     * server was down
+     */
+    last_status = 0;
   }
-  if (last_status == 0) {      /* if was down before */
+
+  if (last_status == 0) {      /* reinitialize if was down before */
     time_t dummy;
+    error = nis_init(m, map, &dummy);
+    if (error)
+      return 0;                        /* still down */
     plog(XLOG_INFO, "nis_isup: NIS came back up for map %s", map);
-    /* XXX: do we really need to reinitialize nis? */
-    error = nis_init(m, map, &dummy);
-    if (!error)
-      last_status = 1;
+    last_status = 1;
   }
   return 1;                    /* NIS is up */
 }
@@ -239,8 +272,10 @@
   }
 
 
-  if (has_yp_order) {
+  switch (has_yp_order) {
+  case 1:
     /*
+     * NIS server with yp_order
      * Check if map has changed
      */
     if (yp_order(gopt.nis_domain, map, &order))
@@ -249,7 +284,9 @@
       *tp = (time_t) order;
       return -1;
     }
-  } else {
+    break;
+
+  case 0:
     /*
      * NIS+ server without yp_order
      * Check if timeout has expired to invalidate the cache
@@ -259,6 +296,15 @@
       *tp = (time_t)order;
       return(-1);
     }
+    break;
+
+  default:
+    /*
+     * server was down
+     */
+     if (nis_isup(m, map))
+       return -1;
+     return EIO;
   }
 
   /*
@@ -303,7 +349,8 @@
   yp_order_result = yp_order(gopt.nis_domain, map, &order);
   switch (yp_order_result) {
   case 0:
-    has_yp_order = TRUE;
+    /* NIS server found */
+    has_yp_order = 1;
     *tp = (time_t) order;
 #ifdef DEBUG
     dlog("NIS master for %s@%s has order %lu", map, gopt.nis_domain, (unsigned long) order);
@@ -311,7 +358,7 @@
     break;
   case YPERR_YPERR:
     /* NIS+ server found ! */
-    has_yp_order = FALSE;
+    has_yp_order = 0;
     /* try yp_master() instead */
     if (yp_master(gopt.nis_domain, map, &master)) {
       return ENOENT;
@@ -324,6 +371,8 @@
     }
     break;
   default:
+    /* server is down */
+    has_yp_order = -1;
     return ENOENT;
   }
   return 0;



Home | Main Index | Thread Index | Old Index