X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fpatplex.c;h=a0818d2bd68cee1d5951f9385167738656745b19;hb=518c678c21a99f4b148f3cb1f40afe8b51577082;hp=b03b626614c9c79f3440e5da00042ec885d45bd2;hpb=acc2d159e6f946ed6abc7c0e843a483d6478bee3;p=ashd.git diff --git a/src/patplex.c b/src/patplex.c index b03b626..a0818d2 100644 --- a/src/patplex.c +++ b/src/patplex.c @@ -249,13 +249,16 @@ static struct pattern *parsepattern(struct cfstate *s) if(pat->restpat != NULL) free(pat->restpat); pat->restpat = sstrdup(s->argv[1]); - } else if(!strcmp(s->argv[0], "set")) { + } else if(!strcmp(s->argv[0], "set") || !strcmp(s->argv[0], "xset")) { if(s->argc < 3) { - flog(LOG_WARNING, "%s:%i: missing header name or pattern for `set' directive", s->file, s->lno); + flog(LOG_WARNING, "%s:%i: missing header name or pattern for `%s' directive", s->file, s->lno, s->argv[0]); continue; } omalloc(head); - head->name = sstrdup(s->argv[1]); + if(!strcmp(s->argv[0], "xset")) + head->name = sprintf2("X-Ash-%s", s->argv[1]); + else + head->name = sstrdup(s->argv[1]); head->value = sstrdup(s->argv[2]); head->next = pat->headers; pat->headers = head; @@ -488,10 +491,12 @@ static void reloadconf(char *nm) static void chldhandler(int sig) { pid_t pid; + int st; - do { - pid = waitpid(-1, NULL, WNOHANG); - } while(pid > 0); + while((pid = waitpid(-1, &st, WNOHANG)) > 0) { + if(WCOREDUMP(st)) + flog(LOG_WARNING, "child process %i dumped core", pid); + } } static void sighandler(int sig) @@ -509,7 +514,7 @@ int main(int argc, char **argv) { int c; int nodef; - char *gcf; + char *gcf, *lcf; struct hthead *req; int fd; @@ -537,8 +542,14 @@ int main(int argc, char **argv) free(gcf); } } - if((lconfig = readconfig(argv[optind])) == NULL) { - flog(LOG_ERR, "could not read `%s'", argv[optind]); + if((strchr(lcf = argv[optind], '/')) == NULL) { + if((lcf = findstdconf(sprintf3("ashd/%s", lcf))) == NULL) { + flog(LOG_ERR, "could not find requested configuration file `%s'", argv[optind]); + exit(1); + } + } + if((lconfig = readconfig(lcf)) == NULL) { + flog(LOG_ERR, "could not read `%s'", lcf); exit(1); } signal(SIGCHLD, chldhandler); @@ -546,7 +557,7 @@ int main(int argc, char **argv) signal(SIGPIPE, sighandler); while(1) { if(reload) { - reloadconf(argv[optind]); + reloadconf(lcf); reload = 0; } if((fd = recvreq(0, &req)) < 0) {