From: wessels <> Date: Thu, 13 Nov 1997 01:58:38 +0000 (+0000) Subject: Fixed proxy auth support X-Git-Tag: SQUID_3_0_PRE1~4550 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fc5d6f7f369a05e34b136894a258d81ae3c6ca3f;p=thirdparty%2Fsquid.git Fixed proxy auth support --- diff --git a/src/acl.cc b/src/acl.cc index 6e9ddd5cd6..cead898184 100644 --- a/src/acl.cc +++ b/src/acl.cc @@ -1,6 +1,6 @@ /* - * $Id: acl.cc,v 1.114 1997/11/12 00:08:44 wessels Exp $ + * $Id: acl.cc,v 1.115 1997/11/12 18:58:38 wessels Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -53,7 +53,7 @@ static int aclMatchDomainList(void *dataptr, const char *); static squid_acl aclType(const char *s); static int decode_addr(const char *, struct in_addr *, struct in_addr *); static void aclCheck(aclCheck_t * checklist); -static void aclCheckCallback(aclCheck_t * checklist, int answer); +static void aclCheckCallback(aclCheck_t * checklist, allow_t answer); static IPH aclLookupDstIPDone; static FQDNH aclLookupSrcFQDNDone; static FQDNH aclLookupDstFQDNDone; @@ -1073,7 +1073,6 @@ aclMatchProxyAuth(struct _acl_proxy_auth *p, aclCheck_t * checklist) return 0; } passwd = strtok(sent_user, null_string); - passwd++; /* See if we've already validated them */ passwd[0] |= 0x80; if (strcmp(hashr->item, passwd) == 0) { @@ -1124,8 +1123,7 @@ aclMatchTime(struct _acl_time_data *data, time_t when) static time_t last_when = 0; static struct tm tm; time_t t; - if (data == NULL) - fatal_dump("aclMatchTime: NULL data"); + assert(data != NULL); if (when != last_when) { last_when = when; xmemcpy(&tm, localtime(&when), sizeof(struct tm)); @@ -1275,7 +1273,7 @@ aclCheckFast(const struct _acl_access *A, aclCheck_t * checklist) static void aclCheck(aclCheck_t * checklist) { - int allow = 0; + allow_t allow = ACCESS_DENIED; const struct _acl_access *A; int match; ipcache_addrs *ia; @@ -1309,6 +1307,10 @@ aclCheck(aclCheck_t * checklist) return; } if (match) { + /* hack! */ + if (allow == ACCESS_DENIED) + if (checklist->state[ACL_PROXY_AUTH] == ACL_LOOKUP_NEEDED) + allow = ACCESS_REQ_PROXY_AUTH; debug(28, 3) ("aclCheck: match found, returning %d\n", allow); aclCheckCallback(checklist, allow); return; @@ -1334,7 +1336,7 @@ aclChecklistFree(aclCheck_t * checklist) } static void -aclCheckCallback(aclCheck_t * checklist, int answer) +aclCheckCallback(aclCheck_t * checklist, allow_t answer) { debug(28, 3) ("aclCheckCallback: answer=%d\n", answer); if (cbdataValid(checklist->callback_data)) @@ -1523,7 +1525,7 @@ aclDestroyAcls(acl ** head) break; case ACL_NONE: default: - fatal_dump("aclDestroyAcls: Found ACL_NONE?"); + assert(0); break; } safe_free(a->cfgline); diff --git a/src/client_side.cc b/src/client_side.cc index b140bc75e1..7b977f174b 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.144 1997/11/12 00:08:45 wessels Exp $ + * $Id: client_side.cc,v 1.145 1997/11/12 18:58:39 wessels Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -32,6 +32,8 @@ #include "squid.h" static const char *const crlf = "\r\n"; +static const char *const proxy_auth_line = +"Proxy-Authenticate: Basic realm=\"Squid proxy-caching web server\"\r\n"; #define REQUEST_BUF_SIZE 4096 #define FAILURE_MODE_TIME 300 @@ -39,6 +41,8 @@ static const char *const crlf = "\r\n"; /* Local functions */ static CWCB icpHandleIMSComplete; +static CWCB clientWriteComplete; +static CWCB clientShortWriteComplete; static PF clientReadRequest; static PF connStateFree; static PF requestTimeout; @@ -61,6 +65,7 @@ static STCB clientSendMoreData; static STCB clientCacheHit; static void icpParseRequestHeaders(clientHttpRequest *); static void icpProcessRequest(int, clientHttpRequest *); +static char *clientConstructProxyAuthReply(clientHttpRequest * http); @@ -103,6 +108,55 @@ clientAccessCheck(void *data) aclNBCheck(http->acl_checklist, clientAccessCheckDone, http); } +static char * +clientConstructProxyAuthReply(clientHttpRequest * http) +{ + LOCAL_ARRAY(char, buf, 8192); + LOCAL_ARRAY(char, content, 4096); + char *hdr; + memset(buf, '\0', 8192); + memset(content, '\0', 4096); + snprintf(content, 4096, + "
\n" + "Sorry, you are not currently allowed to request:\n" + "
%s\n" + "from this cache until you have authenticated yourself.\n" + "\n
" + "You need to use Netscape version 2.0 or greater, or Microsoft\n" + "Internet Explorer 3.0 or an HTTP/1.1 compliant browser for this\n" + "to work. Please contact the cache\n" + "administrator if you have difficulties authenticating\n" + "yourself, or\n" + "change your\n" + "default password.\n" + "
\n" + "%s\n" + "