From 74e035200d9a79d08010b764687379bc671c480a Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan@rename-it.nl>
Date: Thu, 6 Aug 2015 22:23:03 +0200
Subject: [PATCH] lib-sieve: Properly implemented checking of ABI version for
 plugins.

---
 configure.ac                                             | 2 ++
 pigeonhole-config.h.in                                   | 3 +++
 src/lib-sieve/sieve-plugins.c                            | 2 +-
 src/lib-sieve/storage/ldap/sieve-ldap-storage.c          | 2 ++
 src/plugins/sieve-extprograms/sieve-extprograms-plugin.c | 2 ++
 5 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index d802991c9..0d4783856 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,6 @@
 AC_INIT([Pigeonhole], [0.4.8], [dovecot@dovecot.org], [dovecot-2.2-pigeonhole])
+AC_DEFINE_UNQUOTED([PIGEONHOLE_ABI_VERSION], "0.4.ABIv1($PACKAGE_VERSION)", [Pigeonhole ABI version])
+
 AC_CONFIG_AUX_DIR([.])
 AC_CONFIG_SRCDIR([src])
 AC_CONFIG_MACRO_DIR([m4])
diff --git a/pigeonhole-config.h.in b/pigeonhole-config.h.in
index e28e583ea..60b0ff9fb 100644
--- a/pigeonhole-config.h.in
+++ b/pigeonhole-config.h.in
@@ -5,6 +5,9 @@
 /* Define to the version of Pigeonhole for Dovecot. */
 #undef PIGEONHOLE_VERSION
 
+/* Pigeonhole ABI version */
+#undef PIGEONHOLE_ABI_VERSION
+
 /* Define to build unfinished features/extensions. */
 #undef HAVE_SIEVE_UNFINISHED
 
diff --git a/src/lib-sieve/sieve-plugins.c b/src/lib-sieve/sieve-plugins.c
index 93656abd4..b7f98a4b4 100644
--- a/src/lib-sieve/sieve-plugins.c
+++ b/src/lib-sieve/sieve-plugins.c
@@ -77,7 +77,7 @@ void sieve_plugins_load
 		path = MODULEDIR"/sieve";
 
 	memset(&mod_set, 0, sizeof(mod_set));
-	mod_set.abi_version = PIGEONHOLE_VERSION;
+	mod_set.abi_version = PIGEONHOLE_ABI_VERSION;
 	mod_set.require_init_funcs = TRUE;
 	mod_set.debug = FALSE;
 
diff --git a/src/lib-sieve/storage/ldap/sieve-ldap-storage.c b/src/lib-sieve/storage/ldap/sieve-ldap-storage.c
index 873574c55..81e7e7162 100644
--- a/src/lib-sieve/storage/ldap/sieve-ldap-storage.c
+++ b/src/lib-sieve/storage/ldap/sieve-ldap-storage.c
@@ -184,6 +184,8 @@ const struct sieve_storage sieve_ldap_storage_plugin = {
 #ifndef SIEVE_BUILTIN_LDAP
 /* Building a plugin */
 
+const char *sieve_storage_ldap_plugin_version = PIGEONHOLE_ABI_VERSION;
+
 void sieve_storage_ldap_plugin_load
 (struct sieve_instance *svinst, void **context);
 void sieve_storage_ldap_plugin_unload
diff --git a/src/plugins/sieve-extprograms/sieve-extprograms-plugin.c b/src/plugins/sieve-extprograms/sieve-extprograms-plugin.c
index acd9ac667..c629336d7 100644
--- a/src/plugins/sieve-extprograms/sieve-extprograms-plugin.c
+++ b/src/plugins/sieve-extprograms/sieve-extprograms-plugin.c
@@ -18,6 +18,8 @@ struct _plugin_context {
 	const struct sieve_extension *ext_execute;		
 };
 
+const char *sieve_extprograms_plugin_version = PIGEONHOLE_ABI_VERSION;
+
 void sieve_extprograms_plugin_load
 (struct sieve_instance *svinst, void **context)
 {
-- 
GitLab