[dovecot-cvs] dovecot/src/auth auth-master-connection.c, 1.29,
1.30 auth-request.c, 1.13, 1.14 auth-request.h, 1.11,
1.12 auth-worker-client.c, 1.1, 1.2 auth.c, 1.14, 1.15 auth.h,
1.12, 1.13 main.c, 1.41, 1.42 passdb-blocking.c, 1.2,
1.3 passdb.c, 1.33, 1.34 passdb.h, 1.23,
1.24 userdb-blocking.c, 1.1, 1.2 userdb-blocking.h, 1.1,
1.2 userdb.c, 1.18, 1.19 userdb.h, 1.21, 1.22
cras at dovecot.org
cras at dovecot.org
Mon Mar 7 20:55:15 EET 2005
Update of /var/lib/cvs/dovecot/src/auth
In directory talvi:/tmp/cvs-serv539/src/auth
Modified Files:
auth-master-connection.c auth-request.c auth-request.h
auth-worker-client.c auth.c auth.h main.c passdb-blocking.c
passdb.c passdb.h userdb-blocking.c userdb-blocking.h userdb.c
userdb.h
Log Message:
Replaced userdb/passdb settings with blocks so it's possible to give
multiple ones. Plaintext password mechanisms now support handling multiple
passdbs, but others don't yet. Also fixed a few memory leaks.
Index: auth-master-connection.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-master-connection.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- auth-master-connection.c 28 Feb 2005 22:19:21 -0000 1.29
+++ auth-master-connection.c 7 Mar 2005 18:55:13 -0000 1.30
@@ -228,7 +228,10 @@
i_error("close(): %m");
conn->fd = -1;
- o_stream_close(conn->output);
+ i_stream_unref(conn->input);
+ conn->input = NULL;
+
+ o_stream_unref(conn->output);
conn->output = NULL;
if (conn->io != NULL) {
Index: auth-request.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-request.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- auth-request.c 5 Mar 2005 11:48:13 -0000 1.13
+++ auth-request.c 7 Mar 2005 18:55:13 -0000 1.14
@@ -24,6 +24,8 @@
request = mech->auth_new();
request->state = AUTH_REQUEST_STATE_NEW;
+ request->passdb = auth->passdbs;
+ request->userdb = auth->userdbs;
request->refcount = 1;
request->created = ioloop_time;
@@ -107,7 +109,7 @@
static void auth_request_save_cache(struct auth_request *request,
enum passdb_result result)
{
- struct passdb_module *passdb = request->auth->passdb;
+ struct passdb_module *passdb = request->passdb->passdb;
string_t *str;
if (passdb_cache == NULL)
@@ -163,7 +165,7 @@
auth_request_save_cache(request, result);
cache_key = passdb_cache == NULL ? NULL :
- request->auth->passdb->cache_key;
+ request->passdb->passdb->cache_key;
if (result == PASSDB_RESULT_INTERNAL_FAILURE && cache_key != NULL) {
/* lookup failed. if we're looking here only because the
request was expired in cache, fallback to using cached
@@ -190,6 +192,20 @@
strlen(request->passdb_password));
}
+ if (result != PASSDB_RESULT_OK &&
+ result != PASSDB_RESULT_INTERNAL_FAILURE &&
+ request->passdb->next != NULL) {
+ /* try next passdb. */
+ if (request->extra_fields != NULL)
+ str_truncate(request->extra_fields, 0);
+
+ request->state = AUTH_REQUEST_STATE_MECH_CONTINUE;
+ request->passdb = request->passdb->next;
+ auth_request_verify_plain(request, request->mech_password,
+ request->private_callback.verify_plain);
+ return;
+ }
+
safe_memset(request->mech_password, 0, strlen(request->mech_password));
request->private_callback.verify_plain(result, request);
@@ -199,13 +215,14 @@
const char *password,
verify_plain_callback_t *callback)
{
- struct passdb_module *passdb = request->auth->passdb;
+ struct passdb_module *passdb = request->passdb->passdb;
enum passdb_result result;
const char *cache_key;
i_assert(request->state == AUTH_REQUEST_STATE_MECH_CONTINUE);
- request->mech_password = p_strdup(request->pool, password);
+ if (request->mech_password == NULL)
+ request->mech_password = p_strdup(request->pool, password);
request->private_callback.verify_plain = callback;
cache_key = passdb_cache == NULL ? NULL : passdb->cache_key;
@@ -244,7 +261,7 @@
}
cache_key = passdb_cache == NULL ? NULL :
- request->auth->passdb->cache_key;
+ request->passdb->passdb->cache_key;
if (result == PASSDB_RESULT_INTERNAL_FAILURE && cache_key != NULL) {
/* lookup failed. if we're looking here only because the
request was expired in cache, fallback to using cached
@@ -269,7 +286,7 @@
enum passdb_credentials credentials,
lookup_credentials_callback_t *callback)
{
- struct passdb_module *passdb = request->auth->passdb;
+ struct passdb_module *passdb = request->passdb->passdb;
const char *cache_key, *result, *scheme;
i_assert(request->state == AUTH_REQUEST_STATE_MECH_CONTINUE);
@@ -299,15 +316,40 @@
}
}
+void auth_request_userdb_callback(const char *result,
+ struct auth_request *request)
+{
+ if (result == NULL && request->userdb->next != NULL) {
+ /* try next userdb. */
+ if (request->extra_fields != NULL)
+ str_truncate(request->extra_fields, 0);
+
+ request->userdb = request->userdb->next;
+ auth_request_lookup_user(request,
+ request->private_callback.userdb);
+ return;
+ }
+
+ if (result == NULL && request->client_pid != 0) {
+ /* this was actual login attempt */
+ auth_request_log_error(request, "userdb",
+ "user not found from userdb");
+ }
+
+ request->private_callback.userdb(result, request);
+}
+
void auth_request_lookup_user(struct auth_request *request,
userdb_callback_t *callback)
{
- struct userdb_module *userdb = request->auth->userdb;
+ struct userdb_module *userdb = request->userdb->userdb;
+
+ request->private_callback.userdb = callback;
if (userdb->blocking)
- userdb_blocking_lookup(request, callback);
+ userdb_blocking_lookup(request);
else
- userdb->lookup(request, callback);
+ userdb->lookup(request, auth_request_userdb_callback);
}
int auth_request_set_username(struct auth_request *request,
Index: auth-request.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-request.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- auth-request.h 5 Mar 2005 11:48:13 -0000 1.11
+++ auth-request.h 7 Mar 2005 18:55:13 -0000 1.12
@@ -28,6 +28,8 @@
struct mech_module *mech;
struct auth *auth;
+ struct auth_passdb *passdb;
+ struct auth_userdb *userdb;
unsigned int connect_uid;
unsigned int client_pid;
@@ -109,5 +111,7 @@
void auth_request_lookup_credentials_callback(enum passdb_result result,
const char *credentials,
struct auth_request *request);
+void auth_request_userdb_callback(const char *result,
+ struct auth_request *request);
#endif
Index: auth-worker-client.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-worker-client.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- auth-worker-client.c 2 Mar 2005 20:46:25 -0000 1.1
+++ auth-worker-client.c 7 Mar 2005 18:55:13 -0000 1.2
@@ -54,6 +54,8 @@
auth_request->refcount = 1;
auth_request->created = ioloop_time;
auth_request->auth = client->auth;
+ auth_request->passdb = client->auth->passdbs;
+ auth_request->userdb = client->auth->userdbs;
client->refcount++;
auth_request->context = client;
@@ -115,6 +117,15 @@
/* verify plaintext password */
struct auth_request *auth_request;
const char *password;
+ unsigned int num;
+
+ num = atoi(t_strcut(args, '\t'));
+ args = strchr(args, '\t');
+ if (args == NULL) {
+ i_error("BUG: Auth worker server sent us invalid PASSV");
+ return;
+ }
+ args++;
password = t_strcut(args, '\t');
args = strchr(args, '\t');
@@ -124,8 +135,16 @@
auth_request->mech_password =
p_strdup(auth_request->pool, password);
- client->auth->passdb->verify_plain(auth_request, password,
- verify_plain_callback);
+ for (; num > 0; num++) {
+ auth_request->passdb = auth_request->passdb->next;
+ if (auth_request->passdb == NULL) {
+ i_error("BUG: PASSV had invalid passdb num");
+ return;
+ }
+ }
+
+ auth_request->passdb->passdb->verify_plain(auth_request, password,
+ verify_plain_callback);
}
static void
@@ -162,16 +181,35 @@
struct auth_request *auth_request;
const char *credentials_str;
enum passdb_credentials credentials;
+ unsigned int num;
+
+ num = atoi(t_strcut(args, '\t'));
+ args = strchr(args, '\t');
+ if (args == NULL) {
+ i_error("BUG: Auth worker server sent us invalid PASSL");
+ return;
+ }
+ args++;
credentials_str = t_strcut(args, '\t');
args = strchr(args, '\t');
if (args != NULL) args++;
- credentials = atoi(credentials_str);
+ credentials = atoi(credentials_str);
auth_request = worker_auth_request_new(client, id, args);
- client->auth->passdb->lookup_credentials(auth_request, credentials,
- lookup_credentials_callback);
+
+ for (; num > 0; num++) {
+ auth_request->passdb = auth_request->passdb->next;
+ if (auth_request->passdb == NULL) {
+ i_error("BUG: PASSL had invalid passdb num");
+ return;
+ }
+ }
+
+ auth_request->passdb->passdb->
+ lookup_credentials(auth_request, credentials,
+ lookup_credentials_callback);
}
static void
@@ -196,9 +234,24 @@
{
/* lookup user */
struct auth_request *auth_request;
+ unsigned int num;
+
+ num = atoi(t_strcut(args, '\t'));
+ args = strchr(args, '\t');
+ if (args != NULL) args++;
auth_request = worker_auth_request_new(client, id, args);
- client->auth->userdb->lookup(auth_request, lookup_user_callback);
+
+ for (; num > 0; num++) {
+ auth_request->userdb = auth_request->userdb->next;
+ if (auth_request->userdb == NULL) {
+ i_error("BUG: USER had invalid userdb num");
+ return;
+ }
+ }
+
+ auth_request->userdb->userdb->
+ lookup(auth_request, lookup_user_callback);
}
static int
Index: auth.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- auth.c 28 Feb 2005 22:19:21 -0000 1.14
+++ auth.c 7 Mar 2005 18:55:13 -0000 1.15
@@ -7,6 +7,7 @@
#include "mech.h"
#include "userdb.h"
#include "passdb.h"
+#include "passdb-cache.h"
#include "auth.h"
#include "auth-request-handler.h"
@@ -15,23 +16,46 @@
struct auth *auth_preinit(void)
{
- struct auth *auth;
- const char *env;
+ struct auth *auth;
+ const char *driver, *args;
+ pool_t pool;
+ unsigned int i;
- auth = i_new(struct auth, 1);
+ pool = pool_alloconly_create("auth", 1024);
+ auth = p_new(pool, struct auth, 1);
+ auth->pool = pool;
auth->verbose = getenv("VERBOSE") != NULL;
auth->verbose_debug = getenv("VERBOSE_DEBUG") != NULL;
- env = getenv("PASSDB");
- if (env == NULL)
- i_fatal("PASSDB environment is unset");
- passdb_preinit(auth, env);
+ t_push();
+ for (i = 1; ; i++) {
+ driver = getenv(t_strdup_printf("PASSDB_%u_DRIVER", i));
+ if (driver == NULL)
+ break;
- env = getenv("USERDB");
- if (env == NULL)
- i_fatal("USERDB environment is unset");
- userdb_preinit(auth, env);
+ args = getenv(t_strdup_printf("PASSDB_%u_ARGS", i));
+ passdb_preinit(auth, driver, args);
+
+ }
+ t_pop();
+
+ t_push();
+ for (i = 1; ; i++) {
+ driver = getenv(t_strdup_printf("USERDB_%u_DRIVER", i));
+ if (driver == NULL)
+ break;
+
+ args = getenv(t_strdup_printf("USERDB_%u_ARGS", i));
+ userdb_preinit(auth, driver, args);
+
+ }
+ t_pop();
+
+ if (auth->passdbs == NULL)
+ i_fatal("No password databases set");
+ if (auth->userdbs == NULL)
+ i_fatal("No user databases set");
return auth;
}
@@ -51,7 +75,7 @@
{
struct mech_module_list *list;
- list = i_new(struct mech_module_list, 1);
+ list = p_new(auth->pool, struct mech_module_list, 1);
list->module = *mech;
str_printfa(auth->mech_handshake, "MECH\t%s", mech->mech_name);
@@ -75,35 +99,62 @@
auth->mech_modules = list;
}
+static int auth_passdb_list_have_plain(struct auth *auth)
+{
+ struct auth_passdb *passdb;
+
+ for (passdb = auth->passdbs; passdb != NULL; passdb = passdb->next) {
+ if (passdb->passdb->verify_plain != NULL)
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static int auth_passdb_list_have_credentials(struct auth *auth)
+{
+ struct auth_passdb *passdb;
+
+ for (passdb = auth->passdbs; passdb != NULL; passdb = passdb->next) {
+ if (passdb->passdb->lookup_credentials != NULL)
+ return TRUE;
+ }
+ return FALSE;
+}
+
static void auth_mech_list_verify_passdb(struct auth *auth)
{
struct mech_module_list *list;
for (list = auth->mech_modules; list != NULL; list = list->next) {
if (list->module.passdb_need_plain &&
- auth->passdb->verify_plain == NULL)
+ !auth_passdb_list_have_plain(auth))
break;
if (list->module.passdb_need_credentials &&
- auth->passdb->lookup_credentials == NULL)
+ !auth_passdb_list_have_credentials(auth))
break;
}
if (list != NULL) {
- i_fatal("Passdb %s doesn't support %s method",
- auth->passdb->name, list->module.mech_name);
+ i_fatal("%s mechanism can't be supported with given passdbs",
+ list->module.mech_name);
}
}
void auth_init(struct auth *auth)
{
+ struct auth_passdb *passdb;
+ struct auth_userdb *userdb;
struct mech_module *mech;
const char *const *mechanisms;
const char *env;
- passdb_init(auth);
- userdb_init(auth);
+ for (passdb = auth->passdbs; passdb != NULL; passdb = passdb->next)
+ passdb_init(passdb);
+ for (userdb = auth->userdbs; userdb != NULL; userdb = userdb->next)
+ userdb_init(userdb);
+ passdb_cache_init();
- auth->mech_handshake = str_new(default_pool, 512);
+ auth->mech_handshake = str_new(auth->pool, 512);
auth->anonymous_username = getenv("ANONYMOUS_USERNAME");
if (auth->anonymous_username != NULL &&
@@ -170,8 +221,14 @@
void auth_deinit(struct auth *auth)
{
- userdb_deinit(auth);
- passdb_deinit(auth);
+ struct auth_passdb *passdb;
+ struct auth_userdb *userdb;
- str_free(auth->mech_handshake);
+ passdb_cache_deinit();
+ for (passdb = auth->passdbs; passdb != NULL; passdb = passdb->next)
+ passdb_deinit(passdb);
+ for (userdb = auth->userdbs; userdb != NULL; userdb = userdb->next)
+ userdb_deinit(userdb);
+
+ pool_unref(auth->pool);
}
Index: auth.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- auth.h 28 Feb 2005 22:19:21 -0000 1.12
+++ auth.h 7 Mar 2005 18:55:13 -0000 1.13
@@ -1,19 +1,38 @@
#ifndef __AUTH_H
#define __AUTH_H
-struct auth {
- struct mech_module_list *mech_modules;
- buffer_t *mech_handshake;
+struct auth_passdb {
+ struct auth *auth;
+ struct auth_passdb *next;
+ unsigned int num;
+ const char *args;
struct passdb_module *passdb;
- struct userdb_module *userdb;
+#ifdef HAVE_MODULES
+ struct auth_module *module;
+#endif
+};
+
+struct auth_userdb {
+ struct auth *auth;
+ struct auth_userdb *next;
+ unsigned int num;
+ const char *args;
+ struct userdb_module *userdb;
#ifdef HAVE_MODULES
- struct auth_module *passdb_module;
- struct auth_module *userdb_module;
+ struct auth_module *module;
#endif
+};
- char *passdb_args, *userdb_args;
+struct auth {
+ pool_t pool;
+
+ struct mech_module_list *mech_modules;
+ buffer_t *mech_handshake;
+
+ struct auth_passdb *passdbs;
+ struct auth_userdb *userdbs;
const char *const *auth_realms;
const char *default_realm;
Index: main.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/main.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- main.c 28 Feb 2005 22:19:21 -0000 1.41
+++ main.c 7 Mar 2005 18:55:13 -0000 1.42
@@ -271,6 +271,7 @@
for (i = 0; i < size; i++)
auth_master_connection_destroy(master[i]);
}
+ buffer_free(masters_buf);
auth_request_handler_deinit();
auth_deinit(auth);
Index: passdb-blocking.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb-blocking.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- passdb-blocking.c 5 Mar 2005 11:48:13 -0000 1.2
+++ passdb-blocking.c 7 Mar 2005 18:55:13 -0000 1.3
@@ -12,19 +12,35 @@
static enum passdb_result
check_failure(struct auth_request *request, const char **reply)
{
+ enum passdb_result ret;
+ const char *p;
+
/* OK / FAIL */
if (strncmp(*reply, "OK\t", 3) == 0) {
*reply += 3;
return PASSDB_RESULT_OK;
}
- /* FAIL \t result */
- if (strncmp(*reply, "FAIL\t", 5) != 0) {
+ /* FAIL \t result \t password */
+ if (strncmp(*reply, "FAIL\t", 5) == 0) {
+ *reply += 5;
+ ret = atoi(t_strcut(*reply, '\t'));
+
+ p = strchr(*reply, '\t');
+ if (p == NULL)
+ *reply += strlen(*reply);
+ else
+ *reply = p + 1;
+ if (ret != PASSDB_RESULT_OK)
+ return ret;
+
auth_request_log_error(request, "blocking",
- "Received unknown reply from worker: %s", *reply);
+ "Received invalid FAIL result from worker: %d", ret);
return PASSDB_RESULT_INTERNAL_FAILURE;
} else {
- return atoi(*reply + 5);
+ auth_request_log_error(request, "blocking",
+ "Received unknown reply from worker: %s", *reply);
+ return PASSDB_RESULT_INTERNAL_FAILURE;
}
}
@@ -90,7 +106,7 @@
i_assert(request->extra_fields == NULL);
str = t_str_new(64);
- str_append(str, "PASSV\t");
+ str_printfa(str, "PASSV\t%u\t", request->passdb->num);
str_append(str, request->mech_password);
str_append_c(str, '\t');
auth_request_export(request, str);
@@ -123,7 +139,8 @@
i_assert(request->extra_fields == NULL);
str = t_str_new(64);
- str_printfa(str, "PASSL\t%d\t", request->credentials);
+ str_printfa(str, "PASSL\t%u\t%d\t",
+ request->passdb->num, request->credentials);
auth_request_export(request, str);
auth_worker_call(request, str_c(str), lookup_credentials_callback);
Index: passdb.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- passdb.c 28 Feb 2005 22:19:21 -0000 1.33
+++ passdb.c 7 Mar 2005 18:55:13 -0000 1.34
@@ -5,7 +5,6 @@
#include "password-scheme.h"
#include "auth-worker-server.h"
#include "passdb.h"
-#include "passdb-cache.h"
#include <stdlib.h>
@@ -117,67 +116,65 @@
callback(PASSDB_RESULT_OK, password, auth_request);
}
-void passdb_preinit(struct auth *auth, const char *data)
+void passdb_preinit(struct auth *auth, const char *driver, const char *args)
{
struct passdb_module **p;
- const char *name, *args;
-
- args = strchr(data, ' ');
- name = t_strcut(data, ' ');
+ struct auth_passdb *auth_passdb, **dest;
if (args == NULL) args = "";
- while (*args == ' ' || *args == '\t')
- args++;
- auth->passdb_args = i_strdup(args);
+ auth_passdb = p_new(auth->pool, struct auth_passdb, 1);
+ auth_passdb->auth = auth;
+ auth_passdb->args = p_strdup(auth->pool, args);
+
+ for (dest = &auth->passdbs; *dest != NULL; dest = &(*dest)->next)
+ auth_passdb->num++;
+ *dest = auth_passdb;
for (p = passdbs; *p != NULL; p++) {
- if (strcmp((*p)->name, name) == 0) {
- auth->passdb = *p;
+ if (strcmp((*p)->name, driver) == 0) {
+ auth_passdb->passdb = *p;
break;
}
}
#ifdef HAVE_MODULES
- auth->passdb_module = auth->passdb != NULL ? NULL :
- auth_module_open(name);
- if (auth->passdb_module != NULL) {
- auth->passdb = auth_module_sym(auth->passdb_module,
- t_strconcat("passdb_", name,
- NULL));
+ if (auth_passdb->passdb == NULL)
+ auth_passdb->module = auth_module_open(driver);
+ if (auth_passdb->module != NULL) {
+ auth_passdb->passdb =
+ auth_module_sym(auth_passdb->module,
+ t_strconcat("passdb_", driver, NULL));
}
#endif
- if (auth->passdb == NULL)
- i_fatal("Unknown passdb type '%s'", name);
+ if (auth_passdb->passdb == NULL)
+ i_fatal("Unknown passdb driver '%s'", driver);
- if (auth->passdb->preinit != NULL)
- auth->passdb->preinit(auth->passdb_args);
+ if (auth_passdb->passdb->preinit != NULL)
+ auth_passdb->passdb->preinit(auth_passdb->args);
}
-void passdb_init(struct auth *auth)
+void passdb_init(struct auth_passdb *passdb)
{
- passdb_cache_init();
- if (auth->passdb->init != NULL)
- auth->passdb->init(auth->passdb_args);
+ if (passdb->passdb->init != NULL)
+ passdb->passdb->init(passdb->args);
- i_assert(auth->passdb->default_pass_scheme != NULL ||
- auth->passdb->cache_key == NULL);
+ i_assert(passdb->passdb->default_pass_scheme != NULL ||
+ passdb->passdb->cache_key == NULL);
- if (auth->passdb->blocking && !worker) {
+ if (passdb->passdb->blocking && !worker) {
/* blocking passdb - we need an auth server */
auth_worker_server_init();
}
}
-void passdb_deinit(struct auth *auth)
+void passdb_deinit(struct auth_passdb *passdb)
{
- if (auth->passdb->deinit != NULL)
- auth->passdb->deinit();
+ if (passdb->passdb->deinit != NULL)
+ passdb->passdb->deinit();
#ifdef HAVE_MODULES
- if (auth->passdb_module != NULL)
- auth_module_close(auth->passdb_module);
+ if (passdb->module != NULL)
+ auth_module_close(passdb->module);
#endif
- passdb_cache_deinit();
- i_free(auth->passdb_args);
}
Index: passdb.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/passdb.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- passdb.h 28 Feb 2005 22:19:21 -0000 1.23
+++ passdb.h 7 Mar 2005 18:55:13 -0000 1.24
@@ -67,9 +67,9 @@
lookup_credentials_callback_t *callback,
struct auth_request *auth_request);
-void passdb_preinit(struct auth *auth, const char *data);
-void passdb_init(struct auth *auth);
-void passdb_deinit(struct auth *auth);
+void passdb_preinit(struct auth *auth, const char *driver, const char *args);
+void passdb_init(struct auth_passdb *passdb);
+void passdb_deinit(struct auth_passdb *passdb);
#include "auth-request.h"
Index: userdb-blocking.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/userdb-blocking.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- userdb-blocking.c 2 Mar 2005 20:46:25 -0000 1.1
+++ userdb-blocking.c 7 Mar 2005 18:55:13 -0000 1.2
@@ -13,15 +13,12 @@
request->private_callback.userdb(reply, request);
}
-void userdb_blocking_lookup(struct auth_request *request,
- userdb_callback_t *callback)
+void userdb_blocking_lookup(struct auth_request *request)
{
string_t *str;
- request->private_callback.userdb = callback;
-
str = t_str_new(64);
- str_append(str, "USER\t");
+ str_printfa(str, "USER\t%u\t", request->userdb->num);
auth_request_export(request, str);
auth_worker_call(request, str_c(str), user_callback);
Index: userdb-blocking.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/userdb-blocking.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- userdb-blocking.h 2 Mar 2005 20:46:25 -0000 1.1
+++ userdb-blocking.h 7 Mar 2005 18:55:13 -0000 1.2
@@ -1,7 +1,6 @@
#ifndef __USERDB_BLOCKING_H
#define __USERDB_BLOCKING_H
-void userdb_blocking_lookup(struct auth_request *request,
- userdb_callback_t *callback);
+void userdb_blocking_lookup(struct auth_request *request);
#endif
Index: userdb.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/userdb.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- userdb.c 8 Jan 2005 16:56:04 -0000 1.18
+++ userdb.c 7 Mar 2005 18:55:13 -0000 1.19
@@ -77,56 +77,57 @@
return gr->gr_gid;
}
-void userdb_preinit(struct auth *auth, const char *data)
+void userdb_preinit(struct auth *auth, const char *driver, const char *args)
{
struct userdb_module **p;
- const char *name, *args;
-
- args = strchr(data, ' ');
- name = t_strcut(data, ' ');
+ struct auth_userdb *auth_userdb, **dest;
if (args == NULL) args = "";
- while (*args == ' ' || *args == '\t')
- args++;
- auth->userdb_args = i_strdup(args);
+ auth_userdb = p_new(auth->pool, struct auth_userdb, 1);
+ auth_userdb->auth = auth;
+ auth_userdb->args = p_strdup(auth->pool, args);
+
+ for (dest = &auth->userdbs; *dest != NULL; dest = &(*dest)->next)
+ auth_userdb->num++;
+ *dest = auth_userdb;
for (p = userdbs; *p != NULL; p++) {
- if (strcmp((*p)->name, name) == 0) {
- auth->userdb = *p;
+ if (strcmp((*p)->name, driver) == 0) {
+ auth_userdb->userdb = *p;
break;
}
}
+
#ifdef HAVE_MODULES
- auth->userdb_module = auth->userdb != NULL ? NULL :
- auth_module_open(name);
- if (auth->userdb_module != NULL) {
- auth->userdb = auth_module_sym(auth->userdb_module,
- t_strconcat("userdb_", name,
- NULL));
+ if (auth_userdb->userdb == NULL)
+ auth_userdb->module = auth_module_open(driver);
+ if (auth_userdb->module != NULL) {
+ auth_userdb->userdb =
+ auth_module_sym(auth_userdb->module,
+ t_strconcat("userdb_", driver, NULL));
}
#endif
- if (auth->userdb == NULL)
- i_fatal("Unknown userdb type '%s'", name);
+ if (auth_userdb->userdb == NULL)
+ i_fatal("Unknown userdb driver '%s'", driver);
- if (auth->userdb->preinit != NULL)
- auth->userdb->preinit(args);
+ if (auth_userdb->userdb->preinit != NULL)
+ auth_userdb->userdb->preinit(auth_userdb->args);
}
-void userdb_init(struct auth *auth)
+void userdb_init(struct auth_userdb *userdb)
{
- if (auth->userdb->init != NULL)
- auth->userdb->init(auth->userdb_args);
+ if (userdb->userdb->init != NULL)
+ userdb->userdb->init(userdb->args);
}
-void userdb_deinit(struct auth *auth)
+void userdb_deinit(struct auth_userdb *userdb)
{
- if (auth->userdb->deinit != NULL)
- auth->userdb->deinit();
+ if (userdb->userdb->deinit != NULL)
+ userdb->userdb->deinit();
#ifdef HAVE_MODULES
- if (auth->userdb_module != NULL)
- auth_module_close(auth->userdb_module);
+ if (userdb->module != NULL)
+ auth_module_close(userdb->module);
#endif
- i_free(auth->userdb_args);
}
Index: userdb.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/userdb.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- userdb.h 28 Feb 2005 22:19:21 -0000 1.21
+++ userdb.h 7 Mar 2005 18:55:13 -0000 1.22
@@ -24,9 +24,9 @@
uid_t userdb_parse_uid(struct auth_request *request, const char *str);
gid_t userdb_parse_gid(struct auth_request *request, const char *str);
-void userdb_preinit(struct auth *auth, const char *data);
-void userdb_init(struct auth *auth);
-void userdb_deinit(struct auth *auth);
+void userdb_preinit(struct auth *auth, const char *driver, const char *args);
+void userdb_init(struct auth_userdb *passdb);
+void userdb_deinit(struct auth_userdb *passdb);
#include "auth-request.h"
More information about the dovecot-cvs
mailing list