Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Functions about FCGI applications and filters. |
| 3 | * |
| 4 | * Copyright (C) 2019 HAProxy Technologies, Christopher Faulet <cfaulet@haproxy.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | */ |
| 12 | |
Willy Tarreau | dcc048a | 2020-06-04 19:11:43 +0200 | [diff] [blame] | 13 | #include <haproxy/acl.h> |
Willy Tarreau | 4c7e4b7 | 2020-05-27 12:58:42 +0200 | [diff] [blame] | 14 | #include <haproxy/api.h> |
Willy Tarreau | 6be7849 | 2020-06-05 00:00:29 +0200 | [diff] [blame] | 15 | #include <haproxy/cfgparse.h> |
Willy Tarreau | c13ed53 | 2020-06-02 10:22:45 +0200 | [diff] [blame] | 16 | #include <haproxy/chunk.h> |
Willy Tarreau | 8d36697 | 2020-05-27 16:10:29 +0200 | [diff] [blame] | 17 | #include <haproxy/errors.h> |
Willy Tarreau | c659968 | 2020-06-04 21:33:21 +0200 | [diff] [blame] | 18 | #include <haproxy/fcgi-app.h> |
Willy Tarreau | c7babd8 | 2020-06-04 21:29:29 +0200 | [diff] [blame] | 19 | #include <haproxy/filters.h> |
Willy Tarreau | 126ba3a | 2020-06-04 18:26:43 +0200 | [diff] [blame] | 20 | #include <haproxy/http_fetch.h> |
Willy Tarreau | 8773533 | 2020-06-04 09:08:41 +0200 | [diff] [blame] | 21 | #include <haproxy/http_htx.h> |
Willy Tarreau | aeed4a8 | 2020-06-04 22:01:04 +0200 | [diff] [blame] | 22 | #include <haproxy/log.h> |
Willy Tarreau | 03f839d | 2021-05-08 20:23:18 +0200 | [diff] [blame] | 23 | #include <haproxy/proxy.h> |
Willy Tarreau | 7cd8b6e | 2020-06-02 17:32:26 +0200 | [diff] [blame] | 24 | #include <haproxy/regex.h> |
Willy Tarreau | e6ce10b | 2020-06-04 15:33:47 +0200 | [diff] [blame] | 25 | #include <haproxy/sample.h> |
Willy Tarreau | 1e56f92 | 2020-06-04 23:20:13 +0200 | [diff] [blame] | 26 | #include <haproxy/server-t.h> |
Willy Tarreau | 48d25b3 | 2020-06-04 18:58:52 +0200 | [diff] [blame] | 27 | #include <haproxy/session.h> |
Christopher Faulet | c97406f | 2020-06-22 11:07:18 +0200 | [diff] [blame] | 28 | #include <haproxy/sink.h> |
Willy Tarreau | 48fbcae | 2020-06-03 18:09:46 +0200 | [diff] [blame] | 29 | #include <haproxy/tools.h> |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 30 | |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 31 | |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 32 | /* Global list of all FCGI applications */ |
| 33 | static struct fcgi_app *fcgi_apps = NULL; |
| 34 | |
| 35 | struct flt_ops fcgi_flt_ops; |
| 36 | const char *fcgi_flt_id = "FCGI filter"; |
| 37 | |
| 38 | DECLARE_STATIC_POOL(pool_head_fcgi_flt_ctx, "fcgi_flt_ctx", sizeof(struct fcgi_flt_ctx)); |
| 39 | DECLARE_STATIC_POOL(pool_head_fcgi_param_rule, "fcgi_param_rule", sizeof(struct fcgi_param_rule)); |
| 40 | DECLARE_STATIC_POOL(pool_head_fcgi_hdr_rule, "fcgi_hdr_rule", sizeof(struct fcgi_hdr_rule)); |
| 41 | |
| 42 | /**************************************************************************/ |
| 43 | /***************************** Uitls **************************************/ |
| 44 | /**************************************************************************/ |
| 45 | /* Makes a fcgi parameter name (prefixed by ':fcgi-') with <name> (in |
| 46 | * lowercase). All non alphanumeric character are replaced by an underscore |
Ilya Shipitsin | 0188108 | 2021-08-07 14:41:56 +0500 | [diff] [blame] | 47 | * ('_'). The result is copied into <dst>. the corresponding ist is returned. |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 48 | */ |
| 49 | static struct ist fcgi_param_name(char *dst, const struct ist name) |
| 50 | { |
| 51 | size_t ofs1, ofs2; |
| 52 | |
| 53 | memcpy(dst, ":fcgi-", 6); |
| 54 | ofs1 = 6; |
| 55 | for (ofs2 = 0; ofs2 < name.len; ofs2++) { |
Willy Tarreau | 9080711 | 2020-02-25 08:16:33 +0100 | [diff] [blame] | 56 | if (isalnum((unsigned char)name.ptr[ofs2])) |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 57 | dst[ofs1++] = ist_lc[(unsigned char)name.ptr[ofs2]]; |
| 58 | else |
| 59 | dst[ofs1++] = '_'; |
| 60 | } |
| 61 | return ist2(dst, ofs1); |
| 62 | } |
| 63 | |
Ilya Shipitsin | 47d1718 | 2020-06-21 21:42:57 +0500 | [diff] [blame] | 64 | /* Returns a pointer to the FCGi application matching the name <name>. NULL is |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 65 | * returned if no match found. |
| 66 | */ |
| 67 | struct fcgi_app *fcgi_app_find_by_name(const char *name) |
| 68 | { |
| 69 | struct fcgi_app *app; |
| 70 | |
| 71 | for (app = fcgi_apps; app != NULL; app = app->next) { |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 72 | if (strcmp(app->name, name) == 0) |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 73 | return app; |
| 74 | } |
| 75 | |
| 76 | return NULL; |
| 77 | } |
| 78 | |
| 79 | struct fcgi_flt_conf *find_px_fcgi_conf(struct proxy *px) |
| 80 | { |
| 81 | struct flt_conf *fconf; |
| 82 | |
| 83 | list_for_each_entry(fconf, &px->filter_configs, list) { |
| 84 | if (fconf->id == fcgi_flt_id) |
| 85 | return fconf->conf; |
| 86 | } |
| 87 | return NULL; |
| 88 | } |
| 89 | |
| 90 | struct fcgi_flt_ctx *find_strm_fcgi_ctx(struct stream *s) |
| 91 | { |
| 92 | struct filter *filter; |
| 93 | |
| 94 | if (!s) |
| 95 | return NULL; |
| 96 | |
| 97 | list_for_each_entry(filter, &strm_flt(s)->filters, list) { |
| 98 | if (FLT_ID(filter) == fcgi_flt_id) |
| 99 | return FLT_CONF(filter); |
| 100 | } |
| 101 | return NULL; |
| 102 | } |
| 103 | |
| 104 | struct fcgi_app *get_px_fcgi_app(struct proxy *px) |
| 105 | { |
| 106 | struct fcgi_flt_conf *fcgi_conf = find_px_fcgi_conf(px); |
| 107 | |
| 108 | if (fcgi_conf) |
| 109 | return fcgi_conf->app; |
| 110 | return NULL; |
| 111 | } |
| 112 | |
| 113 | struct fcgi_app *get_strm_fcgi_app(struct stream *s) |
| 114 | { |
| 115 | struct fcgi_flt_ctx *fcgi_ctx = find_strm_fcgi_ctx(s); |
| 116 | |
| 117 | if (fcgi_ctx) |
| 118 | return fcgi_ctx->app; |
| 119 | return NULL; |
| 120 | } |
| 121 | |
| 122 | static void fcgi_release_rule_conf(struct fcgi_rule_conf *rule) |
| 123 | { |
| 124 | if (!rule) |
| 125 | return; |
| 126 | free(rule->name); |
| 127 | free(rule->value); |
Aurelien DARRAGON | c610095 | 2023-05-11 12:29:51 +0200 | [diff] [blame] | 128 | free_acl_cond(rule->cond); |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 129 | free(rule); |
| 130 | } |
| 131 | |
| 132 | static void fcgi_release_rule(struct fcgi_rule *rule) |
| 133 | { |
| 134 | if (!rule) |
| 135 | return; |
| 136 | |
| 137 | if (!LIST_ISEMPTY(&rule->value)) { |
| 138 | struct logformat_node *lf, *lfb; |
| 139 | |
| 140 | list_for_each_entry_safe(lf, lfb, &rule->value, list) { |
Willy Tarreau | 2b71810 | 2021-04-21 07:32:39 +0200 | [diff] [blame] | 141 | LIST_DELETE(&lf->list); |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 142 | release_sample_expr(lf->expr); |
| 143 | free(lf->arg); |
| 144 | free(lf); |
| 145 | } |
| 146 | } |
| 147 | /* ->cond and ->name are not owned by the rule */ |
| 148 | free(rule); |
| 149 | } |
| 150 | |
| 151 | /**************************************************************************/ |
| 152 | /*********************** FCGI Sample fetches ******************************/ |
| 153 | /**************************************************************************/ |
| 154 | |
| 155 | static int smp_fetch_fcgi_docroot(const struct arg *args, struct sample *smp, |
| 156 | const char *kw, void *private) |
| 157 | { |
| 158 | struct fcgi_app *app = get_strm_fcgi_app(smp->strm); |
| 159 | |
| 160 | if (!app) |
| 161 | return 0; |
| 162 | |
| 163 | smp->data.type = SMP_T_STR; |
| 164 | smp->data.u.str.area = app->docroot.ptr; |
| 165 | smp->data.u.str.data = app->docroot.len; |
| 166 | smp->flags = SMP_F_CONST; |
| 167 | return 1; |
| 168 | } |
| 169 | |
| 170 | static int smp_fetch_fcgi_index(const struct arg *args, struct sample *smp, |
| 171 | const char *kw, void *private) |
| 172 | { |
| 173 | struct fcgi_app *app = get_strm_fcgi_app(smp->strm); |
| 174 | |
| 175 | if (!app || !istlen(app->index)) |
| 176 | return 0; |
| 177 | |
| 178 | smp->data.type = SMP_T_STR; |
| 179 | smp->data.u.str.area = app->index.ptr; |
| 180 | smp->data.u.str.data = app->index.len; |
| 181 | smp->flags = SMP_F_CONST; |
| 182 | return 1; |
| 183 | } |
| 184 | |
| 185 | /**************************************************************************/ |
| 186 | /************************** FCGI filter ***********************************/ |
| 187 | /**************************************************************************/ |
| 188 | static int fcgi_flt_init(struct proxy *px, struct flt_conf *fconf) |
| 189 | { |
| 190 | fconf->flags |= FLT_CFG_FL_HTX; |
| 191 | return 0; |
| 192 | } |
| 193 | |
| 194 | static void fcgi_flt_deinit(struct proxy *px, struct flt_conf *fconf) |
| 195 | { |
| 196 | struct fcgi_flt_conf *fcgi_conf = fconf->conf; |
| 197 | struct fcgi_rule *rule, *back; |
| 198 | |
| 199 | if (!fcgi_conf) |
| 200 | return; |
| 201 | |
| 202 | free(fcgi_conf->name); |
| 203 | |
| 204 | list_for_each_entry_safe(rule, back, &fcgi_conf->param_rules, list) { |
Willy Tarreau | 2b71810 | 2021-04-21 07:32:39 +0200 | [diff] [blame] | 205 | LIST_DELETE(&rule->list); |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 206 | fcgi_release_rule(rule); |
| 207 | } |
| 208 | |
| 209 | list_for_each_entry_safe(rule, back, &fcgi_conf->hdr_rules, list) { |
Willy Tarreau | 2b71810 | 2021-04-21 07:32:39 +0200 | [diff] [blame] | 210 | LIST_DELETE(&rule->list); |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 211 | fcgi_release_rule(rule); |
| 212 | } |
| 213 | |
| 214 | free(fcgi_conf); |
| 215 | } |
| 216 | |
| 217 | static int fcgi_flt_check(struct proxy *px, struct flt_conf *fconf) |
| 218 | { |
| 219 | struct fcgi_flt_conf *fcgi_conf = fconf->conf; |
| 220 | struct fcgi_rule_conf *crule, *back; |
| 221 | struct fcgi_rule *rule = NULL; |
| 222 | struct flt_conf *f; |
| 223 | char *errmsg = NULL; |
| 224 | |
| 225 | fcgi_conf->app = fcgi_app_find_by_name(fcgi_conf->name); |
| 226 | if (!fcgi_conf->app) { |
Amaury Denoyelle | 1112430 | 2021-06-04 18:22:08 +0200 | [diff] [blame] | 227 | ha_alert("proxy '%s' : fcgi-app '%s' not found.\n", |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 228 | px->id, fcgi_conf->name); |
| 229 | goto err; |
| 230 | } |
| 231 | |
| 232 | list_for_each_entry(f, &px->filter_configs, list) { |
| 233 | if (f->id == http_comp_flt_id || f->id == cache_store_flt_id) |
| 234 | continue; |
| 235 | else if ((f->id == fconf->id) && f->conf != fcgi_conf) { |
Amaury Denoyelle | 1112430 | 2021-06-04 18:22:08 +0200 | [diff] [blame] | 236 | ha_alert("proxy '%s' : only one fcgi-app supported per backend.\n", |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 237 | px->id); |
| 238 | goto err; |
| 239 | } |
| 240 | else if (f->id != fconf->id) { |
| 241 | /* Implicit declaration is only allowed with the |
| 242 | * compression and cache. For other filters, an implicit |
| 243 | * declaration is required. */ |
| 244 | ha_alert("config: proxy '%s': require an explicit filter declaration " |
| 245 | "to use the fcgi-app '%s'.\n", px->id, fcgi_conf->name); |
| 246 | goto err; |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | list_for_each_entry_safe(crule, back, &fcgi_conf->app->conf.rules, list) { |
| 251 | rule = calloc(1, sizeof(*rule)); |
| 252 | if (!rule) { |
Amaury Denoyelle | 1112430 | 2021-06-04 18:22:08 +0200 | [diff] [blame] | 253 | ha_alert("proxy '%s' : out of memory.\n", px->id); |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 254 | goto err; |
| 255 | } |
| 256 | rule->type = crule->type; |
| 257 | rule->name = ist(crule->name); |
| 258 | rule->cond = crule->cond; |
| 259 | LIST_INIT(&rule->value); |
| 260 | |
| 261 | if (crule->value) { |
| 262 | if (!parse_logformat_string(crule->value, px, &rule->value, LOG_OPT_HTTP, |
| 263 | SMP_VAL_BE_HRQ_HDR, &errmsg)) { |
Amaury Denoyelle | 1112430 | 2021-06-04 18:22:08 +0200 | [diff] [blame] | 264 | ha_alert("proxy '%s' : %s.\n", px->id, errmsg); |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 265 | goto err; |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | if (rule->type == FCGI_RULE_SET_PARAM || rule->type == FCGI_RULE_UNSET_PARAM) |
Willy Tarreau | 2b71810 | 2021-04-21 07:32:39 +0200 | [diff] [blame] | 270 | LIST_APPEND(&fcgi_conf->param_rules, &rule->list); |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 271 | else /* FCGI_RULE_PASS_HDR/FCGI_RULE_HIDE_HDR */ |
Willy Tarreau | 2b71810 | 2021-04-21 07:32:39 +0200 | [diff] [blame] | 272 | LIST_APPEND(&fcgi_conf->hdr_rules, &rule->list); |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 273 | } |
| 274 | return 0; |
| 275 | |
| 276 | err: |
| 277 | free(errmsg); |
| 278 | free(rule); |
| 279 | return 1; |
| 280 | } |
| 281 | |
| 282 | static int fcgi_flt_start(struct stream *s, struct filter *filter) |
| 283 | { |
| 284 | struct fcgi_flt_conf *fcgi_conf = FLT_CONF(filter); |
| 285 | struct fcgi_flt_ctx *fcgi_ctx; |
| 286 | |
Willy Tarreau | 18f43d8 | 2021-03-22 15:07:37 +0100 | [diff] [blame] | 287 | fcgi_ctx = pool_alloc(pool_head_fcgi_flt_ctx); |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 288 | if (fcgi_ctx == NULL) { |
| 289 | // FIXME: send a warning |
| 290 | return 0; |
| 291 | } |
| 292 | fcgi_ctx->filter = filter; |
| 293 | fcgi_ctx->app = fcgi_conf->app; |
| 294 | filter->ctx = fcgi_ctx; |
| 295 | |
| 296 | s->req.analysers |= AN_REQ_HTTP_BODY; |
| 297 | return 1; |
| 298 | } |
| 299 | |
| 300 | static void fcgi_flt_stop(struct stream *s, struct filter *filter) |
| 301 | { |
| 302 | struct flt_fcgi_ctx *fcgi_ctx = filter->ctx; |
| 303 | |
| 304 | if (!fcgi_ctx) |
| 305 | return; |
| 306 | pool_free(pool_head_fcgi_flt_ctx, fcgi_ctx); |
| 307 | filter->ctx = NULL; |
| 308 | } |
| 309 | |
| 310 | static int fcgi_flt_http_headers(struct stream *s, struct filter *filter, struct http_msg *msg) |
| 311 | { |
| 312 | struct session *sess = strm_sess(s); |
| 313 | struct buffer *value; |
| 314 | struct fcgi_flt_conf *fcgi_conf = FLT_CONF(filter); |
| 315 | struct fcgi_rule *rule; |
| 316 | struct fcgi_param_rule *param_rule; |
| 317 | struct fcgi_hdr_rule *hdr_rule; |
| 318 | struct ebpt_node *node, *next; |
| 319 | struct eb_root param_rules = EB_ROOT; |
| 320 | struct eb_root hdr_rules = EB_ROOT; |
| 321 | struct htx *htx; |
| 322 | struct http_hdr_ctx ctx; |
| 323 | int ret; |
| 324 | |
| 325 | htx = htxbuf(&msg->chn->buf); |
| 326 | |
| 327 | if (msg->chn->flags & CF_ISRESP) { |
| 328 | struct htx_sl *sl; |
| 329 | |
| 330 | /* Remove the header "Status:" from the response */ |
| 331 | ctx.blk = NULL; |
| 332 | while (http_find_header(htx, ist("status"), &ctx, 1)) |
| 333 | http_remove_header(htx, &ctx); |
| 334 | |
| 335 | /* Add the header "Date:" if not found */ |
| 336 | ctx.blk = NULL; |
| 337 | if (!http_find_header(htx, ist("date"), &ctx, 1)) { |
| 338 | struct tm tm; |
| 339 | |
| 340 | get_gmtime(date.tv_sec, &tm); |
| 341 | trash.data = strftime(trash.area, trash.size, "%a, %d %b %Y %T %Z", &tm); |
| 342 | if (trash.data) |
| 343 | http_add_header(htx, ist("date"), ist2(trash.area, trash.data)); |
| 344 | } |
| 345 | |
| 346 | /* Add the header "Content-Length:" if possible */ |
| 347 | sl = http_get_stline(htx); |
Christopher Faulet | d057960 | 2022-04-06 15:29:34 +0200 | [diff] [blame] | 348 | if (s->txn->meth != HTTP_METH_HEAD && sl && |
Christopher Faulet | 32af9a7 | 2022-04-15 15:26:24 +0200 | [diff] [blame] | 349 | (msg->flags & (HTTP_MSGF_XFER_LEN|HTTP_MSGF_CNT_LEN|HTTP_MSGF_TE_CHNK)) == HTTP_MSGF_XFER_LEN && |
Christopher Faulet | d1ac2b9 | 2020-12-02 19:12:22 +0100 | [diff] [blame] | 350 | (htx->flags & HTX_FL_EOM)) { |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 351 | struct htx_blk * blk; |
| 352 | char *end; |
| 353 | size_t len = 0; |
| 354 | |
| 355 | for (blk = htx_get_first_blk(htx); blk; blk = htx_get_next_blk(htx, blk)) { |
| 356 | enum htx_blk_type type = htx_get_blk_type(blk); |
| 357 | |
Christopher Faulet | d1ac2b9 | 2020-12-02 19:12:22 +0100 | [diff] [blame] | 358 | if (type == HTX_BLK_TLR || type == HTX_BLK_EOT) |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 359 | break; |
| 360 | if (type == HTX_BLK_DATA) |
| 361 | len += htx_get_blksz(blk); |
| 362 | } |
| 363 | end = ultoa_o(len, trash.area, trash.size); |
Christopher Faulet | 32af9a7 | 2022-04-15 15:26:24 +0200 | [diff] [blame] | 364 | if (http_add_header(htx, ist("content-length"), ist2(trash.area, end-trash.area))) { |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 365 | sl->flags |= HTX_SL_F_CLEN; |
Christopher Faulet | 32af9a7 | 2022-04-15 15:26:24 +0200 | [diff] [blame] | 366 | msg->flags |= HTTP_MSGF_CNT_LEN; |
| 367 | } |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | return 1; |
| 371 | } |
| 372 | |
| 373 | /* Analyze the request's headers */ |
| 374 | |
| 375 | value = alloc_trash_chunk(); |
| 376 | if (!value) |
| 377 | goto end; |
| 378 | |
| 379 | list_for_each_entry(rule, &fcgi_conf->param_rules, list) { |
| 380 | if (rule->cond) { |
| 381 | ret = acl_exec_cond(rule->cond, s->be, sess, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL); |
| 382 | ret = acl_pass(ret); |
| 383 | if (rule->cond->pol == ACL_COND_UNLESS) |
| 384 | ret = !ret; |
| 385 | |
| 386 | /* the rule does not match */ |
| 387 | if (!ret) |
| 388 | continue; |
| 389 | } |
| 390 | |
| 391 | param_rule = NULL; |
| 392 | node = ebis_lookup_len(¶m_rules, rule->name.ptr, rule->name.len); |
| 393 | if (node) { |
| 394 | param_rule = container_of(node, struct fcgi_param_rule, node); |
| 395 | ebpt_delete(node); |
| 396 | } |
| 397 | else { |
Willy Tarreau | 18f43d8 | 2021-03-22 15:07:37 +0100 | [diff] [blame] | 398 | param_rule = pool_alloc(pool_head_fcgi_param_rule); |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 399 | if (param_rule == NULL) |
| 400 | goto param_rule_err; |
| 401 | } |
| 402 | |
| 403 | param_rule->node.key = rule->name.ptr; |
| 404 | param_rule->name = rule->name; |
| 405 | param_rule->value = &rule->value; |
| 406 | ebis_insert(¶m_rules, ¶m_rule->node); |
| 407 | } |
| 408 | |
| 409 | list_for_each_entry(rule, &fcgi_conf->hdr_rules, list) { |
| 410 | if (rule->cond) { |
| 411 | ret = acl_exec_cond(rule->cond, s->be, sess, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL); |
| 412 | ret = acl_pass(ret); |
| 413 | if (rule->cond->pol == ACL_COND_UNLESS) |
| 414 | ret = !ret; |
| 415 | |
| 416 | /* the rule does not match */ |
| 417 | if (!ret) |
| 418 | continue; |
| 419 | } |
| 420 | |
| 421 | hdr_rule = NULL; |
| 422 | node = ebis_lookup_len(&hdr_rules, rule->name.ptr, rule->name.len); |
| 423 | if (node) { |
| 424 | hdr_rule = container_of(node, struct fcgi_hdr_rule, node); |
| 425 | ebpt_delete(node); |
| 426 | } |
| 427 | else { |
Willy Tarreau | 18f43d8 | 2021-03-22 15:07:37 +0100 | [diff] [blame] | 428 | hdr_rule = pool_alloc(pool_head_fcgi_hdr_rule); |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 429 | if (hdr_rule == NULL) |
| 430 | goto hdr_rule_err; |
| 431 | } |
| 432 | |
| 433 | hdr_rule->node.key = rule->name.ptr; |
| 434 | hdr_rule->name = rule->name; |
| 435 | hdr_rule->pass = (rule->type == FCGI_RULE_PASS_HDR); |
| 436 | ebis_insert(&hdr_rules, &hdr_rule->node); |
| 437 | } |
| 438 | |
| 439 | node = ebpt_first(¶m_rules); |
| 440 | while (node) { |
| 441 | next = ebpt_next(node); |
| 442 | ebpt_delete(node); |
| 443 | param_rule = container_of(node, struct fcgi_param_rule, node); |
| 444 | node = next; |
| 445 | |
| 446 | b_reset(value); |
| 447 | value->data = build_logline(s, value->area, value->size, param_rule->value); |
Harris Kaufmann | b605a73 | 2020-07-15 16:26:13 +0200 | [diff] [blame] | 448 | if (!value->data) { |
| 449 | pool_free(pool_head_fcgi_param_rule, param_rule); |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 450 | continue; |
Harris Kaufmann | b605a73 | 2020-07-15 16:26:13 +0200 | [diff] [blame] | 451 | } |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 452 | if (!http_add_header(htx, param_rule->name, ist2(value->area, value->data))) |
| 453 | goto rewrite_err; |
| 454 | pool_free(pool_head_fcgi_param_rule, param_rule); |
| 455 | } |
| 456 | |
| 457 | node = ebpt_first(&hdr_rules); |
| 458 | while (node) { |
| 459 | next = ebpt_next(node); |
| 460 | ebpt_delete(node); |
| 461 | hdr_rule = container_of(node, struct fcgi_hdr_rule, node); |
| 462 | node = next; |
| 463 | |
| 464 | if (!hdr_rule->pass) { |
| 465 | ctx.blk = NULL; |
| 466 | while (http_find_header(htx, hdr_rule->name, &ctx, 1)) |
| 467 | http_remove_header(htx, &ctx); |
| 468 | } |
| 469 | pool_free(pool_head_fcgi_hdr_rule, hdr_rule); |
| 470 | } |
| 471 | |
| 472 | goto end; |
| 473 | |
| 474 | rewrite_err: |
Willy Tarreau | 4781b15 | 2021-04-06 13:53:36 +0200 | [diff] [blame] | 475 | _HA_ATOMIC_INC(&sess->fe->fe_counters.failed_rewrites); |
| 476 | _HA_ATOMIC_INC(&s->be->be_counters.failed_rewrites); |
William Lallemand | 36119de | 2021-03-08 15:26:48 +0100 | [diff] [blame] | 477 | if (sess->listener && sess->listener->counters) |
Willy Tarreau | 4781b15 | 2021-04-06 13:53:36 +0200 | [diff] [blame] | 478 | _HA_ATOMIC_INC(&sess->listener->counters->failed_rewrites); |
Christopher Faulet | cff0f73 | 2019-12-16 16:13:44 +0100 | [diff] [blame] | 479 | if (objt_server(s->target)) |
Willy Tarreau | 4781b15 | 2021-04-06 13:53:36 +0200 | [diff] [blame] | 480 | _HA_ATOMIC_INC(&__objt_server(s->target)->counters.failed_rewrites); |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 481 | hdr_rule_err: |
| 482 | node = ebpt_first(&hdr_rules); |
| 483 | while (node) { |
| 484 | next = ebpt_next(node); |
| 485 | ebpt_delete(node); |
| 486 | hdr_rule = container_of(node, struct fcgi_hdr_rule, node); |
| 487 | node = next; |
| 488 | pool_free(pool_head_fcgi_hdr_rule, hdr_rule); |
| 489 | } |
| 490 | param_rule_err: |
| 491 | node = ebpt_first(¶m_rules); |
| 492 | while (node) { |
| 493 | next = ebpt_next(node); |
| 494 | ebpt_delete(node); |
| 495 | param_rule = container_of(node, struct fcgi_param_rule, node); |
| 496 | node = next; |
| 497 | pool_free(pool_head_fcgi_param_rule, param_rule); |
| 498 | } |
| 499 | end: |
| 500 | free_trash_chunk(value); |
| 501 | return 1; |
| 502 | } |
| 503 | |
| 504 | struct flt_ops fcgi_flt_ops = { |
| 505 | .init = fcgi_flt_init, |
| 506 | .check = fcgi_flt_check, |
| 507 | .deinit = fcgi_flt_deinit, |
| 508 | |
| 509 | .attach = fcgi_flt_start, |
| 510 | .detach = fcgi_flt_stop, |
| 511 | |
| 512 | .http_headers = fcgi_flt_http_headers, |
| 513 | }; |
| 514 | |
| 515 | /**************************************************************************/ |
| 516 | /*********************** FCGI Config parsing ******************************/ |
| 517 | /**************************************************************************/ |
| 518 | static int |
| 519 | parse_fcgi_flt(char **args, int *cur_arg, struct proxy *px, |
| 520 | struct flt_conf *fconf, char **err, void *private) |
| 521 | { |
| 522 | struct flt_conf *f, *back; |
| 523 | struct fcgi_flt_conf *fcgi_conf = NULL; |
| 524 | char *name = NULL; |
| 525 | int pos = *cur_arg; |
| 526 | |
| 527 | /* Get the fcgi-app name*/ |
Christopher Faulet | 0ce57b0 | 2019-09-18 11:18:33 +0200 | [diff] [blame] | 528 | if (!*args[pos + 1]) { |
| 529 | memprintf(err, "%s : expects a <name> argument", args[pos]); |
| 530 | goto err; |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 531 | } |
Christopher Faulet | 0ce57b0 | 2019-09-18 11:18:33 +0200 | [diff] [blame] | 532 | name = strdup(args[pos + 1]); |
| 533 | if (!name) { |
| 534 | memprintf(err, "%s '%s' : out of memory", args[pos], args[pos + 1]); |
| 535 | goto err; |
| 536 | } |
| 537 | pos += 2; |
| 538 | |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 539 | /* Check if an fcgi-app filter with the same name already exists */ |
| 540 | list_for_each_entry_safe(f, back, &px->filter_configs, list) { |
| 541 | if (f->id != fcgi_flt_id) |
| 542 | continue; |
| 543 | fcgi_conf = f->conf; |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 544 | if (strcmp(name, fcgi_conf->name) != 0) { |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 545 | fcgi_conf = NULL; |
| 546 | continue; |
| 547 | } |
| 548 | |
| 549 | /* Place the filter at its right position */ |
Willy Tarreau | 2b71810 | 2021-04-21 07:32:39 +0200 | [diff] [blame] | 550 | LIST_DELETE(&f->list); |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 551 | free(f); |
Willy Tarreau | 61cfdf4 | 2021-02-20 10:46:51 +0100 | [diff] [blame] | 552 | ha_free(&name); |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 553 | break; |
| 554 | } |
| 555 | |
| 556 | /* No other fcgi-app filter found, create configuration for the explicit one */ |
| 557 | if (!fcgi_conf) { |
| 558 | fcgi_conf = calloc(1, sizeof(*fcgi_conf)); |
| 559 | if (!fcgi_conf) { |
| 560 | memprintf(err, "%s: out of memory", args[*cur_arg]); |
| 561 | goto err; |
| 562 | } |
| 563 | fcgi_conf->name = name; |
| 564 | LIST_INIT(&fcgi_conf->param_rules); |
| 565 | LIST_INIT(&fcgi_conf->hdr_rules); |
| 566 | } |
| 567 | |
| 568 | fconf->id = fcgi_flt_id; |
| 569 | fconf->conf = fcgi_conf; |
| 570 | fconf->ops = &fcgi_flt_ops; |
| 571 | |
| 572 | *cur_arg = pos; |
| 573 | return 0; |
| 574 | err: |
| 575 | free(name); |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 576 | return -1; |
| 577 | } |
| 578 | |
| 579 | /* Parses the "use-fcgi-app" proxy keyword */ |
| 580 | static int proxy_parse_use_fcgi_app(char **args, int section, struct proxy *curpx, |
Willy Tarreau | 0182516 | 2021-03-09 09:53:46 +0100 | [diff] [blame] | 581 | const struct proxy *defpx, const char *file, int line, |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 582 | char **err) |
| 583 | { |
| 584 | struct flt_conf *fconf = NULL; |
| 585 | struct fcgi_flt_conf *fcgi_conf = NULL; |
| 586 | int retval = 0; |
| 587 | |
Aurelien DARRAGON | d49a580 | 2023-01-12 15:44:22 +0100 | [diff] [blame] | 588 | if ((curpx->cap & PR_CAP_DEF) || !(curpx->cap & PR_CAP_BE)) { |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 589 | memprintf(err, "'%s' only available in backend or listen section", args[0]); |
| 590 | retval = -1; |
| 591 | goto end; |
| 592 | } |
| 593 | |
| 594 | if (!*(args[1])) { |
| 595 | memprintf(err, "'%s' expects <name> as argument", args[0]); |
| 596 | retval = -1; |
| 597 | goto end; |
| 598 | } |
| 599 | |
| 600 | /* check if a fcgi filter was already registered with this name, |
| 601 | * if that's the case, must use it. */ |
| 602 | list_for_each_entry(fconf, &curpx->filter_configs, list) { |
| 603 | if (fconf->id == fcgi_flt_id) { |
| 604 | fcgi_conf = fconf->conf; |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 605 | if (fcgi_conf && strcmp((char *)fcgi_conf->name, args[1]) == 0) |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 606 | goto end; |
| 607 | memprintf(err, "'%s' : only one fcgi-app supported per backend", args[0]); |
| 608 | retval = -1; |
| 609 | goto end; |
| 610 | } |
| 611 | } |
| 612 | |
| 613 | /* Create the FCGI filter config */ |
| 614 | fcgi_conf = calloc(1, sizeof(*fcgi_conf)); |
| 615 | if (!fcgi_conf) |
| 616 | goto err; |
| 617 | fcgi_conf->name = strdup(args[1]); |
Ilia Shipitsin | 10be69e | 2024-08-05 20:59:09 +0200 | [diff] [blame] | 618 | if (!fcgi_conf->name) |
| 619 | goto err; |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 620 | LIST_INIT(&fcgi_conf->param_rules); |
| 621 | LIST_INIT(&fcgi_conf->hdr_rules); |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 622 | |
| 623 | /* Register the filter */ |
| 624 | fconf = calloc(1, sizeof(*fconf)); |
| 625 | if (!fconf) |
| 626 | goto err; |
| 627 | fconf->id = fcgi_flt_id; |
| 628 | fconf->conf = fcgi_conf; |
| 629 | fconf->ops = &fcgi_flt_ops; |
Willy Tarreau | 2b71810 | 2021-04-21 07:32:39 +0200 | [diff] [blame] | 630 | LIST_APPEND(&curpx->filter_configs, &fconf->list); |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 631 | |
| 632 | end: |
| 633 | return retval; |
| 634 | err: |
| 635 | if (fcgi_conf) { |
| 636 | free(fcgi_conf->name); |
| 637 | free(fcgi_conf); |
| 638 | } |
| 639 | memprintf(err, "out of memory"); |
| 640 | retval = -1; |
| 641 | goto end; |
| 642 | } |
| 643 | |
| 644 | /* Finishes the parsing of FCGI application of proxies and servers */ |
| 645 | static int cfg_fcgi_apps_postparser() |
| 646 | { |
| 647 | struct fcgi_app *curapp; |
| 648 | struct proxy *px; |
| 649 | struct server *srv; |
Christopher Faulet | c97406f | 2020-06-22 11:07:18 +0200 | [diff] [blame] | 650 | struct logsrv *logsrv; |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 651 | int err_code = 0; |
| 652 | |
| 653 | for (px = proxies_list; px; px = px->next) { |
| 654 | struct fcgi_flt_conf *fcgi_conf = find_px_fcgi_conf(px); |
| 655 | int nb_fcgi_srv = 0; |
| 656 | |
| 657 | if (px->mode == PR_MODE_TCP && fcgi_conf) { |
Amaury Denoyelle | 1112430 | 2021-06-04 18:22:08 +0200 | [diff] [blame] | 658 | ha_alert("proxy '%s': FCGI application cannot be used in non-HTTP mode.\n", |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 659 | px->id); |
| 660 | err_code |= ERR_ALERT | ERR_FATAL; |
| 661 | goto end; |
| 662 | } |
| 663 | |
Christopher Faulet | 18c13d3 | 2022-05-16 11:43:10 +0200 | [diff] [blame] | 664 | /* By default, for FCGI-ready backend, HTTP request header names |
| 665 | * are restricted and the "delete" policy is set |
| 666 | */ |
| 667 | if (fcgi_conf && !(px->options2 & PR_O2_RSTRICT_REQ_HDR_NAMES_MASK)) |
| 668 | px->options2 |= PR_O2_RSTRICT_REQ_HDR_NAMES_DEL; |
| 669 | |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 670 | for (srv = px->srv; srv; srv = srv->next) { |
| 671 | if (srv->mux_proto && isteq(srv->mux_proto->token, ist("fcgi"))) { |
| 672 | nb_fcgi_srv++; |
| 673 | if (fcgi_conf) |
| 674 | continue; |
Amaury Denoyelle | 1112430 | 2021-06-04 18:22:08 +0200 | [diff] [blame] | 675 | ha_alert("proxy '%s': FCGI server '%s' has no FCGI app configured.\n", |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 676 | px->id, srv->id); |
| 677 | err_code |= ERR_ALERT | ERR_FATAL; |
| 678 | goto end; |
| 679 | } |
| 680 | } |
| 681 | if (fcgi_conf && !nb_fcgi_srv) { |
Amaury Denoyelle | 1112430 | 2021-06-04 18:22:08 +0200 | [diff] [blame] | 682 | ha_alert("proxy '%s': FCGI app configured but no FCGI server found.\n", |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 683 | px->id); |
| 684 | err_code |= ERR_ALERT | ERR_FATAL; |
| 685 | goto end; |
| 686 | } |
| 687 | } |
| 688 | |
| 689 | for (curapp = fcgi_apps; curapp != NULL; curapp = curapp->next) { |
| 690 | if (!istlen(curapp->docroot)) { |
Amaury Denoyelle | 1112430 | 2021-06-04 18:22:08 +0200 | [diff] [blame] | 691 | ha_alert("fcgi-app '%s': no docroot configured.\n", |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 692 | curapp->name); |
| 693 | err_code |= ERR_ALERT | ERR_FATAL; |
| 694 | goto end; |
| 695 | } |
| 696 | if (!(curapp->flags & (FCGI_APP_FL_MPXS_CONNS|FCGI_APP_FL_GET_VALUES))) { |
| 697 | if (curapp->maxreqs > 1) { |
Amaury Denoyelle | 1112430 | 2021-06-04 18:22:08 +0200 | [diff] [blame] | 698 | ha_warning("fcgi-app '%s': multiplexing not supported, " |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 699 | "ignore the option 'max-reqs'.\n", |
| 700 | curapp->name); |
| 701 | err_code |= ERR_WARN; |
| 702 | } |
| 703 | curapp->maxreqs = 1; |
| 704 | } |
Christopher Faulet | c97406f | 2020-06-22 11:07:18 +0200 | [diff] [blame] | 705 | |
| 706 | list_for_each_entry(logsrv, &curapp->logsrvs, list) { |
| 707 | if (logsrv->type == LOG_TARGET_BUFFER) { |
| 708 | struct sink *sink = sink_find(logsrv->ring_name); |
| 709 | |
| 710 | if (!sink || sink->type != SINK_TYPE_BUFFER) { |
Amaury Denoyelle | 1112430 | 2021-06-04 18:22:08 +0200 | [diff] [blame] | 711 | ha_alert("fcgi-app '%s' : log server uses unknown ring named '%s'.\n", |
Christopher Faulet | c97406f | 2020-06-22 11:07:18 +0200 | [diff] [blame] | 712 | curapp->name, logsrv->ring_name); |
| 713 | err_code |= ERR_ALERT | ERR_FATAL; |
| 714 | } |
| 715 | logsrv->sink = sink; |
| 716 | } |
| 717 | } |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 718 | } |
| 719 | |
| 720 | end: |
| 721 | return err_code; |
| 722 | } |
| 723 | |
| 724 | static int fcgi_app_add_rule(struct fcgi_app *curapp, enum fcgi_rule_type type, char *name, char *value, |
| 725 | struct acl_cond *cond, char **err) |
| 726 | { |
| 727 | struct fcgi_rule_conf *rule; |
| 728 | |
| 729 | /* Param not found, add a new one */ |
| 730 | rule = calloc(1, sizeof(*rule)); |
| 731 | if (!rule) |
| 732 | goto err; |
| 733 | LIST_INIT(&rule->list); |
| 734 | rule->type = type; |
| 735 | if (type == FCGI_RULE_SET_PARAM || type == FCGI_RULE_UNSET_PARAM) { |
| 736 | struct ist fname = fcgi_param_name(trash.area, ist(name)); |
| 737 | rule->name = my_strndup(fname.ptr, fname.len); |
| 738 | } |
Christopher Faulet | bc96c90 | 2019-12-02 10:33:31 +0100 | [diff] [blame] | 739 | else { /* FCGI_RULE_PASS_HDR/FCGI_RULE_HIDE_HDR */ |
| 740 | struct ist fname = ist2bin_lc(trash.area, ist(name)); |
| 741 | rule->name = my_strndup(fname.ptr, fname.len); |
| 742 | } |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 743 | if (!rule->name) |
| 744 | goto err; |
| 745 | |
| 746 | if (value) { |
| 747 | rule->value = strdup(value); |
| 748 | if (!rule->value) |
| 749 | goto err; |
| 750 | } |
| 751 | rule->cond = cond; |
Willy Tarreau | 2b71810 | 2021-04-21 07:32:39 +0200 | [diff] [blame] | 752 | LIST_APPEND(&curapp->conf.rules, &rule->list); |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 753 | return 1; |
| 754 | |
| 755 | err: |
| 756 | if (rule) { |
| 757 | free(rule->name); |
| 758 | free(rule->value); |
| 759 | free(rule); |
| 760 | } |
Aurelien DARRAGON | c610095 | 2023-05-11 12:29:51 +0200 | [diff] [blame] | 761 | free_acl_cond(cond); |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 762 | memprintf(err, "out of memory"); |
| 763 | return 0; |
| 764 | } |
| 765 | |
| 766 | /* Parses "fcgi-app" section */ |
| 767 | static int cfg_parse_fcgi_app(const char *file, int linenum, char **args, int kwm) |
| 768 | { |
| 769 | static struct fcgi_app *curapp = NULL; |
| 770 | struct acl_cond *cond = NULL; |
| 771 | char *name, *value = NULL; |
| 772 | enum fcgi_rule_type type; |
| 773 | int err_code = 0; |
| 774 | const char *err; |
| 775 | char *errmsg = NULL; |
| 776 | |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 777 | if (strcmp(args[0], "fcgi-app") == 0) { /* new fcgi-app */ |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 778 | if (!*(args[1])) { |
| 779 | ha_alert("parsing [%s:%d]: '%s' expects <name> as argument.\n", |
| 780 | file, linenum, args[0]); |
| 781 | err_code |= ERR_ALERT | ERR_FATAL; |
| 782 | goto out; |
| 783 | } |
| 784 | if (alertif_too_many_args(1, file, linenum, args, &err_code)) |
| 785 | goto out; |
| 786 | |
| 787 | err = invalid_char(args[1]); |
| 788 | if (err) { |
| 789 | ha_alert("parsing [%s:%d]: character '%c' is not permitted in '%s' name '%s'.\n", |
| 790 | file, linenum, *err, args[0], args[1]); |
| 791 | err_code |= ERR_ALERT | ERR_FATAL; |
| 792 | goto out; |
| 793 | } |
| 794 | |
| 795 | for (curapp = fcgi_apps; curapp != NULL; curapp = curapp->next) { |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 796 | if (strcmp(curapp->name, args[1]) == 0) { |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 797 | ha_alert("Parsing [%s:%d]: fcgi-app section '%s' has the same name as another one declared at %s:%d.\n", |
| 798 | file, linenum, args[1], curapp->conf.file, curapp->conf.line); |
| 799 | err_code |= ERR_ALERT | ERR_FATAL; |
| 800 | } |
| 801 | } |
| 802 | |
| 803 | curapp = calloc(1, sizeof(*curapp)); |
| 804 | if (!curapp) { |
| 805 | ha_alert("parsing [%s:%d] : out of memory.\n", file, linenum); |
| 806 | err_code |= ERR_ALERT | ERR_ABORT; |
| 807 | goto out; |
| 808 | } |
| 809 | |
| 810 | curapp->next = fcgi_apps; |
| 811 | fcgi_apps = curapp; |
| 812 | curapp->flags = FCGI_APP_FL_KEEP_CONN; |
| 813 | curapp->docroot = ist(NULL); |
| 814 | curapp->index = ist(NULL); |
| 815 | curapp->pathinfo_re = NULL; |
| 816 | curapp->name = strdup(args[1]); |
| 817 | curapp->maxreqs = 1; |
| 818 | curapp->conf.file = strdup(file); |
| 819 | curapp->conf.line = linenum; |
| 820 | LIST_INIT(&curapp->acls); |
| 821 | LIST_INIT(&curapp->logsrvs); |
| 822 | LIST_INIT(&curapp->conf.args.list); |
| 823 | LIST_INIT(&curapp->conf.rules); |
| 824 | |
| 825 | /* Set info about authentication */ |
| 826 | if (!fcgi_app_add_rule(curapp, FCGI_RULE_SET_PARAM, "REMOTE_USER", "%[http_auth_user]", NULL, &errmsg) || |
| 827 | !fcgi_app_add_rule(curapp, FCGI_RULE_SET_PARAM, "AUTH_TYPE", "%[http_auth_type]", NULL, &errmsg)) { |
| 828 | ha_alert("parsing [%s:%d] : '%s' : %s.\n", file, linenum, |
| 829 | args[1], errmsg); |
| 830 | err_code |= ERR_ALERT | ERR_FATAL; |
| 831 | } |
| 832 | |
| 833 | /* Hide hop-by-hop headers by default */ |
| 834 | if (!fcgi_app_add_rule(curapp, FCGI_RULE_HIDE_HDR, "connection", NULL, NULL, &errmsg) || |
| 835 | !fcgi_app_add_rule(curapp, FCGI_RULE_HIDE_HDR, "keep-alive", NULL, NULL, &errmsg) || |
| 836 | !fcgi_app_add_rule(curapp, FCGI_RULE_HIDE_HDR, "authorization", NULL, NULL, &errmsg) || |
| 837 | !fcgi_app_add_rule(curapp, FCGI_RULE_HIDE_HDR, "proxy", NULL, NULL, &errmsg) || |
| 838 | !fcgi_app_add_rule(curapp, FCGI_RULE_HIDE_HDR, "proxy-authorization", NULL, NULL, &errmsg) || |
| 839 | !fcgi_app_add_rule(curapp, FCGI_RULE_HIDE_HDR, "proxy-authenticate", NULL, NULL, &errmsg) || |
| 840 | !fcgi_app_add_rule(curapp, FCGI_RULE_HIDE_HDR, "te", NULL, NULL, &errmsg) || |
| 841 | !fcgi_app_add_rule(curapp, FCGI_RULE_HIDE_HDR, "trailers", NULL, NULL, &errmsg) || |
| 842 | !fcgi_app_add_rule(curapp, FCGI_RULE_HIDE_HDR, "transfer-encoding", NULL, NULL, &errmsg) || |
| 843 | !fcgi_app_add_rule(curapp, FCGI_RULE_HIDE_HDR, "upgrade", NULL, NULL, &errmsg)) { |
| 844 | ha_alert("parsing [%s:%d] : '%s' : %s.\n", file, linenum, |
| 845 | args[1], errmsg); |
| 846 | err_code |= ERR_ALERT | ERR_FATAL; |
| 847 | } |
| 848 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 849 | else if (strcmp(args[0], "docroot") == 0) { |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 850 | if (!*(args[1])) { |
| 851 | ha_alert("parsing [%s:%d] : '%s' expects <path> as argument.\n", |
| 852 | file, linenum, args[0]); |
| 853 | err_code |= ERR_ALERT | ERR_FATAL; |
| 854 | goto out; |
| 855 | } |
| 856 | if (alertif_too_many_args_idx(0, 1, file, linenum, args, &err_code)) |
| 857 | goto out; |
Tim Duesterhus | ed52637 | 2020-03-05 17:56:33 +0100 | [diff] [blame] | 858 | istfree(&curapp->docroot); |
Tim Duesterhus | dcf753a | 2021-03-04 17:31:47 +0100 | [diff] [blame] | 859 | curapp->docroot = ist(strdup(args[1])); |
Tim Duesterhus | ed52637 | 2020-03-05 17:56:33 +0100 | [diff] [blame] | 860 | if (!isttest(curapp->docroot)) { |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 861 | ha_alert("parsing [%s:%d] : out of memory.\n", file, linenum); |
| 862 | err_code |= ERR_ALERT | ERR_ABORT; |
| 863 | } |
| 864 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 865 | else if (strcmp(args[0], "path-info") == 0) { |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 866 | if (!*(args[1])) { |
| 867 | ha_alert("parsing [%s:%d] : '%s' expects <regex> as argument.\n", |
| 868 | file, linenum, args[0]); |
| 869 | err_code |= ERR_ALERT | ERR_FATAL; |
| 870 | goto out; |
| 871 | } |
| 872 | if (alertif_too_many_args_idx(0, 1, file, linenum, args, &err_code)) |
| 873 | goto out; |
| 874 | regex_free(curapp->pathinfo_re); |
| 875 | curapp->pathinfo_re = regex_comp(args[1], 1, 1, &errmsg); |
| 876 | if (!curapp->pathinfo_re) { |
| 877 | ha_alert("parsing [%s:%d] : '%s' : %s.\n", file, linenum, |
| 878 | args[1], errmsg); |
| 879 | err_code |= ERR_ALERT | ERR_FATAL; |
| 880 | } |
| 881 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 882 | else if (strcmp(args[0], "index") == 0) { |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 883 | if (!*(args[1])) { |
| 884 | ha_alert("parsing [%s:%d] : '%s' expects <filename> as argument.\n", |
| 885 | file, linenum, args[0]); |
| 886 | err_code |= ERR_ALERT | ERR_FATAL; |
| 887 | goto out; |
| 888 | } |
| 889 | if (alertif_too_many_args_idx(0, 1, file, linenum, args, &err_code)) |
| 890 | goto out; |
Tim Duesterhus | ed52637 | 2020-03-05 17:56:33 +0100 | [diff] [blame] | 891 | istfree(&curapp->index); |
Tim Duesterhus | dcf753a | 2021-03-04 17:31:47 +0100 | [diff] [blame] | 892 | curapp->index = ist(strdup(args[1])); |
Tim Duesterhus | ed52637 | 2020-03-05 17:56:33 +0100 | [diff] [blame] | 893 | if (!isttest(curapp->index)) { |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 894 | ha_alert("parsing [%s:%d] : out of memory.\n", file, linenum); |
| 895 | err_code |= ERR_ALERT | ERR_ABORT; |
| 896 | } |
| 897 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 898 | else if (strcmp(args[0], "acl") == 0) { |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 899 | const char *err; |
| 900 | err = invalid_char(args[1]); |
| 901 | if (err) { |
| 902 | ha_alert("parsing [%s:%d] : character '%c' is not permitted in acl name '%s'.\n", |
| 903 | file, linenum, *err, args[1]); |
| 904 | err_code |= ERR_ALERT | ERR_FATAL; |
Tim Duesterhus | 0cf811a | 2020-02-05 21:00:50 +0100 | [diff] [blame] | 905 | goto out; |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 906 | } |
Tim Duesterhus | 0cf811a | 2020-02-05 21:00:50 +0100 | [diff] [blame] | 907 | if (strcasecmp(args[1], "or") == 0) { |
Tim Duesterhus | f1bc24c | 2020-02-06 22:04:03 +0100 | [diff] [blame] | 908 | ha_alert("parsing [%s:%d] : acl name '%s' will never match. 'or' is used to express a " |
Tim Duesterhus | 0cf811a | 2020-02-05 21:00:50 +0100 | [diff] [blame] | 909 | "logical disjunction within a condition.\n", |
| 910 | file, linenum, args[1]); |
| 911 | err_code |= ERR_ALERT | ERR_FATAL; |
| 912 | goto out; |
| 913 | } |
| 914 | if (parse_acl((const char **)args+1, &curapp->acls, &errmsg, &curapp->conf.args, file, linenum) == NULL) { |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 915 | ha_alert("parsing [%s:%d] : error detected while parsing ACL '%s' : %s.\n", |
| 916 | file, linenum, args[1], errmsg); |
| 917 | err_code |= ERR_ALERT | ERR_FATAL; |
Tim Duesterhus | 0cf811a | 2020-02-05 21:00:50 +0100 | [diff] [blame] | 918 | goto out; |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 919 | } |
| 920 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 921 | else if (strcmp(args[0], "set-param") == 0) { |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 922 | if (!*(args[1]) || !*(args[2])) { |
| 923 | ha_alert("parsing [%s:%d] : '%s' expects <name> and <value> as arguments.\n", |
| 924 | file, linenum, args[0]); |
| 925 | err_code |= ERR_ALERT | ERR_FATAL; |
| 926 | goto out; |
| 927 | } |
| 928 | type = FCGI_RULE_SET_PARAM; |
| 929 | name = args[1]; |
| 930 | value = args[2]; |
| 931 | cond = NULL; |
| 932 | args += 3; |
| 933 | |
| 934 | parse_cond_rule: |
| 935 | if (!*(args[0])) /* No condition */ |
| 936 | goto add_rule; |
| 937 | |
| 938 | if (strcmp(args[0], "if") == 0) |
| 939 | cond = parse_acl_cond((const char **)args+1, &curapp->acls, ACL_COND_IF, &errmsg, &curapp->conf.args, |
| 940 | file, linenum); |
| 941 | else if (strcmp(args[0], "unless") == 0) |
| 942 | cond = parse_acl_cond((const char **)args+1, &curapp->acls, ACL_COND_UNLESS, &errmsg, &curapp->conf.args, |
| 943 | file, linenum); |
| 944 | if (!cond) { |
| 945 | ha_alert("parsing [%s:%d] : '%s' : %s.\n", file, linenum, |
| 946 | name, errmsg); |
| 947 | err_code |= ERR_ALERT | ERR_FATAL; |
| 948 | } |
| 949 | add_rule: |
| 950 | if (!fcgi_app_add_rule(curapp, type, name, value, cond, &errmsg)) { |
| 951 | ha_alert("parsing [%s:%d] : '%s' : %s.\n", file, linenum, |
| 952 | name, errmsg); |
| 953 | err_code |= ERR_ALERT | ERR_FATAL; |
| 954 | } |
| 955 | } |
| 956 | #if 0 /* Disabled for now */ |
| 957 | else if (!strcmp(args[0], "unset-param")) { |
| 958 | if (!*(args[1])) { |
| 959 | ha_alert("parsing [%s:%d] : '%s' expects <name> as arguments.\n", |
| 960 | file, linenum, args[0]); |
| 961 | err_code |= ERR_ALERT | ERR_FATAL; |
| 962 | goto out; |
| 963 | } |
| 964 | type = FCGI_RULE_UNSET_PARAM; |
| 965 | name = args[1]; |
| 966 | value = NULL; |
| 967 | cond = NULL; |
| 968 | args += 2; |
| 969 | goto parse_cond_rule; |
| 970 | } |
| 971 | #endif |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 972 | else if (strcmp(args[0], "pass-header") == 0) { |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 973 | if (!*(args[1])) { |
| 974 | ha_alert("parsing [%s:%d] : '%s' expects <name> as arguments.\n", |
| 975 | file, linenum, args[0]); |
| 976 | err_code |= ERR_ALERT | ERR_FATAL; |
| 977 | goto out; |
| 978 | } |
| 979 | type = FCGI_RULE_PASS_HDR; |
| 980 | name = args[1]; |
| 981 | value = NULL; |
| 982 | cond = NULL; |
| 983 | args += 2; |
| 984 | goto parse_cond_rule; |
| 985 | } |
| 986 | #if 0 /* Disabled for now */ |
| 987 | else if (!strcmp(args[0], "hide-header")) { |
| 988 | if (!*(args[1])) { |
| 989 | ha_alert("parsing [%s:%d] : '%s' expects <name> as arguments.\n", |
| 990 | file, linenum, args[0]); |
| 991 | err_code |= ERR_ALERT | ERR_FATAL; |
| 992 | goto out; |
| 993 | } |
| 994 | type = FCGI_RULE_HIDE_HDR; |
| 995 | name = args[1]; |
| 996 | value = NULL; |
| 997 | cond = NULL; |
| 998 | args += 2; |
| 999 | goto parse_cond_rule; |
| 1000 | } |
| 1001 | #endif |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1002 | else if (strcmp(args[0], "option") == 0) { |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 1003 | if (!*(args[1])) { |
| 1004 | ha_alert("parsing [%s:%d]: '%s' expects an option name.\n", |
| 1005 | file, linenum, args[0]); |
| 1006 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1007 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1008 | else if (strcmp(args[1], "keep-conn") == 0) { |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 1009 | if (alertif_too_many_args_idx(0, 1, file, linenum, args, &err_code)) |
| 1010 | goto out; |
| 1011 | if (kwm == KWM_STD) |
| 1012 | curapp->flags |= FCGI_APP_FL_KEEP_CONN; |
| 1013 | else if (kwm == KWM_NO) |
| 1014 | curapp->flags &= ~FCGI_APP_FL_KEEP_CONN; |
| 1015 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1016 | else if (strcmp(args[1], "get-values") == 0) { |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 1017 | if (alertif_too_many_args_idx(0, 1, file, linenum, args, &err_code)) |
| 1018 | goto out; |
| 1019 | if (kwm == KWM_STD) |
| 1020 | curapp->flags |= FCGI_APP_FL_GET_VALUES; |
| 1021 | else if (kwm == KWM_NO) |
| 1022 | curapp->flags &= ~FCGI_APP_FL_GET_VALUES; |
| 1023 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1024 | else if (strcmp(args[1], "mpxs-conns") == 0) { |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 1025 | if (alertif_too_many_args_idx(0, 1, file, linenum, args, &err_code)) |
| 1026 | goto out; |
| 1027 | if (kwm == KWM_STD) |
| 1028 | curapp->flags |= FCGI_APP_FL_MPXS_CONNS; |
| 1029 | else if (kwm == KWM_NO) |
| 1030 | curapp->flags &= ~FCGI_APP_FL_MPXS_CONNS; |
| 1031 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1032 | else if (strcmp(args[1], "max-reqs") == 0) { |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 1033 | if (kwm != KWM_STD) { |
| 1034 | ha_alert("parsing [%s:%d]: negation/default is not supported for option '%s'.\n", |
| 1035 | file, linenum, args[1]); |
| 1036 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1037 | goto out; |
| 1038 | } |
| 1039 | if (!*(args[2])) { |
| 1040 | ha_alert("parsing [%s:%d]: option '%s' expects an integer argument.\n", |
| 1041 | file, linenum, args[1]); |
| 1042 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1043 | goto out; |
| 1044 | } |
| 1045 | if (alertif_too_many_args_idx(1, 1, file, linenum, args, &err_code)) |
| 1046 | goto out; |
| 1047 | |
| 1048 | curapp->maxreqs = atol(args[2]); |
| 1049 | if (!curapp->maxreqs) { |
| 1050 | ha_alert("parsing [%s:%d]: option '%s' expects a strictly positive integer argument.\n", |
| 1051 | file, linenum, args[1]); |
| 1052 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1053 | goto out; |
| 1054 | } |
| 1055 | } |
| 1056 | else { |
| 1057 | ha_alert("parsing [%s:%d] : unknown option '%s'.\n", file, linenum, args[1]); |
| 1058 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1059 | } |
| 1060 | } |
Tim Duesterhus | e5ff141 | 2021-01-02 22:31:53 +0100 | [diff] [blame] | 1061 | else if (strcmp(args[0], "log-stderr") == 0) { |
Emeric Brun | 9533a70 | 2021-04-02 10:13:43 +0200 | [diff] [blame] | 1062 | if (!parse_logsrv(args, &curapp->logsrvs, (kwm == KWM_NO), file, linenum, &errmsg)) { |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 1063 | ha_alert("parsing [%s:%d] : %s : %s\n", file, linenum, args[0], errmsg); |
| 1064 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1065 | } |
| 1066 | } |
| 1067 | else { |
| 1068 | ha_alert("parsing [%s:%d]: unknown keyword '%s' in '%s' section\n", file, linenum, args[0], "fcgi-app"); |
| 1069 | err_code |= ERR_ALERT | ERR_FATAL; |
| 1070 | } |
| 1071 | |
| 1072 | out: |
| 1073 | free(errmsg); |
| 1074 | return err_code; |
| 1075 | } |
| 1076 | |
| 1077 | |
| 1078 | /**************************************************************************/ |
| 1079 | /*********************** FCGI Deinit functions ****************************/ |
| 1080 | /**************************************************************************/ |
| 1081 | void fcgi_apps_deinit() |
| 1082 | { |
| 1083 | struct fcgi_app *curapp, *nextapp; |
| 1084 | struct logsrv *log, *logb; |
| 1085 | |
| 1086 | for (curapp = fcgi_apps; curapp != NULL; curapp = nextapp) { |
| 1087 | struct fcgi_rule_conf *rule, *back; |
| 1088 | |
| 1089 | free(curapp->name); |
Tim Duesterhus | ed52637 | 2020-03-05 17:56:33 +0100 | [diff] [blame] | 1090 | istfree(&curapp->docroot); |
| 1091 | istfree(&curapp->index); |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 1092 | regex_free(curapp->pathinfo_re); |
| 1093 | free(curapp->conf.file); |
| 1094 | |
| 1095 | list_for_each_entry_safe(log, logb, &curapp->logsrvs, list) { |
Willy Tarreau | 2b71810 | 2021-04-21 07:32:39 +0200 | [diff] [blame] | 1096 | LIST_DELETE(&log->list); |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 1097 | free(log); |
| 1098 | } |
| 1099 | |
| 1100 | list_for_each_entry_safe(rule, back, &curapp->conf.rules, list) { |
Willy Tarreau | 2b71810 | 2021-04-21 07:32:39 +0200 | [diff] [blame] | 1101 | LIST_DELETE(&rule->list); |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 1102 | fcgi_release_rule_conf(rule); |
| 1103 | } |
| 1104 | |
| 1105 | nextapp = curapp->next; |
| 1106 | free(curapp); |
| 1107 | } |
| 1108 | } |
| 1109 | |
| 1110 | |
| 1111 | /**************************************************************************/ |
| 1112 | /*************** Keywords definition and registration *********************/ |
| 1113 | /**************************************************************************/ |
| 1114 | static struct cfg_kw_list cfg_kws = {ILH, { |
| 1115 | { CFG_LISTEN, "use-fcgi-app", proxy_parse_use_fcgi_app }, |
| 1116 | { 0, NULL, NULL }, |
| 1117 | }}; |
| 1118 | |
| 1119 | // FIXME: Add rep.fcgi smp_fetch |
| 1120 | static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, { |
| 1121 | { "fcgi.docroot", smp_fetch_fcgi_docroot, 0, NULL, SMP_T_STR, SMP_USE_HRQHV }, |
Willy Tarreau | fc41e25 | 2019-09-27 22:45:17 +0200 | [diff] [blame] | 1122 | { "fcgi.index", smp_fetch_fcgi_index, 0, NULL, SMP_T_STR, SMP_USE_HRQHV }, |
| 1123 | { /* END */ } |
Christopher Faulet | 78fbb9f | 2019-08-11 23:11:03 +0200 | [diff] [blame] | 1124 | }}; |
| 1125 | |
| 1126 | /* Declare the filter parser for "fcgi-app" keyword */ |
| 1127 | static struct flt_kw_list filter_kws = { "FCGI", { }, { |
| 1128 | { "fcgi-app", parse_fcgi_flt, NULL }, |
| 1129 | { NULL, NULL, NULL }, |
| 1130 | } |
| 1131 | }; |
| 1132 | |
| 1133 | INITCALL1(STG_REGISTER, sample_register_fetches, &sample_fetch_keywords); |
| 1134 | INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws); |
| 1135 | INITCALL1(STG_REGISTER, flt_register_keywords, &filter_kws); |
| 1136 | |
| 1137 | INITCALL1(STG_REGISTER, hap_register_post_deinit, fcgi_apps_deinit); |
| 1138 | |
| 1139 | REGISTER_CONFIG_SECTION("fcgi-app", cfg_parse_fcgi_app, NULL); |
| 1140 | REGISTER_CONFIG_POSTPARSER("fcgi-apps", cfg_fcgi_apps_postparser); |
| 1141 | |
| 1142 | /* |
| 1143 | * Local variables: |
| 1144 | * c-indent-level: 8 |
| 1145 | * c-basic-offset: 8 |
| 1146 | * End: |
| 1147 | */ |