[dovecot-cvs] dovecot/src/auth mech-anonymous.c, 1.15, 1.16 mech-apop.c, 1.21, 1.22 mech-cram-md5.c, 1.23, 1.24 mech-digest-md5.c, 1.40, 1.41 mech-login.c, 1.17, 1.18 mech-ntlm.c, 1.25, 1.26 mech-plain.c, 1.35, 1.36 mech-rpa.c, 1.25, 1.26 mech.c, 1.55, 1.56 mech.h, 1.37, 1.38

cras at dovecot.org cras at dovecot.org
Sat Jun 17 22:15:27 EEST 2006


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

Modified Files:
	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.c mech.h 
Log Message:
Added mech_generic_auth_internal() and mech_generic_auth_free() functions   
and used them wherever possible to reduce code duplication. Patch by Andrey 
Panin.



Index: mech-anonymous.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech-anonymous.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- mech-anonymous.c	28 Dec 2005 17:15:43 -0000	1.15
+++ mech-anonymous.c	17 Jun 2006 19:15:20 -0000	1.16
@@ -23,24 +23,6 @@
 	auth_request_success(request, NULL, 0);
 }
 
-static void
-mech_anonymous_auth_initial(struct auth_request *request,
-			    const unsigned char *data, size_t data_size)
-{
-	if (data_size == 0) {
-		request->callback(request, AUTH_CLIENT_RESULT_CONTINUE,
-				  NULL, 0);
-	} else {
-		mech_anonymous_auth_continue(request, data, data_size);
-	}
-}
-
-static void
-mech_anonymous_auth_free(struct auth_request *request)
-{
-	pool_unref(request->pool);
-}
-
 static struct auth_request *mech_anonymous_auth_new(void)
 {
         struct auth_request *request;
@@ -61,7 +43,7 @@
 	MEMBER(passdb_need_credentials) FALSE,
 
 	mech_anonymous_auth_new,
-	mech_anonymous_auth_initial,
+	mech_generic_auth_initial,
 	mech_anonymous_auth_continue,
-        mech_anonymous_auth_free
+	mech_generic_auth_free
 };

Index: mech-apop.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech-apop.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- mech-apop.c	16 Jun 2006 10:38:56 -0000	1.21
+++ mech-apop.c	17 Jun 2006 19:15:20 -0000	1.22
@@ -136,11 +136,6 @@
 					apop_credentials_callback);
 }
 
-static void mech_apop_auth_free(struct auth_request *request)
-{
-	pool_unref(request->pool);
-}
-
 static struct auth_request *mech_apop_auth_new(void)
 {
 	struct apop_auth_request *request;
@@ -165,5 +160,5 @@
 	mech_apop_auth_new,
 	mech_apop_auth_initial,
 	NULL,
-        mech_apop_auth_free
+        mech_generic_auth_free
 };

Index: mech-cram-md5.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech-cram-md5.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- mech-cram-md5.c	13 Jan 2006 20:25:57 -0000	1.23
+++ mech-cram-md5.c	17 Jun 2006 19:15:20 -0000	1.24
@@ -168,11 +168,6 @@
 			       request->challenge, strlen(request->challenge));
 }
 
-static void mech_cram_md5_auth_free(struct auth_request *request)
-{
-	pool_unref(request->pool);
-}
-
 static struct auth_request *mech_cram_md5_auth_new(void)
 {
 	struct cram_auth_request *request;
@@ -197,5 +192,5 @@
 	mech_cram_md5_auth_new,
 	mech_cram_md5_auth_initial,
 	mech_cram_md5_auth_continue,
-        mech_cram_md5_auth_free
+        mech_generic_auth_free
 };

Index: mech-digest-md5.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech-digest-md5.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- mech-digest-md5.c	30 May 2006 08:39:37 -0000	1.40
+++ mech-digest-md5.c	17 Jun 2006 19:15:20 -0000	1.41
@@ -596,11 +596,6 @@
 			       str_data(challenge), str_len(challenge));
 }
 
-static void mech_digest_md5_auth_free(struct auth_request *request)
-{
-	pool_unref(request->pool);
-}
-
 static struct auth_request *mech_digest_md5_auth_new(void)
 {
 	struct digest_auth_request *request;
@@ -627,5 +622,5 @@
 	mech_digest_md5_auth_new,
 	mech_digest_md5_auth_initial,
 	mech_digest_md5_auth_continue,
-        mech_digest_md5_auth_free
+	mech_generic_auth_free
 };

Index: mech-login.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech-login.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- mech-login.c	16 Jun 2006 10:38:56 -0000	1.17
+++ mech-login.c	17 Jun 2006 19:15:20 -0000	1.18
@@ -66,11 +66,6 @@
 	}
 }
 
-static void mech_login_auth_free(struct auth_request *request)
-{
-	pool_unref(request->pool);
-}
-
 static struct auth_request *mech_login_auth_new(void)
 {
 	struct auth_request *request;
@@ -93,5 +88,5 @@
 	mech_login_auth_new,
 	mech_login_auth_initial,
 	mech_login_auth_continue,
-        mech_login_auth_free
+	mech_generic_auth_free
 };

