[dovecot-cvs] dovecot/src/login auth-connection.c,1.21,1.22 auth-connection.h,1.9,1.10 client-authenticate.c,1.33,1.34 client.h,1.13,1.14 common.h,1.6,1.7 master.c,1.12,1.13 master.h,1.7,1.8

cras at procontrol.fi cras at procontrol.fi
Mon Jan 27 03:33:43 EET 2003


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

Modified Files:
	auth-connection.c auth-connection.h client-authenticate.c 
	client.h common.h master.c master.h 
Log Message:
We have now separate "userdb" and "passdb". They aren't tied to each others
in any way, so it's possible to use whatever user database with whatever
password database.

Added "static" userdb, which uses same uid/gid for everyone and generates
home directory from given template. This could be useful with PAM, although
insecure since everyone uses same uid.

Not too well tested, and userdb/passdb API still needs to be changed to
asynchronous for sql/ldap/etc lookups.



Index: auth-connection.c
===================================================================
RCS file: /home/cvs/dovecot/src/login/auth-connection.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- auth-connection.c	11 Jan 2003 19:55:57 -0000	1.21
+++ auth-connection.c	27 Jan 2003 01:33:40 -0000	1.22
@@ -12,29 +12,12 @@
 #include <dirent.h>
 #include <sys/stat.h>
 
-#define MAX_INBUF_SIZE AUTH_MAX_REQUEST_DATA_SIZE
-#define MAX_OUTBUF_SIZE \
-	(sizeof(struct auth_continued_request_data) + \
-	 AUTH_MAX_REQUEST_DATA_SIZE)
-
-struct auth_connection {
-	struct auth_connection *next;
-
-	char *path;
-	int fd;
-	struct io *io;
-	struct istream *input;
-	struct ostream *output;
-
-	unsigned int auth_process;
-	enum auth_mech available_auth_mechs;
-        struct auth_reply_data in_reply;
-
-        struct hash_table *requests;
+/* Maximum size for an auth reply. 50kB should be more than enough. */
+#define MAX_INBUF_SIZE (1024*50)
 
-	unsigned int init_received:1;
-	unsigned int in_reply_received:1;
-};
+#define MAX_OUTBUF_SIZE \
+	(sizeof(struct auth_login_request_continue) + \
+	 AUTH_LOGIN_MAX_REQUEST_DATA_SIZE)
 
 enum auth_mech available_auth_mechs;
 
@@ -62,7 +45,7 @@
 static struct auth_connection *auth_connection_new(const char *path)
 {
 	struct auth_connection *conn;
-        struct client_auth_init_data init_data;
+        struct auth_login_handshake_input handshake;
 	int fd;
 
 	fd = net_connect_unix(path);
@@ -72,6 +55,9 @@
 		return NULL;
 	}
 
+	/* we depend on auth process - if it's slow, just wait */
+        net_set_nonblock(fd, FALSE);
+
 	conn = i_new(struct auth_connection, 1);
 	conn->path = i_strdup(path);
 	conn->fd = fd;
@@ -87,9 +73,9 @@
 	auth_connections = conn;
 
 	/* send our handshake */
-	memset(&init_data, 0, sizeof(init_data));
-	init_data.pid = login_process_uid;
-	if (o_stream_send(conn->output, &init_data, sizeof(init_data)) < 0) {
+	memset(&handshake, 0, sizeof(handshake));
+	handshake.pid = login_process_uid;
+	if (o_stream_send(conn->output, &handshake, sizeof(handshake)) < 0) {
                 auth_connection_destroy(conn);
 		return NULL;
 	}
@@ -102,19 +88,13 @@
 	i_free(request);
 }
 
-static void request_abort(struct auth_request *request)
-{
-	request->callback(request, request->conn->auth_process,
-			  AUTH_RESULT_INTERNAL_FAILURE,
-			  (const unsigned char *) "Authentication process died",
-			  0, NULL, request->context);
-	request_destroy(request);
-}
-
 static void request_hash_destroy(void *key __attr_unused__, void *value,
 				 void *context __attr_unused__)
 {
-	request_abort(value);
+	struct auth_request *request = value;
+
+	request->callback(request, NULL, NULL, request->context);
+	request_destroy(request);
 }
 
 static void auth_connection_destroy(struct auth_connection *conn)
@@ -181,39 +161,32 @@
                 available_auth_mechs |= conn->available_auth_mechs;
 }
 
