summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2015-05-13 13:29:43 -0400
committerAnthony G. Basile <blueness@gentoo.org>2015-05-13 13:29:43 -0400
commita580fed3ffd74fc0e1a238425d36f2a681576fe2 (patch)
tree46dfe5434a9bd8ec5b0af739188fd612f2d86ec2
parentsys-auth/polkit: fix compilation with musl by making netgroup related section... (diff)
downloadhardened-dev-a580fed3ffd74fc0e1a238425d36f2a681576fe2.tar.gz
hardened-dev-a580fed3ffd74fc0e1a238425d36f2a681576fe2.tar.bz2
hardened-dev-a580fed3ffd74fc0e1a238425d36f2a681576fe2.zip
mail-mta/exim: fix -lnsl. Bug #533660.
Package-Manager: portage-2.2.18 RepoMan-Options: --force Manifest-Sign-Key: 0xF52D4BBA
-rw-r--r--mail-mta/exim/Manifest27
-rw-r--r--mail-mta/exim/exim-4.84-r99.ebuild513
-rw-r--r--mail-mta/exim/files/auth_conf.sub25
-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.69-r1.27021.patch48
-rw-r--r--mail-mta/exim/files/exim-4.74-localscan_dlopen.patch262
-rw-r--r--mail-mta/exim/files/exim-4.74-radius-db-ENV-clash.patch22
-rw-r--r--mail-mta/exim/files/exim-4.76-crosscompile.patch15
-rw-r--r--mail-mta/exim/files/exim-4.76-dsn.patch18
-rw-r--r--mail-mta/exim/files/exim-4.77-as-needed-ldflags.patch144
-rw-r--r--mail-mta/exim/files/exim-4.77-makefile-freebsd.patch48
-rw-r--r--mail-mta/exim/files/exim-4.80-spool-mail-group.patch27
-rw-r--r--mail-mta/exim/files/exim-4.82-makefile-freebsd.patch45
-rw-r--r--mail-mta/exim/files/exim-submission.socket10
-rw-r--r--mail-mta/exim/files/exim-submission_at.service11
-rw-r--r--mail-mta/exim/files/exim.confd5
-rw-r--r--mail-mta/exim/files/exim.logrotate9
-rw-r--r--mail-mta/exim/files/exim.rc830
-rw-r--r--mail-mta/exim/files/exim.rc946
-rw-r--r--mail-mta/exim/files/exim.service12
-rw-r--r--mail-mta/exim/files/exim.socket10
-rw-r--r--mail-mta/exim/files/exim_482_dsn_1_3.patch1212
-rw-r--r--mail-mta/exim/files/exim_at.service7
-rw-r--r--mail-mta/exim/metadata.xml50
25 files changed, 2621 insertions, 0 deletions
diff --git a/mail-mta/exim/Manifest b/mail-mta/exim/Manifest
new file mode 100644
index 00000000..2a37072d
--- /dev/null
+++ b/mail-mta/exim/Manifest
@@ -0,0 +1,27 @@
+AUX auth_conf.sub 790 SHA256 d0631d487f115c07a178d48bc7168cd16d7b22c8879b1e926923152cde95ba78 SHA512 c0799a44e0fabdd4eb33c9c4a009c7abed80d5b2ab773206b11d644e54bb79004c5741fc510df77fe9856bdff979a14f1cf9a58da19fb00aaae05c623da287b3 WHIRLPOOL 54a457732851ec3154b38e161728f932e52166e0a3debe3f4672208207eb3070056a473bd6b73977ecda2d8d6c7348cbaf4870ee3d4b3250e64f2da5f58c5153
+AUX exim-4.14-tail.patch 446 SHA256 74d1044bb94e167180fd8f8aba7449ca3d2b09b1ce170a1a2e4e54ca0cd660da SHA512 a0365b15f0a48076f9660ebc424d48f68995ac21bbf77f407bdca5103ca65758d7f2241d0151eb5c78476557e240b24a95c23d3b12cfffc1b34ab6f89f2c2110 WHIRLPOOL c6e7e1d183c7669a745b33643c61b672a2c2800a0f1eeff380afa5cafe6d97a91106a4f08273ed154a87cfc7ee807cef8308422b53092083fcc12030403786a5
+AUX exim-4.20-maildir.patch 478 SHA256 2704c4db67bb7c58c2421656d942f533d1eedf1df187e76297ab72d2c2a2fb4c SHA512 2c6f68e3c162a51e62ce6e391db8e79733f11bba20cc8778737650158203b88f9a77b7bbbd2a32b2cf8ae50f039b794fb0996f198acec6a50b94cad6a111f432 WHIRLPOOL 4cf3638b7c7b05badeebbb65151f5d8e847fe2324ca5f88bcca87b8bf7e01ae290a9deccb26dec6abec89f105d00625efe99874e9ea2edf4a557b3d831c3b9f0
+AUX exim-4.69-r1.27021.patch 1447 SHA256 dc81115be1324cf2d61ff2e2393462bd31aa63551a8b58d9dac39293bec058d5 SHA512 45a5b833c698da4690485716c7c45d762a9194d5ae41514028bbad548bbd44373cf7a3a3c6a1c4f635f3f50d1695ac7ead098bf8be15cd1f691c7cc6c7f8d715 WHIRLPOOL ddf5a97d6d2c7220ebbca8ae5377a2c177c75bbed82a2e356f71582839021fe32eb6001d099fa4fb9c4afd55e7a74249d54997cdf691eb6b6aa44a8f834b1d64
+AUX exim-4.74-localscan_dlopen.patch 9280 SHA256 dcd44f552e9b9b79facc988c9efad3ab1609a4e4209e9276323f49d1ea00e462 SHA512 bfd35b8fcc7b8bd50a28b2bb7865d358ed1af3978b057da1c83a0be38ba30a737d983b6b5cf829559ba8c490709d28bdb7d679eb825fe7e24798ec223bedc94e WHIRLPOOL 7140c45782d8611638f3aecc960f890963b1d34fd1cca7a5b78058a616607d10c1a50d4110498e9c3d700ca04df8797c184ce816bfd1cab8931bd4eb9ef3aa8a
+AUX exim-4.74-radius-db-ENV-clash.patch 667 SHA256 a4150c9b73203dd284faa646a67e39f431d07c6a378af8fabc97a4ad9e078437 SHA512 040bbdb2259df882569a428b7fef03f89c3685428654ac29e93360a4791bdabe66e52d33d14f0822461fac119295bd31aad5998f63d59d4af057bd26b310a568 WHIRLPOOL 3ef9641fc821be5d7477ccc41f8656f987a896e883a7aa3a627b92e64e2663a87f345bd0fc46ae1b4b9f6ac09a560c951c0396dd135305c97821374d8aa08806
+AUX exim-4.76-crosscompile.patch 462 SHA256 25ba013858b0fc239e24166554c1e28832d3d25801b53ca633f289bc4ae72b8e SHA512 d4fd4417c1ce727f139999c399795312cdbbb9735d0793d68f8e3150240bc53b31277cb26f9946ba549b34c661fc0a61147d376bda09aa6763cab55d80d62343 WHIRLPOOL 22026d355888efb2f823842c596fb670f0821076fe6faaae9d0a6ecf57a4a6de52af9f720e784e8d7bbcf681494a020f22e75f4a2aa079d30880f5c9af759405
+AUX exim-4.76-dsn.patch 822 SHA256 2b36099285ff271f1c6db189435ebe3c2d3f3e8407ac11a041c7ea21b1997463 SHA512 b25324ca0bb9d5d9fd6b4604c5fb4f601ed793d409f75c008e7638a2d8ac5435bccc300b95999fe34ff167275c7a19a0af7ebc8eb15627243b3cbcddb3fa4f04 WHIRLPOOL d49305b97a43686436c12453366a71bd6730e4593566d340f73a02f08db94ff6b9b8c473993e5ec5ec699425aee5f50f4ba90bc14168f9e8876a0b4a91ee0ddd
+AUX exim-4.77-as-needed-ldflags.patch 5954 SHA256 3960f6883f7c3b44110ca5916ad8fa63f829516624c011a807cda00972b4dffd SHA512 716cac89116b66df645a6d49c88369ed062e3d3cf158fb50420984fe1fd2c1d3f56ad3a59ba36bb5d88dc9f8194f5fa105340baa82120b63298a245c6aaaaca2 WHIRLPOOL 8e321d3abf5a2d55af93d7cc865a33b1b8f13ba19af8ce6b17c29ba7b4003b4cc7acb4789ab941e8dc0b475d8568c0934e8da2c429dec9099901e85b966830d0
+AUX exim-4.77-makefile-freebsd.patch 1124 SHA256 50108e7f26ca2acb594d3d9a57c25ad041f32ada729b604da7378e9376b3ac7c SHA512 99dd86a5aedb6505356e3c5614b065a68d4bbae69502cd5c0a780038c231fb1047e21a2f0b8757a65d6b1a6dcdf8a7f7416a299edc1c85adeec4e362b992f321 WHIRLPOOL 33a4d49572cb3beafe2680b742fe68ceb6d7098be4244677c3ae2ea23dfed8af1be4ef91f0247e5d69adec5679dd02cb3dc71233ba4cb3418f93c70e717727fa
+AUX exim-4.80-spool-mail-group.patch 946 SHA256 4f013e30f6f96360baa7d5d7818eaf5247984ab0eb43b8b5ba8d1bd8704b811b SHA512 24f30e9a9d90dc0f1fe8b3db26f8bc2649182b4e78110dc28a9c0f3a3feb7589f923144a4f1c54a1c46ff8cfe40826a1f2212787753be752f4d15a72d54a143b WHIRLPOOL aa34f4e721fda796ebeb091514ec35ffcf153e813b7760245d25da5d6f27590734d28032498a0ffb2262e170355b0a99b53947818e669d1f79bd0393ae85a2d6
+AUX exim-4.82-makefile-freebsd.patch 1252 SHA256 c407ea37ff8125f20f535ddb02793d5242a12582b9ab388d2ba956f932af2f3d SHA512 fb440ad3e46b90d4c2e4826841944f4006390ccebee08154a39e46f6854be15edd7d0b028333b41451a0511f886ad3a30cb4b86e7ba8be99f12616a137f09d56 WHIRLPOOL 72132bdce44ba23fb162a5afaed33ea72ef2c917d020f5ddf920ce16991f02411c0bbcb23526b0e09753ab84cf2f258108aa2283ce5f9529810844497df29501
+AUX exim-submission.socket 161 SHA256 d3bb58f0fbeaaa33c812a823708664bbcd828da7d24e2a098f84a15aee443fee SHA512 4a233761793e3510e9efa5aad3a6098c41b757f13133a7ea825680f2b393aba8d7935f16bf1dd065dde884fe7ba45639a8d398333a7d9bf0a6b72f88c8f2a09d WHIRLPOOL 7fe2a157ae3361440d8a85c8eca44a97a289be1689261efda943076c9a76ab74ef9d5f01ec0eecdde940ae30ccb46530c95d7223cf62b78e8eb2bde5268288e2
+AUX exim-submission_at.service 360 SHA256 55719e8b823702b0054584326ca28349b7487e5be9e567ddc7a6e6259767e05b SHA512 dc28698f15e8eaa4614ae81fc8cb76d92fed1110ce02f7a6ee8feace418dbb194711eb2d4dd444cf818628c11721e21d80b7b974879ab6ddd78cc717cce17c2f WHIRLPOOL 8e907250dc6be75a252b0a6880004b05fccb2ebeb044a4538bc88eae6ed81f5a537a319188320657d43b3ae1850e11cfa0d86393b038d2d0d1e9a0ce7a7543fc
+AUX exim.confd 141 SHA256 352c48d5302d122d75b821395933150e1fc6e16004b0d28e99a14b60f160ee6e SHA512 cb5e4aa71d3f0b7945e9806064f6a3ab64cb894381654ead40c73a49ae2d1bbb3dc587919952a09b2c81b9fcf8784f73d59c12081cda96a5b7210442f5088998 WHIRLPOOL 078764d27c5c7614120ac0f531b97ac4b65a68ee741fe11fd3ae68e8e89307cc3aaab6d7ee651ec5969479cf9f752933c54faef1e068efa3fda85360343f4d39
+AUX exim.logrotate 116 SHA256 755eab8631ebc103fff111b0c37ff104a34f8fdff349d383d62cd91db3bc0984 SHA512 24bb8dcfadb1204c2ab0316d57de287b5092754731949390cfb3c88fa6827d45acfe1048cf9e26f615ca0449e8d780d0c98ea55ed61be9d1558755d3e53b9ec8 WHIRLPOOL 7c3092e99e20a038fe21f10ada71bae39faa31de6d032b0bd02a373a92b34f3972ab68642cca072364b28d3c0cbe3f35787f137681b8d8093105fb56abd9c7ed
+AUX exim.rc8 755 SHA256 8ebeb8d406690918c6d4e9b87fd2fd44053055130091671e49ce7d77608e0390 SHA512 4fe4d04cc330a7445cb0f00c163148bda51b9ae6d7fece640efab1a3dec60ae4eb8ea2dbc24502a27c48e8bc03f8892d1cb6c78316d8e9262897e21e67bdc02e WHIRLPOOL e9d00cad884804f8d6b1ecd5adcc8df8be92fb305b37eaeb39194dc2d41a2ea3785d27cb34df31e29847b734318ef5ee9b42c9474203629262f32c9dc78b56e1
+AUX exim.rc9 1236 SHA256 e541e950313a4057e3cd13cabac26db924485c54607410e0dcb3a2c348bf2fab SHA512 2032f27ecb23dc9dcc7154d959dd60f9e24316415a78a993ce1ed7511753a99f12774c649698aec1a92bd641c3254c6b81a9a42f2a424dd43ff10813e1aad2f5 WHIRLPOOL ebbdda159ddd609a3524dfc2b79d482fc30a0b11dbaed11c4687fd781ed8231982cb61e2dfc5bc830f8ef281f0d02db84f18535660034ef8e0dbdc5ee960a578
+AUX exim.service 229 SHA256 6e5372338d93b75d96bf571d892b167ac812378bcf978dcd3f3324d7e612463a SHA512 a071e9fb74b5fc2fdf0c73ad64ddfbc3954d8f7095d6a363dacf8c75d72a479fbf6821822ec5c8f3846d7687342e1bd447b97f91ca7b0582e5c98008aac30cca WHIRLPOOL 5f2ccd6898c95599f8e801aa111c53dbb50b7ec9f6ba6552fe195ad07d41efdcbff765cba1d696df6acb564bca29830d0bf61bcda9a244a3b48354318914bbd5
+AUX exim.socket 139 SHA256 3e3d8b6be2741d2587a496196c08b3f2ffa05b5803b2bf9fb49359cef3a98d26 SHA512 db621116907ceb573e6f34581f47c91f751bff593054d7ddc32397b34c7f2405bec184bdb0589d2ac457fa3a61bcba072761e3a6293a99c9c764d2d9fd6069ae WHIRLPOOL 6ddceaa1bf31d995afa2dc49ab4d8e1068321ab12b158e075f6ea3f2cc4dff35c2052da2a85fe998813354755e574670086880ef7e42e2a02877d4f766706d3c
+AUX exim_482_dsn_1_3.patch 41505 SHA256 4e00069a4b2e2deb414f05ea33f29b3f007d9ebff17cfc16998800b21b8e0ef5 SHA512 5f184d903300851dba46f4c3d46e70269111ff335fc71e9d14b04f40462c163411521f6fd60e1d703dfab3a173911225a209133369bb3c26d83455499261e777 WHIRLPOOL 842040f5009ad43b40ceff4935510b06a0f7496bfb7e7a13db8f3eeb6fec63d7c7b38e4ed31b2d8de543ddaf7e8af8becef334c88d1365910e783c8c0ad5a7ff
+AUX exim_at.service 140 SHA256 faad96dadbb2750faa5652d830f10d5a14be487a42e8db1cec797164acf14b73 SHA512 11c8133ee15b3e5193c9b1c59aed66c81b6e045dd23310bede9fcde6c88905db5ef08afdb798b53b75a7465915ea1247e980edf95db07a7f9b7bb58ce95fbb5a WHIRLPOOL 78f0c825526ae890458c4e71df2bd724d77d508081c6d6c2e3493732f11576ffeed755968dd2f3bcfb1cc6e0b0d61ea9fc175cd71340d908646f1a9ccbc7406e
+DIST exim-4.84.tar.bz2 1761790 SHA256 78ea22be87fb6df880e7fd482f3bec9ef6ceca0c9dedd50f8a26cae0b38b9e9c SHA512 3cd41af6d57e5f0377fc93367753eae6cb6bf835803e8608c44e1da5acefce1ed8886f4fe7536950de072bfed6e927afe1536c1e6466cf3121dd352b69a68039 WHIRLPOOL 9e840aa6afa0db68455b4ab458706eedd7ea57b084999c9e85eaaec0530ed93958731d934ff1d7830d9b5cd086e36cb56dc8a2f78dad85bdba9ae6573510e840
+DIST exim-html-4.84.tar.bz2 465281 SHA256 7ee7e9015b853915604b7806be93d56e9ba1fb915b63f0d6828c47f2228fd45b SHA512 7de8513476b6abcdfd36b0121a2a9d6decf1ccf94ef51b8363e544066cc05670e6f2b4d03d5fbc49071b1431183dfd9badde5cbcc65f51d55ec6b25ebcb070b9 WHIRLPOOL 88c376fd399e17b2bc06d2d0fad19f8c6485807118a81e0c200f6c39defe7155fa920489481a8b82e629951766ce0222b85956f387d22d22549303bd3dff7f82
+DIST system_filter.exim.gz 3075 SHA256 3a3471b486a09e0a0153f7b520e1eaf26d21b97d73ea8348bdc593c00eb1e437 SHA512 cb358d3ce2499a0bb5920d962a06f2af8486e55ec90c8c928bd8e3aefb279aa57f5f960d5adfcef68bd94110b405eaa144e9629cfe6014a529c79c544600bbf3 WHIRLPOOL ce68d9c18b24eca3ef97ea810964cc1ada5f85b795a7c432ad39b5788188a16419101c92fb52b418738d760e1d658f7a41485e5561079a667d84d276c71be5a4
+EBUILD exim-4.84-r99.ebuild 12405 SHA256 c62882bcabceff343d0384e3ddb34dbdce36af3594bbd00dd2f21cf985b97f51 SHA512 2198d439730ed2429ef113a7898bcf69d131a81bcc0e612bfc67f4b7f34ac09df561304f8c27bee1640c784f1718cd527e1cac236e2a401994421b4acc51af90 WHIRLPOOL 6eb6d0e1ba489623779c13bc43ba88e97b383b518eefd51319ec9ef8c61fbb15eddc8bdd2d1fa70ba4ef10265df41629c9c36ec6c6160ba6c484d4b5e12f707b
+MISC metadata.xml 2299 SHA256 a2985b24eb4e06b72f5c3a77403fd36e511112d789c584c391f344f547b21bcf SHA512 a7d4c9faf6240b5795e1da7df99f918bf438b1bf93fbe9ce12269b0f48000beb622dfad2489337f35b42c342605cd19359edf4e581794fc33f76a4cb0d035568 WHIRLPOOL 7eb7ade4038826e0947df620a65044acd2167b32126963c3f28336050680b05e4dca211588b722e7fb8273e13e171690a5ba0114182047e0690c43fdf244b71f
diff --git a/mail-mta/exim/exim-4.84-r99.ebuild b/mail-mta/exim/exim-4.84-r99.ebuild
new file mode 100644
index 00000000..e1604561
--- /dev/null
+++ b/mail-mta/exim/exim-4.84-r99.ebuild
@@ -0,0 +1,513 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/mail-mta/exim/exim-4.84.ebuild,v 1.17 2015/03/21 21:18:34 jlec Exp $
+
+EAPI="5"
+
+inherit eutils toolchain-funcs multilib pam systemd
+
+IUSE="dcc +dkim dlfunc dmarc +dnsdb doc dovecot-sasl dsn exiscan-acl gnutls ipv6 ldap lmtp maildir mbx mysql nis pam perl pkcs11 postgres +prdr proxy radius redis sasl selinux spf sqlite srs ssl syslog tcpd tpda X"
+REQUIRED_USE="spf? ( exiscan-acl ) srs? ( exiscan-acl ) dmarc? ( spf dkim ) pkcs11? ( gnutls )"
+
+COMM_URI="ftp://ftp.exim.org/pub/exim/exim4$([[ ${PV} == *_rc* ]] && echo /test)"
+
+DESCRIPTION="A highly configurable, drop-in replacement for sendmail"
+SRC_URI="${COMM_URI}/${P//rc/RC}.tar.bz2
+ mirror://gentoo/system_filter.exim.gz
+ doc? ( ${COMM_URI}/${PN}-html-${PV//rc/RC}.tar.bz2 )"
+HOMEPAGE="http://www.exim.org/"
+
+SLOT="0"
+LICENSE="GPL-2"
+KEYWORDS="amd64 ppc ~mips x86"
+
+COMMON_DEPEND=">=sys-apps/sed-4.0.5
+ >=sys-libs/db-3.2
+ dev-libs/libpcre
+ perl? ( dev-lang/perl:= )
+ pam? ( virtual/pam )
+ tcpd? ( sys-apps/tcp-wrappers )
+ ssl? ( dev-libs/openssl )
+ gnutls? ( net-libs/gnutls[pkcs11?]
+ dev-libs/libtasn1 )
+ ldap? ( >=net-nds/openldap-2.0.7 )
+ mysql? ( virtual/mysql )
+ postgres? ( dev-db/postgresql )
+ sasl? ( >=dev-libs/cyrus-sasl-2.1.26-r2 )
+ redis? ( dev-libs/hiredis )
+ spf? ( >=mail-filter/libspf2-1.2.5-r1 )
+ dmarc? ( mail-filter/opendmarc )
+ srs? ( mail-filter/libsrs_alt )
+ X? ( x11-proto/xproto
+ x11-libs/libX11
+ x11-libs/libXmu
+ x11-libs/libXt
+ x11-libs/libXaw
+ )
+ sqlite? ( dev-db/sqlite )
+ radius? ( net-dialup/radiusclient )
+ virtual/libiconv
+ "
+ # added X check for #57206
+DEPEND="${COMMON_DEPEND}
+ virtual/pkgconfig"
+RDEPEND="${COMMON_DEPEND}
+ !mail-mta/courier
+ !mail-mta/esmtp
+ !mail-mta/mini-qmail
+ !<mail-mta/msmtp-1.4.19-r1
+ !>=mail-mta/msmtp-1.4.19-r1[mta]
+ !mail-mta/netqmail
+ !mail-mta/nullmailer
+ !mail-mta/postfix
+ !mail-mta/qmail-ldap
+ !mail-mta/sendmail
+ !mail-mta/opensmtpd
+ !<mail-mta/ssmtp-2.64-r2
+ !>=mail-mta/ssmtp-2.64-r2[mta]
+ !net-mail/mailwrapper
+ >=net-mail/mailbase-0.00-r5
+ virtual/logger
+ dcc? ( mail-filter/dcc )
+ selinux? ( sec-policy/selinux-exim )
+ "
+
+S=${WORKDIR}/${P//rc/RC}
+
+src_prepare() {
+ epatch "${FILESDIR}"/exim-4.14-tail.patch
+ epatch "${FILESDIR}"/exim-4.74-localscan_dlopen.patch
+ epatch "${FILESDIR}"/exim-4.69-r1.27021.patch
+ epatch "${FILESDIR}"/exim-4.74-radius-db-ENV-clash.patch # 287426
+ epatch "${FILESDIR}"/exim-4.82-makefile-freebsd.patch # 235785
+ epatch "${FILESDIR}"/exim-4.77-as-needed-ldflags.patch # 352265, 391279
+ epatch "${FILESDIR}"/exim-4.76-crosscompile.patch # 266591
+
+ if use maildir ; then
+ epatch "${FILESDIR}"/exim-4.20-maildir.patch
+ else
+ epatch "${FILESDIR}"/exim-4.80-spool-mail-group.patch # 438606
+ fi
+
+ # user Exim believes it should be
+ MAILUSER=mail
+ MAILGROUP=mail
+ if use prefix && [[ ${EUID} != 0 ]] ; then
+ MAILUSER=$(id -un)
+ MAILGROUP=$(id -gn)
+ fi
+}
+
+src_configure() {
+ # general config and paths
+
+ sed -i.orig \
+ -e "/SYSTEM_ALIASES_FILE/s'SYSTEM_ALIASES_FILE'${EPREFIX}/etc/mail/aliases'" \
+ "${S}"/src/configure.default || die
+
+ sed -i -e 's/^buildname=.*/buildname=exim-gentoo/g' Makefile || die
+
+ sed -e "48i\CFLAGS=${CFLAGS}" \
+ -e "s:BIN_DIRECTORY=/usr/exim/bin:BIN_DIRECTORY=${EPREFIX}/usr/sbin:" \
+ -e "s:EXIM_USER=:EXIM_USER=${MAILUSER}:" \
+ -e "s:CONFIGURE_FILE=/usr/exim/configure:CONFIGURE_FILE=${EPREFIX}/etc/exim/exim.conf:" \
+ -e "s:ZCAT_COMMAND=.*$:ZCAT_COMMAND=${EPREFIX}/bin/zcat:" \
+ -e "s:COMPRESS_COMMAND=.*$:COMPRESS_COMMAND=${EPREFIX}/bin/gzip:" \
+ src/EDITME > Local/Makefile
+
+ if use elibc_musl; then
+ sed -e 's/^LIBS = -lnsl/LIBS =/g' \
+ -e 's/^HAVE_ICONV=yes/#HAVE_ICONV=yes/' \
+ -i OS/Makefile-Linux
+ fi
+
+ cd Local
+
+ cat >> Makefile <<- EOC
+ INFO_DIRECTORY=${EPREFIX}/usr/share/info
+ PID_FILE_PATH=${EPREFIX}/run/exim.pid
+ SPOOL_DIRECTORY=${EPREFIX}/var/spool/exim
+ EOC
+
+ # if we use libiconv, now is the time to tell so
+ use !elibc_glibc && use !elibc_musl && echo "EXTRALIBS_EXIM=-liconv" >> Makefile
+
+ # support for IPv6
+ if use ipv6; then
+ cat >> Makefile <<- EOC
+ HAVE_IPV6=YES
+ EOC
+ fi
+
+ #
+ # mail storage formats
+
+ # mailstore is Exim's traditional storage format
+ cat >> Makefile <<- EOC
+ SUPPORT_MAILSTORE=yes
+ EOC
+
+ # mbox
+ if use mbx; then
+ cat >> Makefile <<- EOC
+ SUPPORT_MBX=yes
+ EOC
+ fi
+
+ # maildir
+ if use maildir; then
+ cat >> Makefile <<- EOC
+ SUPPORT_MAILDIR=yes
+ EOC
+ fi
+
+ #
+ # lookup methods
+
+ # use the "native" interfaces to the DBM and CDB libraries, support
+ # passwd and directory lookups by default
+ cat >> Makefile <<- EOC
+ USE_DB=yes
+ DBMLIB=-ldb
+ LOOKUP_CDB=yes
+ LOOKUP_PASSWD=yes
+ LOOKUP_DSEARCH=yes
+ EOC
+
+ if ! use dnsdb; then
+ # DNSDB lookup is enabled by default
+ sed -i "s:^LOOKUP_DNSDB=yes:# LOOKUP_DNSDB=yes:" Makefile
+ fi
+
+ if use ldap; then
+ cat >> Makefile <<- EOC
+ LOOKUP_LDAP=yes
+ LDAP_LIB_TYPE=OPENLDAP2
+ LOOKUP_INCLUDE += -I"${EROOT}"usr/include/ldap
+ LOOKUP_LIBS += -lldap -llber
+ EOC
+ fi
+
+ if use mysql; then
+ cat >> Makefile <<- EOC
+ LOOKUP_MYSQL=yes
+ LOOKUP_INCLUDE += $(mysql_config --include)
+ LOOKUP_LIBS += $(mysql_config --libs)
+ EOC
+ fi
+
+ if use nis; then
+ cat >> Makefile <<- EOC
+ LOOKUP_NIS=yes
+ LOOKUP_NISPLUS=yes
+ EOC
+ fi
+
+ if use postgres; then
+ cat >> Makefile <<- EOC
+ LOOKUP_PGSQL=yes
+ LOOKUP_INCLUDE += -I$(pg_config --includedir)
+ LOOKUP_LIBS += -L$(pg_config --libdir) -lpq
+ EOC
+ fi
+
+ if use sqlite; then
+ cat >> Makefile <<- EOC
+ LOOKUP_SQLITE=yes
+ LOOKUP_SQLITE_PC=sqlite3
+ EOC
+ fi
+
+ if use redis; then
+ cat >> Makefile <<- EOC
+ EXPERIMENTAL_REDIS=yes
+ LOOKUP_LIBS += -lhiredis
+ EOC
+ fi
+
+ #
+ # Exim monitor, enabled by default, controlled via X USE-flag,
+ # disable if not requested, bug #46778
+ if use X; then
+ cp ../exim_monitor/EDITME eximon.conf || die
+ else
+ sed -i -e '/^EXIM_MONITOR=/s/^/# /' Makefile
+ fi
+
+ #
+ # features
+
+ # content scanning support
+ if use exiscan-acl; then
+ cat >> Makefile <<- EOC
+ WITH_CONTENT_SCAN=yes
+ WITH_OLD_DEMIME=yes
+ EOC
+ fi
+
+ # DomainKeys Identified Mail, RFC4871
+ if ! use dkim; then
+ # DKIM is enabled by default
+ cat >> Makefile <<- EOC
+ DISABLE_DKIM=yes
+ EOC
+ fi
+
+ # Per-Recipient-Data-Response
+ if ! use prdr; then
+ # PRDR is enabled by default
+ cat >> Makefile <<- EOC
+ DISABLE_PRDR=yes
+ EOC
+ fi
+
+ # log to syslog
+ if use syslog; then
+ sed -i "s:LOG_FILE_PATH=/var/log/exim/exim_%s.log:LOG_FILE_PATH=syslog:" Makefile
+ cat >> Makefile <<- EOC
+ LOG_FILE_PATH=syslog
+ EOC
+ else
+ cat >> Makefile <<- EOC
+ LOG_FILE_PATH=${EPREFIX}/var/log/exim/exim_%s.log
+ EOC
+ fi
+
+ # starttls support (ssl)
+ if use ssl; then
+ echo "SUPPORT_TLS=yes" >> Makefile
+ if use gnutls; then
+ echo "USE_GNUTLS=yes" >> Makefile
+ echo "USE_GNUTLS_PC=gnutls" >> Makefile
+ use pkcs11 || echo "AVOID_GNUTLS_PKCS11=yes" >> Makefile
+ else
+ echo "USE_OPENSSL_PC=openssl" >> Makefile
+ fi
+ fi
+
+ # TCP wrappers
+ if use tcpd; then
+ cat >> Makefile <<- EOC
+ USE_TCP_WRAPPERS=yes
+ EXTRALIBS_EXIM += -lwrap
+ EOC
+ fi
+
+ # Light Mail Transport Protocol
+ if use lmtp; then
+ cat >> Makefile <<- EOC
+ TRANSPORT_LMTP=yes
+ EOC
+ fi
+
+ # embedded Perl
+ if use perl; then
+ cat >> Makefile <<- EOC
+ EXIM_PERL=perl.o
+ EOC
+ fi
+
+ # dlfunc
+ if use dlfunc; then
+ cat >> Makefile <<- EOC
+ EXPAND_DLFUNC=yes
+ EOC
+ fi
+
+ #
+ # experimental features
+
+ # Distributed Checksum Clearinghouse
+ if use dcc; then
+ echo "EXPERIMENTAL_DCC=yes">> Makefile
+ fi
+
+ # Sender Policy Framework
+ if use spf; then
+ cat >> Makefile <<- EOC
+ EXPERIMENTAL_SPF=yes
+ EXTRALIBS_EXIM += -lspf2
+ EOC
+ fi
+
+ # Sender Rewriting Scheme
+ if use srs; then
+ cat >> Makefile <<- EOC
+ EXPERIMENTAL_SRS=yes
+ EXTRALIBS_EXIM += -lsrs_alt
+ EOC
+ fi
+
+ # DMARC
+ if use dmarc; then
+ cat >> Makefile <<- EOC
+ EXPERIMENTAL_DMARC=yes
+ EXTRALIBS_EXIM += -lopendmarc
+ EOC
+ fi
+
+ # Transport post-delivery actions
+ if use tpda; then
+ cat >> Makefile <<- EOC
+ EXPERIMENTAL_TPDA=yes
+ EOC
+ fi
+
+ # Proxy Protocol
+ if use proxy; then
+ cat >> Makefile <<- EOC
+ EXPERIMENTAL_PROXY=yes
+ EOC
+ fi
+
+ # Delivery Sender Notifications
+ if use dsn; then
+ cat >> Makefile <<- EOC
+ EXPERIMENTAL_DSN=yes
+ EOC
+ fi
+
+ #
+ # authentication (SMTP AUTH)
+
+ # standard bits
+ cat >> Makefile <<- EOC
+ AUTH_SPA=yes
+ AUTH_CRAM_MD5=yes
+ AUTH_PLAINTEXT=yes
+ EOC
+
+ # Cyrus SASL
+ if use sasl; then
+ cat >> Makefile <<- EOC
+ CYRUS_SASLAUTHD_SOCKET=${EPREFIX}/run/saslauthd/mux
+ AUTH_CYRUS_SASL=yes
+ AUTH_LIBS += -lsasl2
+ EOC
+ fi
+
+ # Dovecot
+ if use dovecot-sasl; then
+ cat >> Makefile <<- EOC
+ AUTH_DOVECOT=yes
+ EOC
+ fi
+
+ # Pluggable Authentication Modules
+ if use pam; then
+ cat >> Makefile <<- EOC
+ SUPPORT_PAM=yes
+ AUTH_LIBS += -lpam
+ EOC
+ fi
+
+ # Radius
+ if use radius; then
+ cat >> Makefile <<- EOC
+ RADIUS_CONFIG_FILE=${EPREFIX}/etc/radiusclient/radiusclient.conf
+ RADIUS_LIB_TYPE=RADIUSCLIENT
+ AUTH_LIBS += -lradiusclient
+ EOC
+ fi
+}
+
+src_compile() {
+ emake -j1 CC="$(tc-getCC)" HOSTCC="$(tc-getCC $CBUILD)" \
+ AR="$(tc-getAR) cq" RANLIB="$(tc-getRANLIB)" FULLECHO='' \
+ || die "make failed"
+}
+
+src_install () {
+ cd "${S}"/build-exim-gentoo || die
+ dosbin exim
+ if use X; then
+ dosbin eximon.bin
+ dosbin eximon
+ fi
+ fperms 4755 /usr/sbin/exim
+
+ dosym exim /usr/sbin/sendmail
+ dosym exim /usr/sbin/rsmtp
+ dosym exim /usr/sbin/rmail
+ dosym /usr/sbin/exim /usr/bin/mailq
+ dosym /usr/sbin/exim /usr/bin/newaliases
+ dosym /usr/sbin/sendmail /usr/lib/sendmail
+
+ for i in exicyclog exim_dbmbuild exim_dumpdb exim_fixdb exim_lock \
+ exim_tidydb exinext exiwhat exigrep eximstats exiqsumm exiqgrep \
+ convert4r3 convert4r4 exipick
+ do
+ dosbin $i
+ done
+
+ dodoc "${S}"/doc/*
+ doman "${S}"/doc/exim.8
+ use dsn && dodoc "${S}"/README.DSN
+ use doc && dohtml -r "${WORKDIR}"/${PN}-html-${PV//rc/RC}/doc/html/spec_html/*
+
+ # conf files
+ insinto /etc/exim
+ newins "${S}"/src/configure.default exim.conf.dist
+ if use exiscan-acl; then
+ newins "${S}"/src/configure.default exim.conf.exiscan-acl
+ fi
+ doins "${WORKDIR}"/system_filter.exim
+ doins "${FILESDIR}"/auth_conf.sub
+
+ pamd_mimic system-auth exim auth account
+
+ # headers, #436406
+ if use dlfunc ; then
+ # fixup includes so they actually can be found when including
+ sed -i \
+ -e '/#include "\(config\|store\|mytypes\).h"/s:"\(.\+\)":<exim/\1>:' \
+ local_scan.h || die
+ insinto /usr/include/exim
+ doins {config,local_scan}.h ../src/{mytypes,store}.h
+ fi
+
+ insinto /etc/logrotate.d
+ newins "${FILESDIR}/exim.logrotate" exim
+
+ newinitd "${FILESDIR}"/exim.rc8 exim
+ newconfd "${FILESDIR}"/exim.confd exim
+
+ systemd_dounit "${FILESDIR}"/{exim.service,exim.socket,exim-submission.socket}
+ systemd_newunit "${FILESDIR}"/exim_at.service 'exim@.service'
+ systemd_newunit "${FILESDIR}"/exim-submission_at.service 'exim-submission@.service'
+
+ DIROPTIONS="-m 0750 -o ${MAILUSER} -g ${MAILGROUP}"
+ dodir /var/log/${PN}
+}
+
+pkg_postinst() {
+ if [[ ! -f ${EROOT}etc/exim/exim.conf ]] ; then
+ einfo "${EROOT}etc/exim/system_filter.exim is a sample system_filter."
+ einfo "${EROOT}etc/exim/auth_conf.sub contains the configuration sub for using smtp auth."
+ einfo "Please create ${EROOT}etc/exim/exim.conf from ${EROOT}etc/exim/exim.conf.dist."
+ fi
+ if use dcc ; then
+ einfo "DCC support is experimental, you can find some limited"
+ einfo "documentation at the bottom of this prerelease message:"
+ einfo "http://article.gmane.org/gmane.mail.exim.devel/3579"
+ fi
+ use spf && einfo "SPF support is experimental"
+ use srs && einfo "SRS support is experimental"
+ if use dmarc ; then
+ einfo "DMARC support is experimental. See global settings to"
+ einfo "configure DMARC, for usage see the documentation at "
+ einfo "experimental-spec.txt."
+ fi
+ use tpda && einfo "TPDA support is experimental"
+ use proxy && einfo "proxy support is experimental"
+ if use dsn ; then
+ einfo "Starting from Exim 4.83, DSN support comes from upstream."
+ einfo "DSN support is an experimental feature. If you used DSN"
+ einfo "support prior to 4.83, make sure to remove all dsn_process"
+ einfo "switches from your routers, see http://bugs.gentoo.org/511818"
+ fi
+ einfo "Exim maintains some db files under its spool directory that need"
+ einfo "cleaning from time to time. (${EROOT}var/spool/exim/db)"
+ einfo "Please use the exim_tidydb tool as documented in the Exim manual:"
+ einfo "http://www.exim.org/exim-html-current/doc/html/spec_html/ch-exim_utilities.html#SECThindatmai"
+}
diff --git a/mail-mta/exim/files/auth_conf.sub b/mail-mta/exim/files/auth_conf.sub
new file mode 100644
index 00000000..24434a71
--- /dev/null
+++ b/mail-mta/exim/files/auth_conf.sub
@@ -0,0 +1,25 @@
+######################################################################
+# AUTHENTICATION CONFIGURATION #
+######################################################################
+# If you're using PAM to authenticate, lifes real simple.
+# This plain directive works for nearly everything except windows MUA's the
+# login directive will allow you to authenticate your Outlook 2000 and
+# outlook express clients.
+
+
+
+plain:
+ driver = plaintext
+ public_name = PLAIN
+ server_condition = "${if pam{$2:$3}{1}{0}}"
+ server_set_id = $2
+
+login:
+ driver = plaintext
+ public_name = LOGIN
+ server_prompts = "Username:: : Password::"
+ server_condition = "${if pam{$1:${sg{$2}{:}{::}}}{1}{0}}"
+ server_set_id = $1
+#
+# FIXME
+# Need to add authenticator for SPA!!
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.69-r1.27021.patch b/mail-mta/exim/files/exim-4.69-r1.27021.patch
new file mode 100644
index 00000000..804e16d6
--- /dev/null
+++ b/mail-mta/exim/files/exim-4.69-r1.27021.patch
@@ -0,0 +1,48 @@
+diff -urN exim-4.69.orig/src/configure.default exim-4.69/src/configure.default
+--- exim-4.69.orig/src/configure.default 2008-05-05 10:17:44.000000000 +0100
++++ exim-4.69/src/configure.default 2008-05-05 10:18:26.000000000 +0100
+@@ -592,6 +592,22 @@
+ pipe_transport = address_pipe
+ reply_transport = address_reply
+
++# This router runs procmail if users have a .procmailrc file
++procmail:
++ check_local_user
++ driver = accept
++ transport = procmail_pipe
++ require_files = ${local_part}:+${home}:+${home}/.procmailrc:+/usr/bin/procmail
++ no_verify
++
++# This router runs maildrop if users have a .mailfilter file
++maildrop:
++ check_local_user
++ driver = accept
++ transport = maildrop_pipe
++ require_files = ${local_part}:+${home}:+${home}/.mailfilter:+/usr/bin/maildrop
++ no_verify
++
+
+ # This router matches local user mailboxes. If the router fails, the error
+ # message is "Unknown user".
+@@ -676,6 +692,21 @@
+ address_reply:
+ driver = autoreply
+
++# This transport is used for procmail
++procmail_pipe:
++ driver = pipe
++ command = "/usr/bin/procmail -d ${local_part}"
++ return_path_add
++ delivery_date_add
++ envelope_to_add
++
++# This transport is used for courier-maildrop filtering (Maildir filter system)
++maildrop_pipe:
++ driver = pipe
++ command = "/usr/bin/maildrop -d ${local_part}"
++ return_path_add
++ delivery_date_add
++ envelope_to_add
+
+
+ ######################################################################
diff --git a/mail-mta/exim/files/exim-4.74-localscan_dlopen.patch b/mail-mta/exim/files/exim-4.74-localscan_dlopen.patch
new file mode 100644
index 00000000..3bb57c16
--- /dev/null
+++ b/mail-mta/exim/files/exim-4.74-localscan_dlopen.patch
@@ -0,0 +1,262 @@
+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,24 @@
+
+
+ #------------------------------------------------------------------------------
++# 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
++ifeq ($(OSTYPE),Linux)
++LFLAGS += -ldl
++endif
++
++
++#------------------------------------------------------------------------------
+ # 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 },
diff --git a/mail-mta/exim/files/exim-4.74-radius-db-ENV-clash.patch b/mail-mta/exim/files/exim-4.74-radius-db-ENV-clash.patch
new file mode 100644
index 00000000..247668ef
--- /dev/null
+++ b/mail-mta/exim/files/exim-4.74-radius-db-ENV-clash.patch
@@ -0,0 +1,22 @@
+Nasty workaround for
+http://bugs.gentoo.org/show_bug.cgi?id=287426
+
+--- src/auths/call_radius.c
++++ src/auths/call_radius.c
+@@ -10,6 +10,16 @@
+ /* This file was originally supplied by Ian Kirk. The libradius support came
+ from Alex Kiernan. */
+
++/* ugly hack to work around redefinition of ENV by radiusclient.h and
++ * db.h: define _DB_H_ so the db.h include thinks it's already included,
++ * we can get away with it like this, since this file doesn't use any db
++ * functions. */
++#ifndef _DB_H_
++#define _DB_H_ 1
++#define _DB_EXT_PROT_IN_ 1
++#define DB void
++#endif
++
+ #include "../exim.h"
+
+ /* This module contains functions that call the Radius authentication
diff --git a/mail-mta/exim/files/exim-4.76-crosscompile.patch b/mail-mta/exim/files/exim-4.76-crosscompile.patch
new file mode 100644
index 00000000..cf47adee
--- /dev/null
+++ b/mail-mta/exim/files/exim-4.76-crosscompile.patch
@@ -0,0 +1,15 @@
+https://bugs.gentoo.org/show_bug.cgi?id=266591
+
+--- OS/Makefile-Base
++++ OS/Makefile-Base
+@@ -114,8 +114,8 @@
+
+ # Targets for special-purpose configuration header builders
+ buildconfig: buildconfig.c
+- @echo "$(CC) buildconfig.c"
+- $(FE)$(CC) $(CFLAGS) $(INCLUDE) -o buildconfig buildconfig.c $(LIBS)
++ @echo "$(HOSTCC) buildconfig.c"
++ $(FE)$(HOSTCC) $(HOSTCFLAGS) $(INCLUDE) -o buildconfig buildconfig.c $(LIBS)
+
+
+ # Target for the exicyclog utility script
diff --git a/mail-mta/exim/files/exim-4.76-dsn.patch b/mail-mta/exim/files/exim-4.76-dsn.patch
new file mode 100644
index 00000000..8a608ba6
--- /dev/null
+++ b/mail-mta/exim/files/exim-4.76-dsn.patch
@@ -0,0 +1,18 @@
+http://bugs.gentoo.org/show_bug.cgi?id=366835
+https://sourceforge.net/tracker/?func=detail&aid=3300653&group_id=121058&atid=689120
+
+--- exim_469_dsn_1_3.patch
++++ exim_469_dsn_1_3.patch
+@@ -524,10 +524,10 @@
+ diff -urN exim-4.69-orig/src/readconf.c exim-4.69-dsn/src/readconf.c
+ --- exim-4.69-orig/src/readconf.c 2007-08-23 12:01:49.000000000 +0100
+ +++ exim-4.69-dsn/src/readconf.c 2008-07-28 09:52:55.000000000 +0100
+-@@ -207,6 +207,9 @@
+- { "dns_ipv4_lookup", opt_stringptr, &dns_ipv4_lookup },
++@@ -219,6 +219,9 @@
+ { "dns_retrans", opt_time, &dns_retrans },
+ { "dns_retry", opt_int, &dns_retry },
++ { "dns_use_edns0", opt_int, &dns_use_edns0 },
+ +#ifdef SUPPORT_DSN
+ + { "dsn", opt_bool, &dsn },
+ +#endif
diff --git a/mail-mta/exim/files/exim-4.77-as-needed-ldflags.patch b/mail-mta/exim/files/exim-4.77-as-needed-ldflags.patch
new file mode 100644
index 00000000..4eac9aa3
--- /dev/null
+++ b/mail-mta/exim/files/exim-4.77-as-needed-ldflags.patch
@@ -0,0 +1,144 @@
+https://bugs.gentoo.org/show_bug.cgi?id=352265
+
+Make sure LDFLAGS comes first, such that all libraries are considered,
+and not discarded when --as-needed is in effect.
+
+https://bugs.gentoo.org/show_bug.cgi?id=391279
+
+Use LDFLAGS for all targets, not just the exim binary, such that
+--as-needed works as well.
+
+
+--- OS/Makefile-Base
++++ OS/Makefile-Base
+@@ -327,12 +327,12 @@
+ $(FE)$(CC) -c $(CFLAGS) $(INCLUDE) $(IPV6_INCLUDE) $(TLS_INCLUDE) version.c
+ rm -f exim
+ @echo "$(LNCC) -o exim"
+- $(FE)$(PURIFY) $(LNCC) -o exim $(LFLAGS) $(OBJ_EXIM) version.o \
++ $(FE)$(PURIFY) $(LNCC) -o exim $(LDFLAGS) $(OBJ_EXIM) version.o \
+ routers/routers.a transports/transports.a lookups/lookups.a \
+ auths/auths.a pdkim/pdkim.a \
+ $(LIBRESOLV) $(LIBS) $(LIBS_EXIM) $(IPV6_LIBS) $(EXTRALIBS) \
+ $(EXTRALIBS_EXIM) $(DBMLIB) $(LOOKUP_LIBS) $(AUTH_LIBS) \
+- $(PERL_LIBS) $(TLS_LIBS) $(PCRE_LIBS) $(LDFLAGS)
++ $(PERL_LIBS) $(TLS_LIBS) $(PCRE_LIBS) $(LFLAGS)
+ @if [ x"$(STRIP_COMMAND)" != x"" ]; then \
+ echo $(STRIP_COMMAND) exim; \
+ $(STRIP_COMMAND) exim; \
+@@ -340,8 +340,8 @@
+
+ exim_dumpdb: $(OBJ_DUMPDB)
+ @echo "$(LNCC) -o exim_dumpdb"
+- $(FE)$(LNCC) $(CFLAGS) $(INCLUDE) -o exim_dumpdb $(LFLAGS) $(OBJ_DUMPDB) \
+- $(LIBS) $(EXTRALIBS) $(DBMLIB)
++ $(FE)$(LNCC) $(CFLAGS) $(INCLUDE) -o exim_dumpdb $(LDFLAGS) $(OBJ_DUMPDB) \
++ $(LIBS) $(EXTRALIBS) $(DBMLIB) $(LFLAGS)
+ @if [ x"$(STRIP_COMMAND)" != x"" ]; then \
+ echo $(STRIP_COMMAND) exim_dumpdb; \
+ $(STRIP_COMMAND) exim_dumpdb; \
+@@ -355,8 +355,8 @@
+
+ exim_fixdb: $(OBJ_FIXDB) auths/auths.a
+ @echo "$(LNCC) -o exim_fixdb"
+- $(FE)$(LNCC) $(CFLAGS) $(INCLUDE) -o exim_fixdb $(LFLAGS) $(OBJ_FIXDB) \
+- auths/auths.a $(LIBS) $(EXTRALIBS) $(DBMLIB)
++ $(FE)$(LNCC) $(CFLAGS) $(INCLUDE) -o exim_fixdb $(LDFLAGS) $(OBJ_FIXDB) \
++ auths/auths.a $(LIBS) $(EXTRALIBS) $(DBMLIB) $(LFLAGS)
+ @if [ x"$(STRIP_COMMAND)" != x"" ]; then \
+ echo $(STRIP_COMMAND) exim_fixdb; \
+ $(STRIP_COMMAND) exim_fixdb; \
+@@ -370,8 +370,8 @@
+
+ exim_tidydb: $(OBJ_TIDYDB)
+ @echo "$(LNCC) -o exim_tidydb"
+- $(FE)$(LNCC) $(CFLAGS) $(INCLUDE) -o exim_tidydb $(LFLAGS) $(OBJ_TIDYDB) \
+- $(LIBS) $(EXTRALIBS) $(DBMLIB)
++ $(FE)$(LNCC) $(CFLAGS) $(INCLUDE) -o exim_tidydb $(LDFLAGS) $(OBJ_TIDYDB) \
++ $(LIBS) $(EXTRALIBS) $(DBMLIB) $(LFLAGS)
+ @if [ x"$(STRIP_COMMAND)" != x"" ]; then \
+ echo $(STRIP_COMMAND) exim_tidydb; \
+ $(STRIP_COMMAND) exim_tidydb; \
+@@ -383,8 +383,8 @@
+
+ exim_dbmbuild: exim_dbmbuild.o
+ @echo "$(LNCC) -o exim_dbmbuild"
+- $(FE)$(LNCC) -o exim_dbmbuild $(LFLAGS) exim_dbmbuild.o \
+- $(LIBS) $(EXTRALIBS) $(DBMLIB)
++ $(FE)$(LNCC) -o exim_dbmbuild $(LDFLAGS) exim_dbmbuild.o \
++ $(LIBS) $(EXTRALIBS) $(DBMLIB) $(LFLAGS)
+ @if [ x"$(STRIP_COMMAND)" != x"" ]; then \
+ echo $(STRIP_COMMAND) exim_dbmbuild; \
+ $(STRIP_COMMAND) exim_dbmbuild; \
+@@ -398,8 +398,8 @@
+ @echo "$(CC) exim_lock.c"
+ $(FE)$(CC) -c $(CFLAGS) $(INCLUDE) exim_lock.c
+ @echo "$(LNCC) -o exim_lock"
+- $(FE)$(LNCC) -o exim_lock $(LFLAGS) exim_lock.o \
+- $(LIBS) $(EXTRALIBS)
++ $(FE)$(LNCC) -o exim_lock $(LDFLAGS) exim_lock.o \
++ $(LIBS) $(EXTRALIBS) $(LFLAGS)
+ @if [ x"$(STRIP_COMMAND)" != x"" ]; then \
+ echo $(STRIP_COMMAND) exim_lock; \
+ $(STRIP_COMMAND) exim_lock; \
+@@ -429,9 +429,9 @@
+ $(FE)$(CC) -o em_version.o -c \
+ $(CFLAGS) $(XINCLUDE) -I. ../exim_monitor/em_version.c
+ @echo "$(LNCC) -o eximon.bin"
+- $(FE)$(PURIFY) $(LNCC) -o eximon.bin em_version.o $(LFLAGS) $(XLFLAGS) \
++ $(FE)$(PURIFY) $(LNCC) -o eximon.bin em_version.o $(LDFLAGS) $(XLFLAGS) \
+ $(OBJ_MONBIN) -lXaw -lXmu -lXt -lXext -lX11 $(PCRE_LIBS) \
+- $(LIBS) $(LIBS_EXIMON) $(EXTRALIBS) $(EXTRALIBS_EXIMON) -lc
++ $(LIBS) $(LIBS_EXIMON) $(EXTRALIBS) $(EXTRALIBS_EXIMON) -lc $(LFLAGS)
+ @if [ x"$(STRIP_COMMAND)" != x"" ]; then \
+ echo $(STRIP_COMMAND) eximon.bin; \
+ $(STRIP_COMMAND) eximon.bin; \
+@@ -706,9 +706,9 @@
+ test_dbfn: config.h dbfn.c dummies.o sa-globals.o sa-os.o store.o \
+ string.o tod.o version.o
+ $(CC) -c $(CFLAGS) $(INCLUDE) -DSTAND_ALONE dbfn.c
+- $(LNCC) -o test_dbfn $(LFLAGS) dbfn.o \
++ $(LNCC) -o test_dbfn $(LDFLAGS) dbfn.o \
+ dummies.o sa-globals.o sa-os.o store.o string.o \
+- tod.o version.o $(LIBS) $(DBMLIB)
++ tod.o version.o $(LIBS) $(DBMLIB) $(LFLAGS)
+ rm -f dbfn.o
+
+ test_host: config.h child.c host.c dns.c dummies.c sa-globals.o os.o \
+@@ -717,28 +717,28 @@
+ $(CC) -c $(CFLAGS) $(INCLUDE) -DSTAND_ALONE -DTEST_HOST host.c
+ $(CC) -c $(CFLAGS) $(INCLUDE) -DSTAND_ALONE -DTEST_HOST dns.c
+ $(CC) -c $(CFLAGS) $(INCLUDE) -DSTAND_ALONE -DTEST_HOST dummies.c
+- $(LNCC) -o test_host $(LFLAGS) \
++ $(LNCC) -o test_host $(LDFLAGS) \
+ host.o child.o dns.o dummies.o sa-globals.o os.o store.o string.o \
+- tod.o tree.o $(LIBS) $(LIBRESOLV)
++ tod.o tree.o $(LIBS) $(LIBRESOLV) $(LFLAGS)
+ rm -f child.o dummies.o host.o dns.o
+
+ test_os: os.h os.c dummies.o sa-globals.o store.o string.o tod.o
+ $(CC) -c $(CFLAGS) $(INCLUDE) -DSTAND_ALONE os.c
+- $(LNCC) -o test_os $(LFLAGS) os.o dummies.o \
+- sa-globals.o store.o string.o tod.o $(LIBS)
++ $(LNCC) -o test_os $(LDFLAGS) os.o dummies.o \
++ sa-globals.o store.o string.o tod.o $(LIBS) $(LFLAGS)
+ rm -f os.o
+
+ test_parse: config.h parse.c dummies.o sa-globals.o \
+ store.o string.o tod.o version.o
+ $(CC) -c $(CFLAGS) $(INCLUDE) -DSTAND_ALONE parse.c
+- $(LNCC) -o test_parse $(LFLAGS) parse.o \
+- dummies.o sa-globals.o store.o string.o tod.o version.o
++ $(LNCC) -o test_parse $(LDFLAGS) parse.o \
++ dummies.o sa-globals.o store.o string.o tod.o version.o $(LFLAGS)
+ rm -f parse.o
+
+ test_string: config.h string.c dummies.o sa-globals.o store.o tod.o
+ $(CC) -c $(CFLAGS) $(INCLUDE) -DSTAND_ALONE string.c
+- $(LNCC) -o test_string $(LFLAGS) -DSTAND_ALONE string.o \
+- dummies.o sa-globals.o store.o tod.o $(LIBS)
++ $(LNCC) -o test_string $(LDFLAGS) -DSTAND_ALONE string.o \
++ dummies.o sa-globals.o store.o tod.o $(LIBS) $(LFLAGS)
+ rm -f string.o
+
+ # End
diff --git a/mail-mta/exim/files/exim-4.77-makefile-freebsd.patch b/mail-mta/exim/files/exim-4.77-makefile-freebsd.patch
new file mode 100644
index 00000000..f3c03323
--- /dev/null
+++ b/mail-mta/exim/files/exim-4.77-makefile-freebsd.patch
@@ -0,0 +1,48 @@
+--- OS/Makefile-FreeBSD
++++ OS/Makefile-FreeBSD
+@@ -1,12 +1,10 @@
+-# Exim: OS-specific make file for FreeBSD
+-# There's no setting of CFLAGS here, to allow the system default
+-# for "make" to be the default.
+-
+-PORTOBJFORMAT!= test -x /usr/bin/objformat && /usr/bin/objformat || echo aout
+-
+-CHOWN_COMMAND=/usr/sbin/chown
+-STRIP_COMMAND=/usr/bin/strip
+-CHMOD_COMMAND=/bin/chmod
++# Exim: OS-specific FreeBSD make file, modified for Gentoo Prefix
++
++
++BASENAME_COMMAND=look_for_it
++CHOWN_COMMAND=look_for_it
++CHGRP_COMMAND=look_for_it
++CHMOD_COMMAND=look_for_it
+
+ HAVE_SA_LEN=YES
+
+@@ -18,23 +16,12 @@
+ # Dynamicly loaded modules need to be built with -fPIC
+ CFLAGS_DYNAMIC=-shared -rdynamic -fPIC
+
+-# FreeBSD always ships with Berkeley DB
++DBMLIB = -ldb
+ USE_DB=yes
+
+-# This code for building outside ports suggested by Richard Clayton
+-.ifdef X11BASE
+-X11=${X11BASE}
+-.elifdef LOCALBASE
+-X11=$(LOCALBASE)
+-.else
+-X11=/usr/local
+-.endif
+-
++X11=/usr/X11R6
+ XINCLUDE=-I$(X11)/include
+ XLFLAGS=-L$(X11)/lib
+-.if ${PORTOBJFORMAT} == "elf"
+-XLFLAGS+=-Wl,-rpath,${X11}/lib
+-.endif
+ X11_LD_LIB=$(X11)/lib
+
+ EXIWHAT_PS_ARG=-ax
diff --git a/mail-mta/exim/files/exim-4.80-spool-mail-group.patch b/mail-mta/exim/files/exim-4.80-spool-mail-group.patch
new file mode 100644
index 00000000..6f88d853
--- /dev/null
+++ b/mail-mta/exim/files/exim-4.80-spool-mail-group.patch
@@ -0,0 +1,27 @@
+Change default such that we run on a stock Gentoo system. Bug #438606
+
+--- src/configure.default
++++ src/configure.default
+@@ -674,8 +674,9 @@
+ # BSD mailbox format. By default it will be run under the uid and gid of the
+ # local user, and requires the sticky bit to be set on the /var/mail directory.
+ # Some systems use the alternative approach of running mail deliveries under a
+-# particular group instead of using the sticky bit. The commented options below
+-# show how this can be done.
++# particular group instead of using the sticky bit. This is also the
++# default case on Gentoo, therefore group and mode are set below.
++# Comment them out, to get the default behaviour.
+
+ local_delivery:
+ driver = appendfile
+@@ -683,8 +684,8 @@
+ delivery_date_add
+ envelope_to_add
+ return_path_add
+-# group = mail
+-# mode = 0660
++ group = mail
++ mode = 0660
+
+
+ # This transport is used for handling pipe deliveries generated by alias or
diff --git a/mail-mta/exim/files/exim-4.82-makefile-freebsd.patch b/mail-mta/exim/files/exim-4.82-makefile-freebsd.patch
new file mode 100644
index 00000000..9693d494
--- /dev/null
+++ b/mail-mta/exim/files/exim-4.82-makefile-freebsd.patch
@@ -0,0 +1,45 @@
+--- OS/Makefile-FreeBSD.orig 2013-09-30 19:59:09.000000000 +0200
++++ OS/Makefile-FreeBSD 2013-09-30 20:01:22.000000000 +0200
+@@ -1,10 +1,8 @@
+-# Exim: OS-specific make file for FreeBSD
+-# There's no setting of CFLAGS here, to allow the system default
+-# for "make" to be the default.
+-
+-CHOWN_COMMAND=/usr/sbin/chown
+-STRIP_COMMAND=/usr/bin/strip
+-CHMOD_COMMAND=/bin/chmod
++# Exim: OS-specific FreeBSD make file, modified for Gentoo Prefix
++
++CHOWN_COMMAND=look_for_it
++STRIP_COMMAND=
++CHMOD_COMMAND=look_for_it
+
+ HAVE_SA_LEN=YES
+
+@@ -15,17 +13,9 @@
+ CFLAGS_DYNAMIC=-shared -rdynamic -fPIC
+
+ # FreeBSD always ships with Berkeley DB
++DBMLIB = -ldb
+ USE_DB=yes
+
+-# This code for building outside ports suggested by Richard Clayton
+-.ifdef X11BASE
+-X11=${X11BASE}
+-.elifdef LOCALBASE
+-X11=$(LOCALBASE)
+-.else
+-X11=/usr/local
+-.endif
+-
+ # nb: FreeBSD is entirely elf; objformat was removed prior to FreeBSD 7
+ # http://www.freebsd.org/cgi/cvsweb.cgi/src/usr.bin/objformat/Attic/objformat.c
+ # deleted Jan 2007.
+@@ -37,6 +27,7 @@
+ # switch to default to ELF came with FreeBSD 3. elf(5) claims ELF support
+ # introduced in FreeBSD 2.2.6.
+ #
++X11=/usr/X11R6
+ XINCLUDE=-I$(X11)/include
+ XLFLAGS=-L$(X11)/lib -Wl,-rpath,${X11}/lib
+ X11_LD_LIB=$(X11)/lib
diff --git a/mail-mta/exim/files/exim-submission.socket b/mail-mta/exim/files/exim-submission.socket
new file mode 100644
index 00000000..b9593e2e
--- /dev/null
+++ b/mail-mta/exim/files/exim-submission.socket
@@ -0,0 +1,10 @@
+[Unit]
+Description=Exim Mail Transfer Agent (message submission)
+Conflicts=exim.service
+
+[Socket]
+ListenStream=587
+Accept=yes
+
+[Install]
+WantedBy=sockets.target
diff --git a/mail-mta/exim/files/exim-submission_at.service b/mail-mta/exim/files/exim-submission_at.service
new file mode 100644
index 00000000..4f90cd83
--- /dev/null
+++ b/mail-mta/exim/files/exim-submission_at.service
@@ -0,0 +1,11 @@
+# It doesn't make sense for this to be separate from exim@.service
+# However, I couldn't think of a way to have two .socket files point
+# to it ([Socket] Service= is rejected if Accept=yes is set).
+
+[Unit]
+Description=Exim Mail Daemon per-connection server (message submission)
+
+[Service]
+ExecStart=-/usr/bin/exim -bs
+StandardInput=socket
+StandardError=syslog
diff --git a/mail-mta/exim/files/exim.confd b/mail-mta/exim/files/exim.confd
new file mode 100644
index 00000000..1534d9df
--- /dev/null
+++ b/mail-mta/exim/files/exim.confd
@@ -0,0 +1,5 @@
+# Command-line options for running exim
+EXIM_OPTS="-bd -q15m"
+
+# Additional flags passed to exim_tidydb upon start (e.g. -t 7d)
+TIDY_OPTS=""
diff --git a/mail-mta/exim/files/exim.logrotate b/mail-mta/exim/files/exim.logrotate
new file mode 100644
index 00000000..f54f8c47
--- /dev/null
+++ b/mail-mta/exim/files/exim.logrotate
@@ -0,0 +1,9 @@
+/var/log/exim/exim*.log {
+ daily
+ missingok
+ rotate 28
+ compress
+ delaycompress
+ notifempty
+ create 640 mail mail
+}
diff --git a/mail-mta/exim/files/exim.rc8 b/mail-mta/exim/files/exim.rc8
new file mode 100644
index 00000000..f84d772e
--- /dev/null
+++ b/mail-mta/exim/files/exim.rc8
@@ -0,0 +1,30 @@
+#!/sbin/runscript
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/mail-mta/exim/files/exim.rc8,v 1.1 2013/10/08 18:16:18 grobian Exp $
+
+extra_started_commands="reload"
+
+depend() {
+ need logger
+ use antivirus net
+ provide mta
+}
+
+start() {
+ ebegin "Starting ${SVCNAME}"
+ start-stop-daemon --start --exec /usr/sbin/exim --pidfile /run/${SVCNAME}.pid -- -C /etc/exim/${SVCNAME}.conf ${EXIM_OPTS:--bd -q15m}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping ${SVCNAME}"
+ start-stop-daemon --stop --pidfile /run/${SVCNAME}.pid --name exim
+ eend $?
+}
+
+reload() {
+ ebegin "Reloading ${SVCNAME}"
+ start-stop-daemon --signal HUP --pidfile /run/${SVCNAME}.pid --name exim
+ eend $?
+}
diff --git a/mail-mta/exim/files/exim.rc9 b/mail-mta/exim/files/exim.rc9
new file mode 100644
index 00000000..c88f6533
--- /dev/null
+++ b/mail-mta/exim/files/exim.rc9
@@ -0,0 +1,46 @@
+#!/sbin/runscript
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/mail-mta/exim/files/exim.rc9,v 1.1 2015/05/05 12:55:34 grobian Exp $
+
+extra_started_commands="reload"
+
+depend() {
+ need logger
+ use antivirus net
+ provide mta
+}
+
+tidy_dbs() {
+ local spooldir=$(/usr/sbin/exim -C /etc/exim/${SVCNAME}.conf -bP -n spool_directory)
+ local db
+ local ret=0
+ ebegin "Tidying hints databases in ${spooldir}/db"
+ for db in "${spooldir}"/db/* ; do
+ [[ ${db} == *".lockfile" || ${db} == *"*" ]] && continue
+ /usr/sbin/exim_tidydb ${TIDY_OPTS} "${spooldir}" ${db##*/} > /dev/null
+ : $((ret += $?))
+ done
+ eend ${ret}
+}
+
+start() {
+ # if you use multiple instances, make sure you set spool_directory
+ # in the configfile
+ tidy_dbs
+ ebegin "Starting ${SVCNAME}"
+ start-stop-daemon --start --exec /usr/sbin/exim --pidfile /run/${SVCNAME}.pid -- -C /etc/exim/${SVCNAME}.conf ${EXIM_OPTS:--bd -q15m}
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping ${SVCNAME}"
+ start-stop-daemon --stop --pidfile /run/${SVCNAME}.pid --name exim
+ eend $?
+}
+
+reload() {
+ ebegin "Reloading ${SVCNAME}"
+ start-stop-daemon --signal HUP --pidfile /run/${SVCNAME}.pid --name exim
+ eend $?
+}
diff --git a/mail-mta/exim/files/exim.service b/mail-mta/exim/files/exim.service
new file mode 100644
index 00000000..c8a61cdc
--- /dev/null
+++ b/mail-mta/exim/files/exim.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Exim Mail Transport Agent
+After=network.target
+
+[Service]
+Environment=QUEUE=15m
+ExecStart=/usr/sbin/exim -bdf -q${QUEUE}
+ExecReload=/bin/kill -HUP $MAINPID
+PrivateTmp=true
+
+[Install]
+WantedBy=multi-user.target
diff --git a/mail-mta/exim/files/exim.socket b/mail-mta/exim/files/exim.socket
new file mode 100644
index 00000000..36d28684
--- /dev/null
+++ b/mail-mta/exim/files/exim.socket
@@ -0,0 +1,10 @@
+[Unit]
+Description=Exim Mail Transfer Agent
+Conflicts=exim.service
+
+[Socket]
+ListenStream=25
+Accept=yes
+
+[Install]
+WantedBy=sockets.target
diff --git a/mail-mta/exim/files/exim_482_dsn_1_3.patch b/mail-mta/exim/files/exim_482_dsn_1_3.patch
new file mode 100644
index 00000000..c3006996
--- /dev/null
+++ b/mail-mta/exim/files/exim_482_dsn_1_3.patch
@@ -0,0 +1,1212 @@
+Modified for 4.82 by Gentoo -- not the official patch from
+http://sourceforge.net/projects/eximdsn/
+
+diff -Naur exim-4.82_RC5.orig/README.DSN exim-4.82_RC5/README.DSN
+--- exim-4.82_RC5.orig/README.DSN 1970-01-01 01:00:00.000000000 +0100
++++ exim-4.82_RC5/README.DSN 2013-10-27 21:47:32.000000000 +0100
+@@ -0,0 +1,118 @@
++Exim DSN Patch (4.76)
++---------------------
++
++This patch 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.
++
++This patch is distributed in the hope that it will be useful,
++but WITHOUT ANY WARRANTY; without even the implied warranty of
++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++GNU General Public License for more details.
++
++You should have received a copy of the GNU General Public License
++along with this patch; if not, write to the Free Software
++Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
++
++Install
++-------
++cd into the source tree for a vanilla exim
++
++patch -p1 </path/to/patch/file.patch
++
++Example :-
++[root@linuxbuild exim-4.72-test]# patch -p1 <../exim.dsn.patch-472
++
++Expected Output :-
++patching file README.DSN
++patching file src/config.h.defaults
++patching file src/deliver.c
++patching file src/exim.c
++patching file src/exim.h
++patching file src/globals.c
++patching file src/globals.h
++patching file src/local_scan.h
++patching file src/macros.h
++patching file src/readconf.c
++patching file src/route.c
++patching file src/smtp_in.c
++patching file src/spool_in.c
++patching file src/spool_out.c
++patching file src/structs.h
++patching file src/transport.c
++patching file src/transports/smtp.c
++
++
++This patch can be included / excluded from the compilation by use of the #define SUPPORT_DSN
++which gets added into src/config.h.defaults & src/EDITME by the patch.
++
++Use
++---
++
++The facility (once compiled in) can be turned on for a particular router via the
++dsn_process directive Eg :-
++
++dest_delivery_int:
++ driver = manualroute
++ domains = +relay_to_domains
++ condition = ${if eq {${lc:$sender_address_domain}}\
++ {domain.com}\
++ {yes}{no}\
++ }
++ dsn_process
++ hide route_data = ${lc:${extract{mailHost}{$address_data}{$value}{}}}
++ transport = remote_smtp
++
++Exim will produce 1 of 2 DSN's back to the originator, or pass on the DSN request.
++The 2 DSN's will either contain (relayed via non "Remote SMTP" router) or
++(relayed to non-DSN-aware mailer) depending on if the delivery was VIA an SMTP
++transport or not.
++
++
++Credits
++-------
++
++The original work for the patch was done by Philip Hazel in Exim 3
++
++The extract was taken and re-applied to Exim 4 by the following :-
++Phil Bingham (phil.bingham@cwipapps.net)
++Steve Falla (steve.falla@cwipapps.net)
++Ray Edah (ray.edah@cwipapps.net)
++Andrew Johnson (andrew.johnson@cwippaps.net)
++Adrian Hungate (adrian.hungate@cwipapps.net)
++
++Now Primarily maintained by :-
++Andrew Johnson (andrew.johnson@cwippaps.net)
++
++Contributions
++-------------
++Andrey J. Melnikoff (TEMHOTA) (temnota@kmv.ru)
++
++
++ChangeLog
++---------
++
++14-Apr-2006 : Changed subject to "Delivery Status Notification"
++
++17-May-2006 : debug_printf in spool-in.c were not wrapped with #ifndef COMPILE_UTILITY
++ thanks to Andrey J. Melnikoff for this information
++
++12-Sep-2006 : Now supports Exim 4.63
++
++12-Sep-2006 : src/EDITME did not include the #define SUPPORT_DSN as stated
++ in the documentation, this has now been corrected
++ thanks to Robert Kehl for this information
++
++28-Jul-2008 : New version for exim 4.69 released.
++
++02-Jul-2010 : New version for exim 4.72 released.
++
++20-May-2011 : New version for exim 4.76 released.
++
++
++Support for this patch (limited though it is) will only be provided through the SourceForge
++project page (http://sourceforge.net/projects/eximdsn/)
++
++--
++Andrew Johnson Cable & Wireless
+diff -Naur exim-4.82_RC5.orig/src/config.h.defaults exim-4.82_RC5/src/config.h.defaults
+--- exim-4.82_RC5.orig/src/config.h.defaults 2013-10-27 21:46:25.000000000 +0100
++++ exim-4.82_RC5/src/config.h.defaults 2013-10-27 21:47:32.000000000 +0100
+@@ -136,6 +136,7 @@
+ #define SUPPORT_MOVE_FROZEN_MESSAGES
+ #define SUPPORT_PAM
+ #define SUPPORT_TLS
++#define SUPPORT_DSN
+ #define SUPPORT_TRANSLATE_IP_ADDRESS
+
+ #define SYSLOG_LOG_PID
+diff -Naur exim-4.82_RC5.orig/src/deliver.c exim-4.82_RC5/src/deliver.c
+--- exim-4.82_RC5.orig/src/deliver.c 2013-10-27 21:46:25.000000000 +0100
++++ exim-4.82_RC5/src/deliver.c 2013-10-27 21:47:32.000000000 +0100
+@@ -63,6 +63,9 @@
+ static address_item *addr_remote = NULL;
+ static address_item *addr_route = NULL;
+ static address_item *addr_succeed = NULL;
++#ifdef SUPPORT_DSN
++static address_item *addr_dsntmp = NULL;
++#endif
+
+ static FILE *message_log = NULL;
+ static BOOL update_spool;
+@@ -2966,6 +2969,15 @@
+ addr->flags |= af_prdr_used; break;
+ #endif
+
++ #ifdef SUPPORT_DSN
++ case 'D':
++ if (addr == NULL) break;
++ addr->dsn_aware = (*ptr)? string_copy(ptr) : string_copy(" ");
++ while (*ptr++);
++ DEBUG(D_deliver) debug_printf("DSN read: addr->dsn_aware = %s\n", addr->dsn_aware);
++ break;
++ #endif
++
+ case 'A':
+ if (addr == NULL)
+ {
+@@ -4074,6 +4086,15 @@
+ if (addr->flags & af_prdr_used) rmt_dlv_checked_write(fd, "P", 1);
+ #endif
+
++ #ifdef SUPPORT_DSN
++ if (addr->dsn_aware == NULL)
++ addr->dsn_aware = string_copy(" ");
++ DEBUG(D_deliver) debug_printf("DSN write: addr->dsn_aware = %s\n", addr->dsn_aware);
++ sprintf(big_buffer, "D%s", addr->dsn_aware);
++ DEBUG(D_deliver) debug_printf("DSN write: big_buffer = %s (%d)\n", big_buffer, strlen(big_buffer)+1);
++ write(fd, big_buffer, strlen(big_buffer)+1);
++ #endif
++
+ /* Retry information: for most success cases this will be null. */
+
+ for (r = addr->retries; r != NULL; r = r->next)
+@@ -5219,6 +5240,14 @@
+ if (r->pno >= 0)
+ new->onetime_parent = recipients_list[r->pno].address;
+
++ #ifdef SUPPORT_DSN
++ /* If DSN support is enabled, set the dsn flags and the original receipt
++ to be passed on to other DSN enabled MTAs */
++ new->dsn_flags = r->dsn_flags & rf_dsnflags;
++ new->dsn_orcpt = r->orcpt;
++ debug_printf("DSN (deliver): orcpt: %s flags: %d\n", new->dsn_orcpt, new->dsn_flags);
++ #endif
++
+ switch (process_recipients)
+ {
+ /* RECIP_DEFER is set when a system filter freezes a message. */
+@@ -6163,6 +6192,12 @@
+ regex_must_compile(US"\\n250[\\s\\-]PRDR(\\s|\\n|$)", FALSE, TRUE);
+ #endif
+
++ #ifdef SUPPORT_DSN
++ /* Set the regex to check for DSN support on remote MTA */
++ if (regex_DSN == NULL) regex_DSN =
++ regex_must_compile(US"\\n250[\\s\\-]DSN(\\s|\\n|$)", FALSE, TRUE);
++ #endif
++
+ /* Now sort the addresses if required, and do the deliveries. The yield of
+ do_remote_deliveries is FALSE when mua_wrapper is set and all addresses
+ cannot be delivered in one transaction. */
+@@ -6267,6 +6302,179 @@
+
+ else if (!dont_deliver) retry_update(&addr_defer, &addr_failed, &addr_succeed);
+
++#ifdef SUPPORT_DSN
++/* ********** philb - Send DSN for successful messages */
++
++addr_dsntmp = addr_succeed;
++
++while(addr_dsntmp != NULL)
++{
++ BOOL dsn_sendmessage = FALSE;
++ uschar dsnmsgbuf[4096];
++
++ DEBUG(D_deliver)
++ debug_printf("DSN: processing router : %s\n", addr_dsntmp->router->name);
++
++ DEBUG(D_deliver)
++ debug_printf("DSN: processing successful delivery address: %s\n", addr_dsntmp->address);
++
++ if (testflag(addr_dsntmp, af_ignore_error))
++ {
++ DEBUG(D_deliver)
++ debug_printf("DSN: Ignore error for: %s\n", addr_dsntmp->address);
++ }
++ else
++ {
++ DEBUG(D_deliver) debug_printf("DSN: Checking Flag\n");
++ if (addr_dsntmp->dsn_aware == NULL) {
++ DEBUG(D_deliver) debug_printf("DSN: dsn_aware was NULL, setting to space at %s %d\n", __FILE__, __LINE__);
++ addr_dsntmp->dsn_aware = string_copy(" ");
++ }
++ DEBUG(D_deliver) debug_printf("DSN: Sender_address: %s\n", sender_address);
++ DEBUG(D_deliver) debug_printf("DSN: orcpt: %s flags: %d\n", addr_dsntmp->dsn_orcpt, addr_dsntmp->dsn_flags);
++ DEBUG(D_deliver) debug_printf("DSN: envid: %s ret: %d\n", dsn_envid, dsn_ret);
++ DEBUG(D_deliver) debug_printf("DSN: Remote SMTP server supports DSN: %s\n", addr_dsntmp->dsn_aware);
++
++ /* Process the flags */
++ if((addr_dsntmp->dsn_flags & rf_dsnflags) != 0)
++ {
++ /* We've got at least one flag set */
++
++ /* set flag so we don't send bounces */
++ setflag(addr_dsntmp, af_ignore_error);
++
++ if((addr_dsntmp->dsn_flags & rf_notify_never) != 0)
++ {
++ DEBUG(D_deliver) debug_printf("DSN: NEVER FLAG\n");
++
++ /* nothing to do here */
++ }
++
++ if((addr_dsntmp->dsn_flags & rf_notify_success) != 0)
++ {
++ DEBUG(D_deliver) debug_printf("DSN: SUCCESS FLAG\n");
++
++ dsn_sendmessage = TRUE;
++ }
++
++ if((addr_dsntmp->dsn_flags & rf_notify_failure) != 0)
++ {
++ DEBUG(D_deliver) debug_printf("DSN: FAILURE FLAG\n");
++
++ /* allow bounce messages */
++ clearflag(addr_dsntmp, af_ignore_error);
++ }
++
++ if((addr_dsntmp->dsn_flags & rf_notify_delay) != 0)
++ {
++ DEBUG(D_deliver) debug_printf("DSN: DELAY FLAG\n");
++
++ /* hmm, what to do here? */
++ }
++ }
++
++ if ((addr_dsntmp->dsn_aware != 0) && (addr_dsntmp->dsn_aware[0] != 'Y') && (dsn_sendmessage == TRUE) && (addr_dsntmp->router->dsn_process == TRUE))
++ {
++ pid_t pid;
++ int fd;
++
++ /* remote MTA does not support DSN, so we need to send message */
++
++ /* create exim process to send message */
++ pid = child_open_exim(&fd);
++
++ DEBUG(D_deliver) debug_printf("DSN: child_open_exim returns: %d\n", pid);
++
++ if (pid < 0) /* Creation of child failed */
++ {
++ log_write(0, LOG_MAIN|LOG_PANIC_DIE, "Process %d (parent %d) failed to "
++ "create child process to send failure message: %s", getpid(),
++ getppid(), strerror(errno));
++
++ DEBUG(D_deliver) debug_printf("DSN: child_open_exim failed\n");
++
++ }
++ else /* Creation of child succeeded */
++ {
++ FILE *f = fdopen(fd, "wb");
++ int topt = topt_add_return_path;
++ uschar boundaryStr[64];
++
++ DEBUG(D_deliver) debug_printf("sending error message to: %s\n", sender_address);
++
++ /* build unique id for MIME boundary */
++ snprintf(boundaryStr, 63, "%d-cwdsn-%d", pid, rand());
++ DEBUG(D_deliver) debug_printf("DSN: MIME boundary: %s\n", boundaryStr);
++
++ /* if the sender doesn't want the whole message returned, don't send the body */
++ if (dsn_ret != dsn_ret_full) topt |= topt_no_body;
++
++ if (errors_reply_to != NULL) fprintf(f,"Reply-To: %s\n", errors_reply_to);
++
++ fprintf(f,"Auto-Submitted: auto-generated\n");
++ fprintf(f,"From: Mail Delivery System <Mailer-Daemon@%s>\n", qualify_domain_sender);
++ fprintf(f,"To: %s\n", sender_address);
++ fprintf(f,"Subject: Delivery Status Notification\n");
++ fprintf(f,"Content-Type: multipart/report; report-type=delivery-status; boundary=%s\n", boundaryStr);
++ fprintf(f,"MIME-Version: 1.0\n\n");
++
++ fprintf(f,"--%s\n", boundaryStr);
++ fprintf(f,"Content-type: text/plain; charset=us-ascii\n\n");
++
++ fprintf(f,"This message was created automatically by mail delivery software.\n");
++ fprintf(f," ----- The following addresses had successful delivery notifications -----\n");
++/* AH: added specific message for non "Remote SMTP" situations */
++ if (addr_dsntmp->dsn_aware[0] == 'N') {
++ fprintf(f,"<%s> (relayed to non-DSN-aware mailer)\n\n", addr_dsntmp->address);
++ } else {
++ fprintf(f,"<%s> (relayed via non \"Remote SMTP\" router)\n\n", addr_dsntmp->address);
++ }
++
++ fprintf(f,"--%s\n", boundaryStr);
++ fprintf(f,"Content-type: message/delivery-status\n\n");
++
++ if (dsn_envid) { /* Test for NULL added by GC */
++ fprintf(f,"Original-Envelope-Id: %s\n", dsn_envid);
++ }
++ fprintf(f,"Reporting-MTA: dns; %s\n", qualify_domain_sender);
++ if (addr_dsntmp->dsn_orcpt) { /* Test for NULL added by GC */
++ fprintf(f,"Original-Recipient: %s\n", addr_dsntmp->dsn_orcpt);
++ }
++ fprintf(f,"Action: delivered\n\n");
++
++ fprintf(f,"--%s\n", boundaryStr);
++ fprintf(f,"Content-type: message/rfc822\n\n");
++
++ fflush(f);
++ transport_filter_argv = NULL; /* Just in case */
++ return_path = sender_address; /* In case not previously set */
++
++ /* Write the original email out */
++ transport_write_message(NULL, fileno(f), topt, 2048, NULL, NULL, NULL, NULL, NULL, 0);
++ fflush(f);
++
++ fprintf(f,"\n");
++ fprintf(f,"--%s--\n", boundaryStr);
++
++ fflush(f);
++ fclose(f);
++ rc = child_close(pid, 0); /* Waits for child to close, no timeout */
++ }
++ }
++ else
++ { if (addr_dsntmp->router->dsn_process == TRUE)
++ DEBUG(D_deliver) debug_printf("DSN: *** NOT SENDING DSN SUCCESS Message ***\n");
++ if (addr_dsntmp->router->dsn_process == FALSE)
++ DEBUG(D_deliver) debug_printf("DSN: *** NOT SENDING DSN SUCCESS Message (gagged) ***\n");
++ }
++ }
++
++ addr_dsntmp = addr_dsntmp->next;
++}
++
++/* ********** philb - end of mod */
++#endif
++
+ /* If any addresses failed, we must send a message to somebody, unless
+ af_ignore_error is set, in which case no action is taken. It is possible for
+ several messages to get sent if there are addresses with different
+diff -Naur exim-4.82_RC5.orig/src/EDITME exim-4.82_RC5/src/EDITME
+--- exim-4.82_RC5.orig/src/EDITME 2013-10-27 21:46:25.000000000 +0100
++++ exim-4.82_RC5/src/EDITME 2013-10-27 21:47:32.000000000 +0100
+@@ -192,6 +192,8 @@
+ # least one type of lookup. You should consider whether you want to build
+ # the Exim monitor or not.
+
++# Support DSN
++SUPPORT_DSN=yes
+
+ #------------------------------------------------------------------------------
+ # These settings determine which individual router drivers are included in the
+diff -Naur exim-4.82_RC5.orig/src/exim.c exim-4.82_RC5/src/exim.c
+--- exim-4.82_RC5.orig/src/exim.c 2013-10-27 21:46:25.000000000 +0100
++++ exim-4.82_RC5/src/exim.c 2013-10-27 21:47:32.000000000 +0100
+@@ -831,6 +831,9 @@
+ #ifdef EXPERIMENTAL_REDIS
+ fprintf(f, " Experimental_Redis");
+ #endif
++#ifdef SUPPORT_DSN
++ fprintf(f, " C&W_DSN_1.3");
++#endif
+ fprintf(f, "\n");
+
+ fprintf(f, "Lookups (built-in):");
+@@ -2653,6 +2656,16 @@
+ break;
+ }
+
++ #ifdef SUPPORT_DSN
++ /* -MCD: set the smtp_use_dsn flag; this indicates that the host
++ that exim is connected to supports the esmtp extension DSN */
++ else if (strcmp(argrest, "CD") == 0)
++ {
++ smtp_use_dsn = TRUE;
++ break;
++ }
++ #endif
++
+ /* -MCP: set the smtp_use_pipelining flag; this is useful only when
+ it preceded -MC (see above) */
+
+diff -Naur exim-4.82_RC5.orig/src/globals.c exim-4.82_RC5/src/globals.c
+--- exim-4.82_RC5.orig/src/globals.c 2013-10-27 21:46:25.000000000 +0100
++++ exim-4.82_RC5/src/globals.c 2013-10-27 21:47:32.000000000 +0100
+@@ -124,6 +124,13 @@
+ uschar *local_scan_path = NULL;
+ #endif
+
++#ifdef SUPPORT_DSN
++BOOL dsn = TRUE;
++uschar *dsn_envid = NULL;
++int dsn_ret = 0;
++const pcre *regex_DSN = NULL;
++BOOL smtp_use_dsn = FALSE;
++#endif
+
+ #ifdef SUPPORT_TLS
+ BOOL gnutls_compat_mode = FALSE;
+@@ -341,6 +348,11 @@
+ NULL, /* authenticator */
+ NULL, /* auth_id */
+ NULL, /* auth_sndr */
++ #ifdef SUPPORT_DSN
++ NULL, /* dsn_orcpt */
++ 0, /* dsn_flags */
++ NULL, /* dsn_aware */
++ #endif
+ (uid_t)(-1), /* uid */
+ (gid_t)(-1), /* gid */
+ 0, /* flags */
+@@ -1096,6 +1108,9 @@
+ TRUE, /* verify_sender */
+ FALSE, /* uid_set */
+ FALSE, /* unseen */
++#ifdef SUPPORT_DSN
++ FALSE, /* dsn_process */
++#endif
+
+ self_freeze, /* self_code */
+ (uid_t)(-1), /* uid */
+@@ -1105,6 +1120,7 @@
+ NULL, /* transport instance */
+ NULL, /* pass_router */
+ NULL /* redirect_router */
++
+ };
+
+ uschar *router_name = NULL;
+diff -Naur exim-4.82_RC5.orig/src/globals.h exim-4.82_RC5/src/globals.h
+--- exim-4.82_RC5.orig/src/globals.h 2013-10-27 21:46:25.000000000 +0100
++++ exim-4.82_RC5/src/globals.h 2013-10-27 21:47:32.000000000 +0100
+@@ -130,6 +130,13 @@
+ extern int (*receive_ferror)(void);
+ extern BOOL (*receive_smtp_buffered)(void);
+
++#ifdef SUPPORT_DSN
++extern BOOL dsn; /* FALSE if DSN not to be used */
++extern uschar *dsn_envid; /* DSN envid string */
++extern int dsn_ret; /* DSN ret type*/
++extern const pcre *regex_DSN; /* For recognizing DSN settings */
++extern BOOL smtp_use_dsn; /* Global for passed connections */
++#endif
+
+ /* For clearing, saving, restoring address expansion variables. We have to have
+ the size of this vector set explicitly, because it is referenced from more than
+diff -Naur exim-4.82_RC5.orig/src/local_scan.h exim-4.82_RC5/src/local_scan.h
+--- exim-4.82_RC5.orig/src/local_scan.h 2013-10-27 21:46:25.000000000 +0100
++++ exim-4.82_RC5/src/local_scan.h 2013-10-27 21:47:32.000000000 +0100
+@@ -124,9 +124,13 @@
+ field is always NULL except for one_time aliases that had errors_to on the
+ routers that generated them. */
+
++/* Added the dsn attributes orcpt and dsn_flags for DSN support*/
++
+ typedef struct recipient_item {
+ uschar *address; /* the recipient address */
+ int pno; /* parent number for "one_time" alias, or -1 */
++ uschar *orcpt; /* DSN orcpt */
++ int dsn_flags; /* DSN flags */
+ uschar *errors_to; /* the errors_to address or NULL */
+ #ifdef EXPERIMENTAL_BRIGHTMAIL
+ uschar *bmi_optin;
+diff -Naur exim-4.82_RC5.orig/src/macros.h exim-4.82_RC5/src/macros.h
+--- exim-4.82_RC5.orig/src/macros.h 2013-10-27 21:46:25.000000000 +0100
++++ exim-4.82_RC5/src/macros.h 2013-10-27 21:47:32.000000000 +0100
+@@ -778,6 +778,22 @@
+ #define topt_no_body 0x040 /* Omit body */
+ #define topt_escape_headers 0x080 /* Apply escape check to headers */
+
++ /* Flags for recipient_block, used in DSN support */
++
++ #define rf_onetime 0x01 /* A one-time alias */
++ #define rf_notify_never 0x02 /* NOTIFY= settings */
++ #define rf_notify_success 0x04
++ #define rf_notify_failure 0x08
++ #define rf_notify_delay 0x10
++
++ #define rf_dsnflags (rf_notify_never | rf_notify_success | \
++ rf_notify_failure | rf_notify_delay)
++
++ /* DSN RET types */
++
++ #define dsn_ret_full 1
++ #define dsn_ret_hdrs 2
++
+ /* Codes for the host_find_failed and host_all_ignored options. */
+
+ #define hff_freeze 0
+diff -Naur exim-4.82_RC5.orig/src/readconf.c exim-4.82_RC5/src/readconf.c
+--- exim-4.82_RC5.orig/src/readconf.c 2013-10-27 21:46:25.000000000 +0100
++++ exim-4.82_RC5/src/readconf.c 2013-10-27 21:49:15.000000000 +0100
+@@ -229,6 +229,9 @@
+ /* This option is now a no-op, retained for compability */
+ { "drop_cr", opt_bool, &drop_cr },
+ /*********************************************************/
++#ifdef SUPPORT_DSN
++ { "dsn", opt_bool, &dsn },
++#endif
+ { "dsn_from", opt_stringptr, &dsn_from },
+ { "envelope_to_remove", opt_bool, &envelope_to_remove },
+ { "errors_copy", opt_stringptr, &errors_copy },
+diff -Naur exim-4.82_RC5.orig/src/receive.c exim-4.82_RC5/src/receive.c
+--- exim-4.82_RC5.orig/src/receive.c 2013-10-27 21:46:25.000000000 +0100
++++ exim-4.82_RC5/src/receive.c 2013-10-27 21:47:32.000000000 +0100
+@@ -490,6 +490,8 @@
+ memcpy(recipients_list, oldlist, oldmax * sizeof(recipient_item));
+ }
+
++/* memset added by GC to blank dsn records, etc. */
++memset(&recipients_list[recipients_count], 0, sizeof(recipient_item));
+ recipients_list[recipients_count].address = recipient;
+ recipients_list[recipients_count].pno = pno;
+ #ifdef EXPERIMENTAL_BRIGHTMAIL
+diff -Naur exim-4.82_RC5.orig/src/route.c exim-4.82_RC5/src/route.c
+--- exim-4.82_RC5.orig/src/route.c 2013-10-27 21:46:25.000000000 +0100
++++ exim-4.82_RC5/src/route.c 2013-10-27 21:47:32.000000000 +0100
+@@ -58,6 +58,10 @@
+ (void *)offsetof(router_instance, domains) },
+ { "driver", opt_stringptr|opt_public,
+ (void *)offsetof(router_instance, driver_name) },
++ #ifdef SUPPORT_DSN
++ { "dsn_process", opt_bool|opt_public,
++ (void *)offsetof(router_instance, dsn_process) },
++ #endif
+ { "errors_to", opt_stringptr|opt_public,
+ (void *)(offsetof(router_instance, errors_to)) },
+ { "expn", opt_bool|opt_public,
+@@ -270,6 +274,13 @@
+
+ if (r->pass_router_name != NULL)
+ set_router(r, r->pass_router_name, &(r->pass_router), TRUE);
++
++ #ifdef SUPPORT_DSN
++ if (r->dsn_process == FALSE)
++ DEBUG(D_route) debug_printf("%s router skipping DSN - add dsn_process to router\n", r->name);
++ if (r->dsn_process == TRUE)
++ DEBUG(D_route) debug_printf("%s router performing DSN \n", r->name);
++ #endif
+ }
+ }
+
+@@ -1412,7 +1423,10 @@
+
+ copyflag(new, addr, af_propagate);
+ new->p.address_data = addr->p.address_data;
+-
++#ifdef SUPPORT_DSN
++ new->dsn_flags = addr->dsn_flags;
++ new->dsn_orcpt = addr->dsn_orcpt;
++#endif
+
+ /* As it has turned out, we haven't set headers_add or headers_remove for the
+ * clone. Thinking about it, it isn't entirely clear whether they should be
+diff -Naur exim-4.82_RC5.orig/src/smtp_in.c exim-4.82_RC5/src/smtp_in.c
+--- exim-4.82_RC5.orig/src/smtp_in.c 2013-10-27 21:46:25.000000000 +0100
++++ exim-4.82_RC5/src/smtp_in.c 2013-10-27 21:47:32.000000000 +0100
+@@ -213,6 +213,9 @@
+ #ifdef EXPERIMENTAL_PRDR
+ ENV_MAIL_OPT_PRDR,
+ #endif
++#ifdef SUPPORT_DSN
++ ENV_MAIL_OPT_RET, ENV_MAIL_OPT_ENVID,
++#endif
+ ENV_MAIL_OPT_NULL
+ };
+ typedef struct {
+@@ -228,6 +231,10 @@
+ #ifdef EXPERIMENTAL_PRDR
+ { US"PRDR", ENV_MAIL_OPT_PRDR, FALSE },
+ #endif
++#ifdef SUPPORT_DSN
++ { US"RET", ENV_MAIL_OPT_RET, FALSE },
++ { US"ENVID", ENV_MAIL_OPT_ENVID, FALSE },
++#endif
+ { US"NULL", ENV_MAIL_OPT_NULL, FALSE }
+ };
+
+@@ -1073,6 +1080,13 @@
+ sender_verified_list = NULL; /* No senders verified */
+ memset(sender_address_cache, 0, sizeof(sender_address_cache));
+ memset(sender_domain_cache, 0, sizeof(sender_domain_cache));
++
++#ifdef SUPPORT_DSN
++/* Reset the DSN flags */
++dsn_ret = 0;
++dsn_envid = NULL;
++#endif
++
+ authenticated_sender = NULL;
+ #ifdef EXPERIMENTAL_BRIGHTMAIL
+ bmi_run = 0;
+@@ -2679,6 +2693,10 @@
+ int ptr, size, rc;
+ int c, i;
+ auth_instance *au;
++#ifdef SUPPORT_DSN
++ uschar *orcpt = NULL;
++ int flags;
++#endif
+
+ switch(smtp_read_command(TRUE))
+ {
+@@ -3106,6 +3124,12 @@
+ s = string_cat(s, &size, &ptr, US"-8BITMIME\r\n", 11);
+ }
+
++ #ifdef SUPPORT_DSN
++ /* Advertise DSN support if configured to do so. */
++ if (dsn)
++ s = string_cat(s, &size, &ptr, US"250-DSN\r\n", 9);
++ #endif
++
+ /* Advertise ETRN if there's an ACL checking whether a host is
+ permitted to issue it; a check is made when any host actually tries. */
+
+@@ -3360,6 +3384,42 @@
+ arg_error = TRUE;
+ break;
+
++#ifdef SUPPORT_DSN
++
++ /* Handle the two DSN options, but only if configured to do so
++ * (which will have caused "DSN" to be given in the EHLO
++ * response). The code itself is included only if configured in
++ * at build time. */
++
++ case ENV_MAIL_OPT_RET:
++ /* Check if RET has already been set */
++ if (dsn_ret > 0) {
++ synprot_error(L_smtp_syntax_error, 501, NULL,
++ US"RET can be specified once only");
++ goto COMMAND_LOOP;
++ }
++ dsn_ret = (strcmpic(value, US"HDRS") == 0)? dsn_ret_hdrs :
++ (strcmpic(value, US"FULL") == 0)? dsn_ret_full : 0;
++ DEBUG(D_receive) debug_printf("DSN_RET: %d\n", dsn_ret);
++ /* Check for invalid invalid value, and exit with error */
++ if (dsn_ret == 0) {
++ synprot_error(L_smtp_syntax_error, 501, NULL,
++ US"Value for RET is invalid");
++ goto COMMAND_LOOP;
++ }
++ break;
++ case ENV_MAIL_OPT_ENVID:
++ /* Check if the dsn envid has been already set */
++ if (dsn_envid != NULL) {
++ synprot_error(L_smtp_syntax_error, 501, NULL,
++ US"ENVID can be specified once only");
++ goto COMMAND_LOOP;
++ }
++ dsn_envid = string_copy(value);
++ DEBUG(D_receive) debug_printf("DSN_ENVID: %s\n", dsn_envid);
++ break;
++#endif
++
+ /* Handle the AUTH extension. If the value given is not "<>" and either
+ the ACL says "yes" or there is no ACL but the sending host is
+ authenticated, we set it up as the authenticated sender. However, if the
+@@ -3633,6 +3693,89 @@
+ rcpt_fail_count++;
+ break;
+ }
++
++ #ifdef SUPPORT_DSN
++ /* Set the DSN flags orcpt and dsn_flags from the session*/
++ orcpt = NULL;
++ flags = 0;
++
++ if (esmtp) for(;;)
++ {
++ uschar *name, *value, *end;
++ int size;
++
++ if (!extract_option(&name, &value))
++ {
++ break;
++ }
++
++ if (strcmpic(name, US"ORCPT") == 0)
++ {
++ /* Check whether orcpt has been already set */
++ if (orcpt != NULL) {
++ synprot_error(L_smtp_syntax_error, 501, NULL,
++ US"ORCPT can be specified once only");
++ goto COMMAND_LOOP;
++ }
++ orcpt = string_copy(value);
++ DEBUG(D_receive) debug_printf("DSN orcpt: %s\n", orcpt);
++ }
++
++ else if (strcmpic(name, US"NOTIFY") == 0)
++ {
++ /* Check if the notify flags have been already set */
++ if (flags > 0)
++ {
++ synprot_error(L_smtp_syntax_error, 501, NULL,
++ US"NOTIFY can be specified once only");
++ goto COMMAND_LOOP;
++ }
++ if (strcmpic(value, US"NEVER") == 0) flags |= rf_notify_never; else
++ {
++ uschar *p = value;
++ while (*p != 0)
++ {
++ uschar *pp = p;
++ while (*pp != 0 && *pp != ',') pp++;
++ if (*pp == ',') *pp++ = 0;
++ if (strcmpic(p, US"SUCCESS") == 0) {
++ DEBUG(D_receive) debug_printf("GC: Setting notify success\n");
++ flags |= rf_notify_success;
++ }
++ else if (strcmpic(p, US"FAILURE") == 0) {
++ DEBUG(D_receive) debug_printf("GC: Setting notify failure\n");
++ flags |= rf_notify_failure;
++ }
++ else if (strcmpic(p, US"DELAY") == 0) {
++ DEBUG(D_receive) debug_printf("GC: Setting notify delay\n");
++ flags |= rf_notify_delay;
++ }
++ else
++ {
++ /* Catch any strange values */
++ synprot_error(L_smtp_syntax_error, 501, NULL,
++ US"Invalid value for NOTIFY parameter");
++ goto COMMAND_LOOP;
++ }
++ p = pp;
++ }
++ DEBUG(D_receive) debug_printf("DSN Flags: %x\n", flags);
++ }
++ }
++
++ /* Unknown option. Stick back the terminator characters and break
++ the loop. An error for a malformed address will occur. */
++
++ else
++ {
++ DEBUG(D_receive) debug_printf("Invalid dsn command: %s : %s\n", name, value);
++ name[-1] = ' ';
++ value[-1] = '=';
++ break;
++ }
++ }
++ #endif
++
+
+ /* Apply SMTP rewriting then extract the working address. Don't allow "<>"
+ as a recipient address */
+@@ -3747,6 +3890,24 @@
+ if (user_msg == NULL) smtp_printf("250 Accepted\r\n");
+ else smtp_user_msg(US"250", user_msg);
+ receive_add_recipient(recipient, -1);
++
++ #ifdef SUPPORT_DSN
++
++ /* Set the dsn flags in the recipients_list */
++ if (orcpt != NULL)
++ recipients_list[recipients_count-1].orcpt = orcpt;
++ else
++ recipients_list[recipients_count-1].orcpt = NULL;
++
++ if (flags != 0)
++ recipients_list[recipients_count-1].dsn_flags = flags;
++ else
++ recipients_list[recipients_count-1].dsn_flags = 0;
++ debug_printf("DSN-AJ(smtp-in): orcpt: %s flags: %d\n", recipients_list[recipients_count-1].orcpt, recipients_list[recipients_count-1].dsn_flags);
++
++
++ #endif
++
+ }
+
+ /* The recipient was discarded */
+diff -Naur exim-4.82_RC5.orig/src/spool_in.c exim-4.82_RC5/src/spool_in.c
+--- exim-4.82_RC5.orig/src/spool_in.c 2013-10-27 21:46:25.000000000 +0100
++++ exim-4.82_RC5/src/spool_in.c 2013-10-27 21:47:32.000000000 +0100
+@@ -293,6 +293,13 @@
+ spam_score_int = NULL;
+ #endif
+
++#ifdef SUPPORT_DSN
++#ifndef COMPILE_UTILITY
++dsn_ret = 0;
++dsn_envid = NULL;
++#endif /* COMPILE_UTILITY */
++#endif
++
+ /* Generate the full name and open the file. If message_subdir is already
+ set, just look in the given directory. Otherwise, look in both the split
+ and unsplit directories, as for the data file above. */
+@@ -467,6 +474,19 @@
+ case 'd':
+ if (Ustrcmp(p, "eliver_firsttime") == 0)
+ deliver_firsttime = TRUE;
++ #ifdef SUPPORT_DSN
++ #ifndef COMPILE_UTILITY
++ /* Check if the dsn flags have been set in the header file */
++ else if (Ustrncmp(p, "sn_ret", 6) == 0)
++ {
++ dsn_ret= atoi(big_buffer + 8);
++ }
++ else if (Ustrncmp(p, "sn_envid", 8) == 0)
++ {
++ dsn_envid = string_copy(big_buffer + 11);
++ }
++ #endif /* COMPILE_UTILITY */
++ #endif
+ break;
+
+ case 'f':
+@@ -554,7 +574,7 @@
+ tls_in.sni = string_unprinting(string_copy(big_buffer + 9));
+ break;
+ #endif
+-
++
+ default: /* Present because some compilers complain if all */
+ break; /* possibilities are not covered. */
+ }
+@@ -604,6 +624,10 @@
+ {
+ int nn;
+ int pno = -1;
++ #ifdef SUPPORT_DSN
++ int dsn_flags = 0;
++ uschar *orcpt = NULL;
++ #endif
+ uschar *errors_to = NULL;
+ uschar *p;
+
+@@ -672,10 +696,19 @@
+ }
+
+ /* Handle current format Exim 4 spool files */
++ /* Spool file is modified if DSN is supported
++ Original was "address errors_to len(errors_to),pno
++ New for DSN support is now:
++ "address errors_to orcpt len(errors_to),len(orcpt),pno,dsn_flags */
+
+ else if (*p == '#')
+ {
+ int flags;
++
++ #ifndef COMPILE_UTILITY
++ DEBUG(D_deliver) debug_printf("**** SPOOL_IN - Exim 4 standard format spoolfile\n");
++ #endif /* COMPILE_UTILITY */
++
+ (void)sscanf(CS p+1, "%d", &flags);
+
+ if ((flags & 0x01) != 0) /* one_time data exists */
+@@ -688,15 +721,82 @@
+ {
+ p -= len;
+ errors_to = string_copy(p);
++ }
++ }
++
++ *(--p) = 0; /* Terminate address */
++ }
++ #ifdef SUPPORT_DSN
++ else if (*p == '!') /* Handle Exim4 + DSN spool files */
++ {
++ int flags;
++ int temp_dsn_flags;
++
++ #ifndef COMPILE_UTILITY
++ DEBUG(D_deliver) debug_printf("**** SPOOL_IN - C&W DSN format spoolfile\n");
++ #endif /* COMPILE_UTILITY */
++
++ sscanf(CS p+1, "%d,%d", &flags, &temp_dsn_flags);
++
++ if (((flags & 0x01) != 0) || (temp_dsn_flags > 0)) /* one_time data or dsn_flags exist */
++ {
++ int len;
++ int len_orcpt;
++
++ #ifndef COMPILE_UTILITY
++ DEBUG(D_deliver) debug_printf("**** spool_in dsn_flags = 0\n");
++ #endif /* COMPILE_UTILITY */
++
++ dsn_flags = 0;
++
++ while (isdigit(*(--p)) || *p == ',' || *p == '-');
++ sscanf(CS p+1, "%d,%d,%d,%d", &len, &len_orcpt, &pno, &dsn_flags);
++
++ *p = 0;
++ if (len_orcpt > 0)
++ {
++ p -= len_orcpt;
++ orcpt = string_copy(p);
+ }
++ *(--p) = 0; /* change the space to a NULL */
++
++ if (len > 0)
++ {
++ p -= len;
++ errors_to = string_copy(p);
++ }
+ }
+
+ *(--p) = 0; /* Terminate address */
+ }
++ #endif
++ #ifndef COMPILE_UTILITY
++ else
++ {
++ DEBUG(D_deliver) debug_printf("**** SPOOL_IN - No additional fields\n");
++ }
++ #endif /* COMPILE_UTILITY */
++
++ #ifdef SUPPORT_DSN
++ #ifndef COMPILE_UTILITY
++ DEBUG(D_deliver) debug_printf("**** SPOOL_IN - address: |%s| errorsto: |%s| orcpt: |%s| dsn_flags: %d\n",
++ big_buffer, errors_to, orcpt, dsn_flags);
++ #endif /* COMPILE_UTILITY */
++ #endif
++ #ifndef SUPPORT_DSN
++ #ifndef COMPILE_UTILITY
++ DEBUG(D_deliver) debug_printf("**** SPOOL_IN - address: |%s| errorsto: |%s|\n",
++ big_buffer, errors_to);
++ #endif /* COMPILE_UTILITY */
++ #endif
+
+ recipients_list[recipients_count].address = string_copy(big_buffer);
+ recipients_list[recipients_count].pno = pno;
+ recipients_list[recipients_count].errors_to = errors_to;
++ #ifdef SUPPORT_DSN
++ recipients_list[recipients_count].orcpt = orcpt;
++ recipients_list[recipients_count].dsn_flags = dsn_flags;
++ #endif
+ }
+
+ /* The remainder of the spool header file contains the headers for the message,
+diff -Naur exim-4.82_RC5.orig/src/spool_out.c exim-4.82_RC5/src/spool_out.c
+--- exim-4.82_RC5.orig/src/spool_out.c 2013-10-27 21:46:25.000000000 +0100
++++ exim-4.82_RC5/src/spool_out.c 2013-10-27 21:47:32.000000000 +0100
+@@ -234,6 +234,15 @@
+ if (tls_in.sni != NULL) fprintf(f, "-tls_sni %s\n", string_printing(tls_in.sni));
+ #endif
+
++#ifdef SUPPORT_DSN
++/* Write the dsn flags to the spool header file */
++DEBUG(D_deliver) debug_printf("DSN: Write SPOOL :-dsn_envid %s\n", dsn_envid);
++if (dsn_envid != NULL) fprintf(f, "-dsn_envid %s\n", dsn_envid);
++DEBUG(D_deliver) debug_printf("DSN: Write SPOOL :-dsn_ret %d\n", dsn_ret);
++if (dsn_ret != 0) fprintf(f, "-dsn_ret %d\n", dsn_ret);
++#endif
++
++
+ /* To complete the envelope, write out the tree of non-recipients, followed by
+ the list of recipients. These won't be disjoint the first time, when no
+ checking has been done. If a recipient is a "one-time" alias, it is followed by
+@@ -244,14 +253,36 @@
+ for (i = 0; i < recipients_count; i++)
+ {
+ recipient_item *r = recipients_list + i;
+- if (r->pno < 0 && r->errors_to == NULL)
++#ifdef SUPPORT_DSN
++DEBUG(D_deliver) debug_printf("DSN: Flags :%d\n", r->dsn_flags);
++#endif
++ if (r->pno < 0 && r->errors_to == NULL
++ #ifdef SUPPORT_DSN
++ && r->dsn_flags == 0
++ #endif
++ )
+ fprintf(f, "%s\n", r->address);
+ else
+ {
+ uschar *errors_to = (r->errors_to == NULL)? US"" : r->errors_to;
++ #ifdef SUPPORT_DSN
++ uschar *orcpt = (r->orcpt == NULL)? US"" : r->orcpt;
++ fprintf(f, "%s %s %s %d,%d,%d,%d!1\n", r->address, errors_to, orcpt,
++ Ustrlen(errors_to), Ustrlen(orcpt), r->pno, r->dsn_flags);
++ #else
+ fprintf(f, "%s %s %d,%d#1\n", r->address, errors_to,
+ Ustrlen(errors_to), r->pno);
++ #endif
+ }
++
++ #ifdef SUPPORT_DSN
++ DEBUG(D_deliver) debug_printf("DSN :**** SPOOL_OUT - address: |%s| errorsto: |%s| orcpt: |%s| dsn_flags: %d\n",
++ r->address, r->errors_to, r->orcpt, r->dsn_flags);
++ #endif
++ #ifndef SUPPORT_DSN
++ DEBUG(D_deliver) debug_printf("**** SPOOL_OUT - address: |%s| errorsto: |%s|\n",
++ r->address, r->errors_to);
++ #endif
+ }
+
+ /* Put a blank line before the headers */
+diff -Naur exim-4.82_RC5.orig/src/structs.h exim-4.82_RC5/src/structs.h
+--- exim-4.82_RC5.orig/src/structs.h 2013-10-27 21:46:25.000000000 +0100
++++ exim-4.82_RC5/src/structs.h 2013-10-27 21:47:32.000000000 +0100
+@@ -282,7 +282,9 @@
+ BOOL verify_sender; /* Use this router when verifying a sender */
+ BOOL uid_set; /* Flag to indicate uid is set */
+ BOOL unseen; /* If TRUE carry on, even after success */
+-
++#ifdef SUPPORT_DSN
++ BOOL dsn_process; /* If TRUE, activate DSN for this router */
++#endif
+ int self_code; /* Encoded version of "self" */
+ uid_t uid; /* Fixed uid value */
+ gid_t gid; /* Fixed gid value */
+@@ -547,6 +549,12 @@
+ uschar *auth_id; /* auth "login" name used by transport */
+ uschar *auth_sndr; /* AUTH arg to SMTP MAIL, used by transport */
+
++ #ifdef SUPPORT_DSN
++ uschar *dsn_orcpt; /* DSN orcpt value */
++ int dsn_flags; /* DSN flags */
++ uschar *dsn_aware; /* DSN aware flag */
++ #endif
++
+ uid_t uid; /* uid for transporting */
+ gid_t gid; /* gid for transporting */
+
+diff -Naur exim-4.82_RC5.orig/src/transport.c exim-4.82_RC5/src/transport.c
+--- exim-4.82_RC5.orig/src/transport.c 2013-10-27 21:46:25.000000000 +0100
++++ exim-4.82_RC5/src/transport.c 2013-10-27 21:47:32.000000000 +0100
+@@ -1802,6 +1802,11 @@
+
+ argv = child_exec_exim(CEE_RETURN_ARGV, TRUE, &i, FALSE, 0);
+
++ #ifdef SUPPORT_DSN
++ /* Call with the dsn flag */
++ if (smtp_use_dsn) argv[i++] = US"-MCD";
++ #endif
++
+ if (smtp_authenticated) argv[i++] = US"-MCA";
+
+ #ifdef SUPPORT_TLS
+diff -Naur exim-4.82_RC5.orig/src/transports/smtp.c exim-4.82_RC5/src/transports/smtp.c
+--- exim-4.82_RC5.orig/src/transports/smtp.c 2013-10-27 21:46:25.000000000 +0100
++++ exim-4.82_RC5/src/transports/smtp.c 2013-10-27 21:47:32.000000000 +0100
+@@ -242,6 +242,16 @@
+ #endif
+ };
+
++#ifdef SUPPORT_DSN
++/* some DSN flags for use later */
++
++static int rf_list[] = {rf_notify_never, rf_notify_success,
++ rf_notify_failure, rf_notify_delay };
++
++static uschar *rf_names[] = { "NEVER", "SUCCESS", "FAILURE", "DELAY" };
++#endif
++
++
+
+ /* Local statics */
+
+@@ -1079,6 +1089,27 @@
+ else if (new[0] != 0) local_authenticated_sender = new;
+ }
+
++#ifdef SUPPORT_DSN
++/* Add any DSN flags to the mail command */
++
++if (smtp_use_dsn)
++ {
++ uschar *p = buffer;
++ if (dsn_ret == dsn_ret_hdrs)
++ {
++ strcpy(p, " RET=HDRS");
++ while (*p) p++;
++ }
++ else if (dsn_ret == dsn_ret_full)
++ {
++ strcpy(p, " RET=FULL");
++ while (*p) p++;
++ }
++ if (dsn_envid != NULL)
++ string_format(p, sizeof(buffer) - (p-buffer), " ENVID=%s", dsn_envid);
++ }
++#endif
++
+ /* Add the authenticated sender address if present */
+
+ if ((smtp_authenticated || ob->authenticated_sender_force) &&
+@@ -1587,6 +1618,14 @@
+ {DEBUG(D_transport) debug_printf("PRDR usable\n");}
+ #endif
+
++ #ifdef SUPPORT_DSN
++ /* Note if the server supports DSN */
++ smtp_use_dsn = dsn &&
++ esmtp && pcre_exec(regex_DSN, NULL, CS buffer, (int)Ustrlen(CS buffer), 0,
++ PCRE_EOPT, NULL, 0) >= 0;
++ DEBUG(D_transport) debug_printf("use_dsn=%d\n", smtp_use_dsn);
++ #endif
++
+ /* Note if the response to EHLO specifies support for the AUTH extension.
+ If it has, check that this host is one we want to authenticate to, and do
+ the business. The host name and address must be available when the
+@@ -1746,18 +1785,66 @@
+ int count;
+ BOOL no_flush;
+
++ #ifdef SUPPORT_DSN
++ /* philb - set dsn_aware flag for this recipient */
++ if(smtp_use_dsn)
++ addr->dsn_aware = string_copy("Y");
++ else
++ addr->dsn_aware = string_copy("N");
++ #endif
++
+ if (addr->transport_return != PENDING_DEFER) continue;
+
+ address_count++;
+ no_flush = smtp_use_pipelining && (!mua_wrapper || addr->next != NULL);
+
++ #ifdef SUPPORT_DSN
++ /* Add any DSN flags to the rcpt command and add to the sent string */
++
++ p = buffer;
++ *p = 0;
++
++ if (smtp_use_dsn)
++ {
++ if ((addr->dsn_flags & rf_dsnflags) != 0)
++ {
++ int i;
++ BOOL first = TRUE;
++ strcpy(p, " NOTIFY=");
++ while (*p) p++;
++ for (i = 0; i < 4; i++)
++ {
++ if ((addr->dsn_flags & rf_list[i]) != 0)
++ {
++ if (!first) *p++ = ',';
++ first = FALSE;
++ strcpy(p, rf_names[i]);
++ while (*p) p++;
++ }
++ }
++ }
++
++ if (addr->dsn_orcpt != NULL)
++ string_format(p, sizeof(buffer) - (p-buffer), " ORCPT=%s",
++ addr->dsn_orcpt);
++ }
++
++ #endif
++
++
+ /* Now send the RCPT command, and process outstanding responses when
+ necessary. After a timeout on RCPT, we just end the function, leaving the
+ yield as OK, because this error can often mean that there is a problem with
+ just one address, so we don't want to delay the host. */
+
++ #ifdef SUPPORT_DSN
++ count = smtp_write_command(&outblock, no_flush, "RCPT TO:<%s>%s%s\r\n",
++ transport_rcpt_address(addr, tblock->rcpt_include_affixes), igquotstr, buffer);
++ #else
+ count = smtp_write_command(&outblock, no_flush, "RCPT TO:<%s>%s\r\n",
+ transport_rcpt_address(addr, tblock->rcpt_include_affixes), igquotstr);
++ #endif
++
+ if (count < 0) goto SEND_FAILED;
+ if (count > 0)
+ {
diff --git a/mail-mta/exim/files/exim_at.service b/mail-mta/exim/files/exim_at.service
new file mode 100644
index 00000000..19c07a51
--- /dev/null
+++ b/mail-mta/exim/files/exim_at.service
@@ -0,0 +1,7 @@
+[Unit]
+Description=Exim Mail Daemon per-connection server
+
+[Service]
+ExecStart=-/usr/bin/exim -bs
+StandardInput=socket
+StandardError=syslog
diff --git a/mail-mta/exim/metadata.xml b/mail-mta/exim/metadata.xml
new file mode 100644
index 00000000..c94ff4f9
--- /dev/null
+++ b/mail-mta/exim/metadata.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <herd>net-mail</herd>
+ <maintainer>
+ <email>grobian@gentoo.org</email>
+ </maintainer>
+ <longdescription>
+ Exim is a message transfer agent (MTA) developed at the University of
+ Cambridge for use on Unix systems connected to the Internet. It is
+ freely available under the terms of the GNU General Public Licence. In
+ style it is similar to Smail 3, but its facilities are more general.
+ There is a great deal of flexibility in the way mail can be routed, and
+ there are extensive facilities for checking incoming mail. Exim can be
+ installed in place of sendmail, although the configuration of exim is
+ quite different to that of sendmail.
+ </longdescription>
+ <use>
+ <flag name='dcc'>Adds support for Distributed Checksum Clearinghouse
+ (DCC)</flag>
+ <flag name='dkim'>Adds support for DomainKeys Identified Mail
+ (DKIM)</flag>
+ <flag name='dnsdb'>Adds support for a DNS search for a record whose
+ domain name is the supplied query</flag>
+ <flag name='dovecot-sasl'>Adds support for Dovecot's
+ authentication</flag>
+ <flag name='dlfunc'>Install local_scan.h header to compile separate
+ dlfunc libraries</flag>
+ <flag name='dmarc'>Adds support for DMARC</flag>
+ <flag name='dsn'>Adds support for Delivery Status Notifications
+ (DSN)</flag>
+ <flag name='exiscan-acl'>Patch providing support for content
+ scanning</flag>
+ <flag name='lmtp'>Adds support for lmtp</flag>
+ <flag name='mbx'>Adds support for UW's mbx format</flag>
+ <flag name='spf'>Adds support for Sender Policy Framework</flag>
+ <flag name='srs'>Adds support for Sender Rewriting Scheme</flag>
+ <flag name='proxy'>Add support for being behind a proxy, such as HAProxy</flag>
+ <flag name='pkcs11'>Require pkcs11 support in <pkg>net-libs/gnutls</pkg> with USE=gnutls</flag>
+ <flag name='redis'>Adds support for querying <pkg>dev-db/redis</pkg></flag>
+ <flag name='prdr'>Adds support for Per-Recipient Data Response</flag>
+ <flag name='tpda'>Adds support for Transport Post-Delivery Actions</flag>
+ </use>
+ <upstream>
+ <bugs-to>http://bugs.exim.org/</bugs-to>
+ <!-- stupid DTD doesn't allow this
+ <vcs>http://git.exim.org/exim.git</vcs>
+ -->
+ </upstream>
+</pkgmetadata>