dovecot-2.0: auth: auth_userdb and auth_passdb no longer has poi...

dovecot at dovecot.org dovecot at dovecot.org
Sat Mar 13 17:28:30 EET 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/1a4c2e4bff75
changeset: 10893:1a4c2e4bff75
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Mar 13 17:28:18 2010 +0200
description:
auth: auth_userdb and auth_passdb no longer has pointer to struct auth.

diffstat:

 src/auth/auth-request.c         |   4 ++++
 src/auth/auth-settings.c        |   2 ++
 src/auth/auth-settings.h        |   2 ++
 src/auth/auth-worker-server.c   |  14 +++++---------
 src/auth/auth-worker-server.h   |   3 +--
 src/auth/auth.h                 |   4 ++--
 src/auth/main.c                 |   9 +++++----
 src/auth/passdb-blocking.c      |   7 +++----
 src/auth/passdb-bsdauth.c       |   5 ++---
 src/auth/passdb-checkpassword.c |   4 ++--
 src/auth/passdb-ldap.c          |   4 ++--
 src/auth/passdb-pam.c           |   6 +++---
 src/auth/passdb-passwd-file.c   |  13 +++++--------
 src/auth/passdb-sql.c           |   4 ++--
 src/auth/passdb-vpopmail.c      |   5 ++---
 src/auth/passdb.c               |   2 +-
 src/auth/userdb-blocking.c      |   6 ++----
 src/auth/userdb-checkpassword.c |   4 ++--
 src/auth/userdb-ldap.c          |  12 +++++-------
 src/auth/userdb-nss.c           |   2 +-
 src/auth/userdb-passwd-file.c   |  12 ++++--------
 src/auth/userdb-passwd.c        |   4 ++--
 src/auth/userdb-sql.c           |   4 ++--
 src/auth/userdb-static.c        |   4 ++--
 src/auth/userdb-vpopmail.c      |   2 +-
 src/auth/userdb.c               |   2 +-
 26 files changed, 65 insertions(+), 75 deletions(-)

diffs (truncated from 601 to 300 lines):

diff -r 9675d9a54ac9 -r 1a4c2e4bff75 src/auth/auth-request.c
--- a/src/auth/auth-request.c	Sat Mar 13 16:52:50 2010 +0200
+++ b/src/auth/auth-request.c	Sat Mar 13 17:28:18 2010 +0200
@@ -63,6 +63,10 @@
 	auth_request->refcount = 1;
 	auth_request->last_access = ioloop_time;
 
+	if (auth == NULL) {
+		auth = p_new(pool, struct auth, 1);
+		auth->set = global_auth_settings;
+	}
 	auth_request->auth = auth;
 	auth_request->passdb = auth->passdbs;
 	auth_request->userdb = auth->userdbs;
diff -r 9675d9a54ac9 -r 1a4c2e4bff75 src/auth/auth-settings.c
--- a/src/auth/auth-settings.c	Sat Mar 13 16:52:50 2010 +0200
+++ b/src/auth/auth-settings.c	Sat Mar 13 17:28:18 2010 +0200
@@ -288,6 +288,8 @@
 }
 /* </settings checks> */
 
+struct auth_settings *global_auth_settings;
+
 struct auth_settings *
 auth_settings_read(struct master_service *service)
 {
diff -r 9675d9a54ac9 -r 1a4c2e4bff75 src/auth/auth-settings.h
--- a/src/auth/auth-settings.h	Sat Mar 13 16:52:50 2010 +0200
+++ b/src/auth/auth-settings.h	Sat Mar 13 17:28:18 2010 +0200
@@ -50,6 +50,8 @@
 	const char *const *realms_arr;
 };
 
+extern struct auth_settings *global_auth_settings;
+
 struct auth_settings *auth_settings_read(struct master_service *service);
 
 #endif
