]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: cfgparse: detect collisions between defaults and log-forward
authorWilly Tarreau <w@1wt.eu>
Wed, 18 Sep 2024 16:05:02 +0000 (18:05 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 18 Sep 2024 16:08:15 +0000 (18:08 +0200)
Sadly, when log-forward were introduced they took great care of avoiding
collision with regular proxies but defaults were missed (they need to be
explicitly checked for). So now we have to move them to a warning for 3.1
instead of rejecting them.

src/cfgparse-listen.c
src/log.c

index e5945d8e24534ccc7dade625b51feca040f67e31..60f20ecd2c605a1552af0f5d8ef3be5fa458f24a 100644 (file)
@@ -318,6 +318,19 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                                   curproxy->id, curproxy->conf.file, curproxy->conf.line);
                        err_code |= ERR_WARN;
                }
+               else if (rc & PR_CAP_DEF) {
+                       /* only defaults need to be checked here, other proxies
+                        * have already been above.
+                        */
+                       curproxy = log_forward_by_name(args[1]);
+                       if (curproxy) {
+                               ha_warning("Parsing [%s:%d]: %s '%s' has the same name as log-forward section '%s' declared at %s:%d."
+                                          " This is dangerous and will not be supported anymore in version 3.3.\n",
+                                          file, linenum, proxy_cap_str(rc), args[1],
+                                          curproxy->id, curproxy->conf.file, curproxy->conf.line);
+                               err_code |= ERR_WARN;
+                       }
+               }
 
                if (rc & PR_CAP_DEF && strcmp(args[1], "from") == 0 && *args[2] && !*args[3]) {
                        // also support "defaults from blah" (no name then)
index 993fe08e80b4597a00efc30e531550e2c3c1168a..8b6e9b61f70eb1338cebef24af2952027e665ebf 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -5867,6 +5867,16 @@ int cfg_parse_log_forward(const char *file, int linenum, char **args, int kwm)
                        goto out;
                }
 
+               px = proxy_find_by_name(args[1], PR_CAP_DEF, 0);
+               if (px) {
+                       /* collision with a "defaults" section */
+                       ha_warning("Parsing [%s:%d]: log-forward section '%s' has the same name as %s '%s' declared at %s:%d."
+                                  " This is dangerous and will not be supported anymore in version 3.3.\n",
+                                  file, linenum, args[1], proxy_type_str(px),
+                                  px->id, px->conf.file, px->conf.line);
+                       err_code |= ERR_WARN;
+               }
+
                px = calloc(1, sizeof *px);
                if (!px) {
                        err_code |= ERR_ALERT | ERR_FATAL;