]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleanup: disconnect Authentication and URL-rewrite callback handlers
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 19 Jun 2012 23:16:13 +0000 (11:16 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 19 Jun 2012 23:16:13 +0000 (11:16 +1200)
The authentication handlers were for some reason using RH (rewrite helper)
callback typedef. But specifying it as a fatal error if the char*
parameter was used in auth.

Assign a new callback typedef AUTHCB for use by authentication callers.

This allows auth callers to use different parameters (none) and to avoid
possibly fatal mistakes when coding new auth modules.

14 files changed:
src/auth/AclProxyAuth.cc
src/auth/AclProxyAuth.h
src/auth/State.h
src/auth/UserRequest.cc
src/auth/UserRequest.h
src/auth/basic/UserRequest.cc
src/auth/basic/UserRequest.h
src/auth/basic/auth_basic.h
src/auth/digest/UserRequest.cc
src/auth/digest/UserRequest.h
src/auth/negotiate/UserRequest.cc
src/auth/negotiate/UserRequest.h
src/auth/ntlm/UserRequest.cc
src/auth/ntlm/UserRequest.h

index f2c48f95c0e35b270f9da1477d298606340a46f0..69f29ede46d0e329cccdeb17db06b6c3f68846ce 100644 (file)
@@ -152,15 +152,12 @@ ProxyAuthLookup::checkForAsync(ACLChecklist *cl)const
 }
 
 void
