OSSP CVS Repository

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

Check-in Number: 2433
Date: 2002-Jul-30 18:36:41 (local)
2002-Jul-30 16:36:41 (UTC)
User:ms
Branch:
Comment: Implemented command execution mode, and now OSSP rc is dangerous to use because it will actually execute code. Test suite is adjusted accordingly.
Tickets:
Inspections:
Files:
ossp-pkg/rc/00TODO      1.31 -> 1.32     1 inserted, 0 deleted
ossp-pkg/rc/rc.h      1.36 -> 1.37     1 inserted, 0 deleted
ossp-pkg/rc/rc_private.h      1.18 -> 1.19     1 inserted, 0 deleted
ossp-pkg/rc/rc_proc.c      1.13 -> 1.14     23 inserted, 7 deleted
ossp-pkg/rc/rc_script.c      1.7 -> 1.8     14 inserted, 0 deleted
ossp-pkg/rc/rc_test.sh      1.19 -> 1.20     7 inserted, 4 deleted
ossp-pkg/rc/rc_test/rc.dhcpd      added-> 1.1

ossp-pkg/rc/00TODO 1.31 -> 1.32

--- 00TODO       2002/07/29 16:33:48     1.31
+++ 00TODO       2002/07/30 16:36:41     1.32
@@ -6,6 +6,7 @@
   What when multiple command interpreters and one --print or --eval given?
   File rc.func totally undocumented, but logic should be clear.
   Check combo options for correctness, like config contains exc, evl, prn.
+  Consider forking at rc_proc.c:procRun/exec so rc keeps in control afterwards.
   Control flow
     Explain logical ordering of multiple section spanning multiple rcfiles.
     Give example semantics of a common scenario.


ossp-pkg/rc/rc.h 1.36 -> 1.37

--- rc.h 2002/07/29 16:34:58     1.36
+++ rc.h 2002/07/30 16:36:41     1.37
@@ -114,6 +114,7 @@
 rc_return_t scriptAppend(rc_script_t *, char *, size_t);
 char *scriptSection(rc_script_t *, const char *);
 rc_return_t scriptDump(rc_script_t *);
+const char *scriptTostring(rc_script_t *);
 rc_return_t scriptDelete(rc_script_t *);
 
 /* Processor function prototypes */


ossp-pkg/rc/rc_private.h 1.18 -> 1.19

--- rc_private.h 2002/07/04 16:49:58     1.18
+++ rc_private.h 2002/07/30 16:36:41     1.19
@@ -51,6 +51,7 @@
 
 #define RC_SEC_SUB         1
 #define RC_GOOD_MEASURE    8
+#define RC_EXEC_MAXARGS    8
 #define RC_READ_BUFSIZE 1024
 #define RC_STR_ID  "OSSP rc"                        /* APPID for OSSP rc */
 #define RC_UID_ID 0xf8a1845c55e6449481176f6e9cea34b /* UUID for OSSP rc  */


ossp-pkg/rc/rc_proc.c 1.13 -> 1.14

--- rc_proc.c    2002/07/10 19:03:58     1.13
+++ rc_proc.c    2002/07/30 16:36:41     1.14
@@ -189,17 +189,33 @@
 ************************************************/
 rc_return_t procRun(rc_proc_t *pRc)
 {
-    /* This will evaluate, execute, or print the script to stdout */
-    if (configGetval(RC_EVL_VAL))       /* Evaluate */
+    char *pszVec[RC_EXEC_MAXARGS];
+
+    /****************************************************/
+    /* This will execute, evaluate, or print the script */
+    /* Exec  - Fork and execute each command            */
+    /* Eval  - Print machine evaluatable format         */
+    /* Print - Print human readable format              */
+    /****************************************************/
+    if (configGetval(RC_EVL_VAL))        /* Evaluate */
         fprintf(stderr, "Error: Evaluate is not implemented yet.\n"); /* FIX */
-    else if (configGetval(RC_EXC_VAL))  /* Execute  */
-        fprintf(stderr, "Error: Execute is not implemented yet.\n");  /* FIX */
-    else if (configGetval(RC_PRN_VAL))  /* Print    */
+
+    else if (configGetval(RC_EXC_VAL)) { /* Execute  */
+            pszVec[0] = "/bin/sh";
+            pszVec[1] = "-c";
+            pszVec[2] = (char *)scriptTostring(pRc->m_pScript);
+            pszVec[3] = NULL;   /* Add a NULL to mark the end of the chain */
+        if (execvp(*pszVec, pszVec) == -1)  /* launch                   */
+            TRACE("Bad, execvp in child returned -1");
+    }
+
+    else if (configGetval(RC_PRN_VAL))   /* Print    */
         scriptDump(pRc->m_pScript);
-    else                                /* Something is wrong here, there is */
+
+    else                                 /* Something is wrong here */
         fprintf(stderr, "Error: Placeholder, until problem with ex_ is fixed.\n");
 /* FIXME!!: Ralf, following segfaults in ex */
-/*        return(RC_THROW(RC_ERR_INT));*/   /* probably no default in the config */
+/*        return(RC_THROW(RC_ERR_INT));*/
 
     return(RC_THROW(RC_OK));
 }


