0004
2021-01-02
op
* Copyright (c) 2021, 2022 Omar Polo <op@omarpolo.com>
0005
2021-07-09
op
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
0006
2021-07-09
op
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
0007
2021-07-09
op
* Copyright (c) 2004 Ryan McBride <mcbride@openbsd.org>
0008
2021-07-09
op
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
0009
2021-07-09
op
* Copyright (c) 2001 Markus Friedl. All rights reserved.
0010
2021-07-09
op
* Copyright (c) 2001 Daniel Hartmeier. All rights reserved.
0011
2021-07-09
op
* Copyright (c) 2001 Theo de Raadt. All rights reserved.
0013
2021-01-15
op
* Permission to use, copy, modify, and distribute this software for any
0014
2021-01-15
op
* purpose with or without fee is hereby granted, provided that the above
0015
2021-01-15
op
* copyright notice and this permission notice appear in all copies.
0017
2021-01-15
op
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
0018
2021-01-15
op
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
0019
2021-01-15
op
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
0020
2021-01-15
op
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
0021
2021-01-15
op
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
0022
2021-01-15
op
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
0023
2021-01-15
op
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
0026
2022-02-03
op
#include "gmid.h"
0028
2021-06-16
op
#include <ctype.h>
0029
2021-02-10
op
#include <errno.h>
0030
2021-02-06
op
#include <stdarg.h>
0031
2021-01-15
op
#include <stdio.h>
0032
2021-06-16
op
#include <stdlib.h>
0033
2021-01-28
op
#include <string.h>
0035
2021-07-09
op
TAILQ_HEAD(files, file) files = TAILQ_HEAD_INITIALIZER(files);
0036
2021-07-09
op
static struct file {
0037
2021-07-09
op
TAILQ_ENTRY(file) entry;
0038
2021-07-09
op
FILE *stream;
0039
2021-07-09
op
char *name;
0040
2021-07-09
op
size_t ungetpos;
0041
2021-07-09
op
size_t ungetsize;
0042
2021-07-09
op
u_char *ungetbuf;
0043
2021-07-09
op
int eof_reached;
0044
2021-07-09
op
int lineno;
0045
2021-07-09
op
int errors;
0046
2021-07-09
op
} *file, *topfile;
0048
2021-07-09
op
struct file *pushfile(const char *, int);
0049
2021-07-09
op
int popfile(void);
0050
2021-07-09
op
int yyparse(void);
0051
2021-07-09
op
int yylex(void);
0052
2021-07-09
op
void yyerror(const char *, ...)
0053
2021-07-09
op
__attribute__((__format__ (printf, 1, 2)))
0054
2021-07-09
op
__attribute__((__nonnull__ (1)));
0055
2021-07-13
op
void yywarn(const char *, ...)
0056
2021-07-13
op
__attribute__((__format__ (printf, 1, 2)))
0057
2021-07-13
op
__attribute__((__nonnull__ (1)));
0058
2021-07-09
op
int kw_cmp(const void *, const void *);
0059
2021-07-09
op
int lookup(char *);
0060
2021-07-09
op
int igetc(void);
0061
2021-07-09
op
int lgetc(int);
0062
2021-07-09
op
void lungetc(int);
0063
2021-07-09
op
int findeol(void);
0066
2021-01-15
op
* #define YYDEBUG 1
0067
2021-01-15
op
* int yydebug = 1;
0070
2021-06-29
op
TAILQ_HEAD(symhead, sym) symhead = TAILQ_HEAD_INITIALIZER(symhead);
0071
2021-06-29
op
struct sym {
0072
2021-06-29
op
TAILQ_ENTRY(sym) entry;
0073
2021-06-29
op
int used;
0074
2021-06-29
op
int persist;
0075
2021-06-29
op
char *name;
0076
2021-06-29
op
char *val;
0079
2021-07-09
op
int symset(const char *, const char *, int);
0080
2021-07-09
op
char *symget(const char *);
0082
2021-07-09
op
struct vhost *new_vhost(void);
0083
2021-07-09
op
struct location *new_location(void);
0084
2021-01-02
op
struct proxy *new_proxy(void);
0085
2021-02-01
op
char *ensure_absolute_path(char*);
0086
2021-02-06
op
int check_block_code(int);
0087
2021-02-06
op
char *check_block_fmt(char*);
0088
2021-02-06
op
int check_strip_no(int);
0089
2021-07-09
op
int check_port_num(int);
0090
2021-02-07
op
int check_prefork_num(int);
0091
2021-02-10
op
void advance_loc(void);
0092
2021-01-02
op
void advance_proxy(void);
0093
2021-01-02
op
void parsehp(char *, char **, const char **, const char *);
0094
2021-05-03
op
void only_once(const void*, const char*);
0095
2021-05-09
op
void only_oncei(int, const char*);
0096
2021-05-09
op
int fastcgi_conf(char *, char *, char *);
0097
2022-09-10
op
void add_param(char *, char *);
0099
2021-07-09
op
static struct vhost *host;
0100
2021-07-09
op
static struct location *loc;
0101
2021-01-02
op
static struct proxy *proxy;
0102
2022-02-26
op
static char *current_media;
0103
2021-07-09
op
static int errors;
0105
2021-07-09
op
typedef struct {
0107
2021-07-09
op
char *string;
0108
2021-07-09
op
int number;
0110
2021-07-09
op
int lineno;
0111
2021-07-09
op
} YYSTYPE;
0115
2021-01-15
op
/* for bison: */
0116
2021-01-15
op
/* %define parse.error verbose */
0118
2021-07-19
op
%token ALIAS AUTO
0119
2021-07-19
op
%token BLOCK
0120
2022-09-06
op
%token CA CERT CHROOT CLIENT
0121
2021-07-19
op
%token DEFAULT
0122
2021-01-02
op
%token FASTCGI FOR_HOST
0123
2021-07-19
op
%token INCLUDE INDEX IPV6
0124
2021-07-19
op
%token KEY
0125
2021-07-19
op
%token LANG LOCATION LOG
0126
2021-10-15
op
%token OCSP OFF ON
0127
2021-01-02
op
%token PARAM PORT PREFORK PROTO PROTOCOLS PROXY
0128
2021-12-29
op
%token RELAY_TO REQUIRE RETURN ROOT
0129
2022-01-30
op
%token SERVER SNI SPAWN STRIP
0130
2022-02-26
op
%token TCP TOEXT TYPE TYPES
0131
2021-01-01
op
%token USE_TLS USER
0132
2021-01-01
op
%token VERIFYNAME
0134
2021-07-09
op
%token ERROR
0136
2021-07-09
op
%token <v.string> STRING
0137
2021-07-09
op
%token <v.number> NUM
0139
2021-07-09
op
%type <v.number> bool
0140
2022-02-26
op
%type <v.string> string numberstring
0144
2021-06-29
op
conf : /* empty */
0145
2021-07-09
op
| conf include '\n'
0146
2021-07-09
op
| conf '\n'
0147
2021-07-09
op
| conf varset '\n'
0148
2021-07-09
op
| conf option '\n'
0149
2021-07-09
op
| conf vhost '\n'
0150
2022-02-26
op
| conf types '\n'
0151
2021-07-09
op
| conf error '\n' { file->errors++; }
0154
2021-07-09
op
include : INCLUDE STRING {
0155
2021-07-09
op
struct file *nfile;
0157
2021-07-09
op
if ((nfile = pushfile($2, 0)) == NULL) {
0158
2021-07-09
op
yyerror("failed to include file %s", $2);
0159
2021-07-09
op
free($2);
0160
2021-07-09
op
YYERROR;
0162
2021-07-09
op
free($2);
0164
2021-07-09
op
file = nfile;
0165
2021-07-09
op
lungetc('\n');
0169
2021-07-19
op
bool : ON { $$ = 1; }
0170
2021-07-19
op
| OFF { $$ = 0; }
0173
2021-07-09
op
string : string STRING {
0174
2021-06-29
op
if (asprintf(&$$, "%s%s", $1, $2) == -1) {
0175
2021-06-29
op
free($1);
0176
2021-06-29
op
free($2);
0177
2021-06-29
op
yyerror("string: asprintf: %s", strerror(errno));
0178
2021-06-29
op
YYERROR;
0180
2021-06-29
op
free($1);
0181
2021-06-29
op
free($2);
0183
2021-07-09
op
| STRING
0186
2022-02-26
op
numberstring : NUM {
0187
2022-02-26
op
char *s;
0188
2022-02-26
op
if (asprintf(&s, "%d", $1) == -1) {
0189
2022-02-26
op
yyerror("asprintf: number");
0190
2022-02-26
op
YYERROR;
0194
2022-02-26
op
| STRING
0197
2021-07-09
op
varset : STRING '=' string {
0198
2021-06-29
op
char *s = $1;
0199
2021-06-29
op
while (*s++) {
0200
2021-07-09
op
if (isspace((unsigned char)*s)) {
0201
2021-06-29
op
yyerror("macro name cannot contain "
0202
2021-06-29
op
"whitespaces");
0203
2021-06-29
op
free($1);
0204
2021-06-29
op
free($3);
0205
2021-06-29
op
YYERROR;
0208
2021-06-29
op
symset($1, $3, 0);
0209
2021-06-29
op
free($1);
0210
2021-06-29
op
free($3);
0214
2022-09-10
op
option : CHROOT string {
0215
2022-09-10
op
if (strlcpy(conf.chroot, $2, sizeof(conf.chroot)) >=
0216
2022-09-10
op
sizeof(conf.chroot))
0217
2022-09-10
op
yyerror("chroot path too long");
0218
2022-09-10
op
free($2);
0220
2021-07-19
op
| IPV6 bool { conf.ipv6 = $2; }
0221
2021-07-19
op
| PORT NUM { conf.port = check_port_num($2); }
0222
2021-07-19
op
| PREFORK NUM { conf.prefork = check_prefork_num($2); }
0223
2021-07-19
op
| PROTOCOLS string {
0224
2021-01-15
op
if (tls_config_parse_protocols(&conf.protos, $2) == -1)
0225
2021-02-10
op
yyerror("invalid protocols string \"%s\"", $2);
0226
2021-01-01
op
free($2);
0228
2022-09-10
op
| USER string {
0229
2022-09-10
op
if (strlcpy(conf.user, $2, sizeof(conf.user)) >=
0230
2022-09-10
op
sizeof(conf.user))
0231
2022-09-10
op
yyerror("user name too long");
0232
2022-09-10
op
free($2);
0236
2021-07-19
op
vhost : SERVER string {
0237
2021-03-31
op
host = new_vhost();
0238
2021-03-31
op
TAILQ_INSERT_HEAD(&hosts, host, vhosts);
0240
2021-03-31
op
loc = new_location();
0241
2021-03-31
op
TAILQ_INSERT_HEAD(&host->locations, loc, locations);
0243
2021-01-02
op
TAILQ_INIT(&host->proxies);
0245
2021-03-31
op
loc->match = xstrdup("*");
0246
2021-01-15
op
host->domain = $2;
0248
2021-01-28
op
if (strstr($2, "xn--") != NULL) {
0249
2021-07-13
op
yywarn("\"%s\" looks like punycode: you "
0250
2021-07-13
op
"should use the decoded hostname", $2);
0252
2021-01-02
op
} '{' optnl servbody '}' {
0253
2021-04-30
op
if (host->cert == NULL || host->key == NULL)
0254
2021-02-10
op
yyerror("invalid vhost definition: %s", $2);
0256
2021-07-13
op
| error '}' { yyerror("bad server directive"); }
0259
2021-01-02
op
servbody : /* empty */
0260
2021-01-02
op
| servbody servopt optnl
0261
2021-01-02
op
| servbody location optnl
0262
2021-01-02
op
| servbody proxy optnl
0265
2021-07-19
op
servopt : ALIAS string {
0266
2021-04-29
op
struct alist *a;
0268
2021-04-29
op
a = xcalloc(1, sizeof(*a));
0269
2021-04-29
op
a->alias = $2;
0270
2021-04-29
op
if (TAILQ_EMPTY(&host->aliases))
0271
2021-04-29
op
TAILQ_INSERT_HEAD(&host->aliases, a, aliases);
0273
2021-04-29
op
TAILQ_INSERT_TAIL(&host->aliases, a, aliases);
0275
2021-07-19
op
| CERT string {
0276
2021-05-03
op
only_once(host->cert, "cert");
0277
2021-05-03
op
host->cert = ensure_absolute_path($2);
0279
2021-07-19
op
| KEY string {
0280
2021-05-03
op
only_once(host->key, "key");
0281
2021-05-03
op
host->key = ensure_absolute_path($2);
0283
2021-10-15
op
| OCSP string {
0284
2021-10-15
op
only_once(host->ocsp, "ocsp");
0285
2021-10-15
op
host->ocsp = ensure_absolute_path($2);
0287
2021-07-19
op
| PARAM string '=' string {
0288
2022-09-10
op
add_param($2, $4);
0290
2021-01-24
op
| locopt
0293
2021-01-02
op
proxy : PROXY { advance_proxy(); }
0294
2021-01-02
op
proxy_matches '{' optnl proxy_opts '}' {
0295
2021-01-02
op
if (proxy->host == NULL)
0296
2021-01-02
op
yyerror("invalid proxy block: missing `relay-to' option");
0298
2021-01-02
op
if ((proxy->cert == NULL && proxy->key != NULL) ||
0299
2021-01-02
op
(proxy->cert != NULL && proxy->key == NULL))
0300
2021-01-02
op
yyerror("invalid proxy block: missing cert or key");
0304
2021-01-02
op
proxy_matches : /* empty */
0305
2021-01-02
op
| proxy_matches proxy_match
0308
2021-01-02
op
proxy_match : PROTO string {
0309
2021-01-02
op
only_once(proxy->match_proto, "proxy proto");
0310
2021-01-02
op
free(proxy->match_proto);
0311
2021-01-02
op
proxy->match_proto = $2;
0313
2021-01-02
op
| FOR_HOST string {
0314
2021-01-02
op
only_once(proxy->match_host, "proxy for-host");
0315
2021-01-02
op
free(proxy->match_host);
0316
2021-01-02
op
parsehp($2, &proxy->match_host, &proxy->match_port, "10965");
0320
2021-01-01
op
proxy_opts : /* empty */
0321
2021-01-01
op
| proxy_opts proxy_opt optnl
0324
2021-01-01
op
proxy_opt : CERT string {
0325
2021-01-02
op
only_once(proxy->cert, "proxy cert");
0326
2021-01-02
op
tls_unload_file(proxy->cert, proxy->certlen);
0327
2021-01-01
op
ensure_absolute_path($2);
0328
2021-01-02
op
proxy->cert = tls_load_file($2, &proxy->certlen, NULL);
0329
2021-01-02
op
if (proxy->cert == NULL)
0330
2021-01-01
op
yyerror("can't load cert %s", $2);
0331
2021-01-01
op
free($2);
0333
2021-01-01
op
| KEY string {
0334
2021-01-02
op
only_once(proxy->key, "proxy key");
0335
2021-01-02
op
tls_unload_file(proxy->key, proxy->keylen);
0336
2021-01-01
op
ensure_absolute_path($2);
0337
2021-01-02
op
proxy->key = tls_load_file($2, &proxy->keylen, NULL);
0338
2021-01-02
op
if (proxy->key == NULL)
0339
2021-01-01
op
yyerror("can't load key %s", $2);
0340
2021-01-01
op
free($2);
0342
2021-01-01
op
| PROTOCOLS string {
0343
2021-01-02
op
if (tls_config_parse_protocols(&proxy->protocols, $2) == -1)
0344
2021-01-01
op
yyerror("invalid protocols string \"%s\"", $2);
0345
2021-01-01
op
free($2);
0347
2021-01-01
op
| RELAY_TO string {
0348
2021-01-02
op
only_once(proxy->host, "proxy relay-to");
0349
2021-01-02
op
free(proxy->host);
0350
2021-01-02
op
parsehp($2, &proxy->host, &proxy->port, "1965");
0352
2022-01-04
op
| REQUIRE CLIENT CA string {
0353
2022-01-04
op
only_once(proxy->reqca, "require client ca");
0354
2022-01-04
op
ensure_absolute_path($4);
0355
2022-01-04
op
if ((proxy->reqca = load_ca($4)) == NULL)
0356
2022-01-04
op
yyerror("couldn't load ca cert: %s", $4);
0357
2022-01-04
op
free($4);
0359
2022-01-30
op
| SNI string {
0360
2022-01-30
op
only_once(proxy->sni, "proxy sni");
0361
2022-01-30
op
free(proxy->sni);
0362
2022-01-30
op
proxy->sni = $2;
0364
2021-01-01
op
| USE_TLS bool {
0365
2021-01-02
op
proxy->notls = !$2;
0367
2021-01-01
op
| VERIFYNAME bool {
0368
2021-01-02
op
proxy->noverifyname = !$2;
0372
2021-07-19
op
location : LOCATION { advance_loc(); } string '{' optnl locopts '}' {
0373
2021-02-10
op
/* drop the starting '/' if any */
0374
2021-02-10
op
if (*$3 == '/')
0375
2021-02-10
op
memmove($3, $3+1, strlen($3));
0376
2021-02-10
op
loc->match = $3;
0378
2021-01-24
op
| error '}'
0381
2021-01-24
op
locopts : /* empty */
0382
2021-07-09
op
| locopts locopt optnl
0385
2021-07-19
op
locopt : AUTO INDEX bool { loc->auto_index = $3 ? 1 : -1; }
0386
2021-07-19
op
| BLOCK RETURN NUM string {
0387
2021-05-03
op
only_once(loc->block_fmt, "block");
0388
2021-02-06
op
loc->block_fmt = check_block_fmt($4);
0389
2021-02-06
op
loc->block_code = check_block_code($3);
0391
2021-07-19
op
| BLOCK RETURN NUM {
0392
2021-05-03
op
only_once(loc->block_fmt, "block");
0393
2021-02-06
op
loc->block_fmt = xstrdup("temporary failure");
0394
2021-02-06
op
loc->block_code = check_block_code($3);
0395
2021-02-06
op
if ($3 >= 30 && $3 < 40)
0396
2021-02-06
op
yyerror("missing `meta' for block return %d", $3);
0398
2021-07-19
op
| BLOCK {
0399
2021-05-03
op
only_once(loc->block_fmt, "block");
0400
2021-02-06
op
loc->block_fmt = xstrdup("temporary failure");
0401
2021-02-06
op
loc->block_code = 40;
0403
2021-07-19
op
| DEFAULT TYPE string {
0404
2021-05-03
op
only_once(loc->default_mime, "default type");
0405
2021-02-09
op
loc->default_mime = $3;
0407
2021-07-19
op
| FASTCGI fastcgi
0408
2021-07-19
op
| INDEX string {
0409
2021-05-03
op
only_once(loc->index, "index");
0410
2021-02-09
op
loc->index = $2;
0412
2021-07-19
op
| LANG string {
0413
2021-05-03
op
only_once(loc->lang, "lang");
0414
2021-02-09
op
loc->lang = $2;
0416
2021-07-19
op
| LOG bool { loc->disable_log = !$2; }
0417
2021-01-01
op
| REQUIRE CLIENT CA string {
0418
2021-01-01
op
only_once(loc->reqca, "require client ca");
0419
2021-01-01
op
ensure_absolute_path($4);
0420
2021-01-01
op
if ((loc->reqca = load_ca($4)) == NULL)
0421
2021-01-01
op
yyerror("couldn't load ca cert: %s", $4);
0422
2021-01-01
op
free($4);
0424
2021-01-01
op
| ROOT string {
0425
2021-01-01
op
only_once(loc->dir, "root");
0426
2021-01-01
op
loc->dir = ensure_absolute_path($2);
0428
2021-01-01
op
| STRIP NUM { loc->strip = check_strip_no($2); }
0431
2021-07-19
op
fastcgi : SPAWN string {
0432
2021-05-24
op
only_oncei(loc->fcgi, "fastcgi");
0433
2021-05-24
op
loc->fcgi = fastcgi_conf(NULL, NULL, $2);
0435
2021-06-29
op
| string {
0436
2021-05-24
op
only_oncei(loc->fcgi, "fastcgi");
0437
2021-05-24
op
loc->fcgi = fastcgi_conf($1, NULL, NULL);
0439
2021-07-19
op
| TCP string PORT NUM {
0440
2021-05-24
op
char *c;
0441
2021-07-09
op
if (asprintf(&c, "%d", $4) == -1)
0442
2021-05-24
op
err(1, "asprintf");
0443
2021-05-24
op
only_oncei(loc->fcgi, "fastcgi");
0444
2021-05-24
op
loc->fcgi = fastcgi_conf($2, c, NULL);
0446
2021-07-19
op
| TCP string {
0447
2021-05-24
op
only_oncei(loc->fcgi, "fastcgi");
0448
2021-05-24
op
loc->fcgi = fastcgi_conf($2, xstrdup("9000"), NULL);
0450
2021-07-19
op
| TCP string PORT string {
0451
2021-05-24
op
only_oncei(loc->fcgi, "fastcgi");
0452
2021-07-09
op
loc->fcgi = fastcgi_conf($2, $4, NULL);
0456
2022-09-10
op
types : TYPES '{' optnl mediaopts_l '}' ;
0458
2022-02-26
op
mediaopts_l : mediaopts_l mediaoptsl nl
0459
2022-02-26
op
| mediaoptsl nl
0462
2022-09-10
op
mediaoptsl : STRING {
0463
2022-09-10
op
free(current_media);
0464
2022-09-10
op
current_media = $1;
0465
2022-09-10
op
} medianames_l optsemicolon
0466
2022-02-26
op
| include
0469
2022-02-26
op
medianames_l : medianames_l medianamesl
0470
2022-02-26
op
| medianamesl
0473
2022-04-08
op
medianamesl : numberstring {
0474
2022-04-08
op
if (add_mime(&conf.mime, current_media, $1) == -1)
0475
2022-04-08
op
err(1, "add_mime");
0476
2022-09-10
op
free($1);
0480
2022-02-26
op
nl : '\n' optnl
0483
2021-07-09
op
optnl : '\n' optnl /* zero or more newlines */
0484
2021-07-09
op
| ';' optnl /* semicolons too */
0485
2021-07-09
op
| /*empty*/
0488
2022-02-26
op
optsemicolon : ';'
0494
2022-03-19
op
static const struct keyword {
0495
2021-06-16
op
const char *word;
0496
2021-06-16
op
int token;
0497
2021-06-16
op
} keywords[] = {
0498
2021-07-09
op
/* these MUST be sorted */
0499
2021-07-19
op
{"alias", ALIAS},
0500
2021-07-19
op
{"auto", AUTO},
0501
2021-07-19
op
{"block", BLOCK},
0502
2021-07-19
op
{"ca", CA},
0503
2021-07-19
op
{"cert", CERT},
0504
2021-07-19
op
{"chroot", CHROOT},
0505
2021-07-19
op
{"client", CLIENT},
0506
2021-07-19
op
{"default", DEFAULT},
0507
2021-07-19
op
{"fastcgi", FASTCGI},
0508
2021-01-02
op
{"for-host", FOR_HOST},
0509
2022-02-26
op
{"include", INCLUDE},
0510
2021-07-19
op
{"index", INDEX},
0511
2021-07-19
op
{"ipv6", IPV6},
0512
2021-07-19
op
{"key", KEY},
0513
2021-07-19
op
{"lang", LANG},
0514
2021-07-19
op
{"location", LOCATION},
0515
2021-07-19
op
{"log", LOG},
0516
2021-10-15
op
{"ocsp", OCSP},
0517
2021-07-19
op
{"off", OFF},
0518
2021-07-19
op
{"on", ON},
0519
2021-07-19
op
{"param", PARAM},
0520
2021-07-19
op
{"port", PORT},
0521
2021-07-19
op
{"prefork", PREFORK},
0522
2021-01-02
op
{"proto", PROTO},
0523
2021-07-19
op
{"protocols", PROTOCOLS},
0524
2021-12-29
op
{"proxy", PROXY},
0525
2021-12-29
op
{"relay-to", RELAY_TO},
0526
2021-07-19
op
{"require", REQUIRE},
0527
2021-07-19
op
{"return", RETURN},
0528
2021-07-19
op
{"root", ROOT},
0529
2021-07-19
op
{"server", SERVER},
0530
2022-01-30
op
{"sni", SNI},
0531
2021-07-19
op
{"spawn", SPAWN},
0532
2021-07-19
op
{"strip", STRIP},
0533
2021-07-19
op
{"tcp", TCP},
0534
2021-07-19
op
{"to-ext", TOEXT},
0535
2021-07-19
op
{"type", TYPE},
0536
2022-02-26
op
{"types", TYPES},
0537
2021-01-01
op
{"use-tls", USE_TLS},
0538
2021-07-19
op
{"user", USER},
0539
2021-01-01
op
{"verifyname", VERIFYNAME},
0543
2021-07-09
op
yyerror(const char *msg, ...)
0545
2021-07-09
op
va_list ap;
0547
2021-07-09
op
file->errors++;
0549
2021-07-09
op
va_start(ap, msg);
0550
2021-07-13
op
fprintf(stderr, "%s:%d error: ", config_path, yylval.lineno);
0551
2021-07-13
op
vfprintf(stderr, msg, ap);
0552
2021-07-13
op
fprintf(stderr, "\n");
0553
2021-07-13
op
va_end(ap);
0557
2021-07-13
op
yywarn(const char *msg, ...)
0559
2021-07-13
op
va_list ap;
0561
2021-07-13
op
va_start(ap, msg);
0562
2021-07-13
op
fprintf(stderr, "%s:%d warning: ", config_path, yylval.lineno);
0563
2021-07-09
op
vfprintf(stderr, msg, ap);
0564
2021-07-09
op
fprintf(stderr, "\n");
0565
2021-07-09
op
va_end(ap);
0569
2021-07-09
op
kw_cmp(const void *k, const void *e)
0571
2021-07-09
op
return strcmp(k, ((struct keyword *)e)->word);
0575
2021-07-09
op
lookup(char *s)
0577
2021-07-09
op
const struct keyword *p;
0579
2021-07-09
op
p = bsearch(s, keywords, sizeof(keywords)/sizeof(keywords[0]),
0580
2021-07-09
op
sizeof(keywords[0]), kw_cmp);
0583
2021-07-09
op
return p->token;
0585
2021-07-09
op
return STRING;
0588
2021-07-09
op
#define START_EXPAND 1
0589
2021-07-09
op
#define DONE_EXPAND 2
0591
2021-07-09
op
static int expanding;
0594
2021-07-09
op
igetc(void)
0598
2021-07-09
op
while (1) {
0599
2021-07-09
op
if (file->ungetpos > 0)
0600
2021-07-09
op
c = file->ungetbuf[--file->ungetpos];
0602
2021-07-09
op
c = getc(file->stream);
0604
2021-07-09
op
if (c == START_EXPAND)
0605
2021-07-09
op
expanding = 1;
0606
2021-07-09
op
else if (c == DONE_EXPAND)
0607
2021-07-09
op
expanding = 0;
0611
2021-07-09
op
return c;
0615
2021-07-09
op
lgetc(int quotec)
0617
2021-07-09
op
int c, next;
0619
2021-07-09
op
if (quotec) {
0620
2021-07-09
op
if ((c = igetc()) == EOF) {
0621
2021-07-09
op
yyerror("reached end of file while parsing "
0622
2021-07-09
op
"quoted string");
0623
2021-07-09
op
if (file == topfile || popfile() == EOF)
0624
2021-07-09
op
return EOF;
0625
2021-07-09
op
return quotec;
0627
2021-06-16
op
return c;
0630
2021-07-09
op
while ((c = igetc()) == '\\') {
0631
2021-07-09
op
next = igetc();
0632
2021-07-09
op
if (next != '\n') {
0633
2021-07-09
op
c = next;
0636
2021-07-09
op
yylval.lineno = file->lineno;
0637
2021-07-09
op
file->lineno++;
0640
2021-07-09
op
if (c == EOF) {
0642
2021-07-09
op
* Fake EOL when hit EOF for the first time. This gets line
0643
2021-07-09
op
* count right if last line in included file is syntactically
0644
2021-07-09
op
* invalid and has no newline.
0646
2021-07-09
op
if (file->eof_reached == 0) {
0647
2021-07-09
op
file->eof_reached = 1;
0648
2021-07-09
op
return '\n';
0650
2021-07-09
op
while (c == EOF) {
0651
2021-07-09
op
if (file == topfile || popfile() == EOF)
0652
2021-07-09
op
return EOF;
0653
2021-07-09
op
c = igetc();
0656
2021-07-09
op
return c;
0660
2021-07-09
op
lungetc(int c)
0662
2021-07-09
op
if (c == EOF)
0665
2021-07-09
op
if (file->ungetpos >= file->ungetsize) {
0666
2021-07-09
op
void *p = reallocarray(file->ungetbuf, file->ungetsize, 2);
0667
2021-07-09
op
if (p == NULL)
0668
2021-07-09
op
err(1, "lungetc");
0669
2021-07-09
op
file->ungetbuf = p;
0670
2021-07-09
op
file->ungetsize *= 2;
0672
2021-07-09
op
file->ungetbuf[file->ungetpos++] = c;
0676
2021-07-09
op
findeol(void)
0680
2021-07-09
op
/* Skip to either EOF or the first real EOL. */
0681
2021-07-09
op
while (1) {
0682
2021-07-09
op
c = lgetc(0);
0683
2021-07-09
op
if (c == '\n') {
0684
2021-07-09
op
file->lineno++;
0687
2021-07-09
op
if (c == EOF)
0690
2021-07-09
op
return ERROR;
0694
2021-07-09
op
yylex(void)
0696
2021-07-09
op
char buf[8096];
0697
2021-07-09
op
char *p, *val;
0698
2021-07-09
op
int quotec, next, c;
0699
2021-07-09
op
int token;
0702
2021-07-09
op
p = buf;
0703
2021-07-09
op
while ((c = lgetc(0)) == ' ' || c == '\t')
0704
2021-07-09
op
; /* nothing */
0706
2021-07-09
op
yylval.lineno = file->lineno;
0707
2021-07-09
op
if (c == '#')
0708
2021-07-09
op
while ((c = lgetc(0)) != '\n' && c != EOF)
0709
2021-07-09
op
; /* nothing */
0710
2021-07-09
op
if (c == '$' && !expanding) {
0711
2021-07-09
op
while (1) {
0712
2021-07-09
op
if ((c = lgetc(0)) == EOF)
0713
2021-07-09
op
return 0;
0714
2021-07-09
op
if (p + 1 >= buf + sizeof(buf) -1) {
0715
2021-07-09
op
yyerror("string too long");
0716
2021-07-09
op
return findeol();
0718
2021-07-09
op
if (isalnum(c) || c == '_') {
0719
2021-07-09
op
*p++ = c;
0720
2021-07-09
op
continue;
0722
2021-07-09
op
*p = '\0';
0723
2021-07-09
op
lungetc(c);
0726
2021-07-09
op
val = symget(buf);
0727
2021-07-09
op
if (val == NULL) {
0728
2021-07-09
op
yyerror("macro `%s' not defined", buf);
0729
2021-07-09
op
return findeol();
0731
2021-07-09
op
yylval.v.string = xstrdup(val);
0732
2021-07-09
op
return STRING;
0734
2021-07-09
op
if (c == '@' && !expanding) {
0735
2021-07-09
op
while (1) {
0736
2021-07-09
op
if ((c = lgetc(0)) == EOF)
0737
2021-07-09
op
return 0;
0739
2021-07-09
op
if (p + 1 >= buf + sizeof(buf) - 1) {
0740
2021-07-09
op
yyerror("string too long");
0741
2021-07-09
op
return findeol();
0743
2021-07-09
op
if (isalnum(c) || c == '_') {
0744
2021-07-09
op
*p++ = c;
0745
2021-06-16
op
continue;
0747
2021-07-09
op
*p = '\0';
0748
2021-07-09
op
lungetc(c);
0751
2021-07-09
op
val = symget(buf);
0752
2021-07-09
op
if (val == NULL) {
0753
2021-07-09
op
yyerror("macro '%s' not defined", buf);
0754
2021-07-09
op
return findeol();
0756
2021-07-09
op
p = val + strlen(val) - 1;
0757
2021-07-09
op
lungetc(DONE_EXPAND);
0758
2021-07-09
op
while (p >= val) {
0759
2021-07-09
op
lungetc(*p);
0762
2021-07-09
op
lungetc(START_EXPAND);
0763
2021-07-09
op
goto top;
0766
2021-07-09
op
switch (c) {
0767
2021-07-09
op
case '\'':
0768
2021-07-09
op
case '"':
0769
2021-07-09
op
quotec = c;
0770
2021-07-09
op
while (1) {
0771
2021-07-09
op
if ((c = lgetc(quotec)) == EOF)
0772
2021-07-09
op
return 0;
0773
2021-07-09
op
if (c == '\n') {
0774
2021-07-09
op
file->lineno++;
0775
2021-07-09
op
continue;
0776
2021-07-09
op
} else if (c == '\\') {
0777
2021-07-09
op
if ((next = lgetc(quotec)) == EOF)
0778
2021-07-09
op
return (0);
0779
2021-07-09
op
if (next == quotec || next == ' ' ||
0780
2021-07-09
op
next == '\t')
0781
2021-07-09
op
c = next;
0782
2021-07-09
op
else if (next == '\n') {
0783
2021-07-09
op
file->lineno++;
0784
2021-07-09
op
continue;
0786
2021-07-09
op
lungetc(next);
0787
2021-07-09
op
} else if (c == quotec) {
0788
2021-07-09
op
*p = '\0';
0790
2021-07-09
op
} else if (c == '\0') {
0791
2021-07-13
op
yyerror("invalid syntax");
0792
2021-07-09
op
return findeol();
0794
2021-07-09
op
if (p + 1 >= buf + sizeof(buf) - 1) {
0795
2021-07-09
op
yyerror("string too long");
0796
2021-07-09
op
return findeol();
0798
2021-07-09
op
*p++ = c;
0800
2021-07-09
op
yylval.v.string = strdup(buf);
0801
2021-07-09
op
if (yylval.v.string == NULL)
0802
2021-07-09
op
err(1, "yylex: strdup");
0803
2021-07-09
op
return STRING;
0806
2021-07-09
op
#define allowed_to_end_number(x) \
0807
2021-07-09
op
(isspace(x) || x == ')' || x ==',' || x == '/' || x == '}' || x == '=')
0809
2021-07-09
op
if (c == '-' || isdigit(c)) {
0811
2021-07-09
op
*p++ = c;
0812
2021-07-09
op
if ((size_t)(p-buf) >= sizeof(buf)) {
0813
2021-07-09
op
yyerror("string too long");
0814
2021-07-09
op
return findeol();
0816
2021-07-09
op
} while ((c = lgetc(0)) != EOF && isdigit(c));
0817
2021-07-09
op
lungetc(c);
0818
2021-07-09
op
if (p == buf + 1 && buf[0] == '-')
0819
2021-07-09
op
goto nodigits;
0820
2021-07-09
op
if (c == EOF || allowed_to_end_number(c)) {
0821
2021-07-09
op
const char *errstr = NULL;
0823
2021-07-09
op
*p = '\0';
0824
2021-07-09
op
yylval.v.number = strtonum(buf, LLONG_MIN,
0825
2021-07-09
op
LLONG_MAX, &errstr);
0826
2021-07-09
op
if (errstr) {
0827
2021-07-09
op
yyerror("\"%s\" invalid number: %s",
0828
2021-07-09
op
buf, errstr);
0829
2021-07-09
op
return findeol();
0831
2021-07-09
op
return NUM;
0832
2021-07-09
op
} else {
0833
2021-07-09
op
nodigits:
0834
2021-07-09
op
while (p > buf + 1)
0835
2021-07-09
op
lungetc(*--p);
0836
2021-07-09
op
c = *--p;
0837
2021-07-09
op
if (c == '-')
0838
2021-07-09
op
return c;
0842
2021-07-09
op
#define allowed_in_string(x) \
0843
2021-07-09
op
(isalnum(x) || (ispunct(x) && x != '(' && x != ')' && \
0844
2021-07-09
op
x != '{' && x != '}' && \
0845
2021-07-09
op
x != '!' && x != '=' && x != '#' && \
0846
2021-07-09
op
x != ',' && x != ';'))
0848
2021-07-09
op
if (isalnum(c) || c == ':' || c == '_') {
0850
2021-07-09
op
*p++ = c;
0851
2021-07-09
op
if ((size_t)(p-buf) >= sizeof(buf)) {
0852
2021-07-09
op
yyerror("string too long");
0853
2021-07-09
op
return findeol();
0855
2021-07-09
op
} while ((c = lgetc(0)) != EOF && (allowed_in_string(c)));
0856
2021-07-09
op
lungetc(c);
0857
2021-07-09
op
*p = '\0';
0858
2021-07-09
op
if ((token = lookup(buf)) == STRING)
0859
2021-07-09
op
yylval.v.string = xstrdup(buf);
0860
2021-07-09
op
return token;
0862
2021-07-09
op
if (c == '\n') {
0863
2021-07-09
op
yylval.lineno = file->lineno;
0864
2021-07-09
op
file->lineno++;
0866
2021-07-09
op
if (c == EOF)
0867
2021-07-09
op
return 0;
0868
2021-07-09
op
return c;
0871
2021-07-09
op
struct file *
0872
2021-07-09
op
pushfile(const char *name, int secret)
0874
2021-07-09
op
struct file *nfile;
0876
2021-07-09
op
nfile = xcalloc(1, sizeof(*nfile));
0877
2021-07-09
op
nfile->name = xstrdup(name);
0878
2021-07-09
op
if ((nfile->stream = fopen(nfile->name, "r")) == NULL) {
0879
2021-08-23
op
log_warn(NULL, "can't open %s: %s", nfile->name,
0880
2021-07-09
op
strerror(errno));
0881
2021-07-09
op
free(nfile->name);
0882
2021-07-09
op
free(nfile);
0883
2021-07-09
op
return NULL;
0885
2021-07-09
op
nfile->lineno = TAILQ_EMPTY(&files) ? 1 : 0;
0886
2021-07-09
op
nfile->ungetsize = 16;
0887
2021-07-09
op
nfile->ungetbuf = xcalloc(1, nfile->ungetsize);
0888
2021-07-09
op
TAILQ_INSERT_TAIL(&files, nfile, entry);
0889
2021-07-09
op
return nfile;
0893
2021-07-09
op
popfile(void)
0895
2021-07-09
op
struct file *prev;
0897
2021-07-09
op
if ((prev = TAILQ_PREV(file, files, entry)) != NULL)
0898
2021-07-09
op
prev->errors += file->errors;
0900
2021-07-09
op
TAILQ_REMOVE(&files, file, entry);
0901
2021-07-09
op
fclose(file->stream);
0902
2021-07-09
op
free(file->name);
0903
2021-07-09
op
free(file->ungetbuf);
0904
2021-07-09
op
free(file);
0905
2021-07-09
op
file = prev;
0906
2021-07-09
op
return file ? 0 : EOF;
0910
2021-07-09
op
parse_conf(const char *filename)
0912
2021-07-09
op
struct sym *sym, *next;
0914
2021-07-09
op
file = pushfile(filename, 0);
0915
2021-07-09
op
if (file == NULL)
0916
2021-08-23
op
exit(1);
0917
2021-07-09
op
topfile = file;
0919
2021-01-27
op
yyparse();
0920
2021-07-09
op
errors = file->errors;
0921
2021-07-09
op
popfile();
0923
2021-07-09
op
/* Free macros and check which have not been used. */
0924
2021-06-29
op
TAILQ_FOREACH_SAFE(sym, &symhead, entry, next) {
0925
2021-06-29
op
/* TODO: warn if !sym->used */
0926
2021-06-29
op
if (!sym->persist) {
0927
2021-06-29
op
free(sym->name);
0928
2021-06-29
op
free(sym->val);
0929
2021-06-29
op
TAILQ_REMOVE(&symhead, sym, entry);
0930
2021-06-29
op
free(sym);
0934
2021-07-09
op
if (errors)
0935
2021-07-09
op
exit(1);
0939
2021-10-09
op
print_conf(void)
0941
2021-10-09
op
struct vhost *h;
0942
2021-10-09
op
/* struct location *l; */
0943
2021-10-09
op
/* struct envlist *e; */
0944
2021-10-09
op
/* struct alist *a; */
0946
2022-09-10
op
if (*conf.chroot != '\0')
0947
2021-10-09
op
printf("chroot \"%s\"\n", conf.chroot);
0948
2021-10-09
op
printf("ipv6 %s\n", conf.ipv6 ? "on" : "off");
0949
2021-10-09
op
/* XXX: defined mimes? */
0950
2021-10-09
op
printf("port %d\n", conf.port);
0951
2021-10-09
op
printf("prefork %d\n", conf.prefork);
0952
2021-10-09
op
/* XXX: protocols? */
0953
2022-09-10
op
if (*conf.user != '\0')
0954
2021-10-09
op
printf("user \"%s\"\n", conf.user);
0956
2021-10-09
op
TAILQ_FOREACH(h, &hosts, vhosts) {
0957
2021-10-09
op
printf("\nserver \"%s\" {\n", h->domain);
0958
2021-10-09
op
printf(" cert \"%s\"\n", h->cert);
0959
2021-10-09
op
printf(" key \"%s\"\n", h->key);
0960
2021-10-09
op
/* TODO: print locations... */
0961
2021-10-09
op
printf("}\n");
0966
2021-07-09
op
symset(const char *name, const char *val, int persist)
0968
2021-07-09
op
struct sym *sym;
0970
2021-07-09
op
TAILQ_FOREACH(sym, &symhead, entry) {
0971
2021-07-09
op
if (!strcmp(name, sym->name))
0975
2021-07-09
op
if (sym != NULL) {
0976
2021-07-09
op
if (sym->persist)
0977
2021-07-09
op
return 0;
0979
2021-07-09
op
free(sym->name);
0980
2021-07-09
op
free(sym->val);
0981
2021-07-09
op
TAILQ_REMOVE(&symhead, sym, entry);
0982
2021-07-09
op
free(sym);
0986
2021-07-09
op
sym = xcalloc(1, sizeof(*sym));
0987
2021-07-09
op
sym->name = xstrdup(name);
0988
2021-07-09
op
sym->val = xstrdup(val);
0989
2021-07-09
op
sym->used = 0;
0990
2021-07-09
op
sym->persist = persist;
0992
2021-07-09
op
TAILQ_INSERT_TAIL(&symhead, sym, entry);
0993
2021-07-09
op
return 0;
0997
2021-07-09
op
cmdline_symset(char *s)
0999
2021-07-09
op
char *sym, *val;
1000
2021-07-09
op
int ret;
1002
2021-07-09
op
if ((val = strrchr(s, '=')) == NULL)
1003
2021-07-09
op
return -1;
1004
2021-07-09
op
sym = xcalloc(1, val - s + 1);
1005
2021-07-09
op
memcpy(sym, s, val - s);
1006
2021-07-09
op
ret = symset(sym, val + 1, 1);
1007
2021-07-09
op
free(sym);
1008
2021-07-09
op
return ret;
1012
2021-07-09
op
symget(const char *nam)
1014
2021-07-09
op
struct sym *sym;
1016
2021-07-09
op
TAILQ_FOREACH(sym, &symhead, entry) {
1017
2021-07-09
op
if (strcmp(nam, sym->name) == 0) {
1018
2021-07-09
op
sym->used = 1;
1019
2021-07-09
op
return sym->val;
1022
2021-07-09
op
return NULL;
1025
2021-07-09
op
struct vhost *
1026
2021-07-09
op
new_vhost(void)
1028
2021-01-02
op
return xcalloc(1, sizeof(struct vhost));
1031
2021-07-09
op
struct location *
1032
2021-07-09
op
new_location(void)
1034
2021-07-09
op
struct location *l;
1036
2021-07-09
op
l = xcalloc(1, sizeof(*l));
1037
2021-07-09
op
l->dirfd = -1;
1038
2021-07-09
op
l->fcgi = -1;
1039
2021-07-09
op
return l;
1042
2021-01-02
op
struct proxy *
1043
2021-01-02
op
new_proxy(void)
1045
2021-01-02
op
struct proxy *p;
1047
2022-09-06
op
conf.can_open_sockets = 1;
1049
2021-01-02
op
p = xcalloc(1, sizeof(*p));
1050
2021-01-02
op
p->protocols = TLS_PROTOCOLS_DEFAULT;
1051
2021-01-02
op
return p;
1055
2021-02-01
op
ensure_absolute_path(char *path)
1057
2021-02-01
op
if (path == NULL || *path != '/')
1058
2021-04-30
op
yyerror("not an absolute path: %s", path);
1059
2021-02-01
op
return path;
1063
2021-02-06
op
check_block_code(int n)
1065
2021-02-06
op
if (n < 10 || n >= 70 || (n >= 20 && n <= 29))
1066
2021-02-06
op
yyerror("invalid block code %d", n);
1067
2021-02-06
op
return n;
1071
2021-02-06
op
check_block_fmt(char *fmt)
1073
2021-02-06
op
char *s;
1075
2021-02-06
op
for (s = fmt; *s; ++s) {
1076
2021-02-06
op
if (*s != '%')
1077
2021-02-06
op
continue;
1078
2021-02-06
op
switch (*++s) {
1079
2021-02-06
op
case '%':
1080
2021-02-06
op
case 'p':
1081
2021-02-06
op
case 'q':
1082
2021-02-06
op
case 'P':
1083
2021-02-06
op
case 'N':
1085
2021-02-06
op
default:
1086
2021-02-06
op
yyerror("invalid format specifier %%%c", *s);
1090
2021-02-06
op
return fmt;
1094
2021-02-06
op
check_strip_no(int n)
1096
2021-02-06
op
if (n <= 0)
1097
2021-02-06
op
yyerror("invalid strip number %d", n);
1098
2021-02-07
op
return n;
1102
2021-07-09
op
check_port_num(int n)
1104
2021-07-09
op
if (n <= 0 || n >= UINT16_MAX)
1105
2021-07-09
op
yyerror("port number is %s: %d",
1106
2021-07-09
op
n <= 0 ? "too small" : "too large",
1108
2021-07-09
op
return n;
1112
2021-02-07
op
check_prefork_num(int n)
1114
2021-03-03
op
if (n <= 0 || n >= PROC_MAX)
1115
2021-02-07
op
yyerror("invalid prefork number %d", n);
1116
2021-02-06
op
return n;
1120
2021-02-10
op
advance_loc(void)
1122
2021-03-31
op
loc = new_location();
1123
2021-03-31
op
TAILQ_INSERT_TAIL(&host->locations, loc, locations);
1127
2021-01-02
op
advance_proxy(void)
1129
2021-01-02
op
proxy = new_proxy();
1130
2021-01-02
op
TAILQ_INSERT_TAIL(&host->proxies, proxy, proxies);
1134
2021-01-02
op
parsehp(char *str, char **host, const char **port, const char *def)
1136
2021-01-02
op
char *at;
1137
2021-01-02
op
const char *errstr;
1139
2021-01-02
op
*host = str;
1141
2021-01-02
op
if ((at = strchr(str, ':')) != NULL) {
1142
2021-01-02
op
*at++ = '\0';
1143
2021-01-02
op
*port = at;
1145
2021-01-02
op
*port = def;
1147
2021-01-02
op
strtonum(*port, 1, UINT16_MAX, &errstr);
1148
2021-01-02
op
if (errstr != NULL)
1149
2021-01-02
op
yyerror("port is %s: %s", errstr, *port);
1153
2021-05-03
op
only_once(const void *ptr, const char *name)
1155
2021-05-03
op
if (ptr != NULL)
1156
2021-05-03
op
yyerror("`%s' specified more than once", name);
1160
2021-05-09
op
only_oncei(int i, const char *name)
1162
2021-05-09
op
if (i != -1)
1163
2021-05-09
op
yyerror("`%s' specified more than once", name);
1167
2021-05-09
op
fastcgi_conf(char *path, char *port, char *prog)
1169
2021-05-09
op
struct fcgi *f;
1172
2022-09-06
op
conf.can_open_sockets = 1;
1174
2021-05-09
op
for (i = 0; i < FCGI_MAX; ++i) {
1175
2021-05-09
op
f = &fcgi[i];
1177
2021-05-09
op
if (f->path == NULL) {
1178
2021-05-09
op
f->id = i;
1179
2021-05-09
op
f->path = path;
1180
2021-05-09
op
f->port = port;
1181
2021-05-09
op
f->prog = prog;
1182
2021-05-09
op
return i;
1185
2021-05-09
op
/* XXX: what to do with prog? */
1186
2021-05-09
op
if (!strcmp(f->path, path) &&
1187
2021-05-09
op
((port == NULL && f->port == NULL) ||
1188
2021-05-09
op
!strcmp(f->port, port))) {
1189
2021-05-09
op
free(path);
1190
2021-05-09
op
free(port);
1191
2021-05-09
op
return i;
1195
2021-05-09
op
yyerror("too much `fastcgi' rules defined.");
1196
2021-05-09
op
return -1;
1200
2022-09-10
op
add_param(char *name, char *val)
1202
2021-06-11
op
struct envlist *e;
1203
2022-09-10
op
struct envhead *h = &host->params;
1205
2021-06-11
op
e = xcalloc(1, sizeof(*e));
1206
2021-06-11
op
e->name = name;
1207
2021-06-11
op
e->value = val;
1208
2021-06-11
op
if (TAILQ_EMPTY(h))
1209
2021-06-11
op
TAILQ_INSERT_HEAD(h, e, envs);
1211
2021-06-11
op
TAILQ_INSERT_TAIL(h, e, envs);