]> git.ipfire.org Git - thirdparty/squid.git/commit - src/acl/Gadgets.cc
Acess Control API cleanup
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 16 Jul 2011 15:21:48 +0000 (03:21 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 16 Jul 2011 15:21:48 +0000 (03:21 +1200)
commit2efeb0b7697c0d38f9e79f25510ffe411db864f9
tree32627c91702452f0fef9ca92ddaffea37a23b9c1
parent92b77cf7c6c513d9d19ee8d9bd1d4f963a479c44
Acess Control API cleanup

In summary:
 * use nonBlockingCheck() or fastCheck() to test ACLs.
 * be prepared to handle any allow_t in the result.

ACL testing functions publicly available from ACLChecklist are:

 - nonBlockingCheck (public), fastCheck public), check (public but not to be used)
 - matchAclListFast (public), matchAclListSlow (private), matchAclList (private).

Given that there are only two types of test performed, this array of API
methods has been causing confusion and mistakes for some developers.

This patch seeks to clarify that API by correcting a flaw in the naming
of check() and matchAclListFast().

Due to "Fast" ACLs coming in two types there are two overloaded
fastCheck() functions. Now with identical output behaviour. Both return
the allow_t result of the lookup. This is expected to _usually_ be
ACCESS_ALLOWED / ACCESS_DENIED but that is not always the case.
Callers need to be written with consideration that the set of enum
results may change.

 - fastCheck(), no parameters, when a full set of "Fast" *_access lines
   are to be scanned. The checklist constructor accepts the list to be
   scanned. This is the old fastCheck(), with the new ALLOWED / DENIED
   / DUNNO result.

 - fastCheck(list), one parameter, when a single-line set of ACLs is to
   be scanned. This is the old matchAclListFast(), with the new ALLOWED
   / DENIED / DUNNO result. Will return ALLOWED whenever the whole set
   of ACLs matches. Other results may vary.

 - nonBlockingCheck() - for "Slow" non-blocking lookups with asynchronous
   callback handler. NP: not touched by this patch.

The output change from boolean to allow_t is due to the fastCheck()
callers mixed set of needs allow/deny/other which boolean cannot meet.
Mapping that tri-state need to a boolean result has led to inconsistent
cases of fastCheck() producing unusual values for "true". Sometimes
wrongly for the caller.

Added result lookup type ACCESS_DUNNO, to indicate a test was unable to
be completed BUT there was no allow/deny/auth-required resulting.

Alters all previous calling code to use the new fastCheck() API output.
Some have been polished up to boolean where appropriate instead of
relying on integer values.

Removes matchAclListFast/matchAclListSlow,
Renames check() to matchNonBlocking;
   all match*() functions are internal operations during ACL testing.
36 files changed:
src/ClientRequestContext.h
src/CommCalls.cc
src/DelayId.cc
src/HttpHeaderTools.cc
src/HttpReply.cc
src/HttpRequest.cc
src/ICP.h
src/PeerSelectState.h
src/acl/Acl.h
src/acl/Checklist.cc
src/acl/Checklist.h
src/acl/DestinationDomain.cc
src/acl/DestinationIp.cc
src/acl/Gadgets.cc
src/acl/SourceDomain.cc
src/adaptation/AccessCheck.cc
src/adaptation/AccessCheck.h
src/adaptation/icap/Launcher.cc
src/adaptation/icap/Xaction.cc
src/auth/AclProxyAuth.cc
src/client_side.cc
src/client_side_reply.cc
src/client_side_reply.h
src/client_side_request.cc
src/external_acl.cc
src/forward.cc
src/htcp.cc
src/icp_v2.cc
src/ident/AclIdent.cc
src/log/access_log.cc
src/neighbors.cc
src/peer_select.cc
src/snmp_core.cc
src/ssl/support.cc
src/tests/stub_icp.cc
src/tunnel.cc