OSSP CVS Repository

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

Check-in Number: 3318
Date: 2003-Apr-03 14:05:14 (local)
2003-Apr-03 12:05:14 (UTC)
User:ms
Branch:
Comment: Bring rc back to life, corrected the processor and script object memory problems, and made small changes to test suite.
Tickets:
Inspections:
Files:
ossp-pkg/rc/rc.h      1.38 -> 1.39     2 inserted, 1 deleted
ossp-pkg/rc/rc_private.h      1.20 -> 1.21     1 inserted, 0 deleted
ossp-pkg/rc/rc_proc.c      1.17 -> 1.18     9 inserted, 13 deleted
ossp-pkg/rc/rc_script.c      1.11 -> 1.12     7 inserted, 5 deleted
ossp-pkg/rc/rc_sect.c      1.1 -> 1.2     18 inserted, 4 deleted
ossp-pkg/rc/rc_test.sh      1.21 -> 1.22     23 inserted, 0 deleted
ossp-pkg/rc/rc_test/rc.dhcpd      1.2 -> 1.3     1 inserted, 0 deleted

ossp-pkg/rc/rc.h 1.38 -> 1.39

--- rc.h 2002/08/02 16:38:09     1.38
+++ rc.h 2003/04/03 12:05:14     1.39
@@ -111,7 +111,7 @@
 
 /* Script function prototypes */
 rc_script_t *scriptNew(void);
-rc_return_t scriptAppend(rc_script_t *, char *, size_t);
+rc_return_t scriptAppend(rc_script_t *, const char *, size_t);
 rc_section_t *scriptSection(rc_script_t *, const char *);
 rc_return_t scriptDump(rc_script_t *);
 const char *scriptTostring(rc_script_t *);
@@ -122,6 +122,7 @@
 const int sectionGetpri(rc_section_t *);
 const int sectionGetuid(rc_section_t *);
 const char *sectionGetdata(rc_section_t *);
+size_t sectionGetlen(rc_section_t *);
 rc_return_t sectionSetpri(rc_section_t *, int);
 rc_return_t sectionSetuid(rc_section_t *, int);
 rc_return_t sectionSetdata(rc_section_t *, const char *);


ossp-pkg/rc/rc_private.h 1.20 -> 1.21

--- rc_private.h 2002/08/02 16:38:09     1.20
+++ rc_private.h 2003/04/03 12:05:14     1.21
@@ -90,6 +90,7 @@
     int nPri;
     int nUid;
     char *szData;
+    size_t Bytes;
 } rc_section_t;
 
 /* Processor class */


ossp-pkg/rc/rc_proc.c 1.17 -> 1.18

--- rc_proc.c    2002/08/02 20:09:59     1.17
+++ rc_proc.c    2003/04/03 12:05:14     1.18
@@ -152,25 +152,20 @@
 /* FIXME: Swap nested rcfile/section logic loops for section/rcfile ordering */
             for (i = 0; pRc->m_pAnal->m_pszSecs[i]; i++) { /* Iterate over */
                 /* Extract a section from the temp script, and append it */
-                szSec = scriptSection(pTempscript, pRc->m_pAnal->m_pszSecs[i]);
+                pSec = scriptSection(pTempscript, pRc->m_pAnal->m_pszSecs[i]);
 
-                if (szSec) { /* Only call if the section lookup succeeds */
-                    scriptAppend(ppParts[nIter], szSec, strlen(szSec));
+                if (pSec) { /* Only call if the section lookup succeeds */
+                    scriptAppend(ppParts[nIter], sectionGetdata(pSec),
+                        sectionGetlen(pSec) - 1);
                     scriptAppend(pRc->m_pScript, "\n", sizeof(char));
                 }
-/*                if (szSec) { -* Only call if the section lookup succeeds *-
-                    scriptAppend(pRc->m_pScript, szSec, strlen(szSec));
-                    scriptAppend(pRc->m_pScript, "\n", sizeof(char));
-                }
-                else if (configGetval(RC_DBG_VAL)) -* Only show if debug set *-
+                else if (configGetval(RC_DBG_VAL)) /* Only show if debug set */
                     fprintf(stderr, "#Warning: Missing section '%s' in %s!\n",\
                         pRc->m_pAnal->m_pszSecs[i],\
-                        pRc->m_pAnal->m_szRcs[nIter]);*/
+                        pRc->m_pAnal->m_szRcs[nIter]);
 
-                if (szSec) { /* Cleanup iterative section string */
-                    free(szSec);
-                    szSec = NULL;
-                }
+                if (pSec)   /* Cleanup iterative section string */
+                    sectionDelete(pSec);
             }
         }
         catch(Except)
