dovecot-2.2: Plugin ABI version checking improvements.
dovecot at dovecot.org
dovecot at dovecot.org
Fri Oct 12 00:52:06 EEST 2012
details: http://hg.dovecot.org/dovecot-2.2/rev/73916b7be94e
changeset: 15199:73916b7be94e
user: Timo Sirainen <tss at iki.fi>
date: Fri Oct 12 00:51:41 2012 +0300
description:
Plugin ABI version checking improvements.
Previously the plugin version was checked against the version string
returned by the currently running Dovecot master process, not necessarily
the same as the binary. Also version_ignore=yes setting skipped the version
check entirely.
Now there's a new DOVECOT_ABI_VERSION macro that can (at least in theory) be
updated only when the ABI actually changes. The version is in format
"2.2.ABIv1(2.2.15)", where the (2.2.15) would be the actual Dovecot version
number that gets ignored when comparing the strings.
Also now the plugin version is compared to the actually running binary's
ABI, not the master's version, and it can't be ignored with a setting.
diffstat:
configure.in | 1 +
src/auth/main.c | 4 ++--
src/config/config-parser.c | 2 +-
src/dict/main.c | 2 +-
src/doveadm/doveadm-mail.c | 2 +-
src/doveadm/doveadm-util.c | 2 +-
src/lib-sql/driver-mysql.c | 2 +-
src/lib-sql/driver-pgsql.c | 2 +-
src/lib-sql/driver-sqlite.c | 2 +-
src/lib-storage/mail-storage-service.c | 2 +-
src/lib/module-dir.c | 19 +++++++++++++++----
src/lib/module-dir.h | 8 +++++---
src/plugins/acl/acl-plugin.c | 2 +-
src/plugins/acl/doveadm-acl.c | 2 +-
src/plugins/expire/doveadm-expire.c | 2 +-
src/plugins/expire/expire-plugin.c | 2 +-
src/plugins/fts-lucene/doveadm-fts-lucene.c | 2 +-
src/plugins/fts-lucene/fts-lucene-plugin.c | 2 +-
src/plugins/fts-solr/fts-solr-plugin.c | 2 +-
src/plugins/fts-squat/fts-squat-plugin.c | 2 +-
src/plugins/fts/doveadm-fts.c | 2 +-
src/plugins/fts/fts-plugin.c | 2 +-
src/plugins/imap-acl/imap-acl-plugin.c | 2 +-
src/plugins/imap-quota/imap-quota-plugin.c | 2 +-
src/plugins/imap-stats/imap-stats-plugin.c | 2 +-
src/plugins/imap-zlib/imap-zlib-plugin.c | 2 +-
src/plugins/lazy-expunge/lazy-expunge-plugin.c | 2 +-
src/plugins/listescape/listescape-plugin.c | 2 +-
src/plugins/mailbox-alias/mailbox-alias-plugin.c | 2 +-
src/plugins/notify/notify-plugin.c | 2 +-
src/plugins/pop3-migration/pop3-migration-plugin.c | 2 +-
src/plugins/quota/doveadm-quota.c | 2 +-
src/plugins/quota/quota-plugin.c | 2 +-
src/plugins/snarf/snarf-plugin.c | 2 +-
src/plugins/stats/stats-plugin.c | 2 +-
src/plugins/trash/trash-plugin.c | 2 +-
src/plugins/virtual/virtual-plugin.c | 2 +-
src/plugins/zlib/doveadm-zlib.c | 2 +-
src/plugins/zlib/zlib-plugin.c | 2 +-
39 files changed, 58 insertions(+), 44 deletions(-)
diffs (truncated from 507 to 300 lines):
diff -r ce57bacc3010 -r 73916b7be94e configure.in
--- a/configure.in Fri Oct 12 00:22:19 2012 +0300
+++ b/configure.in Fri Oct 12 00:51:41 2012 +0300
@@ -1,5 +1,6 @@
AC_PREREQ([2.59])
AC_INIT([Dovecot],[2.2.UNSTABLE],[dovecot at dovecot.org])
+AC_DEFINE_UNQUOTED([DOVECOT_ABI_VERSION], "2.2.ABIv0($PACKAGE_VERSION)", [Dovecot ABI version])
AC_CONFIG_SRCDIR([src])
AM_INIT_AUTOMAKE([foreign])
diff -r ce57bacc3010 -r 73916b7be94e src/auth/main.c
--- a/src/auth/main.c Fri Oct 12 00:22:19 2012 +0300
+++ b/src/auth/main.c Fri Oct 12 00:51:41 2012 +0300
@@ -188,7 +188,7 @@
services = read_global_settings();
memset(&mod_set, 0, sizeof(mod_set));
- mod_set.version = master_service_get_version_string(master_service);
+ mod_set.abi_version = DOVECOT_ABI_VERSION;
mod_set.require_init_funcs = TRUE;
mod_set.debug = global_auth_settings->debug;
mod_set.filter_callback = auth_module_filter;
@@ -218,7 +218,7 @@
struct module_dir_load_settings mod_set;
memset(&mod_set, 0, sizeof(mod_set));
- mod_set.version = master_service_get_version_string(master_service);
+ mod_set.abi_version = DOVECOT_ABI_VERSION;
mod_set.require_init_funcs = TRUE;
mod_set.debug = global_auth_settings->debug;
mod_set.ignore_missing = TRUE;
diff -r ce57bacc3010 -r 73916b7be94e src/config/config-parser.c
--- a/src/config/config-parser.c Fri Oct 12 00:22:19 2012 +0300
+++ b/src/config/config-parser.c Fri Oct 12 00:51:41 2012 +0300
@@ -989,7 +989,7 @@
unsigned int i, count;
memset(&mod_set, 0, sizeof(mod_set));
- mod_set.version = master_service_get_version_string(master_service);
+ mod_set.abi_version = DOVECOT_ABI_VERSION;
modules = module_dir_load(CONFIG_MODULE_DIR, NULL, &mod_set);
module_dir_init(modules);
diff -r ce57bacc3010 -r 73916b7be94e src/dict/main.c
--- a/src/dict/main.c Fri Oct 12 00:22:19 2012 +0300
+++ b/src/dict/main.c Fri Oct 12 00:51:41 2012 +0300
@@ -55,7 +55,7 @@
}
memset(&mod_set, 0, sizeof(mod_set));
- mod_set.version = master_service_get_version_string(master_service);
+ mod_set.abi_version = DOVECOT_ABI_VERSION;
mod_set.require_init_funcs = TRUE;
modules = module_dir_load(DICT_MODULE_DIR, NULL, &mod_set);
diff -r ce57bacc3010 -r 73916b7be94e src/doveadm/doveadm-mail.c
--- a/src/doveadm/doveadm-mail.c Fri Oct 12 00:22:19 2012 +0300
+++ b/src/doveadm/doveadm-mail.c Fri Oct 12 00:51:41 2012 +0300
@@ -703,7 +703,7 @@
doveadm_mail_register_cmd(mail_commands[i]);
memset(&mod_set, 0, sizeof(mod_set));
- mod_set.version = master_service_get_version_string(master_service);
+ mod_set.abi_version = DOVECOT_ABI_VERSION;
mod_set.require_init_funcs = TRUE;
mod_set.debug = doveadm_debug;
mod_set.binary_name = "doveadm";
diff -r ce57bacc3010 -r 73916b7be94e src/doveadm/doveadm-util.c
--- a/src/doveadm/doveadm-util.c Fri Oct 12 00:22:19 2012 +0300
+++ b/src/doveadm/doveadm-util.c Fri Oct 12 00:51:41 2012 +0300
@@ -25,7 +25,7 @@
only those whose dependencies have been loaded earlier, the rest are
ignored. */
memset(&mod_set, 0, sizeof(mod_set));
- mod_set.version = master_service_get_version_string(master_service);
+ mod_set.abi_version = DOVECOT_ABI_VERSION;
mod_set.require_init_funcs = TRUE;
mod_set.debug = doveadm_debug;
mod_set.ignore_dlopen_errors = TRUE;
diff -r ce57bacc3010 -r 73916b7be94e src/lib-sql/driver-mysql.c
--- a/src/lib-sql/driver-mysql.c Fri Oct 12 00:22:19 2012 +0300
+++ b/src/lib-sql/driver-mysql.c Fri Oct 12 00:51:41 2012 +0300
@@ -659,7 +659,7 @@
.failed_try_retry = TRUE
};
-const char *driver_mysql_version = DOVECOT_VERSION;
+const char *driver_mysql_version = DOVECOT_ABI_VERSION;
void driver_mysql_init(void);
void driver_mysql_deinit(void);
diff -r ce57bacc3010 -r 73916b7be94e src/lib-sql/driver-pgsql.c
--- a/src/lib-sql/driver-pgsql.c Fri Oct 12 00:22:19 2012 +0300
+++ b/src/lib-sql/driver-pgsql.c Fri Oct 12 00:51:41 2012 +0300
@@ -1087,7 +1087,7 @@
}
};
-const char *driver_pgsql_version = DOVECOT_VERSION;
+const char *driver_pgsql_version = DOVECOT_ABI_VERSION;
void driver_pgsql_init(void);
void driver_pgsql_deinit(void);
diff -r ce57bacc3010 -r 73916b7be94e src/lib-sql/driver-sqlite.c
--- a/src/lib-sql/driver-sqlite.c Fri Oct 12 00:22:19 2012 +0300
+++ b/src/lib-sql/driver-sqlite.c Fri Oct 12 00:51:41 2012 +0300
@@ -444,7 +444,7 @@
}
};
-const char *driver_sqlite_version = DOVECOT_VERSION;
+const char *driver_sqlite_version = DOVECOT_ABI_VERSION;
void driver_sqlite_init(void);
void driver_sqlite_deinit(void);
diff -r ce57bacc3010 -r 73916b7be94e src/lib-storage/mail-storage-service.c
--- a/src/lib-storage/mail-storage-service.c Fri Oct 12 00:22:19 2012 +0300
+++ b/src/lib-storage/mail-storage-service.c Fri Oct 12 00:51:41 2012 +0300
@@ -918,7 +918,7 @@
return;
memset(&mod_set, 0, sizeof(mod_set));
- mod_set.version = master_service_get_version_string(ctx->service);
+ mod_set.abi_version = DOVECOT_ABI_VERSION;
mod_set.binary_name = master_service_get_name(ctx->service);
mod_set.setting_name = "mail_plugins";
mod_set.require_init_funcs = TRUE;
diff -r ce57bacc3010 -r 73916b7be94e src/lib/module-dir.c
--- a/src/lib/module-dir.c Fri Oct 12 00:22:19 2012 +0300
+++ b/src/lib/module-dir.c Fri Oct 12 00:51:41 2012 +0300
@@ -168,6 +168,17 @@
#endif
}
+static bool versions_equal(const char *str1, const char *str2)
+{
+ while (*str1 == *str2) {
+ if (*str1 == '\0' || *str1 == '(')
+ return TRUE;
+ str1++;
+ str2++;
+ }
+ return FALSE;
+}
+
static struct module *
module_load(const char *path, const char *name,
const struct module_dir_load_settings *set,
@@ -212,12 +223,12 @@
module->name = i_strdup(name);
module->handle = handle;
- module_version = set->version == NULL ? NULL :
+ module_version = set->abi_version == NULL ? NULL :
get_symbol(module, t_strconcat(name, "_version", NULL), TRUE);
if (module_version != NULL &&
- strcmp(*module_version, set->version) != 0) {
- i_error("Module is for different version %s: %s",
- *module_version, path);
+ !versions_equal(*module_version, set->abi_version)) {
+ i_error("Module is for different ABI version %s (we have %s): %s",
+ *module_version, set->abi_version, path);
module_free(module);
return NULL;
}
diff -r ce57bacc3010 -r 73916b7be94e src/lib/module-dir.h
--- a/src/lib/module-dir.h Fri Oct 12 00:22:19 2012 +0300
+++ b/src/lib/module-dir.h Fri Oct 12 00:51:41 2012 +0300
@@ -2,9 +2,11 @@
#define MODULE_DIR_H
struct module_dir_load_settings {
- /* If version is non-NULL and the module contains a version symbol,
- fail the load if they're different. */
- const char *version;
+ /* If abi_version is non-NULL and the module contains a version symbol,
+ fail the load if they're different. In both strings ignore anything
+ after the first '(' character, so the version can be e.g.:
+ 2.2.ABIv1(2.2.15) */
+ const char *abi_version;
/* Binary name used for checking if plugin is tried to be loaded for
wrong binary. */
const char *binary_name;
diff -r ce57bacc3010 -r 73916b7be94e src/plugins/acl/acl-plugin.c
--- a/src/plugins/acl/acl-plugin.c Fri Oct 12 00:22:19 2012 +0300
+++ b/src/plugins/acl/acl-plugin.c Fri Oct 12 00:51:41 2012 +0300
@@ -7,7 +7,7 @@
#include <stdlib.h>
-const char *acl_plugin_version = DOVECOT_VERSION;
+const char *acl_plugin_version = DOVECOT_ABI_VERSION;
static struct mail_storage_hooks acl_mail_storage_hooks = {
.mail_user_created = acl_mail_user_created,
diff -r ce57bacc3010 -r 73916b7be94e src/plugins/acl/doveadm-acl.c
--- a/src/plugins/acl/doveadm-acl.c Fri Oct 12 00:22:19 2012 +0300
+++ b/src/plugins/acl/doveadm-acl.c Fri Oct 12 00:51:41 2012 +0300
@@ -16,7 +16,7 @@
enum acl_modify_mode modify_mode;
};
-const char *doveadm_acl_plugin_version = DOVECOT_VERSION;
+const char *doveadm_acl_plugin_version = DOVECOT_ABI_VERSION;
void doveadm_acl_plugin_init(struct module *module);
void doveadm_acl_plugin_deinit(void);
diff -r ce57bacc3010 -r 73916b7be94e src/plugins/expire/doveadm-expire.c
--- a/src/plugins/expire/doveadm-expire.c Fri Oct 12 00:22:19 2012 +0300
+++ b/src/plugins/expire/doveadm-expire.c Fri Oct 12 00:51:41 2012 +0300
@@ -40,7 +40,7 @@
bool delete_nonexistent_users;
};
-const char *doveadm_expire_plugin_version = DOVECOT_VERSION;
+const char *doveadm_expire_plugin_version = DOVECOT_ABI_VERSION;
void doveadm_expire_plugin_init(struct module *module);
void doveadm_expire_plugin_deinit(void);
diff -r ce57bacc3010 -r 73916b7be94e src/plugins/expire/expire-plugin.c
--- a/src/plugins/expire/expire-plugin.c Fri Oct 12 00:22:19 2012 +0300
+++ b/src/plugins/expire/expire-plugin.c Fri Oct 12 00:51:41 2012 +0300
@@ -39,7 +39,7 @@
unsigned int first_expunged:1;
};
-const char *expire_plugin_version = DOVECOT_VERSION;
+const char *expire_plugin_version = DOVECOT_ABI_VERSION;
static MODULE_CONTEXT_DEFINE_INIT(expire_storage_module,
&mail_storage_module_register);
diff -r ce57bacc3010 -r 73916b7be94e src/plugins/fts-lucene/doveadm-fts-lucene.c
--- a/src/plugins/fts-lucene/doveadm-fts-lucene.c Fri Oct 12 00:22:19 2012 +0300
+++ b/src/plugins/fts-lucene/doveadm-fts-lucene.c Fri Oct 12 00:51:41 2012 +0300
@@ -8,7 +8,7 @@
#include <stdio.h>
#include <sys/stat.h>
-const char *doveadm_fts_lucene_plugin_version = DOVECOT_VERSION;
+const char *doveadm_fts_lucene_plugin_version = DOVECOT_ABI_VERSION;
void doveadm_fts_lucene_plugin_init(struct module *module);
void doveadm_fts_lucene_plugin_deinit(void);
diff -r ce57bacc3010 -r 73916b7be94e src/plugins/fts-lucene/fts-lucene-plugin.c
--- a/src/plugins/fts-lucene/fts-lucene-plugin.c Fri Oct 12 00:22:19 2012 +0300
+++ b/src/plugins/fts-lucene/fts-lucene-plugin.c Fri Oct 12 00:51:41 2012 +0300
@@ -6,7 +6,7 @@
#include "lucene-wrapper.h"
#include "fts-lucene-plugin.h"
-const char *fts_lucene_plugin_version = DOVECOT_VERSION;
+const char *fts_lucene_plugin_version = DOVECOT_ABI_VERSION;
struct fts_lucene_user_module fts_lucene_user_module =
MODULE_CONTEXT_INIT(&mail_user_module_register);
diff -r ce57bacc3010 -r 73916b7be94e src/plugins/fts-solr/fts-solr-plugin.c
--- a/src/plugins/fts-solr/fts-solr-plugin.c Fri Oct 12 00:22:19 2012 +0300
+++ b/src/plugins/fts-solr/fts-solr-plugin.c Fri Oct 12 00:51:41 2012 +0300
@@ -8,7 +8,7 @@
#include <stdlib.h>
-const char *fts_solr_plugin_version = DOVECOT_VERSION;
+const char *fts_solr_plugin_version = DOVECOT_ABI_VERSION;
struct fts_solr_user_module fts_solr_user_module =
MODULE_CONTEXT_INIT(&mail_user_module_register);
diff -r ce57bacc3010 -r 73916b7be94e src/plugins/fts-squat/fts-squat-plugin.c
--- a/src/plugins/fts-squat/fts-squat-plugin.c Fri Oct 12 00:22:19 2012 +0300
+++ b/src/plugins/fts-squat/fts-squat-plugin.c Fri Oct 12 00:51:41 2012 +0300
@@ -3,7 +3,7 @@
#include "lib.h"
#include "fts-squat-plugin.h"
-const char *fts_squat_plugin_version = DOVECOT_VERSION;
+const char *fts_squat_plugin_version = DOVECOT_ABI_VERSION;
void fts_squat_plugin_init(struct module *module ATTR_UNUSED)
{
diff -r ce57bacc3010 -r 73916b7be94e src/plugins/fts/doveadm-fts.c
--- a/src/plugins/fts/doveadm-fts.c Fri Oct 12 00:22:19 2012 +0300
+++ b/src/plugins/fts/doveadm-fts.c Fri Oct 12 00:51:41 2012 +0300
@@ -6,7 +6,7 @@
#include "doveadm-mail.h"
#include "doveadm-fts.h"
-const char *doveadm_fts_plugin_version = DOVECOT_VERSION;
+const char *doveadm_fts_plugin_version = DOVECOT_ABI_VERSION;
static int
fts_namespace_find(struct mail_user *user, const char *ns_prefix,
diff -r ce57bacc3010 -r 73916b7be94e src/plugins/fts/fts-plugin.c
--- a/src/plugins/fts/fts-plugin.c Fri Oct 12 00:22:19 2012 +0300
+++ b/src/plugins/fts/fts-plugin.c Fri Oct 12 00:51:41 2012 +0300
@@ -7,7 +7,7 @@
#include <stdlib.h>
-const char *fts_plugin_version = DOVECOT_VERSION;
+const char *fts_plugin_version = DOVECOT_ABI_VERSION;
More information about the dovecot-cvs
mailing list