X-Git-Url: http://www.dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fdirplex.c;h=8e4ae11629a61bc695c03f53e8d3ba377a842add;hb=9bebca54879412ae5879695800ceac77eb2c805c;hp=d596df09045d78bd86ec24693a3bffda4076abcd;hpb=8232cebe1da1a5f2341d4acd4b57dc9cbc1bc6b8;p=ashd.git diff --git a/src/dirplex.c b/src/dirplex.c index d596df0..8e4ae11 100644 --- a/src/dirplex.c +++ b/src/dirplex.c @@ -444,13 +444,13 @@ static void handledir(struct hthead *req, int fd, char *path) struct config **cfs; int i, o; struct stat sb; - char *inm, *ipath, *p; + char *inm, *ipath, *p, *cpath; DIR *dir; struct dirent *dent; struct pattern *pat; - path = sprintf2("%s/", path); - cfs = getconfigs(path); + cpath = sprintf2("%s/", path); + cfs = getconfigs(cpath); for(i = 0; cfs[i] != NULL; i++) { if(cfs[i]->index != NULL) { for(o = 0; cfs[i]->index[o] != NULL; o++) { @@ -489,14 +489,14 @@ static void handledir(struct hthead *req, int fd, char *path) break; } } - if((pat = findmatch(path, 0, 1)) != NULL) { - handle(req, fd, path, pat); + if((pat = findmatch(cpath, 0, 1)) != NULL) { + handle(req, fd, cpath, pat); goto out; } simpleerror(fd, 403, "Not Authorized", "Will not send listings for this directory."); out: - free(path); + free(cpath); } static int checkdir(struct hthead *req, int fd, char *path) @@ -640,7 +640,7 @@ int main(int argc, char **argv) { int c; int nodef; - char *gcf, *lcf; + char *gcf, *lcf, *clcf; struct hthead *req; int fd; @@ -673,8 +673,18 @@ int main(int argc, char **argv) } } if(lcf != NULL) { - if((lconfig = readconfig(lcf)) == NULL) - exit(1); + if(strchr(lcf, '/') == NULL) { + if((clcf = findstdconf(sprintf3("ashd/%s", lcf))) == NULL) { + flog(LOG_ERR, "could not find requested configuration `%s'", lcf); + exit(1); + } + if((lconfig = readconfig(clcf)) == NULL) + exit(1); + free(clcf); + } else { + if((lconfig = readconfig(lcf)) == NULL) + exit(1); + } } if(chdir(argv[optind])) { flog(LOG_ERR, "could not change directory to %s: %s", argv[optind], strerror(errno));