--- rc_proc.c 2003/06/30 15:09:46 1.52
+++ rc_proc.c 2003/06/30 15:27:38 1.53
@@ -276,6 +276,8 @@
pFatscript = NULL;
}
else if (configGetval(RC_EXC_VAL)) { /* Execute */
+ int nStat; /* Used for reporting status on return of a forked child */
+
/* This block does nothing more than implement the feature, */
/* that allows rc to run unprivileged (as long as no privileged */
/* code is used in the script sections to be executed */
@@ -392,7 +394,7 @@
szVerbose = NULL;
/* Spawn the section shell code */
- switch (Pidexec = fork()){
+ switch (Pidexec = fork()) {
case -1: /* Broken */
return(RC_THROW(RC_ERR_INT));
break; /* Huh? */
@@ -400,12 +402,14 @@
nSectuid = sectionGetuid(ppSectmp[nTmp]);
if (nSectuid >= 0 && getuid() != nSectuid)
if (setuid(nSectuid) != 0)
- return(RC_THROW(RC_ERR_INT));
+ return(RC_THROW(RC_ERR_ROOT));
if (execvp(*pszVec, pszVec) == -1)
return(RC_THROW(RC_ERR_INT));
break;
default: /* Parent, blocks until child returns */
- waitpid(Pidexec, NULL, WUNTRACED);
+ waitpid(Pidexec, &nStat, WUNTRACED);
+ if ((nStat = WEXITSTATUS(nStat)) != 0)
+ return(nStat);
break;
}
if (szExec) {
@@ -443,12 +447,14 @@
nSectuid = sectionGetuid(ppSectmp[nTmp]);
if (nSectuid >= 0 && getuid() != nSectuid)
if (setuid(nSectuid) != 0)
- return(RC_THROW(RC_ERR_INT));
+ return(RC_THROW(RC_ERR_ROOT));
if (execvp(*pszVec, pszVec) == -1)
return(RC_THROW(RC_ERR_INT));
break;
default: /* Parent, blocks until child returns */
- waitpid(Pidexec, NULL, WUNTRACED);
+ waitpid(Pidexec, &nStat, WUNTRACED);
+ if ((nStat = WEXITSTATUS(nStat)) != 0)
+ return(nStat);
break;
}
free(szExec); /* Cleanup after exec */
|