net-mail/dovecot: security bump to 2.3.10.1
[gentoo.git] / net-mail / vpopmail / vpopmail-5.4.33-r6.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 inherit autotools fixheadtails qmail
7
8 HOMEPAGE="http://www.inter7.com/index.php?page=vpopmail"
9 DESCRIPTION="Collection of programs to manage virtual email on Qmail servers"
10 SRC_URI="mirror://sourceforge/${PN}/${P}.tar.gz"
11
12 LICENSE="GPL-2"
13 SLOT="0"
14 KEYWORDS="amd64 arm hppa ~ia64 ppc ppc64 ~s390 sparc x86"
15 IUSE="clearpasswd ipalias maildrop mysql postgres spamassassin"
16 REQUIRED_USE="mysql? ( !postgres )"
17
18 DEPEND="
19         acct-group/vpopmail
20         acct-user/vpopmail
21         virtual/qmail
22         maildrop? ( mail-filter/maildrop )
23         mysql? ( dev-db/mysql-connector-c:0= )
24         postgres? ( <dev-db/postgresql-9999:=[server] )
25         spamassassin? ( mail-filter/spamassassin )"
26 RDEPEND="${DEPEND}"
27
28 PATCHES=(
29         "${FILESDIR}"/${PN}-5.4.9-access.violation.patch
30         "${FILESDIR}"/${PN}-lazy.patch
31         "${FILESDIR}"/${PN}-vpgsql.patch
32         "${FILESDIR}"/${PN}-double-free.patch
33         "${FILESDIR}"/${PN}-5.4.33-vdelivermail-add-static.patch
34         "${FILESDIR}"/${PN}-5.4.33-fix-those-vfork-instances-that-do-more-than-exec.patch
35         "${FILESDIR}"/${PN}-5.4.33-remove-unneeded-forward-declaration.patch
36         "${FILESDIR}"/${PN}-5.4.33-clean-up-calling-maildrop.patch
37         "${FILESDIR}"/${PN}-5.4.33-fix-S-tag-in-case-spamassassin-changed-the-file-size.patch
38         "${FILESDIR}"/${PN}-5.4.33-strncat.patch
39         "${FILESDIR}"/${PN}-5.4.33-unistd.patch
40         "${FILESDIR}"/${PN}-5.4.33-check-crypt-return-value-for-NULL.patch
41         "${FILESDIR}"/${PN}-5.4.33-use-proper-printf-format-strings.patch
42 )
43 DOCS=(
44         ChangeLog
45         doc/.
46 )
47 HTML_DOCS=(
48         doc_html/.
49         man_html/.
50 )
51
52 VPOP_HOME="/var/vpopmail"
53
54 pkg_setup() {
55         upgradewarning
56 }
57
58 src_prepare() {
59         default
60
61         echo 'install-recursive: install-exec-am' \
62                 >>"${S}"/Makefile.am || die
63
64         # fix maildir paths
65         sed -i -e 's|Maildir|.maildir|g' \
66                 vchkpw.c vconvert.c vdelivermail.c \
67                 vpopbull.c vpopmail.c vqmaillocal.c \
68                 vuserinfo.c maildirquota.c || die
69
70         # remove vpopmail advertisement
71         sed -i -e '/printf.*vpopmail/s:vpopmail (:(:' \
72                 vdelivermail.c vpopbull.c vqmaillocal.c || die
73
74         # automake/autoconf
75         mv "${S}"/configure.{in,ac} || die
76         sed -i -e 's,AM_CONFIG_HEADER,AC_CONFIG_HEADERS,g' \
77                 configure.ac || die
78
79         # _FORTIFY_SOURCE
80         sed -i \
81                 -e 's/\(snprintf(\s*\(LI->[a-zA-Z_]\+\),\s*\)[a-zA-Z_]\+,/\1 sizeof(\2),/' \
82                 vlistlib.c || die
83
84         eautoreconf
85         ht_fix_file cdb/Makefile
86 }
87
88 src_configure() {
89         local -a authopts
90         if use mysql; then
91                 incdir=$(mysql_config --variable=pkgincludedir || die)
92                 libdir=$(mysql_config --variable=pkglibdir || die)
93                 authopts+=( "--enable-auth-module=mysql"
94                         "--enable-incdir=${incdir}"
95                         "--enable-libdir=${libdir}"
96                         "--enable-sql-logging"
97                         "--enable-valias"
98                         "--disable-mysql-replication"
99                         "--enable-mysql-limits"
100                 )
101         elif use postgres; then
102                 libdir=$(pg_config --libdir || die)
103                 incdir=$(pg_config --pkgincludedir || die)
104                 authopts+=( "--enable-auth-module=pgsql"
105                         "--enable-incdir=${incdir}"
106                         "--enable-libdir=${libdir}"
107                         "--enable-sql-logging"
108                         "--enable-valias"
109                 )
110         else
111                 authopts+=( "--enable-auth-module=cdb" )
112         fi
113
114         econf ${authopts[@]} \
115                 --sysconfdir=${VPOP_HOME}/etc \
116                 --enable-non-root-build \
117                 --enable-qmaildir=${QMAIL_HOME} \
118                 --enable-qmail-newu=${QMAIL_HOME}/bin/qmail-newu \
119                 --enable-qmail-inject=${QMAIL_HOME}/bin/qmail-inject \
120                 --enable-qmail-newmrh=${QMAIL_HOME}/bin/qmail-newmrh \
121                 --enable-vpopuser=vpopmail \
122                 --enable-vpopgroup=vpopmail \
123                 --enable-many-domains \
124                 --enable-file-locking \
125                 --enable-file-sync \
126                 --enable-md5-passwords \
127                 --enable-logging \
128                 --enable-auth-logging \
129                 --enable-log-name=vpopmail \
130                 --enable-qmail-ext \
131                 --disable-tcpserver-file \
132                 --disable-roaming-users \
133                 $(use_enable ipalias ip-alias-domains) \
134                 $(use_enable clearpasswd clear-passwd) \
135                 $(use_enable maildrop) \
136                 $(use_enable maildrop maildrop-prog /usr/bin/maildrop) \
137                 $(use_enable spamassassin)
138 }
139
140 src_install() {
141         emake DESTDIR="${D}" install
142         keepdir "${VPOP_HOME}"/domains
143
144         # install helper script for maildir conversion
145         into "${VPOP_HOME}"
146         dobin "${FILESDIR}"/vpopmail-Maildir-dotmaildir-fix.sh
147         into /usr
148
149         mv doc/doc_html/ doc/man_html/ . || die
150         einstalldocs
151         rm -r "${D}/${VPOP_HOME}"/doc || die
152
153         # create /etc/vpopmail.conf
154         if use mysql; then
155                 insinto /etc
156                 newins "${D}${VPOP_HOME}"/etc/vpopmail.mysql vpopmail.conf
157                 dosym ../../../etc/vpopmail.conf "${VPOP_HOME}"/etc/vpopmail.mysql
158
159                 sed 's/^[^#]/# &/' -i "${D}"/etc/vpopmail.conf || die
160                 echo '# Read-only DB' >> "${D}"/etc/vpopmail.conf || die
161                 echo 'localhost|0|vpopmail|secret|vpopmail' >> "${D}"/etc/vpopmail.conf || die
162                 echo '# Write DB' >> "${D}"/etc/vpopmail.conf || die
163                 echo 'localhost|0|vpopmail|secret|vpopmail' >> "${D}"/etc/vpopmail.conf || die
164
165                 # lock down perms
166                 fperms 640 /etc/vpopmail.conf
167                 fowners root:vpopmail /etc/vpopmail.conf
168         fi
169
170         insinto "${VPOP_HOME}"/etc
171         doins vusagec.conf
172         dosym .."${VPOP_HOME}"/etc/vusagec.conf /etc/vusagec.conf
173         sed -i 's/Disable = False;/Disable = True;/g' "${D}${VPOP_HOME}"/etc/vusagec.conf || die
174
175         einfo "Installing env.d entry"
176         doenvd "${FILESDIR}"/99vpopmail
177
178         einfo "Locking down vpopmail permissions"
179         fowners -R root:0 "${VPOP_HOME}"/{bin,etc,include}
180         fowners root:vpopmail "${VPOP_HOME}"/bin/vchkpw
181         fperms 4711 "${VPOP_HOME}"/bin/vchkpw
182 }
183
184 pkg_postinst() {
185         if use mysql ; then
186                 elog
187                 elog "You have 'mysql' turned on in your USE"
188                 elog "Vpopmail needs a VALID MySQL USER. Let's call it 'vpopmail'"
189                 elog "You MUST add it and then specify its passwd in the /etc/vpopmail.conf file"
190                 elog
191                 elog "First log into mysql as your mysql root user and pass. Then:"
192                 elog "> create database vpopmail;"
193                 elog "> use mysql;"
194                 elog "> grant select, insert, update, delete, create, drop on vpopmail.* to"
195                 elog "  vpopmail@localhost identified by 'your password';"
196                 elog "> flush privileges;"
197                 elog
198                 elog "If you have problems with vpopmail not accepting mail properly,"
199                 elog "please ensure that /etc/vpopmail.conf is chmod 640 and"
200                 elog "owned by root:vpopmail"
201                 elog
202         fi
203
204         # do this for good measure
205         if [[ -e /etc/vpopmail.conf ]]; then
206                 chmod 640 /etc/vpopmail.conf || die
207                 chown root:vpopmail /etc/vpopmail.conf || die
208         fi
209
210         upgradewarning
211 }
212
213 pkg_postrm() {
214         elog "The vpopmail DATA will NOT be removed automatically."
215         elog "You can delete them manually by removing the ${VPOP_HOME} directory."
216 }
217
218 upgradewarning() {
219         if has_version "<=net-mail/vpopmail-5.2.1-r8"; then
220                 ewarn
221                 ewarn "Massive important warning if you are upgrading to 5.2.1-r8 or older"
222                 ewarn "The internal structure of the mail storage has changed for"
223                 ewarn "consistancy with the rest of Gentoo! Please review and utilize the "
224                 ewarn "script at ${VPOP_HOME}/bin/vpopmail-Maildir-dotmaildir-fix.sh"
225                 ewarn "to upgrade your system! (It can do conversions both ways)."
226                 ewarn "You should be able to run it right away without any changes."
227                 ewarn
228         fi
229
230         elog
231         elog "Use of vpopmail's tcp.smtp[.cdb] is also deprecated now, consider"
232         elog "using net-mail/relay-ctrl instead."
233         elog
234
235         if use mysql; then
236                 if has_version "<=net-mail/vpopmail-5.4.17"; then
237                         elog
238                         elog "If you are upgrading from 5.4.17 or older, you have to fix your"
239                         elog "MySQL tables, please see the UPGRADE file in the documentation!"
240                         elog
241                 fi
242         fi
243
244         ewarn
245         ewarn "Newer versions of vpopmail contain a quota daemon called vusaged."
246         ewarn "This ebuild DOES NOT INSTALL vusaged and has therefore disabled"
247         ewarn "its usage in ${VPOP_HOME}/etc/vusagec.conf. DO NOT ENABLE!"
248         ewarn "Otherwise mail delivery WILL BREAK"
249         ewarn
250 }