* amq/pawd.c (transform_dir): resolve path repeatedly until
authorErez Zadok <ezk@cs.sunysb.edu>
Wed, 26 Oct 2005 03:35:50 +0000 (03:35 +0000)
committerErez Zadok <ezk@cs.sunysb.edu>
Wed, 26 Oct 2005 03:35:50 +0000 (03:35 +0000)
finished.  Bug fix from Jonathan Chen <jon+amd-at-spock.org>.
Added safety check to prevent infinite loops.

AUTHORS
ChangeLog
NEWS
amq/pawd.c

diff --git a/AUTHORS b/AUTHORS
index c2825212da9e977ff2d70ff09cebb11c6b78e704..37c1bee70fa1c219c08567f0e7732b8d66ebb105 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -397,6 +397,7 @@ October 22, 2004: patch/fix to move mlock/mlockall/plock code after the
 fork().
 June 29, 2005: core dump going off end of exported_ap[] array.
 September 29, 2005: patch/fix for pawd not to go into an infinite loop.
+October 25, 2005: patch/fix for pawd to repeatedly resolve path.
 
 * David Rage <rage@ucl.ac.uk>
 January 17, 2005: prevent Amd from logging 'Read-only filesystem' errors
index 3c8772bdf3e5685b68605ac392897706eed8831f..d9f1fc69cbb520092c136fd4e0ad8c70a2d13eae 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-10-25  Erez Zadok  <ezk@cs.sunysb.edu>
+
+       * amq/pawd.c (transform_dir): resolve path repeatedly until
+       finished.  Bug fix from Jonathan Chen <jon+amd-at-spock.org>.
+       Added safety check to prevent infinite loops.
+
 2005-10-19  Erez Zadok  <ezk@cs.sunysb.edu>
 
        * doc/am-utils.texi (opts Option): document new pcfs options
diff --git a/NEWS b/NEWS
index 57801462181b56b593b7863d3ee9e22ffab7aedc..8479d42e1295eae40c29360f8be46a5a29d3f41b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ shortname, user=N, group=N, mask=N, and dirmask=N.
 
 - Bugs fixed:
        * correctly print nfs_args->addr info (sin_family/port/addr)
+       * pawd should resolve path repeatedly until no more to do
 
 *** Notes specific to am-utils version 6.2a1
 
index 39b1764a94b8b0f0e94ff90fd9e2a5e1c12cdf03..a7d77f6551351167e3f6efb2e8b293a2d5e5c239 100644 (file)
@@ -57,6 +57,9 @@
 #include <am_defs.h>
 #include <amq.h>
 
+/* maximum number of transformations for each path */
+#define MAX_LOOP       10
+
 /* statics */
 static char *localhost = "localhost";
 static char transform[MAXPATHLEN];
@@ -182,6 +185,7 @@ transform_dir(char *dir)
   struct timeval tmo = {10, 0};
   char *dummystr;
   amq_string *spp;
+  int again = 1, maxloop = MAX_LOOP;
 
 #ifdef DISK_HOME_HACK
   if (ch = hack_name(dir))
@@ -208,11 +212,21 @@ transform_dir(char *dir)
     return dir;
 
   xstrlcpy(transform, dir, sizeof(transform));
-  dummystr = transform;
-  spp = amqproc_pawd_1((amq_string *) &dummystr, clnt);
-  if (spp && *spp && **spp) {
-    xstrlcpy(transform, *spp, sizeof(transform));
-    XFREE(*spp);
+  while (again) {
+    if (--maxloop <= 0) {
+      fprintf(stderr, "pawd: exceeded maximum no. of transformations (%d)\n",
+             MAX_LOOP);
+      break;
+    }
+    again = 0;
+    dummystr = transform;
+    spp = amqproc_pawd_1((amq_string *) &dummystr, clnt);
+    if (spp && *spp && **spp) {
+      if (STREQ(transform, *spp))
+       again++;
+      xstrlcpy(transform, *spp, sizeof(transform));
+      XFREE(*spp);
+    }
   }
   clnt_destroy(clnt);
   return transform;