--- /dev/null
+# Contributor: Stuart Cardall <developer@it-offshore.co.uk>
+# Contributor: Ash Berlin-Taylor <ash.berlin@gmail.com>
+# Contributor: Valery Kartel <valery.kartel@gmail.com>
+# Contributor: Ćukasz Jendrysik <scadu@yandex.com>
+# Contributor: Jesse Young <jlyo@jlyo.org>
+# Maintainer: Jesse Young <jlyo@jlyo.org>
+pkgname=exim-openldap
+_pkgname=exim
+provides=$_pkgname
+pkgver=4.95
+pkgrel=1
+pkgdesc="Replacement package for exim with built-in OpenLDAP support"
+url="https://www.exim.org/"
+arch="all"
+license="GPL-2.0-or-later"
+options="!check suid"
+pkgusers="$_pkgname"
+pkggroups="$_pkgname mail"
+depends="ca-certificates exim-openrc"
+makedepends="bash tdb-dev gawk libidn-dev libspf2-dev linux-headers
+ mariadb-connector-c-dev openssl1.1-compat-dev pcre-dev perl libpq-dev sqlite-dev
+ openldap-dev
+ "
+install="$pkgname.pre-install"
+source="https://ftp.exim.org/pub/exim/exim4/exim-$pkgver.tar.xz
+ bounce-charset.patch
+ exim.Makefile
+ exim.logrotate
+ "
+builddir="$srcdir/$_pkgname-$pkgver"
+
+# secfixes:
+# 4.94.2-r0:
+# - CVE-2021-27216
+# - CVE-2020-28007
+# - CVE-2020-28008
+# - CVE-2020-28009
+# - CVE-2020-28010
+# - CVE-2020-28011
+# - CVE-2020-28012
+# - CVE-2020-28013
+# - CVE-2020-28014
+# - CVE-2020-28015
+# - CVE-2020-28016
+# - CVE-2020-28017
+# - CVE-2020-28018
+# - CVE-2020-28019
+# - CVE-2020-28020
+# - CVE-2020-28021
+# - CVE-2020-28022
+# - CVE-2020-28023
+# - CVE-2020-28024
+# - CVE-2020-28025
+# - CVE-2020-28026
+# 4.93-r1:
+# - CVE-2020-12783
+# 4.92.2-r1:
+# - CVE-2019-16928
+# 4.92.2-r0:
+# - CVE-2019-15846
+# 4.92.1-r0:
+# - CVE-2019-13917
+# 4.92-r0:
+# - CVE-2019-10149
+# 4.89-r5:
+# - CVE-2017-1000369
+# 4.89-r7:
+# - CVE-2017-16943
+# 4.89.1-r0:
+# - CVE-2017-16944
+# 4.90.1-r0:
+# - CVE-2018-6789
+
+prepare() {
+ default_prepare
+
+ cp "$srcdir"/$_pkgname.Makefile Local/Makefile
+ sed -i \
+ -e 's/-lnsl//g' \
+ -e 's/^HAVE_ICONV.*$//' \
+ OS/Makefile-Linux
+}
+
+build() {
+ make makefile
+ make
+}
+
+package() {
+ install -m750 -D -g mail -d "$pkgdir"/etc/mail
+ make DESTDIR="$pkgdir" INSTALL_ARG="-no_symlink -no_chown exim" install
+ cd "$pkgdir"/usr/sbin
+ mv exim-${pkgver%.*}* exim
+ chmod u+s exim
+ local i; for i in mailq rmail rsmtp runq sendmail newaliases; do
+ ln -s exim $i
+ done
+ install -Dm644 "$srcdir"/$_pkgname.logrotate "$pkgdir"/etc/logrotate.d/$_pkgname
+ # Fix clamav local socket path, Add variant to spamd address
+ sed -i \
+ -e 's~# av_scanner = clamd:/tmp/clamd~# av_scanner = clamd:/run/clamav/clamd.sock~' \
+ -e '/# spamd_address = 127.0.0.1 783/a# spamd_address = 127.0.0.1 11333 variant=rspamd' \
+ "$pkgdir"/etc/$_pkgname/$_pkgname.conf
+ # Create subdirs for logs and extensions
+ install -dm750 -o $_pkgname -g mail "$pkgdir"/var/log/$_pkgname
+ mkdir -p "$pkgdir"/usr/lib/$_pkgname
+}
+
+sha512sums="
+93d09c20d99f27da5edbe3e6dc7d25aa4548faa2b67ca26f2cc0b4aeaf58398dd468e0263714fcf0df97531f05d16fcd3f1f0e9d0656ead7858a66b248a44a65 exim-4.95.tar.xz
+691df92954f015711398350963ea321d143127bc731a985bcacc5364c71b6df84b6c21a2e8dc3cc2048fcd3dd02def3dc8015f4d84dd672f23d5a41348e72dc7 bounce-charset.patch
+4d2a33d2d9399c2d9485155585a180f1314fdc6f0ea164f3ebd74dbafa0b968f0edfbdd6d6ed7cdb4bc63696073b66f25e03317cc304192457e40fa30a12e207 exim.Makefile
+28e748693a6a72d9943fa9c342ff041fe650fa6977f468dee127e845e6c2a91872ce33fb6f5698838906bde3ed92de7a91cdb0349cedc40b806261867e8c06cb exim.logrotate
+"
--- /dev/null
+--- a/src/deliver.c
++++ b/src/deliver.c
+@@ -7373,7 +7373,7 @@
+ "MIME-Version: 1.0\n\n"
+
+ "--%s\n"
+- "Content-type: text/plain; charset=us-ascii\n\n"
++ "Content-type: text/plain; charset=utf-8\n\n"
+
+ "This message was created automatically by mail delivery software.\n"
+ " ----- The following addresses had successful delivery notifications -----\n",
+@@ -7644,7 +7644,7 @@
+
+ /* output human readable part as text/plain section */
+ fprintf(fp, "--%s\n"
+- "Content-type: text/plain; charset=us-ascii\n\n",
++ "Content-type: text/plain; charset=utf-8\n\n",
+ bound);
+
+ if ((emf_text = next_emf(emf, US"intro")))
+@@ -8252,7 +8252,7 @@
+
+ /* output human readable part as text/plain section */
+ fprintf(f, "--%s\n"
+- "Content-type: text/plain; charset=us-ascii\n\n",
++ "Content-type: text/plain; charset=utf-8\n\n",
+ bound);
+
+ if ((wmf_text = next_emf(wmf, US"intro")))
--- /dev/null
+#!/bin/sh
+
+addgroup -S exim 2>/dev/null
+adduser -S -D -H -h /var/spool/exim -s /sbin/nologin -G exim -g exim exim 2>/dev/null
+adduser exim mail 2>/dev/null
+
+exit 0
--- /dev/null
+AUTH_CRAM_MD5=yes
+AUTH_DOVECOT=yes
+AUTH_PLAINTEXT=yes
+AUTH_SPA=yes
+AUTH_TLS=yes
+BIN_DIRECTORY=/usr/sbin
+CFLAGS_DYNAMIC=-shared -rdynamic -fPIC
+COMPRESS_COMMAND=/bin/gzip
+COMPRESS_SUFFIX=gz
+CONFIGURE_FILE=/etc/exim/exim.conf
+CONFIGURE_FILE_USE_EUID=yes
+CONFIGURE_FILE_USE_NODE=yes
+EXICYCLOG_MAX=10
+EXIM_USER=ref:exim
+EXPAND_DLFUNC=yes
+EXPERIMENTAL_CERTNAMES=yes
+EXPERIMENTAL_EVENT=yes
+EXPERIMENTAL_INTERNATIONAL=yes
+EXPERIMENTAL_SOCKS=yes
+EXTRALIBS_EXIM=-export-dynamic -rdynamic -ldl
+FIXED_NEVER_USERS=root
+HAVE_IPV6=YES
+HEADERS_CHARSET="ISO-8859-1"
+LDFLAGS += -lidn
+LDFLAGS += -lspf2
+LOG_FILE_PATH=/var/log/exim/%slog
+LOOKUP_CDB=2
+LOOKUP_DBM=2
+LOOKUP_DNSDB=2
+LOOKUP_DSEARCH=yes
+LOOKUP_LSEARCH=yes
+LOOKUP_MODULE_DIR=/usr/lib/exim/
+LOOKUP_MYSQL=2
+LOOKUP_MYSQL_INCLUDE=-I/usr/include/mysql
+LOOKUP_MYSQL_LIBS=-Wl,--no-as-needed -lmysqlclient
+LOOKUP_PASSWD=yes
+LOOKUP_PGSQL=2
+LOOKUP_PGSQL_INCLUDE=-I/usr/include/postgresql
+LOOKUP_PGSQL_LIBS=-Wl,--no-as-needed -lpq
+LOOKUP_SQLITE=2
+LOOKUP_SQLITE_LIBS=-Wl,--no-as-needed -lsqlite3
+MAKE_SHELL=/bin/bash
+NO_SYMLINK=yes
+PCRE_CONFIG=yes
+PCRE_LIBS=-lpcre
+PID_FILE_PATH=/run/exim.pid
+ROUTER_ACCEPT=yes
+ROUTER_DNSLOOKUP=yes
+ROUTER_IPLITERAL=yes
+ROUTER_IPLOOKUP=yes
+ROUTER_MANUALROUTE=yes
+ROUTER_QUERYPROGRAM=yes
+ROUTER_REDIRECT=yes
+SPOOL_DIRECTORY=/var/spool/exim
+SUPPORT_CRYPTEQ=yes
+SUPPORT_MAILDIR=yes
+SUPPORT_MOVE_FROZEN_MESSAGES=yes
+SUPPORT_PROXY=yes
+SUPPORT_SPF=yes
+SUPPORT_TLS=yes
+SYSLOG_LOG_PID=no
+SYSTEM_ALIASES_FILE=/etc/mail/aliases
+TMPDIR="/tmp"
+TRANSPORT_APPENDFILE=yes
+TRANSPORT_AUTOREPLY=yes
+TRANSPORT_LMTP=yes
+TRANSPORT_PIPE=yes
+TRANSPORT_SMTP=yes
+USE_OPENSSL=yes
+USE_OPENSSL_PC=openssl
+WITH_CONTENT_SCAN=yes
+WITH_OLD_DEMIME=yes
+ZCAT_COMMAND=
+USE_TDB=yes
+DBMLIB=-ltdb
+
+LOOKUP_LDAP=yes
+LDAP_LIB_TYPE=OPENLDAP2
+LOOKUP_LIBS=-lldap -llber
--- /dev/null
+/var/log/exim/*log {
+ daily
+ missingok
+ rotate 28
+ compress
+ delaycompress
+ notifempty
+ create 640 exim mail
+ sharedscripts
+ postrotate
+ /etc/init.d/exim --quiet --ifstarted reload
+ endscript
+}