From 9baae63d8d20067f97a7263e6317639e09fef800 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 11 Jan 2013 17:06:15 +0100 Subject: [PATCH] MAJOR: acl: remove fetch argument validation from the ACL struct ACL fetch being inherited from the sample fetch keyword, we don't need anymore to specify what function to use to validate the fetch arguments. Note that the job is still done in the ACL parsing code based on elements from the sample fetch structs. --- include/types/acl.h | 1 - src/acl.c | 2 +- src/payload.c | 4 ++-- src/proto_http.c | 44 ++++++++++++++++++++++---------------------- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/include/types/acl.h b/include/types/acl.h index 3e62ae2d3..bb5ad0d64 100644 --- a/include/types/acl.h +++ b/include/types/acl.h @@ -237,7 +237,6 @@ struct acl_keyword { int (*parse)(const char **text, struct acl_pattern *pattern, int *opaque, char **err); int (*match)(struct sample *smp, struct acl_pattern *pattern); unsigned int requires; /* bit mask of all ACL_USE_* required to evaluate this keyword */ - int (*val_args)(struct arg *arg_p, char **err_msg); /* argument validation function */ /* must be after the config params */ struct sample_fetch *smp; /* the sample fetch we depend on */ int use_cnt; diff --git a/src/acl.c b/src/acl.c index a996c634e..2e23e30c3 100644 --- a/src/acl.c +++ b/src/acl.c @@ -1052,7 +1052,7 @@ struct acl_expr *parse_acl_expr(const char **args, char **err) if (!expr->args) expr->args = empty_arg_list; - if (aclkw->val_args && !aclkw->val_args(expr->args, err)) { + if (aclkw->smp->val_args && !aclkw->smp->val_args(expr->args, err)) { /* invalid keyword argument, error must have been * set by val_args(). */ diff --git a/src/payload.c b/src/payload.c index 34b21eddd..25145cd0a 100644 --- a/src/payload.c +++ b/src/payload.c @@ -669,8 +669,8 @@ static struct sample_fetch_kw_list smp_kws = {{ },{ * Please take care of keeping this list alphabetically sorted. */ static struct acl_kw_list acl_kws = {{ },{ - { "payload", NULL, acl_parse_str, acl_match_str, ACL_USE_L6REQ_VOLATILE, val_payload }, - { "payload_lv", NULL, acl_parse_str, acl_match_str, ACL_USE_L6REQ_VOLATILE, val_payload_lv }, + { "payload", NULL, acl_parse_str, acl_match_str, ACL_USE_L6REQ_VOLATILE }, + { "payload_lv", NULL, acl_parse_str, acl_match_str, ACL_USE_L6REQ_VOLATILE }, { "rep_ssl_hello_type", NULL, acl_parse_int, acl_match_int, ACL_USE_L6RTR_VOLATILE }, { "req_len", NULL, acl_parse_int, acl_match_int, ACL_USE_L6REQ_VOLATILE }, { "req_rdp_cookie", "rdp_cookie", acl_parse_str, acl_match_str, ACL_USE_L6REQ_VOLATILE }, diff --git a/src/proto_http.c b/src/proto_http.c index a835fdceb..020009a70 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -9542,17 +9542,17 @@ static struct acl_kw_list acl_kws = {{ },{ { "cook_sub", "cook", acl_parse_str, acl_match_sub, ACL_USE_L7REQ_VOLATILE }, { "cook_val", "cook_val", acl_parse_int, acl_match_int, ACL_USE_L7REQ_VOLATILE }, - { "hdr", "hdr", acl_parse_str, acl_match_str, ACL_USE_L7REQ_VOLATILE, val_hdr }, - { "hdr_beg", "hdr", acl_parse_str, acl_match_beg, ACL_USE_L7REQ_VOLATILE, val_hdr }, - { "hdr_cnt", "hdr_cnt", acl_parse_int, acl_match_int, ACL_USE_L7REQ_VOLATILE }, - { "hdr_dir", "hdr", acl_parse_str, acl_match_dir, ACL_USE_L7REQ_VOLATILE, val_hdr }, - { "hdr_dom", "hdr", acl_parse_str, acl_match_dom, ACL_USE_L7REQ_VOLATILE, val_hdr }, - { "hdr_end", "hdr", acl_parse_str, acl_match_end, ACL_USE_L7REQ_VOLATILE, val_hdr }, - { "hdr_ip", "hdr_ip", acl_parse_ip, acl_match_ip, ACL_USE_L7REQ_VOLATILE, val_hdr }, - { "hdr_len", "hdr", acl_parse_int, acl_match_len, ACL_USE_L7REQ_VOLATILE, val_hdr }, - { "hdr_reg", "hdr", acl_parse_reg, acl_match_reg, ACL_USE_L7REQ_VOLATILE, val_hdr }, - { "hdr_sub", "hdr", acl_parse_str, acl_match_sub, ACL_USE_L7REQ_VOLATILE, val_hdr }, - { "hdr_val", "hdr_val", acl_parse_int, acl_match_int, ACL_USE_L7REQ_VOLATILE, val_hdr }, + { "hdr", "hdr", acl_parse_str, acl_match_str, ACL_USE_L7REQ_VOLATILE }, + { "hdr_beg", "hdr", acl_parse_str, acl_match_beg, ACL_USE_L7REQ_VOLATILE }, + { "hdr_cnt", "hdr_cnt", acl_parse_int, acl_match_int, ACL_USE_L7REQ_VOLATILE }, + { "hdr_dir", "hdr", acl_parse_str, acl_match_dir, ACL_USE_L7REQ_VOLATILE }, + { "hdr_dom", "hdr", acl_parse_str, acl_match_dom, ACL_USE_L7REQ_VOLATILE }, + { "hdr_end", "hdr", acl_parse_str, acl_match_end, ACL_USE_L7REQ_VOLATILE }, + { "hdr_ip", "hdr_ip", acl_parse_ip, acl_match_ip, ACL_USE_L7REQ_VOLATILE }, + { "hdr_len", "hdr", acl_parse_int, acl_match_len, ACL_USE_L7REQ_VOLATILE }, + { "hdr_reg", "hdr", acl_parse_reg, acl_match_reg, ACL_USE_L7REQ_VOLATILE }, + { "hdr_sub", "hdr", acl_parse_str, acl_match_sub, ACL_USE_L7REQ_VOLATILE }, + { "hdr_val", "hdr_val", acl_parse_int, acl_match_int, ACL_USE_L7REQ_VOLATILE }, { "http_auth", NULL, acl_parse_nothing, acl_match_nothing, ACL_USE_L7REQ_VOLATILE }, { "http_auth_group", NULL, acl_parse_strcat, acl_match_auth, ACL_USE_L7REQ_VOLATILE }, @@ -9585,17 +9585,17 @@ static struct acl_kw_list acl_kws = {{ },{ { "scook_sub", "scook", acl_parse_str, acl_match_sub, ACL_USE_L7RTR_VOLATILE }, { "scook_val", "scook_val", acl_parse_int, acl_match_int, ACL_USE_L7RTR_VOLATILE }, - { "shdr", "shdr", acl_parse_str, acl_match_str, ACL_USE_L7RTR_VOLATILE, val_hdr }, - { "shdr_beg", "shdr", acl_parse_str, acl_match_beg, ACL_USE_L7RTR_VOLATILE, val_hdr }, - { "shdr_cnt", "shdr_cnt", acl_parse_int, acl_match_int, ACL_USE_L7RTR_VOLATILE }, - { "shdr_dir", "shdr", acl_parse_str, acl_match_dir, ACL_USE_L7RTR_VOLATILE, val_hdr }, - { "shdr_dom", "shdr", acl_parse_str, acl_match_dom, ACL_USE_L7RTR_VOLATILE, val_hdr }, - { "shdr_end", "shdr", acl_parse_str, acl_match_end, ACL_USE_L7RTR_VOLATILE, val_hdr }, - { "shdr_ip", "shdr_ip", acl_parse_ip, acl_match_ip, ACL_USE_L7RTR_VOLATILE, val_hdr }, - { "shdr_len", "shdr", acl_parse_int, acl_match_len, ACL_USE_L7RTR_VOLATILE, val_hdr }, - { "shdr_reg", "shdr", acl_parse_reg, acl_match_reg, ACL_USE_L7RTR_VOLATILE, val_hdr }, - { "shdr_sub", "shdr", acl_parse_str, acl_match_sub, ACL_USE_L7RTR_VOLATILE, val_hdr }, - { "shdr_val", "shdr_val", acl_parse_int, acl_match_int, ACL_USE_L7RTR_VOLATILE, val_hdr }, + { "shdr", "shdr", acl_parse_str, acl_match_str, ACL_USE_L7RTR_VOLATILE }, + { "shdr_beg", "shdr", acl_parse_str, acl_match_beg, ACL_USE_L7RTR_VOLATILE }, + { "shdr_cnt", "shdr_cnt", acl_parse_int, acl_match_int, ACL_USE_L7RTR_VOLATILE }, + { "shdr_dir", "shdr", acl_parse_str, acl_match_dir, ACL_USE_L7RTR_VOLATILE }, + { "shdr_dom", "shdr", acl_parse_str, acl_match_dom, ACL_USE_L7RTR_VOLATILE }, + { "shdr_end", "shdr", acl_parse_str, acl_match_end, ACL_USE_L7RTR_VOLATILE }, + { "shdr_ip", "shdr_ip", acl_parse_ip, acl_match_ip, ACL_USE_L7RTR_VOLATILE }, + { "shdr_len", "shdr", acl_parse_int, acl_match_len, ACL_USE_L7RTR_VOLATILE }, + { "shdr_reg", "shdr", acl_parse_reg, acl_match_reg, ACL_USE_L7RTR_VOLATILE }, + { "shdr_sub", "shdr", acl_parse_str, acl_match_sub, ACL_USE_L7RTR_VOLATILE }, + { "shdr_val", "shdr_val", acl_parse_int, acl_match_int, ACL_USE_L7RTR_VOLATILE }, { "status", NULL, acl_parse_int, acl_match_int, ACL_USE_L7RTR_PERMANENT },