GeoIP Patch

"Ian P. Christian" <[email protected]> Tue, 30 Nov 2004 19:59:03 +0000
Newsgroups gmane.mail.exim.exiscan.user
Message-ID <[email protected]>
Full modified Exiscan patch: http://pookey.co.uk/files/exiscan.patch.gz

Only started learning C again last week , for forgive any stupid mistakes ;)

Example usage:
  warn    message     = X-Country-Code: $geoip_code
          geoip       = *
  warn    message     = X-Country: $geoip_country
          geoip       = *


Gentoo Users
------------

Attached Patched against version 27, exim 4.42.
Also attached, modified gentoo ebuild.

Place ebuild in: /usr/local/portage/mail-mta/exim/

and the patch in /usr/local/portage/mail-mta/exim/files/

(assuming /usr/local/portage is set as the portage overlay directory)

Please note a link to my Amazon wishlist on my website ;)

Feedback more then welcome.

Kind Regards,

-- 
Ian P. Christian
http://pookey.co.uk
pookey.patch (text/x-diff, 9.1 KB)
diff -uPr exim-4.42-gentoo/OS/Makefile-Base exim-4.42-pookey/OS/Makefile-Base
--- exim-4.42-gentoo/OS/Makefile-Base	2004-11-29 12:33:16.000000000 +0000
+++ exim-4.42-pookey/OS/Makefile-Base	2004-11-30 11:20:31.000000000 +0000
@@ -287,7 +287,7 @@
 
 OBJ_EXIM = acl.o bmi_spam.o child.o crypt16.o daemon.o dbfn.o debug.o deliver.o demime.o \
         directory.o dns.o drtables.o enq.o exim.o expand.o filter.o \
-        filtertest.o globals.o \
+        filtertest.o geoip.o globals.o \
         header.o host.o ip.o log.o lss.o malware.o match.o mime.o moan.o \
         os.o parse.o queue.o \
         rda.o readconf.o receive.o regex.o retry.o rewrite.o rfc2047.o \
@@ -513,6 +513,7 @@
 expand.o:        $(HDRS) expand.c
 filter.o:        $(HDRS) filter.c
 filtertest.o:    $(HDRS) filtertest.c
+geoip.o:         $(HDRS) geoip.c
 globals.o:       $(HDRS) globals.c
 header.o:        $(HDRS) header.c
 host.o:          $(HDRS) host.c
diff -uPr exim-4.42-gentoo/scripts/MakeLinks exim-4.42-pookey/scripts/MakeLinks
--- exim-4.42-gentoo/scripts/MakeLinks	2004-11-29 12:33:16.000000000 +0000
+++ exim-4.42-pookey/scripts/MakeLinks	2004-11-30 11:21:13.000000000 +0000
@@ -177,6 +177,7 @@
 ln -s ../src/demime.h          demime.h
 ln -s ../src/exim.h            exim.h
 ln -s ../src/functions.h       functions.h
+ln -s ../src/geoip.h           geoip.h
 ln -s ../src/globals.h         globals.h
 ln -s ../src/local_scan.h      local_scan.h
 ln -s ../src/macros.h          macros.h
@@ -185,7 +186,7 @@
 ln -s ../src/osfunctions.h     osfunctions.h
 ln -s ../src/spam.h            spam.h
 ln -s ../src/spf.h             spf.h
-ln -s ../src/srs.h		srs.h
+ln -s ../src/srs.h             srs.h
 ln -s ../src/store.h           store.h
 ln -s ../src/structs.h         structs.h
 ln -s ../src/tnef.h            tnef.h
@@ -212,6 +213,7 @@
 ln -s ../src/expand.c          expand.c
 ln -s ../src/filter.c          filter.c
 ln -s ../src/filtertest.c      filtertest.c
+ln -s ../src/geoip.c           geoip.c
 ln -s ../src/globals.c         globals.c
 ln -s ../src/header.c          header.c
 ln -s ../src/host.c            host.c
diff -uPr exim-4.42-gentoo/src/acl.c exim-4.42-pookey/src/acl.c
--- exim-4.42-gentoo/src/acl.c	2004-11-29 12:33:16.000000000 +0000
+++ exim-4.42-pookey/src/acl.c	2004-11-30 12:27:24.000000000 +0000
@@ -42,7 +42,11 @@
   ACLC_BMI_OPTIN,
 #endif
   ACLC_CONDITION, ACLC_CONTROL, ACLC_DECODE, ACLC_DELAY, ACLC_DEMIME,
-  ACLC_DNSLISTS, ACLC_DOMAINS, ACLC_ENCRYPTED, ACLC_ENDPASS, ACLC_HOSTS,
+  ACLC_DNSLISTS, ACLC_DOMAINS, ACLC_ENCRYPTED, ACLC_ENDPASS,
+#ifdef GEOIP
+  ACLC_GEOIP,
+#endif
+ ACLC_HOSTS,
   ACLC_LOCAL_PARTS, ACLC_LOG_MESSAGE, ACLC_LOGWRITE, ACLC_MALWARE, ACLC_MESSAGE, ACLC_MIME_REGEX,
   ACLC_RECIPIENTS, ACLC_REGEX, ACLC_SENDER_DOMAINS, ACLC_SENDERS, ACLC_SET, ACLC_SPAM,
 #ifdef SPF
@@ -59,7 +63,11 @@
   US"bmi_optin",
 #endif
   US"condition", US"control", US"decode", US"delay", US"demime", US"dnslists", US"domains", US"encrypted",
-  US"endpass", US"hosts", US"local_parts", US"log_message", US"logwrite", US"malware",
+  US"endpass", 
+#ifdef GEOIP
+  US"geoip",
+#endif
+  US"hosts", US"local_parts", US"log_message", US"logwrite", US"malware",
   US"message", US"mime_regex", US"recipients", US"regex", US"sender_domains", US"senders", US"set", US"spam", 
 #ifdef SPF
   US"spf",
@@ -85,6 +93,9 @@
   FALSE,   /* domains */
   FALSE,   /* encrypted */
   TRUE,    /* endpass */
+#ifdef GEOIP
+  TRUE,    /* geoip */
+#endif
   FALSE,   /* hosts */
   FALSE,   /* local_parts */
   TRUE,    /* log_message */
@@ -121,6 +132,9 @@
   FALSE,   /* domains */
   FALSE,   /* encrypted */
   TRUE,    /* endpass */
+#ifdef GEOIP
+  FALSE,   /* geoip */
+#endif
   FALSE,   /* hosts */
   FALSE,   /* local_parts */
   TRUE,    /* log_message */
@@ -200,6 +214,16 @@
     
   0,                                               /* endpass */
   
+#ifdef GEOIP
+  (1<<ACL_WHERE_AUTH)|                             /* geoip */
+    (1<<ACL_WHERE_CONNECT)|(1<<ACL_WHERE_HELO)|
+    (1<<ACL_WHERE_MIME)|(1<<ACL_WHERE_RCPT)|
+    (1<<ACL_WHERE_ETRN)|(1<<ACL_WHERE_EXPN)|
+    (1<<ACL_WHERE_MAILAUTH)|
+    (1<<ACL_WHERE_MAIL)|(1<<ACL_WHERE_STARTTLS)|
+    (1<<ACL_WHERE_VRFY),
+#endif
+
   (1<<ACL_WHERE_NOTSMTP),                          /* hosts */
 
   (1<<ACL_WHERE_NOTSMTP)|(1<<ACL_WHERE_AUTH)|      /* local_parts */
@@ -1421,6 +1445,12 @@
     break;
 #endif
 
+#ifdef GEOIP
+    case ACLC_GEOIP:
+      rc = geoip_check(&arg);
+    break;
+#endif
+    
     case ACLC_MALWARE:
       {
       /* Seperate the regular expression and any optional parameters. */
diff -uPr exim-4.42-gentoo/src/expand.c exim-4.42-pookey/src/expand.c
--- exim-4.42-gentoo/src/expand.c	2004-11-29 12:33:16.000000000 +0000
+++ exim-4.42-pookey/src/expand.c	2004-11-30 12:45:30.000000000 +0000
@@ -337,6 +337,10 @@
   { "exim_path",           vtype_stringptr,   &exim_path },
   { "exim_uid",            vtype_uid,         &exim_uid },
   { "found_extension",     vtype_stringptr,   &found_extension },
+#ifdef GEOIP
+  { "geoip_code",          vtype_stringptr,   &geoip_code },
+  { "geoip_country",       vtype_stringptr,   &geoip_country },
+#endif
   { "home",                vtype_stringptr,   &deliver_home },
   { "host",                vtype_stringptr,   &deliver_host },
   { "host_address",        vtype_stringptr,   &deliver_host_address },
diff -uPr exim-4.42-gentoo/src/functions.h exim-4.42-pookey/src/functions.h
--- exim-4.42-gentoo/src/functions.h	2004-11-29 12:33:16.000000000 +0000
+++ exim-4.42-pookey/src/functions.h	2004-11-30 11:27:02.000000000 +0000
@@ -93,6 +93,8 @@
 extern BOOL    filter_runtest(int, BOOL, BOOL);
 extern BOOL    filter_system_interpret(address_item **, uschar **);
 
+extern int     geoip_check(uschar **);
+
 extern void    header_add(int, char *, ...);
 extern header_line *header_insert(header_line *);
 extern int     header_checkname(header_line *, BOOL);
diff -uPr exim-4.42-gentoo/src/geoip.c exim-4.42-pookey/src/geoip.c
--- exim-4.42-gentoo/src/geoip.c	1970-01-01 01:00:00.000000000 +0100
+++ exim-4.42-pookey/src/geoip.c	2004-11-30 12:58:38.974550537 +0000
@@ -0,0 +1,32 @@
+/*
+ * GeoIP Patch by Ian P. Christian <[email protected]
+ * http://pookey.co.uk
+ * 30/11/2004
+ */
+
+#ifdef GEOIP
+
+#include "exim.h"
+#include "geoip.h"
+
+uschar geoip_country_buff[256];
+uschar geoip_code_buff[10];
+
+int geoip_init(uschar *remote_addr) {
+  GeoIP * gi;
+  gi = GeoIP_new(GEOIP_STANDARD);
+
+  sprintf(geoip_code_buff, "%s", GeoIP_country_code_by_addr(gi, remote_addr));
+  sprintf(geoip_country_buff, "%s", GeoIP_country_name_by_addr(gi, remote_addr));
+
+  return 1;
+}
+
+int geoip_check(uschar **listptr) {
+  geoip_country = geoip_country_buff;
+  geoip_code = geoip_code_buff;
+  return OK;
+}
+
+#endif
+
diff -uPr exim-4.42-gentoo/src/geoip.h exim-4.42-pookey/src/geoip.h
--- exim-4.42-gentoo/src/geoip.h	1970-01-01 01:00:00.000000000 +0100
+++ exim-4.42-pookey/src/geoip.h	2004-11-30 12:58:44.926285312 +0000
@@ -0,0 +1,15 @@
+/*
+ * GeoIP Patch by Ian P. Christian <[email protected]
+ * http://pookey.co.uk
+ * 30/11/2004
+ */
+
+#ifdef GEOIP
+
+#include <GeoIP.h>
+
+int geoip_init(uschar *);
+int geoip_process(uschar **);
+
+#endif
+
diff -uPr exim-4.42-gentoo/src/globals.c exim-4.42-pookey/src/globals.c
--- exim-4.42-gentoo/src/globals.c	2004-11-29 12:33:16.000000000 +0000
+++ exim-4.42-pookey/src/globals.c	2004-11-30 12:43:46.000000000 +0000
@@ -488,6 +488,10 @@
 
 uschar *gecos_name             = NULL;
 uschar *gecos_pattern          = NULL;
+#ifdef GEOIP
+uschar *geoip_code              = NULL;
+uschar *geoip_country           = NULL;
+#endif
 rewrite_rule  *global_rewrite_rules = NULL;
 
 uschar *headers_charset        = US HEADERS_CHARSET;
diff -uPr exim-4.42-gentoo/src/globals.h exim-4.42-pookey/src/globals.h
--- exim-4.42-gentoo/src/globals.h	2004-11-29 12:33:16.000000000 +0000
+++ exim-4.42-pookey/src/globals.h	2004-11-30 12:41:16.000000000 +0000
@@ -291,6 +291,10 @@
 
 extern uschar *gecos_name;             /* To be expanded when pattern matches */
 extern uschar *gecos_pattern;          /* Pattern to match */
+#ifdef GEOIP
+extern uschar *geoip_code;            /* GeoIP country Code */
+extern uschar *geoip_country;          /* GeoIP country */
+#endif
 extern rewrite_rule *global_rewrite_rules;  /* Chain of rewriting rules */
 
 extern int     header_insert_maxlen;   /* Max for inserting headers */
diff -uPr exim-4.42-gentoo/src/smtp_in.c exim-4.42-pookey/src/smtp_in.c
--- exim-4.42-gentoo/src/smtp_in.c	2004-11-29 12:33:16.000000000 +0000
+++ exim-4.42-pookey/src/smtp_in.c	2004-11-29 21:53:02.000000000 +0000
@@ -14,6 +14,10 @@
 #include "spf.h"
 #endif
 
+#ifdef GEOIP
+#include "geoip.h"
+#endif
+
 /* Initialize for TCP wrappers if so configured. It appears that the macro
 HAVE_IPV6 is used in some versions of the tcpd.h header, so we unset it before
 including that header, and restore its value afterwards. */
@@ -825,6 +829,10 @@
 spf_result = NULL;  
 spf_smtp_comment = NULL;
 #endif
+#ifdef GEOIP
+geoip_code = NULL;
+geoip_country = NULL;
+#endif
 
 
 body_linecount = body_zerocount = 0;
@@ -2356,6 +2364,10 @@
     spf_init(sender_helo_name, sender_host_address);
 #endif
 
+#ifdef GEOIP
+    geoip_init(sender_host_address);
+#endif
+
     /* Apply an ACL check if one is defined */
 
     if (acl_smtp_helo != NULL)
exim-4.42.ebuild (text/plain, 8.1 KB)
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/mail-mta/exim/exim-4.42.ebuild,v 1.2 2004/09/05 13:19:57 gmsoft Exp $

inherit eutils

IUSE="geoip tcpd ssl postgres mysql ldap pam exiscan-acl mailwrapper lmtp ipv6 sasl wildlsearch dnsdb perl mbox X exiscan spf srs"

EXISCANACL_VER=${PV}-27

DESCRIPTION="A highly configurable, drop-in replacement for sendmail"
SRC_URI="ftp://ftp.exim.org/pub/exim/exim4/${P}.tar.bz2
	exiscan-acl? ( http://duncanthrax.net/exiscan-acl/exiscan-acl-${EXISCANACL_VER}.patch )"
HOMEPAGE="http://www.exim.org/"

SLOT="0"
LICENSE="GPL-2"
KEYWORDS="x86 ~sparc ~hppa ~alpha ~amd64"

PROVIDE="virtual/mta"
DEPEND=">=sys-apps/sed-4.0.5
	dev-lang/perl
	>=sys-libs/db-3.2
	pam? ( >=sys-libs/pam-0.75 )
	tcpd? ( sys-apps/tcp-wrappers )
	ssl? ( >=dev-libs/openssl-0.9.6 )
	ldap? ( >=net-nds/openldap-2.0.7 )
	mysql? ( >=dev-db/mysql-3.23.28 )
	postgres? ( >=dev-db/postgresql-7 )
	sasl? ( >=dev-libs/cyrus-sasl-2.1.14 )
	spf? ( >=mail-filter/libspf2-1.0.4 )
	srs? ( >=mail-filter/libsrs2-1.0.16 )
	X? ( virtual/x11 )"
	# added X check for #57206
RDEPEND="${DEPEND}
	mailwrapper? ( >=net-mail/mailwrapper-0.2 )
	!mailwrapper? ( !virtual/mta )
	>=net-mail/mailbase-0.00-r5"

src_unpack() {
	unpack ${A}
	cd ${S}

	local myconf
	local mycflags

	mycflags="${CFLAGS}"

	epatch ${FILESDIR}/exim-4.14-tail.patch

	if ! use mbox; then
		einfo "Patching maildir support into exim.conf"
		epatch ${FILESDIR}/exim-4.20-maildir.patch
	fi

	sed -i "/SYSTEM_ALIASES_FILE/ s'SYSTEM_ALIASES_FILE'/etc/mail/aliases'" ${S}/src/configure.default
	cp ${S}/src/configure.default ${S}/src/configure.default.orig
		epatch ${FILESDIR}/exim-4.30-conf.patch

	if use exiscan-acl; then
		einfo "Patching exican-acl support into exim ${PV}.."
		epatch ${DISTDIR}/exiscan-acl-${EXISCANACL_VER}.patch
	elif use spf || use srs; then
		eerror SPF and SRS support require exiscan-acl
		exit 1
	fi
	if use spf; then
		myconf="${myconf} -lspf2"
		mycflags="${mycflags} -DSPF"
	fi
	if use srs; then
		myconf="${myconf} -lsrs2"
		mycflags="${mycflags} -DSRS"
		epatch ${FILESDIR}/exim-4.43-srs2.patch
	fi
	if use geoip; then
	        myconf="${myconf} -lGeoIP"
	        mycflags="${mycflags} -DGEOIP"
	        epatch ${FILESDIR}/pookey.patch
	fi
	# Includes Typo fix for bug 47106
	sed -e "48i\CFLAGS=${mycflags}" \
		-e "s:# AUTH_CRAM_MD5=yes:AUTH_CRAM_MD5=yes:" \
		-e "s:# AUTH_PLAINTEXT=yes:AUTH_PLAINTEXT=yes:" \
		-e "s:BIN_DIRECTORY=/usr/exim/bin:BIN_DIRECTORY=/usr/sbin:" \
		-e "s:COMPRESS_COMMAND=/opt/gnu/bin/gzip:COMPRESS_COMMAND=/usr/bin/gzip:" \
		-e "s:ZCAT_COMMAND=/opt/gnu/bin/zcat:ZCAT_COMMAND=/usr/bin/zcat:" \
		-e "s:CONFIGURE_FILE=/usr/exim/configure:CONFIGURE_FILE=/etc/exim/exim.conf:" \
		-e "s:EXIM_MONITOR=eximon.bin:# EXIM_MONITOR=eximon.bin:" \
		-e "s:# INFO_DIRECTORY=/usr/local/info:INFO_DIRECTORY=/usr/share/info:" \
		-e "s:# LOG_FILE_PATH=/var/log/exim_%slog:LOG_FILE_PATH=/var/log/exim/exim_%s.log:" \
		-e "s:# PID_FILE_PATH=/var/lock/exim.pid:PID_FILE_PATH=/var/run/exim.pid:" \
		-e "s:# SPOOL_DIRECTORY=/var/spool/exim:SPOOL_DIRECTORY=/var/spool/exim:" \
		-e "s:# SUPPORT_MAILDIR=yes:SUPPORT_MAILDIR=yes:" \
		-e "s:# SUPPORT_MAILSTORE=yes:SUPPORT_MAILSTORE=yes:" \
		-e "s:EXIM_USER=:EXIM_USER=mail:" \
		-e "s:# AUTH_SPA=yes:AUTH_SPA=yes:" \
		src/EDITME > Local/Makefile

	cd Local
	# enable optional exim_monitor support via X use flag bug #46778
	if use X; then
		einfo "Configuring eximon"
		cp ../exim_monitor/EDITME eximon.conf
		sed -i "s:# EXIM_MONITOR=eximon.bin:EXIM_MONITOR=eximon.bin:" Makefile
	fi
	#These next two should resolve 37964
	if use perl; then
		sed -i "s:# EXIM_PERL=perl.o:EXIM_PERL=perl.o:" Makefile
	fi
	if use mbox; then
		sed -i "s:# SUPPORT_MBX=yes:SUPPORT_MBX=yes:" Makefile
	fi
	if use pam; then
		sed -i "s:# \(SUPPORT_PAM=yes\):\1:" Makefile
		myconf="${myconf} -lpam"
	fi
	if use sasl; then
		sed -i "s:# CYRUS_SASLAUTHD_SOCKET=/var/state/saslauthd/mux:CYRUS_SASLAUTHD_SOCKET=/var/lib/sasl2/mux:" \
		Makefile
		myconf="${myconf} -lsasl2"
	fi
	if use tcpd; then
		sed -i "s:# \(USE_TCP_WRAPPERS=yes\):\1:" Makefile
		myconf="${myconf} -lwrap"
	fi
	if use lmtp; then
		sed -i "s:# \(TRANSPORT_LMTP=yes\):\1:" Makefile
	fi
	if use ipv6; then
		echo "HAVE_IPV6=YES" >> Makefile
		#To fix bug 41196
		echo "IPV6_USE_INET_PTON=yes" >> Makefile
	fi

	if [ -n "$myconf" ] ; then
		echo "EXTRALIBS=${myconf} ${LDFLAGS}" >> Makefile
	fi

	cd ${S}
	if use ssl; then
		sed -i \
			-e "s:# \(SUPPORT_TLS=yes\):\1:" \
			-e "s:# \(TLS_LIBS=-lssl -lcrypto\):\1:" Local/Makefile
	fi

	LOOKUP_INCLUDE=
	LOOKUP_LIBS=

	if use ldap; then
		sed -i \
			-e "s:# \(LOOKUP_LDAP=yes\):\1:" \
			-e "s:# \(LDAP_LIB_TYPE=OPENLDAP2\):\1:" Local/Makefile
		LOOKUP_INCLUDE="-I/usr/include/ldap"
		LOOKUP_LIBS="-L/usr/lib -lldap -llber"
	fi

	if use mysql; then
		sed -i "s:# LOOKUP_MYSQL=yes:LOOKUP_MYSQL=yes:" Local/Makefile
		LOOKUP_INCLUDE="$LOOKUP_INCLUDE -I/usr/include/mysql"
		LOOKUP_LIBS="$LOOKUP_LIBS -L/usr/lib -lmysqlclient"
	fi

	if use postgres; then
		sed -i "s:# LOOKUP_PGSQL=yes:LOOKUP_PGSQL=yes:" Local/Makefile
		LOOKUP_INCLUDE="$LOOKUP_INCLUDE -I/usr/include/postgresql"
		LOOKUP_LIBS="$LOOKUP_LIBS -lpq"
	fi

	if [ -n "$LOOKUP_INCLUDE" ]; then
		sed -i "s:# LOOKUP_INCLUDE=-I /usr/local/ldap/include -I /usr/local/mysql/include -I /usr/local/pgsql/include:LOOKUP_INCLUDE=$LOOKUP_INCLUDE:" \
			Local/Makefile
	fi

	if [ -n "$LOOKUP_LIBS" ]; then
		sed -i "s:# LOOKUP_LIBS=-L/usr/local/lib -lldap -llber -lmysqlclient -lpq -lgds:LOOKUP_LIBS=$LOOKUP_LIBS:" \
			Local/Makefile
	fi


	cat Makefile | sed -e 's/^buildname=.*/buildname=exim-gentoo/g' > Makefile.gentoo && mv -f Makefile.gentoo Makefile

	sed -i "s:# LOOKUP_DSEARCH=yes:LOOKUP_DSEARCH=yes:" Local/Makefile
	if use wildlsearch; then
		sed -i \
			-e "s:# LOOKUP_WILDLSEARCH=yes:LOOKUP_WILDLSEARCH=yes:" \
			-e "s:# LOOKUP_NWILDLSEARCH=yes:LOOKUP_NWILDLSEARCH=yes:" Local/Makefile
	fi

	if use dnsdb; then
		sed -i "s:# LOOKUP_DNSDB=yes:LOOKUP_DNSDB=yes:" Local/Makefile
	fi
	sed -i "s:# LOOKUP_CDB=yes:LOOKUP_CDB=yes:" Local/Makefile

	# Use the "native" interface to the DBM library
	echo "USE_DB=yes" >> ${S}/Local/Makefile
}

src_compile() {
	make || die "make failed"
}


src_install () {
	cd ${S}/build-exim-gentoo
	exeinto /usr/sbin
	doexe exim
	if use X;then
			doexe eximon.bin
			doexe eximon
	fi
	fperms 4755 /usr/sbin/exim

	dodir /usr/bin /usr/sbin /usr/lib
	dosym ../sbin/exim /usr/bin/mailq
	dosym ../sbin/exim /usr/bin/newaliases
	einfo "The Exim ebuild will no longer touch /usr/bin/mail, so as not to interfere with mailx/nail."
	dosym exim /usr/sbin/rsmtp
	dosym exim /usr/sbin/rmail
	if \[ ! -e /usr/lib/sendmail \];
	then
		dosym /usr/sbin/sendmail /usr/lib/sendmail
	fi

	if use mailwrapper
	then
		insinto /etc/mail
		doins ${FILESDIR}/mailer.conf
	else
		dosym exim /usr/sbin/sendmail
	fi

	exeinto /usr/sbin
	for i in exicyclog exim_dbmbuild exim_dumpdb exim_fixdb exim_lock \
		exim_tidydb exinext exiwhat exigrep eximstats exiqsumm \
		convert4r3 convert4r4
	do
		doexe $i
	done

	dodoc ${S}/doc/*
	doman ${S}/doc/exim.8

	# conf files
	insinto /etc/exim
	newins ${S}/src/configure.default.orig exim.conf.dist
	if use exiscan-acl; then
		newins ${S}/src/configure.default exim.conf.exiscan-acl
	fi
	doins ${FILESDIR}/system_filter.exim
	doins ${FILESDIR}/auth_conf.sub
	if use exiscan; then
		newins ${S}/src/configure.default exim.conf.exiscan
		doins ${FILESDIR}/exiscan.conf
	fi

	# INSTALL a pam.d file for SMTP AUTH that works with gentoo's pam
	insinto /etc/pam.d
	newins ${FILESDIR}/pam.d-exim exim

	exeinto /etc/init.d
	newexe ${FILESDIR}/exim.rc6 exim

	insinto /etc/conf.d
	newins ${FILESDIR}/exim.confd exim

	DIROPTIONS="--mode=0750 --owner=mail --group=mail"
	dodir /var/log/${PN}
}


pkg_postinst() {
	einfo "/etc/exim/system_filter.exim is a sample system_filter."
	einfo "/etc/exim/auth_conf.sub contains the configuration sub for using smtp auth."
	einfo "Please create /etc/exim/exim.conf from /etc/exim/exim.conf.dist."

	if ! use mailwrapper && [[ -e /etc/mailer.conf ]]
	then
		einfo
		einfo "Since you emerged $PN without mailwrapper in USE,"
		einfo "you probably want to 'emerge -C mailwrapper' now."
		einfo
	fi
}