]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: log: keep the ref in dup_logger()
authorAurelien DARRAGON <adarragon@haproxy.com>
Mon, 13 Nov 2023 09:19:12 +0000 (10:19 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 13 Nov 2023 10:06:05 +0000 (11:06 +0100)
This bug was introduced with 969e212 ("MINOR: log: add dup_logsrv() helper
function")

When duplicating an existing log entry, we must take care to inherit from
its original ->ref if it is set, because not doing so would make 28ac0999
("MINOR: log: Keep the ref when a log server is copied to avoid duplicate entries")
ineffective given that global log directives will lose their original
reference when duplicated resursively (at least twice), which is what
happens when global log directives are first inherited to defaults which
are then inherited to a regular proxy at the end of the chain.

This can be easily reproduced using the following configuration:

   |global
   |  log stdout format raw local0
   |
   |defaults
   |  log global
   |
   |frontend test
   |  log global
   |  ...

Logs from "test" proxy will be duplicated because test incorrectly
inherited from global "log" directives twice, which 28ac0999 would
normally detect and prevent.

No backport needed unless 969e212 gets backported.

src/log.c

index c6f817c6657f963a0c551327e3b308d6f7bb758c..a2d4dc84182a8d1b80a19d520c328491813cb3e7 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -1089,7 +1089,10 @@ struct logger *dup_logger(struct logger *def)
                if (!cpy->conf.file)
                        goto error;
        }
-       cpy->ref = def;
+
+       /* inherit from original reference if set */
+       cpy->ref = (def->ref) ? def->ref : def;
+
        return cpy;
 
  error: