X-Git-Url: http://www.dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fdirplex%2Fdirplex.c;h=31920e625e717bab485ae6e56a6058c003674fd3;hb=fd735432ca61308348e1f1eb1b79a42e357aa0b7;hp=7f2a12d2bde3dd0144431a9624b1ce0493234918;hpb=da75c835b71b9ed9cf1d2c8fcbcfb7631dd24a05;p=ashd.git diff --git a/src/dirplex/dirplex.c b/src/dirplex/dirplex.c index 7f2a12d..31920e6 100644 --- a/src/dirplex/dirplex.c +++ b/src/dirplex/dirplex.c @@ -217,9 +217,34 @@ static int checkentry(struct hthead *req, int fd, char *path, char *rest, char * return(0); } +static int checkdir(struct hthead *req, int fd, char *path, char *rest) +{ + char *cpath; + struct config *cf, *ccf; + struct child *ch; + + cf = getconfig(path); + if(cf->capture != NULL) { + cpath = sprintf2("%s/", path); + if((ch = findchild(cpath, cf->capture, &ccf)) == NULL) { + free(cpath); + flog(LOG_ERR, "child %s requested for capture, but was not declared", cf->capture); + simpleerror(fd, 500, "Configuration Error", "The server is erroneously configured. Handler %s was requested, but not declared.", cf->capture); + return(1); + } + free(cpath); + if(*rest == '/') + rest++; + replrest(req, rest); + if(childhandle(ch, req, fd, chinit, ccf->path)) + simpleerror(fd, 500, "Server Error", "The request handler crashed."); + return(1); + } + return(0); +} + static int checkpath(struct hthead *req, int fd, char *path, char *rest) { - struct config *cf; char *p, *el; int rv; @@ -228,7 +253,8 @@ static int checkpath(struct hthead *req, int fd, char *path, char *rest) if(!strncmp(path, "./", 2)) path += 2; - cf = getconfig(path); + if(checkdir(req, fd, path, rest)) + return(1); if((p = strchr(rest, '/')) == NULL) { el = unquoteurl(rest); @@ -270,6 +296,10 @@ static void serve(struct hthead *req, int fd) simpleerror(fd, 404, "Not Found", "The requested URL has no corresponding resource."); } +static void sighandler(int sig) +{ +} + static void usage(FILE *out) { fprintf(out, "usage: dirplex [-hN] [-c CONFIG] DIR\n"); @@ -330,6 +360,7 @@ int main(int argc, char **argv) exit(1); } signal(SIGCHLD, SIG_IGN); + signal(SIGPIPE, sighandler); while(1) { if((fd = recvreq(0, &req)) < 0) { if(errno != 0)