-static void auth_handle_init(struct auth_connection *conn,
-			     struct auth_init_data *init_data)
+static void auth_handle_handshake(struct auth_connection *conn,
+				  struct auth_login_handshake_output *handshake)
 {
-	conn->auth_process = init_data->auth_process;
-	conn->available_auth_mechs = init_data->auth_mechanisms;
-	conn->init_received = TRUE;
+	conn->pid = handshake->pid;
+	conn->available_auth_mechs = handshake->auth_mechanisms;
+	conn->handshake_received = TRUE;
 
 	update_available_auth_mechs();
 }
 
 static void auth_handle_reply(struct auth_connection *conn,
-			      struct auth_reply_data *reply_data,
+			      struct auth_login_reply *reply,
 			      const unsigned char *data)
 {
 	struct auth_request *request;
 
-	request = hash_lookup(conn->requests, POINTER_CAST(reply_data->id));
+	request = hash_lookup(conn->requests, POINTER_CAST(reply->id));
 	if (request == NULL) {
 		i_error("BUG: imap-auth sent us reply with unknown ID %u",
-			reply_data->id);
+			reply->id);
 		return;
 	}
 
-	/* save the returned cookie */
-	memcpy(request->cookie, reply_data->cookie, AUTH_COOKIE_SIZE);
-
-	t_push();
-	request->callback(request, request->conn->auth_process,
-			  reply_data->result, data, reply_data->data_size,
-			  reply_data->virtual_user, request->context);
-	t_pop();
+	request->callback(request, reply, data, request->context);
 
-	if (reply_data->result != AUTH_RESULT_CONTINUE)
+	if (reply->result != AUTH_LOGIN_RESULT_CONTINUE)
 		request_destroy(request);
 }
 
@@ -221,7 +194,7 @@
 		       struct io *io __attr_unused__)
 {
 	struct auth_connection *conn = context;
-        struct auth_init_data init_data;
+        struct auth_login_handshake_output handshake;
 	const unsigned char *data;
 	size_t size;
 
@@ -241,45 +214,40 @@
 		return;
 	}
 
