[dovecot-cvs] dovecot/src/auth auth-client-connection.c, 1.30, 1.31 auth-request.c, 1.4, 1.5 auth-request.h, 1.4, 1.5 mech-anonymous.c, 1.10, 1.11 mech-apop.c, 1.11, 1.12 mech-cram-md5.c, 1.18, 1.19 mech-digest-md5.c, 1.32, 1.33 mech-login.c, 1.9, 1.10 mech-ntlm.c, 1.15, 1.16 mech-plain.c, 1.27, 1.28 mech-rpa.c, 1.14, 1.15 mech.h, 1.32, 1.33

cras at dovecot.org cras at dovecot.org
Sat Jan 8 23:22:54 EET 2005


Update of /var/lib/cvs/dovecot/src/auth
In directory talvi:/tmp/cvs-serv24017

Modified Files:
	auth-client-connection.c auth-request.c auth-request.h 
	mech-anonymous.c mech-apop.c mech-cram-md5.c mech-digest-md5.c 
	mech-login.c mech-ntlm.c mech-plain.c mech-rpa.c mech.h 
Log Message:
API cleanup



Index: auth-client-connection.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-client-connection.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- auth-client-connection.c	8 Jan 2005 19:01:34 -0000	1.30
+++ auth-client-connection.c	8 Jan 2005 21:22:52 -0000	1.31
@@ -226,9 +226,14 @@
 		return FALSE;
 	}
 
-	request = auth_request_new(conn->auth, mech);
+	request = mech->auth_new(auth_callback);
 	if (request == NULL)
 		return TRUE;
+
+	request->auth = conn->auth;
+	request->mech = mech;
+	request->created = ioloop_time;
+
 	hash_insert(conn->auth_requests, POINTER_CAST(id), request);
 
 	request->conn = conn;
@@ -297,8 +302,7 @@
 
 	/* connection is referenced only until auth_callback is called. */
 	conn->refcount++;
-	auth_request_initial(request, initial_resp_data, initial_resp_len,
-			     auth_callback);
+	auth_request_initial(request, initial_resp_data, initial_resp_len);
 	return TRUE;
 }
 
@@ -348,7 +352,7 @@
 	}
 
 	conn->refcount++;
-	auth_request_continue(request, buf->data, buf->used, auth_callback);
+	auth_request_continue(request, buf->data, buf->used);
 	return TRUE;
 }
 

Index: auth-request.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-request.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- auth-request.c	8 Jan 2005 16:56:04 -0000	1.4
+++ auth-request.c	8 Jan 2005 21:22:52 -0000	1.5
@@ -23,21 +23,6 @@
 static buffer_t *auth_failures_buf;
 static struct timeout *to_auth_failures;
 
-struct auth_request *auth_request_new(struct auth *auth,
-				      struct mech_module *mech)
-{
-	struct auth_request *request;
-
-	request = mech->auth_new();
-	if (request == NULL)
-		return NULL;
-
-	request->auth = auth;
-	request->mech = mech;
-	request->created = ioloop_time;
-	return request;
-}
-
 void auth_request_destroy(struct auth_request *request)
 {
 	i_assert(request->refcount > 0);
@@ -118,17 +103,15 @@
 }
 
 void auth_request_initial(struct auth_request *request,
-			  const unsigned char *data, size_t data_size,
-			  mech_callback_t *callback)
+			  const unsigned char *data, size_t data_size)
 {
-	request->mech->auth_initial(request, data, data_size, callback);
+	request->mech->auth_initial(request, data, data_size);
 }
 
 void auth_request_continue(struct auth_request *request,
-			   const unsigned char *data, size_t data_size,
-			   mech_callback_t *callback)
+			   const unsigned char *data, size_t data_size)
 {
-	request->mech->auth_continue(request, data, data_size, callback);
+	request->mech->auth_continue(request, data, data_size);
 }
 
 void auth_request_verify_plain(struct auth_request *request,

Index: auth-request.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-request.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- auth-request.h	8 Jan 2005 16:56:04 -0000	1.4
+++ auth-request.h	8 Jan 2005 21:22:52 -0000	1.5
@@ -48,11 +48,9 @@
 int auth_request_unref(struct auth_request *request);
 
 void auth_request_initial(struct auth_request *request,
-			  const unsigned char *data, size_t data_size,
-			  mech_callback_t *callback);
+			  const unsigned char *data, size_t data_size);
 void auth_request_continue(struct auth_request *request,
-			   const unsigned char *data, size_t data_size,
-			   mech_callback_t *callback);
+			   const unsigned char *data, size_t data_size);
 
 void auth_request_verify_plain(struct auth_request *request,
 			       const char *password,

Index: mech-anonymous.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech-anonymous.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- mech-anonymous.c	8 Jan 2005 16:56:04 -0000	1.10
+++ mech-anonymous.c	8 Jan 2005 21:22:52 -0000	1.11
@@ -5,8 +5,7 @@
 
 static void
 mech_anonymous_auth_continue(struct auth_request *request,
-			     const unsigned char *data, size_t data_size,
-			     mech_callback_t *callback)
+			     const unsigned char *data, size_t data_size)
 {
 	i_assert(request->auth->anonymous_username != NULL);
 
@@ -18,7 +17,6 @@
 		auth_request_log_info(request, "anonymous", "login");
 	}
 
