* amd/srvr_nfs.c (find_nfs_srvr): flush NFS handle cache if the IP
authorErez Zadok <ezk@cs.sunysb.edu>
Mon, 11 Jul 2005 01:55:28 +0000 (01:55 +0000)
committerErez Zadok <ezk@cs.sunysb.edu>
Mon, 11 Jul 2005 01:55:28 +0000 (01:55 +0000)
address of a down server had changed.

* amd/info_union.c (union_reload): use safer xsnprintf() routine.

ChangeLog
NEWS
amd/info_union.c
amd/srvr_nfs.c

index db1535a128f478cdec662c6ff1ccdc2af382f71d..67c3892d7cb3e77ec9c4538bdf0a66b566fd209f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2005-07-10  Erez Zadok  <ezk@cs.sunysb.edu>
 
+       * amd/srvr_nfs.c (find_nfs_srvr): flush NFS handle cache if the IP
+       address of a down server had changed.
+
+       * amd/info_union.c (union_reload): use safer xsnprintf() routine.
+
        * amd/srvr_nfs.c (find_nfs_srvr): check to see if the IP address
        of a named but down fserver changed (i.e., the previous IP address
        is no longer responding).  If so, then reset the fserver to the
diff --git a/NEWS b/NEWS
index a5e17fbd8e6a7895eb2df8372a08f3fc1c4e7196..65318072ca4cd3f74335ca2f94820045190c004a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,7 @@
        * buffer overflow in pawd.
        * aix4 clean build.
        * use strlcat/snprintf in a few places for safety.
+       * recover from IP address change of a down NFS server
 
 *** Notes specific to am-utils version 6.1
 
index e4a8f0bfde48aaf6208bfb8b6eab0e3ac4e6a3c6..3c69d3acae605f6718083aae29cc1840ca08d35b 100644 (file)
@@ -37,7 +37,7 @@
  * SUCH DAMAGE.
  *
  *
- * $Id: info_union.c,v 1.11 2005/02/17 03:37:42 ezk Exp $
+ * $Id: info_union.c,v 1.12 2005/07/11 01:55:28 ezk Exp $
  *
  */
 
@@ -133,9 +133,10 @@ union_reload(mnt_map *m, char *map, void (*fn) (mnt_map *, char *, char *))
    * Add wildcard entry
    */
   {
-    char *val = xmalloc(strlen(*(dir-1)) + 5);
+    size_t len = strlen(*(dir-1)) + 5;
+    char *val = xmalloc(len);
 
-    sprintf(val, "fs:=%s", *(dir-1));
+    xsnprintf(val, len, "fs:=%s", *(dir-1));
     (*fn) (m, strdup("*"), val);
   }
   XFREE(mapd);
index 49b3f7630e2df0c1eb845aaa151862dba8e60e7e..2e8dadfd397743e090209ed1c3bdf58223d61a68 100644 (file)
@@ -37,7 +37,7 @@
  * SUCH DAMAGE.
  *
  *
- * $Id: srvr_nfs.c,v 1.40 2005/07/10 21:41:48 ezk Exp $
+ * $Id: srvr_nfs.c,v 1.41 2005/07/11 01:55:28 ezk Exp $
  *
  */
 
@@ -635,7 +635,7 @@ find_nfs_srvr(mntfs *mf)
   int pingval;
   mntent_t mnt;
   nfs_private *np;
-  struct hostent *hp = 0;
+  struct hostent *hp = NULL;
   struct sockaddr_in *ip = NULL;
   u_long nfs_version = 0;      /* default is no version specified */
   u_long best_nfs_version = 0;
@@ -769,6 +769,7 @@ find_nfs_srvr(mntfs *mf)
              sizeof(ip->sin_addr));
       fs->fs_flags |= FSF_VALID;
       fs->fs_flags &= ~(FSF_DOWN|FSF_ERROR);
+      flush_nfs_fhandle_cache(fs); /* XXX: safer, but really needed? */
       /* fall through to checking available NFS protocols, pinging, etc. */
     } else {
       /* server was down and is still down.  Not much we can do. */