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++) {
ipath = NULL;
if(!strchr(inm, '.') && ((dir = opendir(path)) != NULL)) {
while((dent = readdir(dir)) != NULL) {
+ /* Ignore backup files.
+ * XXX: There is probably a better and more
+ * extensible way to do this. */
+ if(dent->d_name[strlen(dent->d_name) - 1] == '~')
+ continue;
if((p = strchr(dent->d_name, '.')) == NULL)
continue;
if(strncmp(dent->d_name, inm, strlen(inm)))
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)
if(!strchr(p, '.') && ((dir = opendir(path)) != NULL)) {
while((dent = readdir(dir)) != NULL) {
buf = sprintf3("%s/%s", path, dent->d_name);
+ /* Ignore backup files.
+ * XXX: There is probably a better and more
+ * extensible way to do this. */
+ if(dent->d_name[strlen(dent->d_name) - 1] == '~')
+ continue;
if((p3 = strchr(dent->d_name, '.')) != NULL)
*p3 = 0;
if(strcmp(dent->d_name, p))
{
int c;
int nodef;
- char *gcf, *lcf;
+ char *gcf, *lcf, *clcf;
struct hthead *req;
int fd;
}
}
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));