4 15902770 2021-01-15 op * Copyright (c) 2021 Omar Polo <op@omarpolo.com>
6 15902770 2021-01-15 op * Permission to use, copy, modify, and distribute this software for any
7 15902770 2021-01-15 op * purpose with or without fee is hereby granted, provided that the above
8 15902770 2021-01-15 op * copyright notice and this permission notice appear in all copies.
10 15902770 2021-01-15 op * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 15902770 2021-01-15 op * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 15902770 2021-01-15 op * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 15902770 2021-01-15 op * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 15902770 2021-01-15 op * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 15902770 2021-01-15 op * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 15902770 2021-01-15 op * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 74f0778b 2021-06-16 op #include <ctype.h>
20 002a84a1 2021-02-10 op #include <errno.h>
21 6abda252 2021-02-06 op #include <stdarg.h>
22 15902770 2021-01-15 op #include <stdio.h>
23 74f0778b 2021-06-16 op #include <stdlib.h>
24 32693ee6 2021-01-28 op #include <string.h>
26 15902770 2021-01-15 op #include "gmid.h"
31 15902770 2021-01-15 op * #define YYDEBUG 1
32 15902770 2021-01-15 op * int yydebug = 1;
35 ca21e100 2021-02-04 op struct vhost *host;
36 ca21e100 2021-02-04 op struct location *loc;
38 74f0778b 2021-06-16 op static int goterror;
39 74f0778b 2021-06-16 op static int lineno, colno;
41 b8e64ccd 2021-03-31 op static struct vhost *new_vhost(void);
42 b8e64ccd 2021-03-31 op static struct location *new_location(void);
44 6abda252 2021-02-06 op void yyerror(const char*, ...);
45 74f0778b 2021-06-16 op static int yylex(void);
46 13ed2fb6 2021-01-27 op int parse_portno(const char*);
47 13ed2fb6 2021-01-27 op void parse_conf(const char*);
48 e17642a7 2021-02-01 op char *ensure_absolute_path(char*);
49 6abda252 2021-02-06 op int check_block_code(int);
50 6abda252 2021-02-06 op char *check_block_fmt(char*);
51 6abda252 2021-02-06 op int check_strip_no(int);
52 a709ddf5 2021-02-07 op int check_prefork_num(int);
53 49b73ba1 2021-02-10 op void advance_loc(void);
54 c705ecb1 2021-05-03 op void only_once(const void*, const char*);
55 8ad1c570 2021-05-09 op void only_oncei(int, const char*);
56 8ad1c570 2021-05-09 op int fastcgi_conf(char *, char *, char *);
57 c92b802b 2021-06-11 op void add_param(char *, char *, int);
61 15902770 2021-01-15 op /* for bison: */
62 15902770 2021-01-15 op /* %define parse.error verbose */
69 d06d6f4b 2021-04-29 op %token TIPV6 TPORT TPROTOCOLS TMIME TDEFAULT TTYPE TCHROOT TUSER TSERVER
70 d06d6f4b 2021-04-29 op %token TPREFORK TLOCATION TCERT TKEY TROOT TCGI TENV TLANG TLOG TINDEX TAUTO
71 8ad1c570 2021-05-09 op %token TSTRIP TBLOCK TRETURN TENTRYPOINT TREQUIRE TCLIENT TCA TALIAS TTCP
72 c92b802b 2021-06-11 op %token TFASTCGI TSPAWN TPARAM
76 15902770 2021-01-15 op %token <str> TSTRING
77 15902770 2021-01-15 op %token <num> TNUM
78 15902770 2021-01-15 op %token <num> TBOOL
82 15902770 2021-01-15 op conf : options vhosts ;
84 15902770 2021-01-15 op options : /* empty */
85 15902770 2021-01-15 op | options option
88 eb59f87e 2021-02-09 op option : TCHROOT TSTRING { conf.chroot = $2; }
89 eb59f87e 2021-02-09 op | TIPV6 TBOOL { conf.ipv6 = $2; }
90 eb59f87e 2021-02-09 op | TMIME TSTRING TSTRING { add_mime(&conf.mime, $2, $3); }
91 15902770 2021-01-15 op | TPORT TNUM { conf.port = $2; }
92 eb59f87e 2021-02-09 op | TPREFORK TNUM { conf.prefork = check_prefork_num($2); }
93 5bc3c98e 2021-01-15 op | TPROTOCOLS TSTRING {
94 5bc3c98e 2021-01-15 op if (tls_config_parse_protocols(&conf.protos, $2) == -1)
95 002a84a1 2021-02-10 op yyerror("invalid protocols string \"%s\"", $2);
97 ae08ec7d 2021-01-25 op | TUSER TSTRING { conf.user = $2; }
100 15902770 2021-01-15 op vhosts : /* empty */
101 15902770 2021-01-15 op | vhosts vhost
104 b8e64ccd 2021-03-31 op vhost : TSERVER TSTRING {
105 b8e64ccd 2021-03-31 op host = new_vhost();
106 b8e64ccd 2021-03-31 op TAILQ_INSERT_HEAD(&hosts, host, vhosts);
108 b8e64ccd 2021-03-31 op loc = new_location();
109 b8e64ccd 2021-03-31 op TAILQ_INSERT_HEAD(&host->locations, loc, locations);
111 b8e64ccd 2021-03-31 op loc->match = xstrdup("*");
112 15902770 2021-01-15 op host->domain = $2;
114 cbeee4ca 2021-01-28 op if (strstr($2, "xn--") != NULL) {
115 cbeee4ca 2021-01-28 op warnx("%s:%d \"%s\" looks like punycode: "
116 415ac7a2 2021-01-28 op "you should use the decoded hostname.",
117 74f0778b 2021-06-16 op config_path, lineno, $2);
119 b8e64ccd 2021-03-31 op } '{' servopts locations '}' {
121 fdea6aa0 2021-04-30 op if (host->cert == NULL || host->key == NULL)
122 002a84a1 2021-02-10 op yyerror("invalid vhost definition: %s", $2);
124 15902770 2021-01-15 op | error '}' { yyerror("error in server directive"); }
127 15902770 2021-01-15 op servopts : /* empty */
128 15902770 2021-01-15 op | servopts servopt
131 cc8c2901 2021-04-29 op servopt : TALIAS TSTRING {
132 cc8c2901 2021-04-29 op struct alist *a;
134 cc8c2901 2021-04-29 op a = xcalloc(1, sizeof(*a));
135 cc8c2901 2021-04-29 op a->alias = $2;
136 cc8c2901 2021-04-29 op if (TAILQ_EMPTY(&host->aliases))
137 cc8c2901 2021-04-29 op TAILQ_INSERT_HEAD(&host->aliases, a, aliases);
139 cc8c2901 2021-04-29 op TAILQ_INSERT_TAIL(&host->aliases, a, aliases);
141 c705ecb1 2021-05-03 op | TCERT TSTRING {
142 c705ecb1 2021-05-03 op only_once(host->cert, "cert");
143 c705ecb1 2021-05-03 op host->cert = ensure_absolute_path($2);
145 15902770 2021-01-15 op | TCGI TSTRING {
146 c705ecb1 2021-05-03 op only_once(host->cgi, "cgi");
147 15902770 2021-01-15 op /* drop the starting '/', if any */
148 709f4c94 2021-02-04 op if (*$2 == '/')
149 709f4c94 2021-02-04 op memmove($2, $2+1, strlen($2));
150 709f4c94 2021-02-04 op host->cgi = $2;
152 e3ddf390 2021-02-06 op | TENTRYPOINT TSTRING {
153 c705ecb1 2021-05-03 op only_once(host->entrypoint, "entrypoint");
154 e3ddf390 2021-02-06 op while (*$2 == '/')
155 e3ddf390 2021-02-06 op memmove($2, $2+1, strlen($2));
156 e3ddf390 2021-02-06 op host->entrypoint = $2;
158 9cc630aa 2021-04-28 op | TENV TSTRING TSTRING {
159 c92b802b 2021-06-11 op add_param($2, $3, 1);
161 c705ecb1 2021-05-03 op | TKEY TSTRING {
162 c705ecb1 2021-05-03 op only_once(host->key, "key");
163 c705ecb1 2021-05-03 op host->key = ensure_absolute_path($2);
165 c92b802b 2021-06-11 op | TPARAM TSTRING TSTRING {
166 c92b802b 2021-06-11 op add_param($2, $3, 0);
171 c8b74339 2021-01-24 op locations : /* empty */
172 c8b74339 2021-01-24 op | locations location
175 49b73ba1 2021-02-10 op location : TLOCATION { advance_loc(); } TSTRING '{' locopts '}' {
176 49b73ba1 2021-02-10 op /* drop the starting '/' if any */
177 49b73ba1 2021-02-10 op if (*$3 == '/')
178 49b73ba1 2021-02-10 op memmove($3, $3+1, strlen($3));
179 49b73ba1 2021-02-10 op loc->match = $3;
184 c8b74339 2021-01-24 op locopts : /* empty */
185 c8b74339 2021-01-24 op | locopts locopt
188 eb59f87e 2021-02-09 op locopt : TAUTO TINDEX TBOOL { loc->auto_index = $3 ? 1 : -1; }
189 6abda252 2021-02-06 op | TBLOCK TRETURN TNUM TSTRING {
190 c705ecb1 2021-05-03 op only_once(loc->block_fmt, "block");
191 6abda252 2021-02-06 op loc->block_fmt = check_block_fmt($4);
192 6abda252 2021-02-06 op loc->block_code = check_block_code($3);
194 6abda252 2021-02-06 op | TBLOCK TRETURN TNUM {
195 c705ecb1 2021-05-03 op only_once(loc->block_fmt, "block");
196 6abda252 2021-02-06 op loc->block_fmt = xstrdup("temporary failure");
197 6abda252 2021-02-06 op loc->block_code = check_block_code($3);
198 6abda252 2021-02-06 op if ($3 >= 30 && $3 < 40)
199 6abda252 2021-02-06 op yyerror("missing `meta' for block return %d", $3);
202 c705ecb1 2021-05-03 op only_once(loc->block_fmt, "block");
203 6abda252 2021-02-06 op loc->block_fmt = xstrdup("temporary failure");
204 6abda252 2021-02-06 op loc->block_code = 40;
206 eb59f87e 2021-02-09 op | TDEFAULT TTYPE TSTRING {
207 c705ecb1 2021-05-03 op only_once(loc->default_mime, "default type");
208 eb59f87e 2021-02-09 op loc->default_mime = $3;
210 0d047efc 2021-05-24 op | TFASTCGI fastcgi
211 eb59f87e 2021-02-09 op | TINDEX TSTRING {
212 c705ecb1 2021-05-03 op only_once(loc->index, "index");
213 eb59f87e 2021-02-09 op loc->index = $2;
215 eb59f87e 2021-02-09 op | TLANG TSTRING {
216 c705ecb1 2021-05-03 op only_once(loc->lang, "lang");
217 eb59f87e 2021-02-09 op loc->lang = $2;
219 793835cb 2021-02-23 op | TLOG TBOOL { loc->disable_log = !$2; }
220 02be96c6 2021-02-09 op | TREQUIRE TCLIENT TCA TSTRING {
221 c705ecb1 2021-05-03 op only_once(loc->reqca, "require client ca");
222 adbe6a64 2021-04-30 op ensure_absolute_path($4);
223 02be96c6 2021-02-09 op if ((loc->reqca = load_ca($4)) == NULL)
224 02be96c6 2021-02-09 op yyerror("couldn't load ca cert: %s", $4);
227 fdea6aa0 2021-04-30 op | TROOT TSTRING {
228 c705ecb1 2021-05-03 op only_once(loc->dir, "root");
229 fdea6aa0 2021-04-30 op loc->dir = ensure_absolute_path($2);
231 eb59f87e 2021-02-09 op | TSTRIP TNUM { loc->strip = check_strip_no($2); }
234 0d047efc 2021-05-24 op fastcgi : TSPAWN TSTRING {
235 0d047efc 2021-05-24 op only_oncei(loc->fcgi, "fastcgi");
236 0d047efc 2021-05-24 op loc->fcgi = fastcgi_conf(NULL, NULL, $2);
239 0d047efc 2021-05-24 op only_oncei(loc->fcgi, "fastcgi");
240 0d047efc 2021-05-24 op loc->fcgi = fastcgi_conf($1, NULL, NULL);
242 0d047efc 2021-05-24 op | TTCP TSTRING TNUM {
244 0d047efc 2021-05-24 op if (asprintf(&c, "%d", $3) == -1)
245 0d047efc 2021-05-24 op err(1, "asprintf");
246 0d047efc 2021-05-24 op only_oncei(loc->fcgi, "fastcgi");
247 0d047efc 2021-05-24 op loc->fcgi = fastcgi_conf($2, c, NULL);
249 0d047efc 2021-05-24 op | TTCP TSTRING {
250 0d047efc 2021-05-24 op only_oncei(loc->fcgi, "fastcgi");
251 0d047efc 2021-05-24 op loc->fcgi = fastcgi_conf($2, xstrdup("9000"), NULL);
253 0d047efc 2021-05-24 op | TTCP TSTRING TSTRING {
254 0d047efc 2021-05-24 op only_oncei(loc->fcgi, "fastcgi");
255 0d047efc 2021-05-24 op loc->fcgi = fastcgi_conf($2, $3, NULL);
261 b8e64ccd 2021-03-31 op static struct vhost *
262 b8e64ccd 2021-03-31 op new_vhost(void)
264 b8e64ccd 2021-03-31 op return xcalloc(1, sizeof(struct vhost));
267 b8e64ccd 2021-03-31 op static struct location *
268 b8e64ccd 2021-03-31 op new_location(void)
270 fdea6aa0 2021-04-30 op struct location *l;
272 fdea6aa0 2021-04-30 op l = xcalloc(1, sizeof(*l));
273 fdea6aa0 2021-04-30 op l->dirfd = -1;
274 8ad1c570 2021-05-09 op l->fcgi = -1;
279 6abda252 2021-02-06 op yyerror(const char *msg, ...)
283 13ed2fb6 2021-01-27 op goterror = 1;
285 6abda252 2021-02-06 op va_start(ap, msg);
286 74f0778b 2021-06-16 op fprintf(stderr, "%s:%d: ", config_path, lineno);
287 6abda252 2021-02-06 op vfprintf(stderr, msg, ap);
288 a1373913 2021-02-07 op fprintf(stderr, "\n");
292 74f0778b 2021-06-16 op static struct keyword {
293 74f0778b 2021-06-16 op const char *word;
295 74f0778b 2021-06-16 op } keywords[] = {
296 74f0778b 2021-06-16 op {"alias", TALIAS},
297 74f0778b 2021-06-16 op {"auto", TAUTO},
298 74f0778b 2021-06-16 op {"block", TBLOCK},
300 74f0778b 2021-06-16 op {"cert", TCERT},
301 74f0778b 2021-06-16 op {"cgi", TCGI},
302 74f0778b 2021-06-16 op {"chroot", TCHROOT},
303 74f0778b 2021-06-16 op {"client", TCLIENT},
304 74f0778b 2021-06-16 op {"default", TDEFAULT},
305 74f0778b 2021-06-16 op {"entrypoint", TENTRYPOINT},
306 74f0778b 2021-06-16 op {"env", TENV},
307 74f0778b 2021-06-16 op {"fastcgi", TFASTCGI},
308 74f0778b 2021-06-16 op {"index", TINDEX},
309 74f0778b 2021-06-16 op {"ipv6", TIPV6},
310 74f0778b 2021-06-16 op {"key", TKEY},
311 74f0778b 2021-06-16 op {"lang", TLANG},
312 74f0778b 2021-06-16 op {"location", TLOCATION},
313 74f0778b 2021-06-16 op {"log", TLOG},
314 74f0778b 2021-06-16 op {"mime", TMIME},
315 74f0778b 2021-06-16 op {"param", TPARAM},
316 74f0778b 2021-06-16 op {"port", TPORT},
317 74f0778b 2021-06-16 op {"prefork", TPREFORK},
318 74f0778b 2021-06-16 op {"protocols", TPROTOCOLS},
319 74f0778b 2021-06-16 op {"require", TREQUIRE},
320 74f0778b 2021-06-16 op {"return", TRETURN},
321 74f0778b 2021-06-16 op {"root", TROOT},
322 74f0778b 2021-06-16 op {"server", TSERVER},
323 74f0778b 2021-06-16 op {"spawn", TSPAWN},
324 74f0778b 2021-06-16 op {"strip", TSTRIP},
325 74f0778b 2021-06-16 op {"tcp", TTCP},
326 74f0778b 2021-06-16 op {"type", TTYPE},
327 74f0778b 2021-06-16 op {"user", TUSER},
331 74f0778b 2021-06-16 op * Taken an adapted from doas' parse.y
336 74f0778b 2021-06-16 op char buf[1024], *ebuf, *p, *str;
337 74f0778b 2021-06-16 op int c, quotes = 0, escape = 0, qpos = -1, nonkw = 0;
341 74f0778b 2021-06-16 op ebuf = buf + sizeof(buf);
344 74f0778b 2021-06-16 op /* skip whitespace first */
345 74f0778b 2021-06-16 op for (c = getc(yyfp); isspace(c); c = getc(yyfp)) {
347 74f0778b 2021-06-16 op if (c == '\n') {
353 74f0778b 2021-06-16 op /* check for special one-character constructions */
359 74f0778b 2021-06-16 op /* skip comments; NUL is allowed; no continuation */
360 74f0778b 2021-06-16 op while ((c = getc(yyfp)) != '\n')
361 74f0778b 2021-06-16 op if (c == EOF)
370 74f0778b 2021-06-16 op /* parsing next word */
371 74f0778b 2021-06-16 op for (;; c = getc(yyfp), colno++) {
374 74f0778b 2021-06-16 op yyerror("unallowed character NULL in column %d",
379 74f0778b 2021-06-16 op escape = !escape;
385 74f0778b 2021-06-16 op yyerror("unterminated quotes in column %d",
387 74f0778b 2021-06-16 op if (escape) {
396 74f0778b 2021-06-16 op yyerror("unterminated escape in column %d",
399 74f0778b 2021-06-16 op yyerror("unterminated quotes in column %d",
407 74f0778b 2021-06-16 op if (!escape && !quotes)
411 74f0778b 2021-06-16 op if (!escape) {
412 74f0778b 2021-06-16 op quotes = !quotes;
413 74f0778b 2021-06-16 op if (quotes) {
415 74f0778b 2021-06-16 op qpos = colno;
421 74f0778b 2021-06-16 op if (p == ebuf) {
422 74f0778b 2021-06-16 op yyerror("line too long");
430 74f0778b 2021-06-16 op if (c != EOF)
431 74f0778b 2021-06-16 op ungetc(c, yyfp);
432 74f0778b 2021-06-16 op if (p == buf) {
434 74f0778b 2021-06-16 op * There could be a number of reason for empty buffer,
435 74f0778b 2021-06-16 op * and we handle all of them here, to avoid cluttering
436 74f0778b 2021-06-16 op * the main loop.
438 74f0778b 2021-06-16 op if (c == EOF)
440 74f0778b 2021-06-16 op else if (qpos == -1) /* accept, e.g., empty args: cmd foo args "" */
443 74f0778b 2021-06-16 op if (!nonkw) {
444 74f0778b 2021-06-16 op for (i = 0; i < sizeof(keywords) / sizeof(keywords[0]); ++i) {
445 74f0778b 2021-06-16 op if (!strcmp(buf, keywords[i].word))
446 74f0778b 2021-06-16 op return keywords[i].token;
450 74f0778b 2021-06-16 op if (!nonkw && (c == '-' || isdigit(c))) {
451 74f0778b 2021-06-16 op yylval.num = parse_portno(buf);
454 74f0778b 2021-06-16 op if (!nonkw && !strcmp(buf, "on")) {
455 74f0778b 2021-06-16 op yylval.num = 1;
456 74f0778b 2021-06-16 op return TBOOL;
458 74f0778b 2021-06-16 op if (!nonkw && !strcmp(buf, "off")) {
459 74f0778b 2021-06-16 op yylval.num = 0;
460 74f0778b 2021-06-16 op return TBOOL;
462 74f0778b 2021-06-16 op if ((str = strdup(buf)) == NULL)
463 74f0778b 2021-06-16 op err(1, "%s", __func__);
464 74f0778b 2021-06-16 op yylval.str = str;
465 74f0778b 2021-06-16 op return TSTRING;
468 74f0778b 2021-06-16 op if (ferror(yyfp))
469 74f0778b 2021-06-16 op yyerror("input error reading config");
474 13ed2fb6 2021-01-27 op parse_portno(const char *p)
476 13ed2fb6 2021-01-27 op const char *errstr;
479 13ed2fb6 2021-01-27 op n = strtonum(p, 0, UINT16_MAX, &errstr);
480 13ed2fb6 2021-01-27 op if (errstr != NULL)
481 2d34f732 2021-02-10 op yyerror("port number is %s: %s", errstr, p);
486 13ed2fb6 2021-01-27 op parse_conf(const char *path)
488 13ed2fb6 2021-01-27 op config_path = path;
489 74f0778b 2021-06-16 op if ((yyfp = fopen(path, "r")) == NULL)
490 48b69cb2 2021-04-28 op err(1, "cannot open config: %s", path);
492 74f0778b 2021-06-16 op fclose(yyfp);
494 13ed2fb6 2021-01-27 op if (goterror)
497 b8e64ccd 2021-03-31 op if (TAILQ_FIRST(&hosts)->domain == NULL)
498 48b69cb2 2021-04-28 op errx(1, "no vhost defined in %s", path);
502 e17642a7 2021-02-01 op ensure_absolute_path(char *path)
504 e17642a7 2021-02-01 op if (path == NULL || *path != '/')
505 adbe6a64 2021-04-30 op yyerror("not an absolute path: %s", path);
510 6abda252 2021-02-06 op check_block_code(int n)
512 6abda252 2021-02-06 op if (n < 10 || n >= 70 || (n >= 20 && n <= 29))
513 6abda252 2021-02-06 op yyerror("invalid block code %d", n);
518 6abda252 2021-02-06 op check_block_fmt(char *fmt)
522 6abda252 2021-02-06 op for (s = fmt; *s; ++s) {
523 6abda252 2021-02-06 op if (*s != '%')
525 6abda252 2021-02-06 op switch (*++s) {
533 6abda252 2021-02-06 op yyerror("invalid format specifier %%%c", *s);
541 6abda252 2021-02-06 op check_strip_no(int n)
544 6abda252 2021-02-06 op yyerror("invalid strip number %d", n);
549 a709ddf5 2021-02-07 op check_prefork_num(int n)
551 2c3e53da 2021-03-03 op if (n <= 0 || n >= PROC_MAX)
552 a709ddf5 2021-02-07 op yyerror("invalid prefork number %d", n);
557 49b73ba1 2021-02-10 op advance_loc(void)
559 b8e64ccd 2021-03-31 op loc = new_location();
560 b8e64ccd 2021-03-31 op TAILQ_INSERT_TAIL(&host->locations, loc, locations);
564 c705ecb1 2021-05-03 op only_once(const void *ptr, const char *name)
566 c705ecb1 2021-05-03 op if (ptr != NULL)
567 c705ecb1 2021-05-03 op yyerror("`%s' specified more than once", name);
571 8ad1c570 2021-05-09 op only_oncei(int i, const char *name)
574 8ad1c570 2021-05-09 op yyerror("`%s' specified more than once", name);
578 8ad1c570 2021-05-09 op fastcgi_conf(char *path, char *port, char *prog)
580 8ad1c570 2021-05-09 op struct fcgi *f;
583 8ad1c570 2021-05-09 op for (i = 0; i < FCGI_MAX; ++i) {
584 8ad1c570 2021-05-09 op f = &fcgi[i];
586 8ad1c570 2021-05-09 op if (f->path == NULL) {
588 8ad1c570 2021-05-09 op f->path = path;
589 8ad1c570 2021-05-09 op f->port = port;
590 8ad1c570 2021-05-09 op f->prog = prog;
594 8ad1c570 2021-05-09 op /* XXX: what to do with prog? */
595 8ad1c570 2021-05-09 op if (!strcmp(f->path, path) &&
596 8ad1c570 2021-05-09 op ((port == NULL && f->port == NULL) ||
597 8ad1c570 2021-05-09 op !strcmp(f->port, port))) {
604 8ad1c570 2021-05-09 op yyerror("too much `fastcgi' rules defined.");
609 c92b802b 2021-06-11 op add_param(char *name, char *val, int env)
611 c92b802b 2021-06-11 op struct envlist *e;
612 c92b802b 2021-06-11 op struct envhead *h;
615 c92b802b 2021-06-11 op h = &host->env;
617 c92b802b 2021-06-11 op h = &host->params;
619 c92b802b 2021-06-11 op e = xcalloc(1, sizeof(*e));
620 c92b802b 2021-06-11 op e->name = name;
621 c92b802b 2021-06-11 op e->value = val;
622 c92b802b 2021-06-11 op if (TAILQ_EMPTY(h))
623 c92b802b 2021-06-11 op TAILQ_INSERT_HEAD(h, e, envs);
625 c92b802b 2021-06-11 op TAILQ_INSERT_TAIL(h, e, envs);