diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/proxy/mod_proxy.c | 133 | ||||
-rw-r--r-- | modules/proxy/mod_proxy_balancer.c | 67 |
2 files changed, 81 insertions, 119 deletions
diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c index 233019ccec..3380e1d5e0 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -2969,78 +2969,79 @@ static const char *proxysection(cmd_parms *cmd, void *mconfig, const char *arg) ap_add_per_proxy_conf(cmd->server, new_dir_conf); - /* if (*arg != '\0') { Yann Ylavic <ylavic.dev@gmail.com> */ - if (thiscmd->cmd_data) - return "Multiple <ProxyMatch> arguments not (yet) supported."; - if (conf->p_is_fnmatch) - return apr_pstrcat(cmd->pool, thiscmd->name, - "> arguments are not supported for wildchar url.", - NULL); - if (!ap_strchr_c(conf->p, ':')) - return apr_pstrcat(cmd->pool, thiscmd->name, - "> arguments are not supported for non url.", - NULL); - if (ap_proxy_valid_balancer_name((char *)conf->p, 9)) { - balancer = ap_proxy_get_balancer(cmd->pool, sconf, conf->p, 0); - if (!balancer) { - err = ap_proxy_define_balancer(cmd->pool, &balancer, - sconf, conf->p, "/", 0); - if (err) - return apr_pstrcat(cmd->temp_pool, thiscmd->name, - " ", err, NULL); - } - if (!balancer->section_config) { - balancer->section_config = new_dir_conf; - } - } - else { - worker = ap_proxy_get_worker(cmd->temp_pool, NULL, sconf, - ap_proxy_de_socketfy(cmd->temp_pool, (char*)conf->p)); - if (!worker) { - if (use_regex) { - err = ap_proxy_define_match_worker(cmd->pool, &worker, NULL, - sconf, conf->p, 0); + if (*arg != '\0') { + if (thiscmd->cmd_data) + return "Multiple <ProxyMatch> arguments not (yet) supported."; + if (conf->p_is_fnmatch) + return apr_pstrcat(cmd->pool, thiscmd->name, + "> arguments are not supported for wildchar url.", + NULL); + if (!ap_strchr_c(conf->p, ':')) + return apr_pstrcat(cmd->pool, thiscmd->name, + "> arguments are not supported for non url.", + NULL); + if (ap_proxy_valid_balancer_name((char *)conf->p, 9)) { + balancer = ap_proxy_get_balancer(cmd->pool, sconf, conf->p, 0); + if (!balancer) { + err = ap_proxy_define_balancer(cmd->pool, &balancer, + sconf, conf->p, "/", 0); + if (err) + return apr_pstrcat(cmd->temp_pool, thiscmd->name, + " ", err, NULL); } - else { - err = ap_proxy_define_worker(cmd->pool, &worker, NULL, - sconf, conf->p, 0); + if (!balancer->section_config) { + balancer->section_config = new_dir_conf; } - if (err) - return apr_pstrcat(cmd->temp_pool, thiscmd->name, - " ", err, NULL); } - else if ((use_regex != 0) ^ (worker->s->is_name_matchable != 0)) { - return apr_pstrcat(cmd->temp_pool, "ProxyPass/<Proxy> and " - "ProxyPassMatch/<ProxyMatch> can't be used " - "altogether with the same worker name ", - "(", worker->s->name, ")", NULL); + else { + worker = ap_proxy_get_worker(cmd->temp_pool, NULL, sconf, + ap_proxy_de_socketfy(cmd->temp_pool, (char*)conf->p)); + if (!worker) { + if (use_regex) { + err = ap_proxy_define_match_worker(cmd->pool, &worker, NULL, + sconf, conf->p, 0); + } + else { + err = ap_proxy_define_worker(cmd->pool, &worker, NULL, + sconf, conf->p, 0); + } + if (err) + return apr_pstrcat(cmd->temp_pool, thiscmd->name, + " ", err, NULL); + } + else if ((use_regex != 0) ^ (worker->s->is_name_matchable != 0)) { + return apr_pstrcat(cmd->temp_pool, "ProxyPass/<Proxy> and " + "ProxyPassMatch/<ProxyMatch> can't be used " + "altogether with the same worker name ", + "(", worker->s->name, ")", NULL); + } + if (!worker->section_config) { + worker->section_config = new_dir_conf; + } } - if (!worker->section_config) { - worker->section_config = new_dir_conf; + if (worker == NULL && balancer == NULL) { + return apr_pstrcat(cmd->pool, thiscmd->name, + "> arguments are supported only for workers.", + NULL); } - } - if (worker == NULL && balancer == NULL) { - return apr_pstrcat(cmd->pool, thiscmd->name, - "> arguments are supported only for workers.", - NULL); - } - while (*arg) { - word = ap_getword_conf(cmd->pool, &arg); - val = strchr(word, '='); - if (!val) { - return "Invalid Proxy parameter. Parameter must be " - "in the form 'key=value'"; + while (*arg) { + word = ap_getword_conf(cmd->pool, &arg); + val = strchr(word, '='); + if (!val) { + return "Invalid Proxy parameter. Parameter must be " + "in the form 'key=value'"; + } + else + *val++ = '\0'; + if (worker) + err = set_worker_param(cmd->pool, cmd->server, worker, word, val); + else + err = set_balancer_param(sconf, cmd->pool, balancer, + word, val); + if (err) + return apr_pstrcat(cmd->temp_pool, thiscmd->name, " ", err, " ", + word, "=", val, "; ", conf->p, NULL); } - else - *val++ = '\0'; - if (worker) - err = set_worker_param(cmd->pool, cmd->server, worker, word, val); - else - err = set_balancer_param(sconf, cmd->pool, balancer, - word, val); - if (err) - return apr_pstrcat(cmd->temp_pool, thiscmd->name, " ", err, " ", - word, "=", val, "; ", conf->p, NULL); } cmd->path = old_path; diff --git a/modules/proxy/mod_proxy_balancer.c b/modules/proxy/mod_proxy_balancer.c index 5032e2d55a..66be13a6d6 100644 --- a/modules/proxy/mod_proxy_balancer.c +++ b/modules/proxy/mod_proxy_balancer.c @@ -1109,12 +1109,12 @@ static void push2table(const char *input, apr_table_t *params, */ static int balancer_process_balancer_worker(request_rec *r, proxy_server_conf *conf, proxy_balancer *bsel, - proxy_worker *wsel, + proxy_worker *wsel, int ok2change, apr_table_t *params) { apr_status_t rv; /* First set the params */ - if (wsel) { + if (wsel && ok2change) { const char *val; int was_usable = PROXY_WORKER_IS_USABLE(wsel); @@ -1223,7 +1223,7 @@ static int balancer_process_balancer_worker(request_rec *r, proxy_server_conf *c } - if (bsel) { + if (bsel && ok2change) { const char *val; int ival; ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01193) @@ -1374,42 +1374,6 @@ static int balancer_process_balancer_worker(request_rec *r, proxy_server_conf *c } /* - * Process a request for balancer or worker management from another module - */ -static int balancer_manage(request_rec *r, apr_table_t *params) -{ - void *sconf; - proxy_server_conf *conf; - proxy_balancer *bsel = NULL; - proxy_worker *wsel = NULL; - const char *name; - sconf = r->server->module_config; - conf = (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module); - - /* Process the parameters */ - if ((name = apr_table_get(params, "b"))) { - ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "balancer_manage " - "balancer: %s", name); - bsel = ap_proxy_get_balancer(r->pool, conf, - apr_pstrcat(r->pool, BALANCER_PREFIX, name, NULL), 0); - } - - if ((name = apr_table_get(params, "w"))) { - ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "balancer_manage " - "worker: %s", name); - wsel = ap_proxy_get_worker(r->pool, bsel, conf, name); - } - if (bsel) { - ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "balancer_manage " - "balancer: %s", bsel->s->name); - return(balancer_process_balancer_worker(r, conf, bsel, wsel, params)); - } - ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "balancer_manage failed: " - "No balancer!"); - return HTTP_BAD_REQUEST; -} - -/* * builds the page and links to configure via HTLM or XML. */ static void balancer_display_page(request_rec *r, proxy_server_conf *conf, @@ -1983,23 +1947,21 @@ static int balancer_handler(request_rec *r) /* Check that the supplied nonce matches this server's nonce; * otherwise ignore all parameters, to prevent a CSRF attack. */ - if ((name = apr_table_get(params, "nonce"))) { - /* we have a nonce */ - if (bsel) { - /* we have a balancer */ - if (*bsel->s->nonce && strcmp(bsel->s->nonce, name) != 0) - ok2change = 0; - } - } else { + if (!bsel || + (*bsel->s->nonce && + ( + (name = apr_table_get(params, "nonce")) == NULL || + strcmp(bsel->s->nonce, name) != 0 + ) + ) + ) { ok2change = 0; } /* process the parameters and add the worker to the balancer */ - if (ok2change) { - rv = balancer_process_balancer_worker(r, conf, bsel, wsel, params); - if (rv != APR_SUCCESS) { - return HTTP_BAD_REQUEST; - } + rv = balancer_process_balancer_worker(r, conf, bsel, wsel, ok2change, params); + if (rv != APR_SUCCESS) { + return HTTP_BAD_REQUEST; } /* display the HTML or XML page */ @@ -2068,7 +2030,6 @@ static void ap_proxy_balancer_register_hook(apr_pool_t *p) static const char *const aszPred[] = { "mpm_winnt.c", "mod_slotmem_shm.c", NULL}; static const char *const aszPred2[] = { "mod_proxy.c", NULL}; /* manager handler */ - ap_register_provider(p, "balancer", "manager", "0", &balancer_manage); ap_hook_post_config(balancer_post_config, aszPred2, NULL, APR_HOOK_MIDDLE); ap_hook_pre_config(balancer_pre_config, NULL, NULL, APR_HOOK_MIDDLE); ap_hook_handler(balancer_handler, NULL, NULL, APR_HOOK_FIRST); |