diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2014-07-30 13:49:49 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2014-07-30 13:49:49 +0000 |
commit | 1a8cc45f340f9c80f014da0c656f0cb4bf0d80b8 (patch) | |
tree | d19930b855ac33437f08329be31ed4523bf0bcd9 /usr.sbin/httpd/server_http.c | |
parent | e600718ee3f52c5f466a82ef8a6d4cc2b4b00c9f (diff) |
Make "location" work with name-based virtual servers.
Diffstat (limited to 'usr.sbin/httpd/server_http.c')
-rw-r--r-- | usr.sbin/httpd/server_http.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/usr.sbin/httpd/server_http.c b/usr.sbin/httpd/server_http.c index 05e8bf5d755..8e4de311747 100644 --- a/usr.sbin/httpd/server_http.c +++ b/usr.sbin/httpd/server_http.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server_http.c,v 1.20 2014/07/30 10:05:14 reyk Exp $ */ +/* $OpenBSD: server_http.c,v 1.21 2014/07/30 13:49:48 reyk Exp $ */ /* * Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org> @@ -671,7 +671,7 @@ server_response(struct httpd *httpd, struct client *clt) char path[MAXPATHLEN]; struct http_descriptor *desc = clt->clt_desc; struct server *srv = clt->clt_srv; - struct server_config *srv_conf = &srv->srv_conf; + struct server_config *srv_conf = &srv->srv_conf, *location; struct kv *kv, key, *host; int ret; @@ -717,11 +717,9 @@ server_response(struct httpd *httpd, struct client *clt) if (host != NULL) { /* XXX maybe better to turn srv_hosts into a tree */ TAILQ_FOREACH(srv_conf, &srv->srv_hosts, entry) { - if (((srv_conf->flags & SRVFLAG_LOCATION) && - fnmatch(srv_conf->location, - desc->http_path, FNM_CASEFOLD) == 0) || - (fnmatch(srv_conf->name, host->kv_value, - FNM_CASEFOLD) == 0)) { + if ((srv_conf->flags & SRVFLAG_LOCATION) == 0 && + fnmatch(srv_conf->name, host->kv_value, + FNM_CASEFOLD) == 0) { /* Replace host configuration */ clt->clt_srv_conf = srv_conf; srv_conf = NULL; @@ -740,6 +738,20 @@ server_response(struct httpd *httpd, struct client *clt) if (strlcpy(desc->http_host, host->kv_value, sizeof(desc->http_host)) >= sizeof(desc->http_host)) goto fail; + srv_conf = clt->clt_srv_conf; + } + + /* Now search for the location */ + TAILQ_FOREACH(location, &srv->srv_hosts, entry) { + if ((location->flags & SRVFLAG_LOCATION) && + location->id == srv_conf->id && + fnmatch(location->location, desc->http_path, + FNM_CASEFOLD) == 0) { + /* Replace host configuration */ + clt->clt_srv_conf = location; + srv_conf = NULL; + break; + } } if ((ret = server_file(httpd, clt)) == -1) |