[dovecot-cvs] dovecot/src/auth mech-anonymous.c,NONE,1.1 Makefile.am,1.18,1.19 auth-login-interface.h,1.4,1.5 auth-mech-desc.h,1.1,1.2 mech.c,1.10,1.11 mech.h,1.8,1.9
cras at procontrol.fi
cras at procontrol.fi
Thu May 8 07:24:59 EEST 2003
Update of /home/cvs/dovecot/src/auth
In directory danu:/tmp/cvs-serv782/src/auth
Modified Files:
Makefile.am auth-login-interface.h auth-mech-desc.h mech.c
mech.h
Added Files:
mech-anonymous.c
Log Message:
Added support for ANONYMOUS SASL mechanism.
--- NEW FILE: mech-anonymous.c ---
/* Copyright (C) 2002 Timo Sirainen */
#include "common.h"
#include "mech.h"
static int
mech_anonymous_auth_continue(struct auth_request *auth_request,
struct auth_login_request_continue *request,
const unsigned char *data,
mech_callback_t *callback)
{
i_assert(anonymous_username != NULL);
if (verbose) {
i_info("mech-anonymous: login by %s",
t_strndup(data, request->data_size));
}
auth_request->callback = callback;
auth_request->user = p_strdup(auth_request->pool, anonymous_username);
mech_auth_finish(auth_request, NULL, 0, TRUE);
return TRUE;
}
static void
mech_anonymous_auth_free(struct auth_request *auth_request)
{
pool_unref(auth_request->pool);
}
static struct auth_request *
mech_anonymous_auth_new(struct login_connection *conn, unsigned int id,
mech_callback_t *callback)
{
struct auth_request *auth_request;
struct auth_login_reply reply;
pool_t pool;
pool = pool_alloconly_create("anonymous_auth_request", 256);
auth_request = p_new(pool, struct auth_request, 1);
auth_request->pool = pool;
auth_request->auth_continue = mech_anonymous_auth_continue;
auth_request->auth_free = mech_anonymous_auth_free;
/* initialize reply */
memset(&reply, 0, sizeof(reply));
reply.id = id;
reply.result = AUTH_LOGIN_RESULT_CONTINUE;
callback(&reply, NULL, conn);
return auth_request;
}
struct mech_module mech_anonymous = {
AUTH_MECH_ANONYMOUS,
mech_anonymous_auth_new
};
Index: Makefile.am
===================================================================
RCS file: /home/cvs/dovecot/src/auth/Makefile.am,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- Makefile.am 4 Apr 2003 14:40:14 -0000 1.18
+++ Makefile.am 8 May 2003 03:24:57 -0000 1.19
@@ -28,6 +28,7 @@
master-connection.c \
md5crypt.c \
mech.c \
+ mech-anonymous.c \
mech-cyrus-sasl2.c \
mech-plain.c \
mech-digest-md5.c \
Index: auth-login-interface.h
===================================================================
RCS file: /home/cvs/dovecot/src/auth/auth-login-interface.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- auth-login-interface.h 18 Feb 2003 19:11:26 -0000 1.4
+++ auth-login-interface.h 8 May 2003 03:24:57 -0000 1.5
@@ -11,6 +11,7 @@
enum auth_mech {
AUTH_MECH_PLAIN = 0x01,
AUTH_MECH_DIGEST_MD5 = 0x02,
+ AUTH_MECH_ANONYMOUS = 0x04,
AUTH_MECH_COUNT
};
Index: auth-mech-desc.h
===================================================================
RCS file: /home/cvs/dovecot/src/auth/auth-mech-desc.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- auth-mech-desc.h 5 Jan 2003 15:19:50 -0000 1.1
+++ auth-mech-desc.h 8 May 2003 03:24:57 -0000 1.2
@@ -10,7 +10,8 @@
static struct auth_mech_desc auth_mech_desc[AUTH_MECH_COUNT] = {
{ AUTH_MECH_PLAIN, "PLAIN", TRUE, FALSE },
- { AUTH_MECH_DIGEST_MD5, "DIGEST-MD5", FALSE, TRUE }
+ { AUTH_MECH_DIGEST_MD5, "DIGEST-MD5", FALSE, TRUE },
+ { AUTH_MECH_ANONYMOUS, "ANONYMOUS", FALSE, TRUE }
};
#endif
Index: mech.c
===================================================================
RCS file: /home/cvs/dovecot/src/auth/mech.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- mech.c 2 Apr 2003 02:09:41 -0000 1.10
+++ mech.c 8 May 2003 03:24:57 -0000 1.11
@@ -18,6 +18,7 @@
enum auth_mech auth_mechanisms;
const char *const *auth_realms;
const char *default_realm;
+const char *anonymous_username;
char username_chars[256];
static int set_use_cyrus_sasl;
@@ -201,6 +202,7 @@
extern struct mech_module mech_plain;
extern struct mech_module mech_digest_md5;
+extern struct mech_module mech_anonymous;
void mech_init(void)
{
@@ -213,6 +215,10 @@
memset(&failure_reply, 0, sizeof(failure_reply));
failure_reply.result = AUTH_LOGIN_RESULT_FAILURE;
+ anonymous_username = getenv("ANONYMOUS_USERNAME");
+ if (anonymous_username != NULL && *anonymous_username == '\0')
+ anonymous_username = NULL;
+
/* register wanted mechanisms */
env = getenv("MECHANISMS");
if (env == NULL || *env == '\0')
@@ -224,7 +230,13 @@
mech_register_module(&mech_plain);
else if (strcasecmp(*mechanisms, "DIGEST-MD5") == 0)
mech_register_module(&mech_digest_md5);
- else {
+ else if (strcasecmp(*mechanisms, "ANONYMOUS") == 0) {
+ if (anonymous_username == NULL) {
+ i_fatal("ANONYMOUS listed in mechanisms, "
+ "but anonymous_username not given");
+ }
+ mech_register_module(&mech_anonymous);
+ } else {
i_fatal("Unknown authentication mechanism '%s'",
*mechanisms);
}
@@ -258,7 +270,6 @@
}
set_use_cyrus_sasl = getenv("USE_CYRUS_SASL") != NULL;
-
#ifdef USE_CYRUS_SASL2
if (set_use_cyrus_sasl)
mech_cyrus_sasl_init_lib();
@@ -269,4 +280,5 @@
{
mech_unregister_module(&mech_plain);
mech_unregister_module(&mech_digest_md5);
+ mech_unregister_module(&mech_anonymous);
}
Index: mech.h
===================================================================
RCS file: /home/cvs/dovecot/src/auth/mech.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- mech.h 2 Apr 2003 02:09:41 -0000 1.8
+++ mech.h 8 May 2003 03:24:57 -0000 1.9
@@ -38,6 +38,7 @@
extern enum auth_mech auth_mechanisms;
extern const char *const *auth_realms;
extern const char *default_realm;
+extern const char *anonymous_username;
extern char username_chars[256];
void mech_register_module(struct mech_module *module);
More information about the dovecot-cvs
mailing list