#include "config.h" #include #include #include #include #include #include #include #include #include #include #include "run_part.h" #include "shadowlog_internal.h" #include "string/sprintf/aprintf.h" #include "string/strerrno.h" static int run_part(char *script_path, const char *name, const char *action) { pid_t pid; int wait_status; pid_t pid_status; char *args[] = { script_path, NULL }; pid=fork(); if (pid==-1) { fprintf(shadow_logfd, "fork: %s\n", strerrno()); return 1; } if (pid==0) { setenv("ACTION",action,1); setenv("SUBJECT",name,1); execv(script_path,args); fprintf(shadow_logfd, "execv: %s\n", strerrno()); _exit(1); } pid_status = wait(&wait_status); if (pid_status == pid) { return (wait_status); } fprintf(shadow_logfd, "wait: %s\n", strerrno()); return (1); } int run_parts(const char *directory, const char *name, const char *action) { struct dirent **namelist; int scanlist; int n; int execute_result = 0; scanlist = scandir(directory, &namelist, NULL, alphasort); if (scanlist<=0) { return (0); } for (n=0; nd_name); if (s == NULL) { fprintf(shadow_logfd, "aprintf: %s\n", strerrno()); for (; nd_name); for (; n