-	request->callback = callback;
 	request->user = p_strdup(request->pool,
 				 request->auth->anonymous_username);
 
@@ -27,14 +25,13 @@
 
 static void
 mech_anonymous_auth_initial(struct auth_request *request,
-			    const unsigned char *data, size_t data_size,
-			    mech_callback_t *callback)
+			    const unsigned char *data, size_t data_size)
 {
-	if (data_size == 0)
-		callback(request, AUTH_CLIENT_RESULT_CONTINUE, NULL, 0);
-	else {
-		mech_anonymous_auth_continue(request, data, data_size,
-					     callback);
+	if (data_size == 0) {
+		request->callback(request, AUTH_CLIENT_RESULT_CONTINUE,
+				  NULL, 0);
+	} else {
+		mech_anonymous_auth_continue(request, data, data_size);
 	}
 }
 
@@ -44,7 +41,7 @@
 	pool_unref(request->pool);
 }
 
-static struct auth_request *mech_anonymous_auth_new(void)
+static struct auth_request *mech_anonymous_auth_new(mech_callback_t *callback)
 {
         struct auth_request *request;
 	pool_t pool;
@@ -53,7 +50,7 @@
 	request = p_new(pool, struct auth_request, 1);
 	request->refcount = 1;
 	request->pool = pool;
-
+	request->callback = callback;
 	return request;
 }
 