-	data = i_stream_get_data(conn->input, &size);
-
-	if (!conn->init_received) {
-		if (size == sizeof(struct auth_init_data)) {
-			memcpy(&init_data, data, sizeof(struct auth_init_data));
-			i_stream_skip(conn->input,
-				      sizeof(struct auth_init_data));
+	if (!conn->handshake_received) {
+		data = i_stream_get_data(conn->input, &size);
+		if (size == sizeof(handshake)) {
+			memcpy(&handshake, data, sizeof(handshake));
+			i_stream_skip(conn->input, sizeof(handshake));
 
-			auth_handle_init(conn, &init_data);
-		} else if (size > sizeof(struct auth_init_data)) {
-			i_error("BUG: imap-auth sent us too much "
-				"initialization data (%"PRIuSIZE_T " vs %"
-				PRIuSIZE_T")", size,
-				sizeof(struct auth_init_data));
+			auth_handle_handshake(conn, &handshake);
+		} else if (size > sizeof(handshake)) {
+			i_error("BUG: imap-auth sent us too large handshake "
+				"(%"PRIuSIZE_T " vs %"PRIuSIZE_T")", size,
+				sizeof(handshake));
 			auth_connection_destroy(conn);
 		}
-
 		return;
 	}
 
-	if (!conn->in_reply_received) {
+	if (!conn->reply_received) {
 		data = i_stream_get_data(conn->input, &size);
-		if (size < sizeof(struct auth_reply_data))
+		if (size < sizeof(conn->reply))
 			return;
 
-		memcpy(&conn->in_reply, data, sizeof(struct auth_reply_data));
-		data += sizeof(struct auth_reply_data);
-		size -= sizeof(struct auth_reply_data);
-		i_stream_skip(conn->input, sizeof(struct auth_reply_data));
-		conn->in_reply_received = TRUE;
+		memcpy(&conn->reply, data, sizeof(conn->reply));
+		i_stream_skip(conn->input, sizeof(conn->reply));
+		conn->reply_received = TRUE;
 	}
 
-	if (size < conn->in_reply.data_size)
+	data = i_stream_get_data(conn->input, &size);
+	if (size < conn->reply.data_size)
 		return;
 
 	/* we've got a full reply */
-	conn->in_reply_received = FALSE;
-	auth_handle_reply(conn, &conn->in_reply, data);
-	i_stream_skip(conn->input, conn->in_reply.data_size);
+	conn->reply_received = FALSE;
+	auth_handle_reply(conn, &conn->reply, data);
+	i_stream_skip(conn->input, conn->reply.data_size);
 }
 
 int auth_init_request(enum auth_mech mech, auth_callback_t callback,
@@ -287,12 +255,12 @@
 {
 	struct auth_connection *conn;
 	struct auth_request *request;
-	struct auth_init_request_data request_data;
+	struct auth_login_request_new auth_request;
 
 	if (auth_reconnect)
 		auth_connect_missing();
 
-	conn = auth_connection_get(mech, sizeof(request_data), error);
+	conn = auth_connection_get(mech, sizeof(auth_request), error);
 	if (conn == NULL)
 		return FALSE;
 
@@ -311,11 +279,11 @@
 	hash_insert(conn->requests, POINTER_CAST(request->id), request);
 
 	/* send request to auth */
-	request_data.type = AUTH_REQUEST_INIT;
-	request_data.mech = request->mech;
-	request_data.id = request->id;
-	if (o_stream_send(request->conn->output, &request_data,
-			  sizeof(request_data)) < 0)
+	auth_request.type = AUTH_LOGIN_REQUEST_NEW;
+	auth_request.mech = request->mech;
+	auth_request.id = request->id;
+	if (o_stream_send(request->conn->output, &auth_request,
+			  sizeof(auth_request)) < 0)
 		auth_connection_destroy(request->conn);
 	return TRUE;
 }
@@ -323,16 +291,15 @@
 void auth_continue_request(struct auth_request *request,
 			   const unsigned char *data, size_t data_size)
 {
-	struct auth_continued_request_data request_data;
+	struct auth_login_request_continue auth_request;
 
 	/* send continued request to auth */
-	memcpy(request_data.cookie, request->cookie, AUTH_COOKIE_SIZE);
-	request_data.type = AUTH_REQUEST_CONTINUE;
-	request_data.id = request->id;
-	request_data.data_size = data_size;
+	auth_request.type = AUTH_LOGIN_REQUEST_CONTINUE;
+	auth_request.id = request->id;
+	auth_request.data_size = data_size;
 
-	if (o_stream_send(request->conn->output, &request_data,
-			  sizeof(request_data)) < 0)
+	if (o_stream_send(request->conn->output, &auth_request,
+			  sizeof(auth_request)) < 0)
 		auth_connection_destroy(request->conn);
 	else if (o_stream_send(request->conn->output, data, data_size) < 0)
 		auth_connection_destroy(request->conn);

Index: auth-connection.h
===================================================================
RCS file: /home/cvs/dovecot/src/login/auth-connection.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- auth-connection.h	11 Jan 2003 19:55:57 -0000	1.9
+++ auth-connection.h	27 Jan 2003 01:33:40 -0000	1.10
@@ -1,26 +1,40 @@
 #ifndef __AUTH_CONNECTION_H
 #define __AUTH_CONNECTION_H
 
+struct client;
 struct auth_request;
 
-/* If result == AUTH_RESULT_INTERNAL_FAILURE, request may be NULL and
-   reply_data_size contains the error message. */
-typedef void (*auth_callback_t)(struct auth_request *request,
-				unsigned int auth_process,
-				enum auth_result result,
-				const unsigned char *reply_data,
-				size_t reply_data_size,
-				const char *virtual_user,
-				void *context);
+/* reply is NULL if auth connection died */
+typedef void auth_callback_t(struct auth_request *request,
+			     struct auth_login_reply *reply,
+			     const unsigned char *data, struct client *client);
+
+struct auth_connection {
+	struct auth_connection *next;
+
+	char *path;
+	int fd;
+	struct io *io;
+	struct istream *input;
+	struct ostream *output;
+
+	unsigned int pid;
+	enum auth_mech available_auth_mechs;
+        struct auth_login_reply reply;
+
+        struct hash_table *requests;
+
+	unsigned int handshake_received:1;
+	unsigned int reply_received:1;
+};
 
 struct auth_request {
         enum auth_mech mech;
         struct auth_connection *conn;
 
 	unsigned int id;
-	unsigned char cookie[AUTH_COOKIE_SIZE];
 
-	auth_callback_t callback;
+	auth_callback_t *callback;
 	void *context;
 
 	unsigned int init_sent:1;
@@ -28,7 +42,7 @@
 
 extern enum auth_mech available_auth_mechs;
 
-int auth_init_request(enum auth_mech mech, auth_callback_t callback,
+int auth_init_request(enum auth_mech mech, auth_callback_t *callback,
 		      void *context, const char **error);
 
 void auth_continue_request(struct auth_request *request,

Index: client-authenticate.c
===================================================================
RCS file: /home/cvs/dovecot/src/login/client-authenticate.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- client-authenticate.c	20 Jan 2003 13:53:31 -0000	1.33
+++ client-authenticate.c	27 Jan 2003 01:33:40 -0000	1.34
@@ -77,23 +77,20 @@
 	client_unref(client);
 }
 
-static void master_callback(enum master_reply_result result, void *context)
+static void master_callback(struct client *client, int success)
 {
-	struct client *client = context;
+	const char *reason = NULL;
 
-	switch (result) {
-	case MASTER_RESULT_SUCCESS:
-		client_destroy(client, t_strconcat("Login: ",
-						   client->virtual_user, NULL));
-		client_unref(client);
-		break;
-	case MASTER_RESULT_INTERNAL_FAILURE:
-		client_auth_abort(client, "Internal failure");
-		break;
-	default:
-		client_auth_abort(client, NULL);
-		break;
+	if (success)
+		reason = t_strconcat("Login: ", client->virtual_user, NULL);
+	else {
+		reason = t_strconcat("Internal login failure: ",
+				     client->virtual_user, NULL);
+		client_send_line(client, "* BYE Internal login failure.");
 	}
+
+	client_destroy(client, reason);
+	client_unref(client);
 }
 
 static void client_send_auth_data(struct client *client,
@@ -115,28 +112,55 @@
 	t_pop();
 }
 
+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);
+}
+
 static int auth_callback(struct auth_request *request,
-			 unsigned int auth_process, enum auth_result result,
-			 const unsigned char *reply_data,
-			 size_t reply_data_size, const char *virtual_user,
-			 void *context)
+			 struct auth_login_reply *reply,
+			 const unsigned char *data, void *context)
 {
 	struct client *client = context;
+	const char *user, *realm;
 
-	switch (result) {
-	case AUTH_RESULT_CONTINUE:
+	if (reply == NULL) {
+		/* failed */
+		client->auth_request = NULL;
+		client_auth_abort(client, "NO Authentication process died.");
+		return FALSE;
+	}
+
+	switch (reply->result) {
+	case AUTH_LOGIN_RESULT_CONTINUE:
 		client->auth_request = request;
 		return TRUE;
 
-	case AUTH_RESULT_SUCCESS:
+	case AUTH_LOGIN_RESULT_SUCCESS:
 		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 = i_strdup(virtual_user);
+		client->virtual_user = realm == NULL ?
+			i_strdup(user) : i_strconcat(user, "@", realm, NULL);
 
-		master_request_imap(client->fd, auth_process, client->cmd_tag,
-				    request->cookie, &client->ip,
-				    master_callback, client);
+		/* we should be able to log in. if we fail, just
+		   disconnect the client. */
+		client_send_tagline(client, "OK Logged in.");
+
+		master_request_imap(client, master_callback,
+				    request->conn->pid, request->id);
 
 		/* disable IO until we're back from master */
 		if (client->io != NULL) {
@@ -145,42 +169,33 @@
 		}
 		return FALSE;
 
-	case AUTH_RESULT_FAILURE:
+	case AUTH_LOGIN_RESULT_FAILURE:
 		/* see if we have error message */
 		client->auth_request = NULL;
 
-		if (reply_data_size > 0 &&
-		    reply_data[reply_data_size-1] == '\0') {
+		if (reply->data_size > 0 && data[reply->data_size-1] == '\0') {
 			client_auth_abort(client, t_strconcat(
 				"NO Authentication failed: ",
-				(const char *) reply_data, NULL));
+				(const char *) data, NULL));
 		} else {
 			/* default error message */
 			client_auth_abort(client, NULL);
 		}
 		return FALSE;
-	default:
-		client->auth_request = NULL;
-
-		client_auth_abort(client, t_strconcat(
-			"NO Authentication failed: ", reply_data, NULL));
-		return FALSE;
 	}
+
+	i_unreached();
 }
 
 static void login_callback(struct auth_request *request,
-			   unsigned int auth_process, enum auth_result result,
-			   const unsigned char *reply_data,
-			   size_t reply_data_size, const char *virtual_user,
-			   void *context)
+			   struct auth_login_reply *reply,
+			   const unsigned char *data, struct client *client)
 {
-	struct client *client = context;
 	const void *ptr;
 	size_t size;
 
-	if (auth_callback(request, auth_process, result,
-			  reply_data, reply_data_size, virtual_user, context)) {
-                ptr = buffer_get_data(client->plain_login, &size);
+	if (auth_callback(request, reply, data, client)) {
+		ptr = buffer_get_data(client->plain_login, &size);
 		auth_continue_request(request, ptr, size);
 
 		buffer_set_used_size(client->plain_login, 0);
@@ -233,17 +248,12 @@
 }
 
 static void authenticate_callback(struct auth_request *request,
-				  unsigned int auth_process,
-				  enum auth_result result,
-				  const unsigned char *reply_data,
-				  size_t reply_data_size,
-				  const char *virtual_user, void *context)
+				  struct auth_login_reply *reply,
+				  const unsigned char *data,
+				  struct client *client)
 {
-	struct client *client = context;
-
-	if (auth_callback(request, auth_process, result,
-			  reply_data, reply_data_size, virtual_user, context))
-		client_send_auth_data(client, reply_data, reply_data_size);
+	if (auth_callback(request, reply, data, client))
+		client_send_auth_data(client, data, reply->data_size);
 }
 
 static void client_auth_input(void *context, int fd __attr_unused__,

Index: client.h
===================================================================
RCS file: /home/cvs/dovecot/src/login/client.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- client.h	21 Jan 2003 11:17:44 -0000	1.13
+++ client.h	27 Jan 2003 01:33:40 -0000	1.14
@@ -2,6 +2,7 @@
 #define __CLIENT_H
 
 #include "network.h"
+#include "master.h"
 
 struct client {
 	time_t created;
@@ -22,6 +23,8 @@
 	buffer_t *plain_login;
 	struct auth_request *auth_request;
 	char *virtual_user;
+
+	master_callback_t *master_callback;
 
 	unsigned int tls:1;
 	unsigned int cmd_finished:1;

Index: common.h
===================================================================
RCS file: /home/cvs/dovecot/src/login/common.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- common.h	11 Jan 2003 19:55:57 -0000	1.6
+++ common.h	27 Jan 2003 01:33:40 -0000	1.7
@@ -2,7 +2,7 @@
 #define __COMMON_H
 
 #include "lib.h"
-#include "../auth/auth-interface.h"
+#include "../auth/auth-login-interface.h"
 
 extern int disable_plaintext_auth, process_per_connection, verbose_proctitle;
 extern unsigned int max_logging_users;

Index: master.c
===================================================================
RCS file: /home/cvs/dovecot/src/login/master.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- master.c	11 Jan 2003 19:55:57 -0000	1.12
+++ master.c	27 Jan 2003 01:33:40 -0000	1.13
@@ -1,6 +1,7 @@
 /* Copyright (C) 2002 Timo Sirainen */
 
 #include "common.h"
+#include "hash.h"
 #include "ioloop.h"
 #include "network.h"
 #include "fdpass.h"
@@ -9,88 +10,47 @@
 
 #include <unistd.h>
 
-struct waiting_request {
-	struct waiting_request *next;
-
-	unsigned int id;
-	master_callback_t callback;
-	void *context;
-};
-
 static struct io *io_master;
-static struct waiting_request *requests, **next_request;
+static struct hash_table *master_requests;
 
 static unsigned int master_pos;
-static char master_buf[sizeof(struct master_reply)];
-
-static void push_request(unsigned int id, master_callback_t callback,
-			 void *context)
-{
-	struct waiting_request *req;
-
-	req = i_new(struct waiting_request, 1);
-	req->id = id;
-	req->callback = callback;
-	req->context = context;
-
-	*next_request = req;
-	next_request = &req->next;
-}
+static char master_buf[sizeof(struct master_login_reply)];
 
-static void pop_request(struct master_reply *reply)
+static void request_handle(struct master_login_reply *reply)
 {
-	struct waiting_request *req;
-
-	req = requests;
-	if (req == NULL) {
-		i_error("Master sent us unrequested reply for id %d",
-			reply->id);
-		return;
-	}
-
-	if (reply->id != req->id) {
-		i_fatal("Master sent invalid id for reply "
-			"(got %d, expecting %d)", reply->id, req->id);
-	}
+	struct client *client;
 
-	req->callback(reply->result, req->context);
+	client = hash_lookup(master_requests, POINTER_CAST(reply->tag));
+	if (client == NULL)
+		i_fatal("Master sent reply with unknown tag %u", reply->tag);
 
-	requests = req->next;
-	if (requests == NULL)
-		next_request = &requests;
+	client->master_callback(client, reply->success);
 
-	i_free(req);
+	hash_remove(master_requests, POINTER_CAST(reply->tag));
 }
 
-void master_request_imap(int fd, unsigned int auth_process,
-			 const char *login_tag,
-			 unsigned char cookie[AUTH_COOKIE_SIZE],
-			 struct ip_addr *ip,
-			 master_callback_t callback, void *context)
+void master_request_imap(struct client *client, master_callback_t *callback,
+			 unsigned int auth_pid, unsigned int auth_id)
 {
-	struct master_request req;
-
-	i_assert(fd > 1);
+	struct master_login_request req;
 
 	memset(&req, 0, sizeof(req));
-	req.id = fd;
-	req.auth_process = auth_process;
-	memcpy(&req.ip, ip, sizeof(struct ip_addr));
-	memcpy(req.cookie, cookie, AUTH_COOKIE_SIZE);
-
-	if (strocpy(req.login_tag, login_tag, sizeof(req.login_tag)) < 0)
-		strocpy(req.login_tag, "*", sizeof(req.login_tag));
+	req.tag = client->fd;
+	req.auth_pid = auth_pid;
+	req.auth_id = auth_id;
+	req.ip = client->ip;
 
 	if (fd_send(LOGIN_MASTER_SOCKET_FD,
-		    fd, &req, sizeof(req)) != sizeof(req))
+		    client->fd, &req, sizeof(req)) != sizeof(req))
 		i_fatal("fd_send() failed: %m");
 
-	push_request(req.id, callback, context);
+	client->master_callback = callback;
+	hash_insert(master_requests, POINTER_CAST(req.tag), client);
 }
 
 void master_notify_finished(void)
 {
-	struct master_request req;
+	struct master_login_request req;
 
 	if (io_master == NULL)
 		return;
@@ -138,7 +98,7 @@
 		return;
 
 	/* reply is now read */
-	pop_request((struct master_reply *) master_buf);
+	request_handle((struct master_login_reply *) master_buf);
 	master_pos = 0;
 }
 
@@ -146,8 +106,8 @@
 {
 	main_ref();
 
-	requests = NULL;
-	next_request = &requests;
+	master_requests = hash_create(default_pool, default_pool,
+				      0, NULL, NULL);
 
         master_pos = 0;
 	io_master = io_add(LOGIN_MASTER_SOCKET_FD, IO_READ, master_input, NULL);
@@ -159,13 +119,7 @@
 
 void master_deinit(void)
 {
-	struct waiting_request *next;
-
-	while (requests != NULL) {
-		next = requests->next;
-		i_free(requests);
-		requests = next;
-	}
+	hash_destroy(master_requests);
 
 	if (io_master != NULL)
 		io_remove(io_master);

Index: master.h
===================================================================
RCS file: /home/cvs/dovecot/src/login/master.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- master.h	11 Jan 2003 19:55:57 -0000	1.7
+++ master.h	27 Jan 2003 01:33:40 -0000	1.8
@@ -1,17 +1,14 @@
 #ifndef __MASTER_H
 #define __MASTER_H
 
-#include "../master/master-interface.h"
+struct client;
 
-typedef void (*master_callback_t)(enum master_reply_result result,
-				  void *context);
+#include "../master/master-login-interface.h"
 
-/* Request IMAP process for given cookie. */
-void master_request_imap(int fd, unsigned int auth_process,
-			 const char *login_tag,
-			 unsigned char cookie[AUTH_COOKIE_SIZE],
-			 struct ip_addr *ip,
-			 master_callback_t callback, void *context);
+typedef void master_callback_t(struct client *client, int success);
+
+void master_request_imap(struct client *client, master_callback_t *callback,
+			 unsigned int auth_pid, unsigned int auth_id);
 
 /* Notify master that we're not listening for new connections anymore. */
 void master_notify_finished(void);




More information about the dovecot-cvs mailing list