diff --git a/src/configfile-glue.c b/src/configfile-glue.c index 6290ec7b..98500ab1 100644 --- a/src/configfile-glue.c +++ b/src/configfile-glue.c @@ -50,19 +50,65 @@ int config_plugin_values_init_block(server * const srv, const array * const ca, switch (cpk[i].ktype) { case T_CONFIG_ARRAY: + case T_CONFIG_ARRAY_KVANY: + case T_CONFIG_ARRAY_KVARRAY: + case T_CONFIG_ARRAY_KVSTRING: + case T_CONFIG_ARRAY_VLIST: if (du->type == TYPE_ARRAY) { cpv->v.a = &((const data_array *)du)->value; - /* future: might provide modifiers to perform one of - * array_is_{vlist,kvany,kvarray,kvstring}() tests - * and provide generic error message if mismatch */ } else { log_error(srv->errh, __FILE__, __LINE__, - "%s should have been an array of strings like " - "... = ( \"...\" )", cpk[i].k); + "%s should have been a list like " + "%s = ( \"...\" )", cpk[i].k, cpk[i].k); rc = 0; continue; } + switch (cpk[i].ktype) { + case T_CONFIG_ARRAY_KVANY: + if (!array_is_kvany(cpv->v.a)) { + log_error(srv->errh, __FILE__, __LINE__, + "%s should have been a list of key => values like " + "%s = ( \"...\" => \"...\", \"...\" => \"...\" )", + cpk[i].k, cpk[i].k); + rc = 0; + continue; + } + break; + case T_CONFIG_ARRAY_KVARRAY: + if (!array_is_kvarray(cpv->v.a)) { + log_error(srv->errh, __FILE__, __LINE__, + "%s should have been a list of key => list like " + "%s = ( \"...\" => ( \"...\" => \"...\" ) )", + cpk[i].k, cpk[i].k); + rc = 0; + continue; + } + break; + case T_CONFIG_ARRAY_KVSTRING: + if (!array_is_kvstring(cpv->v.a)) { + log_error(srv->errh, __FILE__, __LINE__, + "%s should have been a list of key => string values like " + "%s = ( \"...\" => \"...\", \"...\" => \"...\" )", + cpk[i].k, cpk[i].k); + rc = 0; + continue; + } + break; + case T_CONFIG_ARRAY_VLIST: + if (!array_is_vlist(cpv->v.a)) { + log_error(srv->errh, __FILE__, __LINE__, + "%s should have been a list of string values like " + "%s = ( \"...\", \"...\" )", + cpk[i].k, cpk[i].k); + rc = 0; + continue; + } + break; + /*case T_CONFIG_ARRAY:*/ + default: + break; + } break; case T_CONFIG_STRING: if (du->type == TYPE_STRING) { diff --git a/src/configfile.c b/src/configfile.c index b69ef5b2..9f451ac7 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -373,12 +373,6 @@ static int config_http_parseopts (server *srv, const array *a) { unsigned short int opts = srv->srvconf.http_url_normalize; unsigned short int decode_2f = 1; int rc = 1; - if (!array_is_kvstring(a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for server.http-parseopts; " - "expected list of \"key\" => \"[enable|disable]\""); - return 0; - } for (size_t i = 0; i < a->used; ++i) { const data_string * const ds = (const data_string *)a->data[i]; const buffer *k = &ds->key; @@ -485,7 +479,7 @@ static int config_http_parseopts (server *srv, const array *a) { static int config_insert_srvconf(server *srv) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("server.modules"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_SERVER } ,{ CONST_STR_LEN("server.compat-module-load"), T_CONFIG_BOOL, @@ -551,10 +545,10 @@ static int config_insert_srvconf(server *srv) { T_CONFIG_INT, T_CONFIG_SCOPE_SERVER } ,{ CONST_STR_LEN("server.upload-dirs"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_SERVER } ,{ CONST_STR_LEN("server.http-parseopts"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_SERVER } ,{ CONST_STR_LEN("server.http-parseopt-header-strict"), T_CONFIG_BOOL, @@ -603,14 +597,6 @@ static int config_insert_srvconf(server *srv) { for (; -1 != cpv->k_id; ++cpv) { switch (cpv->k_id) { case 0: /* server.modules */ - if (!array_is_vlist(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"mod_xxxxxx\" strings", - cpk[cpv->k_id].k); - rc = HANDLER_ERROR; - break; - } array_copy_array(srv->srvconf.modules, cpv->v.a); break; case 1: /* server.compat-module-load */ @@ -677,13 +663,6 @@ static int config_insert_srvconf(server *srv) { srv->srvconf.upload_temp_file_size = cpv->v.u; break; case 22:/* server.upload-dirs */ - if (!array_is_vlist(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"path\" strings", cpk[cpv->k_id].k); - rc = HANDLER_ERROR; - break; - } array_copy_array(srv->srvconf.upload_tempdirs, cpv->v.a); break; case 23:/* server.http-parseopts */ @@ -808,7 +787,7 @@ static int config_insert(server *srv) { T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("mimetype.assign"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("mimetype.use-xattr"), T_CONFIG_BOOL, @@ -922,16 +901,7 @@ static int config_insert(server *srv) { break; } case 19:/* connection.kbytes-per-second */ - break; case 20:/* mimetype.assign */ - if (!array_is_kvstring(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"ext\" => \"mimetype\"", - cpk[cpv->k_id].k); - rc = HANDLER_ERROR; - } - break; case 21:/* mimetype.use-xattr */ case 22:/* etag.use-inode */ case 23:/* etag.use-mtime */ diff --git a/src/gw_backend.c b/src/gw_backend.c index f1021b32..67d40bef 100644 --- a/src/gw_backend.c +++ b/src/gw_backend.c @@ -1234,10 +1234,10 @@ int gw_set_defaults_backend(server *srv, gw_plugin_data *p, const array *a, gw_p T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("bin-environment"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("bin-copy-environment"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("broken-scriptfilename"), T_CONFIG_BOOL, @@ -1255,7 +1255,7 @@ int gw_set_defaults_backend(server *srv, gw_plugin_data *p, const array *a, gw_p T_CONFIG_BOOL, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("x-sendfile-docroot"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("tcp-fin-propagate"), T_CONFIG_BOOL, @@ -1267,14 +1267,6 @@ int gw_set_defaults_backend(server *srv, gw_plugin_data *p, const array *a, gw_p gw_host *host = NULL; - if (!array_is_kvarray(a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; expected " - "( \"ext\" => ( \"backend-label\" => ( \"key\" => \"value\" )))", - cpkkey); - return 0; - } - p->srv_pid = srv->pid; s->exts = gw_extensions_init(); diff --git a/src/mod_access.c b/src/mod_access.c index 2dec2eda..804f0b9f 100644 --- a/src/mod_access.c +++ b/src/mod_access.c @@ -55,10 +55,10 @@ static void mod_access_patch_config(connection * const con, plugin_data * const SETDEFAULTS_FUNC(mod_access_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("url.access-deny"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("url.access-allow"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_CONNECTION } ,{ NULL, 0, T_CONFIG_UNSET, @@ -69,27 +69,6 @@ SETDEFAULTS_FUNC(mod_access_set_defaults) { if (!config_plugin_values_init(srv, p, cpk, "mod_access")) return HANDLER_ERROR; - /* process and validate config directives - * (init i to 0 if global context; to 1 to skip empty global context) */ - for (int i = !p->cvlist[0].v.u2[1]; i < p->nconfig; ++i) { - const config_plugin_value_t *cpv = p->cvlist + p->cvlist[i].v.u2[0]; - for (; -1 != cpv->k_id; ++cpv) { - switch (cpv->k_id) { - case 0: /* url.access-deny */ - case 1: /* url.access-allow */ - if (!array_is_vlist(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"suffix\"", cpk[cpv->k_id].k); - return HANDLER_ERROR; - } - break; - default:/* should not happen */ - break; - } - } - } - /* initialize p->defaults from global config context */ if (p->nconfig > 0 && p->cvlist->v.u2[1]) { const config_plugin_value_t *cpv = p->cvlist + p->cvlist->v.u2[0]; diff --git a/src/mod_alias.c b/src/mod_alias.c index 1ded7260..d5883264 100644 --- a/src/mod_alias.c +++ b/src/mod_alias.c @@ -79,7 +79,7 @@ static int mod_alias_check_order(server * const srv, const array * const a) { SETDEFAULTS_FUNC(mod_alias_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("alias.url"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ NULL, 0, T_CONFIG_UNSET, @@ -97,13 +97,6 @@ SETDEFAULTS_FUNC(mod_alias_set_defaults) { for (; -1 != cpv->k_id; ++cpv) { switch (cpv->k_id) { case 0: /* alias.url */ - if (!array_is_kvstring(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"urlpath\" => \"filepath\"", - cpk[cpv->k_id].k); - return HANDLER_ERROR; - } if (cpv->v.a->used >= 2 && !mod_alias_check_order(srv,cpv->v.a)) return HANDLER_ERROR; break; diff --git a/src/mod_auth.c b/src/mod_auth.c index c1466d04..8c9e4633 100644 --- a/src/mod_auth.c +++ b/src/mod_auth.c @@ -396,7 +396,7 @@ SETDEFAULTS_FUNC(mod_auth_set_defaults) { T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("auth.require"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVARRAY, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("auth.extern-authn"), T_CONFIG_BOOL, @@ -430,7 +430,7 @@ SETDEFAULTS_FUNC(mod_auth_set_defaults) { } break; case 1: /* auth.require */ - if (array_is_kvarray(cpv->v.a)) { + { array * const a = array_init(4); if (HANDLER_GO_ON != mod_auth_require_parse_array(cpv->v.a, a, srv->errh)) { @@ -440,13 +440,6 @@ SETDEFAULTS_FUNC(mod_auth_set_defaults) { cpv->v.a = a; cpv->vtype = T_CONFIG_LOCAL; } - else { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; expected " - "%s = ( \"urlpath\" => ( \"option\" => \"value\" ) )", - cpk[cpv->k_id].k, cpk[cpv->k_id].k); - return HANDLER_ERROR; - } break; case 2: /* auth.extern-authn */ break; diff --git a/src/mod_authn_pam.c b/src/mod_authn_pam.c index 618baaca..4ce3bb54 100644 --- a/src/mod_authn_pam.c +++ b/src/mod_authn_pam.c @@ -74,7 +74,7 @@ static void mod_authn_pam_patch_config(connection * const con, plugin_data * con SETDEFAULTS_FUNC(mod_authn_pam_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("auth.backend.pam.opts"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ NULL, 0, T_CONFIG_UNSET, diff --git a/src/mod_authn_sasl.c b/src/mod_authn_sasl.c index f763cc55..c6eed5fd 100644 --- a/src/mod_authn_sasl.c +++ b/src/mod_authn_sasl.c @@ -158,7 +158,7 @@ static plugin_config * mod_authn_sasl_parse_opts(server *srv, const array * cons SETDEFAULTS_FUNC(mod_authn_sasl_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("auth.backend.sasl.opts"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ NULL, 0, T_CONFIG_UNSET, diff --git a/src/mod_cgi.c b/src/mod_cgi.c index 0d7f98dd..223972e2 100644 --- a/src/mod_cgi.c +++ b/src/mod_cgi.c @@ -189,7 +189,7 @@ static void mod_cgi_patch_config(connection * const con, plugin_data * const p) SETDEFAULTS_FUNC(mod_cgi_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("cgi.assign"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("cgi.execute-x-only"), T_CONFIG_BOOL, @@ -198,7 +198,7 @@ SETDEFAULTS_FUNC(mod_cgi_set_defaults) { T_CONFIG_BOOL, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("cgi.x-sendfile-docroot"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("cgi.local-redir"), T_CONFIG_BOOL, @@ -222,25 +222,10 @@ SETDEFAULTS_FUNC(mod_cgi_set_defaults) { for (; -1 != cpv->k_id; ++cpv) { switch (cpv->k_id) { case 0: /* cgi.assign */ - if (!array_is_kvstring(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"ext\" -> \"exepath\"", - cpk[cpv->k_id].k); - return HANDLER_ERROR; - } - break; case 1: /* cgi.execute-x-only */ case 2: /* cgi.x-sendfile */ break; case 3: /* cgi.x-sendfile-docroot */ - if (!array_is_vlist(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected: %s = ( \"/allowed/path\", ... )", - cpk[cpv->k_id].k, cpk[cpv->k_id].k); - return HANDLER_ERROR; - } for (uint32_t j = 0; j < cpv->v.a->used; ++j) { data_string *ds = (data_string *)cpv->v.a->data[j]; if (ds->value.ptr[0] != '/') { diff --git a/src/mod_cml.c b/src/mod_cml.c index ac584dcc..1640fb68 100644 --- a/src/mod_cml.c +++ b/src/mod_cml.c @@ -122,7 +122,7 @@ SETDEFAULTS_FUNC(mod_cml_set_defaults) { T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("cml.memcache-hosts"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("cml.memcache-namespace"), /*(unused)*/ T_CONFIG_STRING, @@ -148,12 +148,6 @@ SETDEFAULTS_FUNC(mod_cml_set_defaults) { case 0: /* cml.extension */ break; case 1: /* cml.memcache-hosts */ /* config converted to memc handles */ - if (!array_is_vlist(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"host\"", cpk[cpv->k_id].k); - return HANDLER_ERROR; - } if (!mod_cml_init_memcached(srv, cpv)) { return HANDLER_ERROR; } diff --git a/src/mod_compress.c b/src/mod_compress.c index ba7eadc7..53887706 100644 --- a/src/mod_compress.c +++ b/src/mod_compress.c @@ -222,10 +222,10 @@ static short mod_compress_encodings_to_flags(const array *encodings) { SETDEFAULTS_FUNC(mod_compress_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("compress.filetype"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("compress.allowed-encodings"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("compress.cache-dir"), T_CONFIG_STRING, @@ -252,21 +252,9 @@ SETDEFAULTS_FUNC(mod_compress_set_defaults) { for (; -1 != cpv->k_id; ++cpv) { switch (cpv->k_id) { case 0: /* compress.filetype */ - if (!array_is_vlist(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"mimetype\"", cpk[cpv->k_id].k); - return HANDLER_ERROR; - } if (0 == cpv->v.a->used) cpv->v.a = NULL; break; case 1: /* compress.allowed-encodings */ - if (!array_is_vlist(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"encoding\"", cpk[cpv->k_id].k); - return HANDLER_ERROR; - } cpv->v.u = (unsigned int) mod_compress_encodings_to_flags(cpv->v.a); cpv->vtype = T_CONFIG_INT; diff --git a/src/mod_deflate.c b/src/mod_deflate.c index e5687f11..ee3cd841 100644 --- a/src/mod_deflate.c +++ b/src/mod_deflate.c @@ -329,10 +329,10 @@ static short mod_deflate_encodings_to_flags(const array *encodings) { SETDEFAULTS_FUNC(mod_deflate_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("deflate.mimetypes"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("deflate.allow-encodings"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("deflate.max-compress-size"), T_CONFIG_INT, @@ -368,12 +368,6 @@ SETDEFAULTS_FUNC(mod_deflate_set_defaults) { for (; -1 != cpv->k_id; ++cpv) { switch (cpv->k_id) { case 0: /* deflate.mimetypes */ - if (!array_is_vlist(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"mimetype\"", cpk[cpv->k_id].k); - return HANDLER_ERROR; - } /* mod_deflate matches mimetype as prefix of Content-Type * so ignore '*' at end of mimetype for end-user flexibility * in specifying trailing wildcard to grouping of mimetypes */ @@ -386,12 +380,6 @@ SETDEFAULTS_FUNC(mod_deflate_set_defaults) { if (0 == cpv->v.a->used) cpv->v.a = NULL; break; case 1: /* deflate.allowed-encodings */ - if (!array_is_vlist(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"encoding\"", cpk[cpv->k_id].k); - return HANDLER_ERROR; - } cpv->v.shrt = (unsigned short) mod_deflate_encodings_to_flags(cpv->v.a); cpv->vtype = T_CONFIG_SHORT; diff --git a/src/mod_dirlisting.c b/src/mod_dirlisting.c index b6e49d7a..d5dd7341 100644 --- a/src/mod_dirlisting.c +++ b/src/mod_dirlisting.c @@ -206,7 +206,7 @@ SETDEFAULTS_FUNC(mod_dirlisting_set_defaults) { T_CONFIG_BOOL, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("dir-listing.exclude"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("dir-listing.hide-dot-files"), T_CONFIG_BOOL, @@ -263,12 +263,6 @@ SETDEFAULTS_FUNC(mod_dirlisting_set_defaults) { case 1: /* server.dir-listing *//*(historical)*/ break; case 2: /* dir-listing.exclude */ - if (!array_is_vlist(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"regex\"", cpk[cpv->k_id].k); - return HANDLER_ERROR; - } #ifndef HAVE_PCRE_H if (cpv->v.a->used > 0) { log_error(srv->errh, __FILE__, __LINE__, diff --git a/src/mod_expire.c b/src/mod_expire.c index 3a0ed29e..c80cc81b 100644 --- a/src/mod_expire.c +++ b/src/mod_expire.c @@ -195,10 +195,10 @@ static void mod_expire_patch_config(connection * const con, plugin_data * const SETDEFAULTS_FUNC(mod_expire_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("expire.url"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("expire.mimetypes"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ NULL, 0, T_CONFIG_UNSET, @@ -217,23 +217,9 @@ SETDEFAULTS_FUNC(mod_expire_set_defaults) { const array *a = NULL; switch (cpv->k_id) { case 0: /* expire.url */ - if (!array_is_kvstring(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"urlpath\" => \"expiration\"", - cpk[cpv->k_id].k); - return HANDLER_ERROR; - } a = cpv->v.a; break; case 1: /* expire.mimetypes */ - if (!array_is_kvstring(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"mimetype\" => \"expiration\"", - cpk[cpv->k_id].k); - return HANDLER_ERROR; - } for (uint32_t k = 0; k < cpv->v.a->used; ++k) { data_string *ds = (data_string *)cpv->v.a->data[k]; /*(omit trailing '*', if present, from prefix match)*/ diff --git a/src/mod_extforward.c b/src/mod_extforward.c index 1943548b..d9d25ae9 100644 --- a/src/mod_extforward.c +++ b/src/mod_extforward.c @@ -327,13 +327,13 @@ static unsigned int mod_extforward_parse_opts(server *srv, const array *opts_par SETDEFAULTS_FUNC(mod_extforward_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("extforward.forwarder"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("extforward.headers"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("extforward.params"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVANY, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("extforward.hap-PROXY"), T_CONFIG_BOOL, @@ -359,13 +359,6 @@ SETDEFAULTS_FUNC(mod_extforward_set_defaults) { for (; -1 != cpv->k_id; ++cpv) { switch (cpv->k_id) { case 0: /* extforward.forwarder */ - if (!array_is_kvstring(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"IPaddr\" => \"trust\"", - cpk[cpv->k_id].k); - return HANDLER_ERROR; - } cpv->v.v = mod_extforward_parse_forwarder(srv, cpv->v.a); if (NULL == cpv->v.v) { log_error(srv->errh, __FILE__, __LINE__, @@ -375,21 +368,8 @@ SETDEFAULTS_FUNC(mod_extforward_set_defaults) { cpv->vtype = T_CONFIG_LOCAL; break; case 1: /* extforward.headers */ - if (!array_is_vlist(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"headername\"", cpk[cpv->k_id].k); - return HANDLER_ERROR; - } break; case 2: /* extforward.params */ - if (!array_is_kvany(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"param\" => \"value\"", - cpk[cpv->k_id].k); - return HANDLER_ERROR; - } cpv->v.u = mod_extforward_parse_opts(srv, cpv->v.a); if (UINT_MAX == cpv->v.u) return HANDLER_ERROR; diff --git a/src/mod_fastcgi.c b/src/mod_fastcgi.c index c908c7a9..d856bccf 100644 --- a/src/mod_fastcgi.c +++ b/src/mod_fastcgi.c @@ -78,7 +78,7 @@ static void mod_fastcgi_patch_config(connection * const con, plugin_data * const SETDEFAULTS_FUNC(mod_fastcgi_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("fastcgi.server"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVARRAY, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("fastcgi.balance"), T_CONFIG_STRING, @@ -87,7 +87,7 @@ SETDEFAULTS_FUNC(mod_fastcgi_set_defaults) { T_CONFIG_INT, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("fastcgi.map-extensions"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ NULL, 0, T_CONFIG_UNSET, @@ -120,15 +120,7 @@ SETDEFAULTS_FUNC(mod_fastcgi_set_defaults) { cpv->v.u = (unsigned int)gw_get_defaults_balance(srv, cpv->v.b); break; case 2: /* fastcgi.debug */ - break; case 3: /* fastcgi.map-extensions */ - if (!array_is_kvstring(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"suffix\" => \"subst\"", - cpk[cpv->k_id].k); - return HANDLER_ERROR; - } break; default:/* should not happen */ break; diff --git a/src/mod_flv_streaming.c b/src/mod_flv_streaming.c index e662c5fc..f8431e80 100644 --- a/src/mod_flv_streaming.c +++ b/src/mod_flv_streaming.c @@ -54,7 +54,7 @@ static void mod_flv_streaming_patch_config(connection * const con, plugin_data * SETDEFAULTS_FUNC(mod_flv_streaming_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("flv-streaming.extensions"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_CONNECTION } ,{ NULL, 0, T_CONFIG_UNSET, @@ -65,26 +65,6 @@ SETDEFAULTS_FUNC(mod_flv_streaming_set_defaults) { if (!config_plugin_values_init(srv, p, cpk, "mod_flv_streaming")) return HANDLER_ERROR; - /* process and validate config directives - * (init i to 0 if global context; to 1 to skip empty global context) */ - for (int i = !p->cvlist[0].v.u2[1]; i < p->nconfig; ++i) { - const config_plugin_value_t *cpv = p->cvlist + p->cvlist[i].v.u2[0]; - for (; -1 != cpv->k_id; ++cpv) { - switch (cpv->k_id) { - case 0: /* flv-streaming.extensions */ - if (!array_is_vlist(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"ext\"", cpk[cpv->k_id].k); - return HANDLER_ERROR; - } - break; - default:/* should not happen */ - break; - } - } - } - /* initialize p->defaults from global config context */ if (p->nconfig > 0 && p->cvlist->v.u2[1]) { const config_plugin_value_t *cpv = p->cvlist + p->cvlist->v.u2[0]; diff --git a/src/mod_indexfile.c b/src/mod_indexfile.c index 01fd9288..558dd5c1 100644 --- a/src/mod_indexfile.c +++ b/src/mod_indexfile.c @@ -58,10 +58,10 @@ static void mod_indexfile_patch_config(connection * const con, plugin_data * con SETDEFAULTS_FUNC(mod_indexfile_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("index-file.names"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("server.indexfiles"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_CONNECTION } ,{ NULL, 0, T_CONFIG_UNSET, @@ -72,27 +72,6 @@ SETDEFAULTS_FUNC(mod_indexfile_set_defaults) { if (!config_plugin_values_init(srv, p, cpk, "mod_indexfile")) return HANDLER_ERROR; - /* process and validate config directives - * (init i to 0 if global context; to 1 to skip empty global context) */ - for (int i = !p->cvlist[0].v.u2[1]; i < p->nconfig; ++i) { - const config_plugin_value_t *cpv = p->cvlist + p->cvlist[i].v.u2[0]; - for (; -1 != cpv->k_id; ++cpv) { - switch (cpv->k_id) { - case 0: /* index-file.names */ - case 1: /* server.indexfiles */ - if (!array_is_vlist(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"file\"", cpk[cpv->k_id].k); - return HANDLER_ERROR; - } - break; - default:/* should not happen */ - break; - } - } - } - /* initialize p->defaults from global config context */ if (p->nconfig > 0 && p->cvlist->v.u2[1]) { const config_plugin_value_t *cpv = p->cvlist + p->cvlist->v.u2[0]; diff --git a/src/mod_magnet.c b/src/mod_magnet.c index 1884e80f..bf7ac2cb 100644 --- a/src/mod_magnet.c +++ b/src/mod_magnet.c @@ -81,10 +81,10 @@ static void mod_magnet_patch_config(connection * const con, plugin_data * const SETDEFAULTS_FUNC(mod_magnet_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("magnet.attract-raw-url-to"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("magnet.attract-physical-path-to"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_CONNECTION } ,{ NULL, 0, T_CONFIG_UNSET, @@ -103,12 +103,6 @@ SETDEFAULTS_FUNC(mod_magnet_set_defaults) { switch (cpv->k_id) { case 0: /* magnet.attract-raw-url-to */ case 1: /* magnet.attract-physical-path-to */ - if (!array_is_vlist(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"scriptpath\"", cpk[cpv->k_id].k); - return HANDLER_ERROR; - } for (uint32_t j = 0; j < cpv->v.a->used; ++j) { data_string *ds = (data_string *)cpv->v.a->data[j]; if (buffer_string_is_empty(&ds->value)) { diff --git a/src/mod_maxminddb.c b/src/mod_maxminddb.c index 080404b2..aadb8a17 100644 --- a/src/mod_maxminddb.c +++ b/src/mod_maxminddb.c @@ -278,7 +278,7 @@ SETDEFAULTS_FUNC(mod_maxminddb_set_defaults) T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("maxminddb.env"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_CONNECTION } ,{ NULL, 0, T_CONFIG_UNSET, diff --git a/src/mod_openssl.c b/src/mod_openssl.c index 4884cac0..493a8a72 100644 --- a/src/mod_openssl.c +++ b/src/mod_openssl.c @@ -1302,7 +1302,7 @@ mod_openssl_set_defaults_sockets(server *srv, plugin_data *p) T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("ssl.openssl.ssl-conf-cmd"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("ssl.pemfile"), /* included to process global scope */ T_CONFIG_STRING, @@ -1382,12 +1382,6 @@ mod_openssl_set_defaults_sockets(server *srv, plugin_data *p) break; case 5: /* ssl.openssl.ssl-conf-cmd */ *(const array **)&conf.ssl_conf_cmd = cpv->v.a; - if (!array_is_kvstring(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "%s must be array of \"key\" => \"value\" strings", - cpk[cpv->k_id].k); - rc = HANDLER_ERROR; - } break; case 6: /* ssl.pemfile */ /* ignore here; included to process global scope when diff --git a/src/mod_proxy.c b/src/mod_proxy.c index db56b97e..20e1b0ea 100644 --- a/src/mod_proxy.c +++ b/src/mod_proxy.c @@ -282,7 +282,7 @@ SETDEFAULTS_FUNC(mod_proxy_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("proxy.server"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVARRAY, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("proxy.balance"), T_CONFIG_STRING, @@ -291,13 +291,13 @@ SETDEFAULTS_FUNC(mod_proxy_set_defaults) T_CONFIG_INT, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("proxy.map-extensions"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("proxy.forwarded"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVANY, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("proxy.header"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVANY, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("proxy.replace-http-host"), T_CONFIG_BOOL, @@ -343,36 +343,14 @@ SETDEFAULTS_FUNC(mod_proxy_set_defaults) cpv->v.u = (unsigned int)gw_get_defaults_balance(srv, cpv->v.b); break; case 2: /* proxy.debug */ - break; case 3: /* proxy.map-extensions */ - if (!array_is_kvstring(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"suffix\" => \"subst\"", - cpk[cpv->k_id].k); - return HANDLER_ERROR; - } break; case 4: /* proxy.forwarded */ - if (!array_is_kvany(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected ( \"param\" => \"value\" )", - cpk[cpv->k_id].k); - return HANDLER_ERROR; - } cpv->v.u = mod_proxy_parse_forwarded(srv, cpv->v.a); if (UINT_MAX == cpv->v.u) return HANDLER_ERROR; cpv->vtype = T_CONFIG_LOCAL; break; case 5: /* proxy.header */ - if (!array_is_kvany(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected ( \"param\" => ( \"key\" => \"value\" ) )", - cpk[cpv->k_id].k); - return HANDLER_ERROR; - } cpv->v.v = mod_proxy_parse_header_opts(srv, cpv->v.a); if (NULL == cpv->v.v) return HANDLER_ERROR; cpv->vtype = T_CONFIG_LOCAL; diff --git a/src/mod_redirect.c b/src/mod_redirect.c index e219c736..ee325544 100644 --- a/src/mod_redirect.c +++ b/src/mod_redirect.c @@ -97,7 +97,7 @@ static pcre_keyvalue_buffer * mod_redirect_parse_list(server *srv, const array * SETDEFAULTS_FUNC(mod_redirect_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("url.redirect"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("url.redirect-code"), T_CONFIG_SHORT, @@ -118,13 +118,6 @@ SETDEFAULTS_FUNC(mod_redirect_set_defaults) { for (; -1 != cpv->k_id; ++cpv) { switch (cpv->k_id) { case 0: /* url.redirect */ - if (!array_is_kvstring(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"regex\" => \"redirect\"", - cpk[cpv->k_id].k); - return HANDLER_ERROR; - } cpv->v.v = mod_redirect_parse_list(srv, cpv->v.a, p->cvlist[i].k_id); if (NULL == cpv->v.v) return HANDLER_ERROR; diff --git a/src/mod_rewrite.c b/src/mod_rewrite.c index 58f37b84..87d8f129 100644 --- a/src/mod_rewrite.c +++ b/src/mod_rewrite.c @@ -92,15 +92,7 @@ static void mod_rewrite_patch_config(connection * const con, plugin_data * const } } -static pcre_keyvalue_buffer * mod_rewrite_parse_list(server *srv, const array *a, pcre_keyvalue_buffer *kvb, const int condidx, const char *option) { - if (!array_is_kvstring(a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"regex\" => \"subst\"", - option); - return NULL; - } - +static pcre_keyvalue_buffer * mod_rewrite_parse_list(server *srv, const array *a, pcre_keyvalue_buffer *kvb, const int condidx) { int allocated = 0; if (NULL == kvb) { allocated = 1; @@ -128,22 +120,22 @@ static pcre_keyvalue_buffer * mod_rewrite_parse_list(server *srv, const array *a SETDEFAULTS_FUNC(mod_rewrite_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("url.rewrite-once"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("url.rewrite-final"), /* old name => url.rewrite-once */ - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("url.rewrite"), /* old name => url.rewrite-once */ - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("url.rewrite-repeat"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("url.rewrite-if-not-file"), /* rewrite-once if ENOENT */ - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("url.rewrite-repeat-if-not-file"), /* repeat if ENOENT */ - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ NULL, 0, T_CONFIG_UNSET, @@ -191,24 +183,21 @@ SETDEFAULTS_FUNC(mod_rewrite_set_defaults) { pcre_keyvalue_buffer *kvb = NULL, *kvb_NF = NULL; if ((cpv = rewrite_once)) { - cpv->v.v = mod_rewrite_parse_list(srv, cpv->v.a, kvb, condidx, - cpk[cpv->k_id].k); /* directive */ + cpv->v.v = mod_rewrite_parse_list(srv, cpv->v.a, kvb, condidx); if (NULL == cpv->v.v) return HANDLER_ERROR; cpv->vtype = T_CONFIG_LOCAL; kvb = cpv->v.v; } if ((cpv = rewrite_final)) { - cpv->v.v = mod_rewrite_parse_list(srv, cpv->v.a, kvb, condidx, - cpk[cpv->k_id].k); /* directive */ + cpv->v.v = mod_rewrite_parse_list(srv, cpv->v.a, kvb, condidx); if (NULL == cpv->v.v) return HANDLER_ERROR; cpv->vtype = T_CONFIG_LOCAL; kvb = cpv->v.v; } if ((cpv = rewrite)) { - cpv->v.v = mod_rewrite_parse_list(srv, cpv->v.a, kvb, condidx, - cpk[cpv->k_id].k); /* directive */ + cpv->v.v = mod_rewrite_parse_list(srv, cpv->v.a, kvb, condidx); if (NULL == cpv->v.v) return HANDLER_ERROR; cpv->vtype = T_CONFIG_LOCAL; kvb = cpv->v.v; @@ -217,16 +206,14 @@ SETDEFAULTS_FUNC(mod_rewrite_set_defaults) { if (kvb) kvb->x1 = (unsigned short)kvb->used; /* repeat_idx */ if ((cpv = rewrite_repeat)) { - cpv->v.v = mod_rewrite_parse_list(srv, cpv->v.a, kvb, condidx, - cpk[cpv->k_id].k); /* directive */ + cpv->v.v = mod_rewrite_parse_list(srv, cpv->v.a, kvb, condidx); if (NULL == cpv->v.v) return HANDLER_ERROR; cpv->vtype = T_CONFIG_LOCAL; /*kvb = cpv->v.v;*/ } if ((cpv = rewrite_NF)) { - cpv->v.v = mod_rewrite_parse_list(srv, cpv->v.a, kvb_NF, condidx, - cpk[cpv->k_id].k); /* directive */ + cpv->v.v = mod_rewrite_parse_list(srv, cpv->v.a, kvb_NF, condidx); if (NULL == cpv->v.v) return HANDLER_ERROR; cpv->vtype = T_CONFIG_LOCAL; kvb_NF = cpv->v.v; @@ -235,8 +222,7 @@ SETDEFAULTS_FUNC(mod_rewrite_set_defaults) { if (kvb_NF) kvb_NF->x1 = (unsigned short)kvb_NF->used; /* repeat_idx */ if ((cpv = rewrite_repeat_NF)) { - cpv->v.v = mod_rewrite_parse_list(srv, cpv->v.a, kvb_NF, condidx, - cpk[cpv->k_id].k); /* directive */ + cpv->v.v = mod_rewrite_parse_list(srv, cpv->v.a, kvb_NF, condidx); if (NULL == cpv->v.v) return HANDLER_ERROR; cpv->vtype = T_CONFIG_LOCAL; /*kvb_NF = cpv->v.v;*/ diff --git a/src/mod_scgi.c b/src/mod_scgi.c index d39cc999..0abc2530 100644 --- a/src/mod_scgi.c +++ b/src/mod_scgi.c @@ -65,7 +65,7 @@ static void mod_scgi_patch_config(connection * const con, plugin_data * const p) SETDEFAULTS_FUNC(mod_scgi_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("scgi.server"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVARRAY, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("scgi.balance"), T_CONFIG_STRING, @@ -74,7 +74,7 @@ SETDEFAULTS_FUNC(mod_scgi_set_defaults) { T_CONFIG_INT, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("scgi.map-extensions"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("scgi.protocol"), T_CONFIG_STRING, @@ -110,15 +110,7 @@ SETDEFAULTS_FUNC(mod_scgi_set_defaults) { cpv->v.u = (unsigned int)gw_get_defaults_balance(srv, cpv->v.b); break; case 2: /* scgi.debug */ - break; case 3: /* scgi.map-extensions */ - if (!array_is_kvstring(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"suffix\" => \"subst\"", - cpk[cpv->k_id].k); - return HANDLER_ERROR; - } break; case 4: /* scgi.protocol */ if (buffer_eq_slen(cpv->v.b, CONST_STR_LEN("scgi"))) diff --git a/src/mod_setenv.c b/src/mod_setenv.c index 37e76dfc..f08b3d87 100644 --- a/src/mod_setenv.c +++ b/src/mod_setenv.c @@ -87,22 +87,22 @@ static void mod_setenv_patch_config(connection * const con, plugin_data * const SETDEFAULTS_FUNC(mod_setenv_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("setenv.add-request-header"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("setenv.add-response-header"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("setenv.add-environment"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("setenv.set-request-header"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("setenv.set-response-header"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("setenv.set-environment"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ NULL, 0, T_CONFIG_UNSET, @@ -130,12 +130,6 @@ SETDEFAULTS_FUNC(mod_setenv_set_defaults) { case 3: /* setenv.set-request-header */ case 4: /* setenv.set-response-header */ case 5: /* setenv.set-environment */ - if (!array_is_kvstring(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"key\" => \"value\"",cpk[cpv->k_id].k); - return HANDLER_ERROR; - } break; default:/* should not happen */ break; diff --git a/src/mod_skeleton.c b/src/mod_skeleton.c index 3eda3242..62d22500 100644 --- a/src/mod_skeleton.c +++ b/src/mod_skeleton.c @@ -88,7 +88,7 @@ static void mod_skeleton_patch_config(connection * const con, plugin_data * cons SETDEFAULTS_FUNC(mod_skeleton_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("skeleton.array"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_CONNECTION } ,{ NULL, 0, T_CONFIG_UNSET, @@ -99,26 +99,6 @@ SETDEFAULTS_FUNC(mod_skeleton_set_defaults) { if (!config_plugin_values_init(srv, p, cpk, "mod_skeleton")) return HANDLER_ERROR; - /* process and validate config directives - * (init i to 0 if global context; to 1 to skip empty global context) */ - for (int i = !p->cvlist[0].v.u2[1]; i < p->nconfig; ++i) { - const config_plugin_value_t *cpv = p->cvlist + p->cvlist[i].v.u2[0]; - for (; -1 != cpv->k_id; ++cpv) { - switch (cpv->k_id) { - case 0: /* static-file.exclude-extensions */ - if (!array_is_vlist(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"url-path\"", cpk[cpv->k_id].k); - return HANDLER_ERROR; - } - break; - default:/* should not happen */ - break; - } - } - } - /* initialize p->defaults from global config context */ if (p->nconfig > 0 && p->cvlist->v.u2[1]) { const config_plugin_value_t *cpv = p->cvlist + p->cvlist->v.u2[0]; diff --git a/src/mod_sockproxy.c b/src/mod_sockproxy.c index 026f9ab9..38f58bb4 100644 --- a/src/mod_sockproxy.c +++ b/src/mod_sockproxy.c @@ -59,7 +59,7 @@ static void mod_sockproxy_patch_config(connection * const con, plugin_data * con SETDEFAULTS_FUNC(mod_sockproxy_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("sockproxy.server"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVARRAY, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("sockproxy.balance"), T_CONFIG_STRING, diff --git a/src/mod_ssi.c b/src/mod_ssi.c index b54f1cf6..9eacee48 100644 --- a/src/mod_ssi.c +++ b/src/mod_ssi.c @@ -118,7 +118,7 @@ static void mod_ssi_patch_config(connection * const con, plugin_data * const p) SETDEFAULTS_FUNC(mod_ssi_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("ssi.extension"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("ssi.content-type"), T_CONFIG_STRING, @@ -141,31 +141,6 @@ SETDEFAULTS_FUNC(mod_ssi_set_defaults) { if (!config_plugin_values_init(srv, p, cpk, "mod_ssi")) return HANDLER_ERROR; - /* process and validate config directives - * (init i to 0 if global context; to 1 to skip empty global context) */ - for (int i = !p->cvlist[0].v.u2[1]; i < p->nconfig; ++i) { - const config_plugin_value_t *cpv = p->cvlist + p->cvlist[i].v.u2[0]; - for (; -1 != cpv->k_id; ++cpv) { - switch (cpv->k_id) { - case 0: /* ssi.extension */ - if (!array_is_vlist(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"ext\"", cpk[cpv->k_id].k); - return HANDLER_ERROR; - } - break; - case 1: /* ssi.content-type */ - case 2: /* ssi.conditional-requests */ - case 3: /* ssi.exec */ - case 4: /* ssi.recursion-max */ - break; - default:/* should not happen */ - break; - } - } - } - p->defaults.ssi_exec = 1; /* initialize p->defaults from global config context */ diff --git a/src/mod_staticfile.c b/src/mod_staticfile.c index ede55ee8..d3310525 100644 --- a/src/mod_staticfile.c +++ b/src/mod_staticfile.c @@ -67,7 +67,7 @@ static void mod_staticfile_patch_config(connection * const con, plugin_data * co SETDEFAULTS_FUNC(mod_staticfile_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("static-file.exclude-extensions"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("static-file.etags"), T_CONFIG_BOOL, @@ -84,26 +84,6 @@ SETDEFAULTS_FUNC(mod_staticfile_set_defaults) { if (!config_plugin_values_init(srv, p, cpk, "mod_staticfile")) return HANDLER_ERROR; - /* process and validate config directives - * (init i to 0 if global context; to 1 to skip empty global context) */ - for (int i = !p->cvlist[0].v.u2[1]; i < p->nconfig; ++i) { - const config_plugin_value_t *cpv = p->cvlist + p->cvlist[i].v.u2[0]; - for (; -1 != cpv->k_id; ++cpv) { - switch (cpv->k_id) { - case 0: /* static-file.exclude-extensions */ - if (!array_is_vlist(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"ext\"", cpk[cpv->k_id].k); - return HANDLER_ERROR; - } - break; - default:/* should not happen */ - break; - } - } - } - /* initialize p->defaults from global config context */ p->defaults.etags_used = 1; /* etags enabled */ if (p->nconfig > 0 && p->cvlist->v.u2[1]) { diff --git a/src/mod_trigger_b4_dl.c b/src/mod_trigger_b4_dl.c index 96dd485d..bce0a5b6 100644 --- a/src/mod_trigger_b4_dl.c +++ b/src/mod_trigger_b4_dl.c @@ -258,7 +258,7 @@ SETDEFAULTS_FUNC(mod_trigger_b4_dl_set_defaults) { T_CONFIG_SHORT, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("trigger-before-download.memcache-hosts"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("trigger-before-download.memcache-namespace"), T_CONFIG_STRING, @@ -297,12 +297,6 @@ SETDEFAULTS_FUNC(mod_trigger_b4_dl_set_defaults) { case 4: /* trigger-before-download.trigger-timeout */ break; case 5: /* trigger-before-download.memcache-hosts */ - if (!array_is_vlist(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"host\"", cpk[cpv->k_id].k); - return HANDLER_ERROR; - } if (!mod_trigger_b4_dl_init_memcached(srv, cpv)) return HANDLER_ERROR; break; diff --git a/src/mod_userdir.c b/src/mod_userdir.c index 459707bd..45d3e13c 100644 --- a/src/mod_userdir.c +++ b/src/mod_userdir.c @@ -82,10 +82,10 @@ SETDEFAULTS_FUNC(mod_userdir_set_defaults) { T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("userdir.exclude-user"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("userdir.include-user"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("userdir.basepath"), T_CONFIG_STRING, @@ -105,33 +105,6 @@ SETDEFAULTS_FUNC(mod_userdir_set_defaults) { if (!config_plugin_values_init(srv, p, cpk, "mod_userdir")) return HANDLER_ERROR; - /* process and validate config directives - * (init i to 0 if global context; to 1 to skip empty global context) */ - for (int i = !p->cvlist[0].v.u2[1]; i < p->nconfig; ++i) { - const config_plugin_value_t *cpv = p->cvlist + p->cvlist[i].v.u2[0]; - for (; -1 != cpv->k_id; ++cpv) { - switch (cpv->k_id) { - case 0: /* userdir.path */ - break; - case 1: /* userdir.exclude-user */ - case 2: /* userdir.include-user */ - if (!array_is_vlist(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"suffix\"", cpk[cpv->k_id].k); - return HANDLER_ERROR; - } - break; - case 3: /* userdir.basepath */ - case 4: /* userdir.letterhomes */ - case 5: /* userdir.active */ - break; - default:/* should not happen */ - break; - } - } - } - /* enabled by default for backward compatibility; * if userdir.path isn't set userdir is disabled too, * but you can't disable it by setting it to an empty string. */ diff --git a/src/mod_vhostdb_dbi.c b/src/mod_vhostdb_dbi.c index acf7e550..f25be7f3 100644 --- a/src/mod_vhostdb_dbi.c +++ b/src/mod_vhostdb_dbi.c @@ -279,7 +279,7 @@ static void mod_vhostdb_patch_config(connection * const con, plugin_data * const SETDEFAULTS_FUNC(mod_vhostdb_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("vhostdb.dbi"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ NULL, 0, T_CONFIG_UNSET, @@ -298,13 +298,6 @@ SETDEFAULTS_FUNC(mod_vhostdb_set_defaults) { switch (cpv->k_id) { case 0: /* vhostdb. */ if (cpv->v.a->used) { - if (!array_is_kvstring(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"option\" => \"value\"", - cpk[cpv->k_id].k); - return HANDLER_ERROR; - } if (0 != mod_vhostdb_dbconf_setup(srv, cpv->v.a, &cpv->v.v)) return HANDLER_ERROR; if (NULL != cpv->v.v) diff --git a/src/mod_vhostdb_ldap.c b/src/mod_vhostdb_ldap.c index 227cc475..c1268156 100644 --- a/src/mod_vhostdb_ldap.c +++ b/src/mod_vhostdb_ldap.c @@ -506,7 +506,7 @@ static void mod_vhostdb_patch_config(connection * const con, plugin_data * const SETDEFAULTS_FUNC(mod_vhostdb_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("vhostdb.ldap"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ NULL, 0, T_CONFIG_UNSET, @@ -525,13 +525,6 @@ SETDEFAULTS_FUNC(mod_vhostdb_set_defaults) { switch (cpv->k_id) { case 0: /* vhostdb. */ if (cpv->v.a->used) { - if (!array_is_kvstring(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"option\" => \"value\"", - cpk[cpv->k_id].k); - return HANDLER_ERROR; - } if (0 != mod_vhostdb_dbconf_setup(srv, cpv->v.a, &cpv->v.v)) return HANDLER_ERROR; if (NULL != cpv->v.v) diff --git a/src/mod_vhostdb_mysql.c b/src/mod_vhostdb_mysql.c index 76592c13..3ad9a8db 100644 --- a/src/mod_vhostdb_mysql.c +++ b/src/mod_vhostdb_mysql.c @@ -240,7 +240,7 @@ static void mod_vhostdb_patch_config(connection * const con, plugin_data * const SETDEFAULTS_FUNC(mod_vhostdb_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("vhostdb.mysql"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ NULL, 0, T_CONFIG_UNSET, @@ -259,13 +259,6 @@ SETDEFAULTS_FUNC(mod_vhostdb_set_defaults) { switch (cpv->k_id) { case 0: /* vhostdb. */ if (cpv->v.a->used) { - if (!array_is_kvstring(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"option\" => \"value\"", - cpk[cpv->k_id].k); - return HANDLER_ERROR; - } if (0 != mod_vhostdb_dbconf_setup(srv, cpv->v.a, &cpv->v.v)) return HANDLER_ERROR; if (NULL != cpv->v.v) diff --git a/src/mod_vhostdb_pgsql.c b/src/mod_vhostdb_pgsql.c index 8c67d656..2fc26a78 100644 --- a/src/mod_vhostdb_pgsql.c +++ b/src/mod_vhostdb_pgsql.c @@ -218,7 +218,7 @@ static void mod_vhostdb_patch_config(connection * const con, plugin_data * const SETDEFAULTS_FUNC(mod_vhostdb_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("vhostdb.pgsql"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ NULL, 0, T_CONFIG_UNSET, @@ -237,13 +237,6 @@ SETDEFAULTS_FUNC(mod_vhostdb_set_defaults) { switch (cpv->k_id) { case 0: /* vhostdb. */ if (cpv->v.a->used) { - if (!array_is_kvstring(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"option\" => \"value\"", - cpk[cpv->k_id].k); - return HANDLER_ERROR; - } if (0 != mod_vhostdb_dbconf_setup(srv, cpv->v.a, &cpv->v.v)) return HANDLER_ERROR; if (NULL != cpv->v.v) diff --git a/src/mod_webdav.c b/src/mod_webdav.c index 115da2a7..b4d88081 100644 --- a/src/mod_webdav.c +++ b/src/mod_webdav.c @@ -437,7 +437,7 @@ SETDEFAULTS_FUNC(mod_webdav_set_defaults) { T_CONFIG_BOOL, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("webdav.opts"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ NULL, 0, T_CONFIG_UNSET, diff --git a/src/mod_wstunnel.c b/src/mod_wstunnel.c index aefa41b4..f4c4300e 100644 --- a/src/mod_wstunnel.c +++ b/src/mod_wstunnel.c @@ -242,7 +242,7 @@ static void mod_wstunnel_patch_config(connection * const con, plugin_data * cons SETDEFAULTS_FUNC(mod_wstunnel_set_defaults) { static const config_plugin_keys_t cpk[] = { { CONST_STR_LEN("wstunnel.server"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVARRAY, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("wstunnel.balance"), T_CONFIG_STRING, @@ -251,13 +251,13 @@ SETDEFAULTS_FUNC(mod_wstunnel_set_defaults) { T_CONFIG_INT, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("wstunnel.map-extensions"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVSTRING, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("wstunnel.frame-type"), T_CONFIG_STRING, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("wstunnel.origins"), - T_CONFIG_ARRAY, + T_CONFIG_ARRAY_VLIST, T_CONFIG_SCOPE_CONNECTION } ,{ CONST_STR_LEN("wstunnel.ping-interval"), T_CONFIG_SHORT, @@ -303,15 +303,7 @@ SETDEFAULTS_FUNC(mod_wstunnel_set_defaults) { cpv->v.u = (unsigned int)gw_get_defaults_balance(srv, cpv->v.b); break; case 2: /* wstunnel.debug */ - break; case 3: /* wstunnel.map-extensions */ - if (!array_is_kvstring(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected list of \"suffix\" => \"subst\"", - cpk[cpv->k_id].k); - return HANDLER_ERROR; - } break; case 4: /* wstunnel.frame-type */ /*(default frame-type to "text" unless "binary" is specified)*/ @@ -319,13 +311,6 @@ SETDEFAULTS_FUNC(mod_wstunnel_set_defaults) { buffer_eq_icase_slen(cpv->v.b, CONST_STR_LEN("binary")); break; case 5: /* wstunnel.origins */ - if (!array_is_vlist(cpv->v.a)) { - log_error(srv->errh, __FILE__, __LINE__, - "unexpected value for %s; " - "expected %s = ( \"...\", \"...\" )", - cpk[cpv->k_id].k, cpk[cpv->k_id].k); - return HANDLER_ERROR; - } for (uint32_t j = 0; j < cpv->v.a->used; ++j) { buffer *origin = &((data_string *)cpv->v.a->data[j])->value; if (buffer_string_is_empty(origin)) { diff --git a/src/plugin_config.h b/src/plugin_config.h index 0a6348d0..217ae7aa 100644 --- a/src/plugin_config.h +++ b/src/plugin_config.h @@ -83,6 +83,10 @@ typedef enum { T_CONFIG_UNSET, T_CONFIG_INT, T_CONFIG_BOOL, T_CONFIG_ARRAY, + T_CONFIG_ARRAY_KVANY, + T_CONFIG_ARRAY_KVARRAY, + T_CONFIG_ARRAY_KVSTRING, + T_CONFIG_ARRAY_VLIST, T_CONFIG_LOCAL, T_CONFIG_DEPRECATED, T_CONFIG_UNSUPPORTED