]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] http-auth: make the 'unless' keyword work as expected
authorWilly Tarreau <w@1wt.eu>
Mon, 1 Feb 2010 09:40:19 +0000 (10:40 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 1 Feb 2010 09:40:19 +0000 (10:40 +0100)
One check was missing for the 'polarity' of the test. Now 'unless'
works. BTW, 'unless' provides a nice way to perform one-line auth :

    acl valid-user http_auth(user-list)
    http-request auth unless valid-user

src/proto_http.c

index 1b59c68f5f2f5f71a96b8c5e469e771a3fb2c473..692bb9f10926ee374c669655c962085783ebf806 100644 (file)
@@ -2862,8 +2862,13 @@ int http_process_req_common(struct session *s, struct buffer *req, int an_bit, s
                        continue;
 
                /* check condition, but only if attached */
-               if (req_acl->cond)
-                       ret = acl_exec_cond(req_acl->cond, px, s, txn, ACL_DIR_REQ);
+               if (!req_acl->cond)
+                       continue;
+
+               ret = acl_exec_cond(req_acl->cond, px, s, txn, ACL_DIR_REQ);
+               ret = acl_pass(ret);
+               if (req_acl->cond->pol == ACL_COND_UNLESS)
+                       ret = !ret;
 
                if (ret) {
                        req_acl_final = req_acl;