[dovecot-cvs] dovecot/src/auth auth-worker-client.c, 1.25.2.2, 1.25.2.3 passdb.c, 1.42.2.1, 1.42.2.2 passdb.h, 1.33.2.1, 1.33.2.2 password-scheme.c, 1.21.2.4, 1.21.2.5

tss at dovecot.org tss at dovecot.org
Sat Dec 16 13:37:30 UTC 2006


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

Modified Files:
      Tag: branch_1_0
	auth-worker-client.c passdb.c passdb.h password-scheme.c 
Log Message:
Changed the default naming for password schemes: HMAC-MD5 -> CRAM-MD5. MD5
-> MD5-CRYPT. The old names still work for backwards compatibility.



Index: auth-worker-client.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-worker-client.c,v
retrieving revision 1.25.2.2
retrieving revision 1.25.2.3
diff -u -d -r1.25.2.2 -r1.25.2.3
--- auth-worker-client.c	9 Dec 2006 15:11:33 -0000	1.25.2.2
+++ auth-worker-client.c	16 Dec 2006 13:37:28 -0000	1.25.2.3
@@ -171,7 +171,7 @@
 		str_printfa(str, "FAIL\t%d", result);
 	else {
 		str_printfa(str, "OK\t%s\t{%s}%s\t", request->user,
-			    passdb_credentials_to_str(request->credentials),
+			    passdb_credentials_to_str(request->credentials, ""),
 			    credentials);
 		if (request->extra_fields != NULL) {
 			const char *field =

Index: passdb.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb.c,v
retrieving revision 1.42.2.1
retrieving revision 1.42.2.2
diff -u -d -r1.42.2.1 -r1.42.2.2
--- passdb.c	8 Oct 2006 21:25:14 -0000	1.42.2.1
+++ passdb.c	16 Dec 2006 13:37:28 -0000	1.42.2.2
@@ -54,17 +54,22 @@
 };
 
 const char *
-passdb_credentials_to_str(enum passdb_credentials credentials)
+passdb_credentials_to_str(enum passdb_credentials credentials,
+			  const char *wanted_scheme)
 {
 	switch (credentials) {
 	case _PASSDB_CREDENTIALS_INTERNAL:
 		break;
 	case PASSDB_CREDENTIALS_PLAINTEXT:
+		if (strcasecmp(wanted_scheme, "CLEARTEXT") == 0)
+			return wanted_scheme;
 		return "PLAIN";
 	case PASSDB_CREDENTIALS_CRYPT:
 		return "CRYPT";
 	case PASSDB_CREDENTIALS_CRAM_MD5:
-		return "HMAC-MD5";
+		if (strcasecmp(wanted_scheme, "HMAC-MD5") == 0)
+			return wanted_scheme;
+		return "CRAM-MD5";
 	case PASSDB_CREDENTIALS_DIGEST_MD5:
 		return "DIGEST-MD5";
 	case PASSDB_CREDENTIALS_LANMAN:
@@ -89,7 +94,8 @@
 		return t_strdup_printf("{%s}%s", scheme, password);
 	}
 
-	wanted_scheme = passdb_credentials_to_str(auth_request->credentials);
+	wanted_scheme = passdb_credentials_to_str(auth_request->credentials,
+						  wanted_scheme);
 	if (strcasecmp(scheme, wanted_scheme) != 0) {
 		if (strcasecmp(scheme, "PLAIN") != 0 &&
 		    strcasecmp(scheme, "CLEARTEXT") != 0) {

Index: passdb.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb.h,v
retrieving revision 1.33.2.1
retrieving revision 1.33.2.2
diff -u -d -r1.33.2.1 -r1.33.2.2
--- passdb.h	11 Jun 2006 12:51:36 -0000	1.33.2.1
+++ passdb.h	16 Dec 2006 13:37:28 -0000	1.33.2.2
@@ -76,7 +76,8 @@
 			       lookup_credentials_callback_t *callback,
                                struct auth_request *auth_request);
 
-const char *passdb_credentials_to_str(enum passdb_credentials credentials);
+const char *passdb_credentials_to_str(enum passdb_credentials credentials,
+				      const char *wanted_scheme);
 
 struct auth_passdb *passdb_preinit(struct auth *auth, const char *driver,
 				   const char *args, unsigned int id);

Index: password-scheme.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/password-scheme.c,v
retrieving revision 1.21.2.4
retrieving revision 1.21.2.5
diff -u -d -r1.21.2.4 -r1.21.2.5
--- password-scheme.c	3 Dec 2006 19:23:31 -0000	1.21.2.4
+++ password-scheme.c	16 Dec 2006 13:37:28 -0000	1.21.2.5
@@ -119,8 +119,8 @@
 	return t_strdup(mycrypt(plaintext, salt));
 }
 
-static bool md5_verify(const char *plaintext, const char *password,
-		       const char *user __attr_unused__)
+static bool md5_crypt_verify(const char *plaintext, const char *password,
+			     const char *user __attr_unused__)
 {
 	const char *str;
 
@@ -128,8 +128,8 @@
 	return strcmp(str, password) == 0;
 }
 
-static const char *md5_generate(const char *plaintext,
-				const char *user __attr_unused__)
+static const char *md5_crypt_generate(const char *plaintext,
+				      const char *user __attr_unused__)
 {
 	char salt[9];
 	int i;
@@ -312,13 +312,13 @@
 	return plaintext;
 }
 
-static bool hmac_md5_verify(const char *plaintext, const char *password,
+static bool cram_md5_verify(const char *plaintext, const char *password,
 			    const char *user __attr_unused__)
 {
 	return strcmp(password_generate_cram_md5(plaintext), password) == 0;
 }
 
-static const char *hmac_md5_generate(const char *plaintext,
+static const char *cram_md5_generate(const char *plaintext,
 				     const char *user __attr_unused__)
 {
 	return password_generate_cram_md5(plaintext);
@@ -462,14 +462,16 @@
 
 static const struct password_scheme default_schemes[] = {
 	{ "CRYPT", crypt_verify, crypt_generate },
-	{ "MD5", md5_verify, md5_generate },
+	{ "MD5", md5_crypt_verify, md5_crypt_generate },
+	{ "MD5-CRYPT", md5_crypt_verify, md5_crypt_generate },
  	{ "SHA", sha1_verify, sha1_generate },
  	{ "SHA1", sha1_verify, sha1_generate },
 	{ "SMD5", smd5_verify, smd5_generate },
 	{ "SSHA", ssha_verify, ssha_generate },
 	{ "PLAIN", plain_verify, plain_generate },
 	{ "CLEARTEXT", plain_verify, plain_generate },
-	{ "HMAC-MD5", hmac_md5_verify, hmac_md5_generate },
+	{ "CRAM-MD5", cram_md5_verify, cram_md5_generate },
+	{ "HMAC-MD5", cram_md5_verify, cram_md5_generate },
 	{ "DIGEST-MD5", digest_md5_verify, digest_md5_generate },
 	{ "PLAIN-MD4", plain_md4_verify, plain_md4_generate },
 	{ "PLAIN-MD5", plain_md5_verify, plain_md5_generate },



More information about the dovecot-cvs mailing list