diff options
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 31 |
1 files changed, 27 insertions, 4 deletions
@@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.3 2014/07/23 22:02:02 reyk Exp $ */ +/* $OpenBSD: parse.y,v 1.7 2014/07/25 17:04:47 reyk Exp $ */ /* * Copyright (c) 2007 - 2014 Reyk Floeter <reyk@openbsd.org> @@ -126,7 +126,7 @@ typedef struct { %} -%token ALL PORT LISTEN PREFORK SERVER ERROR INCLUDE LOG VERBOSE ON TYPES +%token ALL PORT LISTEN PREFORK ROOT SERVER ERROR LOG VERBOSE ON TYPES %token UPDATES INCLUDE %token <v.string> STRING %token <v.number> NUMBER @@ -215,6 +215,8 @@ server : SERVER STRING { } free($2); + strlcpy(s->srv_conf.docroot, HTTPD_DOCROOT, + sizeof(s->srv_conf.docroot)); s->srv_conf.id = ++last_server_id; s->srv_conf.timeout.tv_sec = SERVER_TIMEOUT; @@ -262,8 +264,19 @@ serveroptsl : LISTEN ON STRING port { memcpy(&srv->srv_conf.ss, &h->ss, sizeof(s->srv_conf.ss)); s->srv_conf.port = h->port.val[0]; + s->srv_conf.prefixlen = h->prefixlen; host_free(&al); } + | ROOT STRING { + if (strlcpy(srv->srv_conf.docroot, $2, + sizeof(srv->srv_conf.docroot)) >= + sizeof(srv->srv_conf.docroot)) { + yyerror("document root too long"); + free($2); + YYERROR; + } + free($2); + } ; types : TYPES '{' optnl mediaopts_l '}' @@ -399,6 +412,7 @@ lookup(char *s) { "on", ON }, { "port", PORT }, { "prefork", PREFORK }, + { "root", ROOT }, { "server", SERVER }, { "types", TYPES }, { "updates", UPDATES } @@ -924,7 +938,10 @@ host_v4(const char *s) sain->sin_len = sizeof(struct sockaddr_in); sain->sin_family = AF_INET; sain->sin_addr.s_addr = ina.s_addr; - + if (sain->sin_addr.s_addr == INADDR_ANY) + h->prefixlen = 0; /* 0.0.0.0 address */ + else + h->prefixlen = -1; /* host address */ return (h); } @@ -950,7 +967,11 @@ host_v6(const char *s) sizeof(sa_in6->sin6_addr)); sa_in6->sin6_scope_id = ((struct sockaddr_in6 *)res->ai_addr)->sin6_scope_id; - + if (memcmp(&sa_in6->sin6_addr, &in6addr_any, + sizeof(sa_in6->sin6_addr)) == 0) + h->prefixlen = 0; /* any address */ + else + h->prefixlen = -1; /* host address */ freeaddrinfo(res); } @@ -1003,6 +1024,7 @@ host_dns(const char *s, struct addresslist *al, int max, if (ipproto != -1) h->ipproto = ipproto; h->ss.ss_family = res->ai_family; + h->prefixlen = -1; /* host address */ if (res->ai_family == AF_INET) { sain = (struct sockaddr_in *)&h->ss; @@ -1065,6 +1087,7 @@ host_if(const char *s, struct addresslist *al, int max, if (ipproto != -1) h->ipproto = ipproto; h->ss.ss_family = af; + h->prefixlen = -1; /* host address */ if (af == AF_INET) { sain = (struct sockaddr_in *)&h->ss; |