changeset 4904:f98ee68ab23f HEAD

Removed support for external I/O loop. The point was originally that this library could be used by external software to talk to dovecot-auth, but nowadays it's much easier to just implement the authentication protocol.
author Timo Sirainen <tss@iki.fi>
date Fri, 15 Dec 2006 19:16:26 +0200
parents 204d7edc7cdc
children ab47138f5c8f
files src/lib-auth/auth-client.c src/lib-auth/auth-client.h src/lib-auth/auth-server-connection.c src/lib-auth/auth-server-connection.h
diffstat 4 files changed, 28 insertions(+), 73 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-auth/auth-client.c	Fri Dec 15 18:55:29 2006 +0200
+++ b/src/lib-auth/auth-client.c	Fri Dec 15 19:16:26 2006 +0200
@@ -12,24 +12,12 @@
 
 struct auth_client *auth_client_new(unsigned int client_pid)
 {
-	return auth_client_new_external(client_pid, NULL, NULL, NULL);
-}
-
-struct auth_client *auth_client_new_external(unsigned int client_pid,
-					     const char *socket_paths,
-					     input_func_add_t *add_func,
-					     input_func_remove_t *remove_func)
-{
 	struct auth_client *client;
 
 	client = i_new(struct auth_client, 1);
 	client->pid = client_pid;
-	client->socket_paths = i_strdup(socket_paths);
 	client->available_auth_mechs = buffer_create_dynamic(default_pool, 128);
 
-	client->ext_input_add = add_func;
-	client->ext_input_remove = remove_func;
-
 	auth_client_connect_missing_servers(client);
 	return client;
 }
@@ -57,7 +45,6 @@
 
 	if (client->to_reconnect != NULL)
 		timeout_remove(&client->to_reconnect);
-	i_free(client->socket_paths);
 	i_free(client);
 }
 
@@ -153,47 +140,39 @@
 	struct dirent *dp;
 	struct stat st;
 
-	if (client->socket_paths != NULL) {
-		auth_client_connect_missing_servers_list(client,
-							 client->socket_paths);
-	} else {
-		/* we're chrooted */
-		dirp = opendir(".");
-		if (dirp == NULL) {
-			i_fatal("opendir(.) failed when trying to get list of "
-				"authentication servers: %m");
+	/* we're chrooted */
+	dirp = opendir(".");
+	if (dirp == NULL) {
+		i_fatal("opendir(.) failed when trying to get list of "
+			"authentication servers: %m");
+	}
+
+	client->reconnect = FALSE;
+	while ((dp = readdir(dirp)) != NULL) {
+		const char *name = dp->d_name;
+
+		if (name[0] == '.')
+			continue;
+
+		if (auth_server_connection_find_path(client, name) != NULL) {
+			/* already connected */
+			continue;
 		}
 
-		client->reconnect = FALSE;
-		while ((dp = readdir(dirp)) != NULL) {
-			const char *name = dp->d_name;
-
-			if (name[0] == '.')
-				continue;
-
-			if (auth_server_connection_find_path(client,
-							     name) != NULL) {
-				/* already connected */
-				continue;
-			}
-
-			/* Normally they're sockets, but in UnixWare they're
-			   created as fifos. */
-			if (stat(name, &st) == 0 &&
-			    (S_ISSOCK(st.st_mode) || S_ISFIFO(st.st_mode))) {
-				if (auth_server_connection_new(client,
-							       name) == NULL)
-					client->reconnect = TRUE;
-			}
+		/* Normally they're sockets, but in UnixWare they're
+		   created as fifos. */
+		if (stat(name, &st) == 0 &&
+		    (S_ISSOCK(st.st_mode) || S_ISFIFO(st.st_mode))) {
+			if (auth_server_connection_new(client, name) == NULL)
+				client->reconnect = TRUE;
 		}
-
-		if (closedir(dirp) < 0)
-			i_error("closedir() failed: %m");
 	}
 
+	if (closedir(dirp) < 0)
+		i_error("closedir() failed: %m");
+
 	if (client->reconnect || client->connections == NULL) {
-		if (client->to_reconnect == NULL &&
-		    client->ext_input_add == NULL) {
+		if (client->to_reconnect == NULL) {
 			client->to_reconnect =
 				timeout_add(5000, reconnect_timeout, client);
 		}
--- a/src/lib-auth/auth-client.h	Fri Dec 15 18:55:29 2006 +0200
+++ b/src/lib-auth/auth-client.h	Fri Dec 15 19:16:26 2006 +0200
@@ -95,16 +95,6 @@
 /* Return the PID of the server that handled this request. */
 unsigned int auth_client_request_get_server_pid(struct auth_request *request);
 
-/* -- Using lib-auth with external I/O loop -- */
-
-typedef void *input_func_add_t(int fd, void (*cb)(void *), void *context);
-typedef void *input_func_remove_t(void *io);
-
-struct auth_client *auth_client_new_external(unsigned int client_pid,
-					     const char *socket_paths,
-					     input_func_add_t *add_func,
-					     input_func_remove_t *remove_func);
-/* Call every few seconds. */
 void auth_client_connect_missing_servers(struct auth_client *client);
 
 #endif
--- a/src/lib-auth/auth-server-connection.c	Fri Dec 15 18:55:29 2006 +0200
+++ b/src/lib-auth/auth-server-connection.c	Fri Dec 15 19:16:26 2006 +0200
@@ -226,12 +226,7 @@
 	conn->client = client;
 	conn->path = p_strdup(pool, path);
 	conn->fd = fd;
-	if (client->ext_input_add == NULL)
-		conn->io = io_add(fd, IO_READ, auth_client_input, conn);
-	else {
-		conn->ext_input_io =
-			client->ext_input_add(fd, auth_client_input, conn);
-	}
+	conn->io = io_add(fd, IO_READ, auth_client_input, conn);
 	conn->input = i_stream_create_file(fd, default_pool,
 					   AUTH_CLIENT_MAX_LINE_LENGTH, FALSE);
 	conn->output = o_stream_create_file(fd, default_pool, (size_t)-1,
@@ -280,10 +275,6 @@
 	if (!conn->handshake_received)
 		client->conn_waiting_handshake_count--;
 
-	if (conn->ext_input_io != NULL) {
-		client->ext_input_remove(conn->ext_input_io);
-		conn->ext_input_io = NULL;
-	}
 	if (conn->io != NULL)
 		io_remove(&conn->io);
 
--- a/src/lib-auth/auth-server-connection.h	Fri Dec 15 18:55:29 2006 +0200
+++ b/src/lib-auth/auth-server-connection.h	Fri Dec 15 19:16:26 2006 +0200
@@ -3,10 +3,6 @@
 
 struct auth_client {
 	unsigned int pid;
-	char *socket_paths;
-
-	input_func_add_t *ext_input_add;
-	input_func_remove_t *ext_input_remove;
 
 	struct auth_server_connection *connections;
 	struct timeout *to_reconnect;
@@ -34,7 +30,6 @@
 	int fd;
 
 	struct io *io;
-	void *ext_input_io;
 	struct istream *input;
 	struct ostream *output;