From: wessels <> Date: Fri, 8 Nov 1996 07:46:42 +0000 (+0000) Subject: make sure ident lookups finish before checking ACLs X-Git-Tag: SQUID_3_0_PRE1~5499 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba1d2afa02564be3748a9cfe3f894402766212c2;p=thirdparty%2Fsquid.git make sure ident lookups finish before checking ACLs --- diff --git a/src/client_side.cc b/src/client_side.cc index 84cf2e827b..f2db2094a5 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.60 1996/11/06 23:14:24 wessels Exp $ + * $Id: client_side.cc,v 1.61 1996/11/08 00:46:42 wessels Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -66,14 +66,13 @@ clientLookupSrcFQDNDone(int fd, const char *fqdn, void *data) clientAccessCheck(icpState, icpState->aclHandler); } -#ifdef UNUSED_CODE static void clientLookupIdentDone(void *data) { + icpStateData *icpState = data; + clientAccessCheck(icpState, icpState->aclHandler); } -#endif - #if USE_PROXY_AUTH /* return 1 if allowed, 0 if denied */ static int @@ -109,6 +108,10 @@ clientAccessCheck(icpStateData * icpState, void (*handler) (icpStateData *, int) aclCheck_t *ch = NULL; char *browser = NULL; + if (Config.identLookup && icpState->ident.state == IDENT_NONE) { + identStart(-1, icpState, clientLookupIdentDone); + return; + } if (icpState->aclChecklist == NULL) { icpState->aclChecklist = xcalloc(1, sizeof(aclCheck_t)); icpState->aclChecklist->src_addr = icpState->peer.sin_addr; diff --git a/src/ident.cc b/src/ident.cc index 53f4f4d0e9..163455f586 100644 --- a/src/ident.cc +++ b/src/ident.cc @@ -1,5 +1,5 @@ /* - * $Id: ident.cc,v 1.20 1996/11/06 23:14:43 wessels Exp $ + * $Id: ident.cc,v 1.21 1996/11/08 00:46:45 wessels Exp $ * * DEBUG: section 30 Ident (RFC 931) * AUTHOR: Duane Wessels @@ -36,17 +36,20 @@ static void identRequestComplete _PARAMS((int, char *, int, int, void *)); static void identReadReply _PARAMS((int, icpStateData *)); static void identClose _PARAMS((int, icpStateData *)); static void identConnectDone _PARAMS((int fd, int status, void *data)); +static void identCallback _PARAMS((icpStateData *icpState)); static void identClose(int fd, icpStateData * icpState) { - icpState->ident_fd = -1; + icpState->ident.fd = -1; } /* start a TCP connection to the peer host on port 113 */ void -identStart(int fd, icpStateData * icpState) +identStart(int fd, icpStateData * icpState, void (*callback) _PARAMS((void *))) { + icpState->ident.callback = callback; + icpState->ident.state = IDENT_PENDING; if (fd < 0) { fd = comm_open(SOCK_STREAM, 0, @@ -54,10 +57,12 @@ identStart(int fd, icpStateData * icpState) 0, COMM_NONBLOCKING, "ident"); - if (fd == COMM_ERROR) + if (fd == COMM_ERROR) { + identCallback(icpState); return; + } } - icpState->ident_fd = fd; + icpState->ident.fd = fd; comm_add_close_handler(fd, (PF) identClose, (void *) icpState); @@ -76,7 +81,8 @@ identConnectDone(int fd, int status, void *data) LOCAL_ARRAY(char, reqbuf, BUFSIZ); if (status == COMM_ERROR) { comm_close(fd); - return; /* die silently */ + identCallback(icpState); + return; } sprintf(reqbuf, "%d, %d\r\n", ntohs(icpState->peer.sin_port), @@ -118,9 +124,18 @@ identReadReply(int fd, icpStateData * icpState) if (strstr(buf, "USERID")) { if ((t = strrchr(buf, ':'))) { while (isspace(*++t)); - strncpy(icpState->ident, t, ICP_IDENT_SZ); + strncpy(icpState->ident.ident, t, ICP_IDENT_SZ); } } } comm_close(fd); + identCallback(icpState); +} + +static void +identCallback(icpStateData * icpState) +{ + icpState->ident.state = IDENT_DONE; + if (icpState->ident.callback) + icpState->ident.callback(icpState); } diff --git a/src/redirect.cc b/src/redirect.cc index f39df754e9..550c76003e 100644 --- a/src/redirect.cc +++ b/src/redirect.cc @@ -1,5 +1,5 @@ /* - * $Id: redirect.cc,v 1.28 1996/11/06 23:14:52 wessels Exp $ + * $Id: redirect.cc,v 1.29 1996/11/08 00:46:46 wessels Exp $ * * DEBUG: section 29 Redirector * AUTHOR: Duane Wessels @@ -320,10 +320,10 @@ redirectStart(int cfd, icpStateData * icpState, RH handler, void *data) r->fd = cfd; r->orig_url = icpState->url; r->client_addr = icpState->log_addr; - if (icpState->ident == NULL || *icpState->ident == '\0') { + if (icpState->ident.ident == NULL || *icpState->ident.ident == '\0') { r->client_ident = dash_str; } else { - r->client_ident = icpState->ident; + r->client_ident = icpState->ident.ident; } r->method_s = RequestMethodStr[icpState->request->method]; r->handler = handler; diff --git a/src/squid.h b/src/squid.h index 6a1af1ec8d..76822da38e 100644 --- a/src/squid.h +++ b/src/squid.h @@ -1,6 +1,6 @@ /* - * $Id: squid.h,v 1.72 1996/11/08 00:02:22 wessels Exp $ + * $Id: squid.h,v 1.73 1996/11/08 00:46:46 wessels Exp $ * * AUTHOR: Duane Wessels * @@ -314,13 +314,14 @@ extern const char *storeToString _PARAMS((const StoreEntry *)); extern void timestampsSet _PARAMS((StoreEntry *)); extern int waisStart _PARAMS((int, const char *, method_t, char *, StoreEntry *)); extern void storeDirClean _PARAMS((void)); -int -passStart _PARAMS((int fd, +extern int passStart _PARAMS((int fd, const char *url, request_t * request, char *buf, int buflen, int *size_ptr)); +extern void identStart _PARAMS((int, icpStateData *, + void (*callback) _PARAMS((void *)))); extern const char *const dash_str; extern const char *const null_string;