]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
make sure ident lookups finish before checking ACLs
authorwessels <>
Fri, 8 Nov 1996 07:46:42 +0000 (07:46 +0000)
committerwessels <>
Fri, 8 Nov 1996 07:46:42 +0000 (07:46 +0000)
src/client_side.cc
src/ident.cc
src/redirect.cc
src/squid.h

index 84cf2e827b9ed30155cd60bf74aceb18fbe20755..f2db2094a5bbf19e5c451e86e412dcee44a0d83f 100644 (file)
@@ -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;
index 53f4f4d0e92b865e9e8defb488b545d224168ccc..163455f5860be36c41678e86685dfa6834202d77 100644 (file)
@@ -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);
 }
index f39df754e9ef82deb8a161cb5c331a5bc87dfee0..550c76003e4e823202aae6519e3c6e088bd92a41 100644 (file)
@@ -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;
index 6a1af1ec8d596a3a887075fdb7bcd61f6237ce6b..76822da38ee5113a1c83204966207eb74bc7b382 100644 (file)
@@ -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;