@@ -192,6 +187,7 @@
             if (ppParts[nRept]) {
                 free(ppParts[nRept]);
                 ppParts[nRept] = NULL;
+            }
         }
         free(ppParts);
         ppParts = NULL;


ossp-pkg/rc/rc_script.c 1.11 -> 1.12

--- rc_script.c  2002/08/02 20:09:59     1.11
+++ rc_script.c  2003/04/03 12:05:14     1.12
@@ -50,11 +50,11 @@
     return(pScript);
 }
 
-/************************************************
-* scriptAppend(rc_script_t *, char *, size_t)   *
-* Append text to a script                       *
-************************************************/
-rc_return_t scriptAppend(rc_script_t *pScript, char *szInbuf, size_t Size)
+/****************************************************
+* scriptAppend(rc_script_t *, const char *, size_t) *
+* Append text to a script                           *
+****************************************************/
+rc_return_t scriptAppend(rc_script_t *pScript, const char *szInbuf, size_t Size)
 {
     int nResize     = 0;
     void *pvRealloc = NULL;
@@ -171,6 +171,8 @@
         piLabstart = piBlocend + *(pnVec + 2);
         nLabsize   = *(pnVec + 3) - *(pnVec + 2);
 
+fprintf(stderr, "Substring we want ist %s!\n", kszSecname);
+fprintf(stderr, "Compared with ist %s!\n", piLabstart);
         /* Test the substring. If it matches our label, make a new section */
         if (!strncmp(piLabstart, kszSecname, nLabsize)) {
             /* Handle the section body */


ossp-pkg/rc/rc_sect.c 1.1 -> 1.2

--- rc_sect.c    2002/08/02 16:38:09     1.1
+++ rc_sect.c    2003/04/03 12:05:14     1.2
@@ -28,6 +28,7 @@
 */
 
 #include <string.h> /* For string copy and such data ops */
+#include <stdlib.h> /* For memory ops */
 
 #include "rc.h"     /* Public Rc interface */
 
@@ -42,8 +43,10 @@
 
     /* Among other things, they make great coffee at Cable & Wireless */
     /* This code would probably have more bugs if the coffee was not as good */
-    pSec = (rc_section_t *)malloc(sizeof(rc_section_t));
-    *pSec = NULL;
+    pSec = (rc_section_t *)calloc(1, sizeof(rc_section_t));
+
+    if (!pSec)
+        RC_THROW(RC_ERR_MEM);
 
     return(pSec);
 }
@@ -82,6 +85,16 @@
     return(0); /* Not reached */
 }
 
