dovecot-2.0: If module can't be loaded due to missing dependency...

dovecot at dovecot.org dovecot at dovecot.org
Fri Jul 30 18:17:05 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/02c9154efe81
changeset: 11906:02c9154efe81
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Jul 30 16:17:02 2010 +0100
description:
If module can't be loaded due to missing dependency, suggest a setting how to do it.

diffstat:

 src/lib-storage/mail-storage-service.c |   1 +
 src/lib/module-dir.c                   |  22 +++++++++++++++++-----
 src/lib/module-dir.h                   |   2 ++
 3 files changed, 20 insertions(+), 5 deletions(-)

diffs (80 lines):

diff -r d5a923df60d4 -r 02c9154efe81 src/lib-storage/mail-storage-service.c
--- a/src/lib-storage/mail-storage-service.c	Wed Jul 28 11:09:50 2010 +0200
+++ b/src/lib-storage/mail-storage-service.c	Fri Jul 30 16:17:02 2010 +0100
@@ -711,6 +711,7 @@
 	memset(&mod_set, 0, sizeof(mod_set));
 	mod_set.version = master_service_get_version_string(ctx->service);
 	mod_set.binary_name = master_service_get_name(ctx->service);
+	mod_set.setting_name = "mail_plugins";
 	mod_set.require_init_funcs = TRUE;
 	mod_set.debug = mail_user_set_get_mail_debug(user_info, user_set);
 
diff -r d5a923df60d4 -r 02c9154efe81 src/lib/module-dir.c
--- a/src/lib/module-dir.c	Wed Jul 28 11:09:50 2010 +0200
+++ b/src/lib/module-dir.c	Fri Jul 30 16:17:02 2010 +0100
@@ -2,6 +2,7 @@
 
 #include "lib.h"
 #include "array.h"
+#include "str.h"
 #include "module-dir.h"
 
 #ifdef HAVE_MODULES
@@ -88,11 +89,13 @@
 }
 
 static bool
-module_check_missing_plugin_dependencies(struct module *module,
+module_check_missing_plugin_dependencies(const struct module_dir_load_settings *set,
+					 struct module *module,
 					 struct module *all_modules)
 {
 	const char **deps;
 	struct module *m;
+	string_t *errmsg;
 	unsigned int len;
 
 	deps = dlsym(module->handle,
@@ -109,9 +112,17 @@
 				break;
 		}
 		if (m == NULL) {
-			i_error("Can't load plugin %s: "
-				"Plugin %s must be loaded also",
-				module->name, *deps);
+			errmsg = t_str_new(128);
+			str_printfa(errmsg, "Can't load plugin %s: "
+				    "Plugin %s must be loaded also",
+				    module->name, *deps);
+			if (set->setting_name != NULL) {
+				str_printfa(errmsg,
+					    " (you must set: %s=$%s %s)",
+					    set->setting_name,
+					    set->setting_name, *deps);
+			}
+			i_error("%s", str_c(errmsg));
 			return FALSE;
 		}
 	}
@@ -207,7 +218,8 @@
 			module->init == NULL ? "init" : "deinit", path);
 		failed = TRUE;
 	} else if (!module_check_wrong_binary_dependency(set, module) ||
-		   !module_check_missing_plugin_dependencies(module, all_modules))
+		   !module_check_missing_plugin_dependencies(set, module,
+							     all_modules))
 		failed = TRUE;
 
 	if (failed) {
diff -r d5a923df60d4 -r 02c9154efe81 src/lib/module-dir.h
--- a/src/lib/module-dir.h	Wed Jul 28 11:09:50 2010 +0200
+++ b/src/lib/module-dir.h	Fri Jul 30 16:17:02 2010 +0100
@@ -8,6 +8,8 @@
 	/* Binary name used for checking if plugin is tried to be loaded for
 	   wrong binary. */
 	const char *binary_name;
+	/* Setting name used in plugin dependency error message */
+	const char *setting_name;
 
 	/* Require all plugins to have <plugin_name>_init() function */
 	unsigned int require_init_funcs:1;


More information about the dovecot-cvs mailing list