Index: ossp-pkg/rc/00TODO RCS File: /v/ossp/cvs/ossp-pkg/rc/00TODO,v rcsdiff -q -kk '-r1.31' '-r1.32' -u '/v/ossp/cvs/ossp-pkg/rc/00TODO,v' 2>/dev/null --- 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. Index: ossp-pkg/rc/rc.h RCS File: /v/ossp/cvs/ossp-pkg/rc/rc.h,v rcsdiff -q -kk '-r1.36' '-r1.37' -u '/v/ossp/cvs/ossp-pkg/rc/rc.h,v' 2>/dev/null --- 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 */ Index: ossp-pkg/rc/rc_private.h RCS File: /v/ossp/cvs/ossp-pkg/rc/rc_private.h,v rcsdiff -q -kk '-r1.18' '-r1.19' -u '/v/ossp/cvs/ossp-pkg/rc/rc_private.h,v' 2>/dev/null --- 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 */ Index: ossp-pkg/rc/rc_proc.c RCS File: /v/ossp/cvs/ossp-pkg/rc/rc_proc.c,v rcsdiff -q -kk '-r1.13' '-r1.14' -u '/v/ossp/cvs/ossp-pkg/rc/rc_proc.c,v' 2>/dev/null --- 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)); } Index: ossp-pkg/rc/rc_script.c RCS File: /v/ossp/cvs/ossp-pkg/rc/rc_script.c,v rcsdiff -q -kk '-r1.7' '-r1.8' -u '/v/ossp/cvs/ossp-pkg/rc/rc_script.c,v' 2>/dev/null --- 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 * ************************************************/ Index: ossp-pkg/rc/rc_test.sh RCS File: /v/ossp/cvs/ossp-pkg/rc/rc_test.sh,v rcsdiff -q -kk '-r1.19' '-r1.20' -u '/v/ossp/cvs/ossp-pkg/rc/rc_test.sh,v' 2>/dev/null --- 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 Index: ossp-pkg/rc/rc_test/rc.dhcpd RCS File: /v/ossp/cvs/ossp-pkg/rc/rc_test/rc.dhcpd,v co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/rc/rc_test/rc.dhcpd,v' | diff -u /dev/null - -L'ossp-pkg/rc/rc_test/rc.dhcpd' 2>/dev/null --- ossp-pkg/rc/rc_test/rc.dhcpd +++ - 2024-05-06 09:11:48.244844477 +0200 @@ -0,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 +