[dovecot-cvs] dovecot/src/login-common auth-common.c,NONE,1.1 auth-common.h,NONE,1.1 Makefile.am,1.1,1.2 client-common.h,1.1,1.2
cras at procontrol.fi
cras at procontrol.fi
Sun Feb 2 12:46:23 EET 2003
Update of /home/cvs/dovecot/src/login-common
In directory danu:/tmp/cvs-serv5293/login-common
Modified Files:
Makefile.am client-common.h
Added Files:
auth-common.c auth-common.h
Log Message:
Moved more auth code to login-common.
--- NEW FILE: auth-common.c ---
/* Copyright (C) 2002 Timo Sirainen */
#include "common.h"
#include "ioloop.h"
#include "client-common.h"
#include "auth-connection.h"
#include "auth-common.h"
static const char *auth_login_get_str(struct auth_login_reply *reply,
const unsigned char *data, size_t idx)
{
size_t stop;
if (idx >= reply->data_size || idx >= reply->reply_idx)
return NULL;
stop = reply->reply_idx < reply->data_size ?
reply->reply_idx-1 : reply->data_size;
return t_strndup(data, stop);
}
int auth_callback(struct auth_request *request, struct auth_login_reply *reply,
const unsigned char *data, struct client *client,
master_callback_t *master_callback, const char **error)
{
const char *user, *realm;
*error = NULL;
if (reply == NULL) {
/* failed */
auth_request_unref(client->auth_request);
client->auth_request = NULL;
*error = "Authentication process died.";
return -1;
}
switch (reply->result) {
case AUTH_LOGIN_RESULT_CONTINUE:
if (client->auth_request != NULL) {
i_assert(client->auth_request == request);
} else {
i_assert(client->auth_request == NULL);
client->auth_request = request;
auth_request_ref(client->auth_request);
}
return 0;
case AUTH_LOGIN_RESULT_SUCCESS:
auth_request_unref(client->auth_request);
client->auth_request = NULL;
user = auth_login_get_str(reply, data, reply->username_idx);
realm = auth_login_get_str(reply, data, reply->realm_idx);
i_free(client->virtual_user);
client->virtual_user = realm == NULL ?
i_strdup(user) : i_strconcat(user, "@", realm, NULL);
master_request_imap(client, master_callback,
request->conn->pid, request->id);
/* disable IO until we're back from master */
if (client->io != NULL) {
io_remove(client->io);
client->io = NULL;
}
return 1;
case AUTH_LOGIN_RESULT_FAILURE:
/* see if we have error message */
auth_request_unref(client->auth_request);
client->auth_request = NULL;
if (reply->data_size > 0 && data[reply->data_size-1] == '\0') {
*error = t_strconcat("Authentication failed: ",
(const char *) data, NULL);
}
return -1;
}
i_unreached();
}
--- NEW FILE: auth-common.h ---
#ifndef __AUTH_COMMON_H
#define __AUTH_COMMON_H
int auth_callback(struct auth_request *request, struct auth_login_reply *reply,
const unsigned char *data, struct client *client,
master_callback_t *master_callback, const char **error);
#endif
Index: Makefile.am
===================================================================
RCS file: /home/cvs/dovecot/src/login-common/Makefile.am,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Makefile.am 28 Jan 2003 21:35:26 -0000 1.1
+++ Makefile.am 2 Feb 2003 10:46:20 -0000 1.2
@@ -4,6 +4,7 @@
-I$(top_srcdir)/src/lib
liblogin_common_a_SOURCES = \
+ auth-common.c \
auth-connection.c \
main.c \
master.c \
@@ -12,6 +13,7 @@
ssl-proxy-openssl.c
noinst_HEADERS = \
+ auth-common.h \
auth-connection.h \
common.h \
client-common.h \
Index: client-common.h
===================================================================
RCS file: /home/cvs/dovecot/src/login-common/client-common.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- client-common.h 28 Jan 2003 21:35:26 -0000 1.1
+++ client-common.h 2 Feb 2003 10:46:20 -0000 1.2
@@ -2,12 +2,18 @@
#define __CLIENT_COMMON_H
#include "network.h"
+#include "master.h"
struct client {
struct ip_addr ip;
+
int fd;
+ struct io *io;
+ struct auth_request *auth_request;
master_callback_t *master_callback;
+
+ char *virtual_user;
/* ... */
};
More information about the dovecot-cvs
mailing list