You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jf...@apache.org on 2021/03/03 13:21:28 UTC

svn commit: r1887143 - in /httpd/httpd/trunk/modules/proxy: mod_proxy.c mod_proxy_balancer.c

Author: jfclere
Date: Wed Mar  3 13:21:27 2021
New Revision: 1887143

URL: http://svn.apache.org/viewvc?rev=1887143&view=rev
Log:
rollback r1887138. Sorry ;-(

Modified:
    httpd/httpd/trunk/modules/proxy/mod_proxy.c
    httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.c?rev=1887143&r1=1887142&r2=1887143&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.c Wed Mar  3 13:21:27 2021
@@ -2969,78 +2969,79 @@ static const char *proxysection(cmd_parm
 
     ap_add_per_proxy_conf(cmd->server, new_dir_conf);
 
-    /* if (*arg != '\0') { Yann Ylavic <yl...@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 (*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);
+            }
+            if (!balancer->section_config) {
+                balancer->section_config = new_dir_conf;
+            }
         }
-        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);
+                }
+                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;
+            }
         }
-    }
-    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 (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'";
             }
+            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, 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 == 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'";
+                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;

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c?rev=1887143&r1=1887142&r2=1887143&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_balancer.c Wed Mar  3 13:21:27 2021
@@ -1109,12 +1109,12 @@ static void push2table(const char *input
  */
 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_wor
 
     }
 
-    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_wor
 }
 
 /*
- * 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
 
     /* 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_h
     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);