1 From d17c6a9c34aa407d2ced8488389520903f16971f Mon Sep 17 00:00:00 2001
2 From: Ron <ron@debian.org>
3 Date: Sat, 25 Oct 2014 00:36:12 +1030
4 Subject: Include the patch level in the dovecot version checks
6 Dovecot broke the t_push() API for 2.2.14 so just checking the major/minor
7 versions is no longer enough. Bonus points for it not actually exporting
8 that version anywhere itself, so we still need to parse the full string to
11 There's a chance this might break some things for dovecot < 2.0 or so
12 (based mostly on the theory that the patch=255 fallback coded into the
13 dovecot-version.c parsing was put there for a reason), but we might be
14 well past the stage of needing to worry about that now. If someone
15 tests it with an earlier version and it breaks there, we'll worry about
16 that when they report how and where it breaks.
18 diff --git a/antispam-plugin.c b/antispam-plugin.c
19 index 103b5fb..6ea49cf 100644
20 --- a/antispam-plugin.c
21 +++ b/antispam-plugin.c
22 @@ -70,7 +70,7 @@ static void lowercase_string(const char *in, char *out)
25 static bool mailbox_patternmatch(struct mailbox *box,
26 -#if DOVECOT_IS_GE(2,0)
27 +#if DOVECOT_IS_GE(2,0,0)
28 const struct mail_namespace *ns,
30 struct mail_storage *storage,
31 @@ -82,7 +82,7 @@ static bool mailbox_patternmatch(struct mailbox *box,
35 -#if DOVECOT_IS_GE(2,0)
36 +#if DOVECOT_IS_GE(2,0,0)
37 if (ns && mailbox_get_namespace(box) != ns)
40 @@ -116,7 +116,7 @@ static bool mailbox_patternmatch(struct mailbox *box,
43 static bool mailbox_patternmatch_case(struct mailbox *box,
44 -#if DOVECOT_IS_GE(2,0)
45 +#if DOVECOT_IS_GE(2,0,0)
46 const struct mail_namespace *ns,
48 struct mail_storage *ns,
49 @@ -127,7 +127,7 @@ static bool mailbox_patternmatch_case(struct mailbox *box,
52 static bool mailbox_patternmatch_icase(struct mailbox *box,
53 -#if DOVECOT_IS_GE(2,0)
54 +#if DOVECOT_IS_GE(2,0,0)
55 const struct mail_namespace *ns,
57 struct mail_storage *ns,
58 @@ -138,7 +138,7 @@ static bool mailbox_patternmatch_icase(struct mailbox *box,
61 static bool _mailbox_equals(struct mailbox *box,
62 -#if DOVECOT_IS_GE(2,0)
63 +#if DOVECOT_IS_GE(2,0,0)
64 const struct mail_namespace *ns,
66 struct mail_storage *ns,
67 @@ -149,7 +149,7 @@ static bool _mailbox_equals(struct mailbox *box,
70 typedef bool (*match_fn_t)(struct mailbox *,
71 -#if DOVECOT_IS_GE(2,0)
72 +#if DOVECOT_IS_GE(2,0,0)
73 const struct mail_namespace *,
75 struct mail_storage *,
76 @@ -187,7 +187,7 @@ static bool mailbox_in_list(struct mailbox *box, char ** const * patterns)
79 if (match_info[i].fn(box,
80 -#if DOVECOT_IS_GE(2,0)
81 +#if DOVECOT_IS_GE(2,0,0)
82 mailbox_get_namespace(box),
84 mailbox_get_storage(box),
85 @@ -374,7 +374,7 @@ void antispam_free_config(struct antispam_config *cfg)
89 -#if DOVECOT_IS_GE(2,0)
90 +#if DOVECOT_IS_GE(2,0,0)
91 void PLUGIN_FUNCTION(init)(struct module *module)
93 antispam_storage_init(module);
94 @@ -392,7 +392,7 @@ void PLUGIN_FUNCTION(deinit)(void)
97 /* put dovecot version we built against into plugin for checking */
98 -#ifdef DOVECOT_ABI_VERSION
99 +#if DOVECOT_IS_GE(2,2,0)
100 const char *PLUGIN_FUNCTION(version) = DOVECOT_ABI_VERSION;
102 const char *PLUGIN_FUNCTION(version) = PACKAGE_VERSION;
103 diff --git a/antispam-plugin.h b/antispam-plugin.h
104 index a06f7be..724ab5e 100644
105 --- a/antispam-plugin.h
106 +++ b/antispam-plugin.h
110 #include "dovecot-version.h"
111 -#if DOVECOT_IS_GE(2, 0)
112 +#if DOVECOT_IS_GE(2,0,0)
113 #include "imap-client.h"
116 @@ -186,7 +186,7 @@ void antispam_free_config(struct antispam_config *cfg);
118 * Dovecot version compat code
120 -#if DOVECOT_IS_EQ(1, 0)
121 +#if DOVECOT_IS_GE(1,0,0) && DOVECOT_IS_LT(1,1,0)
122 #define module_arg void
123 #define ATTR_UNUSED __attr_unused__
124 #define mempool_unref(x) pool_unref(*(x))
125 @@ -217,7 +217,7 @@ static inline int _mail_get_stream(struct mail *mail,
128 #define mail_get_stream _mail_get_stream
129 -#elif DOVECOT_IS_EQ(1, 1)
130 +#elif DOVECOT_IS_GE(1,1,0) && DOVECOT_IS_LT(1,2,0)
131 #define mempool_unref pool_unref
132 #define module_arg void
133 #define ME(err) MAIL_ERROR_ ##err,
134 @@ -236,7 +236,7 @@ o_stream_create_from_fd(int fd, pool_t pool ATTR_UNUSED)
136 return o_stream_create_fd(fd, 0, TRUE);
138 -#elif DOVECOT_IS_EQ(1, 2)
139 +#elif DOVECOT_IS_GE(1,2,0) && DOVECOT_IS_LT(2,0,0)
140 #define mempool_unref pool_unref
141 #define module_arg void
142 #define ME(err) MAIL_ERROR_ ##err,
143 @@ -255,7 +255,7 @@ o_stream_create_from_fd(int fd, pool_t pool ATTR_UNUSED)
145 return o_stream_create_fd(fd, 0, TRUE);
147 -#elif DOVECOT_IS_EQ(2, 0) || DOVECOT_IS_EQ(2, 1)
148 +#elif DOVECOT_IS_GE(2,0,0) && DOVECOT_IS_LT(2,2,0)
149 #define mempool_unref pool_unref
150 #define module_arg struct module *
151 #define ME(err) MAIL_ERROR_ ##err,
152 @@ -277,7 +277,7 @@ o_stream_create_from_fd(int fd, pool_t pool ATTR_UNUSED)
154 return dict_init(uri, DICT_DATA_TYPE_STRING, username, NULL);
156 -#elif DOVECOT_IS_EQ(2, 2)
157 +#elif DOVECOT_IS_GE(2,2,0)
158 #define mempool_unref pool_unref
159 #define module_arg struct module *
160 #define ME(err) MAIL_ERROR_ ##err,
161 diff --git a/dovecot-version.c b/dovecot-version.c
162 index e7e7cf2..a9f980a 100644
163 --- a/dovecot-version.c
164 +++ b/dovecot-version.c
165 @@ -40,19 +40,19 @@ int main(int argc, char **argv)
166 printf("/* Auto-generated file, do not edit */\n\n");
167 printf("#define DOVECOT_VERSION_CODE(maj, min, patch) "
168 "((maj)<<16 | ((min)<<8) | (patch))\n\n");
171 printf("#define DOVECOT_VCODE "
172 - "0x%.2x%.2x%.2x\n", maj, min, 0);
173 - printf("#define DOVECOT_IS_EQ(maj, min) "
174 - "DOVECOT_VCODE == DOVECOT_VERSION_CODE(maj, min, 0)\n");
175 - printf("#define DOVECOT_IS_GT(maj, min) "
176 - "DOVECOT_VCODE > DOVECOT_VERSION_CODE(maj, min, 0)\n");
177 - printf("#define DOVECOT_IS_GE(maj, min) "
178 - "DOVECOT_VCODE >= DOVECOT_VERSION_CODE(maj, min, 0)\n");
179 - printf("#define DOVECOT_IS_LT(maj, min) "
180 - "DOVECOT_VCODE < DOVECOT_VERSION_CODE(maj, min, 0)\n");
181 - printf("#define DOVECOT_IS_LE(maj, min) "
182 - "DOVECOT_VCODE <= DOVECOT_VERSION_CODE(maj, min, 0)\n");
183 + "0x%.2x%.2x%.2x\n", maj, min, patch);
184 + printf("#define DOVECOT_IS_EQ(maj, min, patch) "
185 + "DOVECOT_VCODE == DOVECOT_VERSION_CODE(maj, min, patch)\n");
186 + printf("#define DOVECOT_IS_GT(maj, min, patch) "
187 + "DOVECOT_VCODE > DOVECOT_VERSION_CODE(maj, min, patch)\n");
188 + printf("#define DOVECOT_IS_GE(maj, min, patch) "
189 + "DOVECOT_VCODE >= DOVECOT_VERSION_CODE(maj, min, patch)\n");
190 + printf("#define DOVECOT_IS_LT(maj, min, patch) "
191 + "DOVECOT_VCODE < DOVECOT_VERSION_CODE(maj, min, patch)\n");
192 + printf("#define DOVECOT_IS_LE(maj, min, patch) "
193 + "DOVECOT_VCODE <= DOVECOT_VERSION_CODE(maj, min, patch)\n");
195 /* Use the antispam-storage-2.0.c for dovecot 2.1 and 2.2 as well */
196 if (maj == 2 && min < 3)
200 From 2aa93d15409f5a47589d264991fd3e8261d34b1b Mon Sep 17 00:00:00 2001
201 From: Ron <ron@debian.org>
202 Date: Sat, 25 Oct 2014 00:47:21 +1030
203 Subject: Add a compatibility macro for t_push()
205 This should fix things for the API change in dovecot 2.2.14 reported in:
206 https://bugs.debian.org/765943
208 diff --git a/antispam-plugin.h b/antispam-plugin.h
209 index 724ab5e..939e27e 100644
210 --- a/antispam-plugin.h
211 +++ b/antispam-plugin.h
212 @@ -299,6 +299,10 @@ o_stream_create_from_fd(int fd, pool_t pool ATTR_UNUSED)
213 #define module_arg struct module *
214 #define ME(err) MAIL_ERROR_ ##err,
216 +#if DOVECOT_IS_GE(2,2,14)
217 +#define t_push() t_push(__func__)
220 static inline const char *const *
221 get_mail_headers(struct mail *mail, const char *hdr)