Index: mech-ntlm.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech-ntlm.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- mech-ntlm.c	16 Jun 2006 10:38:56 -0000	1.25
+++ mech-ntlm.c	17 Jun 2006 19:15:20 -0000	1.26
@@ -242,24 +242,6 @@
 	}
 }
 
-static void
-mech_ntlm_auth_initial(struct auth_request *request,
-		       const unsigned char *data, size_t data_size)
-{
-	if (data_size == 0) {
-		request->callback(request, AUTH_CLIENT_RESULT_CONTINUE,
-				  NULL, 0);
-	} else {
-		mech_ntlm_auth_continue(request, data, data_size);
-	}
-}
-
-static void
-mech_ntlm_auth_free(struct auth_request *request)
-{
-	pool_unref(request->pool);
-}
-
 static struct auth_request *mech_ntlm_auth_new(void)
 {
 	struct ntlm_auth_request *request;
@@ -282,7 +264,7 @@
 	MEMBER(passdb_need_credentials) TRUE,
 
 	mech_ntlm_auth_new,
-	mech_ntlm_auth_initial,
+	mech_generic_auth_initial,
 	mech_ntlm_auth_continue,
-	mech_ntlm_auth_free
+	mech_generic_auth_free
 };

Index: mech-plain.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech-plain.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- mech-plain.c	20 Feb 2006 13:14:58 -0000	1.35
+++ mech-plain.c	17 Jun 2006 19:15:20 -0000	1.36
@@ -73,24 +73,6 @@
         safe_memset(pass, 0, strlen(pass));
 }
 
-static void
-mech_plain_auth_initial(struct auth_request *request,
-			const unsigned char *data, size_t data_size)
-{
-	if (data_size == 0) {
-		request->callback(request, AUTH_CLIENT_RESULT_CONTINUE,
-				  NULL, 0);
-	} else {
-		mech_plain_auth_continue(request, data, data_size);
-	}
-}
-
-static void
-mech_plain_auth_free(struct auth_request *request)
-{
-	pool_unref(request->pool);
-}
-
 static struct auth_request *mech_plain_auth_new(void)
 {
         struct auth_request *request;
@@ -111,7 +93,7 @@
 	MEMBER(passdb_need_credentials) FALSE,
 
 	mech_plain_auth_new,
-	mech_plain_auth_initial,
+	mech_generic_auth_initial,
 	mech_plain_auth_continue,
-        mech_plain_auth_free
+	mech_generic_auth_free
 };

Index: mech-rpa.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech-rpa.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- mech-rpa.c	16 Jun 2006 10:38:56 -0000	1.25
+++ mech-rpa.c	17 Jun 2006 19:15:20 -0000	1.26
@@ -568,18 +568,6 @@
 }
 
 static void
-mech_rpa_auth_initial(struct auth_request *request,
-		      const unsigned char *data, size_t data_size)
-{
-	if (data_size == 0) {
-		request->callback(request, AUTH_CLIENT_RESULT_CONTINUE,
-				  NULL, 0);
-	} else {
-		mech_rpa_auth_continue(request, data, data_size);
-	}
-}
-
-static void
 mech_rpa_auth_free(struct auth_request *auth_request)
 {
 	struct rpa_auth_request *request =
@@ -615,7 +603,7 @@
 	MEMBER(passdb_need_credentials) TRUE,
 
 	mech_rpa_auth_new,
-	mech_rpa_auth_initial,
+	mech_generic_auth_initial,
 	mech_rpa_auth_continue,
 	mech_rpa_auth_free
 };

Index: mech.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- mech.c	27 Oct 2005 14:57:51 -0000	1.55
+++ mech.c	17 Jun 2006 19:15:20 -0000	1.56
@@ -46,6 +46,22 @@
 	return NULL;
 }
 
+void mech_generic_auth_initial(struct auth_request *request,
+			       const unsigned char *data, size_t data_size)
+{
+	if (data_size == 0) {
+		request->callback(request, AUTH_CLIENT_RESULT_CONTINUE,
+				  NULL, 0);
+	} else {
+		request->mech->auth_continue(request, data, data_size);
+	}
+}
+
+void mech_generic_auth_free(struct auth_request *request)
+{
+	pool_unref(request->pool);
+}
+
 extern struct mech_module mech_plain;
 extern struct mech_module mech_login;
 extern struct mech_module mech_apop;

Index: mech.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/mech.h,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- mech.h	28 Dec 2005 17:15:43 -0000	1.37
+++ mech.h	17 Jun 2006 19:15:20 -0000	1.38
@@ -45,6 +45,10 @@
 void mech_unregister_module(struct mech_module *module);
 struct mech_module *mech_module_find(const char *name);
 
+void mech_generic_auth_initial(struct auth_request *request,
+			       const unsigned char *data, size_t data_size);
+void mech_generic_auth_free(struct auth_request *request);
+
 void mech_init(void);
 void mech_deinit(void);
 



More information about the dovecot-cvs mailing list