OSSP CVS Repository

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

Check-in Number: 3357
Date: 2003-May-21 17:16:41 (local)
2003-May-21 15:16:41 (UTC)
User:ms
Branch:
Comment: Bug fix recent eval mode addition, and add login name parsing to eval mode.
Tickets:
Inspections:
Files:
ossp-pkg/rc/00TODO      1.41 -> 1.42     1 inserted, 1 deleted
ossp-pkg/rc/rc_proc.c      1.29 -> 1.30     11 inserted, 1 deleted
ossp-pkg/rc/rc_script.c      1.19 -> 1.20     15 inserted, 5 deleted
ossp-pkg/rc/rc_sect.c      1.9 -> 1.10     12 inserted, 3 deleted
ossp-pkg/rc/rc_test/rc.samba      1.2 -> 1.3     1 inserted, 1 deleted

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

--- 00TODO       2003/05/21 12:49:20     1.41
+++ 00TODO       2003/05/21 15:16:41     1.42
@@ -28,7 +28,6 @@
 Document
   Refs, pri, user, group, ci, go only in normal (not special) sections.
   Section definition regular expressions need to follow a format ()\2.
-  Changed from OpenPKG: temp files no longer have pids in their file names
 
 Questions
   Should location regex specify a directory and prefix separately, or files*?
@@ -37,6 +36,7 @@
 
 Variation to OpenPKG rc
   OpenPKG puts sections with no -p at end, but we give them implicitly -p 200
+  Temp files no longer have pids in their file names during eval mode
 
 Consider
   Nice to have feature for ex, a pEx->pObj->strErr(pEx->Value);


ossp-pkg/rc/rc_proc.c 1.29 -> 1.30

--- rc_proc.c    2003/05/21 12:49:21     1.29
+++ rc_proc.c    2003/05/21 15:16:41     1.30
@@ -224,9 +224,15 @@
                 else
                     ppSectmp[nRcs] = NULL;
             }
-            qsort((void *)ppSectmp, (size_t)pRc->m_pAnal->m_nRcs, sizeof(rc_section_t *), priCompare);
+            qsort((void *)ppSectmp, (size_t)pRc->m_pAnal->m_nRcs, \
+                sizeof(rc_section_t *), priCompare);
             nTmp = 0;
             while (nTmp < pRc->m_pAnal->m_nRcs && ppSectmp[nTmp]) {
+                if ((szTmp = (char *)sectionGetlogin(ppSectmp[nTmp])) != NULL) {
+                    scriptAppend(pFatscript, "#su ", strlen("#su "));
+                    scriptAppend(pFatscript, szTmp, strlen(szTmp));
+                    scriptAppend(pFatscript, "\n", strlen("\n") + 1);
+                }
                 szTmp = (char *)sectionGetdata(ppSectmp[nTmp]);
                 scriptAppend(pFatscript, szTmp, strlen(szTmp) + 1);
                 nTmp++;
@@ -238,8 +244,12 @@
         szTmpfile = (char *)configGetval(RC_TMP_VAL);
         nTmpname = (strlen(szTmpfile) + strlen(RC_EVL_TMP) + \
                     strlen(RC_EVL_SUF) + 1) * sizeof(char);
+        if (*(szTmpfile + (strlen(szTmpfile) - 1) * sizeof(char)) != '/')
+            nTmpname += sizeof(char);
         szTmpfile = malloc(nTmpname);
         strcpy(szTmpfile, configGetval(RC_TMP_VAL));
+        if (*(szTmpfile + (strlen(szTmpfile) - 1) * sizeof(char)) != '/')
+            *(szTmpfile + (strlen(szTmpfile)) * sizeof(char)) = '/';
         strcat(szTmpfile, RC_EVL_TMP);
         mktemp(szTmpfile);
         strcat(szTmpfile, RC_EVL_SUF);


ossp-pkg/rc/rc_script.c 1.19 -> 1.20

--- rc_script.c  2003/05/21 12:49:21     1.19
+++ rc_script.c  2003/05/21 15:16:41     1.20
@@ -50,7 +50,10 @@
 
     pNew = (rc_script_t *)malloc(sizeof(rc_script_t));
     *pNew = malloc((strlen(scriptTostring(pOrig)) + 1) * sizeof(char));
-    strcpy(*pNew, scriptTostring(pOrig));
+    if (pNew)
+        strcpy(*pNew, scriptTostring(pOrig));
+    else
+        RC_THROW(RC_ERR_MEM);
 
     return(pNew);
 }
