Dolda2000 GitWeb
/
ashd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make htparser exit when the root multiplexer exits.
[ashd.git]
/
src
/
dirplex.c
diff --git
a/src/dirplex.c
b/src/dirplex.c
index
45d8a11
..
063fbb4
100644
(file)
--- a/
src/dirplex.c
+++ b/
src/dirplex.c
@@
-34,6
+34,7
@@
#include <log.h>
#include <req.h>
#include <proc.h>
#include <log.h>
#include <req.h>
#include <proc.h>
+#include <resp.h>
#define CH_SOCKET 0
#define CH_FORK 1
#define CH_SOCKET 0
#define CH_FORK 1
@@
-149,7
+150,7
@@
static struct rule *newrule(struct pattern *pat)
for(i = 0; pat->rules[i]; i++);
pat->rules = srealloc(pat->rules, sizeof(*pat->rules) * (i + 2));
for(i = 0; pat->rules[i]; i++);
pat->rules = srealloc(pat->rules, sizeof(*pat->rules) * (i + 2));
- rule = pat->rules[i] = smalloc(sizeof(*rule));
+ rule = pat->rules[i] = s
z
malloc(sizeof(*rule));
pat->rules[i + 1] = NULL;
return(rule);
}
pat->rules[i + 1] = NULL;
return(rule);
}
@@
-180,9
+181,10
@@
static struct config *readconfig(char *path)
struct rule *rule;
struct stat sb;
struct rule *rule;
struct stat sb;
- if(stat(path, &sb))
+ p = sprintf3("%s/.htrc", path);
+ if(stat(p, &sb))
return(NULL);
return(NULL);
- if((s = fopen(
sprintf3("%s/.htrc", path)
, "r")) == NULL)
+ if((s = fopen(
p
, "r")) == NULL)
return(NULL);
omalloc(cf);
cf->mtime = sb.st_mtime;
return(NULL);
omalloc(cf);
cf->mtime = sb.st_mtime;
@@
-331,7
+333,7
@@
static struct config *getconfig(char *path)
for(cf = cflist; cf != NULL; cf = cf->next) {
if(!strcmp(cf->path, path)) {
for(cf = cflist; cf != NULL; cf = cf->next) {
if(!strcmp(cf->path, path)) {
- if(stat(
path
, &sb))
+ if(stat(
sprintf3("%s/.htrc", path)
, &sb))
return(NULL);
if(sb.st_mtime != cf->mtime) {
freeconfig(cf);
return(NULL);
if(sb.st_mtime != cf->mtime) {
freeconfig(cf);
@@
-453,8
+455,8
@@
static void handlefile(struct hthead *req, int fd, char *path)
return;
}
if((ch = findchild(path, pat->childnm)) == NULL) {
return;
}
if((ch = findchild(path, pat->childnm)) == NULL) {
- /* XXX: Send a 500 error. */
flog(LOG_ERR, "child %s requested, but was not declared", pat->childnm);
flog(LOG_ERR, "child %s requested, but was not declared", pat->childnm);
+ simpleerror(fd, 500, "Configuration Error", "The server is erroneously configured. Handler %s was requested, but not declared.", pat->childnm);
return;
}
return;
}
@@
-467,6
+469,8
@@
static void handlefile(struct hthead *req, int fd, char *path)
static void handledir(struct hthead *req, int fd, char *path)
{
static void handledir(struct hthead *req, int fd, char *path)
{
+ /* XXX: Todo */
+ simpleerror(fd, 403, "Not Authorized", "Will not send directory listings or indices yet");
}
static int checkdir(struct hthead *req, int fd, char *path)
}
static int checkdir(struct hthead *req, int fd, char *path)
@@
-494,15
+498,19
@@
static void serve(struct hthead *req, int fd)
if(p2 == NULL) {
if(stat(path, &sb)) {
flog(LOG_WARNING, "failed to stat previously stated directory %s: %s", path, strerror(errno));
if(p2 == NULL) {
if(stat(path, &sb)) {
flog(LOG_WARNING, "failed to stat previously stated directory %s: %s", path, strerror(errno));
+ simpleerror(fd, 500, "Internal Server Error", "The server encountered an unexpected condition.");
goto fail;
}
break;
} else {
goto fail;
}
break;
} else {
+ simpleerror(fd, 404, "Not Found", "The requested URL has no corresponding resource.");
goto fail;
}
}
goto fail;
}
}
- if(*p == '.')
+ if(*p == '.') {
+ simpleerror(fd, 404, "Not Found", "The requested URL has no corresponding resource.");
goto fail;
goto fail;
+ }
getconfig(path);
getconfig(path);
@@
-528,6
+536,7
@@
static void serve(struct hthead *req, int fd)
free(tmp);
break;
}
free(tmp);
break;
}
+ simpleerror(fd, 404, "Not Found", "The requested URL has no corresponding resource.");
goto fail;
}
goto fail;
}
@@
-555,6
+564,7
@@
static void serve(struct hthead *req, int fd)
break;
}
break;
}
+ simpleerror(fd, 404, "Not Found", "The requested URL has no corresponding resource.");
goto fail;
next:
goto fail;
next:
@@
-573,12
+583,13
@@
static void serve(struct hthead *req, int fd)
} else if(S_ISREG(sb.st_mode)) {
handlefile(req, fd, path);
} else {
} else if(S_ISREG(sb.st_mode)) {
handlefile(req, fd, path);
} else {
+ simpleerror(fd, 404, "Not Found", "The requested URL has no corresponding resource.");
goto fail;
}
goto out;
fail:
goto fail;
}
goto out;
fail:
- /*
XXX: Send error repor
t. */
+ /*
No special handling, for now at leas
t. */
out:
free(path);
}
out:
free(path);
}