[dovecot-cvs] dovecot/src/auth auth-request.c, 1.75, 1.76 auth-worker-client.c, 1.29, 1.30 passdb.c, 1.44, 1.45 passdb.h, 1.36, 1.37 password-scheme.c, 1.26, 1.27

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


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

Modified Files:
	auth-request.c 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-request.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-request.c,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -d -r1.75 -r1.76
--- auth-request.c	9 Dec 2006 15:11:48 -0000	1.75
+++ auth-request.c	16 Dec 2006 13:37:32 -0000	1.76
@@ -551,7 +551,7 @@
 	request->private_callback.set_credentials = callback;
 
 	new_credentials = t_strconcat("{",
-		passdb_credentials_to_str(credentials), "}", data, NULL);
+		passdb_credentials_to_str(credentials, ""), "}", data, NULL);
 
 	if (passdb->blocking)
 		passdb_blocking_set_credentials(request, new_credentials);

Index: auth-worker-client.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-worker-client.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- auth-worker-client.c	15 Dec 2006 18:38:08 -0000	1.29
+++ auth-worker-client.c	16 Dec 2006 13:37:32 -0000	1.30
@@ -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.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- passdb.c	12 Nov 2006 19:36:41 -0000	1.44
+++ passdb.c	16 Dec 2006 13:37:32 -0000	1.45
@@ -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:
@@ -93,7 +98,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.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- passdb.h	12 Nov 2006 19:36:41 -0000	1.36
+++ passdb.h	16 Dec 2006 13:37:32 -0000	1.37
@@ -85,7 +85,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.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- password-scheme.c	3 Dec 2006 19:23:33 -0000	1.26
+++ password-scheme.c	16 Dec 2006 13:37:32 -0000	1.27
@@ -120,8 +120,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;
 
@@ -129,8 +129,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;
@@ -313,13 +313,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);
@@ -482,14 +482,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