Index: mech-apop.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech-apop.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- mech-apop.c	8 Jan 2005 16:56:04 -0000	1.11
+++ mech-apop.c	8 Jan 2005 21:22:52 -0000	1.12
@@ -71,16 +71,13 @@
 
 static void
 mech_apop_auth_initial(struct auth_request *auth_request,
-		       const unsigned char *data, size_t data_size,
-		       mech_callback_t *callback)
+		       const unsigned char *data, size_t data_size)
 {
 	struct apop_auth_request *request =
 		(struct apop_auth_request *)auth_request;
 	const unsigned char *tmp, *end, *username = NULL;
 	const char *str, *error;
 
-	auth_request->callback = callback;
-
 	if (data_size == 0) {
 		/* Should never happen */
 		auth_request_log_info(auth_request, "apop",
@@ -141,7 +138,7 @@
 	pool_unref(request->pool);
 }
 
-static struct auth_request *mech_apop_auth_new(void)
+static struct auth_request *mech_apop_auth_new(mech_callback_t *callback)
 {
 	struct apop_auth_request *request;
 	pool_t pool;
@@ -152,6 +149,7 @@
 
 	request->auth_request.refcount = 1;
 	request->auth_request.pool = pool;
+	request->auth_request.callback = callback;
 	return &request->auth_request;
 }
 

Index: mech-cram-md5.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech-cram-md5.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- mech-cram-md5.c	8 Jan 2005 16:56:04 -0000	1.18
+++ mech-cram-md5.c	8 Jan 2005 21:22:52 -0000	1.19
@@ -132,16 +132,13 @@
 
 static void
 mech_cram_md5_auth_continue(struct auth_request *auth_request,
-			    const unsigned char *data, size_t data_size,
-			    mech_callback_t *callback)
+			    const unsigned char *data, size_t data_size)
 {
 	struct cram_auth_request *request =
 		(struct cram_auth_request *)auth_request;
 	const char *error;
 
 	if (parse_cram_response(request, data, data_size, &error)) {
-		auth_request->callback = callback;
-
 		if (auth_request_set_username(auth_request, request->username,
 					      &error)) {
 			auth_request_lookup_credentials(auth_request,
@@ -161,15 +158,14 @@
 static void
 mech_cram_md5_auth_initial(struct auth_request *auth_request,
 			   const unsigned char *data __attr_unused__,
-			   size_t data_size __attr_unused__,
-			   mech_callback_t *callback)
+			   size_t data_size __attr_unused__)
 {
 	struct cram_auth_request *request =
 		(struct cram_auth_request *)auth_request;
 
 	request->challenge = p_strdup(request->pool, get_cram_challenge());
-	callback(auth_request, AUTH_CLIENT_RESULT_CONTINUE,
-		 request->challenge, strlen(request->challenge));
+	auth_request->callback(auth_request, AUTH_CLIENT_RESULT_CONTINUE,
+			       request->challenge, strlen(request->challenge));
 }
 
 static void mech_cram_md5_auth_free(struct auth_request *request)
@@ -177,7 +173,7 @@
 	pool_unref(request->pool);
 }
 
-static struct auth_request *mech_cram_md5_auth_new(void)
+static struct auth_request *mech_cram_md5_auth_new(mech_callback_t *callback)
 {
 	struct cram_auth_request *request;
 	pool_t pool;
@@ -188,6 +184,7 @@
 
 	request->auth_request.refcount = 1;
 	request->auth_request.pool = pool;
+	request->auth_request.callback = callback;
 	return &request->auth_request;
 }
 

Index: mech-digest-md5.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech-digest-md5.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- mech-digest-md5.c	8 Jan 2005 16:56:04 -0000	1.32
+++ mech-digest-md5.c	8 Jan 2005 21:22:52 -0000	1.33
@@ -543,8 +543,7 @@
 
 static void
 mech_digest_md5_auth_continue(struct auth_request *auth_request,
-			      const unsigned char *data, size_t data_size,
-			      mech_callback_t *callback)
+			      const unsigned char *data, size_t data_size)
 {
 	struct digest_auth_request *request =
 		(struct digest_auth_request *)auth_request;
@@ -558,8 +557,6 @@
 	}
 
 	if (parse_digest_response(request, data, data_size, &error)) {
-		auth_request->callback = callback;
-
 		username = request->realm == NULL ? request->username :
 			t_strconcat(request->username, "@",
 				    request->realm, NULL);
@@ -580,8 +577,7 @@
 
 static void
 mech_digest_md5_auth_initial(struct auth_request *auth_request,
-			     const unsigned char *data, size_t data_size,
-			     mech_callback_t *callback)
+			     const unsigned char *data, size_t data_size)
 {
 	struct digest_auth_request *request =
 		(struct digest_auth_request *)auth_request;
@@ -589,14 +585,13 @@
 
 	if (data_size > 0) {
 		/* FIXME: support subsequent authentication? */
-		mech_digest_md5_auth_continue(auth_request, data, data_size,
-					      callback);
+		mech_digest_md5_auth_continue(auth_request, data, data_size);
 		return;
 	}
 
 	challenge = get_digest_challenge(request);
-	callback(auth_request, AUTH_CLIENT_RESULT_CONTINUE,
-		 str_data(challenge), str_len(challenge));
+	auth_request->callback(auth_request, AUTH_CLIENT_RESULT_CONTINUE,
+			       str_data(challenge), str_len(challenge));
 }
 
 static void mech_digest_md5_auth_free(struct auth_request *request)
@@ -605,7 +600,7 @@
 }
 
 static struct auth_request *
-mech_digest_md5_auth_new(void)
+mech_digest_md5_auth_new(mech_callback_t *callback)
 {
 	struct digest_auth_request *request;
 	pool_t pool;
@@ -613,10 +608,11 @@
 	pool = pool_alloconly_create("digest_md5_auth_request", 2048);
 	request = p_new(pool, struct digest_auth_request, 1);
 	request->pool = pool;
+	request->qop = QOP_AUTH;
 
 	request->auth_request.refcount = 1;
 	request->auth_request.pool = pool;
-	request->qop = QOP_AUTH;
+	request->auth_request.callback = callback;
 	return &request->auth_request;
 }
 

Index: mech-login.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech-login.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- mech-login.c	8 Jan 2005 16:56:04 -0000	1.9
+++ mech-login.c	8 Jan 2005 21:22:52 -0000	1.10
@@ -32,14 +32,11 @@
 
 static void
 mech_login_auth_continue(struct auth_request *request,
-			 const unsigned char *data, size_t data_size,
-			 mech_callback_t *callback)
+			 const unsigned char *data, size_t data_size)
 {
 	static const char prompt2[] = "Password:";
 	const char *username, *error;
 
-	request->callback = callback;
-
 	if (request->user == NULL) {
 		username = t_strndup(data, data_size);
 
@@ -49,8 +46,8 @@
 			return;
 		}
 
-		callback(request, AUTH_CLIENT_RESULT_CONTINUE,
-			 prompt2, strlen(prompt2));
+		request->callback(request, AUTH_CLIENT_RESULT_CONTINUE,
+				  prompt2, strlen(prompt2));
 	} else {
 		char *pass = p_strndup(unsafe_data_stack_pool, data, data_size);
 		auth_request_verify_plain(request, pass, verify_callback);
@@ -61,13 +58,12 @@
 static void
 mech_login_auth_initial(struct auth_request *request,
 			const unsigned char *data __attr_unused__,
-			size_t data_size __attr_unused__,
-			mech_callback_t *callback)
+			size_t data_size __attr_unused__)
 {
 	static const char prompt1[] = "Username:";
 
-	callback(request, AUTH_CLIENT_RESULT_CONTINUE,
-		 prompt1, strlen(prompt1));
+	request->callback(request, AUTH_CLIENT_RESULT_CONTINUE,
+			  prompt1, strlen(prompt1));
 }
 
 static void mech_login_auth_free(struct auth_request *request)
