[dovecot-cvs] dovecot/src/pop3-login client-authenticate.c,1.2,1.3 client-authenticate.h,1.1,1.2 client.c,1.2,1.3

cras at procontrol.fi cras at procontrol.fi
Thu Jan 30 21:52:41 EET 2003


Update of /home/cvs/dovecot/src/pop3-login
In directory danu:/tmp/cvs-serv21058/pop3-login

Modified Files:
	client-authenticate.c client-authenticate.h client.c 
Log Message:
Support for CAPA command (rfc2449).



Index: client-authenticate.c
===================================================================
RCS file: /home/cvs/dovecot/src/pop3-login/client-authenticate.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- client-authenticate.c	30 Jan 2003 17:56:19 -0000	1.2
+++ client-authenticate.c	30 Jan 2003 19:52:39 -0000	1.3
@@ -10,9 +10,42 @@
 #include "str.h"
 #include "auth-connection.h"
 #include "../auth/auth-mech-desc.h"
+#include "../pop3/capability.h"
 #include "client.h"
 #include "client-authenticate.h"
 #include "master.h"
+
+static enum auth_mech auth_mechs = 0;
+static char *auth_mechs_capability = NULL;
+
+int cmd_capa(struct pop3_client *client, const char *args __attr_unused__)
+{
+	string_t *str;
+	int i;
+
+	if (auth_mechs != available_auth_mechs) {
+		auth_mechs = available_auth_mechs;
+		i_free(auth_mechs_capability);
+
+		str = t_str_new(128);
+
+		str_append(str, "SASL");
+		for (i = 0; i < AUTH_MECH_COUNT; i++) {
+			if ((auth_mechs & auth_mech_desc[i].mech) &&
+			    auth_mech_desc[i].name != NULL) {
+				str_append_c(str, ' ');
+				str_append(str, auth_mech_desc[i].name);
+			}
+		}
+
+		auth_mechs_capability = i_strdup(str_c(str));
+	}
+
+	client_send_line(client, t_strconcat("+OK\r\n" POP3_CAPABILITY_REPLY,
+					     auth_mechs_capability,
+					     "\r\n.", NULL));
+	return TRUE;
+}
 
 static struct auth_mech_desc *auth_mech_find(const char *name)
 {

Index: client-authenticate.h
===================================================================
RCS file: /home/cvs/dovecot/src/pop3-login/client-authenticate.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- client-authenticate.h	28 Jan 2003 21:35:26 -0000	1.1
+++ client-authenticate.h	30 Jan 2003 19:52:39 -0000	1.2
@@ -1,6 +1,7 @@
 #ifndef __CLIENT_AUTHENTICATE_H
 #define __CLIENT_AUTHENTICATE_H
 
+int cmd_capa(struct pop3_client *client, const char *args);
 int cmd_user(struct pop3_client *client, const char *args);
 int cmd_pass(struct pop3_client *client, const char *args);
 int cmd_auth(struct pop3_client *client, const char *args);

Index: client.c
===================================================================
RCS file: /home/cvs/dovecot/src/pop3-login/client.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- client.c	30 Jan 2003 17:56:19 -0000	1.2
+++ client.c	30 Jan 2003 19:52:39 -0000	1.3
@@ -104,6 +104,8 @@
 				  const char *args)
 {
 	cmd = str_ucase(t_strdup_noconst(cmd));
+	if (strcmp(cmd, "CAPA") == 0)
+		return cmd_capa(client, args);
 	if (strcmp(cmd, "USER") == 0)
 		return cmd_user(client, args);
 	if (strcmp(cmd, "PASS") == 0)




More information about the dovecot-cvs mailing list