4 e2f167af 2021-01-02 op * Copyright (c) 2021, 2022 Omar Polo <op@omarpolo.com>
5 c39be742 2021-07-09 op * Copyright (c) 2018 Florian Obser <florian@openbsd.org>
6 c39be742 2021-07-09 op * Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
7 c39be742 2021-07-09 op * Copyright (c) 2004 Ryan McBride <mcbride@openbsd.org>
8 c39be742 2021-07-09 op * Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
9 c39be742 2021-07-09 op * Copyright (c) 2001 Markus Friedl. All rights reserved.
10 c39be742 2021-07-09 op * Copyright (c) 2001 Daniel Hartmeier. All rights reserved.
11 c39be742 2021-07-09 op * Copyright (c) 2001 Theo de Raadt. All rights reserved.
13 15902770 2021-01-15 op * Permission to use, copy, modify, and distribute this software for any
14 15902770 2021-01-15 op * purpose with or without fee is hereby granted, provided that the above
15 15902770 2021-01-15 op * copyright notice and this permission notice appear in all copies.
17 15902770 2021-01-15 op * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
18 15902770 2021-01-15 op * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
19 15902770 2021-01-15 op * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
20 15902770 2021-01-15 op * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
21 15902770 2021-01-15 op * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
22 15902770 2021-01-15 op * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
23 15902770 2021-01-15 op * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
26 1f1f3810 2022-02-03 op #include "gmid.h"
28 74f0778b 2021-06-16 op #include <ctype.h>
29 002a84a1 2021-02-10 op #include <errno.h>
30 6abda252 2021-02-06 op #include <stdarg.h>
31 15902770 2021-01-15 op #include <stdio.h>
32 74f0778b 2021-06-16 op #include <stdlib.h>
33 32693ee6 2021-01-28 op #include <string.h>
35 c39be742 2021-07-09 op TAILQ_HEAD(files, file) files = TAILQ_HEAD_INITIALIZER(files);
36 c39be742 2021-07-09 op static struct file {
37 c39be742 2021-07-09 op TAILQ_ENTRY(file) entry;
40 c39be742 2021-07-09 op size_t ungetpos;
41 c39be742 2021-07-09 op size_t ungetsize;
42 c39be742 2021-07-09 op u_char *ungetbuf;
43 c39be742 2021-07-09 op int eof_reached;
46 c39be742 2021-07-09 op } *file, *topfile;
48 c39be742 2021-07-09 op struct file *pushfile(const char *, int);
49 c39be742 2021-07-09 op int popfile(void);
50 c39be742 2021-07-09 op int yyparse(void);
51 c39be742 2021-07-09 op int yylex(void);
52 c39be742 2021-07-09 op void yyerror(const char *, ...)
53 c39be742 2021-07-09 op __attribute__((__format__ (printf, 1, 2)))
54 c39be742 2021-07-09 op __attribute__((__nonnull__ (1)));
55 f3966209 2021-07-13 op void yywarn(const char *, ...)
56 f3966209 2021-07-13 op __attribute__((__format__ (printf, 1, 2)))
57 f3966209 2021-07-13 op __attribute__((__nonnull__ (1)));
58 c39be742 2021-07-09 op int kw_cmp(const void *, const void *);
59 c39be742 2021-07-09 op int lookup(char *);
60 c39be742 2021-07-09 op int igetc(void);
61 c39be742 2021-07-09 op int lgetc(int);
62 c39be742 2021-07-09 op void lungetc(int);
63 c39be742 2021-07-09 op int findeol(void);
66 15902770 2021-01-15 op * #define YYDEBUG 1
67 15902770 2021-01-15 op * int yydebug = 1;
70 3b21cca3 2021-06-29 op TAILQ_HEAD(symhead, sym) symhead = TAILQ_HEAD_INITIALIZER(symhead);
72 3b21cca3 2021-06-29 op TAILQ_ENTRY(sym) entry;
79 c39be742 2021-07-09 op int symset(const char *, const char *, int);
80 c39be742 2021-07-09 op char *symget(const char *);
82 c39be742 2021-07-09 op struct vhost *new_vhost(void);
83 c39be742 2021-07-09 op struct location *new_location(void);
84 b7967bc1 2021-01-02 op struct proxy *new_proxy(void);
85 e17642a7 2021-02-01 op char *ensure_absolute_path(char*);
86 6abda252 2021-02-06 op int check_block_code(int);
87 6abda252 2021-02-06 op char *check_block_fmt(char*);
88 6abda252 2021-02-06 op int check_strip_no(int);
89 391825e3 2021-07-09 op int check_port_num(int);
90 a709ddf5 2021-02-07 op int check_prefork_num(int);
91 49b73ba1 2021-02-10 op void advance_loc(void);
92 b7967bc1 2021-01-02 op void advance_proxy(void);
93 b7967bc1 2021-01-02 op void parsehp(char *, char **, const char **, const char *);
94 c705ecb1 2021-05-03 op void only_once(const void*, const char*);
95 8ad1c570 2021-05-09 op void only_oncei(int, const char*);
96 8ad1c570 2021-05-09 op int fastcgi_conf(char *, char *, char *);
97 2025e96d 2022-09-10 op void add_param(char *, char *);
99 c39be742 2021-07-09 op static struct vhost *host;
100 c39be742 2021-07-09 op static struct location *loc;
101 b7967bc1 2021-01-02 op static struct proxy *proxy;
102 ee219d70 2022-02-26 op static char *current_media;
103 c39be742 2021-07-09 op static int errors;
105 c39be742 2021-07-09 op typedef struct {
107 c39be742 2021-07-09 op char *string;
115 15902770 2021-01-15 op /* for bison: */
116 15902770 2021-01-15 op /* %define parse.error verbose */
118 c74c7030 2021-07-19 op %token ALIAS AUTO
120 d29a2ee2 2022-09-06 op %token CA CERT CHROOT CLIENT
121 c74c7030 2021-07-19 op %token DEFAULT
122 b7967bc1 2021-01-02 op %token FASTCGI FOR_HOST
123 c74c7030 2021-07-19 op %token INCLUDE INDEX IPV6
125 c74c7030 2021-07-19 op %token LANG LOCATION LOG
126 ff05125e 2021-10-15 op %token OCSP OFF ON
127 b7967bc1 2021-01-02 op %token PARAM PORT PREFORK PROTO PROTOCOLS PROXY
128 72b033ef 2021-12-29 op %token RELAY_TO REQUIRE RETURN ROOT
129 1cdea97b 2022-01-30 op %token SERVER SNI SPAWN STRIP
130 ee219d70 2022-02-26 op %token TCP TOEXT TYPE TYPES
131 593e412b 2021-01-01 op %token USE_TLS USER
132 5128c0b0 2021-01-01 op %token VERIFYNAME
136 c39be742 2021-07-09 op %token <v.string> STRING
137 c39be742 2021-07-09 op %token <v.number> NUM
139 c39be742 2021-07-09 op %type <v.number> bool
140 ee219d70 2022-02-26 op %type <v.string> string numberstring
144 6b86655a 2021-06-29 op conf : /* empty */
145 c39be742 2021-07-09 op | conf include '\n'
147 c39be742 2021-07-09 op | conf varset '\n'
148 c39be742 2021-07-09 op | conf option '\n'
149 c39be742 2021-07-09 op | conf vhost '\n'
150 ee219d70 2022-02-26 op | conf types '\n'
151 c39be742 2021-07-09 op | conf error '\n' { file->errors++; }
154 c39be742 2021-07-09 op include : INCLUDE STRING {
155 c39be742 2021-07-09 op struct file *nfile;
157 c39be742 2021-07-09 op if ((nfile = pushfile($2, 0)) == NULL) {
158 c39be742 2021-07-09 op yyerror("failed to include file %s", $2);
164 c39be742 2021-07-09 op file = nfile;
165 c39be742 2021-07-09 op lungetc('\n');
169 c74c7030 2021-07-19 op bool : ON { $$ = 1; }
170 c74c7030 2021-07-19 op | OFF { $$ = 0; }
173 c39be742 2021-07-09 op string : string STRING {
174 98f52178 2021-06-29 op if (asprintf(&$$, "%s%s", $1, $2) == -1) {
177 98f52178 2021-06-29 op yyerror("string: asprintf: %s", strerror(errno));
186 ee219d70 2022-02-26 op numberstring : NUM {
188 ee219d70 2022-02-26 op if (asprintf(&s, "%d", $1) == -1) {
189 ee219d70 2022-02-26 op yyerror("asprintf: number");
197 c39be742 2021-07-09 op varset : STRING '=' string {
198 3b21cca3 2021-06-29 op char *s = $1;
199 3b21cca3 2021-06-29 op while (*s++) {
200 c39be742 2021-07-09 op if (isspace((unsigned char)*s)) {
201 3b21cca3 2021-06-29 op yyerror("macro name cannot contain "
202 3b21cca3 2021-06-29 op "whitespaces");
208 3b21cca3 2021-06-29 op symset($1, $3, 0);
214 7277bb7d 2022-09-10 op option : CHROOT string {
215 7277bb7d 2022-09-10 op if (strlcpy(conf.chroot, $2, sizeof(conf.chroot)) >=
216 7277bb7d 2022-09-10 op sizeof(conf.chroot))
217 7277bb7d 2022-09-10 op yyerror("chroot path too long");
220 c74c7030 2021-07-19 op | IPV6 bool { conf.ipv6 = $2; }
221 c74c7030 2021-07-19 op | PORT NUM { conf.port = check_port_num($2); }
222 c74c7030 2021-07-19 op | PREFORK NUM { conf.prefork = check_prefork_num($2); }
223 c74c7030 2021-07-19 op | PROTOCOLS string {
224 5bc3c98e 2021-01-15 op if (tls_config_parse_protocols(&conf.protos, $2) == -1)
225 002a84a1 2021-02-10 op yyerror("invalid protocols string \"%s\"", $2);
228 7277bb7d 2022-09-10 op | USER string {
229 7277bb7d 2022-09-10 op if (strlcpy(conf.user, $2, sizeof(conf.user)) >=
230 7277bb7d 2022-09-10 op sizeof(conf.user))
231 7277bb7d 2022-09-10 op yyerror("user name too long");
236 c74c7030 2021-07-19 op vhost : SERVER string {
237 b8e64ccd 2021-03-31 op host = new_vhost();
238 b8e64ccd 2021-03-31 op TAILQ_INSERT_HEAD(&hosts, host, vhosts);
240 b8e64ccd 2021-03-31 op loc = new_location();
241 b8e64ccd 2021-03-31 op TAILQ_INSERT_HEAD(&host->locations, loc, locations);
243 b7967bc1 2021-01-02 op TAILQ_INIT(&host->proxies);
245 b8e64ccd 2021-03-31 op loc->match = xstrdup("*");
246 15902770 2021-01-15 op host->domain = $2;
248 cbeee4ca 2021-01-28 op if (strstr($2, "xn--") != NULL) {
249 f3966209 2021-07-13 op yywarn("\"%s\" looks like punycode: you "
250 f3966209 2021-07-13 op "should use the decoded hostname", $2);
252 b7967bc1 2021-01-02 op } '{' optnl servbody '}' {
253 fdea6aa0 2021-04-30 op if (host->cert == NULL || host->key == NULL)
254 002a84a1 2021-02-10 op yyerror("invalid vhost definition: %s", $2);
256 f3966209 2021-07-13 op | error '}' { yyerror("bad server directive"); }
259 b7967bc1 2021-01-02 op servbody : /* empty */
260 b7967bc1 2021-01-02 op | servbody servopt optnl
261 b7967bc1 2021-01-02 op | servbody location optnl
262 b7967bc1 2021-01-02 op | servbody proxy optnl
265 c74c7030 2021-07-19 op servopt : ALIAS string {
266 cc8c2901 2021-04-29 op struct alist *a;
268 cc8c2901 2021-04-29 op a = xcalloc(1, sizeof(*a));
269 cc8c2901 2021-04-29 op a->alias = $2;
270 edc5ca66 2022-09-10 op TAILQ_INSERT_TAIL(&host->aliases, a, aliases);
272 c74c7030 2021-07-19 op | CERT string {
273 c705ecb1 2021-05-03 op only_once(host->cert, "cert");
274 c705ecb1 2021-05-03 op host->cert = ensure_absolute_path($2);
276 c74c7030 2021-07-19 op | KEY string {
277 c705ecb1 2021-05-03 op only_once(host->key, "key");
278 c705ecb1 2021-05-03 op host->key = ensure_absolute_path($2);
280 ff05125e 2021-10-15 op | OCSP string {
281 ff05125e 2021-10-15 op only_once(host->ocsp, "ocsp");
282 ff05125e 2021-10-15 op host->ocsp = ensure_absolute_path($2);
284 c74c7030 2021-07-19 op | PARAM string '=' string {
285 2025e96d 2022-09-10 op add_param($2, $4);
290 b7967bc1 2021-01-02 op proxy : PROXY { advance_proxy(); }
291 b7967bc1 2021-01-02 op proxy_matches '{' optnl proxy_opts '}' {
292 b7967bc1 2021-01-02 op if (proxy->host == NULL)
293 b7967bc1 2021-01-02 op yyerror("invalid proxy block: missing `relay-to' option");
295 b7967bc1 2021-01-02 op if ((proxy->cert == NULL && proxy->key != NULL) ||
296 b7967bc1 2021-01-02 op (proxy->cert != NULL && proxy->key == NULL))
297 b7967bc1 2021-01-02 op yyerror("invalid proxy block: missing cert or key");
301 b7967bc1 2021-01-02 op proxy_matches : /* empty */
302 b7967bc1 2021-01-02 op | proxy_matches proxy_match
305 b7967bc1 2021-01-02 op proxy_match : PROTO string {
306 b7967bc1 2021-01-02 op only_once(proxy->match_proto, "proxy proto");
307 b7967bc1 2021-01-02 op free(proxy->match_proto);
308 b7967bc1 2021-01-02 op proxy->match_proto = $2;
310 b7967bc1 2021-01-02 op | FOR_HOST string {
311 b7967bc1 2021-01-02 op only_once(proxy->match_host, "proxy for-host");
312 b7967bc1 2021-01-02 op free(proxy->match_host);
313 b7967bc1 2021-01-02 op parsehp($2, &proxy->match_host, &proxy->match_port, "10965");
317 7bdcc91e 2021-01-01 op proxy_opts : /* empty */
318 7bdcc91e 2021-01-01 op | proxy_opts proxy_opt optnl
321 7bdcc91e 2021-01-01 op proxy_opt : CERT string {
322 b7967bc1 2021-01-02 op only_once(proxy->cert, "proxy cert");
323 b7967bc1 2021-01-02 op tls_unload_file(proxy->cert, proxy->certlen);
324 7bdcc91e 2021-01-01 op ensure_absolute_path($2);
325 b7967bc1 2021-01-02 op proxy->cert = tls_load_file($2, &proxy->certlen, NULL);
326 b7967bc1 2021-01-02 op if (proxy->cert == NULL)
327 7bdcc91e 2021-01-01 op yyerror("can't load cert %s", $2);
330 7bdcc91e 2021-01-01 op | KEY string {
331 b7967bc1 2021-01-02 op only_once(proxy->key, "proxy key");
332 b7967bc1 2021-01-02 op tls_unload_file(proxy->key, proxy->keylen);
333 7bdcc91e 2021-01-01 op ensure_absolute_path($2);
334 b7967bc1 2021-01-02 op proxy->key = tls_load_file($2, &proxy->keylen, NULL);
335 b7967bc1 2021-01-02 op if (proxy->key == NULL)
336 7bdcc91e 2021-01-01 op yyerror("can't load key %s", $2);
339 c7c8ef44 2021-01-01 op | PROTOCOLS string {
340 b7967bc1 2021-01-02 op if (tls_config_parse_protocols(&proxy->protocols, $2) == -1)
341 c7c8ef44 2021-01-01 op yyerror("invalid protocols string \"%s\"", $2);
344 7bdcc91e 2021-01-01 op | RELAY_TO string {
345 b7967bc1 2021-01-02 op only_once(proxy->host, "proxy relay-to");
346 b7967bc1 2021-01-02 op free(proxy->host);
347 b7967bc1 2021-01-02 op parsehp($2, &proxy->host, &proxy->port, "1965");
349 ba94a608 2022-01-04 op | REQUIRE CLIENT CA string {
350 ba94a608 2022-01-04 op only_once(proxy->reqca, "require client ca");
351 ba94a608 2022-01-04 op ensure_absolute_path($4);
352 ba94a608 2022-01-04 op if ((proxy->reqca = load_ca($4)) == NULL)
353 ba94a608 2022-01-04 op yyerror("couldn't load ca cert: %s", $4);
356 1cdea97b 2022-01-30 op | SNI string {
357 1cdea97b 2022-01-30 op only_once(proxy->sni, "proxy sni");
358 1cdea97b 2022-01-30 op free(proxy->sni);
359 1cdea97b 2022-01-30 op proxy->sni = $2;
361 593e412b 2021-01-01 op | USE_TLS bool {
362 b7967bc1 2021-01-02 op proxy->notls = !$2;
364 5128c0b0 2021-01-01 op | VERIFYNAME bool {
365 b7967bc1 2021-01-02 op proxy->noverifyname = !$2;
369 c74c7030 2021-07-19 op location : LOCATION { advance_loc(); } string '{' optnl locopts '}' {
370 49b73ba1 2021-02-10 op /* drop the starting '/' if any */
371 49b73ba1 2021-02-10 op if (*$3 == '/')
372 49b73ba1 2021-02-10 op memmove($3, $3+1, strlen($3));
373 49b73ba1 2021-02-10 op loc->match = $3;
378 c8b74339 2021-01-24 op locopts : /* empty */
379 c39be742 2021-07-09 op | locopts locopt optnl
382 c74c7030 2021-07-19 op locopt : AUTO INDEX bool { loc->auto_index = $3 ? 1 : -1; }
383 c74c7030 2021-07-19 op | BLOCK RETURN NUM string {
384 c705ecb1 2021-05-03 op only_once(loc->block_fmt, "block");
385 6abda252 2021-02-06 op loc->block_fmt = check_block_fmt($4);
386 6abda252 2021-02-06 op loc->block_code = check_block_code($3);
388 c74c7030 2021-07-19 op | BLOCK RETURN NUM {
389 c705ecb1 2021-05-03 op only_once(loc->block_fmt, "block");
390 6abda252 2021-02-06 op loc->block_fmt = xstrdup("temporary failure");
391 6abda252 2021-02-06 op loc->block_code = check_block_code($3);
392 6abda252 2021-02-06 op if ($3 >= 30 && $3 < 40)
393 6abda252 2021-02-06 op yyerror("missing `meta' for block return %d", $3);
396 c705ecb1 2021-05-03 op only_once(loc->block_fmt, "block");
397 6abda252 2021-02-06 op loc->block_fmt = xstrdup("temporary failure");
398 6abda252 2021-02-06 op loc->block_code = 40;
400 c74c7030 2021-07-19 op | DEFAULT TYPE string {
401 c705ecb1 2021-05-03 op only_once(loc->default_mime, "default type");
402 eb59f87e 2021-02-09 op loc->default_mime = $3;
404 abc8801d 2021-07-19 op | FASTCGI fastcgi
405 c74c7030 2021-07-19 op | INDEX string {
406 c705ecb1 2021-05-03 op only_once(loc->index, "index");
407 eb59f87e 2021-02-09 op loc->index = $2;
409 c74c7030 2021-07-19 op | LANG string {
410 c705ecb1 2021-05-03 op only_once(loc->lang, "lang");
411 eb59f87e 2021-02-09 op loc->lang = $2;
413 c74c7030 2021-07-19 op | LOG bool { loc->disable_log = !$2; }
414 da2185f3 2021-01-01 op | REQUIRE CLIENT CA string {
415 da2185f3 2021-01-01 op only_once(loc->reqca, "require client ca");
416 da2185f3 2021-01-01 op ensure_absolute_path($4);
417 da2185f3 2021-01-01 op if ((loc->reqca = load_ca($4)) == NULL)
418 da2185f3 2021-01-01 op yyerror("couldn't load ca cert: %s", $4);
421 da2185f3 2021-01-01 op | ROOT string {
422 da2185f3 2021-01-01 op only_once(loc->dir, "root");
423 da2185f3 2021-01-01 op loc->dir = ensure_absolute_path($2);
425 da2185f3 2021-01-01 op | STRIP NUM { loc->strip = check_strip_no($2); }
428 c74c7030 2021-07-19 op fastcgi : SPAWN string {
429 0d047efc 2021-05-24 op only_oncei(loc->fcgi, "fastcgi");
430 0d047efc 2021-05-24 op loc->fcgi = fastcgi_conf(NULL, NULL, $2);
433 0d047efc 2021-05-24 op only_oncei(loc->fcgi, "fastcgi");
434 0d047efc 2021-05-24 op loc->fcgi = fastcgi_conf($1, NULL, NULL);
436 c74c7030 2021-07-19 op | TCP string PORT NUM {
438 762b9b99 2021-07-09 op if (asprintf(&c, "%d", $4) == -1)
439 0d047efc 2021-05-24 op err(1, "asprintf");
440 0d047efc 2021-05-24 op only_oncei(loc->fcgi, "fastcgi");
441 0d047efc 2021-05-24 op loc->fcgi = fastcgi_conf($2, c, NULL);
443 c74c7030 2021-07-19 op | TCP string {
444 0d047efc 2021-05-24 op only_oncei(loc->fcgi, "fastcgi");
445 0d047efc 2021-05-24 op loc->fcgi = fastcgi_conf($2, xstrdup("9000"), NULL);
447 c74c7030 2021-07-19 op | TCP string PORT string {
448 0d047efc 2021-05-24 op only_oncei(loc->fcgi, "fastcgi");
449 762b9b99 2021-07-09 op loc->fcgi = fastcgi_conf($2, $4, NULL);
453 cd5826b8 2022-09-10 op types : TYPES '{' optnl mediaopts_l '}' ;
455 ee219d70 2022-02-26 op mediaopts_l : mediaopts_l mediaoptsl nl
456 ee219d70 2022-02-26 op | mediaoptsl nl
459 aa9543b9 2022-09-10 op mediaoptsl : STRING {
460 aa9543b9 2022-09-10 op free(current_media);
461 aa9543b9 2022-09-10 op current_media = $1;
462 aa9543b9 2022-09-10 op } medianames_l optsemicolon
466 ee219d70 2022-02-26 op medianames_l : medianames_l medianamesl
467 ee219d70 2022-02-26 op | medianamesl
470 d8d170aa 2022-04-08 op medianamesl : numberstring {
471 d8d170aa 2022-04-08 op if (add_mime(&conf.mime, current_media, $1) == -1)
472 d8d170aa 2022-04-08 op err(1, "add_mime");
477 ee219d70 2022-02-26 op nl : '\n' optnl
480 c39be742 2021-07-09 op optnl : '\n' optnl /* zero or more newlines */
481 67f49405 2021-07-09 op | ';' optnl /* semicolons too */
485 ee219d70 2022-02-26 op optsemicolon : ';'
491 e5d82d94 2022-03-19 op static const struct keyword {
492 74f0778b 2021-06-16 op const char *word;
494 74f0778b 2021-06-16 op } keywords[] = {
495 d93c8191 2021-07-09 op /* these MUST be sorted */
496 c74c7030 2021-07-19 op {"alias", ALIAS},
497 c74c7030 2021-07-19 op {"auto", AUTO},
498 c74c7030 2021-07-19 op {"block", BLOCK},
500 c74c7030 2021-07-19 op {"cert", CERT},
501 c74c7030 2021-07-19 op {"chroot", CHROOT},
502 c74c7030 2021-07-19 op {"client", CLIENT},
503 c74c7030 2021-07-19 op {"default", DEFAULT},
504 abc8801d 2021-07-19 op {"fastcgi", FASTCGI},
505 b7967bc1 2021-01-02 op {"for-host", FOR_HOST},
506 88971f9a 2022-02-26 op {"include", INCLUDE},
507 c74c7030 2021-07-19 op {"index", INDEX},
508 c74c7030 2021-07-19 op {"ipv6", IPV6},
509 c74c7030 2021-07-19 op {"key", KEY},
510 c74c7030 2021-07-19 op {"lang", LANG},
511 c74c7030 2021-07-19 op {"location", LOCATION},
512 c74c7030 2021-07-19 op {"log", LOG},
513 ff05125e 2021-10-15 op {"ocsp", OCSP},
514 c74c7030 2021-07-19 op {"off", OFF},
516 c74c7030 2021-07-19 op {"param", PARAM},
517 c74c7030 2021-07-19 op {"port", PORT},
518 c74c7030 2021-07-19 op {"prefork", PREFORK},
519 b7967bc1 2021-01-02 op {"proto", PROTO},
520 c74c7030 2021-07-19 op {"protocols", PROTOCOLS},
521 72b033ef 2021-12-29 op {"proxy", PROXY},
522 72b033ef 2021-12-29 op {"relay-to", RELAY_TO},
523 c74c7030 2021-07-19 op {"require", REQUIRE},
524 c74c7030 2021-07-19 op {"return", RETURN},
525 c74c7030 2021-07-19 op {"root", ROOT},
526 c74c7030 2021-07-19 op {"server", SERVER},
527 1cdea97b 2022-01-30 op {"sni", SNI},
528 c74c7030 2021-07-19 op {"spawn", SPAWN},
529 c74c7030 2021-07-19 op {"strip", STRIP},
530 c74c7030 2021-07-19 op {"tcp", TCP},
531 c74c7030 2021-07-19 op {"to-ext", TOEXT},
532 c74c7030 2021-07-19 op {"type", TYPE},
533 ee219d70 2022-02-26 op {"types", TYPES},
534 593e412b 2021-01-01 op {"use-tls", USE_TLS},
535 c74c7030 2021-07-19 op {"user", USER},
536 5128c0b0 2021-01-01 op {"verifyname", VERIFYNAME},
540 c39be742 2021-07-09 op yyerror(const char *msg, ...)
544 c39be742 2021-07-09 op file->errors++;
546 c39be742 2021-07-09 op va_start(ap, msg);
547 f3966209 2021-07-13 op fprintf(stderr, "%s:%d error: ", config_path, yylval.lineno);
548 f3966209 2021-07-13 op vfprintf(stderr, msg, ap);
549 f3966209 2021-07-13 op fprintf(stderr, "\n");
554 f3966209 2021-07-13 op yywarn(const char *msg, ...)
558 f3966209 2021-07-13 op va_start(ap, msg);
559 f3966209 2021-07-13 op fprintf(stderr, "%s:%d warning: ", config_path, yylval.lineno);
560 c39be742 2021-07-09 op vfprintf(stderr, msg, ap);
561 c39be742 2021-07-09 op fprintf(stderr, "\n");
566 d93c8191 2021-07-09 op kw_cmp(const void *k, const void *e)
568 d93c8191 2021-07-09 op return strcmp(k, ((struct keyword *)e)->word);
572 c39be742 2021-07-09 op lookup(char *s)
574 c39be742 2021-07-09 op const struct keyword *p;
576 c39be742 2021-07-09 op p = bsearch(s, keywords, sizeof(keywords)/sizeof(keywords[0]),
577 c39be742 2021-07-09 op sizeof(keywords[0]), kw_cmp);
580 c39be742 2021-07-09 op return p->token;
582 c39be742 2021-07-09 op return STRING;
585 c39be742 2021-07-09 op #define START_EXPAND 1
586 c39be742 2021-07-09 op #define DONE_EXPAND 2
588 c39be742 2021-07-09 op static int expanding;
596 c39be742 2021-07-09 op if (file->ungetpos > 0)
597 c39be742 2021-07-09 op c = file->ungetbuf[--file->ungetpos];
599 c39be742 2021-07-09 op c = getc(file->stream);
601 c39be742 2021-07-09 op if (c == START_EXPAND)
602 c39be742 2021-07-09 op expanding = 1;
603 c39be742 2021-07-09 op else if (c == DONE_EXPAND)
604 c39be742 2021-07-09 op expanding = 0;
612 c39be742 2021-07-09 op lgetc(int quotec)
616 c39be742 2021-07-09 op if (quotec) {
617 c39be742 2021-07-09 op if ((c = igetc()) == EOF) {
618 c39be742 2021-07-09 op yyerror("reached end of file while parsing "
619 c39be742 2021-07-09 op "quoted string");
620 c39be742 2021-07-09 op if (file == topfile || popfile() == EOF)
622 c39be742 2021-07-09 op return quotec;
627 c39be742 2021-07-09 op while ((c = igetc()) == '\\') {
628 c39be742 2021-07-09 op next = igetc();
629 c39be742 2021-07-09 op if (next != '\n') {
633 c39be742 2021-07-09 op yylval.lineno = file->lineno;
634 c39be742 2021-07-09 op file->lineno++;
637 c39be742 2021-07-09 op if (c == EOF) {
639 c39be742 2021-07-09 op * Fake EOL when hit EOF for the first time. This gets line
640 c39be742 2021-07-09 op * count right if last line in included file is syntactically
641 c39be742 2021-07-09 op * invalid and has no newline.
643 c39be742 2021-07-09 op if (file->eof_reached == 0) {
644 c39be742 2021-07-09 op file->eof_reached = 1;
647 c39be742 2021-07-09 op while (c == EOF) {
648 c39be742 2021-07-09 op if (file == topfile || popfile() == EOF)
657 c39be742 2021-07-09 op lungetc(int c)
659 c39be742 2021-07-09 op if (c == EOF)
662 c39be742 2021-07-09 op if (file->ungetpos >= file->ungetsize) {
663 c39be742 2021-07-09 op void *p = reallocarray(file->ungetbuf, file->ungetsize, 2);
664 c39be742 2021-07-09 op if (p == NULL)
665 c39be742 2021-07-09 op err(1, "lungetc");
666 c39be742 2021-07-09 op file->ungetbuf = p;
667 c39be742 2021-07-09 op file->ungetsize *= 2;
669 c39be742 2021-07-09 op file->ungetbuf[file->ungetpos++] = c;
673 c39be742 2021-07-09 op findeol(void)
677 c39be742 2021-07-09 op /* Skip to either EOF or the first real EOL. */
679 c39be742 2021-07-09 op c = lgetc(0);
680 c39be742 2021-07-09 op if (c == '\n') {
681 c39be742 2021-07-09 op file->lineno++;
684 c39be742 2021-07-09 op if (c == EOF)
687 c39be742 2021-07-09 op return ERROR;
693 1bd706dc 2021-07-09 op char buf[8096];
694 1bd706dc 2021-07-09 op char *p, *val;
695 1bd706dc 2021-07-09 op int quotec, next, c;
700 c39be742 2021-07-09 op while ((c = lgetc(0)) == ' ' || c == '\t')
701 c39be742 2021-07-09 op ; /* nothing */
703 c39be742 2021-07-09 op yylval.lineno = file->lineno;
704 c39be742 2021-07-09 op if (c == '#')
705 c39be742 2021-07-09 op while ((c = lgetc(0)) != '\n' && c != EOF)
706 c39be742 2021-07-09 op ; /* nothing */
707 c39be742 2021-07-09 op if (c == '$' && !expanding) {
709 c39be742 2021-07-09 op if ((c = lgetc(0)) == EOF)
711 67f49405 2021-07-09 op if (p + 1 >= buf + sizeof(buf) -1) {
712 67f49405 2021-07-09 op yyerror("string too long");
713 67f49405 2021-07-09 op return findeol();
715 67f49405 2021-07-09 op if (isalnum(c) || c == '_') {
723 67f49405 2021-07-09 op val = symget(buf);
724 67f49405 2021-07-09 op if (val == NULL) {
725 67f49405 2021-07-09 op yyerror("macro `%s' not defined", buf);
726 67f49405 2021-07-09 op return findeol();
728 67f49405 2021-07-09 op yylval.v.string = xstrdup(val);
729 67f49405 2021-07-09 op return STRING;
731 67f49405 2021-07-09 op if (c == '@' && !expanding) {
733 67f49405 2021-07-09 op if ((c = lgetc(0)) == EOF)
736 c39be742 2021-07-09 op if (p + 1 >= buf + sizeof(buf) - 1) {
737 c39be742 2021-07-09 op yyerror("string too long");
738 c39be742 2021-07-09 op return findeol();
740 c39be742 2021-07-09 op if (isalnum(c) || c == '_') {
748 c39be742 2021-07-09 op val = symget(buf);
749 c39be742 2021-07-09 op if (val == NULL) {
750 c39be742 2021-07-09 op yyerror("macro '%s' not defined", buf);
751 c39be742 2021-07-09 op return findeol();
753 c39be742 2021-07-09 op p = val + strlen(val) - 1;
754 c39be742 2021-07-09 op lungetc(DONE_EXPAND);
755 c39be742 2021-07-09 op while (p >= val) {
759 c39be742 2021-07-09 op lungetc(START_EXPAND);
768 c39be742 2021-07-09 op if ((c = lgetc(quotec)) == EOF)
770 c39be742 2021-07-09 op if (c == '\n') {
771 c39be742 2021-07-09 op file->lineno++;
773 c39be742 2021-07-09 op } else if (c == '\\') {
774 c39be742 2021-07-09 op if ((next = lgetc(quotec)) == EOF)
776 c39be742 2021-07-09 op if (next == quotec || next == ' ' ||
777 c39be742 2021-07-09 op next == '\t')
779 c39be742 2021-07-09 op else if (next == '\n') {
780 c39be742 2021-07-09 op file->lineno++;
783 c39be742 2021-07-09 op lungetc(next);
784 c39be742 2021-07-09 op } else if (c == quotec) {
787 c39be742 2021-07-09 op } else if (c == '\0') {
788 f3966209 2021-07-13 op yyerror("invalid syntax");
789 c39be742 2021-07-09 op return findeol();
791 c39be742 2021-07-09 op if (p + 1 >= buf + sizeof(buf) - 1) {
792 c39be742 2021-07-09 op yyerror("string too long");
793 c39be742 2021-07-09 op return findeol();
797 c39be742 2021-07-09 op yylval.v.string = strdup(buf);
798 c39be742 2021-07-09 op if (yylval.v.string == NULL)
799 c39be742 2021-07-09 op err(1, "yylex: strdup");
800 c39be742 2021-07-09 op return STRING;
803 c39be742 2021-07-09 op #define allowed_to_end_number(x) \
804 c39be742 2021-07-09 op (isspace(x) || x == ')' || x ==',' || x == '/' || x == '}' || x == '=')
806 c39be742 2021-07-09 op if (c == '-' || isdigit(c)) {
809 c39be742 2021-07-09 op if ((size_t)(p-buf) >= sizeof(buf)) {
810 c39be742 2021-07-09 op yyerror("string too long");
811 c39be742 2021-07-09 op return findeol();
813 c39be742 2021-07-09 op } while ((c = lgetc(0)) != EOF && isdigit(c));
815 c39be742 2021-07-09 op if (p == buf + 1 && buf[0] == '-')
816 c39be742 2021-07-09 op goto nodigits;
817 c39be742 2021-07-09 op if (c == EOF || allowed_to_end_number(c)) {
818 c39be742 2021-07-09 op const char *errstr = NULL;
821 c39be742 2021-07-09 op yylval.v.number = strtonum(buf, LLONG_MIN,
822 c39be742 2021-07-09 op LLONG_MAX, &errstr);
823 c39be742 2021-07-09 op if (errstr) {
824 c39be742 2021-07-09 op yyerror("\"%s\" invalid number: %s",
825 c39be742 2021-07-09 op buf, errstr);
826 c39be742 2021-07-09 op return findeol();
831 c39be742 2021-07-09 op while (p > buf + 1)
832 c39be742 2021-07-09 op lungetc(*--p);
834 c39be742 2021-07-09 op if (c == '-')
839 c39be742 2021-07-09 op #define allowed_in_string(x) \
840 c39be742 2021-07-09 op (isalnum(x) || (ispunct(x) && x != '(' && x != ')' && \
841 c39be742 2021-07-09 op x != '{' && x != '}' && \
842 c39be742 2021-07-09 op x != '!' && x != '=' && x != '#' && \
843 67f49405 2021-07-09 op x != ',' && x != ';'))
845 67f49405 2021-07-09 op if (isalnum(c) || c == ':' || c == '_') {
848 c39be742 2021-07-09 op if ((size_t)(p-buf) >= sizeof(buf)) {
849 c39be742 2021-07-09 op yyerror("string too long");
850 c39be742 2021-07-09 op return findeol();
852 c39be742 2021-07-09 op } while ((c = lgetc(0)) != EOF && (allowed_in_string(c)));
855 c39be742 2021-07-09 op if ((token = lookup(buf)) == STRING)
856 c39be742 2021-07-09 op yylval.v.string = xstrdup(buf);
857 c39be742 2021-07-09 op return token;
859 c39be742 2021-07-09 op if (c == '\n') {
860 c39be742 2021-07-09 op yylval.lineno = file->lineno;
861 c39be742 2021-07-09 op file->lineno++;
863 c39be742 2021-07-09 op if (c == EOF)
868 c39be742 2021-07-09 op struct file *
869 c39be742 2021-07-09 op pushfile(const char *name, int secret)
871 c39be742 2021-07-09 op struct file *nfile;
873 c39be742 2021-07-09 op nfile = xcalloc(1, sizeof(*nfile));
874 c39be742 2021-07-09 op nfile->name = xstrdup(name);
875 c39be742 2021-07-09 op if ((nfile->stream = fopen(nfile->name, "r")) == NULL) {
876 83272dfe 2021-08-23 op log_warn(NULL, "can't open %s: %s", nfile->name,
877 c39be742 2021-07-09 op strerror(errno));
878 c39be742 2021-07-09 op free(nfile->name);
882 c39be742 2021-07-09 op nfile->lineno = TAILQ_EMPTY(&files) ? 1 : 0;
883 c39be742 2021-07-09 op nfile->ungetsize = 16;
884 c39be742 2021-07-09 op nfile->ungetbuf = xcalloc(1, nfile->ungetsize);
885 c39be742 2021-07-09 op TAILQ_INSERT_TAIL(&files, nfile, entry);
886 c39be742 2021-07-09 op return nfile;
890 c39be742 2021-07-09 op popfile(void)
892 c39be742 2021-07-09 op struct file *prev;
894 c39be742 2021-07-09 op if ((prev = TAILQ_PREV(file, files, entry)) != NULL)
895 c39be742 2021-07-09 op prev->errors += file->errors;
897 c39be742 2021-07-09 op TAILQ_REMOVE(&files, file, entry);
898 c39be742 2021-07-09 op fclose(file->stream);
899 c39be742 2021-07-09 op free(file->name);
900 c39be742 2021-07-09 op free(file->ungetbuf);
903 c39be742 2021-07-09 op return file ? 0 : EOF;
907 c39be742 2021-07-09 op parse_conf(const char *filename)
909 c39be742 2021-07-09 op struct sym *sym, *next;
911 c39be742 2021-07-09 op file = pushfile(filename, 0);
912 c39be742 2021-07-09 op if (file == NULL)
914 c39be742 2021-07-09 op topfile = file;
917 c39be742 2021-07-09 op errors = file->errors;
920 c39be742 2021-07-09 op /* Free macros and check which have not been used. */
921 3b21cca3 2021-06-29 op TAILQ_FOREACH_SAFE(sym, &symhead, entry, next) {
922 3b21cca3 2021-06-29 op /* TODO: warn if !sym->used */
923 3b21cca3 2021-06-29 op if (!sym->persist) {
924 3b21cca3 2021-06-29 op free(sym->name);
925 3b21cca3 2021-06-29 op free(sym->val);
926 3b21cca3 2021-06-29 op TAILQ_REMOVE(&symhead, sym, entry);
936 f0a01fc7 2021-10-09 op print_conf(void)
938 f0a01fc7 2021-10-09 op struct vhost *h;
939 f0a01fc7 2021-10-09 op /* struct location *l; */
940 f0a01fc7 2021-10-09 op /* struct envlist *e; */
941 f0a01fc7 2021-10-09 op /* struct alist *a; */
943 7277bb7d 2022-09-10 op if (*conf.chroot != '\0')
944 f0a01fc7 2021-10-09 op printf("chroot \"%s\"\n", conf.chroot);
945 f0a01fc7 2021-10-09 op printf("ipv6 %s\n", conf.ipv6 ? "on" : "off");
946 f0a01fc7 2021-10-09 op /* XXX: defined mimes? */
947 f0a01fc7 2021-10-09 op printf("port %d\n", conf.port);
948 f0a01fc7 2021-10-09 op printf("prefork %d\n", conf.prefork);
949 f0a01fc7 2021-10-09 op /* XXX: protocols? */
950 7277bb7d 2022-09-10 op if (*conf.user != '\0')
951 f0a01fc7 2021-10-09 op printf("user \"%s\"\n", conf.user);
953 f0a01fc7 2021-10-09 op TAILQ_FOREACH(h, &hosts, vhosts) {
954 f0a01fc7 2021-10-09 op printf("\nserver \"%s\" {\n", h->domain);
955 f0a01fc7 2021-10-09 op printf(" cert \"%s\"\n", h->cert);
956 f0a01fc7 2021-10-09 op printf(" key \"%s\"\n", h->key);
957 f0a01fc7 2021-10-09 op /* TODO: print locations... */
958 f0a01fc7 2021-10-09 op printf("}\n");
963 c39be742 2021-07-09 op symset(const char *name, const char *val, int persist)
965 c39be742 2021-07-09 op struct sym *sym;
967 c39be742 2021-07-09 op TAILQ_FOREACH(sym, &symhead, entry) {
968 c39be742 2021-07-09 op if (!strcmp(name, sym->name))
972 c39be742 2021-07-09 op if (sym != NULL) {
973 c39be742 2021-07-09 op if (sym->persist)
976 c39be742 2021-07-09 op free(sym->name);
977 c39be742 2021-07-09 op free(sym->val);
978 c39be742 2021-07-09 op TAILQ_REMOVE(&symhead, sym, entry);
983 c39be742 2021-07-09 op sym = xcalloc(1, sizeof(*sym));
984 c39be742 2021-07-09 op sym->name = xstrdup(name);
985 c39be742 2021-07-09 op sym->val = xstrdup(val);
986 c39be742 2021-07-09 op sym->used = 0;
987 c39be742 2021-07-09 op sym->persist = persist;
989 c39be742 2021-07-09 op TAILQ_INSERT_TAIL(&symhead, sym, entry);
994 c39be742 2021-07-09 op cmdline_symset(char *s)
996 c39be742 2021-07-09 op char *sym, *val;
999 c39be742 2021-07-09 op if ((val = strrchr(s, '=')) == NULL)
1001 c39be742 2021-07-09 op sym = xcalloc(1, val - s + 1);
1002 c39be742 2021-07-09 op memcpy(sym, s, val - s);
1003 c39be742 2021-07-09 op ret = symset(sym, val + 1, 1);
1009 c39be742 2021-07-09 op symget(const char *nam)
1011 c39be742 2021-07-09 op struct sym *sym;
1013 c39be742 2021-07-09 op TAILQ_FOREACH(sym, &symhead, entry) {
1014 c39be742 2021-07-09 op if (strcmp(nam, sym->name) == 0) {
1015 c39be742 2021-07-09 op sym->used = 1;
1016 c39be742 2021-07-09 op return sym->val;
1019 c39be742 2021-07-09 op return NULL;
1022 c39be742 2021-07-09 op struct vhost *
1023 c39be742 2021-07-09 op new_vhost(void)
1025 edc5ca66 2022-09-10 op struct vhost *h;
1027 edc5ca66 2022-09-10 op h = xcalloc(1, sizeof(*h));
1028 edc5ca66 2022-09-10 op TAILQ_INIT(&h->locations);
1029 edc5ca66 2022-09-10 op TAILQ_INIT(&h->params);
1030 edc5ca66 2022-09-10 op TAILQ_INIT(&h->aliases);
1031 edc5ca66 2022-09-10 op TAILQ_INIT(&h->proxies);
1035 c39be742 2021-07-09 op struct location *
1036 c39be742 2021-07-09 op new_location(void)
1038 c39be742 2021-07-09 op struct location *l;
1040 c39be742 2021-07-09 op l = xcalloc(1, sizeof(*l));
1041 c39be742 2021-07-09 op l->dirfd = -1;
1042 c39be742 2021-07-09 op l->fcgi = -1;
1046 b7967bc1 2021-01-02 op struct proxy *
1047 b7967bc1 2021-01-02 op new_proxy(void)
1049 b7967bc1 2021-01-02 op struct proxy *p;
1051 76000995 2022-09-06 op conf.can_open_sockets = 1;
1053 b7967bc1 2021-01-02 op p = xcalloc(1, sizeof(*p));
1054 b7967bc1 2021-01-02 op p->protocols = TLS_PROTOCOLS_DEFAULT;
1059 e17642a7 2021-02-01 op ensure_absolute_path(char *path)
1061 e17642a7 2021-02-01 op if (path == NULL || *path != '/')
1062 adbe6a64 2021-04-30 op yyerror("not an absolute path: %s", path);
1063 e17642a7 2021-02-01 op return path;
1067 6abda252 2021-02-06 op check_block_code(int n)
1069 6abda252 2021-02-06 op if (n < 10 || n >= 70 || (n >= 20 && n <= 29))
1070 6abda252 2021-02-06 op yyerror("invalid block code %d", n);
1075 6abda252 2021-02-06 op check_block_fmt(char *fmt)
1079 6abda252 2021-02-06 op for (s = fmt; *s; ++s) {
1080 6abda252 2021-02-06 op if (*s != '%')
1082 6abda252 2021-02-06 op switch (*++s) {
1090 6abda252 2021-02-06 op yyerror("invalid format specifier %%%c", *s);
1098 6abda252 2021-02-06 op check_strip_no(int n)
1101 6abda252 2021-02-06 op yyerror("invalid strip number %d", n);
1106 391825e3 2021-07-09 op check_port_num(int n)
1108 391825e3 2021-07-09 op if (n <= 0 || n >= UINT16_MAX)
1109 391825e3 2021-07-09 op yyerror("port number is %s: %d",
1110 391825e3 2021-07-09 op n <= 0 ? "too small" : "too large",
1116 a709ddf5 2021-02-07 op check_prefork_num(int n)
1118 2c3e53da 2021-03-03 op if (n <= 0 || n >= PROC_MAX)
1119 a709ddf5 2021-02-07 op yyerror("invalid prefork number %d", n);
1124 49b73ba1 2021-02-10 op advance_loc(void)
1126 b8e64ccd 2021-03-31 op loc = new_location();
1127 b8e64ccd 2021-03-31 op TAILQ_INSERT_TAIL(&host->locations, loc, locations);
1131 b7967bc1 2021-01-02 op advance_proxy(void)
1133 b7967bc1 2021-01-02 op proxy = new_proxy();
1134 b7967bc1 2021-01-02 op TAILQ_INSERT_TAIL(&host->proxies, proxy, proxies);
1138 b7967bc1 2021-01-02 op parsehp(char *str, char **host, const char **port, const char *def)
1141 b7967bc1 2021-01-02 op const char *errstr;
1143 b7967bc1 2021-01-02 op *host = str;
1145 b7967bc1 2021-01-02 op if ((at = strchr(str, ':')) != NULL) {
1146 b7967bc1 2021-01-02 op *at++ = '\0';
1149 b7967bc1 2021-01-02 op *port = def;
1151 b7967bc1 2021-01-02 op strtonum(*port, 1, UINT16_MAX, &errstr);
1152 b7967bc1 2021-01-02 op if (errstr != NULL)
1153 b7967bc1 2021-01-02 op yyerror("port is %s: %s", errstr, *port);
1157 c705ecb1 2021-05-03 op only_once(const void *ptr, const char *name)
1159 c705ecb1 2021-05-03 op if (ptr != NULL)
1160 c705ecb1 2021-05-03 op yyerror("`%s' specified more than once", name);
1164 8ad1c570 2021-05-09 op only_oncei(int i, const char *name)
1166 8ad1c570 2021-05-09 op if (i != -1)
1167 8ad1c570 2021-05-09 op yyerror("`%s' specified more than once", name);
1171 8ad1c570 2021-05-09 op fastcgi_conf(char *path, char *port, char *prog)
1173 8ad1c570 2021-05-09 op struct fcgi *f;
1176 76000995 2022-09-06 op conf.can_open_sockets = 1;
1178 8ad1c570 2021-05-09 op for (i = 0; i < FCGI_MAX; ++i) {
1179 8ad1c570 2021-05-09 op f = &fcgi[i];
1181 8ad1c570 2021-05-09 op if (f->path == NULL) {
1183 8ad1c570 2021-05-09 op f->path = path;
1184 8ad1c570 2021-05-09 op f->port = port;
1185 8ad1c570 2021-05-09 op f->prog = prog;
1189 8ad1c570 2021-05-09 op /* XXX: what to do with prog? */
1190 8ad1c570 2021-05-09 op if (!strcmp(f->path, path) &&
1191 8ad1c570 2021-05-09 op ((port == NULL && f->port == NULL) ||
1192 8ad1c570 2021-05-09 op !strcmp(f->port, port))) {
1199 8ad1c570 2021-05-09 op yyerror("too much `fastcgi' rules defined.");
1204 2025e96d 2022-09-10 op add_param(char *name, char *val)
1206 c92b802b 2021-06-11 op struct envlist *e;
1207 2025e96d 2022-09-10 op struct envhead *h = &host->params;
1209 c92b802b 2021-06-11 op e = xcalloc(1, sizeof(*e));
1210 c92b802b 2021-06-11 op e->name = name;
1211 c92b802b 2021-06-11 op e->value = val;
1212 edc5ca66 2022-09-10 op TAILQ_INSERT_TAIL(h, e, envs);