Bug 141 - PBSD_authenticate overwrites value of PBS_O_PATH
: PBSD_authenticate overwrites value of PBS_O_PATH
Status: RESOLVED FIXED
Product: TORQUE
libtorque
: 2.5.x
: PC Linux
: P5 normal
Assigned To: David Beer
:
:
:
  Show dependency treegraph
 
Reported: 2011-06-28 21:01 MDT by Donald Neal
Modified: 2011-06-29 09:51 MDT (History)
2 users (show)

See Also:


Attachments


Note

You need to log in before you can comment on or make changes to this bug.


Description Donald Neal 2011-06-28 21:01:56 MDT
Seen in versions 2.5.5 and 2.5.7.

PBSD_authenticate overwrites the value of PATH with only the first item of
PATH's value, that is the text to the left of the first colon.
PBSD_authenticate being invoked by qsub causes the PBS_O_PATH passed to jobs to
have the wrong value. When qsub is used with both "-c enabled" and "-V", the
job's value of PATH is set to the value of $PBS_O_PATH, which is unlikely to
allow the job to run correctly.

This looks to be fixable by applying to pbsD_connect.c something like

@@ -492,6 +492,7 @@
   int    j;
   FILE *piff;
   char  *ptr;
+  char *buffer, *temp_ptr;

   struct stat buf;

@@ -521,20 +522,25 @@

       if ((ptr = getenv("PATH")) != NULL)
         {
-        ptr = strtok(ptr, ":");
+    buffer = (char *)malloc(strlen(ptr)+1);
+    temp_ptr = buffer;
+        strcpy(temp_ptr, ptr);

-        while (ptr != NULL)
+        temp_ptr = strtok(temp_ptr, ":");
+
+        while (temp_ptr != NULL)
           {
           snprintf(iffpath, sizeof(iffpath), "%s/pbs_iff",
-                   ptr);
+                   temp_ptr);

           rc = stat(iffpath, &buf);

           if (rc != -1)
             break;

-          ptr = strtok(NULL, ":");
+          temp_ptr = strtok(NULL, ":");
           }  /* END while (ptr != NULL) */
+    free(buffer);
         }    /* END if ((ptr = getenv("PATH")) != NULL) */

       if (rc == -1)

Use of strtok_r instead of strtok may be a viable alternative.
Comment 1 David Beer 2011-06-29 09:51:30 MDT
Patch was tested, slightly modified, verified, and checked in.