MEDIUM: acl: get rid of the SET_RES flags
We now simply rely on a boolean result from a fetch to declare a match.
Booleans are not compared against patterns, they fix the result.
diff --git a/include/types/pattern.h b/include/types/pattern.h
index c379595..8fcc5d8 100644
--- a/include/types/pattern.h
+++ b/include/types/pattern.h
@@ -56,11 +56,6 @@
SMP_F_VOLATILE = (1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6), /* any volatility condition */
SMP_F_READ_ONLY = 1 << 7, /* returned data must not be altered */
- SMP_F_RES_SET = 1 << 8, /* migration: ACL match must reflect the RES_PASS flag */
- SMP_F_RES_PASS = 1 << 9, /* migration: returned data is a TRUE boolean */
- SMP_F_SET_RES_PASS = (SMP_F_RES_SET|SMP_F_RES_PASS), /* migration: force ACLs to PASS */
- SMP_F_SET_RES_FAIL = (SMP_F_RES_SET), /* migration: force ACLs to FAIL */
-
SMP_F_MUST_FREE = 1 << 10, /* migration: this sample must be freed ASAP */
};
diff --git a/src/acl.c b/src/acl.c
index 91a9754..9c4ce0c 100644
--- a/src/acl.c
+++ b/src/acl.c
@@ -69,7 +69,7 @@
struct acl_expr *expr, struct sample *smp)
{
smp->type = SMP_T_BOOL;
- smp->flags |= SMP_F_SET_RES_PASS;
+ smp->data.uint = 1;
return 1;
}
@@ -85,7 +85,7 @@
return 0;
}
smp->type = SMP_T_BOOL;
- smp->flags |= SMP_F_SET_RES_PASS;
+ smp->data.uint = 1;
return 1;
}
@@ -95,7 +95,7 @@
struct acl_expr *expr, struct sample *smp)
{
smp->type = SMP_T_BOOL;
- smp->flags |= SMP_F_SET_RES_FAIL;
+ smp->data.uint = 0;
return 1;
}
@@ -1870,8 +1870,8 @@
continue;
}
- if (smp.flags & SMP_F_RES_SET) {
- if (smp.flags & SMP_F_RES_PASS)
+ if (smp.type == SMP_T_BOOL) {
+ if (smp.data.uint)
acl_res |= ACL_PAT_PASS;
else
acl_res |= ACL_PAT_FAIL;
diff --git a/src/backend.c b/src/backend.c
index c60f3a3..4d0d86f 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -1414,9 +1414,9 @@
smp->type = SMP_T_BOOL;
if (!(srv->state & SRV_MAINTAIN) &&
(!(srv->state & SRV_CHECKED) || (srv->state & SRV_RUNNING)))
- smp->flags |= SMP_F_SET_RES_PASS;
+ smp->data.uint = 1;
else
- smp->flags |= SMP_F_SET_RES_FAIL;
+ smp->data.uint = 0;
return 1;
}
diff --git a/src/proto_http.c b/src/proto_http.c
index e9ae1b4..b6036d5 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -7562,7 +7562,7 @@
if (unlikely(txn->req.msg_state < HTTP_MSG_BODY)) {
if ((msg->msg_state == HTTP_MSG_ERROR) || (s->req->flags & BF_FULL)) {
- smp->flags |= SMP_F_SET_RES_FAIL;
+ smp->data.uint = 0;
return -1;
}
@@ -7573,7 +7573,7 @@
/* Still no valid request ? */
if (unlikely(msg->msg_state < HTTP_MSG_BODY)) {
if ((msg->msg_state == HTTP_MSG_ERROR) || (s->req->flags & BF_FULL)) {
- smp->flags |= SMP_F_SET_RES_FAIL;
+ smp->data.uint = 0;
return -1;
}
/* wait for final state */
@@ -7590,7 +7590,7 @@
s->flags |= SN_REDIRECTABLE;
if (unlikely(msg->sl.rq.v_l == 0) && !http_upgrade_v09_to_v10(txn)) {
- smp->flags |= SMP_F_SET_RES_FAIL;
+ smp->data.uint = 0;
return -1;
}
}
@@ -7982,7 +7982,7 @@
CHECK_HTTP_MESSAGE_FIRST();
smp->type = SMP_T_BOOL;
- smp->flags |= SMP_F_SET_RES_PASS;
+ smp->data.uint = 1;
return 1;
}
@@ -7995,11 +7995,7 @@
return 0;
smp->type = SMP_T_BOOL;
- if (s->txn.flags & TX_NOT_FIRST)
- smp->flags |= SMP_F_SET_RES_FAIL;
- else
- smp->flags |= SMP_F_SET_RES_PASS;
-
+ smp->data.uint = !(s->txn.flags & TX_NOT_FIRST);
return 1;
}
@@ -8018,11 +8014,7 @@
return 0;
smp->type = SMP_T_BOOL;
- if (check_user(expr->args->data.usr, 0, l4->txn.auth.user, l4->txn.auth.pass))
- smp->flags |= SMP_F_SET_RES_PASS;
- else
- smp->flags |= SMP_F_SET_RES_FAIL;
-
+ smp->data.uint = check_user(expr->args->data.usr, 0, l4->txn.auth.user, l4->txn.auth.pass);
return 1;
}