+size_t sectionGetlen(rc_section_t *pSec)
+{ /* Data length of section, length of a script body of a particular section */
+    if (pSec)
+        return(pSec->Bytes);
+    else
+        RC_THROW(RC_ERR_USE);
+
+    return(0); /* Not reached */
+}
+
 /************************************************
 * sectionSetXXX(rc_section_t *)                 *
 * Accessor methods                              *
@@ -109,13 +122,14 @@
 rc_return_t sectionSetdata(rc_section_t *pSec, const char *kszScript)
 { /* Data of section, this is the script body of the particular section */
     if (pSec) {
+        pSec->Bytes = strlen(kszScript) + sizeof(char); /* Calculate size */
         if (pSec->szData) { /* The section data is already in use */
             free(pSec->szData);
-            pSec->szData = malloc(strlen(kszScript) + sizeof(char));
+            pSec->szData = malloc(pSec->szData);
             strcpy(pSec->szData, kszScript);
         }
         else { /* Set the data the usual way */
-            pSec->szData = malloc(strlen(kszScript) + sizeof(char));
+            pSec->szData = malloc(pSec->szData);
             strcpy(pSec->szData, kszScript);
         }
         return(RC_THROW(RC_OK));


ossp-pkg/rc/rc_test.sh 1.21 -> 1.22

--- rc_test.sh   2002/08/01 13:25:32     1.21
+++ rc_test.sh   2003/04/03 12:05:14     1.22
@@ -42,18 +42,24 @@
 #./rc -derv -L ./rc_test/rc.d/rc.%{RCFILE:s/^all$/*/} -c ./rc.conf -f ./rc_test/rcfuncs -t /tmp openssh stop sleep=4 start daily minsize=2097152
 
 # Test some long options, should fail for false combination usage
+#clear
 echo; echo "./rc --verbose --silent --print --NameConfig config --ParseSectionDef \"^%(\w+)[ \t]*(.*?)\n(.*?)^$\" uucp stop sleep=6 start"
 ./rc --verbose --silent --print --NameConfig config --ParseSectionDef "^%(\w+)[ \t]*(.*?)\n(.*?)^$" uucp stop sleep=6 start
+#read dummy;clear
 echo; echo "./rc --query myvar --silent --ParseSectionDef \"^%(\w+)[ \t]*(.*?)\n(.*?)^$\" zebra bing bang"
 ./rc --query myvar --silent --ParseSectionDef "^%(\w+)[ \t]*(.*?)\n(.*?)^$" zebra bing bang
+#read dummy;clear
 echo; echo "./rc --conf ./rc.conf --ParseSectionDef \"^<(.+?)[ \t]*(.*?)>\n*(.*?)^<\/\1>\" --locate ./rc_test/ --query this barf test"
 ./rc --conf ./rc.conf --ParseSectionDef "^<(.+?)[ \t]*(.*?)>\n*(.*?)^<\/\1>" --locate ./rc_test/ --query this barf test
+#read dummy;clear
 
 # Test minimal set of long options, should succeed
 echo; echo "./rc --debug --version --ParseSectionDef \"^<(.+?)[ \t]*(.*?)>\n*(.*?)^<\/\1>\" rsyncd nothing matters but the version"
 ./rc --debug --version --ParseSectionDef "^<(.+?)[ \t]*(.*?)>\n*(.*?)^<\/\1>" rsyncd nothing matters but the version
+#read dummy;clear
 echo; echo "./rc --conf $RCBASE/rc.conf --ParseSectionDef \"^%(\w+)[ \t]*(.*?)\n(.*?)^$\" --locate $RCBASE/rc.d:./rc_test:/etc/rc --query all barf test"
 ./rc --conf $RCBASE/rc.conf --ParseSectionDef "^%(\w+)[ \t]*(.*?)\n(.*?)^$" --locate $RCBASE/rc.d:./rc_test:/etc/rc --query all barf test
+#read dummy;clear
 
 # FIXME these cases are not handled yet by our configuration FIXME #
 #echo; echo "./rc --debug --version"
@@ -70,52 +76,69 @@
 
 echo; echo "./rc --func rc_test/rcfuncs --ParseSectionDef \"^%(\w+)[ \t]*(.*?)\n(.*?)^$\" --verbose openssh stop sleep=4 start"
 ./rc --func rc_test/rcfuncs --ParseSectionDef "^%(\w+)[ \t]*(.*?)\n(.*?)^$" --verbose openssh stop sleep=4 start
+#read dummy;clear
 echo; echo "./rc --func ./rc_test/rcfuncs --info --eval uucp restart"
 ./rc --func ./rc_test/rcfuncs --info --eval uucp restart
+#read dummy;clear
 echo; echo "./rc --conf rc_test/myrc.conf --func ./rc_test/rcfuncs --tmp /tmp --ParseSectionDef \"^<(.+?)[ \t]*(.*?)>\n*(.*?)^<\/\1>\" uucp start"
 ./rc --conf rc_test/myrc.conf --func ./rc_test/rcfuncs --tmp /tmp --ParseSectionDef "^<(.+?)[ \t]*(.*?)>\n*(.*?)^<\/\1>" uucp start
+#read dummy;clear
 echo; echo "./rc --conf ./rc_test/myrc.conf --func ./rc_test/rcfuncs --tmp /tmp --debug --ParseSectionDef \"^<(.+?)[ \t]*(.*?)>\n*(.*?)^<\/\1>\" ntp sync"
 ./rc --conf ./rc_test/myrc.conf --func ./rc_test/rcfuncs --tmp /tmp --debug --ParseSectionDef "^<(.+?)[ \t]*(.*?)>\n*(.*?)^<\/\1>" ntp sync
+#read dummy;clear
 echo; echo "./rc --conf ./rc_test/myrc.conf --func ./rc_test/rcfuncs --tmp /tmp --debug --silent --ParseSectionDef \"^<(.+?)[ \t]*(.*?)>\n*(.*?)^<\/\1>\" ralf feed suppe"
 ./rc --conf ./rc_test/myrc.conf --func ./rc_test/rcfuncs --tmp /tmp --debug --silent --ParseSectionDef "^<(.+?)[ \t]*(.*?)>\n*(.*?)^<\/\1>" ralf feed suppe
+#read dummy;clear
 echo; echo "./rc --conf ./rc_test/myrc.conf --func ./rc_test/rcfuncs -L rc_test --ParseSectionDef \"^%(\w+)[ \t]*(.*?)\n(.*?)^$\" --tmp /tmp --silent samba search finish destroy"
 ./rc --conf ./rc_test/myrc.conf --func ./rc_test/rcfuncs -L rc_test --ParseSectionDef "^%(\w+)[ \t]*(.*?)\n(.*?)^$" --tmp /tmp --silent samba search finish destroy
+#read dummy;clear
 
 echo; echo "./rc --conf ./rc_test/myrc.conf --func ./rc_test/rcfuncs -L ./rc_test --ParseSectionDef \"^%(\w+)[ \t]*(.*?)\n(.*?)^$\" --tmp /tmp --silent all feed suppe"
 ./rc --conf ./rc_test/myrc.conf --func ./rc_test/rcfuncs -L ./rc_test --ParseSectionDef "^%(\w+)[ \t]*(.*?)\n(.*?)^$" --tmp /tmp --silent all feed suppe
+#read dummy;clear
 
 echo; echo "./rc --conf ./rc_test/myrc.conf --func ./rc_test/rcfuncs -L $RCBASE/rc.d --ParseSectionDef \"^%(\w+)[ \t]*(.*?)\n(.*?)^$\" --tmp /tmp --silent --debug all config barf gag"
 ./rc --conf ./rc_test/myrc.conf --func ./rc_test/rcfuncs -L $RCBASE/rc.d --ParseSectionDef "^%(\w+)[ \t]*(.*?)\n(.*?)^$" --tmp /tmp --silent --debug all config barf gag
+#read dummy;clear
 
 echo; echo "./rc --conf ./rc_test/myrc.conf --func ./rc_test/rcfuncs -L $RCBASE/rc.d --ParseSectionDef \"^%(\w+)[ \t]*(.*?)\n(.*?)^$\" --tmp /tmp --silent --debug --eval all config start"
 ./rc --conf ./rc_test/myrc.conf --func ./rc_test/rcfuncs -L $RCBASE/rc.d --ParseSectionDef "^%(\w+)[ \t]*(.*?)\n(.*?)^$" --tmp /tmp --silent --debug --eval all config start
+#read dummy;clear
 
 #echo; echo "./rc --conf ./rc_test/myrc.conf --func ./rc_test/rcfuncs -L $RCBASE/rc.d --ParseSectionDef \"^%(\w+)[ \t]*(.*?)\n(.*?)^$\" --tmp /tmp --silent --debug --exec all config start"
 #./rc --conf ./rc_test/myrc.conf --func ./rc_test/rcfuncs -L $RCBASE/rc.d --ParseSectionDef "^%(\w+)[ \t]*(.*?)\n(.*?)^$" --tmp /tmp --silent --debug --exec all config start
 
 echo; echo "./rc --conf ./rc_test/myrc.conf --func ./rc_test/rcfuncs -L $RCBASE/rc.d --ParseSectionDef \"%(.+)\" --tmp /tmp --silent --print --debug pam info"
 ./rc --conf ./rc_test/myrc.conf --func ./rc_test/rcfuncs -L $RCBASE/rc.d --ParseSectionDef "%(.+)" --tmp /tmp --silent --print --debug pam info
+#read dummy;clear
 
 echo; echo "./rc --conf ./rc_test/myrc.conf --func ./rc_test/rcfuncs -L $RCBASE/rc.d --ParseSectionDef \"%(.+)\" --tmp /tmp --silent --debug apache config start"
 ./rc --conf ./rc_test/myrc.conf --func ./rc_test/rcfuncs -L $RCBASE/rc.d --ParseSectionDef "%(.+)" --tmp /tmp --silent --debug apache config start
+#read dummy;clear
 
 echo; echo "./rc --conf ./rc_test/myrc.conf --func ./rc_test/rcfuncs -L ./rc_test/ --ParseSectionDef \"^<(.+?)[ \t]*(.*?)>\n*(.*?)^<\/\1>\" --tmp /tmp --silent --debug all config start"
 ./rc --conf ./rc_test/myrc.conf --func ./rc_test/rcfuncs -L ./rc_test/ --ParseSectionDef "^<(.+?)[ \t]*(.*?)>\n*(.*?)^<\/\1>" --tmp /tmp --silent --debug all config start
+#read dummy;clear
 
 echo; echo "./rc --conf ./rc_test/myrc.conf --func ./rc_test/rcfuncs -L ./rc_test/ --ParseSectionDef \"^<(.+?)[ \t]*(.*?)>\n*(.*?)^<\/\1>\" --tmp /tmp --silent --debug pam info"
 ./rc --conf ./rc_test/myrc.conf --func ./rc_test/rcfuncs -L ./rc_test/ --ParseSectionDef "^<(.+?)[ \t]*(.*?)>\n*(.*?)^<\/\1>" --tmp /tmp --silent --debug pam info
+#read dummy;clear
 
 echo; echo "./rc --conf ./rc_test/myrc.conf --func $RCBASE/rc.func -L $RCBASE/rc.d/ --ParseSectionDef \"^%(\w+)[ \t]*(.*?)\n(.*?)^$\" --tmp /tmp --silent --debug dhcpd start"
 ./rc --conf ./rc_test/myrc.conf --func $RCBASE/rc.func -L $RCBASE/rc.d/ --ParseSectionDef "^%(\w+)[ \t]*(.*?)\n(.*?)^$" --tmp /tmp --silent --debug dhcpd start
+#read dummy;clear
 
 echo; echo "./rc --func ./rc_test/rcfuncs --exec --ParseSectionDef \"^<(.+?)[ \t]*(.*?)>\n*(.*?)^<\/\1>\" -L ./rc_test pam autre"
 ./rc --func ./rc_test/rcfuncs --exec --ParseSectionDef "^<(.+?)[ \t]*(.*?)>\n*(.*?)^<\/\1>" -L ./rc_test pam autre
+#read dummy;clear
 
 echo; echo "./rc --func ./rc_test/rcfuncs -L ./rc_test/ dhcpd stop"
 ./rc --func ./rc_test/rcfuncs -L ./rc_test/ dhcpd stop
+#read dummy;clear
 
 echo; echo "./rc --exec --func ./rc_test/rcfuncs -L ./rc_test/ dhcpd gotest"
 ./rc --exec --func ./rc_test/rcfuncs -L ./rc_test/ dhcpd gotest
+#read dummy;clear
 
 # Next milestone
 #RequireOwner


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

--- rc.dhcpd     2002/08/01 14:31:39     1.2
+++ rc.dhcpd     2003/04/03 12:05:16     1.3
@@ -11,6 +11,7 @@
     /sw/sbin/dhcpd
 
 %gotest
+    echo "Doing gotest section in file rc.dhcpd"
     ping -a -c 4 dt1.dev.de.cw.net
     curl -s ftp://ftp.openpkg.org/current/SRC/ | grep openssl
     date

CVSTrac 2.0.1