[dovecot-cvs] dovecot/src/login-common sasl-server.c, 1.2, 1.3 sasl-server.h, 1.2, 1.3

cras at dovecot.org cras at dovecot.org
Mon Oct 18 04:13:28 EEST 2004


Update of /var/lib/cvs/dovecot/src/login-common
In directory talvi:/tmp/cvs-serv24063/src/login-common

Modified Files:
	sasl-server.c sasl-server.h 
Log Message:
Implemented support for LOGIN-REFERRALS using "referral" and "reason"
parameters from auth server.



Index: sasl-server.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/login-common/sasl-server.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- sasl-server.c	13 Oct 2004 16:38:35 -0000	1.2
+++ sasl-server.c	18 Oct 2004 01:13:26 -0000	1.3
@@ -28,11 +28,8 @@
 static void master_callback(struct client *client, int success)
 {
 	client->authenticating = FALSE;
-	i_free(client->auth_mech_name);
-	client->auth_mech_name = NULL;
-
 	client->sasl_callback(client, success ? SASL_SERVER_REPLY_SUCCESS :
-			      SASL_SERVER_REPLY_MASTER_FAILED, NULL);
+			      SASL_SERVER_REPLY_MASTER_FAILED, NULL, NULL);
 }
 
 static void authenticate_callback(struct auth_request *request, int status,
@@ -40,7 +37,8 @@
 				  const char *const *args, void *context)
 {
 	struct client *client = context;
-	const char *error;
+	unsigned int i;
+	int nologin;
 
 	if (!client->authenticating) {
 		/* client aborted */
@@ -60,33 +58,47 @@
 		}
 
 		client->sasl_callback(client, SASL_SERVER_REPLY_CONTINUE,
-				      data_base64);
+				      data_base64, NULL);
 		break;
 	case 1:
 		client->auth_request = NULL;
 
-		for (; *args != NULL; args++) {
-			if (strncmp(*args, "user=", 5) == 0) {
+		nologin = FALSE;
+		for (i = 0; args[i] != NULL; i++) {
+			if (strncmp(args[i], "user=", 5) == 0) {
 				i_free(client->virtual_user);
-				client->virtual_user = i_strdup(*args + 5);
+				client->virtual_user = i_strdup(args[i] + 5);
+			}
+			if (strcmp(args[i], "nologin") == 0) {
+				/* user can't login */
+				nologin = TRUE;
 			}
 		}
 
-		master_request_login(client, master_callback,
+		if (nologin) {
+			client->authenticating = FALSE;
+			client->sasl_callback(client, SASL_SERVER_REPLY_SUCCESS,
+					      NULL, args);
+		} else {
+			master_request_login(client, master_callback,
 				auth_client_request_get_server_pid(request),
 				auth_client_request_get_id(request));
+		}
 		break;
 	case -1:
 		client->auth_request = NULL;
 
-		/* see if we have error message */
-		if (data_base64 != NULL) {
-			error = t_strconcat("Authentication failed: ",
-					    (const char *)data_base64, NULL);
-		} else {
-			error = NULL;
+		/* base64 contains error message, if there is one */
+		if (verbose_auth && data_base64 != NULL) {
+			client_syslog(client, "Authenticate %s failed: %s",
+				      str_sanitize(client->auth_mech_name,
+						   MAX_MECH_NAME),
+				      (const char *)data_base64);
 		}
-		sasl_server_auth_cancel(client, error);
+
+		client->authenticating = FALSE;
+		client->sasl_callback(client, SASL_SERVER_REPLY_AUTH_FAILED,
+				      (const char *)data_base64, args);
 		break;
 	}
 }
@@ -101,6 +113,7 @@
 	const char *error;
 
 	client->authenticating = TRUE;
+	i_free(client->auth_mech_name);
 	client->auth_mech_name = i_strdup(mech_name);
 	client->sasl_callback = callback;
 
@@ -144,13 +157,12 @@
 	}
 
 	client->authenticating = FALSE;
-	i_free(client->auth_mech_name);
-	client->auth_mech_name = NULL;
 
 	if (client->auth_request != NULL) {
 		auth_client_request_abort(client->auth_request);
 		client->auth_request = NULL;
 	}
 
-	client->sasl_callback(client, SASL_SERVER_REPLY_AUTH_FAILED, reason);
+	client->sasl_callback(client, SASL_SERVER_REPLY_AUTH_FAILED,
+			      reason, NULL);
 }

Index: sasl-server.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/login-common/sasl-server.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- sasl-server.h	13 Oct 2004 16:38:35 -0000	1.2
+++ sasl-server.h	18 Oct 2004 01:13:26 -0000	1.3
@@ -10,7 +10,7 @@
 
 typedef void sasl_server_callback_t(struct client *client,
 				    enum sasl_server_reply reply,
-				    const char *data);
+				    const char *data, const char *const *args);
 
 void sasl_server_auth_begin(struct client *client,
 			    const char *protocol, const char *mech_name,



More information about the dovecot-cvs mailing list