mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-11-21 10:37:22 -08:00
net-mail/dovecot: fix 32 bit test and arithmetic
- On 32-bit systems, SIZE_MAX and UINT_MAX are the same. Fix the test accordingly. - Fix TIME_T_MAX_BITS on 32-bit systems with a 32-bit signed time_t. Closes: https://bugs.gentoo.org/977416 Signed-off-by: Eray Aslan <eras@gentoo.org>
This commit is contained in:
@@ -0,0 +1,292 @@
|
||||
# Copyright 1999-2026 Gentoo Authors
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
EAPI=8
|
||||
|
||||
LUA_COMPAT=( lua5-{3..4} )
|
||||
# do not add a ssl USE flag. ssl is mandatory
|
||||
SSL_DEPS_SKIP=1
|
||||
VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/dovecot.asc
|
||||
inherit autotools dot-a eapi9-ver flag-o-matic lua-single ssl-cert systemd
|
||||
inherit toolchain-funcs verify-sig
|
||||
|
||||
MY_P="${P/_/.}"
|
||||
MY_PV="${PV}"
|
||||
major_minor="$(ver_cut 1-2)"
|
||||
|
||||
DESCRIPTION="An IMAP and POP3 server written with security primarily in mind"
|
||||
HOMEPAGE="https://www.dovecot.org/"
|
||||
SRC_URI="https://www.dovecot.org/releases/${major_minor}/${MY_P}.tar.gz
|
||||
sieve? (
|
||||
https://pigeonhole.dovecot.org/releases/${major_minor}/${PN}-pigeonhole-${MY_PV}.tar.gz
|
||||
verify-sig? (
|
||||
https://pigeonhole.dovecot.org/releases/${major_minor}/${PN}-pigeonhole-${MY_PV}.tar.gz.sig
|
||||
)
|
||||
)
|
||||
managesieve? (
|
||||
https://pigeonhole.dovecot.org/releases/${major_minor}/${PN}-pigeonhole-${MY_PV}.tar.gz
|
||||
verify-sig? (
|
||||
https://pigeonhole.dovecot.org/releases/${major_minor}/${PN}-pigeonhole-${MY_PV}.tar.gz.sig
|
||||
)
|
||||
)
|
||||
verify-sig? (
|
||||
https://www.dovecot.org/releases/${major_minor}/${MY_P}.tar.gz.sig
|
||||
) "
|
||||
S="${WORKDIR}/${MY_P}"
|
||||
PIEGONHOLE_S="../dovecot-pigeonhole-${MY_PV}"
|
||||
LICENSE="LGPL-2.1 MIT"
|
||||
SLOT="0/${PV}"
|
||||
KEYWORDS="amd64 ~arm arm64 ~hppa ~mips ~ppc ppc64 ~riscv ~sparc ~x86"
|
||||
|
||||
IUSE_DOVECOT_AUTH_DICT="cdb kerberos ldap lua mysql pam postgres sqlite"
|
||||
IUSE_DOVECOT_COMPRESS="lz4 zstd"
|
||||
IUSE_DOVECOT_FTS="solr stemmer textcat xapian"
|
||||
IUSE_DOVECOT_OTHER="argon2 managesieve selinux sieve static-libs suid systemd system-icu test unwind"
|
||||
|
||||
IUSE="${IUSE_DOVECOT_AUTH_DICT} ${IUSE_DOVECOT_COMPRESS} ${IUSE_DOVECOT_FTS} ${IUSE_DOVECOT_OTHER}"
|
||||
|
||||
REQUIRED_USE="lua? ( ${LUA_REQUIRED_USE} )"
|
||||
RESTRICT="!test? ( test )"
|
||||
|
||||
DEPEND="
|
||||
app-arch/bzip2
|
||||
dev-libs/openssl:0=
|
||||
net-libs/libtirpc:=
|
||||
dev-libs/libpcre2:0[pcre32]
|
||||
net-libs/rpcsvc-proto
|
||||
sys-libs/libcap
|
||||
virtual/zlib:=
|
||||
virtual/libcrypt:=
|
||||
virtual/libiconv
|
||||
argon2? ( dev-libs/libsodium:= )
|
||||
cdb? ( dev-db/tinycdb )
|
||||
kerberos? ( virtual/krb5 )
|
||||
ldap? ( net-nds/openldap:= )
|
||||
lua? ( ${LUA_DEPS} )
|
||||
xapian? ( dev-libs/xapian:= )
|
||||
lz4? ( app-arch/lz4 )
|
||||
mysql? ( dev-db/mysql-connector-c:0= )
|
||||
pam? ( sys-libs/pam:= )
|
||||
postgres? ( dev-db/postgresql:* )
|
||||
selinux? ( sec-policy/selinux-dovecot )
|
||||
solr? ( net-misc/curl dev-libs/expat )
|
||||
sqlite? ( dev-db/sqlite:* )
|
||||
stemmer? ( dev-libs/snowball-stemmer:= )
|
||||
system-icu? ( dev-libs/icu:= )
|
||||
suid? ( acct-group/mail )
|
||||
systemd? ( sys-apps/systemd:= )
|
||||
textcat? ( app-text/libexttextcat:= )
|
||||
unwind? ( sys-libs/libunwind:= )
|
||||
zstd? ( app-arch/zstd:= )
|
||||
"
|
||||
|
||||
RDEPEND="
|
||||
${DEPEND}
|
||||
acct-group/dovecot
|
||||
acct-group/dovenull
|
||||
acct-user/dovecot
|
||||
acct-user/dovenull
|
||||
net-mail/mailbase[pam?]
|
||||
"
|
||||
|
||||
BDEPEND="virtual/pkgconfig
|
||||
test? (
|
||||
lua? (
|
||||
$(lua_gen_cond_dep '
|
||||
dev-lua/luajson[${LUA_USEDEP}]
|
||||
')
|
||||
)
|
||||
)
|
||||
verify-sig? ( sec-keys/openpgp-keys-dovecot )
|
||||
"
|
||||
|
||||
PATCHES=(
|
||||
"${FILESDIR}/${PN}-autoconf-lua-version-v3.patch"
|
||||
"${FILESDIR}/${PN}-32bit-test.patch"
|
||||
"${FILESDIR}/${PN}-32bit-time-t.patch"
|
||||
)
|
||||
|
||||
pkg_setup() {
|
||||
use lua && lua-single_pkg_setup
|
||||
if use managesieve && ! use sieve; then
|
||||
ewarn "managesieve USE flag selected but sieve USE flag unselected"
|
||||
ewarn "sieve USE flag will be turned on"
|
||||
fi
|
||||
}
|
||||
|
||||
src_unpack() {
|
||||
if use verify-sig; then
|
||||
verify-sig_verify_detached "${DISTDIR}"/${MY_P}.tar.gz{,.sig}
|
||||
use sieve && verify-sig_verify_detached "${DISTDIR}"/${PN}-pigeonhole-${MY_PV}.tar.gz{,.sig}
|
||||
use managesieve && verify-sig_verify_detached "${DISTDIR}"/${PN}-pigeonhole-${MY_PV}.tar.gz{,.sig}
|
||||
fi
|
||||
|
||||
default
|
||||
}
|
||||
|
||||
src_prepare() {
|
||||
default
|
||||
|
||||
# unix socket path too long under portage build dir
|
||||
sed -i '/^TEST_IMAP_CLIENT_HIBERNATE/s/test-imap-client-hibernate//' src/imap/Makefile.am || die
|
||||
|
||||
# rename default cert files
|
||||
sed -i -e "s:ssl-cert.pem:server.pem:" \
|
||||
-e "s:ssl-key.pem:server.key:" \
|
||||
doc/dovecot.conf.in || die "sed failed"
|
||||
|
||||
# bug 657108, 782631
|
||||
#elibtoolize
|
||||
eautoreconf
|
||||
|
||||
# Bug #727244
|
||||
append-cflags -fasynchronous-unwind-tables
|
||||
# Bug #971191
|
||||
append-cflags -fno-strict-aliasing
|
||||
}
|
||||
|
||||
src_configure() {
|
||||
use static-libs && lto-guarantee-fat
|
||||
|
||||
if tc-is-cross-compiler; then
|
||||
# runtime checks cannot be executed on the host
|
||||
# m4/gmtime_max.m4: 40 or 31 bits
|
||||
local maxtime=31
|
||||
tc-has-64bit-time_t && maxtime=40
|
||||
export i_cv_gmtime_max_time_t=${maxtime}
|
||||
export i_cv_epoll_works=yes
|
||||
export i_cv_fd_passing=yes
|
||||
export i_cv_mmap_plays_with_write=yes
|
||||
export i_cv_posix_fallocate_works=yes
|
||||
export lib_cv_va_copy=yes
|
||||
export lib_cv___va_copy=no
|
||||
fi
|
||||
|
||||
# --disable-hardening because our toolchain already defaults to
|
||||
# these bits on, and it actually regresses the default _FORTIFY_SOURCE
|
||||
# level for hardened at least from 3 to 2.
|
||||
#
|
||||
# turn valgrind tests off. Bug #340791
|
||||
VALGRIND=no \
|
||||
LUAPC="${ELUA}" \
|
||||
systemdsystemunitdir="$(systemd_get_systemunitdir)" \
|
||||
econf \
|
||||
--with-rundir="${EPREFIX}/run/dovecot" \
|
||||
--with-statedir="${EPREFIX}/var/lib/dovecot" \
|
||||
--with-moduledir="${EPREFIX}/usr/$(get_libdir)/dovecot" \
|
||||
--disable-hardening \
|
||||
--with-bzlib \
|
||||
--without-libbsd \
|
||||
--with-libcap \
|
||||
--enable-experimental-mail-utf8 \
|
||||
$( use_with argon2 sodium ) \
|
||||
$( use_with cdb) \
|
||||
$( use_with system-icu icu) \
|
||||
$( use_with kerberos gssapi ) \
|
||||
$( use_with lua ) \
|
||||
$( use_with ldap ) \
|
||||
$( use_with xapian flatcurve ) \
|
||||
$( use_with lz4 ) \
|
||||
$( use_with mysql ) \
|
||||
$( use_with pam ) \
|
||||
$( use_with postgres pgsql ) \
|
||||
$( use_with sqlite ) \
|
||||
$( use_with solr ) \
|
||||
$( use_with stemmer ) \
|
||||
$( use_with systemd ) \
|
||||
$( use_with textcat ) \
|
||||
$( use_with unwind libunwind ) \
|
||||
$( use_with zstd ) \
|
||||
$( use_enable static-libs static )
|
||||
|
||||
if use sieve || use managesieve; then
|
||||
# The sieve plugin needs this file to be build to determine the plugin
|
||||
# directory and the list of libraries to link to
|
||||
emake dovecot-config
|
||||
pushd "${PIEGONHOLE_S}" > /dev/null || die
|
||||
econf \
|
||||
$( use_enable static-libs static ) \
|
||||
--localstatedir="${EPREFIX}/var" \
|
||||
--enable-shared \
|
||||
--disable-hardening \
|
||||
--with-dovecot="${S}" \
|
||||
$( use_with ldap ) \
|
||||
$( use_with managesieve )
|
||||
popd > /dev/null || die
|
||||
fi
|
||||
}
|
||||
|
||||
src_compile() {
|
||||
default
|
||||
if use sieve || use managesieve; then
|
||||
pushd "${PIEGONHOLE_S}" > /dev/null || die
|
||||
emake CC="$(tc-getCC)" CFLAGS="${CFLAGS}"
|
||||
popd > /dev/null || die
|
||||
fi
|
||||
}
|
||||
|
||||
src_test() {
|
||||
# bug #340791 and bug #807178
|
||||
local -x NOVALGRIND=true
|
||||
|
||||
# don't fail if dovecot is not installed
|
||||
local -x DOVECONF_PATH="${S}/src/config/doveconf"
|
||||
|
||||
default
|
||||
if use sieve || use managesieve; then
|
||||
pushd "${PIEGONHOLE_S}" > /dev/null || die
|
||||
default
|
||||
popd > /dev/null || die
|
||||
fi
|
||||
}
|
||||
|
||||
src_install() {
|
||||
default
|
||||
|
||||
if use suid; then
|
||||
einfo "Changing perms to allow deliver to be suided"
|
||||
fowners root:mail "/usr/libexec/dovecot/dovecot-lda"
|
||||
fperms 4750 "/usr/libexec/dovecot/dovecot-lda"
|
||||
fi
|
||||
|
||||
newinitd "${FILESDIR}"/dovecot.init-r6 dovecot
|
||||
|
||||
use pam && dosym imap /etc/pam.d/dovecot
|
||||
|
||||
insinto /etc/dovecot/conf.d
|
||||
doins "${FILESDIR}/50-misc.conf"
|
||||
|
||||
dodoc AUTHORS NEWS README.md TODO
|
||||
|
||||
if use sieve || use managesieve; then
|
||||
pushd "${PIEGONHOLE_S}" > /dev/null || die
|
||||
emake DESTDIR="${ED}" install
|
||||
|
||||
newdoc README README.pigeonhole
|
||||
popd > /dev/null || die
|
||||
fi
|
||||
|
||||
if use static-libs; then
|
||||
strip-lto-bytecode
|
||||
else
|
||||
find "${ED}"/usr/lib* -name '*.la' -delete
|
||||
fi
|
||||
}
|
||||
|
||||
pkg_postinst() {
|
||||
if ver_replacing -lt 2.4 ; then
|
||||
# This is an upgrade which requires user review
|
||||
ewarn "Dovecot-2.4.x has new settings and WILL NOT work"
|
||||
ewarn "unless the configuration files are updated."
|
||||
ewarn "Please read the migration guide at:"
|
||||
ewarn " https://doc.dovecot.org/2.4.1/installation/upgrade/2.3-to-2.4.html"
|
||||
fi
|
||||
|
||||
# Let's not make a new certificate if we already have one
|
||||
if ! [[ -e "${ROOT}"/etc/dovecot/server.pem && \
|
||||
-e "${ROOT}"/etc/dovecot/server.key ]]; then
|
||||
einfo "Creating SSL certificate"
|
||||
SSL_ORGANIZATION="${SSL_ORGANIZATION:-Dovecot IMAP Server}"
|
||||
install_cert /etc/dovecot/server
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
From 25a1010e7c36b205f0d51335059ea0e5e2bd4e22 Mon Sep 17 00:00:00 2001
|
||||
From: Paul Howarth <paul@city-fan.org>
|
||||
Date: Fri, 17 Jul 2026 17:59:50 +0100
|
||||
Subject: [PATCH] lib: Fix fatal_array test for 32-bit systems
|
||||
|
||||
On 64-bit systems, SIZE_MAX is much bigger than UINT_MAX so an
|
||||
allocation of UINT_MAX objects is not unreasonable.
|
||||
|
||||
On 32-bit systems, SIZE_MAX and UINT_MAX are the same so an
|
||||
allocation of UINT_MAX objects fails malloc checks before reaching
|
||||
buffer size limit checks.
|
||||
---
|
||||
src/lib/test-array.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/src/lib/test-array.c b/src/lib/test-array.c
|
||||
index d6bebbae348..556d0106988 100644
|
||||
--- a/src/lib/test-array.c
|
||||
+++ b/src/lib/test-array.c
|
||||
@@ -461,7 +461,11 @@ enum fatal_test_state fatal_array(unsigned int stage)
|
||||
|
||||
t_array_init(&arr, 2);
|
||||
array_push_back(&arr, value);
|
||||
+#if SIZEOF_SIZE_T > 4 /* MALLOC_MULTIPLY will fail before buffer_check_limits with 32bit */
|
||||
test_expect_fatal_string("Buffer write out of range");
|
||||
+#else
|
||||
+ test_expect_fatal_string("memory allocation overflow");
|
||||
+#endif
|
||||
/* this is supposed to assert-crash before it even attempts to
|
||||
access value */
|
||||
array_append(&arr, value, UINT_MAX);
|
||||
@@ -0,0 +1,20 @@
|
||||
Fix TIME_T_MAX_BITS on 32-bit systems with a 32-bit signed time_t.
|
||||
https://github.com/dovecot/core/pull/316
|
||||
|
||||
diff --git a/m4/gmtime_max.m4 b/m4/gmtime_max.m4
|
||||
index d2501c1776..a0d8e06780 100644
|
||||
--- a/m4/gmtime_max.m4
|
||||
+++ b/m4/gmtime_max.m4
|
||||
@@ -21,12 +21,10 @@ AC_DEFUN([DOVECOT_GMTIME_MAX], [
|
||||
Let's just do the same as Cyrus folks and limit it to 40 bits. */
|
||||
bits = 40;
|
||||
}
|
||||
- #ifdef TIME_T_SIGNED
|
||||
if (bits == 32) {
|
||||
/* Signed 32-bit time_t is essentially the same as unsigned 31-bit time_t */
|
||||
bits = 31;
|
||||
}
|
||||
- #endif
|
||||
|
||||
f = fopen("conftest.temp", "w");
|
||||
if (f == NULL) {
|
||||
Reference in New Issue
Block a user