diff -r 9675d9a54ac9 -r 1a4c2e4bff75 src/auth/auth-worker-server.c
--- a/src/auth/auth-worker-server.c	Sat Mar 13 16:52:50 2010 +0200
+++ b/src/auth/auth-worker-server.c	Sat Mar 13 17:28:18 2010 +0200
@@ -28,7 +28,6 @@
 };
 
 struct auth_worker_connection {
-	struct auth *auth;
 	int fd;
 
 	struct io *io;
@@ -120,12 +119,12 @@
 	auth_worker_request_send(conn, request);
 }
 
-static struct auth_worker_connection *auth_worker_create(struct auth *auth)
+static struct auth_worker_connection *auth_worker_create(void)
 {
 	struct auth_worker_connection *conn;
 	int fd;
 
-	if (array_count(&connections) >= auth->set->worker_max_count)
+	if (array_count(&connections) >= global_auth_settings->worker_max_count)
 		return NULL;
 
 	fd = net_connect_unix_with_retries(worker_socket_path, 5000);
@@ -135,7 +134,6 @@
 	}
 
 	conn = i_new(struct auth_worker_connection, 1);
-	conn->auth = auth;
 	conn->fd = fd;
 	conn->input = i_stream_create_fd(fd, AUTH_WORKER_MAX_LINE_LENGTH,
 					 FALSE);
@@ -154,7 +152,6 @@
 				const char *reason, bool restart)
 {
 	struct auth_worker_connection *conn = *_conn;
-	struct auth *auth = conn->auth;
 	struct auth_worker_connection *const *conns;
 	unsigned int idx;
 
@@ -188,7 +185,7 @@
 	i_free(conn);
 
 	if (idle_count == 0 && restart) {
-		conn = auth_worker_create(auth);
+		conn = auth_worker_create();
 		auth_worker_request_send_next(conn);
 	}
 }
@@ -286,8 +283,7 @@
 }
 
 struct auth_worker_connection *
