[dovecot-cvs] dovecot/src/auth auth-client-interface.h, 1.3, 1.4 mech.c, 1.20, 1.21 mech.h, 1.14, 1.15 passdb-pam.c, 1.13, 1.14 passdb-vpopmail.c, 1.4, 1.5

cras at procontrol.fi cras at procontrol.fi
Sat May 29 20:06:52 EEST 2004


Update of /home/cvs/dovecot/src/auth
In directory talvi:/tmp/cvs-serv26071/auth

Modified Files:
	auth-client-interface.h mech.c mech.h passdb-pam.c 
	passdb-vpopmail.c 
Log Message:
Don't use hardcoded protocol list for auth process, string is just fine.



Index: auth-client-interface.h
===================================================================
RCS file: /home/cvs/dovecot/src/auth/auth-client-interface.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- a/auth-client-interface.h	17 May 2004 01:32:16 -0000	1.3
+++ b/auth-client-interface.h	29 May 2004 17:06:50 -0000	1.4
@@ -4,6 +4,9 @@
 /* max. size for auth_client_request_continue.data[] */
 #define AUTH_CLIENT_MAX_REQUEST_DATA_SIZE 4096
 
+/* sizeof(struct auth_client_request_new->protocol) */
+#define AUTH_CLIENT_PROTOCOL_BUF_SIZE 12
+
 /* Client process must finish with single authentication requests in this time,
    or the whole connection will be killed. */
 #define AUTH_REQUEST_TIMEOUT 120
@@ -17,11 +20,6 @@
 	AUTH_MECH_COUNT
 };
 
-enum auth_protocol {
-	AUTH_PROTOCOL_IMAP	= 0x01,
-	AUTH_PROTOCOL_POP3	= 0x02
-};
-
 enum auth_client_request_new_flags {
 	AUTH_CLIENT_FLAG_SSL_VALID_CLIENT_CERT = 0x01
 };
@@ -54,8 +52,8 @@
 	unsigned int id; /* unique ID for the request */
 
 	enum auth_mech mech;
-	enum auth_protocol protocol;
-        enum auth_client_request_new_flags flags;
+	enum auth_client_request_new_flags flags;
+	char protocol[AUTH_CLIENT_PROTOCOL_BUF_SIZE];
 };
 
 /* Continue authentication request */

Index: mech.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/mech.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- a/mech.c	29 May 2004 16:43:22 -0000	1.20
+++ b/mech.c	29 May 2004 17:06:50 -0000	1.21
@@ -110,7 +110,8 @@
 		auth_request->created = ioloop_time;
 		auth_request->conn = conn;
 		auth_request->id = request->id;
-		auth_request->protocol = request->protocol;
+		strocpy(auth_request->protocol, request->protocol,
+			sizeof(auth_request->protocol));
 
 		hash_insert(conn->auth_requests, POINTER_CAST(request->id),
 			    auth_request);
@@ -260,16 +261,7 @@
 	tab[2].value = strchr(auth_request->user, '@');
 	if (tab[2].value != NULL)
 		tab[2].value = escape_func(tab[2].value+1);
-
-	switch (auth_request->protocol) {
-	case AUTH_PROTOCOL_IMAP:
-		tab[3].value = "IMAP";
-		break;
-	case AUTH_PROTOCOL_POP3:
-		tab[3].value = "POP3";
-		break;
-	}
-
+	tab[3].value = auth_request->protocol;
 	return tab;
 }
 

Index: mech.h
===================================================================
RCS file: /home/cvs/dovecot/src/auth/mech.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- a/mech.h	24 May 2004 22:33:50 -0000	1.14
+++ b/mech.h	29 May 2004 17:06:50 -0000	1.15
@@ -19,7 +19,7 @@
 	unsigned int id;
 	time_t created;
 
-	enum auth_protocol protocol;
+	char protocol[AUTH_CLIENT_PROTOCOL_BUF_SIZE];
 	mech_callback_t *callback;
 
 	int (*auth_continue)(struct auth_request *auth_request,

Index: passdb-pam.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/passdb-pam.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- a/passdb-pam.c	24 Sep 2003 10:16:46 -0000	1.13
+++ b/passdb-pam.c	29 May 2004 17:06:50 -0000	1.14
@@ -330,14 +330,7 @@
 	int fd[2];
 	pid_t pid;
 
-	service = service_name != NULL ? service_name :
-		request->protocol == AUTH_PROTOCOL_IMAP ? "imap" :
-		request->protocol == AUTH_PROTOCOL_POP3 ? "pop3" : NULL;
-	if (service == NULL) {
-		i_error("Unknown protocol %d in auth request",
-			request->protocol);
-	}
-
+	service = service_name != NULL ? service_name : request->protocol;
 	if (pipe(fd) < 0) {
 		i_error("PAM: pipe() failed: %m");
 		callback(PASSDB_RESULT_INTERNAL_FAILURE, request);

Index: passdb-vpopmail.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/passdb-vpopmail.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- a/passdb-vpopmail.c	18 Feb 2003 19:11:26 -0000	1.4
+++ b/passdb-vpopmail.c	29 May 2004 17:06:50 -0000	1.5
@@ -30,14 +30,12 @@
 	}
 
 	if (((vpw->pw_gid & NO_IMAP) != 0 &&
-	     request->protocol == AUTH_PROTOCOL_IMAP) ||
+	     strcmp(request->protocol, "IMAP") == 0) ||
 	    ((vpw->pw_gid & NO_POP) != 0 &&
-	     request->protocol == AUTH_PROTOCOL_POP3)) {
+	     strcmp(request->protocol, "POP3") == 0)) {
 		if (verbose) {
 			i_info("vpopmail(%s@%s): %s disabled",
-			       vpop_user, vpop_domain,
-			       request->protocol == AUTH_PROTOCOL_IMAP ?
-			       "IMAP" : "POP3");
+			       vpop_user, vpop_domain, request->protocol);
 		}
 		callback(PASSDB_RESULT_USER_DISABLED, request);
 		return;



More information about the dovecot-cvs mailing list