aboutsummaryrefslogtreecommitdiff
path: root/server.c
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2021-05-15 10:31:43 +0000
committerOmar Polo <op@omarpolo.com>2021-05-15 10:31:43 +0000
commit1feaf2a618ee1c4771fee80ced7acf31fe40fdae (patch)
treea5953a40af0f3c434a788248aacc0ede3b718818 /server.c
parent91b9f2a8f9d39f2fb842c33049d966777027e5f4 (diff)
use the correct document root
pass the correct loc_off to the executor, so the various variables that depends on the matched location (like DOCUMENT_ROOT) are computed correctly.
Diffstat (limited to 'server.c')
-rw-r--r--server.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/server.c b/server.c
index b7a71f4..514782b 100644
--- a/server.c
+++ b/server.c
@@ -222,20 +222,25 @@ vhost_fastcgi(struct vhost *v, const char *path)
}
int
-vhost_dirfd(struct vhost *v, const char *path)
+vhost_dirfd(struct vhost *v, const char *path, size_t *retloc)
{
struct location *loc;
+ size_t l = 0;
if (v == NULL || path == NULL)
return -1;
loc = TAILQ_FIRST(&v->locations);
while ((loc = TAILQ_NEXT(loc, locations)) != NULL) {
+ l++;
if (loc->dirfd != -1)
- if (matches(loc->match, path))
+ if (matches(loc->match, path)) {
+ *retloc = l;
return loc->dirfd;
+ }
}
+ *retloc = 0;
loc = TAILQ_FIRST(&v->locations);
return loc->dirfd;
}
@@ -322,7 +327,7 @@ check_path(struct client *c, const char *path, int *fd)
if (*p == '\0')
p = ".";
- dirfd = vhost_dirfd(c->host, path);
+ dirfd = vhost_dirfd(c->host, path, &c->loc);
log_debug(c, "check_path: strip=%d path=%s original=%s",
strip, p, path);
flags = O_RDONLY | O_NOFOLLOW;
@@ -683,6 +688,7 @@ handle_open_conn(int fd, short ev, void *d)
return;
if (c->host->entrypoint != NULL) {
+ c->loc = 0;
start_cgi(c->host->entrypoint, c->iri.path, c);
return;
}
@@ -802,6 +808,7 @@ start_cgi(const char *spath, const char *relpath, struct client *c)
req.notafter = tls_peer_cert_notafter(c->ctx);
req.host_off = host_nth(c->host);
+ req.loc_off = c->loc;
imsg_compose(&exibuf, IMSG_CGI_REQ, c->id, 0, -1, &req, sizeof(req));
imsg_flush(&exibuf);