-ProxyAuthLookup::LookupDone(void *data, char *result)
+ProxyAuthLookup::LookupDone(void *data)
 {
     ACLFilledChecklist *checklist = Filled(static_cast<ACLChecklist*>(data));
 
     assert (checklist->asyncState() == ProxyAuthLookup::Instance());
 
-    if (result != NULL)
-        fatal("AclLookupProxyAuthDone: Old code floating around somewhere.\nMake clean and if that doesn't work, report a bug to the squid developers.\n");
-
     if (checklist->auth_user_request == NULL || !checklist->auth_user_request->valid() || checklist->conn() == NULL) {
         /* credentials could not be checked either way
          * restart the whole process */
index 5d0503d710033d6e86d37e7b83c2517ae512c373..4be089198e73699d07c85e3cc82ebd01827cfde8 100644 (file)
@@ -50,7 +50,7 @@ public:
 
 private:
     static ProxyAuthLookup instance_;
-    static void LookupDone(void *data, char *result);
+    static void LookupDone(void *data);
 };
 
 class ACLProxyAuth : public ACL
index c3c215841f3c10aea394e7413db811c59aa84235..5722f2ad09381a84ff39b07d6531b438157777da 100644 (file)
@@ -15,7 +15,7 @@ namespace Auth
 class StateData
 {
 public:
-    StateData(const UserRequest::Pointer &r, RH *h, void *d) :
+    StateData(const UserRequest::Pointer &r, AUTHCB *h, void *d) :
             data(cbdataReference(d)),
             auth_user_request(r),
             handler(h) {}
@@ -27,7 +27,7 @@ public:
 
     void *data;
     UserRequest::Pointer auth_user_request;
-    RH *handler;
+    AUTHCB *handler;
 
 private:
     CBDATA_CLASS2(StateData);
index 7ba7ebaf5d0b94892648b9401cc5813cce6a0b35..198790efccd6b956e28f06a680a96692657b78d8 100644 (file)
@@ -63,7 +63,7 @@ Auth::UserRequest::username() const
 
 /* send the initial data to an authenticator module */
 void
-Auth::UserRequest::start(RH * handler, void *data)
+Auth::UserRequest::start(AUTHCB * handler, void *data)
 {
     assert(handler);
     assert(data);
index b420cbaffddfa33fd4c959afe3390c23cc8dbc18..808324c63ee563992302fb1990a64f5faf6f52ab 100644 (file)
@@ -66,6 +66,9 @@ public:
     time_t ip_expiretime;
 };
 
+// TODO: make auth schedule AsyncCalls?
+typedef void AUTHCB(void*);
+
 namespace Auth
 {
 
@@ -156,7 +159,7 @@ public:
      * \param handler  Handler to process the callback when its run
      * \param data     CBDATA for handler
      */
-    virtual void module_start(RH *handler, void *data) = 0;
+    virtual void module_start(AUTHCB *handler, void *data) = 0;
 
     // User credentials object this UserRequest is managing
     virtual User::Pointer user() {return _auth_user;}
@@ -186,7 +189,7 @@ public:
     /// Add the appropriate [Proxy-]Authenticate header to the given reply
     static void addReplyAuthHeader(HttpReply * rep, UserRequest::Pointer auth_user_request, HttpRequest * request, int accelerated, int internal);
 
-    void start( RH * handler, void *data);
+    void start(AUTHCB *handler, void *data);
     char const * denyMessage(char const * const default_message = NULL);
 
     /** Possibly overrideable in future */
index 0efa5adb5cc1067044be78862930a394ce057f34..fc07a5d6ac76b706bbb08cfb29fa3d2272fdc256 100644 (file)
@@ -77,7 +77,7 @@ Auth::Basic::UserRequest::module_direction()
 
 /* send the initial data to a basic authenticator module */
 void
-Auth::Basic::UserRequest::module_start(RH * handler, void *data)
+Auth::Basic::UserRequest::module_start(AUTHCB * handler, void *data)
 {
     assert(user()->auth_type == Auth::AUTH_BASIC);
     Auth::Basic::User *basic_auth = dynamic_cast<Auth::Basic::User *>(user().getRaw());
@@ -86,7 +86,7 @@ Auth::Basic::UserRequest::module_start(RH * handler, void *data)
 
     if (static_cast<Auth::Basic::Config*>(Auth::Config::Find("basic"))->authenticateProgram == NULL) {
         debugs(29, DBG_CRITICAL, "ERROR: No Basic authentication program configured.");
-        handler(data, NULL);
+        handler(data);
         return;
     }
 
@@ -124,10 +124,10 @@ Auth::Basic::UserRequest::module_start(RH * handler, void *data)
     int sz = snprintf(buf, sizeof(buf), "%s %s\n", username, pass);
     if (sz<=0) {
         debugs(9, DBG_CRITICAL, "ERROR: Basic Authentication Failure. Can not build helper validation request.");
-        handler(data, NULL);
+        handler(data);
     } else if (static_cast<size_t>(sz) >= sizeof(buf)) {
         debugs(9, DBG_CRITICAL, "ERROR: Basic Authentication Failure. user:password exceeds " << sizeof(buf) << " bytes.");
-        handler(data, NULL);
+        handler(data);
     } else
         helperSubmit(basicauthenticators, buf, Auth::Basic::UserRequest::HandleReply,
                      new Auth::StateData(this, handler, data));
@@ -171,7 +171,7 @@ Auth::Basic::UserRequest::HandleReply(void *data, char *reply)
     basic_auth->expiretime = squid_curtime;
 
     if (cbdataReferenceValidDone(r->data, &cbdata))
-        r->handler(cbdata, NULL);
+        r->handler(cbdata);
 
     cbdataReferenceDone(r->data);
 
@@ -179,7 +179,7 @@ Auth::Basic::UserRequest::HandleReply(void *data, char *reply)
         tmpnode = basic_auth->auth_queue->next;
 
         if (cbdataReferenceValidDone(basic_auth->auth_queue->data, &cbdata))
-            basic_auth->auth_queue->handler(cbdata, NULL);
+            basic_auth->auth_queue->handler(cbdata);
 
         xfree(basic_auth->auth_queue);
 
index febe4453adb89bbf248d5b8efde08348150754b1..304e8cf9df1844b7c03be5c19b3ca41223a16718 100644 (file)
@@ -26,7 +26,7 @@ public:
     virtual int authenticated() const;
     virtual void authenticate(HttpRequest * request, ConnStateData *conn, http_hdr_type type);
     virtual Auth::Direction module_direction();
-    virtual void module_start(RH *, void *);
+    virtual void module_start(AUTHCB *, void *);
 
 private:
     static HLPCB HandleReply;
index 405002a0b7156e207b00af832370e340ca7e1d35..e519fab8da91b3d02e6990912705ba1c11c52d58 100644 (file)
@@ -20,7 +20,7 @@ class BasicAuthQueueNode
 public:
     BasicAuthQueueNode *next;
     Auth::UserRequest::Pointer auth_user_request;
-    RH *handler;
+    AUTHCB *handler;
     void *data;
 };
 
index ef76ff49b01973612699d374d133cbd2102e05b4..92972fdf0ccf77d27c551db25e6a1bdf266a2e50 100644 (file)
@@ -245,7 +245,7 @@ Auth::Digest::UserRequest::addAuthenticationInfoTrailer(HttpReply * rep, int acc
 
 /* send the initial data to a digest authenticator module */
 void
-Auth::Digest::UserRequest::module_start(RH * handler, void *data)
+Auth::Digest::UserRequest::module_start(AUTHCB * handler, void *data)
 {
     char buf[8192];
 
@@ -254,7 +254,7 @@ Auth::Digest::UserRequest::module_start(RH * handler, void *data)
 
     if (static_cast<Auth::Digest::Config*>(Auth::Config::Find("digest"))->authenticateProgram == NULL) {
         debugs(29, DBG_CRITICAL, "ERROR: No Digest authentication program configured.");
-        handler(data, NULL);
+        handler(data);
         return;
     }
 
@@ -309,7 +309,7 @@ Auth::Digest::UserRequest::HandleReply(void *data, char *reply)
     }
 
     if (cbdataReferenceValidDone(replyData->data, &cbdata))
-        replyData->handler(cbdata, NULL);
+        replyData->handler(cbdata);
 
     delete replyData;
 }
index af2d7fc8d4042c01c63969b864b06b4ef3f1458c..011be30dab5044510d09d2a9c677f26eb92b9c26 100644 (file)
@@ -34,7 +34,7 @@ public:
     virtual void addAuthenticationInfoTrailer(HttpReply * rep, int accel);
 #endif
 
-    virtual void module_start(RH *, void *);
+    virtual void module_start(AUTHCB *, void *);
 
     char *nonceb64;             /* "dcd98b7102dd2f0e8b11d0f600bfb0c093" */
     char *cnonce;               /* "0a4f113b" */
index f0712d66febe7d4e4f371315dccadddfe56fe124..e0fa1964b9b89f03fd292ca4135f3f9317679026 100644 (file)
@@ -79,7 +79,7 @@ Auth::Negotiate::UserRequest::module_direction()
 }
 
 void
-Auth::Negotiate::UserRequest::module_start(RH * handler, void *data)
+Auth::Negotiate::UserRequest::module_start(AUTHCB * handler, void *data)
 {
     static char buf[MAX_AUTHTOKEN_LEN];
 
@@ -91,7 +91,7 @@ Auth::Negotiate::UserRequest::module_start(RH * handler, void *data)
 
     if (static_cast<Auth::Negotiate::Config*>(Auth::Config::Find("negotiate"))->authenticateProgram == NULL) {
         debugs(29, DBG_CRITICAL, "ERROR: No Negotiate authentication program configured.");
-        handler(data, NULL);
+        handler(data);
         return;
     }
 
@@ -360,7 +360,7 @@ Auth::Negotiate::UserRequest::HandleReply(void *data, void *lastserver, char *re
     }
 
     lm_request->request = NULL;
-    r->handler(r->data, NULL);
+    r->handler(r->data);
     delete r;
 }
 
index 888cdf93ffba0c814b791e8ab66c4b7a86f0c0c8..478680cfcdee11428523964164306ee65c251fa3 100644 (file)
@@ -27,7 +27,7 @@ public:
     virtual void authenticate(HttpRequest * request, ConnStateData * conn, http_hdr_type type);
     virtual Direction module_direction();
     virtual void onConnectionClose(ConnStateData *);
-    virtual void module_start(RH *, void *);
+    virtual void module_start(AUTHCB *, void *);
 
     virtual void addAuthenticationInfoHeader(HttpReply * rep, int accel);
 
index b228d29dac72a75d6e6857b417f1eeeaa951a0f0..efdb33d25584099238bec4e01e06ab8acee0d9a1 100644 (file)
@@ -77,7 +77,7 @@ Auth::Ntlm::UserRequest::module_direction()
 }
 
 void
-Auth::Ntlm::UserRequest::module_start(RH * handler, void *data)
+Auth::Ntlm::UserRequest::module_start(AUTHCB * handler, void *data)
 {
     static char buf[MAX_AUTHTOKEN_LEN];
 
@@ -86,7 +86,7 @@ Auth::Ntlm::UserRequest::module_start(RH * handler, void *data)
 
     if (static_cast<Auth::Ntlm::Config*>(Auth::Config::Find("ntlm"))->authenticateProgram == NULL) {
         debugs(29, DBG_CRITICAL, "ERROR: NTLM Start: no NTLM program configured.");
-        handler(data, NULL);
+        handler(data);
         return;
     }
 
@@ -340,6 +340,6 @@ Auth::Ntlm::UserRequest::HandleReply(void *data, void *lastserver, char *reply)
         HTTPMSGUNLOCK(lm_request->request);
         lm_request->request = NULL;
     }
-    r->handler(r->data, NULL);
+    r->handler(r->data);
     delete r;
 }
index e999b670c017bf31d318adb03c2dec3b69003287..82e72b101d4e49593a4ee21ae64b3087f028e931 100644 (file)
@@ -27,7 +27,7 @@ public:
     virtual void authenticate(HttpRequest * request, ConnStateData * conn, http_hdr_type type);
     virtual Auth::Direction module_direction();
     virtual void onConnectionClose(ConnStateData *);
-    virtual void module_start(RH *, void *);
+    virtual void module_start(AUTHCB *, void *);
 
     virtual const char * connLastHeader();