@@ -224,7 +227,7 @@
             /* Handle the section userid   */
             piSubtemp = strnstr(piStart, RC_DEF_UIG, piEnd - piStart);
             if (piSubtemp) { /* Userid pattern found */
-                for (nTmp = (int)piSubtemp + strlen(RC_DEF_UIG);\
+                for (nTmp = (int)piSubtemp + strlen(RC_DEF_UIG); \
                     isspace(*(char *)nTmp); nTmp += sizeof (char)); /* Strip */
                 nUid = strtol((char *)nTmp, &piSep, 10);
                 if ((char *)nTmp == piSep)      /* No userid number follows */
@@ -312,17 +315,24 @@
 rc_return_t scriptWrite(rc_script_t *pScript, const char *szPath)
 {
     int nFdtmp = open(szPath, O_WRONLY | O_CREAT, 0600);
-    FILE *pStream = fdopen(nFdtmp, "w");
+    FILE *pStream = NULL;
+
+    /* Initial sanity checks */
+    if (!pScript || nFdtmp < 0)
+        return(RC_THROW(RC_ERR_USE));
+    else
+        pStream = fdopen(nFdtmp, "w");
 
     /* Don't remove this! It encapsulates the script object, */
     /*                    which might not be a simple string */
-    if (pScript && pStream) {
+    if (pStream) {
         fprintf(pStream, "%s", *pScript);
         fclose(pStream);
         return(RC_THROW(RC_OK));
     }
     else
-        return(RC_THROW(RC_ERR_USE));
+        fprintf(stderr, "FIXME: Replace with a real ex_throw!\n");
+/*        return(RC_THROW(RC_ERR_USE));*/
 }
 
 /************************************************


ossp-pkg/rc/rc_sect.c 1.9 -> 1.10

--- rc_sect.c    2003/05/21 12:49:21     1.9
+++ rc_sect.c    2003/05/21 15:16:41     1.10
@@ -226,8 +226,11 @@
 ************************************************/
 rc_return_t sectionDump(rc_section_t *pSec)
 {
+    const char *szLogin = NULL;
+
     if (pSec) {
-        fprintf(stdout, "#su %s\n", sectionGetlogin(pSec));
+        if ((szLogin = sectionGetlogin(pSec)) != NULL)
+            fprintf(stdout, "#su %s\n", szLogin);
         fprintf(stdout, "%s", sectionGetdata(pSec));
         return(RC_THROW(RC_OK));
     }
@@ -242,9 +245,15 @@
 rc_return_t sectionWrite(rc_section_t *pSec, const char *szPath)
 {
     int nFdtmp = open(szPath, O_WRONLY | O_CREAT, 0600);
-    FILE *pStream = fdopen(nFdtmp, "w");
+    FILE *pStream = NULL;
+
+    /* Initial sanity checks */
+    if (!pSec || nFdtmp < 0)
+        return(RC_THROW(RC_ERR_USE));
+    else
+        pStream = fdopen(nFdtmp, "w");
 
-    if (pSec && pStream) {
+    if (pStream) {
         fprintf(pStream, "#su %s\n", sectionGetlogin(pSec));
         fprintf(pStream, "%s", sectionGetdata(pSec));
         fclose(pStream);


ossp-pkg/rc/rc_test/rc.samba 1.2 -> 1.3

--- rc.samba     2003/05/15 12:47:26     1.2
+++ rc.samba     2003/05/21 15:16:44     1.3
@@ -8,7 +8,7 @@
 %search
     whois cyvaned.com
 
-%destroy
+%destroy -u sw-n
     ldd /usr/lib/libpcap.so
 
 %finish

CVSTrac 2.0.1