mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-29 14:50:59 +01:00
BUG/MINOR: proxy/log: frontend/backend and log forward names must differ
This patch disallow to use same name for a log forward section and a frontend/backend section.
This commit is contained in:
parent
cbb7bf7dd1
commit
b0c331f71f
@ -169,6 +169,22 @@ static inline int build_logline(struct stream *s, char *dst, size_t maxsize, str
|
|||||||
|
|
||||||
struct ist *build_log_header(enum log_fmt format, int level, int facility, struct ist *metadata, size_t *nbelem);
|
struct ist *build_log_header(enum log_fmt format, int level, int facility, struct ist *metadata, size_t *nbelem);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* lookup log forward proxy by name
|
||||||
|
* Returns NULL if no proxy found.
|
||||||
|
*/
|
||||||
|
static inline struct proxy *log_forward_by_name(const char *name)
|
||||||
|
{
|
||||||
|
struct proxy *px = cfg_log_forward;
|
||||||
|
|
||||||
|
while (px) {
|
||||||
|
if (strcmp(px->id, name) == 0)
|
||||||
|
return px;
|
||||||
|
px = px->next;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* _HAPROXY_LOG_H */
|
#endif /* _HAPROXY_LOG_H */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -211,6 +211,14 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
|||||||
err_code |= ERR_ALERT | ERR_FATAL;
|
err_code |= ERR_ALERT | ERR_FATAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
curproxy = log_forward_by_name(args[1]);
|
||||||
|
if (curproxy) {
|
||||||
|
ha_alert("Parsing [%s:%d]: %s '%s' has the same name as log forward section '%s' declared at %s:%d.\n",
|
||||||
|
file, linenum, proxy_cap_str(rc), args[1],
|
||||||
|
curproxy->id, curproxy->conf.file, curproxy->conf.line);
|
||||||
|
err_code |= ERR_ALERT | ERR_FATAL;
|
||||||
|
}
|
||||||
|
|
||||||
if ((curproxy = calloc(1, sizeof(*curproxy))) == NULL) {
|
if ((curproxy = calloc(1, sizeof(*curproxy))) == NULL) {
|
||||||
ha_alert("parsing [%s:%d] : out of memory.\n", file, linenum);
|
ha_alert("parsing [%s:%d] : out of memory.\n", file, linenum);
|
||||||
err_code |= ERR_ALERT | ERR_ABORT;
|
err_code |= ERR_ALERT | ERR_ABORT;
|
||||||
|
|||||||
11
src/log.c
11
src/log.c
@ -3731,12 +3731,19 @@ int cfg_parse_log_forward(const char *file, int linenum, char **args, int kwm)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (px = cfg_log_forward ; px ; px = px->next) {
|
px = log_forward_by_name(args[1]);
|
||||||
if (strcmp(px->id, args[1]) == 0) {
|
if (px) {
|
||||||
ha_alert("Parsing [%s:%d]: log-forward section '%s' has the same name as another log-forward section declared at %s:%d.\n",
|
ha_alert("Parsing [%s:%d]: log-forward section '%s' has the same name as another log-forward section declared at %s:%d.\n",
|
||||||
file, linenum, args[1], px->conf.file, px->conf.line);
|
file, linenum, args[1], px->conf.file, px->conf.line);
|
||||||
err_code |= ERR_ALERT | ERR_FATAL;
|
err_code |= ERR_ALERT | ERR_FATAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
px = proxy_find_by_name(args[1], 0, 0);
|
||||||
|
if (px) {
|
||||||
|
ha_alert("Parsing [%s:%d]: log forward section '%s' has the same name as %s '%s' declared at %s:%d.\n",
|
||||||
|
file, linenum, args[1], proxy_type_str(px),
|
||||||
|
px->id, px->conf.file, px->conf.line);
|
||||||
|
err_code |= ERR_ALERT | ERR_FATAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
px = calloc(1, sizeof *px);
|
px = calloc(1, sizeof *px);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user