[dovecot-cvs] dovecot/src/lib module-dir.c, 1.19.2.8, 1.19.2.9 module-dir.h, 1.7.2.1, 1.7.2.2

tss at dovecot.org tss at dovecot.org
Thu Feb 22 14:36:02 UTC 2007


Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv15806/lib

Modified Files:
      Tag: branch_1_0
	module-dir.c module-dir.h 
Log Message:
Don't compare to PACKAGE_VERSION in lib/ core directly, rather make
module_dir_load() have the version string as parameter. Plugin version
checks can be skipped with version_ignore=yes.



Index: module-dir.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/module-dir.c,v
retrieving revision 1.19.2.8
retrieving revision 1.19.2.9
diff -u -d -r1.19.2.8 -r1.19.2.9
--- module-dir.c	22 Feb 2007 14:25:16 -0000	1.19.2.8
+++ module-dir.c	22 Feb 2007 14:35:59 -0000	1.19.2.9
@@ -83,11 +83,12 @@
 }
 
 static struct module *
-module_load(const char *path, const char *name, bool require_init_funcs)
+module_load(const char *path, const char *name, bool require_init_funcs,
+	    const char *version)
 {
 	void *handle;
 	struct module *module;
-	const char *const *version;
+	const char *const *module_version;
 
 	handle = dlopen(path, RTLD_GLOBAL | RTLD_NOW);
 	if (handle == NULL) {
@@ -100,10 +101,12 @@
 	module->name = i_strdup(name);
 	module->handle = handle;
 
-	version = get_symbol(module, t_strconcat(name, "_version", NULL), TRUE);
-	if (version != NULL && strcmp(*version, PACKAGE_VERSION) != 0) {
+	module_version = version == NULL ? NULL :
+		get_symbol(module, t_strconcat(name, "_version", NULL), TRUE);
+	if (module_version != NULL &&
+	    strcmp(*module_version, version) != 0) {
 		i_error("Module is for different version %s: %s",
-			*version, path);
+			*module_version, path);
 		module_free(module);
 		return NULL;
 	}
@@ -183,7 +186,7 @@
 }
 
 struct module *module_dir_load(const char *dir, const char *module_names,
-			       bool require_init_funcs)
+			       bool require_init_funcs, const char *version)
 {
 	DIR *dirp;
 	struct dirent *d;
@@ -257,7 +260,7 @@
 		else {
 			path = t_strconcat(dir, "/", name, NULL);
 			module = module_load(path, stripped_name,
-					     require_init_funcs);
+					     require_init_funcs, version);
 			if (module == NULL && module_names_arr != NULL)
 				exit(FATAL_DEFAULT);
 		}

Index: module-dir.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/module-dir.h,v
retrieving revision 1.7.2.1
retrieving revision 1.7.2.2
diff -u -d -r1.7.2.1 -r1.7.2.2
--- module-dir.h	16 Feb 2007 13:12:03 -0000	1.7.2.1
+++ module-dir.h	22 Feb 2007 14:35:59 -0000	1.7.2.2
@@ -12,9 +12,10 @@
 };
 
 /* Load modules in given directory. module_names is a space separated list of
-   module names to load, or NULL to load everything. */
+   module names to load, or NULL to load everything. If version is non-NULL and
+   the module contains a version symbol, fail the load if they're different. */
 struct module *module_dir_load(const char *dir, const char *module_names,
-			       bool require_init_funcs);
+			       bool require_init_funcs, const char *version);
 /* Call init() in all modules */
 void module_dir_init(struct module *modules);
 /* Call deinit() in all modules and mark them NULL so module_dir_unload()



More information about the dovecot-cvs mailing list