dovecot: Changed plugin handling. We'll just load and call _init...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Aug 6 23:43:33 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/968430741daf
changeset: 6189:968430741daf
user: Timo Sirainen <tss at iki.fi>
date: Mon Aug 06 23:43:28 2007 +0300
description:
Changed plugin handling. We'll just load and call _init() functions for all
plugins in $moduledir/auth/.
diffstat:
8 files changed, 9 insertions(+), 184 deletions(-)
src/auth/Makefile.am | 2
src/auth/auth-module.c | 111 --------------------------------------------
src/auth/auth-module.h | 9 ---
src/auth/auth.h | 7 --
src/auth/main.c | 9 +++
src/auth/passdb.c | 14 -----
src/auth/password-scheme.c | 27 ----------
src/auth/userdb.c | 14 -----
diffs (truncated from 355 to 300 lines):
diff -r e609b4e3a35c -r 968430741daf src/auth/Makefile.am
--- a/src/auth/Makefile.am Mon Aug 06 23:36:43 2007 +0300
+++ b/src/auth/Makefile.am Mon Aug 06 23:43:28 2007 +0300
@@ -40,7 +40,6 @@ dovecot_auth_SOURCES = \
auth-client-connection.c \
auth-master-connection.c \
auth-master-listener.c \
- auth-module.c \
auth-request.c \
auth-request-handler.c \
auth-stream.c \
@@ -97,7 +96,6 @@ headers = \
auth-master-interface.h \
auth-master-connection.h \
auth-master-listener.h \
- auth-module.h \
auth-request.h \
auth-request-handler.h \
auth-stream.h \
diff -r e609b4e3a35c -r 968430741daf src/auth/auth-module.c
--- a/src/auth/auth-module.c Mon Aug 06 23:36:43 2007 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,111 +0,0 @@
-/* Copyright (C) 2003 Timo Sirainen */
-
-#include "lib.h"
-
-#ifdef HAVE_MODULES
-
-#include "auth-module.h"
-
-#include <sys/stat.h>
-#include <dlfcn.h>
-
-#ifndef RTLD_GLOBAL
-# define RTLD_GLOBAL 0
-#endif
-
-#ifndef RTLD_NOW
-# define RTLD_NOW 0
-#endif
-
-struct auth_module {
- struct auth_module *next;
-
- int refcount;
- char *name;
- void *handle;
-};
-
-static struct auth_module *auth_modules = NULL;
-
-static struct auth_module *auth_module_find(const char *name)
-{
- struct auth_module *module;
-
- for (module = auth_modules; module != NULL; module = module->next) {
- if (strcmp(module->name, name) == 0)
- return module;
- }
-
- return NULL;
-}
-
-struct auth_module *auth_module_open(const char *name)
-{
- struct auth_module *module;
- const char *path;
- struct stat st;
- void *handle;
-
- module = auth_module_find(name);
- if (module != NULL) {
- module->refcount++;
- return module;
- }
-
- path = t_strconcat(AUTH_MODULE_DIR"/", name, ".so", NULL);
- if (stat(path, &st) < 0) {
- if (errno != ENOENT)
- i_error("stat(%s) failed: %m", path);
- return NULL;
- }
-
- handle = dlopen(path, RTLD_GLOBAL | RTLD_NOW);
- if (handle == NULL)
- i_error("dlopen(%s) failed: %s", path, dlerror());
-
- module = i_new(struct auth_module, 1);
- module->refcount = 1;
- module->name = i_strdup(name);
- module->handle = handle;
-
- module->next = auth_modules;
- auth_modules = module;
- return module;
-}
-
-void auth_module_close(struct auth_module **_module)
-{
- struct auth_module *module = *_module;
- struct auth_module **pos;
-
- *_module = NULL;
- if (--module->refcount > 0)
- return;
-
- for (pos = &auth_modules; *pos != NULL; pos = &(*pos)->next) {
- if (*pos == module) {
- *pos = module->next;
- break;
- }
- }
-
- if (dlclose(module->handle) != 0)
- i_error("dlclose() failed: %s", dlerror());
- i_free(module->name);
- i_free(module);
-}
-
-void *auth_module_sym(struct auth_module *module, const char *name)
-{
- const char *error;
- void *ret;
-
- ret = dlsym(module->handle, name);
-
- error = dlerror();
- if (error != NULL)
- i_error("dlsym(%s) failed: %s", name, error);
- return ret;
-}
-
-#endif
diff -r e609b4e3a35c -r 968430741daf src/auth/auth-module.h
--- a/src/auth/auth-module.h Mon Aug 06 23:36:43 2007 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-#ifndef __AUTH_MODULE_H
-#define __AUTH_MODULE_H
-
-struct auth_module *auth_module_open(const char *name);
-void auth_module_close(struct auth_module **module);
-
-void *auth_module_sym(struct auth_module *module, const char *name);
-
-#endif
diff -r e609b4e3a35c -r 968430741daf src/auth/auth.h
--- a/src/auth/auth.h Mon Aug 06 23:36:43 2007 +0300
+++ b/src/auth/auth.h Mon Aug 06 23:43:28 2007 +0300
@@ -11,9 +11,7 @@ struct auth_passdb {
unsigned int id;
const char *args;
struct passdb_module *passdb;
-#ifdef HAVE_MODULES
- struct auth_module *module;
-#endif
+
/* if user is found from this passdb, deny authentication immediately */
unsigned int deny:1;
/* after a successful lookup, continue to next passdb */
@@ -27,9 +25,6 @@ struct auth_userdb {
unsigned int num;
const char *args;
struct userdb_module *userdb;
-#ifdef HAVE_MODULES
- struct auth_module *module;
-#endif
};
struct auth {
diff -r e609b4e3a35c -r 968430741daf src/auth/main.c
--- a/src/auth/main.c Mon Aug 06 23:36:43 2007 +0300
+++ b/src/auth/main.c Mon Aug 06 23:43:28 2007 +0300
@@ -8,6 +8,7 @@
#include "restrict-access.h"
#include "fd-close-on-exec.h"
#include "sql-api.h"
+#include "module-dir.h"
#include "randgen.h"
#include "password-scheme.h"
#include "mech.h"
@@ -32,6 +33,7 @@ bool standalone = FALSE, worker = FALSE;
bool standalone = FALSE, worker = FALSE;
time_t process_start_time;
+static struct module *modules = NULL;
static struct auth *auth;
static struct auth_worker_client *worker_client;
@@ -194,8 +196,8 @@ static void drop_privileges(void)
only by root. Also load all modules here. */
passdbs_init();
userdbs_init();
+ modules = module_dir_load(AUTH_MODULE_DIR, NULL, TRUE, PACKAGE_VERSION);
auth = auth_preinit();
- password_schemes_init();
auth_master_listeners_init();
if (!worker)
@@ -229,7 +231,10 @@ static void main_init(bool nodaemon)
lib_signals_ignore(SIGHUP, TRUE);
lib_signals_ignore(SIGUSR2, TRUE);
+ module_dir_init(modules);
+
mech_init();
+ password_schemes_init();
auth_init(auth);
auth_request_handler_init();
@@ -285,6 +290,8 @@ static void main_deinit(void)
auth_worker_server_deinit();
auth_master_listeners_deinit();
+
+ module_dir_unload(&modules);
auth_deinit(&auth);
userdbs_deinit();
passdbs_deinit();
diff -r e609b4e3a35c -r 968430741daf src/auth/passdb.c
--- a/src/auth/passdb.c Mon Aug 06 23:36:43 2007 +0300
+++ b/src/auth/passdb.c Mon Aug 06 23:43:28 2007 +0300
@@ -2,7 +2,6 @@
#include "common.h"
#include "array.h"
-#include "auth-module.h"
#include "password-scheme.h"
#include "auth-worker-server.h"
#include "passdb.h"
@@ -133,15 +132,6 @@ struct auth_passdb *passdb_preinit(struc
auth_passdb->id = id;
iface = passdb_interface_find(driver);
-#ifdef HAVE_MODULES
- if (iface == NULL)
- auth_passdb->module = auth_module_open(driver);
- if (auth_passdb->module != NULL) {
- iface = auth_module_sym(auth_passdb->module,
- t_strconcat("passdb_", driver, NULL));
- }
-#endif
-
if (iface == NULL) {
i_fatal("Unknown passdb driver '%s' "
"(typo, or Dovecot was built without support for it? "
@@ -178,10 +168,6 @@ void passdb_deinit(struct auth_passdb *p
{
if (passdb->passdb->iface.deinit != NULL)
passdb->passdb->iface.deinit(passdb->passdb);
-#ifdef HAVE_MODULES
- if (passdb->module != NULL)
- auth_module_close(&passdb->module);
-#endif
}
extern struct passdb_module_interface passdb_passwd;
diff -r e609b4e3a35c -r 968430741daf src/auth/password-scheme.c
--- a/src/auth/password-scheme.c Mon Aug 06 23:36:43 2007 +0300
+++ b/src/auth/password-scheme.c Mon Aug 06 23:43:28 2007 +0300
@@ -8,7 +8,6 @@
#include "md5.h"
#include "hmac-md5.h"
#include "ntlm.h"
-#include "module-dir.h"
#include "mycrypt.h"
#include "randgen.h"
#include "sha1.h"
@@ -21,9 +20,6 @@ static const char salt_chars[] =
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
ARRAY_TYPE(password_scheme_p) password_schemes;
-#ifdef HAVE_MODULES
-static struct module *scheme_modules;
-#endif
static const struct password_scheme *
password_scheme_lookup_name(const char *name)
@@ -619,37 +615,14 @@ void password_scheme_unregister(const st
void password_schemes_init(void)
{
- const struct password_scheme *s;
-#ifdef HAVE_MODULES
- struct module *mod;
- const char *symbol;
-#endif
unsigned int i;
i_array_init(&password_schemes, N_ELEMENTS(builtin_schemes) + 4);
for (i = 0; i < N_ELEMENTS(builtin_schemes); i++)
password_scheme_register(&builtin_schemes[i]);
-
-#ifdef HAVE_MODULES
- scheme_modules = module_dir_load(AUTH_MODULE_DIR"/password",
- NULL, FALSE, PACKAGE_VERSION);
- module_dir_init(scheme_modules);
- for (mod = scheme_modules; mod != NULL; mod = mod->next) {
- t_push();
More information about the dovecot-cvs
mailing list