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/dovecot/files/, net-mail/dovecot/
Date: Thu, 11 Oct 2018 10:57:41
Message-Id: 1539255412.5261930a4d34c3cd4fdf31fc319e423958a875cc.eras@gentoo
1 commit: 5261930a4d34c3cd4fdf31fc319e423958a875cc
2 Author: Eray Aslan <eras <AT> gentoo <DOT> org>
3 AuthorDate: Thu Oct 11 10:56:52 2018 +0000
4 Commit: Eray Aslan <eras <AT> gentoo <DOT> org>
5 CommitDate: Thu Oct 11 10:56:52 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5261930a
7
8 net-mail/dovecot: fix userdb-passwd errno
9
10 In https://bugs.gentoo.org/667118 Reuben Farrelly
11 noticed that running
12 # doveadm user '*'
13 causes auth daemon to generate errors like:
14 auth-worker(3585): Error: getpwent() failed: Invalid argument
15
16 This happens because on successful call getpwent()
17 now sets errno=EINVAL starting from glibc-2.28.
18 See https://sourceware.org/PR16004 for details.
19
20 The fix is to check 'errno' only when 'getpwent()' fails.
21
22 Reported-by: Reuben Farrelly
23 Bug: https://bugs.gentoo.org/667118
24 Bug: https://sourceware.org/PR16004
25 Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>
26 Signed-off-by: Eray Aslan <eras <AT> gentoo.org>
27 Package-Manager: Portage-2.3.51, Repoman-2.3.11
28
29 net-mail/dovecot/dovecot-2.3.3-r1.ebuild | 294 +++++++++++++++++++++
30 .../dovecot/files/dovecot-userdb-passwd-fix.patch | 18 ++
31 2 files changed, 312 insertions(+)
32
33 diff --git a/net-mail/dovecot/dovecot-2.3.3-r1.ebuild b/net-mail/dovecot/dovecot-2.3.3-r1.ebuild
34 new file mode 100644
35 index 00000000000..120949b5d43
36 --- /dev/null
37 +++ b/net-mail/dovecot/dovecot-2.3.3-r1.ebuild
38 @@ -0,0 +1,294 @@
39 +# Copyright 1999-2018 Gentoo Authors
40 +# Distributed under the terms of the GNU General Public License v2
41 +
42 +EAPI=6
43 +# do not add a ssl USE flag. ssl is mandatory
44 +SSL_DEPS_SKIP=1
45 +inherit autotools ssl-cert systemd user versionator
46 +
47 +MY_P="${P/_/.}"
48 +#MY_S="${PN}-ce-${PV}"
49 +major_minor="$(get_version_component_range 1-2)"
50 +sieve_version="0.5.3"
51 +if [[ ${PV} == *_rc* ]] ; then
52 + rc_dir="rc/"
53 +else
54 + rc_dir=""
55 +fi
56 +SRC_URI="https://dovecot.org/releases/${major_minor}/${rc_dir}${MY_P}.tar.gz
57 + sieve? (
58 + https://pigeonhole.dovecot.org/releases/${major_minor}/${rc_dir}${PN}-${major_minor}-pigeonhole-${sieve_version}.tar.gz
59 + )
60 + managesieve? (
61 + https://pigeonhole.dovecot.org/releases/${major_minor}/${rc_dir}${PN}-${major_minor}-pigeonhole-${sieve_version}.tar.gz
62 + ) "
63 +DESCRIPTION="An IMAP and POP3 server written with security primarily in mind"
64 +HOMEPAGE="https://www.dovecot.org/"
65 +
66 +SLOT="0"
67 +LICENSE="LGPL-2.1 MIT"
68 +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86"
69 +
70 +IUSE_DOVECOT_AUTH="kerberos ldap lua mysql pam postgres sqlite vpopmail"
71 +IUSE_DOVECOT_COMPRESS="bzip2 lzma lz4 zlib"
72 +IUSE_DOVECOT_OTHER="argon2 caps doc ipv6 libressl lucene managesieve selinux sieve solr static-libs suid tcpd textcat"
73 +
74 +IUSE="${IUSE_DOVECOT_AUTH} ${IUSE_DOVECOT_STORAGE} ${IUSE_DOVECOT_COMPRESS} ${IUSE_DOVECOT_OTHER}"
75 +
76 +DEPEND="argon2? ( dev-libs/libsodium )
77 + bzip2? ( app-arch/bzip2 )
78 + caps? ( sys-libs/libcap )
79 + kerberos? ( virtual/krb5 )
80 + ldap? ( net-nds/openldap )
81 + lua? ( dev-lang/lua:* )
82 + lucene? ( >=dev-cpp/clucene-2.3 )
83 + lzma? ( app-arch/xz-utils )
84 + lz4? ( app-arch/lz4 )
85 + mysql? ( virtual/mysql )
86 + pam? ( virtual/pam )
87 + postgres? ( dev-db/postgresql:* !dev-db/postgresql[ldap,threads] )
88 + selinux? ( sec-policy/selinux-dovecot )
89 + solr? ( net-misc/curl dev-libs/expat )
90 + sqlite? ( dev-db/sqlite:* )
91 + !libressl? ( dev-libs/openssl:0 )
92 + libressl? ( dev-libs/libressl )
93 + tcpd? ( sys-apps/tcp-wrappers )
94 + textcat? ( app-text/libexttextcat )
95 + vpopmail? ( net-mail/vpopmail )
96 + zlib? ( sys-libs/zlib )
97 + virtual/libiconv
98 + dev-libs/icu:="
99 +
100 +RDEPEND="${DEPEND}
101 + net-mail/mailbase"
102 +
103 +PATCHES=(
104 + "${FILESDIR}/${PN}-glibc228.patch"
105 + "${FILESDIR}/${PN}-userdb-passwd-fix.patch"
106 +)
107 +
108 +pkg_setup() {
109 + if use managesieve && ! use sieve; then
110 + ewarn "managesieve USE flag selected but sieve USE flag unselected"
111 + ewarn "sieve USE flag will be turned on"
112 + fi
113 + # default internal user
114 + enewgroup dovecot 97
115 + enewuser dovecot 97 -1 /dev/null dovecot
116 + # default login user
117 + enewuser dovenull -1 -1 /dev/null
118 + # add "mail" group for suid'ing. Better security isolation.
119 + if use suid; then
120 + enewgroup mail
121 + fi
122 +}
123 +
124 +src_prepare() {
125 + default
126 + # bug 657108
127 + # elibtoolize
128 + eautoreconf
129 +}
130 +
131 +src_configure() {
132 + local conf=""
133 +
134 + if use postgres || use mysql || use sqlite; then
135 + conf="${conf} --with-sql"
136 + fi
137 +
138 + # turn valgrind tests off. Bug #340791
139 + VALGRIND=no econf \
140 + --with-rundir="${EPREFIX}/run/dovecot" \
141 + --with-statedir="${EPREFIX}/var/lib/dovecot" \
142 + --with-moduledir="${EPREFIX}/usr/$(get_libdir)/dovecot" \
143 + --without-stemmer \
144 + --disable-rpath \
145 + --without-libbsd \
146 + --with-icu \
147 + --with-ssl \
148 + --with-systemdsystemunitdir="$(systemd_get_systemunitdir)" \
149 + $( use_with argon2 sodium ) \
150 + $( use_with bzip2 bzlib ) \
151 + $( use_with caps libcap ) \
152 + $( use_with kerberos gssapi ) \
153 + $( use_with lua ) \
154 + $( use_with ldap ) \
155 + $( use_with lucene ) \
156 + $( use_with lz4 ) \
157 + $( use_with lzma ) \
158 + $( use_with mysql ) \
159 + $( use_with pam ) \
160 + $( use_with postgres pgsql ) \
161 + $( use_with sqlite ) \
162 + $( use_with solr ) \
163 + $( use_with tcpd libwrap ) \
164 + $( use_with textcat ) \
165 + $( use_with vpopmail ) \
166 + $( use_with zlib ) \
167 + $( use_enable static-libs static ) \
168 + ${conf}
169 +
170 + if use sieve || use managesieve ; then
171 + # The sieve plugin needs this file to be build to determine the plugin
172 + # directory and the list of libraries to link to.
173 + emake dovecot-config
174 + cd "../dovecot-${major_minor}-pigeonhole-${sieve_version}" || die "cd failed"
175 + econf \
176 + $( use_enable static-libs static ) \
177 + --localstatedir="${EPREFIX%/}/var" \
178 + --enable-shared \
179 + --with-dovecot="${S}" \
180 + $( use_with managesieve )
181 + fi
182 +}
183 +
184 +src_compile() {
185 + default
186 + if use sieve || use managesieve ; then
187 + cd "../dovecot-${major_minor}-pigeonhole-${sieve_version}" || die "cd failed"
188 + emake CC="$(tc-getCC)" CFLAGS="${CFLAGS}"
189 + fi
190 +}
191 +
192 +src_test() {
193 + default
194 + if use sieve || use managesieve ; then
195 + cd "../dovecot-${major_minor}-pigeonhole-${sieve_version}" || die "cd failed"
196 + default
197 + fi
198 +}
199 +
200 +src_install () {
201 + default
202 +
203 + # insecure:
204 + # use suid && fperms u+s /usr/libexec/dovecot/deliver
205 + # better:
206 + if use suid;then
207 + einfo "Changing perms to allow deliver to be suided"
208 + fowners root:mail "${EPREFIX}/usr/libexec/dovecot/dovecot-lda"
209 + fperms 4750 "${EPREFIX}/usr/libexec/dovecot/dovecot-lda"
210 + fi
211 +
212 + newinitd "${FILESDIR}"/dovecot.init-r5 dovecot
213 +
214 + rm -rf "${ED}"/usr/share/doc/dovecot
215 +
216 + dodoc AUTHORS NEWS README TODO
217 + dodoc doc/*.{txt,cnf,xml,sh}
218 + docinto example-config
219 + dodoc doc/example-config/*.{conf,ext}
220 + docinto example-config/conf.d
221 + dodoc doc/example-config/conf.d/*.{conf,ext}
222 + docinto wiki
223 + dodoc doc/wiki/*
224 + doman doc/man/*.{1,7}
225 +
226 + # Create the dovecot.conf file from the dovecot-example.conf file that
227 + # the dovecot folks nicely left for us....
228 + local conf="${ED}/etc/dovecot/dovecot.conf"
229 + local confd="${ED}/etc/dovecot/conf.d"
230 +
231 + insinto /etc/dovecot
232 + doins doc/example-config/*.{conf,ext}
233 + insinto /etc/dovecot/conf.d
234 + doins doc/example-config/conf.d/*.{conf,ext}
235 + fperms 0600 "${EPREFIX}"/etc/dovecot/dovecot-{ldap,sql}.conf.ext
236 + rm -f "${confd}/../README"
237 +
238 + # .maildir is the Gentoo default
239 + local mail_location="maildir:~/.maildir"
240 + sed -i -e \
241 + "s|#mail_location =|mail_location = ${mail_location}|" \
242 + "${confd}/10-mail.conf" \
243 + || die "failed to update mail location settings in 10-mail.conf"
244 +
245 + # We're using pam files (imap and pop3) provided by mailbase
246 + if use pam; then
247 + sed -i -e '/driver = pam/,/^[ \t]*}/ s|#args = dovecot|args = "\*"|' \
248 + "${confd}/auth-system.conf.ext" \
249 + || die "failed to update PAM settings in auth-system.conf.ext"
250 + # mailbase does not provide a sieve pam file
251 + use managesieve && dosym imap /etc/pam.d/sieve
252 + sed -i -e \
253 + 's/#!include auth-system.conf.ext/!include auth-system.conf.ext/' \
254 + "${confd}/10-auth.conf" \
255 + || die "failed to update PAM settings in 10-auth.conf"
256 + fi
257 +
258 + # Disable ipv6 if necessary
259 + if ! use ipv6; then
260 + sed -i -e 's/^#listen = \*, ::/listen = \*/g' "${conf}" \
261 + || die "failed to update listen settings in dovecot.conf"
262 + fi
263 +
264 + # Update ssl cert locations
265 + sed -i -e 's:^#ssl = yes:ssl = yes:' "${confd}/10-ssl.conf" \
266 + || die "ssl conf failed"
267 + sed -i -e 's:^ssl_cert =.*:ssl_cert = </etc/ssl/dovecot/server.pem:' \
268 + -e 's:^ssl_key =.*:ssl_key = </etc/ssl/dovecot/server.key:' \
269 + "${confd}/10-ssl.conf" || die "failed to update SSL settings in 10-ssl.conf"
270 +
271 + # Install SQL configuration
272 + if use mysql || use postgres; then
273 + sed -i -e \
274 + 's/#!include auth-sql.conf.ext/!include auth-sql.conf.ext/' \
275 + "${confd}/10-auth.conf" || die "failed to update SQL settings in \
276 + 10-auth.conf"
277 + fi
278 +
279 + # Install LDAP configuration
280 + if use ldap; then
281 + sed -i -e \
282 + 's/#!include auth-ldap.conf.ext/!include auth-ldap.conf.ext/' \
283 + "${confd}/10-auth.conf" \
284 + || die "failed to update ldap settings in 10-auth.conf"
285 + fi
286 +
287 + if use vpopmail; then
288 + sed -i -e \
289 + 's/#!include auth-vpopmail.conf.ext/!include auth-vpopmail.conf.ext/' \
290 + "${confd}/10-auth.conf" \
291 + || die "failed to update vpopmail settings in 10-auth.conf"
292 + fi
293 +
294 + if use sieve || use managesieve ; then
295 + cd "../dovecot-${major_minor}-pigeonhole-${sieve_version}" || die "cd failed"
296 + emake DESTDIR="${ED}" install
297 + sed -i -e \
298 + 's/^[[:space:]]*#mail_plugins = $mail_plugins/mail_plugins = sieve/' "${confd}/15-lda.conf" \
299 + || die "failed to update sieve settings in 15-lda.conf"
300 + rm -rf "${ED}"/usr/share/doc/dovecot
301 + docinto example-config/conf.d
302 + dodoc doc/example-config/conf.d/*.conf
303 + insinto /etc/dovecot/conf.d
304 + doins doc/example-config/conf.d/90-sieve{,-extprograms}.conf
305 + use managesieve && doins doc/example-config/conf.d/20-managesieve.conf
306 + docinto sieve/rfc
307 + dodoc doc/rfc/*.txt
308 + docinto sieve/devel
309 + dodoc doc/devel/DESIGN
310 + docinto plugins
311 + dodoc doc/plugins/*.txt
312 + docinto extensions
313 + dodoc doc/extensions/*.txt
314 + docinto locations
315 + dodoc doc/locations/*.txt
316 + doman doc/man/*.{1,7}
317 + fi
318 +
319 + use static-libs || find "${ED}"/usr/lib* -name '*.la' -delete
320 +}
321 +
322 +pkg_postinst() {
323 + # Let's not make a new certificate if we already have one
324 + if ! [[ -e "${ROOT}"/etc/ssl/dovecot/server.pem && \
325 + -e "${ROOT}"/etc/ssl/dovecot/server.key ]]; then
326 + einfo "Creating SSL certificate"
327 + SSL_ORGANIZATION="${SSL_ORGANIZATION:-Dovecot IMAP Server}"
328 + install_cert /etc/ssl/dovecot/server
329 + fi
330 +
331 + elog "Please read http://wiki2.dovecot.org/Upgrading/ for upgrade notes."
332 +}
333
334 diff --git a/net-mail/dovecot/files/dovecot-userdb-passwd-fix.patch b/net-mail/dovecot/files/dovecot-userdb-passwd-fix.patch
335 new file mode 100644
336 index 00000000000..d5bff016394
337 --- /dev/null
338 +++ b/net-mail/dovecot/files/dovecot-userdb-passwd-fix.patch
339 @@ -0,0 +1,18 @@
340 +diff --git a/src/auth/userdb-passwd.c b/src/auth/userdb-passwd.c
341 +index 03cbd554ff..699db314ce 100644
342 +--- a/src/auth/userdb-passwd.c
343 ++++ b/src/auth/userdb-passwd.c
344 +@@ -172,8 +172,11 @@ static void passwd_iterate_next(struct userdb_iterate_context *_ctx)
345 + return;
346 + }
347 +
348 +- errno = 0;
349 +- while ((pw = getpwent()) != NULL) {
350 ++ for (;;) {
351 ++ errno = 0;
352 ++ pw = getpwent();
353 ++ if (pw == NULL)
354 ++ break;
355 + if (passwd_iterate_want_pw(pw, set)) {
356 + _ctx->callback(pw->pw_name, _ctx->context);
357 + return;