mail-filter/procmail: revbump to fix longstanding vulnerabilities
[gentoo.git] / mail-filter / procmail / procmail-3.22-r12.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 inherit flag-o-matic toolchain-funcs prefix
7
8 DESCRIPTION="Mail delivery agent/filter"
9 HOMEPAGE="http://www.procmail.org/"
10 SRC_URI="http://www.procmail.org/${P}.tar.gz"
11
12 LICENSE="|| ( Artistic GPL-2 )"
13 SLOT="0"
14 KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x86-solaris"
15 IUSE="mbox selinux"
16
17 DEPEND="virtual/mta"
18 RDEPEND="selinux? ( sec-policy/selinux-procmail )"
19
20 src_prepare() {
21         # disable flock, using both fcntl and flock style locking
22         # doesn't work with NFS with 2.6.17+ kernels, bug #156493
23
24         sed -e "s:/\*#define NO_flock_LOCK:#define NO_flock_LOCK:" \
25                 -i config.h || die "sed failed"
26
27         if ! use mbox ; then
28                 echo "# Use maildir-style mailbox in user's home directory" > "${S}"/procmailrc || die
29                 echo 'DEFAULT=$HOME/.maildir/' >> "${S}"/procmailrc || die
30                 cd "${S}" || die
31                 eapply "${FILESDIR}/gentoo-maildir3.diff"
32         else
33                 echo '# Use mbox-style mailbox in /var/spool/mail' > "${S}"/procmailrc || die
34                 echo 'DEFAULT=${EPREFIX}/var/spool/mail/$LOGNAME' >> "${S}"/procmailrc || die
35         fi
36
37         # Do not use lazy bindings on lockfile and procmail
38         if [[ ${CHOST} != *-darwin* ]]; then
39                 eapply -p0 "${FILESDIR}/${PN}-lazy-bindings.diff"
40         fi
41
42         # Fix for bug #102340
43         eapply -p0 "${FILESDIR}/${PN}-comsat-segfault.diff"
44
45         # Fix for bug #119890
46         eapply -p0 "${FILESDIR}/${PN}-maxprocs-fix.diff"
47
48         # Prefixify config.h
49         eapply -p0 "${FILESDIR}"/${PN}-prefix.patch
50         eprefixify config.h Makefile src/autoconf src/recommend.c
51
52         # Fix for bug #200006
53         eapply "${FILESDIR}/${PN}-pipealloc.diff"
54
55         # Fix for bug #270551
56         eapply "${FILESDIR}/${PN}-3.22-glibc-2.10.patch"
57
58         # Fix security bugs #522114 and #638108
59         eapply "${FILESDIR}/${PN}-CVE-2014-3618-16844.patch"
60
61         eapply_user
62 }
63
64 src_compile() {
65         # -finline-functions (implied by -O3) leaves strstr() in an infinite loop.
66         # To work around this, we append -fno-inline-functions to CFLAGS
67         # Since GCC 4.7 we also need -fno-ipa-cp-clone (bug #466552)
68         # If it's clang, ignore -fno-ipa-cp-clone, as clang doesn't support this
69         case "$(tc-getCC)" in
70                 "clang") append-flags -fno-inline-functions ;;
71                 "gcc"|*) append-flags -fno-inline-functions -fno-ipa-cp-clone ;;
72         esac
73
74         sed -e "s:CFLAGS0 = -O:CFLAGS0 = ${CFLAGS}:" \
75                 -e "s:LDFLAGS0= -s:LDFLAGS0 = ${LDFLAGS}:" \
76                 -e "s:LOCKINGTEST=__defaults__:#LOCKINGTEST=__defaults__:" \
77                 -e "s:#LOCKINGTEST=/tmp:LOCKINGTEST=/tmp:" \
78                 -i Makefile || die "sed failed"
79
80         emake CC="$(tc-getCC)"
81 }
82
83 src_install() {
84         cd "${S}"/new || die
85         insinto /usr/bin
86         insopts -m 6755
87         doins procmail
88
89         doins lockfile
90         fowners root:mail /usr/bin/lockfile
91         fperms 2755 /usr/bin/lockfile
92
93         dobin formail mailstat
94         insopts -m 0644
95
96         doman *.1 *.5
97
98         cd "${S}" || die
99         dodoc FAQ FEATURES HISTORY INSTALL KNOWN_BUGS README
100
101         insinto /etc
102         doins procmailrc
103
104         docinto examples
105         dodoc examples/*
106 }
107
108 pkg_postinst() {
109         if ! use mbox ; then
110                 elog "Starting with mail-filter/procmail-3.22-r9 you'll need to ensure"
111                 elog "that you configure a mail storage location using DEFAULT in"
112                 elog "/etc/procmailrc, for example:"
113                 elog "\tDEFAULT=\$HOME/.maildir/"
114         fi
115         if has sfperms ${FEATURES}; then
116                 ewarn "FEATURES=sfperms removes the read-bit for others from"
117                 ewarn "  /usr/bin/procmail"
118                 ewarn "  /usr/bin/lockfile"
119                 ewarn "If you use procmail from an MTA like Exim, you need to"
120                 ewarn "re-add the read-bit or avoid the MTA checking the binary"
121                 ewarn "exists."
122         fi
123 }