summaryrefslogtreecommitdiff
path: root/mail-mta
diff options
context:
space:
mode:
authorBertrand Jacquin <beber@meleeweb.net>2006-11-03 02:48:10 +0100
committerBertrand Jacquin <beber@meleeweb.net>2006-11-03 02:48:10 +0100
commitbf1f19ab7bedf3fca4dcf92655f358d852449a7f (patch)
tree246fe69d053d0d65511b97b03157eb2927f72918 /mail-mta
parentadd deps for alphamail (diff)
downloadportage-bf1f19ab7bedf3fca4dcf92655f358d852449a7f.tar.xz
exim: add patch for domainkey & dovecot
Diffstat (limited to 'mail-mta')
-rw-r--r--mail-mta/exim/Manifest36
-rw-r--r--mail-mta/exim/exim-4.62-r1.ebuild310
-rw-r--r--mail-mta/exim/exim-4.62-r2.ebuild321
-rw-r--r--mail-mta/exim/files/digest-exim-4.62-r16
-rw-r--r--mail-mta/exim/files/digest-exim-4.62-r26
-rw-r--r--mail-mta/exim/files/exim-4.14-tail.patch11
-rw-r--r--mail-mta/exim/files/exim-4.20-maildir.patch14
-rw-r--r--mail-mta/exim/files/exim-4.43-SmtpUsingDovecot.patch384
-rw-r--r--mail-mta/exim/files/exim-4.43-SmtpUsingDovecot.patch3384
-rw-r--r--mail-mta/exim/files/exim-4.43-r2-localscan_dlopen.patch259
10 files changed, 1731 insertions, 0 deletions
diff --git a/mail-mta/exim/Manifest b/mail-mta/exim/Manifest
new file mode 100644
index 00000000..cbccefb0
--- /dev/null
+++ b/mail-mta/exim/Manifest
@@ -0,0 +1,36 @@
+AUX exim-4.14-tail.patch 446 RMD160 685e27ff995710f3b8d77d8785b04503170e7e27 SHA1 d52b5d10656ead546beda128068ed2f9dbc67200 SHA256 74d1044bb94e167180fd8f8aba7449ca3d2b09b1ce170a1a2e4e54ca0cd660da
+MD5 5d5aabea7d56a91803df1312c04d32c0 files/exim-4.14-tail.patch 446
+RMD160 685e27ff995710f3b8d77d8785b04503170e7e27 files/exim-4.14-tail.patch 446
+SHA256 74d1044bb94e167180fd8f8aba7449ca3d2b09b1ce170a1a2e4e54ca0cd660da files/exim-4.14-tail.patch 446
+AUX exim-4.20-maildir.patch 478 RMD160 50c6a1dd6ae3f7bb1776696d3d0d7a161c351fce SHA1 c8287f7e44d93b0ca8761b8f7111974cfe1280a5 SHA256 2704c4db67bb7c58c2421656d942f533d1eedf1df187e76297ab72d2c2a2fb4c
+MD5 622b726ea7b32aae93a8fe9f3c2af9cd files/exim-4.20-maildir.patch 478
+RMD160 50c6a1dd6ae3f7bb1776696d3d0d7a161c351fce files/exim-4.20-maildir.patch 478
+SHA256 2704c4db67bb7c58c2421656d942f533d1eedf1df187e76297ab72d2c2a2fb4c files/exim-4.20-maildir.patch 478
+AUX exim-4.43-SmtpUsingDovecot.patch 13382 RMD160 792ec7e17ebf40e3b2ae7a4cb7d2ccee7dde7438 SHA1 c50d1a3a2b87690e439a380a77424472edff8977 SHA256 9c64359f42b9f6019c486a240e2b4a14c5390f680e6fed456894eb6ec3da81cd
+MD5 d7affee8bf277ce9380f2027320c958c files/exim-4.43-SmtpUsingDovecot.patch 13382
+RMD160 792ec7e17ebf40e3b2ae7a4cb7d2ccee7dde7438 files/exim-4.43-SmtpUsingDovecot.patch 13382
+SHA256 9c64359f42b9f6019c486a240e2b4a14c5390f680e6fed456894eb6ec3da81cd files/exim-4.43-SmtpUsingDovecot.patch 13382
+AUX exim-4.43-SmtpUsingDovecot.patch3 11103 RMD160 01845114ae4cab9e323ad9536dede17efa9e0686 SHA1 4c95885af306479b133bb62e4f40f3b2d7e0f96d SHA256 8dbd42b7e14cb45aceaef5b458cf2ef61e6b2adcd3fc66f69ce41b165ffcdf15
+MD5 327dd7e08aa0757741d2dda318fa9f4f files/exim-4.43-SmtpUsingDovecot.patch3 11103
+RMD160 01845114ae4cab9e323ad9536dede17efa9e0686 files/exim-4.43-SmtpUsingDovecot.patch3 11103
+SHA256 8dbd42b7e14cb45aceaef5b458cf2ef61e6b2adcd3fc66f69ce41b165ffcdf15 files/exim-4.43-SmtpUsingDovecot.patch3 11103
+AUX exim-4.43-r2-localscan_dlopen.patch 9236 RMD160 d33f7bcf72f947e8d1a3d917713630100c175491 SHA1 e4239a1bf0261f99491b4a29b26bbe8d9beffbd8 SHA256 3ec15d2dfdf251c70647c3def09711385f23983eceeecb6ec9d42b39f54b198d
+MD5 c76437104cbde9184f01eb0987bfd738 files/exim-4.43-r2-localscan_dlopen.patch 9236
+RMD160 d33f7bcf72f947e8d1a3d917713630100c175491 files/exim-4.43-r2-localscan_dlopen.patch 9236
+SHA256 3ec15d2dfdf251c70647c3def09711385f23983eceeecb6ec9d42b39f54b198d files/exim-4.43-r2-localscan_dlopen.patch 9236
+DIST exim-4.62.tar.bz2 1577729 RMD160 9553b758e3bfd3d12027262b6211e37ad3259252 SHA1 2b3f95c1880de07ef22a96d7141eaa66e3c46768 SHA256 b5438894807c560a7933af36d10b2951f890aece9bff14c95fe2b91b0398629b
+DIST exiscan.conf 22113 RMD160 e52b77f656b3ba2105e833075d1368f41e414d64 SHA1 74dc6e30f49402f5e6fefc280ea325d17f6af8c4 SHA256 f8cc731d3225a902461e05c0997df23bfd231ea8d5bf33a9aba5783bc6e0c964
+EBUILD exim-4.62-r1.ebuild 9415 RMD160 d30f3cc4b0589ad5fdba440158873b90db1d0bec SHA1 14282701dc9a90c0a40979f8895da13ef851b085 SHA256 dfec5f6a4a2a2608189d0982fe48af69a1c6919d7bca13ba622fd5606bda6624
+MD5 06ae8ab5fb6ae358fca522e635177655 exim-4.62-r1.ebuild 9415
+RMD160 d30f3cc4b0589ad5fdba440158873b90db1d0bec exim-4.62-r1.ebuild 9415
+SHA256 dfec5f6a4a2a2608189d0982fe48af69a1c6919d7bca13ba622fd5606bda6624 exim-4.62-r1.ebuild 9415
+EBUILD exim-4.62-r2.ebuild 9746 RMD160 83c3af9169d0e94cf426f4c75d92d57582199ab4 SHA1 ebf4e93c374a677f3fa58e1a45689362bc62250d SHA256 d54efa135f261c97cc94063189c951b20700c5899c46fc63ea48f285d4f6bc87
+MD5 1287278ba300ed151881be0abd68d9af exim-4.62-r2.ebuild 9746
+RMD160 83c3af9169d0e94cf426f4c75d92d57582199ab4 exim-4.62-r2.ebuild 9746
+SHA256 d54efa135f261c97cc94063189c951b20700c5899c46fc63ea48f285d4f6bc87 exim-4.62-r2.ebuild 9746
+MD5 31e2a5f83bcae355694aafddd6d76d10 files/digest-exim-4.62-r1 449
+RMD160 b65f09555de6587827634d3c592f8a25515d938e files/digest-exim-4.62-r1 449
+SHA256 23a4934530694bdb862bb652d6045101cfaa263d8be8e34f7a6b296f97ae2202 files/digest-exim-4.62-r1 449
+MD5 31e2a5f83bcae355694aafddd6d76d10 files/digest-exim-4.62-r2 449
+RMD160 b65f09555de6587827634d3c592f8a25515d938e files/digest-exim-4.62-r2 449
+SHA256 23a4934530694bdb862bb652d6045101cfaa263d8be8e34f7a6b296f97ae2202 files/digest-exim-4.62-r2 449
diff --git a/mail-mta/exim/exim-4.62-r1.ebuild b/mail-mta/exim/exim-4.62-r1.ebuild
new file mode 100644
index 00000000..678e00b7
--- /dev/null
+++ b/mail-mta/exim/exim-4.62-r1.ebuild
@@ -0,0 +1,310 @@
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/mail-mta/exim/exim-4.62.ebuild,v 1.4 2006/10/11 08:40:33 corsair Exp $
+
+inherit eutils
+
+IUSE="tcpd ssl postgres mysql ldap pam exiscan-acl mailwrapper lmtp ipv6 sasl dnsdb perl mbx X exiscan nis syslog spf srs domainkeys gnutls sqlite"
+
+DESCRIPTION="A highly configurable, drop-in replacement for sendmail"
+SRC_URI="ftp://ftp.exim.org/pub/exim/exim4/${P}.tar.bz2 mirror://gentoo/exiscan.conf"
+HOMEPAGE="http://www.exim.org/"
+
+SLOT="0"
+LICENSE="GPL-2"
+KEYWORDS="~alpha ~amd64 ~hppa ~ia64 ~ppc ppc64 sparc x86"
+
+PROVIDE="virtual/mta"
+DEPEND=">=sys-apps/sed-4.0.5
+ perl? ( sys-devel/libperl )
+ >=sys-libs/db-3.2
+ pam? ( >=sys-libs/pam-0.75 )
+ tcpd? ( sys-apps/tcp-wrappers )
+ ssl? ( >=dev-libs/openssl-0.9.6 )
+ gnutls? ( net-libs/gnutls )
+ ldap? ( >=net-nds/openldap-2.0.7 )
+ mysql? ( >=dev-db/mysql-3.23.28 )
+ postgres? ( >=dev-db/postgresql-7 )
+ sasl? ( >=dev-libs/cyrus-sasl-2.1.14 )
+ spf? ( >=mail-filter/libspf2-1.2.5-r1 )
+ srs? ( mail-filter/libsrs_alt )
+ domainkeys? ( mail-filter/libdomainkeys )
+ X? ( || ( ( x11-proto/xproto
+ x11-libs/libX11
+ x11-libs/libXmu
+ x11-libs/libXt
+ x11-libs/libXaw )
+ virtual/x11 )
+ )
+ sqlite? ( dev-db/sqlite )"
+ # added X check for #57206
+RDEPEND="${DEPEND}
+ mailwrapper? ( >=net-mail/mailwrapper-0.2 )
+ !mailwrapper? ( !virtual/mta )
+ >=net-mail/mailbase-0.00-r5"
+
+src_unpack() {
+ unpack ${A}
+ cd ${S}
+
+ local myconf
+
+ epatch ${FILESDIR}/exim-4.14-tail.patch
+ epatch ${FILESDIR}/exim-4.43-r2-localscan_dlopen.patch
+
+ if ! use mbox; then
+ einfo "Patching maildir support into exim.conf"
+ epatch ${FILESDIR}/exim-4.20-maildir.patch
+ fi
+
+ sed -i "/SYSTEM_ALIASES_FILE/ s'SYSTEM_ALIASES_FILE'/etc/mail/aliases'" ${S}/src/configure.default
+ cp ${S}/src/configure.default ${S}/src/configure.default.orig
+
+ # Includes Typo fix for bug 47106
+ sed -e "48i\CFLAGS=${CFLAGS}" \
+ -e "s:# AUTH_CRAM_MD5=yes:AUTH_CRAM_MD5=yes:" \
+ -e "s:# AUTH_PLAINTEXT=yes:AUTH_PLAINTEXT=yes:" \
+ -e "s:BIN_DIRECTORY=/usr/exim/bin:BIN_DIRECTORY=/usr/sbin:" \
+ -e "s:COMPRESS_COMMAND=/usr/bin/gzip:COMPRESS_COMMAND=/bin/gzip:" \
+ -e "s:ZCAT_COMMAND=/usr/bin/zcat:ZCAT_COMMAND=/bin/zcat:" \
+ -e "s:CONFIGURE_FILE=/usr/exim/configure:CONFIGURE_FILE=/etc/exim/exim.conf:" \
+ -e "s:EXIM_MONITOR=eximon.bin:# EXIM_MONITOR=eximon.bin:" \
+ -e "s:# INFO_DIRECTORY=/usr/local/info:INFO_DIRECTORY=/usr/share/info:" \
+ -e "s:# LOG_FILE_PATH=/var/log/exim_%slog:LOG_FILE_PATH=/var/log/exim/exim_%s.log:" \
+ -e "s:# PID_FILE_PATH=/var/lock/exim.pid:PID_FILE_PATH=/var/run/exim.pid:" \
+ -e "s:# SPOOL_DIRECTORY=/var/spool/exim:SPOOL_DIRECTORY=/var/spool/exim:" \
+ -e "s:# SUPPORT_MAILDIR=yes:SUPPORT_MAILDIR=yes:" \
+ -e "s:# SUPPORT_MAILSTORE=yes:SUPPORT_MAILSTORE=yes:" \
+ -e "s:EXIM_USER=:EXIM_USER=mail:" \
+ -e "s:# AUTH_SPA=yes:AUTH_SPA=yes:" \
+ -e "s:^ZCAT_COMMAND.*$:ZCAT_COMMAND=/bin/zcat:" \
+ -e "s:# LOOKUP_PASSWD=yes:LOOKUP_PASSWD=yes:" \
+ src/EDITME > Local/Makefile
+
+ # exiscan-acl is now integrated - enabled it when use-flag set
+ if use exiscan-acl; then
+ sed -i "s:# WITH_CONTENT_SCAN=yes:WITH_CONTENT_SCAN=yes:" Local/Makefile
+ sed -i "s:# WITH_OLD_DEMIME=yes:WITH_OLD_DEMIME=yes:" Local/Makefile
+ elif (use spf || use srs || use domainkeys) then
+ eerror SPF, SRS and DomainKeys support require exiscan-acl to be enabled, please add
+ eerror to your USE settings.
+ exit 1
+ fi
+ if use spf; then
+ myconf="${myconf} -lspf2"
+ sed -i "s:# EXPERIMENTAL_SPF=yes:EXPERIMENTAL_SPF=yes:" Local/Makefile
+ mycflags="${mycflags} -DEXPERIMENTAL_SPF"
+ fi
+ if use srs; then
+ myconf="${myconf} -lsrs_alt"
+ sed -i "s:# EXPERIMENTAL_SRS=yes:EXPERIMENTAL_SRS=yes:" Local/Makefile
+ fi
+
+ if use domainkeys; then
+ myconf="${myconf} -ldomainkeys"
+ echo "EXPERIMENTAL_DOMAINKEYS=yes" >> Local/Makefile
+ mycflags="${mycflags} -DEXPERIMENTAL_DOMAINKEYS"
+ fi
+
+ cd Local
+ # enable optional exim_monitor support via X use flag bug #46778
+ if use X; then
+ einfo "Configuring eximon"
+ cp ../exim_monitor/EDITME eximon.conf
+ sed -i "s:# EXIM_MONITOR=eximon.bin:EXIM_MONITOR=eximon.bin:" Makefile
+ fi
+ #These next two should resolve 37964
+ if use perl; then
+ sed -i "s:# EXIM_PERL=perl.o:EXIM_PERL=perl.o:" Makefile
+ fi
+ # mbox useflag renamed, see bug 110741
+ if use mbx; then
+ sed -i "s:# SUPPORT_MBX=yes:SUPPORT_MBX=yes:" Makefile
+ fi
+ if use pam; then
+ sed -i "s:# \(SUPPORT_PAM=yes\):\1:" Makefile
+ myconf="${myconf} -lpam"
+ fi
+ if use sasl; then
+ sed -i "s:# CYRUS_SASLAUTHD_SOCKET=/var/state/saslauthd/mux:CYRUS_SASLAUTHD_SOCKET=/var/lib/sasl2/mux:" Makefile
+ sed -i "s:# AUTH_CYRUS_SASL=yes:AUTH_CYRUS_SASL=yes:" Makefile
+ myconf="${myconf} -lsasl2"
+ fi
+ if use tcpd; then
+ sed -i "s:# \(USE_TCP_WRAPPERS=yes\):\1:" Makefile
+ myconf="${myconf} -lwrap"
+ fi
+ if use lmtp; then
+ sed -i "s:# \(TRANSPORT_LMTP=yes\):\1:" Makefile
+ fi
+ if use ipv6; then
+ echo "HAVE_IPV6=YES" >> Makefile
+ #To fix bug 41196
+ echo "IPV6_USE_INET_PTON=yes" >> Makefile
+ fi
+
+ if [ -n "$myconf" ] ; then
+ echo "EXTRALIBS=${myconf} ${LDFLAGS}" >> Makefile
+ fi
+
+ cd ${S}
+ if use ssl; then
+ sed -i \
+ -e "s:# \(SUPPORT_TLS=yes\):\1:" Local/Makefile
+ if use gnutls; then
+ sed -i \
+ -e "s:# \(USE_GNUTLS=yes\):\1:" \
+ -e "s:# \(TLS_LIBS=-lgnutls -ltasn1 -lgcrypt\):\1:" Local/Makefile
+ else
+ sed -i \
+ -e "s:# \(TLS_LIBS=-lssl -lcrypto\):\1:" Local/Makefile
+ fi
+ fi
+
+ LOOKUP_INCLUDE=
+ LOOKUP_LIBS=
+
+ if use ldap; then
+ sed -i \
+ -e "s:# \(LOOKUP_LDAP=yes\):\1:" \
+ -e "s:# \(LDAP_LIB_TYPE=OPENLDAP2\):\1:" Local/Makefile
+ LOOKUP_INCLUDE="-I/usr/include/ldap"
+ LOOKUP_LIBS="-L/usr/lib -lldap -llber"
+ fi
+
+ if use mysql; then
+ sed -i "s:# LOOKUP_MYSQL=yes:LOOKUP_MYSQL=yes:" Local/Makefile
+ LOOKUP_INCLUDE="$LOOKUP_INCLUDE -I/usr/include/mysql"
+ LOOKUP_LIBS="$LOOKUP_LIBS -L/usr/lib -lmysqlclient"
+ fi
+
+ if use postgres; then
+ sed -i "s:# LOOKUP_PGSQL=yes:LOOKUP_PGSQL=yes:" Local/Makefile
+ LOOKUP_INCLUDE="$LOOKUP_INCLUDE -I/usr/include/postgresql"
+ LOOKUP_LIBS="$LOOKUP_LIBS -lpq"
+ fi
+ if use sqlite; then
+ sed -i "s:# LOOKUP_SQLITE=yes: LOOKUP_SQLITE=yes:" Local/Makefile
+ LOOKUP_INCLUDE="$LOOKUP_INCLUDE -I/usr/include/sqlite"
+ LOOKUP_LIBS="$LOOKUP_LIBS -lsqlite3"
+ fi
+ if [ -n "$LOOKUP_INCLUDE" ]; then
+ sed -i "s:# LOOKUP_INCLUDE=-I /usr/local/ldap/include -I /usr/local/mysql/include -I /usr/local/pgsql/include:LOOKUP_INCLUDE=$LOOKUP_INCLUDE:" \
+ Local/Makefile
+ fi
+
+ if [ -n "$LOOKUP_LIBS" ]; then
+ sed -i "s:# LOOKUP_LIBS=-L/usr/local/lib -lldap -llber -lmysqlclient -lpq -lgds -lsqlite3:LOOKUP_LIBS=$LOOKUP_LIBS:" \
+ Local/Makefile
+ fi
+
+
+ cat Makefile | sed -e 's/^buildname=.*/buildname=exim-gentoo/g' > Makefile.gentoo && mv -f Makefile.gentoo Makefile
+
+ sed -i "s:# LOOKUP_DSEARCH=yes:LOOKUP_DSEARCH=yes:" Local/Makefile
+
+ if use dnsdb; then
+ sed -i "s:# LOOKUP_DNSDB=yes:LOOKUP_DNSDB=yes:" Local/Makefile
+ fi
+ sed -i "s:# LOOKUP_CDB=yes:LOOKUP_CDB=yes:" Local/Makefile
+
+ if use nis; then
+ sed -i "s:# LOOKUP_NIS=yes:LOOKUP_NIS=yes:" Local/Makefile
+ sed -i "s:# LOOKUP_NISPLUS=yes:LOOKUP_NISPLUS=yes:" Local/Makefile
+ fi
+ if use syslog; then
+ sed -i "s:LOG_FILE_PATH=/var/log/exim/exim_%s.log:LOG_FILE_PATH=syslog:" Local/Makefile
+ fi
+# Use the "native" interface to the DBM library
+ echo "USE_DB=yes" >> ${S}/Local/Makefile
+}
+
+src_compile() {
+ make || die "make failed"
+}
+
+
+src_install () {
+ cd ${S}/build-exim-gentoo
+ exeinto /usr/sbin
+ doexe exim
+ if use X;then
+ doexe eximon.bin
+ doexe eximon
+ fi
+ fperms 4755 /usr/sbin/exim
+
+ dodir /usr/bin /usr/sbin /usr/lib
+ dosym ../sbin/exim /usr/bin/mailq
+ dosym ../sbin/exim /usr/bin/newaliases
+ einfo "The Exim ebuild will no longer touch /usr/bin/mail, so as not to interfere with mailx/nail."
+ dosym exim /usr/sbin/rsmtp
+ dosym exim /usr/sbin/rmail
+ if \[ ! -e /usr/lib/sendmail \];
+ then
+ dosym /usr/sbin/sendmail /usr/lib/sendmail
+ fi
+
+ if use mailwrapper
+ then
+ insinto /etc/mail
+ doins ${FILESDIR}/mailer.conf
+ else
+ dosym exim /usr/sbin/sendmail
+ fi
+
+ exeinto /usr/sbin
+ for i in exicyclog exim_dbmbuild exim_dumpdb exim_fixdb exim_lock \
+ exim_tidydb exinext exiwhat exigrep eximstats exiqsumm exiqgrep \
+ convert4r3 convert4r4 exipick
+ do
+ doexe $i
+ done
+
+ dodoc ${S}/doc/*
+ doman ${S}/doc/exim.8
+
+ # conf files
+ insinto /etc/exim
+ newins ${S}/src/configure.default.orig exim.conf.dist
+ if use exiscan-acl; then
+ newins ${S}/src/configure.default exim.conf.exiscan-acl
+ fi
+ doins ${FILESDIR}/system_filter.exim
+ doins ${FILESDIR}/auth_conf.sub
+ if use exiscan; then
+ newins ${S}/src/configure.default exim.conf.exiscan
+ doins ${FILESDIR}/exiscan.conf
+ fi
+
+ if use pam
+ then
+ # INSTALL a pam.d file for SMTP AUTH that works with gentoo's pam
+ insinto /etc/pam.d
+ newins ${FILESDIR}/pam.d-exim exim
+ fi
+
+ exeinto /etc/init.d
+ newexe ${FILESDIR}/exim.rc6 exim
+
+ insinto /etc/conf.d
+ newins ${FILESDIR}/exim.confd exim
+
+ DIROPTIONS="--mode=0750 --owner=mail --group=mail"
+ dodir /var/log/${PN}
+}
+
+
+pkg_postinst() {
+ einfo "/etc/exim/system_filter.exim is a sample system_filter."
+ einfo "/etc/exim/auth_conf.sub contains the configuration sub for using smtp auth."
+ einfo "Please create /etc/exim/exim.conf from /etc/exim/exim.conf.dist."
+
+ if ! use mailwrapper && [[ -e /etc/mailer.conf ]]
+ then
+ einfo
+ einfo "Since you emerged $PN without mailwrapper in USE,"
+ einfo "you probably want to 'emerge -C mailwrapper' now."
+ einfo
+ fi
+}
diff --git a/mail-mta/exim/exim-4.62-r2.ebuild b/mail-mta/exim/exim-4.62-r2.ebuild
new file mode 100644
index 00000000..74b068b9
--- /dev/null
+++ b/mail-mta/exim/exim-4.62-r2.ebuild
@@ -0,0 +1,321 @@
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/mail-mta/exim/exim-4.62.ebuild,v 1.4 2006/10/11 08:40:33 corsair Exp $
+
+inherit eutils
+
+IUSE="tcpd ssl postgres mysql ldap pam exiscan-acl mailwrapper lmtp ipv6 sasl dnsdb perl mbx X exiscan nis syslog spf srs domainkeys gnutls sqlite dovecot mbox"
+
+DESCRIPTION="A highly configurable, drop-in replacement for sendmail"
+SRC_URI="ftp://ftp.exim.org/pub/exim/exim4/${P}.tar.bz2 mirror://gentoo/exiscan.conf"
+HOMEPAGE="http://www.exim.org/"
+
+SLOT="0"
+LICENSE="GPL-2"
+KEYWORDS="~alpha ~amd64 ~hppa ~ia64 ~ppc ppc64 sparc x86"
+
+PROVIDE="virtual/mta"
+DEPEND=">=sys-apps/sed-4.0.5
+ perl? ( sys-devel/libperl )
+ >=sys-libs/db-3.2
+ pam? ( >=sys-libs/pam-0.75 )
+ tcpd? ( sys-apps/tcp-wrappers )
+ ssl? ( >=dev-libs/openssl-0.9.6 )
+ gnutls? ( net-libs/gnutls )
+ ldap? ( >=net-nds/openldap-2.0.7 )
+ mysql? ( >=dev-db/mysql-3.23.28 )
+ postgres? ( >=dev-db/postgresql-7 )
+ sasl? ( >=dev-libs/cyrus-sasl-2.1.14 )
+ spf? ( >=mail-filter/libspf2-1.2.5-r1 )
+ srs? ( mail-filter/libsrs_alt )
+ domainkeys? ( mail-filter/libdomainkeys )
+ X? ( || ( ( x11-proto/xproto
+ x11-libs/libX11
+ x11-libs/libXmu
+ x11-libs/libXt
+ x11-libs/libXaw )
+ virtual/x11 )
+ )
+ sqlite? ( dev-db/sqlite )
+ dovecot? ( net-mail/dovecot )"
+ # added X check for #57206
+RDEPEND="${DEPEND}
+ mailwrapper? ( >=net-mail/mailwrapper-0.2 )
+ !mailwrapper? ( !virtual/mta )
+ >=net-mail/mailbase-0.00-r5"
+
+src_unpack() {
+ unpack ${A}
+ cd ${S}
+
+ local myconf
+
+ epatch ${FILESDIR}/exim-4.14-tail.patch
+ epatch ${FILESDIR}/exim-4.43-r2-localscan_dlopen.patch
+
+ if use dovecot; then
+ einfo "Patching for SMTP Dovecot Auth"
+ einfo "See http://www.exim.org/eximwiki/AuthenticatedSmtpUsingDovecot"
+ epatch ${FILESDIR}/exim-4.43-SmtpUsingDovecot.patch
+ fi
+
+ if ! use mbox; then
+ einfo "Patching maildir support into exim.conf"
+ epatch ${FILESDIR}/exim-4.20-maildir.patch
+ fi
+
+ sed -i "/SYSTEM_ALIASES_FILE/ s'SYSTEM_ALIASES_FILE'/etc/mail/aliases'" ${S}/src/configure.default
+ cp ${S}/src/configure.default ${S}/src/configure.default.orig
+
+ # Includes Typo fix for bug 47106
+ sed -e "48i\CFLAGS=${CFLAGS}" \
+ -e "s:# AUTH_CRAM_MD5=yes:AUTH_CRAM_MD5=yes:" \
+ -e "s:# AUTH_PLAINTEXT=yes:AUTH_PLAINTEXT=yes:" \
+ -e "s:BIN_DIRECTORY=/usr/exim/bin:BIN_DIRECTORY=/usr/sbin:" \
+ -e "s:COMPRESS_COMMAND=/usr/bin/gzip:COMPRESS_COMMAND=/bin/gzip:" \
+ -e "s:ZCAT_COMMAND=/usr/bin/zcat:ZCAT_COMMAND=/bin/zcat:" \
+ -e "s:CONFIGURE_FILE=/usr/exim/configure:CONFIGURE_FILE=/etc/exim/exim.conf:" \
+ -e "s:EXIM_MONITOR=eximon.bin:# EXIM_MONITOR=eximon.bin:" \
+ -e "s:# INFO_DIRECTORY=/usr/local/info:INFO_DIRECTORY=/usr/share/info:" \
+ -e "s:# LOG_FILE_PATH=/var/log/exim_%slog:LOG_FILE_PATH=/var/log/exim/exim_%s.log:" \
+ -e "s:# PID_FILE_PATH=/var/lock/exim.pid:PID_FILE_PATH=/var/run/exim.pid:" \
+ -e "s:# SPOOL_DIRECTORY=/var/spool/exim:SPOOL_DIRECTORY=/var/spool/exim:" \
+ -e "s:# SUPPORT_MAILDIR=yes:SUPPORT_MAILDIR=yes:" \
+ -e "s:# SUPPORT_MAILSTORE=yes:SUPPORT_MAILSTORE=yes:" \
+ -e "s:EXIM_USER=:EXIM_USER=mail:" \
+ -e "s:# AUTH_SPA=yes:AUTH_SPA=yes:" \
+ -e "s:^ZCAT_COMMAND.*$:ZCAT_COMMAND=/bin/zcat:" \
+ -e "s:# LOOKUP_PASSWD=yes:LOOKUP_PASSWD=yes:" \
+ src/EDITME > Local/Makefile
+
+ # exiscan-acl is now integrated - enabled it when use-flag set
+ if use exiscan-acl; then
+ sed -i "s:# WITH_CONTENT_SCAN=yes:WITH_CONTENT_SCAN=yes:" Local/Makefile
+ sed -i "s:# WITH_OLD_DEMIME=yes:WITH_OLD_DEMIME=yes:" Local/Makefile
+ elif (use spf || use srs || use domainkeys) then
+ eerror SPF, SRS and DomainKeys support require exiscan-acl to be enabled, please add
+ eerror to your USE settings.
+ exit 1
+ fi
+ if use spf; then
+ myconf="${myconf} -lspf2"
+ sed -i "s:# EXPERIMENTAL_SPF=yes:EXPERIMENTAL_SPF=yes:" Local/Makefile
+ mycflags="${mycflags} -DEXPERIMENTAL_SPF"
+ fi
+ if use srs; then
+ myconf="${myconf} -lsrs_alt"
+ sed -i "s:# EXPERIMENTAL_SRS=yes:EXPERIMENTAL_SRS=yes:" Local/Makefile
+ fi
+
+ if use domainkeys; then
+ myconf="${myconf} -ldomainkeys"
+ echo "EXPERIMENTAL_DOMAINKEYS=yes" >> Local/Makefile
+ mycflags="${mycflags} -DEXPERIMENTAL_DOMAINKEYS"
+ fi
+
+ if use dovecot; then
+ sed -i "s:# AUTH_DOVECOT=yes:AUTH_DOVECOT=yes:" Local/Makefile
+ fi
+
+ cd Local
+ # enable optional exim_monitor support via X use flag bug #46778
+ if use X; then
+ einfo "Configuring eximon"
+ cp ../exim_monitor/EDITME eximon.conf
+ sed -i "s:# EXIM_MONITOR=eximon.bin:EXIM_MONITOR=eximon.bin:" Makefile
+ fi
+ #These next two should resolve 37964
+ if use perl; then
+ sed -i "s:# EXIM_PERL=perl.o:EXIM_PERL=perl.o:" Makefile
+ fi
+ # mbox useflag renamed, see bug 110741
+ if use mbx; then
+ sed -i "s:# SUPPORT_MBX=yes:SUPPORT_MBX=yes:" Makefile
+ fi
+ if use pam; then
+ sed -i "s:# \(SUPPORT_PAM=yes\):\1:" Makefile
+ myconf="${myconf} -lpam"
+ fi
+ if use sasl; then
+ sed -i "s:# CYRUS_SASLAUTHD_SOCKET=/var/state/saslauthd/mux:CYRUS_SASLAUTHD_SOCKET=/var/lib/sasl2/mux:" Makefile
+ sed -i "s:# AUTH_CYRUS_SASL=yes:AUTH_CYRUS_SASL=yes:" Makefile
+ myconf="${myconf} -lsasl2"
+ fi
+ if use tcpd; then
+ sed -i "s:# \(USE_TCP_WRAPPERS=yes\):\1:" Makefile
+ myconf="${myconf} -lwrap"
+ fi
+ if use lmtp; then
+ sed -i "s:# \(TRANSPORT_LMTP=yes\):\1:" Makefile
+ fi
+ if use ipv6; then
+ echo "HAVE_IPV6=YES" >> Makefile
+ #To fix bug 41196
+ echo "IPV6_USE_INET_PTON=yes" >> Makefile
+ fi
+
+ if [ -n "$myconf" ] ; then
+ echo "EXTRALIBS=${myconf} ${LDFLAGS}" >> Makefile
+ fi
+
+ cd ${S}
+ if use ssl; then
+ sed -i \
+ -e "s:# \(SUPPORT_TLS=yes\):\1:" Local/Makefile
+ if use gnutls; then
+ sed -i \
+ -e "s:# \(USE_GNUTLS=yes\):\1:" \
+ -e "s:# \(TLS_LIBS=-lgnutls -ltasn1 -lgcrypt\):\1:" Local/Makefile
+ else
+ sed -i \
+ -e "s:# \(TLS_LIBS=-lssl -lcrypto\):\1:" Local/Makefile
+ fi
+ fi
+
+ LOOKUP_INCLUDE=
+ LOOKUP_LIBS=
+
+ if use ldap; then
+ sed -i \
+ -e "s:# \(LOOKUP_LDAP=yes\):\1:" \
+ -e "s:# \(LDAP_LIB_TYPE=OPENLDAP2\):\1:" Local/Makefile
+ LOOKUP_INCLUDE="-I/usr/include/ldap"
+ LOOKUP_LIBS="-L/usr/lib -lldap -llber"
+ fi
+
+ if use mysql; then
+ sed -i "s:# LOOKUP_MYSQL=yes:LOOKUP_MYSQL=yes:" Local/Makefile
+ LOOKUP_INCLUDE="$LOOKUP_INCLUDE -I/usr/include/mysql"
+ LOOKUP_LIBS="$LOOKUP_LIBS -L/usr/lib -lmysqlclient"
+ fi
+
+ if use postgres; then
+ sed -i "s:# LOOKUP_PGSQL=yes:LOOKUP_PGSQL=yes:" Local/Makefile
+ LOOKUP_INCLUDE="$LOOKUP_INCLUDE -I/usr/include/postgresql"
+ LOOKUP_LIBS="$LOOKUP_LIBS -lpq"
+ fi
+ if use sqlite; then
+ sed -i "s:# LOOKUP_SQLITE=yes: LOOKUP_SQLITE=yes:" Local/Makefile
+ LOOKUP_INCLUDE="$LOOKUP_INCLUDE -I/usr/include/sqlite"
+ LOOKUP_LIBS="$LOOKUP_LIBS -lsqlite3"
+ fi
+ if [ -n "$LOOKUP_INCLUDE" ]; then
+ sed -i "s:# LOOKUP_INCLUDE=-I /usr/local/ldap/include -I /usr/local/mysql/include -I /usr/local/pgsql/include:LOOKUP_INCLUDE=$LOOKUP_INCLUDE:" \
+ Local/Makefile
+ fi
+
+ if [ -n "$LOOKUP_LIBS" ]; then
+ sed -i "s:# LOOKUP_LIBS=-L/usr/local/lib -lldap -llber -lmysqlclient -lpq -lgds -lsqlite3:LOOKUP_LIBS=$LOOKUP_LIBS:" \
+ Local/Makefile
+ fi
+
+
+ cat Makefile | sed -e 's/^buildname=.*/buildname=exim-gentoo/g' > Makefile.gentoo && mv -f Makefile.gentoo Makefile
+
+ sed -i "s:# LOOKUP_DSEARCH=yes:LOOKUP_DSEARCH=yes:" Local/Makefile
+
+ if use dnsdb; then
+ sed -i "s:# LOOKUP_DNSDB=yes:LOOKUP_DNSDB=yes:" Local/Makefile
+ fi
+ sed -i "s:# LOOKUP_CDB=yes:LOOKUP_CDB=yes:" Local/Makefile
+
+ if use nis; then
+ sed -i "s:# LOOKUP_NIS=yes:LOOKUP_NIS=yes:" Local/Makefile
+ sed -i "s:# LOOKUP_NISPLUS=yes:LOOKUP_NISPLUS=yes:" Local/Makefile
+ fi
+ if use syslog; then
+ sed -i "s:LOG_FILE_PATH=/var/log/exim/exim_%s.log:LOG_FILE_PATH=syslog:" Local/Makefile
+ fi
+# Use the "native" interface to the DBM library
+ echo "USE_DB=yes" >> ${S}/Local/Makefile
+}
+
+src_compile() {
+ make || die "make failed"
+}
+
+
+src_install () {
+ cd ${S}/build-exim-gentoo
+ exeinto /usr/sbin
+ doexe exim
+ if use X;then
+ doexe eximon.bin
+ doexe eximon
+ fi
+ fperms 4755 /usr/sbin/exim
+
+ dodir /usr/bin /usr/sbin /usr/lib
+ dosym ../sbin/exim /usr/bin/mailq
+ dosym ../sbin/exim /usr/bin/newaliases
+ einfo "The Exim ebuild will no longer touch /usr/bin/mail, so as not to interfere with mailx/nail."
+ dosym exim /usr/sbin/rsmtp
+ dosym exim /usr/sbin/rmail
+ if \[ ! -e /usr/lib/sendmail \];
+ then
+ dosym /usr/sbin/sendmail /usr/lib/sendmail
+ fi
+
+ if use mailwrapper
+ then
+ insinto /etc/mail
+ doins ${FILESDIR}/mailer.conf
+ else
+ dosym exim /usr/sbin/sendmail
+ fi
+
+ exeinto /usr/sbin
+ for i in exicyclog exim_dbmbuild exim_dumpdb exim_fixdb exim_lock \
+ exim_tidydb exinext exiwhat exigrep eximstats exiqsumm exiqgrep \
+ convert4r3 convert4r4 exipick
+ do
+ doexe $i
+ done
+
+ dodoc ${S}/doc/*
+ doman ${S}/doc/exim.8
+
+ # conf files
+ insinto /etc/exim
+ newins ${S}/src/configure.default.orig exim.conf.dist
+ if use exiscan-acl; then
+ newins ${S}/src/configure.default exim.conf.exiscan-acl
+ fi
+ doins ${FILESDIR}/system_filter.exim
+ doins ${FILESDIR}/auth_conf.sub
+ if use exiscan; then
+ newins ${S}/src/configure.default exim.conf.exiscan
+ doins ${FILESDIR}/exiscan.conf
+ fi
+
+ if use pam
+ then
+ # INSTALL a pam.d file for SMTP AUTH that works with gentoo's pam
+ insinto /etc/pam.d
+ newins ${FILESDIR}/pam.d-exim exim
+ fi
+
+ exeinto /etc/init.d
+ newexe ${FILESDIR}/exim.rc6 exim
+
+ insinto /etc/conf.d
+ newins ${FILESDIR}/exim.confd exim
+
+ DIROPTIONS="--mode=0750 --owner=mail --group=mail"
+ dodir /var/log/${PN}
+}
+
+
+pkg_postinst() {
+ einfo "/etc/exim/system_filter.exim is a sample system_filter."
+ einfo "/etc/exim/auth_conf.sub contains the configuration sub for using smtp auth."
+ einfo "Please create /etc/exim/exim.conf from /etc/exim/exim.conf.dist."
+
+ if ! use mailwrapper && [[ -e /etc/mailer.conf ]]
+ then
+ einfo
+ einfo "Since you emerged $PN without mailwrapper in USE,"
+ einfo "you probably want to 'emerge -C mailwrapper' now."
+ einfo
+ fi
+}
diff --git a/mail-mta/exim/files/digest-exim-4.62-r1 b/mail-mta/exim/files/digest-exim-4.62-r1
new file mode 100644
index 00000000..0ff59235
--- /dev/null
+++ b/mail-mta/exim/files/digest-exim-4.62-r1
@@ -0,0 +1,6 @@
+MD5 a8efc92427192fd3b7b5e71decc8cc31 exim-4.62.tar.bz2 1577729
+RMD160 9553b758e3bfd3d12027262b6211e37ad3259252 exim-4.62.tar.bz2 1577729
+SHA256 b5438894807c560a7933af36d10b2951f890aece9bff14c95fe2b91b0398629b exim-4.62.tar.bz2 1577729
+MD5 eb249c90af3ab11e5a4d307e184a75ac exiscan.conf 22113
+RMD160 e52b77f656b3ba2105e833075d1368f41e414d64 exiscan.conf 22113
+SHA256 f8cc731d3225a902461e05c0997df23bfd231ea8d5bf33a9aba5783bc6e0c964 exiscan.conf 22113
diff --git a/mail-mta/exim/files/digest-exim-4.62-r2 b/mail-mta/exim/files/digest-exim-4.62-r2
new file mode 100644
index 00000000..0ff59235
--- /dev/null
+++ b/mail-mta/exim/files/digest-exim-4.62-r2
@@ -0,0 +1,6 @@
+MD5 a8efc92427192fd3b7b5e71decc8cc31 exim-4.62.tar.bz2 1577729
+RMD160 9553b758e3bfd3d12027262b6211e37ad3259252 exim-4.62.tar.bz2 1577729
+SHA256 b5438894807c560a7933af36d10b2951f890aece9bff14c95fe2b91b0398629b exim-4.62.tar.bz2 1577729
+MD5 eb249c90af3ab11e5a4d307e184a75ac exiscan.conf 22113
+RMD160 e52b77f656b3ba2105e833075d1368f41e414d64 exiscan.conf 22113
+SHA256 f8cc731d3225a902461e05c0997df23bfd231ea8d5bf33a9aba5783bc6e0c964 exiscan.conf 22113
diff --git a/mail-mta/exim/files/exim-4.14-tail.patch b/mail-mta/exim/files/exim-4.14-tail.patch
new file mode 100644
index 00000000..481dca9b
--- /dev/null
+++ b/mail-mta/exim/files/exim-4.14-tail.patch
@@ -0,0 +1,11 @@
+--- scripts/Configure-config.h.orig 2003-07-17 18:01:19.000000000 -0400
++++ scripts/Configure-config.h 2003-07-17 18:01:25.000000000 -0400
+@@ -41,7 +41,7 @@
+
+ # Double-check that config.h is complete.
+
+-if [ "`tail -1 config.h`" != "/* End of config.h */" ] ; then
++if [ "`tail -n 1 config.h`" != "/* End of config.h */" ] ; then
+ echo "*** config.h appears to be incomplete"
+ echo "*** unexpected failure in buildconfig program"
+ exit 1
diff --git a/mail-mta/exim/files/exim-4.20-maildir.patch b/mail-mta/exim/files/exim-4.20-maildir.patch
new file mode 100644
index 00000000..3cb198d5
--- /dev/null
+++ b/mail-mta/exim/files/exim-4.20-maildir.patch
@@ -0,0 +1,14 @@
+diff -urN ./exim-4.20.orig/src/configure.default exim-4.20/src/configure.default
+--- ./exim-4.20.orig/src/configure.default 2003-06-27 16:48:22.000000000 -0700
++++ exim-4.20/src/configure.default 2003-06-27 16:52:20.000000000 -0700
+@@ -451,7 +451,9 @@
+
+ local_delivery:
+ driver = appendfile
+- file = /var/mail/$local_part
++# file = /var/mail/$local_part
++ directory = /home/$local_part/.maildir
++ maildir_format
+ delivery_date_add
+ envelope_to_add
+ return_path_add
diff --git a/mail-mta/exim/files/exim-4.43-SmtpUsingDovecot.patch b/mail-mta/exim/files/exim-4.43-SmtpUsingDovecot.patch
new file mode 100644
index 00000000..c51971cc
--- /dev/null
+++ b/mail-mta/exim/files/exim-4.43-SmtpUsingDovecot.patch
@@ -0,0 +1,384 @@
+diff -urdpNx build-Linux-i386 -x Local exim-4.43.vanilla/scripts/MakeLinks exim-4.43/scripts/MakeLinks
+--- exim-4.43.vanilla/scripts/MakeLinks 2004-10-05 12:32:08.000000000 +0400
++++ exim-4.43/scripts/MakeLinks 2004-12-09 15:38:46.000000000 +0300
+@@ -167,6 +167,8 @@ ln -s ../../src/auths/auth-spa.h
+ ln -s ../../src/auths/sha1.c sha1.c
+ ln -s ../../src/auths/spa.c spa.c
+ ln -s ../../src/auths/spa.h spa.h
++ln -s ../../src/auths/dovecot.c dovecot.c
++ln -s ../../src/auths/dovecot.h dovecot.h
+ cd ..
+
+ # The basic source files for Exim and utilities. NB local_scan.h gets linked,
+diff -urdpNx build-Linux-i386 -x Local exim-4.43.vanilla/src/auths/dovecot.c exim-4.43/src/auths/dovecot.c
+--- exim-4.43.vanilla/src/auths/dovecot.c 1970-01-01 03:00:00.000000000 +0300
++++ exim-4.43/src/auths/dovecot.c 2004-12-09 15:38:46.000000000 +0300
+@@ -0,0 +1,247 @@
++/*
++ * Copyright (c) 2004 Andrey Panin <pazke@donpac.ru>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published
++ * by the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ */
++
++#include "../exim.h"
++#include "dovecot.h"
++
++#define VERSION_MAJOR 1
++#define VERSION_MINOR 0
++
++/* Options specific to the authentication mechanism. */
++optionlist auth_dovecot_options[] = {
++ {
++ "server_socket",
++ opt_stringptr,
++ (void *)(offsetof(auth_dovecot_options_block, server_socket))
++ },
++};
++
++/* Size of the options list. An extern variable has to be used so that its
++address can appear in the tables drtables.c. */
++int auth_dovecot_options_count =
++ sizeof(auth_dovecot_options) / sizeof(optionlist);
++
++/* Default private options block for the authentication method. */
++auth_dovecot_options_block auth_dovecot_option_defaults = {
++ NULL, /* server_socket */
++};
++
++/*************************************************
++ * Initialization entry point *
++ *************************************************/
++
++/* Called for each instance, after its options have been read, to
++enable consistency checks to be done, or anything else that needs
++to be set up. */
++void auth_dovecot_init(auth_instance *ablock)
++{
++ auth_dovecot_options_block *ob =
++ (auth_dovecot_options_block *)(ablock->options_block);
++
++ if (ablock->public_name == NULL)
++ ablock->public_name = ablock->name;
++ if (ob->server_socket != NULL)
++ ablock->server = TRUE;
++ ablock->client = FALSE;
++}
++
++static int strcut(char *str, char **ptrs, int nptrs)
++{
++ char *tmp = str;
++ int n;
++
++ for (n = 0; n < nptrs; n++)
++ ptrs[n] = NULL;
++ n = 1;
++
++ while (*str) {
++ if (*str == '\t') {
++ if (n <= nptrs) {
++ *ptrs++ = tmp;
++ tmp = str + 1;
++ *str = 0;
++ }
++ n++;
++ }
++ str++;
++ }
++
++ if (n < nptrs)
++ *ptrs = tmp;
++
++ return n;
++}
++
++#define CHECK_COMMAND(str, arg_min, arg_max) do { \
++ if (strcasecmp((str), args[0]) != 0) \
++ goto out; \
++ if (nargs - 1 < (arg_min)) \
++ goto out; \
++ if (nargs - 1 > (arg_max)) \
++ goto out; \
++} while (0)
++
++#define OUT(msg) do { \
++ auth_defer_msg = (msg); \
++ goto out; \
++} while(0)
++
++/*************************************************
++ * Server entry point *
++ *************************************************/
++
++int auth_dovecot_server(auth_instance *ablock, uschar *data)
++{
++ auth_dovecot_options_block *ob =
++ (auth_dovecot_options_block *)(ablock->options_block);
++ struct sockaddr_un sa;
++ char buffer[4096];
++ char *args[8];
++ int nargs, tmp;
++ int cuid = 0, cont = 1, found = 0, fd, ret = DEFER;
++ FILE *f;
++
++ memset(&sa, 0, sizeof(sa));
++ sa.sun_family = AF_UNIX;
++ if (strncpy(sa.sun_path, ob->server_socket, sizeof(sa.sun_path)) < 0) {
++ auth_defer_msg = "authentication socket path too long";
++ return DEFER;
++ }
++
++ auth_defer_msg = "authentication socket connection error";
++
++ fd = socket(PF_UNIX, SOCK_STREAM, 0);
++ if (fd < 0)
++ return DEFER;
++
++ if (connect(fd, (struct sockaddr *) &sa, sizeof(sa)) < 0)
++ goto out;
++
++ f = fdopen(fd, "a+");
++ if (f == NULL)
++ goto out;
++
++ auth_defer_msg = "authentication socket protocol error";
++
++ while (cont) {
++ if (fgets(buffer, sizeof(buffer), f) == NULL)
++ OUT("authentication socket read error or premature eof");
++
++ buffer[strlen(buffer) - 1] = 0;
++ nargs = strcut(buffer, args, sizeof(args) / sizeof(args[0]));
++
++ switch (toupper(*args[0])) {
++ case 'C':
++ CHECK_COMMAND("CUID", 1, 1);
++ cuid = atoi(args[1]);
++ break;
++
++ case 'D':
++ CHECK_COMMAND("DONE", 0, 0);
++ cont = 0;
++ break;
++
++ case 'M':
++ CHECK_COMMAND("MECH", 1, INT_MAX);
++ if (!strcasecmp(args[1], ablock->public_name))
++ found = 1;
++ break;
++
++ case 'S':
++ CHECK_COMMAND("SPID", 1, 1);
++ break;
++
++ case 'V':
++ CHECK_COMMAND("VERSION", 2, 2);
++ if (atoi(args[1]) != VERSION_MAJOR)
++ OUT("authentication socket protocol version mismatch");
++ break;
++
++ default:
++ goto out;
++ }
++ }
++
++ if (!found)
++ goto out;
++
++ fprintf(f, "VERSION\t%d\t%d\r\nSERVICE\tSMTP\r\nCPID\t%d\r\n"
++ "AUTH\t%d\t%s\trip=%s\tlip=%s\tresp=%s\r\n",
++ VERSION_MAJOR, VERSION_MINOR, getpid(), cuid,
++ ablock->public_name, sender_host_address, interface_address,
++ data ? (char *) data : "");
++
++ while (1) {
++ if (fgets(buffer, sizeof(buffer), f) == NULL) {
++ auth_defer_msg = "authentication socket read error or premature eof";
++ goto out;
++ }
++
++ buffer[strlen(buffer) - 1] = 0;
++ nargs = strcut(buffer, args, sizeof(args) / sizeof(args[0]));
++
++ if (atoi(args[1]) != cuid)
++ OUT("authentication socket connection id mismatch");
++
++ switch (toupper(*args[0])) {
++ case 'C':
++ CHECK_COMMAND("CONT", 1, 2);
++
++ tmp = auth_get_no64_data(&data, args[2]);
++ if (tmp != OK) {
++ ret = tmp;
++ goto out;
++ }
++
++ if (fprintf(f, "CONT\t%d\t%s\r\n", cuid, data) < 0)
++ OUT("authentication socket write error");
++
++ break;
++
++ case 'F':
++ CHECK_COMMAND("FAIL", 1, 2);
++
++ /* FIXME: add proper response handling */
++ if (args[2]) {
++ char *p = strchr(args[2], '=');
++ if (p) {
++ ++p;
++ expand_nstring[1] = p;
++ expand_nlength[1] = strlen(p);
++ expand_nmax = 1;
++ }
++ }
++
++ ret = FAIL;
++ goto out;
++
++ case 'O':
++ CHECK_COMMAND("OK", 2, 2);
++ {
++ /* FIXME: add proper response handling */
++ char *p = strchr(args[2], '=');
++ if (!p)
++ OUT("authentication socket protocol error, username missing");
++
++ p++;
++ expand_nstring[1] = p;
++ expand_nlength[1] = strlen(p);
++ expand_nmax = 1;
++ }
++ ret = OK;
++ /* fallthrough */
++
++ default:
++ goto out;
++ }
++ }
++
++out: close(fd);
++ return ret;
++}
+diff -urdpNx build-Linux-i386 -x Local exim-4.43.vanilla/src/auths/dovecot.h exim-4.43/src/auths/dovecot.h
+--- exim-4.43.vanilla/src/auths/dovecot.h 1970-01-01 03:00:00.000000000 +0300
++++ exim-4.43/src/auths/dovecot.h 2004-12-09 15:47:43.000000000 +0300
+@@ -0,0 +1,28 @@
++/*************************************************
++* Exim - an Internet mail transport agent *
++*************************************************/
++
++/* Copyright (c) University of Cambridge 1995 - 2003 */
++/* See the file NOTICE for conditions of use and distribution. */
++
++/* Private structure for the private options. */
++
++typedef struct {
++ uschar *server_socket;
++} auth_dovecot_options_block;
++
++/* Data for reading the private options. */
++
++extern optionlist auth_dovecot_options[];
++extern int auth_dovecot_options_count;
++
++/* Block containing default values. */
++
++extern auth_dovecot_options_block auth_dovecot_option_defaults;
++
++/* The entry points for the mechanism */
++
++extern void auth_dovecot_init(auth_instance *);
++extern int auth_dovecot_server(auth_instance *, uschar *);
++
++/* End of dovecot.h */
+diff -urdpNx build-Linux-i386 -x Local exim-4.43.vanilla/src/auths/Makefile exim-4.43/src/auths/Makefile
+--- exim-4.43.vanilla/src/auths/Makefile 2004-10-05 12:32:08.000000000 +0400
++++ exim-4.43/src/auths/Makefile 2004-12-09 15:46:44.000000000 +0300
+@@ -7,7 +7,7 @@
+
+ OBJ = b64encode.o b64decode.o call_pam.o call_pwcheck.o call_radius.o \
+ xtextencode.o xtextdecode.o get_data.o get_no64_data.o md5.o \
+- cram_md5.o cyrus_sasl.o plaintext.o pwcheck.o sha1.o auth-spa.o spa.o
++ cram_md5.o cyrus_sasl.o plaintext.o pwcheck.o sha1.o auth-spa.o spa.o dovecot.o
+
+ auths.a: $(OBJ)
+ /bin/rm -f auths.a
+@@ -37,4 +37,6 @@ cyrus_sasl.o: $(HDRS) cyrus_sasl.c cy
+ plaintext.o: $(HDRS) plaintext.c plaintext.h
+ spa.o: $(HDRS) spa.c spa.h
+
++dovecot.o: $(HDRS) dovecot.c dovecot.h
++
+ # End
+diff -urdpNx build-Linux-i386 -x Local exim-4.43.vanilla/src/config.h.defaults exim-4.43/src/config.h.defaults
+--- exim-4.43.vanilla/src/config.h.defaults 2004-10-05 12:32:08.000000000 +0400
++++ exim-4.43/src/config.h.defaults 2004-12-09 15:38:46.000000000 +0300
+@@ -20,6 +20,7 @@ in config.h unless some value is defined
+ #define AUTH_CYRUS_SASL
+ #define AUTH_PLAINTEXT
+ #define AUTH_SPA
++#define AUTH_DOVECOT
+
+ #define BIN_DIRECTORY
+
+diff -urdpNx build-Linux-i386 -x Local exim-4.43.vanilla/src/drtables.c exim-4.43/src/drtables.c
+--- exim-4.43.vanilla/src/drtables.c 2004-10-05 12:32:08.000000000 +0400
++++ exim-4.43/src/drtables.c 2004-12-09 15:47:14.000000000 +0300
+@@ -515,6 +515,10 @@ set to NULL for those that are not compi
+ #include "auths/spa.h"
+ #endif
+
++#ifdef AUTH_DOVECOT
++#include "auths/dovecot.h"
++#endif
++
+ auth_info auths_available[] = {
+
+ /* Checking by an expansion condition on plain text */
+@@ -571,6 +575,18 @@ auth_info auths_available[] = {
+ },
+ #endif
+
++#ifdef AUTH_DOVECOT
++ {
++ US"dovecot", /* lookup name */
++ auth_dovecot_options,
++ &auth_dovecot_options_count,
++ &auth_dovecot_option_defaults,
++ sizeof(auth_dovecot_options_block),
++ auth_dovecot_init, /* init function */
++ auth_dovecot_server, /* server function */
++ },
++#endif
++
+ { US"", NULL, NULL, NULL, 0, NULL, NULL, NULL }
+ };
+
+diff -urdpNx build-Linux-i386 -x Local exim-4.43.vanilla/src/EDITME exim-4.43/src/EDITME
+--- exim-4.43.vanilla/src/EDITME 2004-10-05 12:32:08.000000000 +0400
++++ exim-4.43/src/EDITME 2004-12-09 16:00:00.000000000 +0300
+@@ -410,6 +410,7 @@ FIXED_NEVER_USERS=root
+ # AUTH_CYRUS_SASL=yes
+ # AUTH_PLAINTEXT=yes
+ # AUTH_SPA=yes
++# AUTH_DOVECOT=yes
+
+
+ #------------------------------------------------------------------------------
+diff -urdpNx build-Linux-i386 -x Local exim-4.43.vanilla/src/exim.c exim-4.43/src/exim.c
+--- exim-4.43.vanilla/src/exim.c 2004-10-05 12:32:08.000000000 +0400
++++ exim-4.43/src/exim.c 2004-12-09 15:38:46.000000000 +0300
+@@ -895,6 +895,10 @@ fprintf(f, "Authenticators:");
+ #ifdef AUTH_SPA
+ fprintf(f, " spa");
+ #endif
++#ifdef AUTH_DOVECOT
++ fprintf(f, " dovecot");
++#endif
++
+ fprintf(f, "\n");
+
+ fprintf(f, "Routers:");
+
diff --git a/mail-mta/exim/files/exim-4.43-SmtpUsingDovecot.patch3 b/mail-mta/exim/files/exim-4.43-SmtpUsingDovecot.patch3
new file mode 100644
index 00000000..bc7d0b06
--- /dev/null
+++ b/mail-mta/exim/files/exim-4.43-SmtpUsingDovecot.patch3
@@ -0,0 +1,384 @@
+diff -urdpNx build-Linux-i386 -x Local exim-4.43.vanilla/scripts/MakeLinks exim-4.43/scripts/MakeLinks
+--- exim-4.43.vanilla/scripts/MakeLinks 2004-10-05 12:32:08.000000000 +0400
++++ exim-4.43/scripts/MakeLinks 2004-12-09 15:38:46.000000000 +0300
+ <at> <at> -167,6 +167,8 <at> <at> ln -s ../../src/auths/auth-spa.h
+ ln -s ../../src/auths/sha1.c sha1.c
+ ln -s ../../src/auths/spa.c spa.c
+ ln -s ../../src/auths/spa.h spa.h
++ln -s ../../src/auths/dovecot.c dovecot.c
++ln -s ../../src/auths/dovecot.h dovecot.h
+ cd ..
+
+ # The basic source files for Exim and utilities. NB local_scan.h gets linked,
+diff -urdpNx build-Linux-i386 -x Local exim-4.43.vanilla/src/auths/dovecot.c exim-4.43/src/auths/dovecot.c
+--- exim-4.43.vanilla/src/auths/dovecot.c 1970-01-01 03:00:00.000000000 +0300
++++ exim-4.43/src/auths/dovecot.c 2004-12-09 15:38:46.000000000 +0300
+ <at> <at> -0,0 +1,247 <at> <at>
++/*
++ * Copyright (c) 2004 Andrey Panin <pazke <at> donpac.ru>
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published
++ * by the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ */
++
++#include "../exim.h"
++#include "dovecot.h"
++
++#define VERSION_MAJOR 1
++#define VERSION_MINOR 0
++
++/* Options specific to the authentication mechanism. */
++optionlist auth_dovecot_options[] = {
++ {
++ "server_socket",
++ opt_stringptr,
++ (void *)(offsetof(auth_dovecot_options_block, server_socket))
++ },
++};
++
++/* Size of the options list. An extern variable has to be used so that its
++address can appear in the tables drtables.c. */
++int auth_dovecot_options_count =
++ sizeof(auth_dovecot_options) / sizeof(optionlist);
++
++/* Default private options block for the authentication method. */
++auth_dovecot_options_block auth_dovecot_option_defaults = {
++ NULL, /* server_socket */
++};
++
++/*************************************************
++ * Initialization entry point *
++ *************************************************/
++
++/* Called for each instance, after its options have been read, to
++enable consistency checks to be done, or anything else that needs
++to be set up. */
++void auth_dovecot_init(auth_instance *ablock)
++{
++ auth_dovecot_options_block *ob =
++ (auth_dovecot_options_block *)(ablock->options_block);
++
++ if (ablock->public_name == NULL)
++ ablock->public_name = ablock->name;
++ if (ob->server_socket != NULL)
++ ablock->server = TRUE;
++ ablock->client = FALSE;
++}
++
++static int strcut(char *str, char **ptrs, int nptrs)
++{
++ char *tmp = str;
++ int n;
++
++ for (n = 0; n < nptrs; n++)
++ ptrs[n] = NULL;
++ n = 1;
++
++ while (*str) {
++ if (*str == '\t') {
++ if (n <= nptrs) {
++ *ptrs++ = tmp;
++ tmp = str + 1;
++ *str = 0;
++ }
++ n++;
++ }
++ str++;
++ }
++
++ if (n < nptrs)
++ *ptrs = tmp;
++
++ return n;
++}
++
++#define CHECK_COMMAND(str, arg_min, arg_max) do { \
++ if (strcasecmp((str), args[0]) != 0) \
++ goto out; \
++ if (nargs - 1 < (arg_min)) \
++ goto out; \
++ if (nargs - 1 > (arg_max)) \
++ goto out; \
++} while (0)
++
++#define OUT(msg) do { \
++ auth_defer_msg = (msg); \
++ goto out; \
++} while(0)
++
++/*************************************************
++ * Server entry point *
++ *************************************************/
++
++int auth_dovecot_server(auth_instance *ablock, uschar *data)
++{
++ auth_dovecot_options_block *ob =
++ (auth_dovecot_options_block *)(ablock->options_block);
++ struct sockaddr_un sa;
++ char buffer[4096];
++ char *args[8];
++ int nargs, tmp;
++ int cuid = 0, cont = 1, found = 0, fd, ret = DEFER;
++ FILE *f;
++
++ memset(&sa, 0, sizeof(sa));
++ sa.sun_family = AF_UNIX;
++ if (strncpy(sa.sun_path, ob->server_socket, sizeof(sa.sun_path)) < 0) {
++ auth_defer_msg = "authentication socket path too long";
++ return DEFER;
++ }
++
++ auth_defer_msg = "authentication socket connection error";
++
++ fd = socket(PF_UNIX, SOCK_STREAM, 0);
++ if (fd < 0)
++ return DEFER;
++
++ if (connect(fd, (struct sockaddr *) &sa, sizeof(sa)) < 0)
++ goto out;
++
++ f = fdopen(fd, "a+");
++ if (f == NULL)
++ goto out;
++
++ auth_defer_msg = "authentication socket protocol error";
++
++ while (cont) {
++ if (fgets(buffer, sizeof(buffer), f) == NULL)
++ OUT("authentication socket read error or premature eof");
++
++ buffer[strlen(buffer) - 1] = 0;
++ nargs = strcut(buffer, args, sizeof(args) / sizeof(args[0]));
++
++ switch (toupper(*args[0])) {
++ case 'C':
++ CHECK_COMMAND("CUID", 1, 1);
++ cuid = atoi(args[1]);
++ break;
++
++ case 'D':
++ CHECK_COMMAND("DONE", 0, 0);
++ cont = 0;
++ break;
++
++ case 'M':
++ CHECK_COMMAND("MECH", 1, INT_MAX);
++ if (!strcasecmp(args[1], ablock->public_name))
++ found = 1;
++ break;
++
++ case 'S':
++ CHECK_COMMAND("SPID", 1, 1);
++ break;
++
++ case 'V':
++ CHECK_COMMAND("VERSION", 2, 2);
++ if (atoi(args[1]) != VERSION_MAJOR)
++ OUT("authentication socket protocol version mismatch");
++ break;
++
++ default:
++ goto out;
++ }
++ }
++
++ if (!found)
++ goto out;
++
++ fprintf(f, "VERSION\t%d\t%d\r\nSERVICE\tSMTP\r\nCPID\t%d\r\n"
++ "AUTH\t%d\t%s\trip=%s\tlip=%s\tresp=%s\r\n",
++ VERSION_MAJOR, VERSION_MINOR, getpid(), cuid,
++ ablock->public_name, sender_host_address, interface_address,
++ data ? (char *) data : "");
++
++ while (1) {
++ if (fgets(buffer, sizeof(buffer), f) == NULL) {
++ auth_defer_msg = "authentication socket read error or premature eof";
++ goto out;
++ }
++
++ buffer[strlen(buffer) - 1] = 0;
++ nargs = strcut(buffer, args, sizeof(args) / sizeof(args[0]));
++
++ if (atoi(args[1]) != cuid)
++ OUT("authentication socket connection id mismatch");
++
++ switch (toupper(*args[0])) {
++ case 'C':
++ CHECK_COMMAND("CONT", 1, 2);
++
++ tmp = auth_get_no64_data(&data, args[2]);
++ if (tmp != OK) {
++ ret = tmp;
++ goto out;
++ }
++
++ if (fprintf(f, "CONT\t%d\t%s\r\n", cuid, data) < 0)
++ OUT("authentication socket write error");
++
++ break;
++
++ case 'F':
++ CHECK_COMMAND("FAIL", 1, 2);
++
++ /* FIXME: add proper response handling */
++ if (args[2]) {
++ char *p = strchr(args[2], '=');
++ if (p) {
++ ++p;
++ expand_nstring[1] = p;
++ expand_nlength[1] = strlen(p);
++ expand_nmax = 1;
++ }
++ }
++
++ ret = FAIL;
++ goto out;
++
++ case 'O':
++ CHECK_COMMAND("OK", 2, 2);
++ {
++ /* FIXME: add proper response handling */
++ char *p = strchr(args[2], '=');
++ if (!p)
++ OUT("authentication socket protocol error, username missing");
++
++ p++;
++ expand_nstring[1] = p;
++ expand_nlength[1] = strlen(p);
++ expand_nmax = 1;
++ }
++ ret = OK;
++ /* fallthrough */
++
++ default:
++ goto out;
++ }
++ }
++
++out: close(fd);
++ return ret;
++}
+diff -urdpNx build-Linux-i386 -x Local exim-4.43.vanilla/src/auths/dovecot.h exim-4.43/src/auths/dovecot.h
+--- exim-4.43.vanilla/src/auths/dovecot.h 1970-01-01 03:00:00.000000000 +0300
++++ exim-4.43/src/auths/dovecot.h 2004-12-09 15:47:43.000000000 +0300
+ <at> <at> -0,0 +1,28 <at> <at>
++/*************************************************
++* Exim - an Internet mail transport agent *
++*************************************************/
++
++/* Copyright (c) University of Cambridge 1995 - 2003 */
++/* See the file NOTICE for conditions of use and distribution. */
++
++/* Private structure for the private options. */
++
++typedef struct {
++ uschar *server_socket;
++} auth_dovecot_options_block;
++
++/* Data for reading the private options. */
++
++extern optionlist auth_dovecot_options[];
++extern int auth_dovecot_options_count;
++
++/* Block containing default values. */
++
++extern auth_dovecot_options_block auth_dovecot_option_defaults;
++
++/* The entry points for the mechanism */
++
++extern void auth_dovecot_init(auth_instance *);
++extern int auth_dovecot_server(auth_instance *, uschar *);
++
++/* End of dovecot.h */
+diff -urdpNx build-Linux-i386 -x Local exim-4.43.vanilla/src/auths/Makefile exim-4.43/src/auths/Makefile
+--- exim-4.43.vanilla/src/auths/Makefile 2004-10-05 12:32:08.000000000 +0400
++++ exim-4.43/src/auths/Makefile 2004-12-09 15:46:44.000000000 +0300
+ <at> <at> -7,7 +7,7 <at> <at>
+
+ OBJ = b64encode.o b64decode.o call_pam.o call_pwcheck.o call_radius.o \
+ xtextencode.o xtextdecode.o get_data.o get_no64_data.o md5.o \
+- cram_md5.o cyrus_sasl.o plaintext.o pwcheck.o sha1.o auth-spa.o spa.o
++ cram_md5.o cyrus_sasl.o plaintext.o pwcheck.o sha1.o auth-spa.o spa.o dovecot.o
+
+ auths.a: $(OBJ)
+ /bin/rm -f auths.a
+ <at> <at> -37,4 +37,6 <at> <at> cyrus_sasl.o: $(HDRS) cyrus_sasl.c cy
+ plaintext.o: $(HDRS) plaintext.c plaintext.h
+ spa.o: $(HDRS) spa.c spa.h
+
++dovecot.o: $(HDRS) dovecot.c dovecot.h
++
+ # End
+diff -urdpNx build-Linux-i386 -x Local exim-4.43.vanilla/src/config.h.defaults exim-4.43/src/config.h.defaults
+--- exim-4.43.vanilla/src/config.h.defaults 2004-10-05 12:32:08.000000000 +0400
++++ exim-4.43/src/config.h.defaults 2004-12-09 15:38:46.000000000 +0300
+ <at> <at> -20,6 +20,7 <at> <at> in config.h unless some value is defined
+ #define AUTH_CYRUS_SASL
+ #define AUTH_PLAINTEXT
+ #define AUTH_SPA
++#define AUTH_DOVECOT
+
+ #define BIN_DIRECTORY
+
+diff -urdpNx build-Linux-i386 -x Local exim-4.43.vanilla/src/drtables.c exim-4.43/src/drtables.c
+--- exim-4.43.vanilla/src/drtables.c 2004-10-05 12:32:08.000000000 +0400
++++ exim-4.43/src/drtables.c 2004-12-09 15:47:14.000000000 +0300
+ <at> <at> -515,6 +515,10 <at> <at> set to NULL for those that are not compi
+ #include "auths/spa.h"
+ #endif
+
++#ifdef AUTH_DOVECOT
++#include "auths/dovecot.h"
++#endif
++
+ auth_info auths_available[] = {
+
+ /* Checking by an expansion condition on plain text */
+ <at> <at> -571,6 +575,18 <at> <at> auth_info auths_available[] = {
+ },
+ #endif
+
++#ifdef AUTH_DOVECOT
++ {
++ US"dovecot", /* lookup name */
++ auth_dovecot_options,
++ &auth_dovecot_options_count,
++ &auth_dovecot_option_defaults,
++ sizeof(auth_dovecot_options_block),
++ auth_dovecot_init, /* init function */
++ auth_dovecot_server, /* server function */
++ },
++#endif
++
+ { US"", NULL, NULL, NULL, 0, NULL, NULL, NULL }
+ };
+
+diff -urdpNx build-Linux-i386 -x Local exim-4.43.vanilla/src/EDITME exim-4.43/src/EDITME
+--- exim-4.43.vanilla/src/EDITME 2004-10-05 12:32:08.000000000 +0400
++++ exim-4.43/src/EDITME 2004-12-09 16:00:00.000000000 +0300
+ <at> <at> -410,6 +410,7 <at> <at> FIXED_NEVER_USERS=root
+ # AUTH_CYRUS_SASL=yes
+ # AUTH_PLAINTEXT=yes
+ # AUTH_SPA=yes
++# AUTH_DOVECOT=yes
+
+
+ #------------------------------------------------------------------------------
+diff -urdpNx build-Linux-i386 -x Local exim-4.43.vanilla/src/exim.c exim-4.43/src/exim.c
+--- exim-4.43.vanilla/src/exim.c 2004-10-05 12:32:08.000000000 +0400
++++ exim-4.43/src/exim.c 2004-12-09 15:38:46.000000000 +0300
+ <at> <at> -895,6 +895,10 <at> <at> fprintf(f, "Authenticators:");
+ #ifdef AUTH_SPA
+ fprintf(f, " spa");
+ #endif
++#ifdef AUTH_DOVECOT
++ fprintf(f, " dovecot");
++#endif
++
+ fprintf(f, "\n");
+
+ fprintf(f, "Routers:");
+
diff --git a/mail-mta/exim/files/exim-4.43-r2-localscan_dlopen.patch b/mail-mta/exim/files/exim-4.43-r2-localscan_dlopen.patch
new file mode 100644
index 00000000..146606a1
--- /dev/null
+++ b/mail-mta/exim/files/exim-4.43-r2-localscan_dlopen.patch
@@ -0,0 +1,259 @@
+diff -Naur exim-4.32/src/EDITME exim-4.32-dlopen/src/EDITME
+--- src/EDITME 2004-04-15 08:27:01.000000000 +0000
++++ src/EDITME 2004-05-06 16:15:47.000000000 +0000
+@@ -505,6 +505,21 @@
+
+
+ #------------------------------------------------------------------------------
++# On systems which support dynamic loading of shared libraries, Exim can
++# load a local_scan function specified in its config file instead of having
++# to be recompiled with the desired local_scan function. For a full
++# description of the API to this function, see the Exim specification.
++
++DLOPEN_LOCAL_SCAN=yes
++
++# If you set DLOPEN_LOCAL_SCAN, then you need to include -rdynamic in the
++# linker flags. Without it, the loaded .so won't be able to access any
++# functions from exim.
++
++LFLAGS=-rdynamic -ldl
++
++
++#------------------------------------------------------------------------------
+ # The default distribution of Exim contains only the plain text form of the
+ # documentation. Other forms are available separately. If you want to install
+ # the documentation in "info" format, first fetch the Texinfo documentation
+diff -Naur exim-4.32/src/config.h.defaults exim-4.32-dlopen/src/config.h.defaults
+--- src/config.h.defaults 2004-04-15 08:27:01.000000000 +0000
++++ src/config.h.defaults 2004-05-06 16:16:30.000000000 +0000
+@@ -20,6 +20,8 @@
+ #define AUTH_PLAINTEXT
+ #define AUTH_SPA
+
++#define DLOPEN_LOCAL_SCAN
++
+ #define BIN_DIRECTORY
+
+ #define CONFIGURE_FILE
+diff -Naur exim-4.32/src/globals.c exim-4.32-dlopen/src/globals.c
+--- src/globals.c 2004-04-15 08:27:01.000000000 +0000
++++ src/globals.c 2004-05-06 16:17:07.000000000 +0000
+@@ -109,6 +109,10 @@
+ uschar *tls_verify_hosts = NULL;
+ #endif
+
++#ifdef DLOPEN_LOCAL_SCAN
++uschar *local_scan_path = NULL;
++#endif
++
+
+ /* Input-reading functions for messages, so we can use special ones for
+ incoming TCP/IP. The defaults use stdin. We never need these for any
+diff -Naur exim-4.32/src/globals.h exim-4.32-dlopen/src/globals.h
+--- src/globals.h 2004-04-15 08:27:01.000000000 +0000
++++ src/globals.h 2004-05-06 16:17:50.000000000 +0000
+@@ -73,6 +73,9 @@
+ extern uschar *tls_verify_hosts; /* Mandatory client verification */
+ #endif
+
++#ifdef DLOPEN_LOCAL_SCAN
++extern uschar *local_scan_path; /* Path to local_scan() library */
++#endif
+
+ /* Input-reading functions for messages, so we can use special ones for
+ incoming TCP/IP. */
+diff -Naur exim-4.32/src/local_scan.c exim-4.32-dlopen/src/local_scan.c
+--- src/local_scan.c 2004-04-15 08:27:01.000000000 +0000
++++ src/local_scan.c 2004-05-06 16:21:57.000000000 +0000
+@@ -5,60 +5,131 @@
+ /* Copyright (c) University of Cambridge 1995 - 2004 */
+ /* See the file NOTICE for conditions of use and distribution. */
+
++#include "exim.h"
+
+-/******************************************************************************
+-This file contains a template local_scan() function that just returns ACCEPT.
+-If you want to implement your own version, you should copy this file to, say
+-Local/local_scan.c, and edit the copy. To use your version instead of the
+-default, you must set
+-
+-LOCAL_SCAN_SOURCE=Local/local_scan.c
+-
+-in your Local/Makefile. This makes it easy to copy your version for use with
+-subsequent Exim releases.
+-
+-For a full description of the API to this function, see the Exim specification.
+-******************************************************************************/
+-
+-
+-/* This is the only Exim header that you should include. The effect of
+-including any other Exim header is not defined, and may change from release to
+-release. Use only the documented interface! */
+-
+-#include "local_scan.h"
+-
+-
+-/* This is a "do-nothing" version of a local_scan() function. The arguments
+-are:
+-
+- fd The file descriptor of the open -D file, which contains the
+- body of the message. The file is open for reading and
+- writing, but modifying it is dangerous and not recommended.
+-
+- return_text A pointer to an unsigned char* variable which you can set in
+- order to return a text string. It is initialized to NULL.
+-
+-The return values of this function are:
+-
+- LOCAL_SCAN_ACCEPT
+- The message is to be accepted. The return_text argument is
+- saved in $local_scan_data.
+-
+- LOCAL_SCAN_REJECT
+- The message is to be rejected. The returned text is used
+- in the rejection message.
+-
+- LOCAL_SCAN_TEMPREJECT
+- This specifies a temporary rejection. The returned text
+- is used in the rejection message.
+-*/
++#ifdef DLOPEN_LOCAL_SCAN
++#include <dlfcn.h>
++static int (*local_scan_fn)(int fd, uschar **return_text) = NULL;
++static int load_local_scan_library(void);
++#endif
+
+ int
+ local_scan(int fd, uschar **return_text)
+ {
+ fd = fd; /* Keep picky compilers happy */
+ return_text = return_text;
+-return LOCAL_SCAN_ACCEPT;
++#ifdef DLOPEN_LOCAL_SCAN
++/* local_scan_path is defined AND not the empty string */
++if (local_scan_path && *local_scan_path)
++ {
++ if (!local_scan_fn)
++ {
++ if (!load_local_scan_library())
++ {
++ char *base_msg , *error_msg , *final_msg ;
++ int final_length = -1 ;
++
++ base_msg=US"Local configuration error - local_scan() library failure\n";
++ error_msg = dlerror() ;
++
++ final_length = strlen(base_msg) + strlen(error_msg) + 1 ;
++ final_msg = (char*)malloc( final_length*sizeof(char) ) ;
++ *final_msg = '\0' ;
++
++ strcat( final_msg , base_msg ) ;
++ strcat( final_msg , error_msg ) ;
++
++ *return_text = final_msg ;
++ return LOCAL_SCAN_TEMPREJECT;
++ }
++ }
++ return local_scan_fn(fd, return_text);
++ }
++else
++#endif
++ return LOCAL_SCAN_ACCEPT;
++}
++
++#ifdef DLOPEN_LOCAL_SCAN
++
++static int load_local_scan_library(void)
++{
++/* No point in keeping local_scan_lib since we'll never dlclose() anyway */
++void *local_scan_lib = NULL;
++int (*local_scan_version_fn)(void);
++int vers_maj;
++int vers_min;
++
++local_scan_lib = dlopen(local_scan_path, RTLD_NOW);
++if (!local_scan_lib)
++ {
++ log_write(0, LOG_MAIN|LOG_REJECT, "local_scan() library open failed - "
++ "message temporarily rejected");
++ return FALSE;
++ }
++
++local_scan_version_fn = dlsym(local_scan_lib, "local_scan_version_major");
++if (!local_scan_version_fn)
++ {
++ dlclose(local_scan_lib);
++ log_write(0, LOG_MAIN|LOG_REJECT, "local_scan() library doesn't contain "
++ "local_scan_version_major() function - message temporarily rejected");
++ return FALSE;
++ }
++
++/* The major number is increased when the ABI is changed in a non
++ backward compatible way. */
++vers_maj = local_scan_version_fn();
++
++local_scan_version_fn = dlsym(local_scan_lib, "local_scan_version_minor");
++if (!local_scan_version_fn)
++ {
++ dlclose(local_scan_lib);
++ log_write(0, LOG_MAIN|LOG_REJECT, "local_scan() library doesn't contain "
++ "local_scan_version_minor() function - message temporarily rejected");
++ return FALSE;
++ }
++
++/* The minor number is increased each time a new feature is added (in a
++ way that doesn't break backward compatibility) -- Marc */
++vers_min = local_scan_version_fn();
++
++
++if (vers_maj != LOCAL_SCAN_ABI_VERSION_MAJOR)
++ {
++ dlclose(local_scan_lib);
++ local_scan_lib = NULL;
++ log_write(0, LOG_MAIN|LOG_REJECT, "local_scan() has an incompatible major"
++ "version number, you need to recompile your module for this version"
++ "of exim (The module was compiled for version %d.%d and this exim provides"
++ "ABI version %d.%d)", vers_maj, vers_min, LOCAL_SCAN_ABI_VERSION_MAJOR,
++ LOCAL_SCAN_ABI_VERSION_MINOR);
++ return FALSE;
++ }
++else if (vers_min > LOCAL_SCAN_ABI_VERSION_MINOR)
++ {
++ dlclose(local_scan_lib);
++ local_scan_lib = NULL;
++ log_write(0, LOG_MAIN|LOG_REJECT, "local_scan() has an incompatible minor"
++ "version number, you need to recompile your module for this version"
++ "of exim (The module was compiled for version %d.%d and this exim provides"
++ "ABI version %d.%d)", vers_maj, vers_min, LOCAL_SCAN_ABI_VERSION_MAJOR,
++ LOCAL_SCAN_ABI_VERSION_MINOR);
++ return FALSE;
++ }
++
++local_scan_fn = dlsym(local_scan_lib, "local_scan");
++if (!local_scan_fn)
++ {
++ dlclose(local_scan_lib);
++ log_write(0, LOG_MAIN|LOG_REJECT, "local_scan() library doesn't contain "
++ "local_scan() function - message temporarily rejected");
++ return FALSE;
++ }
++
++return TRUE;
+ }
+
++#endif /* DLOPEN_LOCAL_SCAN */
++
+ /* End of local_scan.c */
+diff -Naur exim-4.32/src/readconf.c exim-4.32-dlopen/src/readconf.c
+--- src/readconf.c 2004-04-15 08:27:01.000000000 +0000
++++ src/readconf.c 2004-05-06 16:23:12.000000000 +0000
+@@ -223,6 +223,9 @@
+ { "local_from_prefix", opt_stringptr, &local_from_prefix },
+ { "local_from_suffix", opt_stringptr, &local_from_suffix },
+ { "local_interfaces", opt_stringptr, &local_interfaces },
++#ifdef DLOPEN_LOCAL_SCAN
++ { "local_scan_path", opt_stringptr, &local_scan_path },
++#endif
+ { "local_scan_timeout", opt_time, &local_scan_timeout },
+ { "local_sender_retain", opt_bool, &local_sender_retain },
+ { "localhost_number", opt_stringptr, &host_number_string },