Gentoo Archives: gentoo-commits

From: "Robin H. Johnson" <robbat2@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: mail-mta/netqmail/, mail-mta/netqmail/files/
Date: Sun, 27 Nov 2016 16:48:21
Message-Id: 1480265291.656ae3db884b62b3576f24741cf18c6dc53226c5.robbat2@gentoo
1 commit: 656ae3db884b62b3576f24741cf18c6dc53226c5
2 Author: Arnt Gulbrandsen <arnt <AT> gulbrandsen <DOT> priv <DOT> no>
3 AuthorDate: Tue Nov 15 14:20:37 2016 +0000
4 Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
5 CommitDate: Sun Nov 27 16:48:11 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=656ae3db
7
8 mail-mta/netqmail: Add SMTPUTF8 support for qmail
9
10 SMTPUTF8 (RFCs 6531 and 6532, plus several that aren't relevant to qmail)
11 allows using unencoded UTF8 almost everywhere in email, including in
12 localparts, domains, subjects and message bodies.
13
14 Thanks to cnnic.cn for sponsoring this work.
15
16 (cherry picked from commit 5116b83a9bf93f59fb7b7d3fcd286f7b2c4da438)
17 Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
18
19 mail-mta/netqmail/Manifest | 1 +
20 mail-mta/netqmail/files/qmail-smtputf8.patch | 242 +++++++++++++++++++++++++++
21 mail-mta/netqmail/netqmail-1.06-r5.ebuild | 183 ++++++++++++++++++++
22 3 files changed, 426 insertions(+)
23
24 diff --git a/mail-mta/netqmail/Manifest b/mail-mta/netqmail/Manifest
25 index cedd87f..39e82f2 100644
26 --- a/mail-mta/netqmail/Manifest
27 +++ b/mail-mta/netqmail/Manifest
28 @@ -5,3 +5,4 @@ DIST netqmail-1.06.tar.gz 260941 SHA256 8e7d98d15211fc9f9c28109e942e2268f42a6672
29 DIST qmail-103.patch 2104 SHA256 4cad53c7a6628a600c74c36bfee327db5052ca24c222d4013e4dfcd7f427653d SHA512 b81062bb0b0023f474c0b6af40601926e1c04ad395de480d114809e48a8060c06d99bdbdeb6f44d9e24ae1acedabb094b979193d305371aed958f18fc6eee354 WHIRLPOOL 5785684b98b9d9732ed14aa1b53910746bd09aa93514e0e6ef3d74831c3df8ed0a55f257057488f34a3d462e485b7a4417ed255f66abaff6dd63d881b9230063
30 DIST qmail-spp-0.42.tar.gz 18689 SHA256 1518e7e82d10fbbb8ecc520f51daf503edeb9c3a9fb935be65a8185e7b53808d SHA512 03449862886a0ca20fbadab4c94b34b55d185f8df3261bd68aea99e9ded9edfab4477c6b38a8e0295e9b38b0045615da8b1a906a458f28745eadd3c4d882bcbf WHIRLPOOL 2f8525bb264fbec4b057bad6d92968e29085fdf10b8538b8e572d81ea8793e74c07c6093d0cc2a34de00b629e797b048007b30e3845dce76829037fdb44f527c
31 DIST vu555316.patch 617 SHA256 cc7b2876ecb183fe55c280404c1c825a6bd1f6ccc87db67e7cfc8bc6336f9b0f SHA512 5d7810360e5eaa8e8ee141fe92c765d9458aa12198a8d0ac702e0630e08d060ad4a1d33690d434f20f5aff79eb200cd8173bebc334c411e340c0198b5d8d1a65 WHIRLPOOL 2564d5622576b89918e247de5dd830011e8ef18a50fd03e6f48e98ebf4a53db2f4994eb0fb22a76c4cd0cbb35b457ac2a5507e05159130a72685866137c5ebc1
32 +DIST qmail-smtputf8.patch 6693 SHA256 cf3a802d439fe53e9cecbeb82a6ce6ff5c71b5fcd0b053eac5a19df918724cfa SHA512 8cafdf1a4f1fd41e6b11ee2abddac5c3da4a1d2ab17b5d3847433875a91f867a26eb358ae8c41791f1e77758e5a2c311134a286d888ccd23fbede6d9f0b475c4 WHIRLPOOL 36d2a822cf42efbe34e0e95da6e171a3394c049cfbcf2a3b68efe789b4199f00fcdb942d1e93268283a4eec15ad3ead7a58df31a327ade517c218fb18f8a7801
33
34 diff --git a/mail-mta/netqmail/files/qmail-smtputf8.patch b/mail-mta/netqmail/files/qmail-smtputf8.patch
35 new file mode 100644
36 index 00000000..5b656b9
37 --- /dev/null
38 +++ b/mail-mta/netqmail/files/qmail-smtputf8.patch
39 @@ -0,0 +1,242 @@
40 +This patch adds EAI support to qmail; EAI allows UTF8 almost everywhere in
41 +email.
42 +
43 +Thanks for CNNIC for sponsoring this work.
44 +
45 +--- /dev/null
46 ++++ netqmail-1.06/Makefile
47 +@@ -1446,7 +1446,7 @@ substdio.a error.a str.a fs.a auto_qmail.o dns.lib socket.lib
48 + timeoutwrite.o timeoutconn.o tcpto.o now.o dns.o ip.o \
49 + ipalloc.o ipme.o quote.o ndelay.a case.a sig.a open.a \
50 + lock.a seek.a getln.a stralloc.a alloc.a substdio.a error.a \
51 +- str.a fs.a auto_qmail.o `cat dns.lib` `cat socket.lib`
52 ++ str.a fs.a auto_qmail.o `cat dns.lib` `cat socket.lib` -lidn2
53 +
54 + qmail-remote.0: \
55 + qmail-remote.8
56 +--- /dev/null
57 ++++ netqmail-1.06/qmail-remote.c
58 +@@ -2,6 +2,7 @@
59 + #include <sys/socket.h>
60 + #include <netinet/in.h>
61 + #include <arpa/inet.h>
62 ++#include <idn2.h>
63 + #include "sig.h"
64 + #include "stralloc.h"
65 + #include "substdio.h"
66 +@@ -42,6 +43,7 @@
67 + stralloc routes = {0};
68 + struct constmap maproutes;
69 + stralloc host = {0};
70 ++stralloc asciihost = {0};
71 + stralloc sender = {0};
72 +
73 + saa reciplist = {0};
74 +@@ -53,12 +55,13 @@
75 + # include "tls.h"
76 + # include "ssl_timeoutio.h"
77 + # include <openssl/x509v3.h>
78 +-# define EHLO 1
79 +
80 + int tls_init();
81 + const char *ssl_err_str = 0;
82 + #endif
83 +
84 ++# define EHLO 1
85 ++
86 + void out(s) char *s; { if (substdio_puts(subfdoutsmall,s) == -1) _exit(0); }
87 + void zero() { if (substdio_put(subfdoutsmall,"\0",1) == -1) _exit(0); }
88 + void zerodie() { zero(); substdio_flush(subfdoutsmall); _exit(0); }
89 +@@ -156,6 +159,7 @@
90 + substdio smtpfrom = SUBSTDIO_FDBUF(saferead,-1,smtpfrombuf,sizeof smtpfrombuf);
91 +
92 + stralloc smtptext = {0};
93 ++stralloc firstpart = {0};
94 +
95 + void get(ch)
96 + char *ch;
97 +@@ -308,6 +312,8 @@
98 + int r;
99 + char ch;
100 +
101 ++ substdio_put(&smtpto,firstpart.s,firstpart.len);
102 ++
103 + for (;;) {
104 + r = substdio_get(&ssin,&ch,1);
105 + if (r == 0) break;
106 +@@ -518,6 +524,88 @@
107 +
108 + stralloc recip = {0};
109 +
110 ++int containsutf8(p, l) unsigned char * p; int l;
111 ++{
112 ++ int i = 0;
113 ++ while (i<l)
114 ++ if(p[i++] > 127) return 1;
115 ++ return 0;
116 ++}
117 ++
118 ++int utf8message;
119 ++
120 ++void checkutf8message()
121 ++{
122 ++ int pos;
123 ++ int i;
124 ++ int r;
125 ++ char ch;
126 ++ int state;
127 ++
128 ++ if (containsutf8(sender.s, sender.len)) { utf8message = 1; return; }
129 ++ for (i = 0;i < reciplist.len;++i)
130 ++ if (containsutf8(reciplist.sa[i].s, reciplist.sa[i].len)) {
131 ++ utf8message = 1;
132 ++ return;
133 ++ }
134 ++
135 ++ state = 0;
136 ++ pos = 0;
137 ++ for (;;) {
138 ++ r = substdio_get(&ssin,&ch,1);
139 ++ if (r == 0) break;
140 ++ if (r == -1) temp_read();
141 ++
142 ++ if (!stralloc_append(&firstpart,&ch)) temp_nomem();
143 ++
144 ++ if (ch == '\r')
145 ++ continue;
146 ++ if (ch == '\t')
147 ++ ch = ' ';
148 ++
149 ++ switch (state) {
150 ++ case 6: /* in Received, at LF but before WITH clause */
151 ++ if (ch == ' ') { state = 3; pos = 1; continue; }
152 ++ state = 0;
153 ++ /* FALL THROUGH */
154 ++
155 ++ case 0: /* start of header field */
156 ++ if (ch == '\n') return;
157 ++ state = 1;
158 ++ pos = 0;
159 ++ /* FALL THROUGH */
160 ++
161 ++ case 1: /* partway through "Received:" */
162 ++ if (ch != "RECEIVED:"[pos] && ch != "received:"[pos]) { state = 2; continue; }
163 ++ if (++pos == 9) { state = 3; pos = 0; }
164 ++ continue;
165 ++
166 ++ case 2: /* other header field */
167 ++ if (ch == '\n') state = 0;
168 ++ continue;
169 ++
170 ++ case 3: /* in Received, before WITH clause or partway though " with " */
171 ++ if (ch == '\n') { state = 6; continue; }
172 ++ if (ch != " WITH "[pos] && ch != " with "[pos]) { pos = 0; continue; }
173 ++ if (++pos == 6) { state = 4; pos = 0; }
174 ++ continue;
175 ++
176 ++ case 4: /* in Received, having seen with, before the argument */
177 ++ if (pos == 0 && (ch == ' ' || ch == '\t')) continue;
178 ++ if (ch != "UTF8"[pos] && ch != "utf8"[pos]) { state = 5; continue; }
179 ++ if(++pos == 4) { utf8message = 1; state = 5; continue; }
180 ++ continue;
181 ++
182 ++ case 5: /* after the RECEIVED WITH argument */
183 ++ /* blast() assumes that it copies whole lines */
184 ++ if (ch == '\n') return;
185 ++ state = 1;
186 ++ pos = 0;
187 ++ continue;
188 ++ }
189 ++ }
190 ++}
191 ++
192 + void smtp()
193 + {
194 + unsigned long code;
195 +@@ -571,9 +659,12 @@
196 + }
197 + #endif
198 +
199 ++ checkutf8message();
200 + substdio_puts(&smtpto,"MAIL FROM:<");
201 + substdio_put(&smtpto,sender.s,sender.len);
202 +- substdio_puts(&smtpto,">\r\n");
203 ++ substdio_puts(&smtpto,">");
204 ++ if (utf8message) substdio_puts(&smtpto," SMTPUTF8");
205 ++ substdio_puts(&smtpto,"\r\n");
206 + substdio_flush(&smtpto);
207 + code = smtpcode();
208 + if (code >= 500) quit("DConnected to "," but sender was rejected");
209 +@@ -702,9 +793,17 @@
210 + relayhost[i] = 0;
211 + }
212 + if (!stralloc_copys(&host,relayhost)) temp_nomem();
213 ++ } else {
214 ++ char * ascii = 0;
215 ++ host.s[host.len] = '\0';
216 ++ switch (idn2_lookup_u8(host.s, (uint8_t**)&ascii, IDN2_NFC_INPUT)) {
217 ++ case IDN2_OK: break;
218 ++ case IDN2_MALLOC: temp_nomem();
219 ++ default: perm_dns();
220 ++ }
221 ++ if (!stralloc_copys(&asciihost, ascii)) temp_nomem();
222 + }
223 +
224 +-
225 + addrmangle(&sender,argv[2],&flagalias,0);
226 +
227 + if (!saa_readyplus(&reciplist,0)) temp_nomem();
228 +@@ -723,7 +822,7 @@
229 +
230 +
231 + random = now() + (getpid() << 16);
232 +- switch (relayhost ? dns_ip(&ip,&host) : dns_mxip(&ip,&host,random)) {
233 ++ switch (relayhost ? dns_ip(&ip,&host) : dns_mxip(&ip,&asciihost,random)) {
234 + case DNS_MEM: temp_nomem();
235 + case DNS_SOFT: temp_dns();
236 + case DNS_HARD: perm_dns();
237 +--- /dev/null
238 ++++ netqmail-1.06/qmail-smtpd.c
239 +@@ -273,6 +273,7 @@
240 + stralloc rcptto = {0};
241 + stralloc fuser = {0};
242 + stralloc mfparms = {0};
243 ++int smtputf8 = 0;
244 +
245 + int mailfrom_size(arg) char *arg;
246 + {
247 +@@ -323,6 +324,7 @@
248 + while (len) {
249 + arg++; len--;
250 + if (*arg == ' ' || *arg == '\0' ) {
251 ++ if (case_starts(mfparms.s,"SMTPUTF8")) smtputf8 = 1;
252 + if (case_starts(mfparms.s,"SIZE=")) if (mailfrom_size(mfparms.s+5)) { flagsize = 1; return; }
253 + if (case_starts(mfparms.s,"AUTH=")) mailfrom_auth(mfparms.s+5,mfparms.len-5);
254 + if (!stralloc_copys(&mfparms,"")) die_nomem;
255 +@@ -351,7 +353,7 @@
256 + out("\r\n250-STARTTLS");
257 + #endif
258 + size[fmt_ulong(size,(unsigned int) databytes)] = 0;
259 +- out("\r\n250-PIPELINING\r\n250-8BITMIME\r\n");
260 ++ out("\r\n250-PIPELINING\r\n250-SMTPUTF8\r\n250-8BITMIME\r\n");
261 + out("250-SIZE "); out(size); out("\r\n");
262 + #ifdef CRAM_MD5
263 + out("250 AUTH LOGIN PLAIN CRAM-MD5\r\n");
264 +@@ -516,7 +518,15 @@
265 + if (qmail_open(&qqt) == -1) { err_qqt(); return; }
266 + qp = qmail_qp(&qqt);
267 + out("354 go ahead\r\n");
268 +-
269 ++
270 ++ if (smtputf8) {
271 ++ stralloc utf8proto = {0};
272 ++ if ('E' == *protocol) protocol++;
273 ++ if (!stralloc_copys(&utf8proto, "UTF8")) die_nomem();
274 ++ if (!stralloc_cats(&utf8proto, protocol)) die_nomem();
275 ++ utf8proto.s[utf8proto.len] = '\0';
276 ++ protocol = utf8proto.s;
277 ++ }
278 + received(&qqt,protocol,local,remoteip,remotehost,remoteinfo,fakehelo);
279 + blast(&hops);
280 + hops = (hops >= MAXHOPS);
281 +
282
283 diff --git a/mail-mta/netqmail/netqmail-1.06-r5.ebuild b/mail-mta/netqmail/netqmail-1.06-r5.ebuild
284 new file mode 100644
285 index 00000000..6609bf6
286 --- /dev/null
287 +++ b/mail-mta/netqmail/netqmail-1.06-r5.ebuild
288 @@ -0,0 +1,183 @@
289 +# Copyright 1999-2015 Gentoo Foundation
290 +# Distributed under the terms of the GNU General Public License v2
291 +# $Id$
292 +
293 +EAPI=5
294 +
295 +GENQMAIL_PV=20080406
296 +QMAIL_SPP_PV=0.42
297 +
298 +QMAIL_TLS_PV=20070417
299 +QMAIL_TLS_F=${PN}-1.05-tls-smtpauth-${QMAIL_TLS_PV}.patch
300 +QMAIL_TLS_CVE=vu555316.patch
301 +
302 +QMAIL_BIGTODO_PV=103
303 +QMAIL_BIGTODO_F=big-todo.${QMAIL_BIGTODO_PV}.patch
304 +
305 +QMAIL_LARGE_DNS='qmail-103.patch'
306 +
307 +QMAIL_SMTPUTF8='qmail-smtputf8.patch'
308 +
309 +inherit eutils qmail
310 +
311 +DESCRIPTION="qmail -- a secure, reliable, efficient, simple message transfer agent"
312 +HOMEPAGE="
313 + http://netqmail.org
314 + http://cr.yp.to/qmail.html
315 + http://qmail.org
316 +"
317 +SRC_URI="mirror://qmail/${P}.tar.gz
318 + https://dev.gentoo.org/~hollow/distfiles/${GENQMAIL_F}
319 + http://www.ckdhr.com/ckd/${QMAIL_LARGE_DNS}
320 + http://inoa.net/qmail-tls/${QMAIL_TLS_CVE}
321 + http://arnt.gulbrandsen.priv.no/qmail/qmail-smtputf8.patch
322 + !vanilla? (
323 + highvolume? ( mirror://qmail/${QMAIL_BIGTODO_F} )
324 + qmail-spp? ( mirror://sourceforge/qmail-spp/${QMAIL_SPP_F} )
325 + ssl? ( http://shupp.org/patches/${QMAIL_TLS_F} )
326 + )
327 +"
328 +
329 +LICENSE="public-domain"
330 +SLOT="0"
331 +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~mips ~ppc ~ppc64 ~x86"
332 +IUSE="authcram gencertdaily highvolume libressl qmail-spp ssl vanilla"
333 +REQUIRED_USE='vanilla? ( !ssl !qmail-spp !highvolume )'
334 +RESTRICT="test"
335 +
336 +DEPEND="
337 + !mail-mta/qmail
338 + net-mail/queue-repair
339 + ssl? (
340 + !libressl? ( dev-libs/openssl:0 )
341 + libressl? ( dev-libs/libressl )
342 + )
343 + sys-apps/gentoo-functions
344 + sys-apps/groff
345 + net-dns/libidn2
346 +"
347 +RDEPEND="
348 + !mail-mta/courier
349 + !mail-mta/esmtp
350 + !mail-mta/exim
351 + !mail-mta/mini-qmail
352 + !mail-mta/msmtp[mta]
353 + !mail-mta/nullmailer
354 + !mail-mta/postfix
355 + !mail-mta/qmail-ldap
356 + !mail-mta/sendmail
357 + !<mail-mta/ssmtp-2.64-r2
358 + !>=mail-mta/ssmtp-2.64-r2[mta]
359 + >=sys-apps/ucspi-tcp-0.88-r17
360 + ssl? ( >=sys-apps/ucspi-ssl-0.70-r1 )
361 + virtual/daemontools
362 + >=net-mail/dot-forward-0.71-r3
363 + virtual/checkpassword
364 + authcram? ( >=net-mail/cmd5checkpw-0.30 )
365 + ${DEPEND}
366 +"
367 +
368 +pkg_setup() {
369 + if [[ -n "${QMAIL_PATCH_DIR}" ]]; then
370 + eerror
371 + eerror "The QMAIL_PATCH_DIR variable for custom patches"
372 + eerror "has been removed from ${PN}. If you need custom patches"
373 + eerror "you should create a copy of this ebuild in an overlay."
374 + eerror
375 + die "QMAIL_PATCH_DIR is not supported anymore"
376 + fi
377 +
378 + qmail_create_users
379 +}
380 +
381 +src_unpack() {
382 + genqmail_src_unpack
383 + use qmail-spp && qmail_spp_src_unpack
384 +
385 + unpack ${P}.tar.gz
386 +}
387 +
388 +src_prepare() {
389 + epatch "${FILESDIR}"/${PV}-exit.patch
390 + epatch "${FILESDIR}"/${PV}-readwrite.patch
391 + epatch "${DISTDIR}"/${QMAIL_LARGE_DNS}
392 + epatch "${FILESDIR}"/${PV}-fbsd-utmpx.patch
393 +
394 + ht_fix_file Makefile*
395 +
396 + if ! use vanilla; then
397 + # This patch contains relative paths and needs to be cleaned up.
398 + sed 's~^--- ../../~--- ~g' \
399 + <"${DISTDIR}"/${QMAIL_TLS_F} \
400 + >"${T}"/${QMAIL_TLS_F} || die
401 + use ssl && epatch "${T}"/${QMAIL_TLS_F}
402 + use ssl && epatch "${DISTDIR}"/${QMAIL_TLS_CVE}
403 + use highvolume && epatch "${DISTDIR}"/${QMAIL_BIGTODO_F}
404 +
405 + if use qmail-spp; then
406 + if use ssl; then
407 + epatch "${QMAIL_SPP_S}"/qmail-spp-smtpauth-tls-20060105.diff
408 + else
409 + epatch "${QMAIL_SPP_S}"/netqmail-spp.diff
410 + fi
411 + cd "${WORKDIR}" || die
412 + epatch "${FILESDIR}"/genqmail-20080406-ldflags.patch
413 + cd - || die
414 + fi
415 + fi
416 +
417 + cd "${WORKDIR}" || die
418 + epatch "${FILESDIR}"/use-new-path-for-functions.sh.patch
419 + epatch "${FILESDIR}"/qmail-smtputf8.patch
420 + cd - || die
421 +
422 + qmail_src_postunpack
423 +
424 + # Fix bug #33818 but for netqmail (Bug 137015)
425 + if ! use authcram; then
426 + einfo "Disabled CRAM_MD5 support"
427 + sed -e 's,^#define CRAM_MD5$,/*&*/,' -i "${S}"/qmail-smtpd.c || die
428 + else
429 + einfo "Enabled CRAM_MD5 support"
430 + fi
431 +}
432 +
433 +src_compile() {
434 + qmail_src_compile
435 + use qmail-spp && qmail_spp_src_compile
436 +}
437 +
438 +src_install() {
439 + qmail_src_install
440 +}
441 +
442 +pkg_postinst() {
443 + qmail_queue_setup
444 + qmail_rootmail_fixup
445 + qmail_tcprules_build
446 +
447 + qmail_config_notice
448 + qmail_supervise_config_notice
449 + elog
450 + elog "If you are looking for documentation, check those links:"
451 + elog "https://www.gentoo.org/doc/en/qmail-howto.xml"
452 + elog " -- qmail/vpopmail Virtual Mail Hosting System Guide"
453 + elog "http://www.lifewithqmail.com/"
454 + elog " -- Life with qmail"
455 + elog
456 +}
457 +
458 +pkg_preinst() {
459 + qmail_tcprules_fixup
460 +}
461 +
462 +pkg_config() {
463 + # avoid some weird locale problems
464 + export LC_ALL=C
465 +
466 + qmail_config_fast
467 + qmail_tcprules_config
468 + qmail_tcprules_build
469 +
470 + use ssl && qmail_ssl_generate
471 +}