@@ -75,16 +71,16 @@
 	pool_unref(request->pool);
 }
 
-static struct auth_request *mech_login_auth_new(void)
+static struct auth_request *mech_login_auth_new(mech_callback_t *callback)
 {
 	struct auth_request *request;
 	pool_t pool;
 
 	pool = pool_alloconly_create("login_auth_request", 256);
 	request = p_new(pool, struct auth_request, 1);
-
 	request->refcount = 1;
 	request->pool = pool;
+	request->callback = callback;
 	return request;
 }
 

Index: mech-ntlm.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech-ntlm.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- mech-ntlm.c	8 Jan 2005 16:56:04 -0000	1.15
+++ mech-ntlm.c	8 Jan 2005 21:22:52 -0000	1.16
@@ -181,15 +181,12 @@
 
 static void
 mech_ntlm_auth_continue(struct auth_request *auth_request,
-			const unsigned char *data, size_t data_size,
-			mech_callback_t *callback)
+			const unsigned char *data, size_t data_size)
 {
 	struct ntlm_auth_request *request =
 		(struct ntlm_auth_request *)auth_request;
 	const char *error;
 
-	auth_request->callback = callback;
-
 	if (!request->challenge) {
 		const struct ntlmssp_request *ntlm_request =
 			(struct ntlmssp_request *)data;
@@ -247,13 +244,14 @@
 
 static void
 mech_ntlm_auth_initial(struct auth_request *request,
-		       const unsigned char *data, size_t data_size,
-		       mech_callback_t *callback)
+		       const unsigned char *data, size_t data_size)
 {
-	if (data_size == 0)
-		callback(request, AUTH_CLIENT_RESULT_CONTINUE, NULL, 0);
-	else
-		mech_ntlm_auth_continue(request, data, data_size, callback);
+	if (data_size == 0) {
+		request->callback(request, AUTH_CLIENT_RESULT_CONTINUE,
+				  NULL, 0);
+	} else {
+		mech_ntlm_auth_continue(request, data, data_size);
+	}
 }
 
 static void
@@ -262,7 +260,7 @@
 	pool_unref(request->pool);
 }
 
-static struct auth_request *mech_ntlm_auth_new(void)
+static struct auth_request *mech_ntlm_auth_new(mech_callback_t *callback)
 {
 	struct ntlm_auth_request *request;
 	pool_t pool;
@@ -273,6 +271,7 @@
 
 	request->auth_request.refcount = 1;
 	request->auth_request.pool = pool;
+	request->auth_request.callback = callback;
 	return &request->auth_request;
 }
 