-auth_worker_call(struct auth *auth, pool_t pool,
-		 struct auth_stream_reply *data,
+auth_worker_call(pool_t pool, struct auth_stream_reply *data,
 		 auth_worker_callback_t *callback, void *context)
 {
 	struct auth_worker_connection *conn;
@@ -307,7 +303,7 @@
 		conn = auth_worker_find_free();
 		if (conn == NULL) {
 			/* no free connections, create a new one */
-			conn = auth_worker_create(auth);
+			conn = auth_worker_create();
 		}
 	}
 	if (conn != NULL)
diff -r 9675d9a54ac9 -r 1a4c2e4bff75 src/auth/auth-worker-server.h
--- a/src/auth/auth-worker-server.h	Sat Mar 13 16:52:50 2010 +0200
+++ b/src/auth/auth-worker-server.h	Sat Mar 13 17:28:18 2010 +0200
@@ -7,8 +7,7 @@
 typedef bool auth_worker_callback_t(const char *reply, void *context);
 
 struct auth_worker_connection *
-auth_worker_call(struct auth *auth, pool_t pool,
-		 struct auth_stream_reply *data,
+auth_worker_call(pool_t pool, struct auth_stream_reply *data,
 		 auth_worker_callback_t *callback, void *context);
 void auth_worker_server_resume_input(struct auth_worker_connection *conn);
 
diff -r 9675d9a54ac9 -r 1a4c2e4bff75 src/auth/auth.h
--- a/src/auth/auth.h	Sat Mar 13 16:52:50 2010 +0200
+++ b/src/auth/auth.h	Sat Mar 13 17:28:18 2010 +0200
@@ -6,7 +6,7 @@
 #define PASSWORD_HIDDEN_STR "<hidden>"
 
 struct auth_passdb {
-	struct auth *auth;
+	pool_t pool;
 	struct auth_passdb *next;
 
         /* id is used by blocking passdb to identify the passdb */
@@ -21,7 +21,7 @@
 };
 
 struct auth_userdb {
-	struct auth *auth;
+	pool_t pool;
 	struct auth_userdb *next;
 
 	unsigned int num;
diff -r 9675d9a54ac9 -r 1a4c2e4bff75 src/auth/main.c
--- a/src/auth/main.c	Sat Mar 13 16:52:50 2010 +0200
+++ b/src/auth/main.c	Sat Mar 13 17:28:18 2010 +0200
@@ -37,7 +37,7 @@
 static struct auth *auth;
 static ARRAY_DEFINE(listen_fd_types, enum auth_socket_type);
 
-static void main_preinit(struct auth_settings *set)
+static void main_preinit(void)
 {
 	struct module_dir_load_settings mod_set;
 
@@ -56,12 +56,12 @@
 	memset(&mod_set, 0, sizeof(mod_set));
 	mod_set.version = master_service_get_version_string(master_service);
 	mod_set.require_init_funcs = TRUE;
-	mod_set.debug = set->debug;
+	mod_set.debug = global_auth_settings->debug;
 
 	modules = module_dir_load(AUTH_MODULE_DIR, NULL, &mod_set);
 	module_dir_init(modules);
 
-	auth = auth_preinit(set);
+	auth = auth_preinit(global_auth_settings);
 
 	/* Password lookups etc. may require roots, allow it. */
 	restrict_access_by_env(NULL, FALSE);
@@ -189,7 +189,8 @@
 		}
 	}
 
-	main_preinit(auth_settings_read(master_service));
+	global_auth_settings = auth_settings_read(master_service);
+	main_preinit();
 
 	master_service_init_finish(master_service);
 	main_init();
diff -r 9675d9a54ac9 -r 1a4c2e4bff75 src/auth/passdb-blocking.c
--- a/src/auth/passdb-blocking.c	Sat Mar 13 16:52:50 2010 +0200
+++ b/src/auth/passdb-blocking.c	Sat Mar 13 17:28:18 2010 +0200
@@ -85,8 +85,7 @@
 	auth_request_export(request, reply);
 
 	auth_request_ref(request);
-	auth_worker_call(request->auth, request->pool, reply,
-			 verify_plain_callback, request);
+	auth_worker_call(request->pool, reply, verify_plain_callback, request);
 }
 
 static bool lookup_credentials_callback(const char *reply, void *context)
@@ -128,7 +127,7 @@
 	auth_request_export(request, reply);
 
 	auth_request_ref(request);
-	auth_worker_call(request->auth, request->pool, reply,
+	auth_worker_call(request->pool, reply,
 			 lookup_credentials_callback, request);
 }
 
@@ -156,6 +155,6 @@
 	auth_request_export(request, reply);
 
 	auth_request_ref(request);
-	auth_worker_call(request->auth, request->pool, reply,
+	auth_worker_call(request->pool, reply,
 			 set_credentials_callback, request);
 }
diff -r 9675d9a54ac9 -r 1a4c2e4bff75 src/auth/passdb-bsdauth.c
--- a/src/auth/passdb-bsdauth.c	Sat Mar 13 16:52:50 2010 +0200
+++ b/src/auth/passdb-bsdauth.c	Sat Mar 13 17:28:18 2010 +0200
@@ -53,13 +53,12 @@
 {
 	struct passdb_module *module;
 
-	module = p_new(auth_passdb->auth->pool, struct passdb_module, 1);
+	module = p_new(auth_passdb->pool, struct passdb_module, 1);
 	module->default_pass_scheme = "PLAIN"; /* same reason as PAM */
 
 	if (strncmp(args, "cache_key=", 10) == 0) {
 		module->cache_key =
-			auth_cache_parse_key(auth_passdb->auth->pool,
-					     args + 10);
+			auth_cache_parse_key(auth_passdb->pool, args + 10);
 	} else if (*args != '\0')
 		i_fatal("passdb bsdauth: Unknown setting: %s", args);
 	return module;
diff -r 9675d9a54ac9 -r 1a4c2e4bff75 src/auth/passdb-checkpassword.c
--- a/src/auth/passdb-checkpassword.c	Sat Mar 13 16:52:50 2010 +0200
+++ b/src/auth/passdb-checkpassword.c	Sat Mar 13 17:28:18 2010 +0200
@@ -239,9 +239,9 @@
 {
 	struct checkpassword_passdb_module *module;
 
-	module = p_new(auth_passdb->auth->pool,
+	module = p_new(auth_passdb->pool,
 		       struct checkpassword_passdb_module, 1);
-	module->checkpassword_path = p_strdup(auth_passdb->auth->pool, args);
+	module->checkpassword_path = p_strdup(auth_passdb->pool, args);
 	module->checkpassword_reply_path =
 		PKG_LIBEXECDIR"/checkpassword-reply";
 
diff -r 9675d9a54ac9 -r 1a4c2e4bff75 src/auth/passdb-ldap.c
--- a/src/auth/passdb-ldap.c	Sat Mar 13 16:52:50 2010 +0200
+++ b/src/auth/passdb-ldap.c	Sat Mar 13 17:28:18 2010 +0200
@@ -397,7 +397,7 @@
 	struct ldap_passdb_module *module;
 	struct ldap_connection *conn;
 
-	module = p_new(auth_passdb->auth->pool, struct ldap_passdb_module, 1);
+	module = p_new(auth_passdb->pool, struct ldap_passdb_module, 1);
 	module->conn = conn = db_ldap_init(args);
 	conn->pass_attr_map =
 		hash_table_create(default_pool, conn->pool, 0, str_hash,
@@ -407,7 +407,7 @@
 			  conn->pass_attr_map,
 			  conn->set.auth_bind ? "password" : NULL);
 	module->module.cache_key =
-		auth_cache_parse_key(auth_passdb->auth->pool,
+		auth_cache_parse_key(auth_passdb->pool,
 				     t_strconcat(conn->set.base,
 						 conn->set.pass_filter, NULL));
 	module->module.default_pass_scheme = conn->set.default_pass_scheme;
diff -r 9675d9a54ac9 -r 1a4c2e4bff75 src/auth/passdb-pam.c
--- a/src/auth/passdb-pam.c	Sat Mar 13 16:52:50 2010 +0200
+++ b/src/auth/passdb-pam.c	Sat Mar 13 17:28:18 2010 +0200
@@ -333,7 +333,7 @@
 	const char *const *t_args;
 	int i;
 
-	module = p_new(auth_passdb->auth->pool, struct pam_passdb_module, 1);
+	module = p_new(auth_passdb->pool, struct pam_passdb_module, 1);
 	module->service_name = "dovecot";
 	/* we're caching the password by using directly the plaintext password
 	   given by the auth mechanism */
@@ -351,7 +351,7 @@
 			module->pam_setcred = TRUE;
 		else if (strncmp(t_args[i], "cache_key=", 10) == 0) {
 			module->module.cache_key =
-				auth_cache_parse_key(auth_passdb->auth->pool,
+				auth_cache_parse_key(auth_passdb->pool,
 						     t_args[i] + 10);
 		} else if (strcmp(t_args[i], "blocking=yes") == 0) {
 			/* ignore, for backwards compatibility */
@@ -364,7 +364,7 @@
 			module->requests_left = atoi(t_args[i] + 13);
 		} else if (t_args[i+1] == NULL) {
 			module->service_name =
-				p_strdup(auth_passdb->auth->pool, t_args[i]);
+				p_strdup(auth_passdb->pool, t_args[i]);
 		} else {
 			i_fatal("passdb pam: Unknown setting: %s", t_args[i]);
 		}
diff -r 9675d9a54ac9 -r 1a4c2e4bff75 src/auth/passdb-passwd-file.c
--- a/src/auth/passdb-passwd-file.c	Sat Mar 13 16:52:50 2010 +0200
+++ b/src/auth/passdb-passwd-file.c	Sat Mar 13 17:28:18 2010 +0200
@@ -14,7 +14,6 @@
 struct passwd_file_passdb_module {
 	struct passdb_module module;


More information about the dovecot-cvs mailing list