Gentoo Archives: gentoo-commits

From: Eray Aslan <eras@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-mail/mailutils/files/, net-mail/mailutils/
Date: Fri, 22 Jun 2018 12:21:23
Message-Id: 1529670068.f99b2a0dc1644fd2983a787ff7d0354b09946f7e.eras@gentoo
1 commit: f99b2a0dc1644fd2983a787ff7d0354b09946f7e
2 Author: Eray Aslan <eras <AT> gentoo <DOT> org>
3 AuthorDate: Fri Jun 22 12:20:34 2018 +0000
4 Commit: Eray Aslan <eras <AT> gentoo <DOT> org>
5 CommitDate: Fri Jun 22 12:21:08 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f99b2a0d
7
8 net-mail/mailutils: fix endiannes problem
9
10 Closes: https://bugs.gentoo.org/654992
11 Package-Manager: Portage-2.3.40, Repoman-2.3.9
12
13 .../files/mailutils-3.4-fix-endianness.patch | 122 +++++++++++++++++++
14 net-mail/mailutils/mailutils-3.4-r2.ebuild | 133 +++++++++++++++++++++
15 2 files changed, 255 insertions(+)
16
17 diff --git a/net-mail/mailutils/files/mailutils-3.4-fix-endianness.patch b/net-mail/mailutils/files/mailutils-3.4-fix-endianness.patch
18 new file mode 100644
19 index 00000000000..0e52fae20c1
20 --- /dev/null
21 +++ b/net-mail/mailutils/files/mailutils-3.4-fix-endianness.patch
22 @@ -0,0 +1,122 @@
23 +From feecde8c46cdb597a76df5e6ef02b854843a8a5c Mon Sep 17 00:00:00 2001
24 +From: Sergey Poznyakoff <gray@×××.org>
25 +Date: Thu, 21 Jun 2018 09:46:43 +0300
26 +Subject: Fix endianness bug in string to IP conversion
27 +
28 +* libmailutils/cidr/fromsa.c (_mu_inaddr_to_bytes)
29 +(_mu_sockaddr_to_bytes): Fix improper endianness conversion.
30 +* libmailutils/cidr/tosa.c (mu_cidr_to_sockaddr): Simplify conversion.
31 +---
32 + libmailutils/cidr/fromsa.c | 45 ++++++++++++++++++++-------------------------
33 + libmailutils/cidr/tosa.c | 9 ++-------
34 + 2 files changed, 22 insertions(+), 32 deletions(-)
35 +
36 +diff --git a/libmailutils/cidr/fromsa.c b/libmailutils/cidr/fromsa.c
37 +index f57aadc..39d24fd 100644
38 +--- a/libmailutils/cidr/fromsa.c
39 ++++ b/libmailutils/cidr/fromsa.c
40 +@@ -29,55 +29,50 @@
41 + #include <mailutils/cidr.h>
42 + #include <mailutils/errno.h>
43 +
44 +-static void
45 +-uint32_to_bytes (unsigned char *bytes, uint32_t u)
46 +-{
47 +- int i;
48 +-
49 +- for (i = 0; i < 4; i++)
50 +- {
51 +- bytes[i] = u & 0xff;
52 +- u >>= 8;
53 +- }
54 +-}
55 +-
56 + int
57 + _mu_inaddr_to_bytes (int af, void *buf, unsigned char *bytes)
58 + {
59 +- uint32_t u;
60 ++ size_t len;
61 +
62 + switch (af)
63 + {
64 + case AF_INET:
65 +- memcpy (&u, buf, sizeof u);
66 +- uint32_to_bytes (bytes, u);
67 +- return 4;
68 +-
69 ++ len = 4;
70 ++ break;
71 ++
72 + #ifdef MAILUTILS_IPV6
73 + case AF_INET6:
74 +- memcpy (bytes, buf, 16);
75 +- return 16;
76 ++ len = 16;
77 ++ break;
78 + #endif
79 ++
80 ++ default:
81 ++ len = 0;
82 + }
83 +- return 0;
84 ++ memcpy (bytes, buf, len);
85 ++ return len;
86 + }
87 +
88 + int
89 + _mu_sockaddr_to_bytes (unsigned char *bytes, struct sockaddr const *sa)
90 + {
91 ++ void *buf;
92 + switch (sa->sa_family)
93 + {
94 + case AF_INET:
95 +- uint32_to_bytes (bytes, ((struct sockaddr_in*)sa)->sin_addr.s_addr);
96 +- return 4;
97 ++ buf = &(((struct sockaddr_in*)sa)->sin_addr.s_addr);
98 ++ break;
99 +
100 + #ifdef MAILUTILS_IPV6
101 + case AF_INET6:
102 +- memcpy (bytes, &((struct sockaddr_in6*)sa)->sin6_addr, 16);
103 +- return 16;
104 ++ buf = &(((struct sockaddr_in6*)sa)->sin6_addr);
105 ++ break;
106 + #endif
107 ++
108 ++ default:
109 ++ return 0;
110 + }
111 +- return 0;
112 ++ return _mu_inaddr_to_bytes (sa->sa_family, buf, bytes);
113 + }
114 +
115 + int
116 +diff --git a/libmailutils/cidr/tosa.c b/libmailutils/cidr/tosa.c
117 +index 33715e1..2b372b1 100644
118 +--- a/libmailutils/cidr/tosa.c
119 ++++ b/libmailutils/cidr/tosa.c
120 +@@ -42,19 +42,14 @@ mu_cidr_to_sockaddr (struct mu_cidr *cidr, struct sockaddr **psa)
121 + } addr;
122 + struct sockaddr *sa;
123 + int socklen;
124 +- int i;
125 +-
126 ++
127 + memset (&addr, 0, sizeof (addr));
128 + addr.sa.sa_family = cidr->family;
129 + switch (cidr->family)
130 + {
131 + case AF_INET:
132 + socklen = sizeof (addr.s_in);
133 +- for (i = 0; i < cidr->len; i++)
134 +- {
135 +- addr.s_in.sin_addr.s_addr <<= 8;
136 +- addr.s_in.sin_addr.s_addr |= cidr->address[i];
137 +- }
138 ++ memcpy (&addr.s_in.sin_addr.s_addr, cidr->address, 4);
139 + break;
140 +
141 + #ifdef MAILUTILS_IPV6
142 +--
143 +cgit v1.0-41-gc330
144 +
145
146 diff --git a/net-mail/mailutils/mailutils-3.4-r2.ebuild b/net-mail/mailutils/mailutils-3.4-r2.ebuild
147 new file mode 100644
148 index 00000000000..29af9bd8f3a
149 --- /dev/null
150 +++ b/net-mail/mailutils/mailutils-3.4-r2.ebuild
151 @@ -0,0 +1,133 @@
152 +# Copyright 1999-2018 Gentoo Foundation
153 +# Distributed under the terms of the GNU General Public License v2
154 +
155 +EAPI=6
156 +PYTHON_COMPAT=( python2_7 )
157 +
158 +inherit autotools eutils flag-o-matic python-single-r1 toolchain-funcs
159 +
160 +DESCRIPTION="A useful collection of mail servers, clients, and filters"
161 +HOMEPAGE="https://www.gnu.org/software/mailutils/mailutils.html"
162 +SRC_URI="mirror://gnu/mailutils/${P}.tar.xz"
163 +
164 +LICENSE="GPL-2 LGPL-2.1"
165 +SLOT="0"
166 +KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~x86 ~ppc-macos ~x64-macos ~x86-macos"
167 +IUSE="berkdb bidi +clients gdbm sasl guile ipv6 kerberos kyotocabinet ldap \
168 + mysql nls pam postgres python servers ssl static-libs +threads tcpd \
169 + tokyocabinet"
170 +
171 +RDEPEND="!mail-client/nmh
172 + !mail-filter/libsieve
173 + !mail-client/mailx
174 + !mail-client/nail
175 + sys-libs/ncurses:=
176 + sys-libs/readline:=
177 + dev-libs/libltdl:0
178 + virtual/mta
179 + berkdb? ( sys-libs/db:= )
180 + bidi? ( dev-libs/fribidi )
181 + gdbm? ( sys-libs/gdbm )
182 + guile? ( dev-scheme/guile:12/22 )
183 + kerberos? ( virtual/krb5 )
184 + kyotocabinet? ( dev-db/kyotocabinet )
185 + ldap? ( net-nds/openldap )
186 + mysql? ( virtual/mysql )
187 + nls? ( sys-devel/gettext )
188 + pam? ( virtual/pam )
189 + postgres? ( dev-db/postgresql:= )
190 + python? ( ${PYTHON_DEPS} )
191 + sasl? ( virtual/gsasl )
192 + ssl? ( net-libs/gnutls:= )
193 + tcpd? ( sys-apps/tcp-wrappers )
194 + tokyocabinet? ( dev-db/tokyocabinet )"
195 +
196 +DEPEND="${RDEPEND}
197 + virtual/pkgconfig"
198 +
199 +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )
200 + servers? ( tcpd )"
201 +
202 +pkg_setup() {
203 + use python && python-single-r1_pkg_setup
204 +}
205 +
206 +src_prepare() {
207 + # Disable bytecompilation of Python modules.
208 + echo "#!/bin/sh" > build-aux/py-compile
209 + eapply "${FILESDIR}/${P}-MH-testsuite.patch" \
210 + "${FILESDIR}/${P}-fix-endianness.patch"
211 + # add missing tests so that make check doesn't fail
212 + cp "${FILESDIR}"/{hdr,nohdr,twomsg,weed}.at "${S}"/readmsg/tests || die
213 + if use mysql; then
214 + sed -i -e /^INCLUDES/"s:$:$(mysql_config --include):" \
215 + sql/Makefile.am || die
216 + fi
217 + eapply_user
218 + eautoreconf
219 +}
220 +
221 +src_configure() {
222 + append-flags -fno-strict-aliasing
223 +
224 + # maildir is the Gentoo default
225 + econf MU_DEFAULT_SCHEME=maildir \
226 + CURSES_LIBS="$($(tc-getPKG_CONFIG) --libs ncurses)" \
227 + $(use_with berkdb berkeley-db) \
228 + $(use_with bidi fribidi) \
229 + $(use_enable ipv6) \
230 + $(use_with gdbm) \
231 + $(use_with sasl gsasl) \
232 + $(use_with guile) \
233 + $(use_with kerberos gssapi) \
234 + $(use_with ldap) \
235 + $(use_with mysql) \
236 + $(use_enable nls) \
237 + $(use_enable pam) \
238 + $(use_with postgres) \
239 + $(use_enable python) \
240 + $(use_with ssl gnutls) \
241 + $(use_enable static-libs static) \
242 + $(use_enable threads pthread) \
243 + $(use_with tokyocabinet) \
244 + $(use_with kyotocabinet) \
245 + $(use_with tcpd tcp-wrappers) \
246 + $(use_enable servers build-servers) \
247 + $(use_enable clients build-clients) \
248 + --with-mail-spool=/var/spool/mail \
249 + --with-readline \
250 + --enable-sendmail \
251 + --disable-debug \
252 + --disable-rpath
253 +}
254 +
255 +src_install() {
256 + emake DESTDIR="${D}" install
257 +
258 + insinto /etc
259 + # bug 613112
260 + newins "${FILESDIR}/mailutils.rc" mailutils.conf
261 + keepdir /etc/mailutils.d/
262 + insinto /etc/mailutils.d
263 + doins "${FILESDIR}/mail"
264 +
265 + if use python; then
266 + python_optimize
267 + if use static-libs; then
268 + rm -r "${D}$(python_get_sitedir)/mailutils"/*.{a,la} || die
269 + fi
270 + fi
271 +
272 + if use servers; then
273 + newinitd "${FILESDIR}"/imap4d.initd imap4d
274 + newinitd "${FILESDIR}"/pop3d.initd pop3d
275 + newinitd "${FILESDIR}"/comsatd.initd comsatd
276 + fi
277 +
278 + dodoc AUTHORS ChangeLog NEWS README* THANKS TODO
279 +
280 + # compatibility link
281 + use clients && dosym /usr/bin/mail /bin/mail
282 +
283 + use static-libs || find "${D}" -name "*.la" -delete
284 +}