mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-27 16:11:03 +00:00
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.
This commit is contained in:
parent
f853c46bc3
commit
197e10aaae
@ -56,11 +56,6 @@ enum {
|
||||
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 */
|
||||
|
||||
};
|
||||
|
10
src/acl.c
10
src/acl.c
@ -69,7 +69,7 @@ acl_fetch_true(struct proxy *px, struct session *l4, void *l7, int dir,
|
||||
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 @@ acl_fetch_wait_end(struct proxy *px, struct session *l4, void *l7, int dir,
|
||||
return 0;
|
||||
}
|
||||
smp->type = SMP_T_BOOL;
|
||||
smp->flags |= SMP_F_SET_RES_PASS;
|
||||
smp->data.uint = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ acl_fetch_false(struct proxy *px, struct session *l4, void *l7, int dir,
|
||||
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 @@ int acl_exec_cond(struct acl_cond *cond, struct proxy *px, struct session *l4, v
|
||||
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;
|
||||
|
@ -1414,9 +1414,9 @@ acl_fetch_srv_is_up(struct proxy *px, struct session *l4, void *l7, int dir,
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -7562,7 +7562,7 @@ acl_prefetch_http(struct proxy *px, struct session *s, void *l7, int dir,
|
||||
|
||||
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 @@ acl_prefetch_http(struct proxy *px, struct session *s, void *l7, int dir,
|
||||
/* 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 @@ acl_prefetch_http(struct proxy *px, struct session *s, void *l7, int dir,
|
||||
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 @@ acl_fetch_proto_http(struct proxy *px, struct session *l4, void *l7, int dir,
|
||||
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 @@ acl_fetch_http_first_req(struct proxy *px, struct session *s, void *l7, int dir,
|
||||
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 @@ acl_fetch_http_auth(struct proxy *px, struct session *l4, void *l7, int dir,
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user