#include "acl/RegexData.h"
#include "acl/UserData.h"
#include "client_side.h"
+#include "comm/Connection.h"
+#include "globals.h"
#include "ident/AclIdent.h"
#include "ident/Ident.h"
ACLFilledChecklist *checklist = Filled(cl);
if (checklist->rfc931[0]) {
return data->match(checklist->rfc931);
- } else if (checklist->conn() != NULL && checklist->conn()->rfc931[0]) {
- return data->match(checklist->conn()->rfc931);
- } else {
+ } else if (checklist->conn() != NULL && checklist->conn()->clientConnection != NULL && checklist->conn()->clientConnection->rfc931[0]) {
+ return data->match(checklist->conn()->clientConnection->rfc931);
+ } else if (checklist->conn() != NULL && Comm::IsConnOpen(checklist->conn()->clientConnection)) {
debugs(28, 3, HERE << "switching to ident lookup state");
checklist->changeState(IdentLookup::Instance());
return 0;
+ } else {
+ debugs(28, DBG_IMPORTANT, HERE << "Can't start ident lookup. No client connection" );
+ checklist->markFinished(ACCESS_DUNNO, "cannot start ident lookup");
+ return -1;
}
}
return new ACLIdent(*this);
}
-
IdentLookup IdentLookup::instance_;
IdentLookup *
IdentLookup::checkForAsync(ACLChecklist *cl)const
{
ACLFilledChecklist *checklist = Filled(cl);
- if (checklist->conn() != NULL) {
- debugs(28, 3, HERE << "Doing ident lookup" );
- checklist->asyncInProgress(true);
- // TODO: store a Comm::Connection in either checklist or ConnStateData one day.
- Comm::Connection cc; // IDENT will clone it's own copy for alterations.
- cc.local = checklist->conn()->me;
- cc.remote = checklist->conn()->peer;
- Ident::Start(&cc, LookupDone, checklist);
- } else {
- debugs(28, DBG_IMPORTANT, "IdentLookup::checkForAsync: Can't start ident lookup. No client connection" );
- checklist->currentAnswer(ACCESS_DENIED);
- checklist->markFinished();
- }
+ const ConnStateData *conn = checklist->conn();
+ // check that ACLIdent::match() tested this lookup precondition
+ assert(conn && Comm::IsConnOpen(conn->clientConnection));
+ debugs(28, 3, HERE << "Doing ident lookup" );
+ checklist->asyncInProgress(true);
+ Ident::Start(checklist->conn()->clientConnection, LookupDone, checklist);
}
void
* Cache the ident result in the connection, to avoid redoing ident lookup
* over and over on persistent connections
*/
- if (checklist->conn() != NULL && !checklist->conn()->rfc931[0])
- xstrncpy(checklist->conn()->rfc931, checklist->rfc931, USER_IDENT_SZ);
+ if (checklist->conn() != NULL && checklist->conn()->clientConnection != NULL && !checklist->conn()->clientConnection->rfc931[0])
+ xstrncpy(checklist->conn()->clientConnection->rfc931, checklist->rfc931, USER_IDENT_SZ);
checklist->asyncInProgress(false);
checklist->changeState(ACLChecklist::NullState::Instance());
- checklist->check();
+ checklist->matchNonBlocking();
}
#endif /* USE_IDENT */