OSSP CVS Repository

ossp - Check-in [3373]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 3373
Date: 2003-May-22 16:46:33 (local)
2003-May-22 14:46:33 (UTC)
User:ms
Branch:
Comment: Half finish the per-user process logic, leading up to coding the fork(2) and waitpid(2).
Tickets:
Inspections:
Files:
ossp-pkg/rc/00TODO      1.42 -> 1.43     1 inserted, 0 deleted
ossp-pkg/rc/rc_proc.c      1.31 -> 1.32     20 inserted, 18 deleted

ossp-pkg/rc/00TODO 1.42 -> 1.43

--- 00TODO       2003/05/21 15:16:41     1.42
+++ 00TODO       2003/05/22 14:46:33     1.43
@@ -24,6 +24,7 @@
     sections of a rcfile are not kept together (logic copied anyways.)
   Rc file prefix rc. is hardcoded, and when wildcard is given, the prefix is
     used in selecting files. Location is not properly used. See rc_anal.c.
+  when a section is not found, the config is also not executed
 
 Document
   Refs, pri, user, group, ci, go only in normal (not special) sections.


ossp-pkg/rc/rc_proc.c 1.31 -> 1.32

--- rc_proc.c    2003/05/21 15:24:07     1.31
+++ rc_proc.c    2003/05/22 14:46:33     1.32
@@ -196,6 +196,7 @@
     int   nSecs     = 0;              /* Section index       */
     char *szTmpfile = NULL;           /* Path of temporary file          */
     char *szTmp     = NULL;           /* Generic temporary string        */
+    char *szCom     = NULL;           /* Stores common script text       */
     char *szExec    = NULL;           /* Used only during exec mode      */
     char *pszVec[RC_EXEC_MAXARGS];    /* For passing in to execv(3)      */
     rc_script_t   *pFatscript = NULL; /* To build a comprehensive script */
@@ -263,10 +264,7 @@
     else if (configGetval(RC_EXC_VAL)) {                        /* Execute  */
         /* Allocate a block of section pointers to use temporarily */
         ppSectmp = calloc(pRc->m_pAnal->m_nRcs, sizeof(rc_section_t *));
-        /* Allocate the command chain string to execute with execv(3) */
-        szTmp = (char *)scriptTostring(pRc->m_pScriptcom);
-        szExec = malloc((strlen(szTmp) + 1) * sizeof(char));
-        strcpy(szExec, szTmp);
+        szCom = (char *)scriptTostring(pRc->m_pScriptcom);
         for (nSecs = 0; nSecs < pRc->m_pAnal->m_nSecs; nSecs++) {
             for (nRcs = 0; nRcs < pRc->m_pAnal->m_nRcs; nRcs++) {
                 nTmp = 0;
@@ -280,27 +278,31 @@
                     ppSectmp[nRcs] = NULL;
             }
             qsort((void *)ppSectmp, (size_t)pRc->m_pAnal->m_nRcs, sizeof(rc_section_t *), priCompare);
-            nTmp = 0;
+            pszVec[0] = "/bin/sh";  /* Run the bourne shell over the following */
+            pszVec[1] = "-c";       /* Append script code of the sections */
+            pszVec[3] = NULL;       /* Add a NULL to mark the end of the chain */
+            nTmp = 0; /* Count from zero until however many sections we have */
             while (nTmp < pRc->m_pAnal->m_nRcs && ppSectmp[nTmp]) {
                 szTmp = (char *)sectionGetdata(ppSectmp[nTmp]);
-                szExec = realloc(szExec, (strlen(szExec) + 1) * sizeof(char) + \
-                                         (strlen(szTmp) + 1) * sizeof(char));
-                strcat(szExec, szTmp); /* Build onto the command chain */
+                szExec = malloc(strlen(szCom) * sizeof(char) + \
+                               (strlen(szTmp) + 1) * sizeof(char));
+                strcpy(szExec, szCom); /* Start out with just the common script code */
+                strcat(szExec, szTmp); /* And build a section onto the command chain */
+                pszVec[2] = szExec; /* Actually launch the new process image now */
+
+/* FIXME: Put the fork in here! */
+                if (execvp(*pszVec, pszVec) == -1) {                    /* launch */
+                    TRACE("Bad, execvp for common script in child returned -1");
+                    return(RC_THROW(RC_ERR_INT));
+                }
+
+                free(szExec); /* Cleanup after exec */
+                szExec = NULL;
                 nTmp++;
             }
         }
         free(ppSectmp);
         ppSectmp = NULL;
-
-        /* Actually launch the new process image now */
-        pszVec[0] = "/bin/sh";
-        pszVec[1] = "-c";
-        pszVec[2] = szExec;
-        pszVec[3] = NULL;   /* Add a NULL to mark the end of the chain */
-        if (execvp(*pszVec, pszVec) == -1) {                    /* launch */
-            TRACE("Bad, execvp for common script in child returned -1");
-            return(RC_THROW(RC_ERR_INT));
-        }
     }
     else if (configGetval(RC_PRN_VAL)) {                        /* Print  */
         /* Allocate a block of section pointers to use as a temporary */

CVSTrac 2.0.1