BUG/MINOR: log: keep the ref in dup_logger()

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.
This commit is contained in:
Aurelien DARRAGON 2023-11-13 10:19:12 +01:00 committed by Christopher Faulet
parent 33a1fc883a
commit 76acde9107

View File

@ -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: