X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=src%2Fdirplex.c;h=75ff4a41806aab3ad7e436fb6b2b99e1c5e6c08b;hb=3e05e989dbb6375304b31ea562b9b3f7378a2353;hp=60f0859ddcb86d41560fcd4b75fdbb9d54472e45;hpb=13975be5892675874bea8c86d7d8140f5790e7e6;p=ashd.git diff --git a/src/dirplex.c b/src/dirplex.c index 60f0859..75ff4a4 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++) { @@ -466,6 +466,11 @@ static void handledir(struct hthead *req, int fd, char *path) 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))) @@ -489,14 +494,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) @@ -583,6 +588,11 @@ static void serve(struct hthead *req, int fd) 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))