mail-mta/opensmtpd: bump for security disaster
[gentoo.git] / mail-mta / sendmail / sendmail-8.14.9.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="5"
5 inherit eutils multilib systemd toolchain-funcs user
6
7 DESCRIPTION="Widely-used Mail Transport Agent (MTA)"
8 HOMEPAGE="http://www.sendmail.org/"
9 SRC_URI="ftp://ftp.sendmail.org/pub/${PN}/${PN}.${PV}.tar.gz"
10
11 LICENSE="Sendmail GPL-2" # GPL-2 is here for initscript
12 SLOT="0"
13 KEYWORDS="~alpha amd64 arm hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86"
14 IUSE="ssl ldap sasl tcpd mbox ipv6 nis sockets"
15
16 DEPEND="net-mail/mailbase
17         sys-devel/m4
18         sasl? ( >=dev-libs/cyrus-sasl-2.1.10 )
19         tcpd? ( sys-apps/tcp-wrappers )
20         ssl? ( dev-libs/openssl:0= )
21         ldap? ( net-nds/openldap )
22         >=sys-libs/db-3.2
23         !net-mail/vacation
24         "
25 RDEPEND="${DEPEND}
26         >=net-mail/mailbase-0.00
27         !mail-mta/courier
28         !mail-mta/esmtp
29         !mail-mta/exim
30         !mail-mta/mini-qmail
31         !mail-mta/msmtp[mta]
32         !mail-mta/netqmail
33         !mail-mta/nullmailer
34         !mail-mta/postfix
35         !mail-mta/opensmtpd
36         !mail-mta/qmail-ldap
37         !<mail-mta/ssmtp-2.64-r2
38         !>=mail-mta/ssmtp-2.64-r2[mta]"
39
40 PDEPEND="!mbox? ( mail-filter/procmail )"
41
42 # libmilter library is part of sendmail, but it does not share the version number with it.
43 # In order to find the right libmilter version number, check SMFI_VERSION definition
44 # that can be found in ${S}/include/libmilter/mfapi.h (see also SM_LM_VRS_* defines).
45 # For example, version 1.0.1 has a SMFI_VERSION of 0x01000001.
46 LIBMILTER_VER=1.0.2
47
48 pkg_setup() {
49         enewgroup smmsp 209
50         enewuser smmsp 209 -1 /var/spool/mqueue smmsp
51 }
52
53 src_prepare() {
54         epatch "${FILESDIR}"/"${PN}"-8.14.6-build-system.patch
55         epatch "${FILESDIR}"/sendmail-delivered_hdr.patch
56         epatch "${FILESDIR}"/libmilter-sharedlib.patch
57         epatch "${FILESDIR}"/"${PN}"-8.14.5+db-5.0.patch
58         epatch "${FILESDIR}"/sendmail-starttls-multi-crl.patch
59
60         local confCC="$(tc-getCC)"
61         local confCCOPTS="${CFLAGS}"
62         local confLDOPTS="${LDFLAGS}"
63         local confMAPDEF="-DMAP_REGEX"
64         local conf_sendmail_LIBS=""
65         use sasl && confLIBS="${confLIBS} -lsasl2"  \
66                 && confENVDEF="${confENVDEF} -DSASL=2" \
67                 && confCCOPTS="${confCCOPTS} -I/usr/include/sasl" \
68                 && conf_sendmail_LIBS="${conf_sendmail_LIBS} -lsasl2"
69         use tcpd && confENVDEF="${confENVDEF} -DTCPWRAPPERS" \
70                 && confLIBS="${confLIBS} -lwrap"
71         use ssl && confENVDEF="${confENVDEF} -DSTARTTLS -D_FFR_DEAL_WITH_ERROR_SSL" \
72                 && confENVDEF="${confENVDEF} -D_FFR_TLS_1" \
73                 && confLIBS="${confLIBS} -lssl -lcrypto" \
74                 && conf_sendmail_LIBS="${conf_sendmail_LIBS} -lssl -lcrypto"
75         use ldap && confMAPDEF="${confMAPDEF} -DLDAPMAP" \
76                 && confLIBS="${confLIBS} -lldap -llber"
77         use ipv6 && confENVDEF="${confENVDEF} -DNETINET6"
78         use nis && confENVDEF="${confENVDEF} -DNIS"
79         use sockets && confENVDEF="${confENVDEF} -DSOCKETMAP"
80         sed -e "s:@@confCCOPTS@@:${confCCOPTS}:" \
81                 -e "s/@@confLDOPTS@@/${confLDOPTS}/" \
82                 -e "s/@@confCC@@/${confCC}/" \
83                 -e "s/@@confMAPDEF@@/${confMAPDEF}/" \
84                 -e "s/@@confENVDEF@@/${confENVDEF}/" \
85                 -e "s/@@confLIBS@@/${confLIBS}/" \
86                 -e "s/@@conf_sendmail_LIBS@@/${conf_sendmail_LIBS}/" \
87                 "${FILESDIR}"/site.config.m4 > devtools/Site/site.config.m4
88 }
89
90 src_compile() {
91         sh Build AR="$(tc-getAR)" RANLIB="$(tc-getRANLIB)" || die "compilation failed in main Build script"
92         pushd libmilter
93         sh Build AR="$(tc-getAR)" RANLIB="$(tc-getRANLIB)" MILTER_SOVER=${LIBMILTER_VER} || die "libmilter compilation failed"
94         popd
95 }
96
97 src_install () {
98         local MY_LIBDIR=/usr/$(get_libdir)
99         local MY_OBJDIR="obj.`uname -s`.`uname -r`.`uname -m`"
100         dodir /usr/bin ${MY_LIBDIR} /usr/include/libmilter
101         dodir /usr/share/man/man{1,5,8} /usr/sbin /var/log /usr/share/sendmail-cf
102         dodir /var/spool/{mqueue,clientmqueue} /etc/conf.d
103         keepdir /var/spool/{clientmqueue,mqueue}
104         for dir in libsmutil sendmail mailstats praliases smrsh makemap vacation editmap
105         do
106                 make DESTDIR="${D}" LIBDIR="${MY_LIBDIR}" MANROOT=/usr/share/man/man \
107                         SBINOWN=root SBINGRP=root UBINOWN=root UBINGRP=root \
108                         MANOWN=root MANGRP=root INCOWN=root INCGRP=root \
109                         LIBOWN=root LIBGRP=root GBINOWN=root GBINGRP=root \
110                         MSPQOWN=root CFOWN=root CFGRP=root \
111                         install -C "${MY_OBJDIR}/${dir}" \
112                         || die "install failed"
113         done
114         for dir in rmail mail.local
115         do
116                 make DESTDIR="${D}" LIBDIR="${MY_LIBDIR}" MANROOT=/usr/share/man/man \
117                         SBINOWN=root SBINGRP=root UBINOWN=root UBINGRP=root \
118                         MANOWN=root MANGRP=root INCOWN=root INCGRP=root \
119                         LIBOWN=root LIBGRP=root GBINOWN=root GBINGRP=root \
120                         MSPQOWN=root CFOWN=root CFGRP=root \
121                         force-install -C "${MY_OBJDIR}/${dir}" \
122                         || die "install failed"
123         done
124
125         make DESTDIR="${D}" LIBDIR="${MY_LIBDIR}" MANROOT=/usr/share/man/man \
126                 SBINOWN=root SBINGRP=root UBINOWN=root UBINGRP=root \
127                 MANOWN=root MANGRP=root INCOWN=root INCGRP=root \
128                 LIBOWN=root LIBGRP=root GBINOWN=root GBINGRP=root \
129                 MSPQOWN=root CFOWN=root CFGRP=root \
130                 MILTER_SOVER=${LIBMILTER_VER} \
131                 install -C "${MY_OBJDIR}/libmilter" \
132                 || die "install failed"
133
134         fowners root:smmsp /usr/sbin/sendmail
135         fperms 2555 /usr/sbin/sendmail
136         fowners smmsp:smmsp /var/spool/clientmqueue
137         fperms 770 /var/spool/clientmqueue
138         fperms 700 /var/spool/mqueue
139         dosym /usr/sbin/makemap /usr/bin/makemap
140         dodoc FAQ KNOWNBUGS README RELEASE_NOTES doc/op/op.ps
141         newdoc sendmail/README README.sendmail
142         newdoc sendmail/SECURITY SECURITY
143         newdoc sendmail/TUNING TUNING
144         newdoc smrsh/README README.smrsh
145         newdoc libmilter/README README.libmilter
146
147         newdoc cf/README README.cf
148         newdoc cf/cf/README README.install-cf
149         cp -pPR cf/* "${D}"/usr/share/sendmail-cf
150
151         docinto contrib
152         dodoc contrib/*
153
154         insinto /etc/mail
155         if use mbox
156         then
157                 newins "${FILESDIR}"/sendmail.mc-r1 sendmail.mc
158         else
159                 newins "${FILESDIR}"/sendmail-procmail.mc sendmail.mc
160         fi
161         m4 "${D}"/usr/share/sendmail-cf/m4/cf.m4 "${D}"/etc/mail/sendmail.mc \
162                 > "${D}"/etc/mail/sendmail.cf
163         echo "include(\`/usr/share/sendmail-cf/m4/cf.m4')dnl" \
164                 > "${D}"/etc/mail/submit.mc
165         cat "${D}"/usr/share/sendmail-cf/cf/submit.mc >> "${D}"/etc/mail/submit.mc
166         echo "# local-host-names - include all aliases for your machine here" \
167                 > "${D}"/etc/mail/local-host-names
168         cat <<- EOF > "${D}"/etc/mail/trusted-users
169                 # trusted-users - users that can send mail as others without a warning
170                 # apache, mailman, majordomo, uucp are good candidates
171         EOF
172         cat <<- EOF > "${D}"/etc/mail/access
173                 # Check the /usr/share/doc/sendmail/README.cf file for a description
174                 # of the format of this file. (search for access_db in that file)
175                 # The /usr/share/doc/sendmail/README.cf is part of the sendmail-doc
176                 # package.
177                 #
178
179         EOF
180         cat <<- EOF > "${D}"/etc/conf.d/sendmail
181                 # Config file for /etc/init.d/sendmail
182                 # add start-up options here
183                 SENDMAIL_OPTS="-bd -q30m -L sm-mta" # default daemon mode
184                 CLIENTMQUEUE_OPTS="-Ac -q30m -L sm-cm" # clientmqueue
185                 KILL_OPTS="" # add -9/-15/your favorite evil SIG level here
186
187         EOF
188         if use sasl; then
189                 dodir /etc/sasl2
190                 cat <<- EOF > "${D}"/etc/sasl2/Sendmail.conf
191                 pwcheck_method: saslauthd
192                 mech_list: PLAIN LOGIN
193
194                 EOF
195         fi
196
197         doinitd "${FILESDIR}"/sendmail
198         systemd_dounit "${FILESDIR}"/sendmail.service
199         systemd_dounit "${FILESDIR}"/sm-client.service
200
201         keepdir /usr/adm/sm.bin
202 }