Index: mech-plain.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech-plain.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- mech-plain.c	8 Jan 2005 16:56:04 -0000	1.27
+++ mech-plain.c	8 Jan 2005 21:22:52 -0000	1.28
@@ -23,15 +23,12 @@
 
 static void
 mech_plain_auth_continue(struct auth_request *request,
-			 const unsigned char *data, size_t data_size,
-			 mech_callback_t *callback)
+			 const unsigned char *data, size_t data_size)
 {
 	const char *authid, *authenid, *error;
 	char *pass;
 	size_t i, count, len;
 
-	request->callback = callback;
-
 	/* authorization ID \0 authentication ID \0 pass.
 	   we'll ignore authorization ID for now. */
 	authid = (const char *) data;
@@ -73,13 +70,14 @@
 
 static void
 mech_plain_auth_initial(struct auth_request *request,
-			const unsigned char *data, size_t data_size,
-			mech_callback_t *callback)
+			const unsigned char *data, size_t data_size)
 {
-	if (data_size == 0)
-		callback(request, AUTH_CLIENT_RESULT_CONTINUE, NULL, 0);
-	else
-		mech_plain_auth_continue(request, data, data_size, callback);
+	if (data_size == 0) {
+		request->callback(request, AUTH_CLIENT_RESULT_CONTINUE,
+				  NULL, 0);
+	} else {
+		mech_plain_auth_continue(request, data, data_size);
+	}
 }
 
 static void
@@ -88,7 +86,7 @@
 	pool_unref(request->pool);
 }
 
-static struct auth_request *mech_plain_auth_new(void)
+static struct auth_request *mech_plain_auth_new(mech_callback_t *callback)
 {
         struct auth_request *request;
 	pool_t pool;
@@ -97,6 +95,7 @@
 	request = p_new(pool, struct auth_request, 1);
 	request->refcount = 1;
 	request->pool = pool;
+        request->callback = callback;
 	return request;
 }
 

Index: mech-rpa.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech-rpa.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- mech-rpa.c	8 Jan 2005 16:56:04 -0000	1.14
+++ mech-rpa.c	8 Jan 2005 21:22:52 -0000	1.15
@@ -504,14 +504,11 @@
 
 static void
 mech_rpa_auth_continue(struct auth_request *auth_request,
-		       const unsigned char *data, size_t data_size,
-		       mech_callback_t *callback)
+		       const unsigned char *data, size_t data_size)
 {
 	struct rpa_auth_request *request =
 		(struct rpa_auth_request *)auth_request;
 
-	auth_request->callback = callback;
-
 	switch (request->phase) {
 	case 0:
 		mech_rpa_auth_phase1(auth_request, data, data_size);
@@ -530,13 +527,14 @@
 
 static void
 mech_rpa_auth_initial(struct auth_request *request,
-		      const unsigned char *data, size_t data_size,
-		      mech_callback_t *callback)
+		      const unsigned char *data, size_t data_size)
 {
-	if (data_size == 0)
-		callback(request, AUTH_CLIENT_RESULT_CONTINUE, NULL, 0);
-	else
-		mech_rpa_auth_continue(request, data, data_size, callback);
+	if (data_size == 0) {
+		request->callback(request, AUTH_CLIENT_RESULT_CONTINUE,
+				  NULL, 0);
+	} else {
+		mech_rpa_auth_continue(request, data, data_size);
+	}
 }
 
 static void
@@ -551,7 +549,7 @@
 	pool_unref(auth_request->pool);
 }
 
-static struct auth_request *mech_rpa_auth_new(void)
+static struct auth_request *mech_rpa_auth_new(mech_callback_t *callback)
 {
 	struct rpa_auth_request *request;
 	pool_t pool;
@@ -563,6 +561,7 @@
 
 	request->auth_request.refcount = 1;
 	request->auth_request.pool = pool;
+	request->auth_request.callback = callback;
 	return &request->auth_request;
 }
 

Index: mech.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- mech.h	7 Jan 2005 19:55:50 -0000	1.32
+++ mech.h	8 Jan 2005 21:22:52 -0000	1.33
@@ -24,13 +24,11 @@
 	unsigned int passdb_need_plain:1;
 	unsigned int passdb_need_credentials:1;
 
-	struct auth_request *(*auth_new)(void);
+	struct auth_request *(*auth_new)(mech_callback_t *callback);
 	void (*auth_initial)(struct auth_request *request,
-			     const unsigned char *data, size_t data_size,
-			     mech_callback_t *callback);
+			     const unsigned char *data, size_t data_size);
 	void (*auth_continue)(struct auth_request *request,
-			      const unsigned char *data, size_t data_size,
-			      mech_callback_t *callback);
+			      const unsigned char *data, size_t data_size);
 	void (*auth_free)(struct auth_request *request);
 };
 



More information about the dovecot-cvs mailing list