[dovecot-cvs] dovecot/src/imap-login Makefile.am,1.2,1.3
client-authenticate.c,1.8,1.9 client.c,1.16,1.17 client.h,1.4,1.5
common.h,1.1,NONE
cras at procontrol.fi
cras at procontrol.fi
Fri Aug 22 06:42:15 EEST 2003
- Previous message: [dovecot-cvs]
dovecot/src/login-common Makefile.am,1.4,1.5 auth-common.c,1.4,1.5
auth-common.h,1.1,1.2 client-common.h,1.3,1.4 common.h,1.2,1.3
main.c,1.12,1.13 master.c,1.6,1.7 master.h,1.3,1.4
auth-connection.c,1.13,NONE auth-connection.h,1.4,NONE
- Next message: [dovecot-cvs] dovecot/src/pop3-login Makefile.am,1.2,1.3
client-authenticate.c,1.9,1.10 client.c,1.13,1.14 client.h,1.4,1.5
common.h,1.1,NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/dovecot/src/imap-login
In directory danu:/tmp/cvs-serv8684/src/imap-login
Modified Files:
Makefile.am client-authenticate.c client.c client.h
Removed Files:
common.h
Log Message:
Moved client side code for auth process handling to lib-auth. Some other login process cleanups.
Index: Makefile.am
===================================================================
RCS file: /home/cvs/dovecot/src/imap-login/Makefile.am,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Makefile.am 4 Feb 2003 03:25:44 -0000 1.2
+++ Makefile.am 22 Aug 2003 02:42:13 -0000 1.3
@@ -4,12 +4,14 @@
INCLUDES = \
-I$(top_srcdir)/src/lib \
+ -I$(top_srcdir)/src/lib-auth \
-I$(top_srcdir)/src/lib-imap \
-I$(top_srcdir)/src/login-common
imap_login_LDADD = \
../login-common/liblogin-common.a \
../lib-imap/imap-parser.o \
+ ../lib-auth/libauth.a \
../lib/liblib.a \
$(SSL_LIBS)
@@ -18,6 +20,5 @@
client-authenticate.c
noinst_HEADERS = \
- common.h \
client.h \
client-authenticate.h
Index: client-authenticate.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap-login/client-authenticate.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- client-authenticate.c 23 May 2003 14:40:50 -0000 1.8
+++ client-authenticate.c 22 Aug 2003 02:42:13 -0000 1.9
@@ -9,26 +9,27 @@
#include "safe-memset.h"
#include "str.h"
#include "imap-parser.h"
-#include "auth-connection.h"
+#include "auth-client.h"
#include "../auth/auth-mech-desc.h"
#include "client.h"
#include "client-authenticate.h"
#include "auth-common.h"
#include "master.h"
-static enum auth_mech auth_mechs = 0;
-static char *auth_mechs_capability = NULL;
-
const char *client_authenticate_get_capabilities(int tls)
{
+ static enum auth_mech cached_auth_mechs = 0;
+ static char *cached_capability = NULL;
+ enum auth_mech auth_mechs;
string_t *str;
int i;
- if (auth_mechs == available_auth_mechs)
- return auth_mechs_capability;
+ auth_mechs = auth_client_get_available_mechs(auth_client);
+ if (auth_mechs == cached_auth_mechs)
+ return cached_capability;
- auth_mechs = available_auth_mechs;
- i_free(auth_mechs_capability);
+ cached_auth_mechs = auth_mechs;
+ i_free(cached_capability);
str = t_str_new(128);
@@ -43,8 +44,8 @@
}
}
- auth_mechs_capability = i_strdup_empty(str_c(str));
- return auth_mechs_capability;
+ cached_capability = i_strdup_empty(str_c(str));
+ return cached_capability;
}
static struct auth_mech_desc *auth_mech_find(const char *name)
@@ -65,8 +66,7 @@
client->authenticating = FALSE;
if (client->common.auth_request != NULL) {
- auth_abort_request(client->common.auth_request);
- auth_request_unref(client->common.auth_request);
+ auth_client_request_abort(client->common.auth_request);
client->common.auth_request = NULL;
}
@@ -80,8 +80,6 @@
io_remove(client->common.io);
client->common.io = client->common.fd == -1 ? NULL :
io_add(client->common.fd, IO_READ, client_input, client);
-
- client_unref(client);
}
static void master_callback(struct client *_client, int success)
@@ -99,7 +97,6 @@
}
client_destroy(client, reason);
- client_unref(client);
}
static void client_send_auth_data(struct imap_client *client,
@@ -122,15 +119,15 @@
}
static void login_callback(struct auth_request *request,
- struct auth_login_reply *reply,
- const unsigned char *data, struct client *_client)
+ struct auth_client_request_reply *reply,
+ const unsigned char *data, void *context)
{
- struct imap_client *client = (struct imap_client *) _client;
+ struct imap_client *client = context;
const char *error;
const void *ptr;
size_t size;
- switch (auth_callback(request, reply, data, _client,
+ switch (auth_callback(request, reply, data, &client->common,
master_callback, &error)) {
case -1:
/* login failed */
@@ -140,7 +137,7 @@
case 0:
/* continue */
ptr = buffer_get_data(client->plain_login, &size);
- auth_continue_request(request, ptr, size);
+ auth_client_request_continue(request, ptr, size);
buffer_set_used_size(client->plain_login, 0);
break;
@@ -184,33 +181,34 @@
buffer_append_c(client->plain_login, '\0');
buffer_append(client->plain_login, pass, strlen(pass));
- client_ref(client);
- if (auth_init_request(AUTH_MECH_PLAIN, AUTH_PROTOCOL_IMAP,
- login_callback, &client->common, &error)) {
- /* don't read any input from client until login is finished */
- if (client->common.io != NULL) {
- io_remove(client->common.io);
- client->common.io = NULL;
- }
- client->authenticating = TRUE;
- return TRUE;
- } else {
+ client->common.auth_request =
+ auth_client_request_new(auth_client, AUTH_MECH_PLAIN,
+ AUTH_PROTOCOL_IMAP, login_callback,
+ client, &error);
+ if (client->common.auth_request == NULL) {
client_send_tagline(client, t_strconcat(
"NO Login failed: ", error, NULL));
- client_unref(client);
return TRUE;
}
+
+ /* don't read any input from client until login is finished */
+ if (client->common.io != NULL) {
+ io_remove(client->common.io);
+ client->common.io = NULL;
+ }
+
+ client->authenticating = TRUE;
+ return TRUE;
}
static void authenticate_callback(struct auth_request *request,
- struct auth_login_reply *reply,
- const unsigned char *data,
- struct client *_client)
+ struct auth_client_request_reply *reply,
+ const unsigned char *data, void *context)
{
- struct imap_client *client = (struct imap_client *) _client;
+ struct imap_client *client = context;
const char *error;
- switch (auth_callback(request, reply, data, _client,
+ switch (auth_callback(request, reply, data, &client->common,
master_callback, &error)) {
case -1:
/* login failed */
@@ -266,9 +264,9 @@
} else if (client->common.auth_request == NULL) {
client_auth_abort(client, "Don't send unrequested data");
} else {
- auth_continue_request(client->common.auth_request,
- buffer_get_data(buf, NULL),
- buffer_get_used_size(buf));
+ auth_client_request_continue(client->common.auth_request,
+ buffer_get_data(buf, NULL),
+ buffer_get_used_size(buf));
}
/* clear sensitive data */
@@ -306,9 +304,12 @@
return TRUE;
}
- client_ref(client);
- if (auth_init_request(mech->mech, AUTH_PROTOCOL_IMAP,
- authenticate_callback, &client->common, &error)) {
+ client->common.auth_request =
+ auth_client_request_new(auth_client, mech->mech,
+ AUTH_PROTOCOL_IMAP,
+ authenticate_callback,
+ client, &error);
+ if (client->common.auth_request != NULL) {
/* following input data will go to authentication */
if (client->common.io != NULL)
io_remove(client->common.io);
@@ -318,7 +319,6 @@
} else {
client_send_tagline(client, t_strconcat(
"NO Authentication failed: ", error, NULL));
- client_unref(client);
}
return TRUE;
Index: client.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap-login/client.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- client.c 2 Jul 2003 00:57:24 -0000 1.16
+++ client.c 22 Aug 2003 02:42:13 -0000 1.17
@@ -12,7 +12,7 @@
#include "imap-parser.h"
#include "client.h"
#include "client-authenticate.h"
-#include "auth-connection.h"
+#include "auth-client.h"
#include "ssl-proxy.h"
/* max. size of one parameter in line */
@@ -41,6 +41,8 @@
static struct hash_table *clients;
static struct timeout *to_idle;
+static int client_unref(struct imap_client *client);
+
static void client_set_title(struct imap_client *client)
{
const char *addr;
@@ -275,7 +277,7 @@
if (!client_read(client))
return;
- if (!auth_is_connected()) {
+ if (!auth_client_is_connected(auth_client)) {
/* we're not yet connected to auth process -
don't allow any commands */
client_send_line(client,
@@ -284,7 +286,7 @@
return;
}
- client_ref(client);
+ client->refcount++;
o_stream_cork(client->output);
while (client_handle_input(client)) ;
@@ -386,6 +388,14 @@
i_stream_close(client->input);
o_stream_close(client->output);
+ if (client->common.auth_request != NULL) {
+ auth_client_request_abort(client->common.auth_request);
+ client->common.auth_request = NULL;
+ }
+
+ if (client->common.master_tag != 0)
+ master_request_abort(&client->common);
+
if (client->common.io != NULL) {
io_remove(client->common.io);
client->common.io = NULL;
@@ -399,12 +409,7 @@
client_unref(client);
}
-void client_ref(struct imap_client *client)
-{
- client->refcount++;
-}
-
-int client_unref(struct imap_client *client)
+static int client_unref(struct imap_client *client)
{
if (--client->refcount > 0)
return TRUE;
@@ -476,7 +481,7 @@
}
}
-void clients_notify_auth_process(void)
+void clients_notify_auth_connected(void)
{
hash_foreach(clients, client_hash_check_io, NULL);
}
Index: client.h
===================================================================
RCS file: /home/cvs/dovecot/src/imap-login/client.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- client.h 4 Mar 2003 22:38:07 -0000 1.4
+++ client.h 22 Aug 2003 02:42:13 -0000 1.5
@@ -33,9 +33,6 @@
struct client *client_create(int fd, struct ip_addr *ip, int ssl);
void client_destroy(struct imap_client *client, const char *reason);
-void client_ref(struct imap_client *client);
-int client_unref(struct imap_client *client);
-
void client_send_line(struct imap_client *client, const char *line);
void client_send_tagline(struct imap_client *client, const char *line);
void client_syslog(struct imap_client *client, const char *text);
--- common.h DELETED ---
- Previous message: [dovecot-cvs]
dovecot/src/login-common Makefile.am,1.4,1.5 auth-common.c,1.4,1.5
auth-common.h,1.1,1.2 client-common.h,1.3,1.4 common.h,1.2,1.3
main.c,1.12,1.13 master.c,1.6,1.7 master.h,1.3,1.4
auth-connection.c,1.13,NONE auth-connection.h,1.4,NONE
- Next message: [dovecot-cvs] dovecot/src/pop3-login Makefile.am,1.2,1.3
client-authenticate.c,1.9,1.10 client.c,1.13,1.14 client.h,1.4,1.5
common.h,1.1,NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list