[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
cras at procontrol.fi
cras at procontrol.fi
Fri Aug 22 06:42:15 EEST 2003
- Previous message: [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
- Next message: [dovecot-cvs]
dovecot/src/lib-auth .cvsignore,NONE,1.1 Makefile.am,NONE,1.1
auth-client.c,NONE,1.1 auth-client.h,NONE,1.1
auth-server-connection.c,NONE,1.1 auth-server-connection.h,NONE,1.1
auth-server-request.c,NONE,1.1 auth-server-request.h,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/dovecot/src/pop3-login
In directory danu:/tmp/cvs-serv8684/src/pop3-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/pop3-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,10 +4,12 @@
INCLUDES = \
-I$(top_srcdir)/src/lib \
+ -I$(top_srcdir)/src/lib-auth \
-I$(top_srcdir)/src/login-common
pop3_login_LDADD = \
../login-common/liblogin-common.a \
+ ../lib-auth/libauth.a \
../lib/liblib.a \
$(SSL_LIBS)
@@ -16,6 +18,5 @@
client-authenticate.c
noinst_HEADERS = \
- common.h \
client.h \
client-authenticate.h
Index: client-authenticate.c
===================================================================
RCS file: /home/cvs/dovecot/src/pop3-login/client-authenticate.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- client-authenticate.c 20 Aug 2003 03:17:25 -0000 1.9
+++ client-authenticate.c 22 Aug 2003 02:42:13 -0000 1.10
@@ -8,7 +8,7 @@
#include "ostream.h"
#include "safe-memset.h"
#include "str.h"
-#include "auth-connection.h"
+#include "auth-client.h"
#include "../auth/auth-mech-desc.h"
#include "../pop3/capability.h"
#include "master.h"
@@ -17,17 +17,18 @@
#include "client-authenticate.h"
#include "ssl-proxy.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__)
{
+ 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) {
- auth_mechs = available_auth_mechs;
- i_free(auth_mechs_capability);
+ auth_mechs = auth_client_get_available_mechs(auth_client);
+ if (cached_auth_mechs != auth_mechs) {
+ cached_auth_mechs = auth_mechs;
+ i_free(cached_capability);
str = t_str_new(128);
@@ -42,13 +43,13 @@
}
}
- auth_mechs_capability = i_strdup(str_c(str));
+ cached_capability = i_strdup(str_c(str));
}
client_send_line(client, t_strconcat("+OK\r\n" POP3_CAPABILITY_REPLY,
(ssl_initialized && !client->tls) ?
"STLS\r\n" : "",
- auth_mechs_capability,
+ cached_capability,
"\r\n.", NULL));
return TRUE;
}
@@ -69,7 +70,7 @@
static void client_auth_abort(struct pop3_client *client, const char *msg)
{
if (client->common.auth_request != NULL) {
- auth_abort_request(client->common.auth_request);
+ auth_client_request_abort(client->common.auth_request);
client->common.auth_request = NULL;
}
@@ -82,8 +83,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)
@@ -101,7 +100,6 @@
}
client_destroy(client, reason);
- client_unref(client);
}
static void client_send_auth_data(struct pop3_client *client,
@@ -124,15 +122,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 pop3_client *client = (struct pop3_client *) _client;
+ struct pop3_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 */
@@ -141,7 +139,7 @@
case 0:
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;
@@ -182,9 +180,11 @@
buffer_append_c(client->plain_login, '\0');
buffer_append(client->plain_login, args, strlen(args));
- client_ref(client);
- if (auth_init_request(AUTH_MECH_PLAIN, AUTH_PROTOCOL_POP3,
- login_callback, &client->common, &error)) {
+ client->common.auth_request =
+ auth_client_request_new(auth_client, AUTH_MECH_PLAIN,
+ AUTH_PROTOCOL_POP3,
+ login_callback, client, &error);
+ if (client->common.auth_request != NULL) {
/* don't read any input from client until login is finished */
if (client->common.io != NULL) {
io_remove(client->common.io);
@@ -194,20 +194,18 @@
} else {
client_send_line(client,
t_strconcat("-ERR Login failed: ", error, NULL));
- client_unref(client);
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 pop3_client *client = (struct pop3_client *) _client;
+ struct pop3_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 */
@@ -255,9 +253,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 */
@@ -286,9 +284,11 @@
return TRUE;
}
- client_ref(client);
- if (auth_init_request(mech->mech, AUTH_PROTOCOL_POP3,
- authenticate_callback, &client->common, &error)) {
+ client->common.auth_request =
+ auth_client_request_new(auth_client, mech->mech,
+ AUTH_PROTOCOL_POP3,
+ 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);
@@ -297,7 +297,6 @@
} else {
client_send_line(client, t_strconcat(
"-ERR Authentication failed: ", error, NULL));
- client_unref(client);
}
return TRUE;
Index: client.c
===================================================================
RCS file: /home/cvs/dovecot/src/pop3-login/client.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- client.c 23 May 2003 14:40:51 -0000 1.13
+++ client.c 22 Aug 2003 02:42:13 -0000 1.14
@@ -11,7 +11,7 @@
#include "strescape.h"
#include "client.h"
#include "client-authenticate.h"
-#include "auth-connection.h"
+#include "auth-client.h"
#include "ssl-proxy.h"
/* max. length of input command line (spec says 512) */
@@ -35,6 +35,8 @@
static struct hash_table *clients;
static struct timeout *to_idle;
+static int client_unref(struct pop3_client *client);
+
static void client_set_title(struct pop3_client *client)
{
const char *addr;
@@ -157,14 +159,14 @@
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->input_blocked = TRUE;
return;
}
- client_ref(client);
+ client->refcount++;
o_stream_cork(client->output);
while (!client->output->closed &&
@@ -280,6 +282,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;
@@ -291,12 +301,7 @@
client_unref(client);
}
-void client_ref(struct pop3_client *client)
-{
- client->refcount++;
-}
-
-int client_unref(struct pop3_client *client)
+static int client_unref(struct pop3_client *client)
{
if (--client->refcount > 0)
return TRUE;
@@ -359,7 +364,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/pop3-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:08 -0000 1.4
+++ client.h 22 Aug 2003 02:42:13 -0000 1.5
@@ -27,9 +27,6 @@
struct client *client_create(int fd, struct ip_addr *ip, int ssl);
void client_destroy(struct pop3_client *client, const char *reason);
-void client_ref(struct pop3_client *client);
-int client_unref(struct pop3_client *client);
-
void client_send_line(struct pop3_client *client, const char *line);
void client_syslog(struct pop3_client *client, const char *text);
--- common.h DELETED ---
- Previous message: [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
- Next message: [dovecot-cvs]
dovecot/src/lib-auth .cvsignore,NONE,1.1 Makefile.am,NONE,1.1
auth-client.c,NONE,1.1 auth-client.h,NONE,1.1
auth-server-connection.c,NONE,1.1 auth-server-connection.h,NONE,1.1
auth-server-request.c,NONE,1.1 auth-server-request.h,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list