From: wessels <> Date: Sat, 9 Dec 2000 06:58:08 +0000 (+0000) Subject: Patch from Marcos Barreto de Castro . Allows X-Git-Tag: SQUID_3_0_PRE1~1741 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=066ed5c15699b5e1c716f9cf1fa80ffb75eb7d42;p=thirdparty%2Fsquid.git Patch from Marcos Barreto de Castro . Allows auth process to send back a one-line message. If the ERR_ACCESS_DENIED page has %m, it gets replaced with this message. --- diff --git a/src/acl.cc b/src/acl.cc index de3eb7408c..648e13774b 100644 --- a/src/acl.cc +++ b/src/acl.cc @@ -1,6 +1,6 @@ /* - * $Id: acl.cc,v 1.225 2000/10/31 23:48:13 wessels Exp $ + * $Id: acl.cc,v 1.226 2000/12/08 23:58:08 wessels Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -1770,10 +1770,15 @@ aclLookupProxyAuthDone(void *data, char *result) checklist->state[ACL_PROXY_AUTH] = ACL_LOOKUP_DONE; debug(28, 4) ("aclLookupProxyAuthDone: result = %s\n", result ? result : "NULL"); - if (result && (strncasecmp(result, "OK", 2) == 0)) + if (NULL == result) + checklist->auth_user->passwd_ok = 0; + else if (0 == strncasecmp(result, "OK", 2)) checklist->auth_user->passwd_ok = 1; - else + else { + if (strlen(result) > sizeof("ERR ")) + checklist->auth_user->message = xstrdup(result+4); checklist->auth_user->passwd_ok = 0; + } aclCheck(checklist); } diff --git a/src/client_side.cc b/src/client_side.cc index e510c741ef..199f34d669 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.514 2000/12/05 09:15:58 wessels Exp $ + * $Id: client_side.cc,v 1.515 2000/12/08 23:58:08 wessels Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -215,10 +215,13 @@ clientAccessCheckDone(int answer, void *data) int page_id = -1; http_status status; ErrorState *err = NULL; + char *proxy_auth_msg = NULL; debug(33, 2) ("The request %s %s is %s, because it matched '%s'\n", RequestMethodStr[http->request->method], http->uri, answer == ACCESS_ALLOWED ? "ALLOWED" : "DENIED", AclMatchedName ? AclMatchedName : "NO ACL's"); + if (http->acl_checklist->auth_user) + proxy_auth_msg = http->acl_checklist->auth_user->message; http->acl_checklist = NULL; if (answer == ACCESS_ALLOWED) { safe_free(http->uri); @@ -230,6 +233,8 @@ clientAccessCheckDone(int answer, void *data) debug(33, 5) ("Access Denied: %s\n", http->uri); debug(33, 5) ("AclMatchedName = %s\n", AclMatchedName ? AclMatchedName : ""); + debug(33, 5) ("Proxy Auth Message = %s\n", + proxy_auth_msg ? proxy_auth_msg : ""); /* * NOTE: get page_id here, based on AclMatchedName because * if USE_DELAY_POOLS is enabled, then AclMatchedName gets @@ -258,6 +263,8 @@ clientAccessCheckDone(int answer, void *data) err = errorCon(page_id, status); err->request = requestLink(http->request); err->src_addr = http->conn->peer.sin_addr; + err->proxy_auth_msg = proxy_auth_msg; + err->callback_data = NULL; errorAppendEntry(http->entry, err); } } diff --git a/src/errorpage.cc b/src/errorpage.cc index 3b04c5ddfd..763ef0c92a 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -1,6 +1,6 @@ /* - * $Id: errorpage.cc,v 1.157 2000/12/05 09:15:59 wessels Exp $ + * $Id: errorpage.cc,v 1.158 2000/12/08 23:58:08 wessels Exp $ * * DEBUG: section 4 Error Generation * AUTHOR: Duane Wessels @@ -377,6 +377,7 @@ errorStateFree(ErrorState * err) safe_free(err->url); safe_free(err->host); safe_free(err->dnsserver_msg); + safe_free(err->proxy_auth_msg); safe_free(err->request_hdrs); wordlistDestroy(&err->ftp.server_msg); safe_free(err->ftp.request); @@ -404,6 +405,7 @@ errorStateFree(ErrorState * err) * I - server IP address x * L - HREF link for more info/contact x * M - Request Method x + * m - Error message returned by external Auth. x * p - URL port # x * P - Protocol x * R - Full HTTP Request x @@ -483,6 +485,9 @@ errorConvert(char token, ErrorState * err) } else p = "[not available]"; break; + case 'm': + p = err->proxy_auth_msg ? err->proxy_auth_msg : "[not available]"; + break; case 'M': p = r ? RequestMethodStr[r->method] : "[unkown method]"; break; diff --git a/src/structs.h b/src/structs.h index 05b8fe4165..f89cc6d799 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.364 2000/12/05 10:10:59 wessels Exp $ + * $Id: structs.h,v 1.365 2000/12/08 23:58:09 wessels Exp $ * * * SQUID Internet Object Cache http://squid.nlanr.net/Squid/ @@ -69,6 +69,7 @@ struct _acl_proxy_auth_user { long expiretime; struct in_addr ipaddr; /* IP addr this user authenticated from */ time_t ip_expiretime; + char *message; }; struct _acl_deny_info_list { @@ -1507,6 +1508,7 @@ struct _ErrorState { char *host; u_short port; char *dnsserver_msg; + char *proxy_auth_msg; time_t ttl; struct in_addr src_addr; char *redirect_url;