ossp-pkg/rc/rc_script.c 1.7 -> 1.8

--- rc_script.c  2002/07/10 19:03:58     1.7
+++ rc_script.c  2002/07/30 16:36:41     1.8
@@ -180,6 +180,20 @@
 }
 
 /************************************************
+* scriptTostring(rc_script_t *)                 *
+* Return the private script data as a string    *
+************************************************/
+const char *scriptTostring(rc_script_t *pScript)
+{
+    /* Don't remove this! It encapsulates the script object, */
+    /*                    which might not be a simple string */
+    if (pScript)
+        return(*pScript);
+    else
+        return(NULL);
+}
+
+/************************************************
 * scriptDump(rc_script_t *)                    *
 * Print a script to standard out                *
 ************************************************/


ossp-pkg/rc/rc_test.sh 1.19 -> 1.20

--- rc_test.sh   2002/07/29 16:34:21     1.19
+++ rc_test.sh   2002/07/30 16:36:41     1.20
@@ -90,8 +90,8 @@
 echo; echo "./rc --conf ./rc_test/myrc.conf --func ./rc_test/rcfuncs -L $RCBASE/rc.d --ParseSectionDef \"^%(\w+).*?\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+).*?\n(.*?)^$" --tmp /tmp --silent --debug --eval all config start
 
-echo; echo "./rc --conf ./rc_test/myrc.conf --func ./rc_test/rcfuncs -L $RCBASE/rc.d --ParseSectionDef \"^%(\w+).*?\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+).*?\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 \"^%(\w+).*?\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+).*?\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
@@ -111,8 +111,11 @@
 echo; echo "./rc --func ./rc_test/rcfuncs -L ./rc_test/ --ParseSectionDef \"^<(.+?)\s*.*?>\n*(.*?)^<\/\1>\" pam info"
 ./rc --func ./rc_test/rcfuncs -L ./rc_test/ --ParseSectionDef "^<(.+?)\s*.*?>\n*(.*?)^<\/\1>" pam info
 
-echo; echo "./rc --func ./rc_test/rcfuncs -L ./rc_test/ ntp stop"
-./rc --func ./rc_test/rcfuncs -L ./rc_test/ ntp stop
+echo; echo "./rc --func ./rc_test/rcfuncs -L ./rc_test/ dhcpd stop"
+./rc --func ./rc_test/rcfuncs -L ./rc_test/ dhcpd stop
+
+echo; echo "./rc --exec --func ./rc_test/rcfuncs -L ./rc_test/ dhcpd gotest"
+./rc --exec --func ./rc_test/rcfuncs -L ./rc_test/ dhcpd gotest
 
 # Next milestone
 #RequireOwner


ossp-pkg/rc/rc_test/rc.dhcpd -> 1.1

*** /dev/null    Sat Nov 23 01:34:11 2024
--- -    Sat Nov 23 01:34:16 2024
***************
*** 0 ****
--- 1,25 ----
+ #! /bin/sh
+ 
+ echo "Run commands DHCPD starting"
+ 
+ %config
+     dhcpd_enable="yes"
+ 
+ %start -p 200 -u root
+     opServiceEnabled dhcpd || exit 0
+     /sw/sbin/dhcpd
+ 
+ %gotest
+     ping -a -c 4 dt1.dev.de.cw.net
+     curl -s ftp://ftp.openpkg.org/current/SRC/ | grep openssl
+     date
+     echo $0
+ #    cat $0
+ 
+ %stop -p 200 -u root
+     opServiceEnabled dhcpd || exit 0
+     kill -TERM `cat /sw/var/dhcpd/dhcpd.pid`
+ 
+ echo "Run commands DHCPD finishing"
+ echo
+ 

CVSTrac 2.0.1