mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-18 11:40:50 +00:00
MINOR: acl: Warn when an ACL is named 'or'
Consider a configuration like this: > acl t always_true > acl or always_false > > http-response set-header Foo Bar if t or t The 'or' within the condition will be treated as a logical disjunction and the header will be set, despite the ACL 'or' being falsy. This patch makes it an error to declare such an ACL that will never work. This patch may be backported to stable releases, turning the error into a warning only (the code was written in a way to make this trivial). It should not break anything and might improve the users' lifes.
This commit is contained in:
parent
9d6bb5a546
commit
0cf811a5f9
@ -807,6 +807,14 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strcasecmp(args[1], "or") == 0) {
|
||||||
|
ha_warning("parsing [%s:%d] : acl name '%s' will never match. 'or' is used to express a "
|
||||||
|
"logical disjunction within a condition.\n",
|
||||||
|
file, linenum, args[1]);
|
||||||
|
err_code |= ERR_ALERT | ERR_FATAL;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
if (parse_acl((const char **)args + 1, &curproxy->acl, &errmsg, &curproxy->conf.args, file, linenum) == NULL) {
|
if (parse_acl((const char **)args + 1, &curproxy->acl, &errmsg, &curproxy->conf.args, file, linenum) == NULL) {
|
||||||
ha_alert("parsing [%s:%d] : error detected while parsing ACL '%s' : %s.\n",
|
ha_alert("parsing [%s:%d] : error detected while parsing ACL '%s' : %s.\n",
|
||||||
file, linenum, args[1], errmsg);
|
file, linenum, args[1], errmsg);
|
||||||
|
@ -885,11 +885,20 @@ static int cfg_parse_fcgi_app(const char *file, int linenum, char **args, int kw
|
|||||||
ha_alert("parsing [%s:%d] : character '%c' is not permitted in acl name '%s'.\n",
|
ha_alert("parsing [%s:%d] : character '%c' is not permitted in acl name '%s'.\n",
|
||||||
file, linenum, *err, args[1]);
|
file, linenum, *err, args[1]);
|
||||||
err_code |= ERR_ALERT | ERR_FATAL;
|
err_code |= ERR_ALERT | ERR_FATAL;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
else if (parse_acl((const char **)args+1, &curapp->acls, &errmsg, &curapp->conf.args, file, linenum) == NULL) {
|
if (strcasecmp(args[1], "or") == 0) {
|
||||||
|
ha_warning("parsing [%s:%d] : acl name '%s' will never match. 'or' is used to express a "
|
||||||
|
"logical disjunction within a condition.\n",
|
||||||
|
file, linenum, args[1]);
|
||||||
|
err_code |= ERR_ALERT | ERR_FATAL;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
if (parse_acl((const char **)args+1, &curapp->acls, &errmsg, &curapp->conf.args, file, linenum) == NULL) {
|
||||||
ha_alert("parsing [%s:%d] : error detected while parsing ACL '%s' : %s.\n",
|
ha_alert("parsing [%s:%d] : error detected while parsing ACL '%s' : %s.\n",
|
||||||
file, linenum, args[1], errmsg);
|
file, linenum, args[1], errmsg);
|
||||||
err_code |= ERR_ALERT | ERR_FATAL;
|
err_code |= ERR_ALERT | ERR_FATAL;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!strcmp(args[0], "set-param")) {
|
else if (!strcmp(args[0], "set-param")) {
|
||||||
|
@ -3991,6 +3991,13 @@ cfg_parse_spoe_message(const char *file, int linenum, char **args, int kwm)
|
|||||||
err_code |= ERR_ALERT | ERR_FATAL;
|
err_code |= ERR_ALERT | ERR_FATAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
if (strcasecmp(args[1], "or") == 0) {
|
||||||
|
ha_warning("parsing [%s:%d] : acl name '%s' will never match. 'or' is used to express a "
|
||||||
|
"logical disjunction within a condition.\n",
|
||||||
|
file, linenum, args[1]);
|
||||||
|
err_code |= ERR_ALERT | ERR_FATAL;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
if (parse_acl((const char **)args + 1, &curmsg->acls, &errmsg, &curproxy->conf.args, file, linenum) == NULL) {
|
if (parse_acl((const char **)args + 1, &curmsg->acls, &errmsg, &curproxy->conf.args, file, linenum) == NULL) {
|
||||||
ha_alert("parsing [%s:%d] : error detected while parsing ACL '%s' : %s.\n",
|
ha_alert("parsing [%s:%d] : error detected while parsing ACL '%s' : %s.\n",
|
||||||
file, linenum, args[1], errmsg);
|
file, linenum, args[1], errmsg);
|
||||||
|
Loading…
Reference in New Issue
Block a user