[dovecot-cvs] dovecot/src/auth mech-digest-md5.c,1.10,1.11 mech-plain.c,1.10,1.11 mech.c,1.8,1.9 mech.h,1.6,1.7

cras at procontrol.fi cras at procontrol.fi
Wed Apr 2 05:00:06 EEST 2003


Update of /home/cvs/dovecot/src/auth
In directory danu:/tmp/cvs-serv1767/src/auth

Modified Files:
	mech-digest-md5.c mech-plain.c mech.c mech.h 
Log Message:
Added auth_default_realm (based on patch by Kristian Hoffmann)



Index: mech-digest-md5.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/mech-digest-md5.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- mech-digest-md5.c	18 Feb 2003 19:24:44 -0000	1.10
+++ mech-digest-md5.c	2 Apr 2003 01:00:04 -0000	1.11
@@ -551,7 +551,7 @@
 	struct digest_auth_request *auth =
 		(struct digest_auth_request *)auth_request;
 	struct auth_login_reply reply;
-	const char *error;
+	const char *error, *realm;
 
 	/* initialize reply */
 	mech_init_login_reply(&reply);
@@ -568,13 +568,14 @@
 				  request->data_size, &error)) {
 		auth_request->callback = callback;
 
-		if (auth->realm == NULL) {
+		realm = auth->realm != NULL ? auth->realm : default_realm;
+		if (realm == NULL) {
 			auth_request->user = p_strdup(auth_request->pool,
 						      auth->username);
 		} else {
 			auth_request->user = p_strconcat(auth_request->pool,
 							 auth->username, "@",
-							 auth->realm, NULL);
+							 realm, NULL);
 		}
 
 		passdb->lookup_credentials(&auth->auth_request,

Index: mech-plain.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/mech-plain.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- mech-plain.c	26 Feb 2003 21:27:17 -0000	1.10
+++ mech-plain.c	2 Apr 2003 01:00:04 -0000	1.11
@@ -47,7 +47,15 @@
 		mech_auth_finish(auth_request, NULL, 0, FALSE);
 	} else {
 		/* split and save user/realm */
-		auth_request->user = p_strdup(auth_request->pool, authenid);
+		if (strchr(authenid, '@') == NULL && default_realm != NULL) {
+			auth_request->user = p_strconcat(auth_request->pool,
+							 authenid, "@",
+							 default_realm, NULL);
+		} else {
+			auth_request->user = p_strdup(auth_request->pool,
+						      authenid);
+		}
+
 		passdb->verify_plain(auth_request, pass, verify_callback);
 
 		/* make sure it's cleared */

Index: mech.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/mech.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- mech.c	18 Feb 2003 19:11:26 -0000	1.8
+++ mech.c	2 Apr 2003 01:00:04 -0000	1.9
@@ -17,6 +17,7 @@
 
 enum auth_mech auth_mechanisms;
 const char *const *auth_realms;
+const char *default_realm;
 
 static int set_use_cyrus_sasl;
 static struct mech_module_list *mech_modules;
@@ -228,6 +229,10 @@
 	if (env == NULL)
 		env = "";
 	auth_realms = t_strsplit(env, " ");
+
+	default_realm = getenv("DEFAULT_REALM");
+	if (default_realm != NULL && *default_realm == '\0')
+		default_realm = NULL;
 
 	set_use_cyrus_sasl = getenv("USE_CYRUS_SASL") != NULL;
 

Index: mech.h
===================================================================
RCS file: /home/cvs/dovecot/src/auth/mech.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- mech.h	18 Feb 2003 19:11:26 -0000	1.6
+++ mech.h	2 Apr 2003 01:00:04 -0000	1.7
@@ -37,6 +37,7 @@
 
 extern enum auth_mech auth_mechanisms;
 extern const char *const *auth_realms;
+extern const char *default_realm;
 
 void mech_register_module(struct mech_module *module);
 void mech_unregister_module(struct mech_module *module);




More information about the dovecot-cvs mailing list