diff --git a/net-mail/courier-imap/courier-imap-4.3.0.ebuild b/net-mail/courier-imap/courier-imap-4.3.0.ebuild
new file mode 100644
index 0000000..58d2528
--- /dev/null
+++ b/net-mail/courier-imap/courier-imap-4.3.0.ebuild
@@ -0,0 +1,267 @@
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: Exp $
+
+inherit autotools eutils multilib
+
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~x86-fbsd"
+
+DESCRIPTION="An IMAP daemon designed specifically for maildirs."
+HOMEPAGE="http://www.courier-mta.org/"
+SRC_URI="mirror://sourceforge/courier/${P}.tar.bz2"
+LICENSE="GPL-3"
+SLOT="0"
+IUSE="berkdb debug fam gdbm ipv6 nls selinux gnutls"
+
+# userpriv breaks linking against vpopmail
+RESTRICT="userpriv"
+
+RDEPEND="gnutls? ( net-libs/gnutls )
+		!gnutls? ( >=dev-libs/openssl-0.9.6 )
+		>=net-libs/courier-authlib-0.57
+		>=net-mail/mailbase-0.00-r8
+		berkdb? ( sys-libs/db )
+		fam? ( virtual/fam )
+		gdbm? ( >=sys-libs/gdbm-1.8.0 )
+		selinux? ( sec-policy/selinux-courier-imap )"
+DEPEND="${RDEPEND}
+		dev-lang/perl
+		!mail-mta/courier
+		userland_GNU? ( sys-process/procps )"
+
+PROVIDE="virtual/imapd"
+
+RC_VER="4.0.6-r1"
+INITD_VER="4.0.6-r1"
+
+pkg_setup() {
+	if ! use berkdb && ! use gdbm ; then
+		echo
+		eerror "Either the 'berkdb' or the 'gdbm' USE flag is required."
+		eerror "Please add it to '/etc/make.conf' or '/etc/portage/package.use'."
+		eerror "Use 'man 5 portage' for more info on '/etc/portage/package.use'."
+		echo
+		die "Required USE flag missing."
+	fi
+}
+
+vpopmail_setup() {
+	VPOPMAIL_INSTALLED=
+	VPOPMAIL_DIR=
+	export VPOPMAIL_INSTALLED VPOPMAIL_DIR
+	VPOPMAIL_DIR=$(grep ^vpopmail /etc/passwd 2>/dev/null | cut -d: -f6)
+	VPOPMAIL_INSTALLED=
+	if has_version 'net-mail/vpopmail' && [[ -n "${VPOPMAIL_DIR}" ]] && [[ -f "${VPOPMAIL_DIR}/etc/lib_deps" ]] ; then
+		VPOPMAIL_INSTALLED=1
+	else
+		VPOPMAIL_DIR=
+	fi
+}
+
+src_unpack() {
+	unpack ${A}
+	cd "${S}"
+
+	# Bug #48838. Patch to enable/disable FAM support.
+	# 20 Aug 2004 langthang@gentoo.org
+	# This patch should fix bug #51540. fam USE flag is not needed for shared folder support.
+	epatch "${FILESDIR}"/${PN}-4.0.1-disable-fam-configure.in.patch
+
+	# Kill unneeded call to AC_PROG_SYSCONFTOOL (bug #168206).
+	epatch "${FILESDIR}"/${PN}-4.0.6-aclocal-fix.patch
+
+	# as-needed fix (bug #168769).
+	epatch "${FILESDIR}"/${P}-as-needed.patch
+
+	# These patches should fix problems detecting BerkeleyDB.
+	# We now can compile with db4 support.
+	if use berkdb ; then
+		epatch "${FILESDIR}"/${PN}-4.0.6-db4-bdbobj_configure.in.patch
+		epatch "${FILESDIR}"/${PN}-4.0.6-db4-tcpd_configure.in.patch
+		epatch "${FILESDIR}"/${PN}-4.0.6-db4-configure.in.patch
+	fi
+
+	ebegin "Recreating configure"
+	AT_NO_RECURSIVE="true" eautoreconf || die "eautoreconf on . failed"
+	eend $?
+
+	cd "${S}/maildir"
+	ebegin "Recreating maildir/configure"
+	eautoreconf || die "eautoreconf on maildir failed"
+	eend $?
+
+	cd "${S}/bdbobj"
+	ebegin "Recreating bdbobj/configure"
+	eautoreconf || die "eautoreconf on bdbobj failed"
+	eend $?
+
+	cd "${S}/tcpd"
+	ebegin "Recreating tcpd/configure"
+	eautoreconf || die "eautoreconf on tcpd failed"
+	eend $?
+}
+
+src_compile() {
+	vpopmail_setup
+
+	local myconf=""
+
+	# 19 Aug 2004 langthang@gentoo.org
+	# Default to gdbm if both berkdb and gdbm are present.
+	if use gdbm ; then
+		einfo "Building with GDBM support"
+		myconf="${myconf} --with-db=gdbm"
+	elif use berkdb ; then
+		einfo "Building with BerkeleyDB support"
+		myconf="${myconf} --with-db=db"
+	fi
+
+	# The default character set is ISO-8859-1/US-ASCII.
+	# USE 'nls' will enable all available character sets.
+	# Set ENABLE_UNICODE=iso-8859-1,utf-8,iso-8859-10
+	# to include only specified translation tables.
+	if use nls && [[ -z "${ENABLE_UNICODE}" ]] ; then
+		einfo "ENABLE_UNICODE is not set, building with all available character sets"
+		myconf="${myconf} --enable-unicode"
+	elif use nls ; then
+		einfo "ENABLE_UNICODE is set, building with unicode=${ENABLE_UNICODE}"
+		myconf="${myconf} --enable-unicode=${ENABLE_UNICODE}"
+	else
+		einfo "Disabling unicode support"
+		myconf="${myconf} --disable-unicode"
+	fi
+
+	use debug && myconf="${myconf} debug=true"
+
+	# Fix for bug #21330
+	CFLAGS="$(echo ${CFLAGS} | xargs)"
+	CXXFLAGS="$(echo ${CXXFLAGS} | xargs)"
+	LDFLAGS="$(echo ${LDFLAGS} | xargs)"
+
+	# Do the actual build now
+	LDFLAGS="${LDFLAGS} " econf \
+		--disable-root-check \
+		--bindir=/usr/sbin \
+		--mandir=/usr/share/man \
+		--sysconfdir=/etc/${PN} \
+		--libexecdir=/usr/$(get_libdir)/${PN} \
+		--localstatedir=/var/lib/${PN} \
+		--with-authdaemonvar=/var/lib/${PN}/authdaemon \
+		--enable-workarounds-for-imap-client-bugs \
+		--with-mailuser=mail \
+		--with-mailgroup=mail \
+		$(use_with fam) \
+		$(use_with ipv6) \
+		$(use_with gnutls) \
+		${myconf} || die "econf failed"
+
+	# Change the pem file location.
+	sed -i -e "s:^\(TLS_CERTFILE=\).*:\1/etc/courier-imap/imapd.pem:" \
+		imap/imapd-ssl.dist || \
+		die "sed failed"
+
+	sed -i -e "s:^\(TLS_CERTFILE=\).*:\1/etc/courier-imap/pop3d.pem:" \
+		imap/pop3d-ssl.dist || \
+		die "sed failed"
+
+	emake || die "emake failed"
+}
+
+src_install() {
+	vpopmail_setup
+
+	dodir /var/lib/${PN} /etc/pam.d
+	emake DESTDIR="${D}" install || die "emake install failed"
+	rm -Rf "${D}/etc/pam.d"
+
+	# Avoid name collisions in /usr/sbin wrt imapd and pop3d
+	cd "${D}/usr/sbin"
+	for name in imapd pop3d ; do
+		mv -f "${name}" "courier-${name}" || die "Failed to mv ${name} to courier-${name}"
+	done
+
+	# Hack /usr/lib/courier-imap/foo.rc to use ${MAILDIR} instead of
+	# 'Maildir', and to use /usr/sbin/courier-foo names.
+	cd "${D}/usr/$(get_libdir)/${PN}"
+	for service in {imapd,pop3d}{,-ssl} ; do
+		sed -i -e 's/Maildir/${MAILDIR}/' "${service}.rc" || die "sed failed"
+		sed -i -e "s/\/usr\/sbin\/${service}/\/usr\/sbin\/courier-${service}/" "${service}.rc" || die "sed failed"
+	done
+
+	# Rename the config files correctly and add a value for ${MAILDIR} to them.
+	cd "${D}/etc/${PN}"
+	for service in {imapd,pop3d}{,-ssl} ; do
+		mv -f "${service}.dist" "${service}" || die "Failed to mv ${service}.dist to ${service}"
+		echo -e '\n# Hardwire a value for ${MAILDIR}' >> "${service}"
+		echo 'MAILDIR=.maildir' >> "${service}"
+		echo 'MAILDIRPATH=.maildir' >> "${service}"
+	done
+	for service in imapd pop3d ; do
+		echo -e '# Put any program for ${PRERUN} here' >> "${service}"
+		echo 'PRERUN=' >> "${service}"
+		echo -e '# Put any program for ${LOGINRUN} here' >> "${service}"
+		echo -e '# this is for relay-ctrl-allow in 4*' >> "${service}"
+		echo 'LOGINRUN=' >> "${service}"
+	done
+
+	cd "${D}/usr/sbin"
+	for x in * ; do
+		if [[ -L "${x}" ]] ; then
+			rm -f "${x}" || die "Failed to rm ${x}"
+		fi
+	done
+
+	cd ../share
+	mv -f * ../sbin
+	mv -f ../sbin/man .
+	cd ..
+
+	for x in mkimapdcert mkpop3dcert ; do
+		mv -f "${D}/usr/sbin/${x}" "${D}/usr/sbin/${x}.orig" || die "Failed to mv /usr/sbin/${x} to /usr/sbin/${x}.orig"
+	done
+
+	exeinto /usr/sbin
+	doexe "${FILESDIR}/mkimapdcert" "${FILESDIR}/mkpop3dcert" || die "doexe failed"
+
+	dosym /usr/sbin/courierlogger /usr/$(get_libdir)/${PN}/courierlogger || die "dosym failed"
+
+	mkdir "${WORKDIR}/tmp" ; cd "${WORKDIR}/tmp"
+	for initd in courier-{imapd,pop3d}{,-ssl} ; do
+		sed -e "s:GENTOO_LIBDIR:$(get_libdir):g" "${FILESDIR}/${PN}-${INITD_VER}-${initd}.rc6" > "${initd}" || die "initd libdir-sed failed"
+		doinitd "${initd}" || die "doinitd ${initd} failed"
+	done
+	exeinto /usr/$(get_libdir)/${PN}
+	for exe in gentoo-{imapd,pop3d}{,-ssl}.rc courier-{imapd,pop3d}.indirect ; do
+		sed -e "s:GENTOO_LIBDIR:$(get_libdir):g" "${FILESDIR}/${PN}-${RC_VER}-${exe}" > "${exe}" || die "exe libdir-sed failed"
+		doexe "${exe}" || die "doexe ${exe} failed"
+	done
+
+	dodir /usr/bin
+	mv -f "${D}/usr/sbin/maildirmake" "${D}/usr/bin/maildirmake" || die "Failed to mv /usr/sbin/maildirmake to /usr/bin/maildirmake"
+
+	# Bug #45953, more docs.
+	cd "${S}"
+	dohtml -r "${S}"/*
+	dodoc "${S}"/{00README.NOW.OR.SUFFER,AUTHORS,INSTALL,NEWS,README,ChangeLog} "${FILESDIR}"/${PN}-gentoo.readme
+	docinto imap
+	dodoc "${S}"/imap/{ChangeLog,BUGS,BUGS.html,README}
+	docinto maildir
+	dodoc "${S}"/maildir/{AUTHORS,INSTALL,README.maildirquota.txt,README.sharedfolders.txt}
+	docinto tcpd
+	dodoc "${S}"/tcpd/README.couriertls
+}
+
+pkg_postinst() {
+	elog "Authdaemond is no longer provided by this package."
+	elog "Authentication libraries are now in courier-authlib."
+	elog "For a quick-start howto please refer to:"
+	elog "/usr/share/doc/${P}/${PN}-gentoo.readme.gz"
+	# Some users have been reporting that permissions on this directory were
+	# getting scrambled, so let's ensure that they are sane.
+	chmod 0755 "${ROOT}/usr/$(get_libdir)/${PN}" || die "Failed to ensure sane permissions on ${ROOT}/usr/$(get_libdir)/${PN}"
+}
+
+src_test() {
+	ewarn "make check is not supported by this package due to the"
+	ewarn "--enable-workarounds-for-imap-client-bugs option."
+}
diff --git a/net-mail/courier-imap/files/authdaemond-3.0.4-r1 b/net-mail/courier-imap/files/authdaemond-3.0.4-r1
new file mode 100644
index 0000000..25baf31
--- /dev/null
+++ b/net-mail/courier-imap/files/authdaemond-3.0.4-r1
@@ -0,0 +1,42 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-mail/courier-imap/files/authdaemond-3.0.4-r1,v 1.3 2004/08/22 23:52:08 robbat2 Exp $
+depend() {
+	need net
+}
+
+checkconfig() {
+	if [ ! -e /etc/courier-imap/authdaemonrc ] ; then
+		eerror "You need an /etc/courier-imap/authdaemonrc file to run authdaemon"
+		return 1
+	fi
+}
+
+setauth() {
+	source /etc/courier-imap/authdaemonrc
+	AUTHLIB="/usr/lib/courier-imap/authlib"
+	source /etc/courier-imap/authdaemond.conf
+	[ -z "$version" ] && version="${AUTHDAEMOND}"
+	pidfile="/var/run/authdaemon.pid"
+	logger="/usr/lib/courier-imap/courierlogger"
+}
+
+start() {
+	checkconfig || return 1
+	setauth
+	
+	ebegin "Starting ${AUTHDAEMOND}"
+	start-stop-daemon --quiet --start --pidfile "$pidfile" --exec \
+		/usr/bin/env -- - $logger -pid="$pidfile" -start "${AUTHLIB}/${AUTHDAEMOND}" 
+	eend $?
+}
+
+stop() {
+	setauth
+	
+	ebegin "Stopping ${AUTHDAEMOND}"
+	start-stop-daemon --quiet --stop \
+		--pidfile "$pidfile"
+	eend $?
+}
diff --git a/net-mail/courier-imap/files/authdaemond.conf-3.0.4-r1 b/net-mail/courier-imap/files/authdaemond.conf-3.0.4-r1
new file mode 100644
index 0000000..fa03934
--- /dev/null
+++ b/net-mail/courier-imap/files/authdaemond.conf-3.0.4-r1
@@ -0,0 +1,14 @@
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-mail/courier-imap/files/authdaemond.conf-3.0.4-r1,v 1.2 2004/06/26 23:30:58 robbat2 Exp $
+
+# This file should contain your chosen authenticator
+# This overrides 'version' in /etc/courier-imap/authdaemonrc
+# Valid choices are..
+#
+# AUTHDAEMOND="authdaemond.plain"
+# AUTHDAEMOND="authdaemond.mysql"
+# AUTHDAEMOND="authdaemond.pgsql"
+# AUTHDAEMOND="authdaemond.ldap"
+#
+AUTHDAEMOND="authdaemond.plain"
diff --git a/net-mail/courier-imap/files/courier-imap-3.0.8-db4-bdbobj_configure.in.patch b/net-mail/courier-imap/files/courier-imap-3.0.8-db4-bdbobj_configure.in.patch
new file mode 100644
index 0000000..776fdc1
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-3.0.8-db4-bdbobj_configure.in.patch
@@ -0,0 +1,31 @@
+--- courier-imap-3.0.7-orig/bdbobj/configure.in	2001-09-18 18:26:28.000000000 -0700
++++ courier-imap-3.0.7/bdbobj/configure.in	2004-08-14 16:15:08.469316646 -0700
+@@ -21,15 +21,19 @@
+ dnl Checks for libraries.
+ 
+ saveLIBS="$LIBS"
+-AC_CHECK_LIB(db, dbopen, [ LIBDB=-ldb ; LIBS="-ldb $LIBS" ],
+-	AC_CHECK_LIB(db, db_open, [ LIBDB=-ldb ; LIBS="-ldb $LIBS"],
+-	AC_CHECK_LIB(db, db_env_create, [ LIBDB=-ldb; LIBS="-ldb $LIBS"])
+-	))
+-
+-FOUND_DB=0
+-AC_CHECK_FUNC(dbopen, FOUND_DB=1)
+-AC_CHECK_FUNC(db_open, FOUND_DB=1)
+-AC_CHECK_FUNC(db_env_create, FOUND_DB=1)
++for dbname in db-4.2 db4.2 db42 db-4.1 db4.1 db41 db-4.0 db4.0 db-4 db40 db4 db
++  do
++        AC_CHECK_LIB($dbname, db_create_4002, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ],
++          AC_CHECK_LIB($dbname, db_create_4001, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ],
++            AC_CHECK_LIB($dbname, db_create_4000, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ],
++              AC_CHECK_LIB($dbname, db_create, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ]))))
++
++  done
++FOUND_DB=0
++AC_CHECK_FUNC(db_create_4002, FOUND_DB=1)
++AC_CHECK_FUNC(db_create_4001, FOUND_DB=1)
++AC_CHECK_FUNC(db_create_4000, FOUND_DB=1)
++AC_CHECK_FUNC(db_create, FOUND_DB=1)
+ 
+ LIBS="$saveLIBS"
+ 
diff --git a/net-mail/courier-imap/files/courier-imap-3.0.8-db4-configure.in.patch b/net-mail/courier-imap/files/courier-imap-3.0.8-db4-configure.in.patch
new file mode 100644
index 0000000..d8ac46e
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-3.0.8-db4-configure.in.patch
@@ -0,0 +1,39 @@
+--- courier-imap-3.0.7-orig/configure.in	2004-08-01 07:08:16.000000000 -0700
++++ courier-imap-3.0.7/configure.in	2004-08-14 16:02:03.856436728 -0700
+@@ -11,7 +11,6 @@
+ AC_PROG_INSTALL
+ AC_PROG_LN_S
+ AC_PROG_MAKE_SET
+-AC_PROG_SYSCONFTOOL
+ 
+ AC_PATH_PROGS(SETENV, env)
+ 
+@@ -132,16 +131,18 @@
+ 
+ if test "$db" != "gdbm"
+ then
+-
+-	AC_CHECK_LIB(db, dbopen, [ LIBDB=-ldb ; LIBS="-ldb $LIBS" ],
+-		AC_CHECK_LIB(db, db_open, [ LIBDB=-ldb ; LIBS="-ldb $LIBS"],
+-		AC_CHECK_LIB(db, db_env_create,
+-				[ LIBDB=-ldb; LIBS="-ldb $LIBS"])
+-	))
+-
+-	AC_CHECK_FUNC(dbopen, HAVE_BDB=1)
+-	AC_CHECK_FUNC(db_open, HAVE_BDB=1)
+-	AC_CHECK_FUNC(db_env_create, HAVE_BDB=1)
++  for dbname in db-4.2 db4.2 db42 db-4.1 db4.1 db41 db-4.0 db4.0 db-4 db40 db4 db
++    do
++	AC_CHECK_LIB($dbname, db_create_4002, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ],
++ 	  AC_CHECK_LIB($dbname, db_create_4001, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ],
++ 	    AC_CHECK_LIB($dbname, db_create_4000, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ],
++ 	      AC_CHECK_LIB($dbname, db_create, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ]))))
++    done
++  AC_CHECK_FUNC(db_create_4002, HAVE_BDB=1)
++  AC_CHECK_FUNC(db_create_4001, HAVE_BDB=1)
++  AC_CHECK_FUNC(db_create_4000, HAVE_BDB=1)
++  AC_CHECK_FUNC(db_create, HAVE_BDB=1)
++
+ fi
+ 
+ LIBS="$saveLIBS"
diff --git a/net-mail/courier-imap/files/courier-imap-3.0.8-disable-fam-configure.in.patch b/net-mail/courier-imap/files/courier-imap-3.0.8-disable-fam-configure.in.patch
new file mode 100644
index 0000000..7019d02
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-3.0.8-disable-fam-configure.in.patch
@@ -0,0 +1,23 @@
+--- courier-imap-3.0.7-orig/maildir/configure.in	2004-06-08 15:44:23.000000000 -0700
++++ courier-imap-3.0.7/maildir/configure.in	2004-08-14 15:28:20.525714876 -0700
+@@ -60,6 +60,12 @@
+ dnl Checks for library functions.
+ AC_CHECK_HEADER(fam.h, :, :)
+ AC_CHECK_FUNCS(symlink readlink strcasecmp utime utimes)
++AC_ARG_WITH(fam, [  --with-fam              Compile with FAM support],
++       fam="$withval",
++       fam="no")
++
++if test "$fam" != "no"
++then
+ AC_CHECK_LIB(fam, FAMOpen,  [
+ 			LIBFAM=-lfam
+ 			AC_DEFINE_UNQUOTED(HAVE_FAM,1,
+@@ -74,6 +80,7 @@
+ AC_MSG_ERROR([[FAM development libraries not found.]]) ]
+ 					)
+ 		  ])
++fi
+ 
+ AC_SUBST(LIBFAM)
+ 
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.1-courier-imapd-ssl.rc6 b/net-mail/courier-imap/files/courier-imap-4.0.1-courier-imapd-ssl.rc6
new file mode 100644
index 0000000..21b386c
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.1-courier-imapd-ssl.rc6
@@ -0,0 +1,42 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-mail/courier-imap/files/courier-imap-4.0.1-courier-imapd-ssl.rc6,v 1.1 2005/01/05 15:46:55 langthang Exp $
+
+depend() {
+	need net courier-authlib
+	use famd
+}
+
+source /etc/courier-imap/imapd-ssl
+
+checkconfig() {
+	if [ ! -e /etc/courier-imap/imapd-ssl ] ; then
+		eerror "You need an /etc/courier-imap/imapd-ssl file to run courier-imapd"
+		return 1
+	fi
+	source /etc/courier-imap/imapd-ssl || {
+		eerror "There are syntax errors in /etc/courier-imap/imapd-ssl"
+		eerror "Please correct them before trying to start imapd-ssl"
+		return 3
+	}
+	if [ ! -e "${TLS_CERTFILE}" ] ; then
+		eerror "You need to create a SSL certificate to use IMAP over SSL"
+		eerror "Edit /etc/courier-imap/imapd.cnf, then run: mkimapdcert"
+		return 2
+	fi
+}
+
+start() {
+	checkconfig || return 1
+	ebegin "Starting courier-imapd over SSL"
+	start-stop-daemon --quiet --start --exec /usr/bin/env - /usr/lib/courier-imap/gentoo-imapd-ssl.rc \
+		--pid=$SSLPIDFILE
+	eend $?
+}
+
+stop() {
+	ebegin "Stopping courier-imapd over SSL"
+	start-stop-daemon --quiet --stop --pid=$SSLPIDFILE
+	eend $?
+}
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.1-courier-imapd.rc6 b/net-mail/courier-imap/files/courier-imap-4.0.1-courier-imapd.rc6
new file mode 100644
index 0000000..aa9f3b8
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.1-courier-imapd.rc6
@@ -0,0 +1,37 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-mail/courier-imap/files/courier-imap-4.0.1-courier-imapd.rc6,v 1.1 2005/01/05 15:46:55 langthang Exp $
+
+depend() {
+	need net courier-authlib
+	use famd
+}
+
+source /etc/courier-imap/imapd
+
+checkconfig() {
+	if [ ! -e /etc/courier-imap/imapd ] ; then
+		eerror "You need an /etc/courier-imap/imapd file to run courier-imapd"
+		return 1
+	fi
+	source /etc/courier-imap/imapd || {
+		eerror "There are syntax errors in /etc/courier-imap/imapd"
+		eerror "Please correct them before trying to start imapd"
+		return 2
+	}
+}
+
+start() {
+	checkconfig || return 1
+	ebegin "Starting courier-imapd"
+	start-stop-daemon --quiet --start --exec /usr/bin/env - /usr/lib/courier-imap/gentoo-imapd.rc \
+		--pid=$PIDFILE
+	eend $?
+}
+
+stop() {
+	ebegin "Stopping courier-imapd"
+	start-stop-daemon --quiet --stop --pid=$PIDFILE
+	eend $?
+}
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.1-courier-pop3d-ssl.rc6 b/net-mail/courier-imap/files/courier-imap-4.0.1-courier-pop3d-ssl.rc6
new file mode 100644
index 0000000..52dabb3
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.1-courier-pop3d-ssl.rc6
@@ -0,0 +1,42 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-mail/courier-imap/files/courier-imap-4.0.1-courier-pop3d-ssl.rc6,v 1.1 2005/01/05 15:46:55 langthang Exp $
+
+depend() {
+	need net courier-authlib
+	use famd
+}
+
+source /etc/courier-imap/pop3d-ssl
+
+checkconfig() {
+	if [ ! -e /etc/courier-imap/pop3d-ssl ] ; then
+		eerror "You need an /etc/courier-imap/pop3d-ssl file to run courier-pop3d"
+		return 1
+	fi
+	source /etc/courier-imap/pop3d-ssl || {
+		eerror "There are syntax errors in /etc/courier-imap/pop3d-ssl"
+		eerror "Please correct them before trying to start pop3d-ssl"
+		return 3
+	}
+	if [ ! -e "${TLS_CERTFILE}" ] ; then
+		eerror "You need to create a SSL certificate to use POP3 over SSL"
+		eerror "Edit /etc/courier-imap/pop3d.cnf, then run: mkpop3dcert"
+		return 2
+	fi
+}
+
+start() {
+	checkconfig || return 1
+	ebegin "Starting courier-pop3d over SSL"
+	start-stop-daemon --quiet --start --exec /usr/bin/env - /usr/lib/courier-imap/gentoo-pop3d-ssl.rc \
+		--pidfile $SSLPIDFILE
+	eend $?
+}
+
+stop() {
+	ebegin "Stopping courier-pop3d over SSL"
+	start-stop-daemon --quiet --stop --pidfile $SSLPIDFILE
+	eend $?
+}
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.1-courier-pop3d.rc6 b/net-mail/courier-imap/files/courier-imap-4.0.1-courier-pop3d.rc6
new file mode 100644
index 0000000..849938d
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.1-courier-pop3d.rc6
@@ -0,0 +1,37 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-mail/courier-imap/files/courier-imap-4.0.1-courier-pop3d.rc6,v 1.1 2005/01/05 15:46:55 langthang Exp $
+
+depend() {
+	need net courier-authlib
+	use famd
+}
+
+source /etc/courier-imap/pop3d
+
+checkconfig() {
+	if [ ! -e /etc/courier-imap/pop3d ] ; then
+		eerror "You need an /etc/courier-imap/pop3d file to run courier-pop3d"
+		return 1
+	fi
+	source /etc/courier-imap/pop3d || {
+		eerror "There are syntax errors in /etc/courier-imap/pop3d"
+		eerror "Please correct them before trying to start pop3d"
+		return 2
+	}
+}
+
+start() {
+	checkconfig || return 1
+	ebegin "Starting courier-pop3d"
+	start-stop-daemon --quiet --start --exec /usr/bin/env - /usr/lib/courier-imap/gentoo-pop3d.rc \
+		--pidfile $PIDFILE
+	eend $?
+}
+
+stop() {
+	ebegin "Stopping courier-pop3d"
+	start-stop-daemon --quiet --stop --pidfile $PIDFILE
+	eend $?
+}
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.1-db4-bdbobj_configure.in.patch b/net-mail/courier-imap/files/courier-imap-4.0.1-db4-bdbobj_configure.in.patch
new file mode 100644
index 0000000..776fdc1
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.1-db4-bdbobj_configure.in.patch
@@ -0,0 +1,31 @@
+--- courier-imap-3.0.7-orig/bdbobj/configure.in	2001-09-18 18:26:28.000000000 -0700
++++ courier-imap-3.0.7/bdbobj/configure.in	2004-08-14 16:15:08.469316646 -0700
+@@ -21,15 +21,19 @@
+ dnl Checks for libraries.
+ 
+ saveLIBS="$LIBS"
+-AC_CHECK_LIB(db, dbopen, [ LIBDB=-ldb ; LIBS="-ldb $LIBS" ],
+-	AC_CHECK_LIB(db, db_open, [ LIBDB=-ldb ; LIBS="-ldb $LIBS"],
+-	AC_CHECK_LIB(db, db_env_create, [ LIBDB=-ldb; LIBS="-ldb $LIBS"])
+-	))
+-
+-FOUND_DB=0
+-AC_CHECK_FUNC(dbopen, FOUND_DB=1)
+-AC_CHECK_FUNC(db_open, FOUND_DB=1)
+-AC_CHECK_FUNC(db_env_create, FOUND_DB=1)
++for dbname in db-4.2 db4.2 db42 db-4.1 db4.1 db41 db-4.0 db4.0 db-4 db40 db4 db
++  do
++        AC_CHECK_LIB($dbname, db_create_4002, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ],
++          AC_CHECK_LIB($dbname, db_create_4001, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ],
++            AC_CHECK_LIB($dbname, db_create_4000, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ],
++              AC_CHECK_LIB($dbname, db_create, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ]))))
++
++  done
++FOUND_DB=0
++AC_CHECK_FUNC(db_create_4002, FOUND_DB=1)
++AC_CHECK_FUNC(db_create_4001, FOUND_DB=1)
++AC_CHECK_FUNC(db_create_4000, FOUND_DB=1)
++AC_CHECK_FUNC(db_create, FOUND_DB=1)
+ 
+ LIBS="$saveLIBS"
+ 
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.1-db4-configure.in.patch b/net-mail/courier-imap/files/courier-imap-4.0.1-db4-configure.in.patch
new file mode 100644
index 0000000..400b746
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.1-db4-configure.in.patch
@@ -0,0 +1,38 @@
+--- configure.in.orig	2004-11-16 16:02:11.045791896 -0800
++++ configure.in	2004-11-16 16:03:06.743324584 -0800
+@@ -11,7 +11,6 @@
+ AC_PROG_INSTALL
+ AC_PROG_LN_S
+ AC_PROG_MAKE_SET
+-AC_PROG_SYSCONFTOOL
+ AC_LIBTOOL_DLOPEN
+ AM_PROG_LIBTOOL
+ 
+@@ -150,16 +150,18 @@
+ 
+ if test "$db" != "gdbm"
+ then
++  for dbname in db-4.2 db4.2 db42 db-4.1 db4.1 db41 db-4.0 db4.0 db-4 db40 db4 db
++    do
++	AC_CHECK_LIB($dbname, db_create_4002, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ],
++ 	  AC_CHECK_LIB($dbname, db_create_4001, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ],
++ 	    AC_CHECK_LIB($dbname, db_create_4000, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ],
++ 	      AC_CHECK_LIB($dbname, db_create, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ]))))
++    done
++  AC_CHECK_FUNC(db_create_4002, HAVE_BDB=1)
++  AC_CHECK_FUNC(db_create_4001, HAVE_BDB=1)
++  AC_CHECK_FUNC(db_create_4000, HAVE_BDB=1)
++  AC_CHECK_FUNC(db_create, HAVE_BDB=1)
+ 
+-	AC_CHECK_LIB(db, dbopen, [ LIBDB=-ldb ; LIBS="-ldb $LIBS" ],
+-		AC_CHECK_LIB(db, db_open, [ LIBDB=-ldb ; LIBS="-ldb $LIBS"],
+-		AC_CHECK_LIB(db, db_env_create,
+-				[ LIBDB=-ldb; LIBS="-ldb $LIBS"])
+-	))
+-
+-	AC_CHECK_FUNC(dbopen, HAVE_BDB=1)
+-	AC_CHECK_FUNC(db_open, HAVE_BDB=1)
+-	AC_CHECK_FUNC(db_env_create, HAVE_BDB=1)
+ fi
+ 
+ LIBS="$saveLIBS"
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.1-disable-fam-configure.in.patch b/net-mail/courier-imap/files/courier-imap-4.0.1-disable-fam-configure.in.patch
new file mode 100644
index 0000000..7019d02
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.1-disable-fam-configure.in.patch
@@ -0,0 +1,23 @@
+--- courier-imap-3.0.7-orig/maildir/configure.in	2004-06-08 15:44:23.000000000 -0700
++++ courier-imap-3.0.7/maildir/configure.in	2004-08-14 15:28:20.525714876 -0700
+@@ -60,6 +60,12 @@
+ dnl Checks for library functions.
+ AC_CHECK_HEADER(fam.h, :, :)
+ AC_CHECK_FUNCS(symlink readlink strcasecmp utime utimes)
++AC_ARG_WITH(fam, [  --with-fam              Compile with FAM support],
++       fam="$withval",
++       fam="no")
++
++if test "$fam" != "no"
++then
+ AC_CHECK_LIB(fam, FAMOpen,  [
+ 			LIBFAM=-lfam
+ 			AC_DEFINE_UNQUOTED(HAVE_FAM,1,
+@@ -74,6 +80,7 @@
+ AC_MSG_ERROR([[FAM development libraries not found.]]) ]
+ 					)
+ 		  ])
++fi
+ 
+ AC_SUBST(LIBFAM)
+ 
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.1-gentoo-imapd-ssl.rc b/net-mail/courier-imap/files/courier-imap-4.0.1-gentoo-imapd-ssl.rc
new file mode 100644
index 0000000..b8574d9
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.1-gentoo-imapd-ssl.rc
@@ -0,0 +1,37 @@
+#!/bin/bash
+# $Id: courier-imap-4.0.1-gentoo-imapd-ssl.rc,v 1.1 2005/01/05 15:46:55 langthang Exp $
+#
+# Copyright 1998 - 2000 Double Precision, Inc.
+# See COPYING for distribution information.
+
+prefix=/usr
+exec_prefix=/usr
+bindir=/usr/sbin
+libexecdir=/usr/lib/courier-imap
+
+source /etc/courier-imap/imapd
+source /etc/courier-imap/imapd-ssl
+
+# the new courier-authlib doesn't usee these settings.
+#LIBAUTHMODULES=""
+#for f in `echo $AUTHMODULES`
+#do
+#	LIBAUTHMODULES="$LIBAUTHMODULES /usr/lib/courier-imap/authlib/$f"
+#done
+
+ulimit -d $IMAP_ULIMITD
+export IMAP_TLS=1
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/imapd | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/imapd-ssl | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+
+eval $PRERUN \
+/usr/lib/courier-imap/couriertcpd -address=$SSLADDRESS \
+	-stderrlogger=/usr/lib/courier-imap/courierlogger \
+	-stderrloggername=imapd-ssl \
+	-maxprocs=$MAXDAEMONS -maxperip=$MAXPERIP \
+	-pid=$SSLPIDFILE $TCPDOPTS \
+	$SSLPORT $COURIERTLS -server -tcpd \
+	${exec_prefix}/sbin/imaplogin \
+		/usr/sbin/courier-imapd ${MAILDIR}
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.1-gentoo-imapd.rc b/net-mail/courier-imap/files/courier-imap-4.0.1-gentoo-imapd.rc
new file mode 100644
index 0000000..66f473b
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.1-gentoo-imapd.rc
@@ -0,0 +1,38 @@
+#!/bin/bash
+# $Id: courier-imap-4.0.1-gentoo-imapd.rc,v 1.1 2005/01/05 15:46:55 langthang Exp $
+#
+# Copyright 1998 - 2000 Double Precision, Inc.
+# See COPYING for distribution information.
+
+prefix=/usr
+exec_prefix=/usr
+bindir=/usr/sbin
+libexecdir=/usr/lib/courier-imap
+
+source /etc/courier-imap/imapd-ssl
+source /etc/courier-imap/imapd
+
+# The new courier-authlib doesn't use these settings.
+#LIBAUTHMODULES=""
+#for f in `echo $AUTHMODULES`
+#do
+#	LIBAUTHMODULES="$LIBAUTHMODULES /usr/lib/courier-imap/authlib/$f"
+#done
+
+ulimit -d $IMAP_ULIMITD
+IMAP_STARTTLS="$IMAPDSTARTTLS"
+export IMAPDSTARTTLS IMAP_STARTTLS
+TLS_PROTOCOL=$TLS_STARTTLS_PROTOCOL
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/imapd | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/imapd-ssl | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+
+eval $PRERUN \
+/usr/lib/courier-imap/couriertcpd -address=$ADDRESS \
+	-stderrlogger=/usr/lib/courier-imap/courierlogger \
+	-stderrloggername=imapd \
+	-maxprocs=$MAXDAEMONS -maxperip=$MAXPERIP \
+	-pid=$PIDFILE $TCPDOPTS \
+	$PORT ${exec_prefix}/sbin/imaplogin \
+		/usr/sbin/courier-imapd ${MAILDIR}
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.1-gentoo-pop3d-ssl.rc b/net-mail/courier-imap/files/courier-imap-4.0.1-gentoo-pop3d-ssl.rc
new file mode 100644
index 0000000..88bd882
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.1-gentoo-pop3d-ssl.rc
@@ -0,0 +1,36 @@
+#!/bin/bash
+# $Id: courier-imap-4.0.1-gentoo-pop3d-ssl.rc,v 1.1 2005/01/05 15:46:55 langthang Exp $
+#
+# Copyright 1998 - 2000 Double Precision, Inc.
+# See COPYING for distribution information.
+
+prefix=/usr
+exec_prefix=/usr
+bindir=/usr/sbin
+libexecdir=/usr/lib/courier-imap
+
+source /etc/courier-imap/pop3d
+source /etc/courier-imap/pop3d-ssl
+
+# The new courier-authlib doesn't use these settings.
+#LIBAUTHMODULES=""
+#for f in `echo $AUTHMODULES`
+#do
+#	LIBAUTHMODULES="$LIBAUTHMODULES /usr/lib/courier-imap/authlib/$f"
+#done
+
+export POP3_TLS=1
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/pop3d | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/pop3d-ssl | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+
+eval $PRERUN \
+/usr/lib/courier-imap/couriertcpd -address=$SSLADDRESS \
+	-stderrlogger=/usr/lib/courier-imap/courierlogger \
+	-stderrloggername=pop3d-ssl \
+	-maxprocs=$MAXDAEMONS -maxperip=$MAXPERIP \
+	-pid=$SSLPIDFILE $TCPDOPTS \
+	$SSLPORT $COURIERTLS -server -tcpd \
+	${exec_prefix}/sbin/pop3login \
+		/usr/sbin/courier-pop3d ${MAILDIR}
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.1-gentoo-pop3d.rc b/net-mail/courier-imap/files/courier-imap-4.0.1-gentoo-pop3d.rc
new file mode 100644
index 0000000..4eca8e1
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.1-gentoo-pop3d.rc
@@ -0,0 +1,36 @@
+#!/bin/bash
+# $Id: courier-imap-4.0.1-gentoo-pop3d.rc,v 1.1 2005/01/05 15:46:55 langthang Exp $
+#
+# Copyright 1998 - 2000 Double Precision, Inc.
+# See COPYING for distribution information.
+
+prefix=/usr
+exec_prefix=/usr
+bindir=/usr/sbin
+libexecdir=/usr/lib/courier-imap
+
+source /etc/courier-imap/pop3d-ssl
+source /etc/courier-imap/pop3d
+
+# The new courier-authlib doesn't use these settings.
+#LIBAUTHMODULES=""
+#for f in `echo $AUTHMODULES`
+#do
+#	LIBAUTHMODULES="$LIBAUTHMODULES /usr/lib/courier-imap/authlib/$f"
+#done
+
+export POP3DSTARTTLS=$POP3_STARTTLS
+TLS_PROTOCOL=$TLS_STARTTLS_PROTOCOL
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/pop3d | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/pop3d-ssl | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+
+eval $PRERUN \
+/usr/lib/courier-imap/couriertcpd -address=$ADDRESS \
+	-stderrlogger=/usr/lib/courier-imap/courierlogger \
+	-stderrloggername=pop3d \
+	-maxprocs=$MAXDAEMONS -maxperip=$MAXPERIP \
+	-pid=$PIDFILE $TCPDOPTS \
+	$PORT ${exec_prefix}/sbin/pop3login \
+		/usr/sbin/courier-pop3d ${MAILDIR}
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.1-r1-courier-imapd.indirect b/net-mail/courier-imap/files/courier-imap-4.0.1-r1-courier-imapd.indirect
new file mode 100644
index 0000000..ec95f65
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.1-r1-courier-imapd.indirect
@@ -0,0 +1,5 @@
+#!/bin/bash
+XMAILDIR="$1"
+eval ${LOGINRUN} \
+	/usr/sbin/courier-imapd \
+	${XMAILDIR}
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.1-r1-courier-pop3d.indirect b/net-mail/courier-imap/files/courier-imap-4.0.1-r1-courier-pop3d.indirect
new file mode 100644
index 0000000..c06fa09
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.1-r1-courier-pop3d.indirect
@@ -0,0 +1,5 @@
+#!/bin/bash
+XMAILDIR="$1"
+eval ${LOGINRUN} \
+	/usr/sbin/courier-pop3d \
+	${XMAILDIR}
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.1-r1-gentoo-imapd-ssl.rc b/net-mail/courier-imap/files/courier-imap-4.0.1-r1-gentoo-imapd-ssl.rc
new file mode 100644
index 0000000..e3d0476
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.1-r1-gentoo-imapd-ssl.rc
@@ -0,0 +1,37 @@
+#!/bin/bash
+# $Id: courier-imap-4.0.1-r1-gentoo-imapd-ssl.rc,v 1.1 2005/02/11 15:34:49 robbat2 Exp $
+#
+# Copyright 1998 - 2000 Double Precision, Inc.
+# See COPYING for distribution information.
+
+prefix=/usr
+exec_prefix=/usr
+bindir=/usr/sbin
+libexecdir=/usr/lib/courier-imap
+
+source /etc/courier-imap/imapd
+source /etc/courier-imap/imapd-ssl
+
+# the new courier-authlib doesn't usee these settings.
+#LIBAUTHMODULES=""
+#for f in `echo $AUTHMODULES`
+#do
+#	LIBAUTHMODULES="$LIBAUTHMODULES /usr/lib/courier-imap/authlib/$f"
+#done
+
+ulimit -d $IMAP_ULIMITD
+export IMAP_TLS=1
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/imapd | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/imapd-ssl | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+
+eval $PRERUN \
+/usr/lib/courier-imap/couriertcpd -address=$SSLADDRESS \
+	-stderrlogger=/usr/lib/courier-imap/courierlogger \
+	-stderrloggername=imapd-ssl \
+	-maxprocs=$MAXDAEMONS -maxperip=$MAXPERIP \
+	-pid=$SSLPIDFILE $TCPDOPTS \
+	$SSLPORT $COURIERTLS -server -tcpd \
+	${exec_prefix}/sbin/imaplogin \
+		/usr/lib/courier-imap/courier-imapd.indirect ${MAILDIR}
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.1-r1-gentoo-imapd.rc b/net-mail/courier-imap/files/courier-imap-4.0.1-r1-gentoo-imapd.rc
new file mode 100644
index 0000000..72bc708
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.1-r1-gentoo-imapd.rc
@@ -0,0 +1,38 @@
+#!/bin/bash
+# $Id: courier-imap-4.0.1-r1-gentoo-imapd.rc,v 1.1 2005/02/11 15:34:49 robbat2 Exp $
+#
+# Copyright 1998 - 2000 Double Precision, Inc.
+# See COPYING for distribution information.
+
+prefix=/usr
+exec_prefix=/usr
+bindir=/usr/sbin
+libexecdir=/usr/lib/courier-imap
+
+source /etc/courier-imap/imapd-ssl
+source /etc/courier-imap/imapd
+
+# The new courier-authlib doesn't use these settings.
+#LIBAUTHMODULES=""
+#for f in `echo $AUTHMODULES`
+#do
+#	LIBAUTHMODULES="$LIBAUTHMODULES /usr/lib/courier-imap/authlib/$f"
+#done
+
+ulimit -d $IMAP_ULIMITD
+IMAP_STARTTLS="$IMAPDSTARTTLS"
+export IMAPDSTARTTLS IMAP_STARTTLS
+TLS_PROTOCOL=$TLS_STARTTLS_PROTOCOL
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/imapd | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/imapd-ssl | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+
+eval $PRERUN \
+/usr/lib/courier-imap/couriertcpd -address=$ADDRESS \
+	-stderrlogger=/usr/lib/courier-imap/courierlogger \
+	-stderrloggername=imapd \
+	-maxprocs=$MAXDAEMONS -maxperip=$MAXPERIP \
+	-pid=$PIDFILE $TCPDOPTS \
+	$PORT ${exec_prefix}/sbin/imaplogin \
+		/usr/lib/courier-imap/courier-imapd.indirect ${MAILDIR}
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.1-r1-gentoo-pop3d-ssl.rc b/net-mail/courier-imap/files/courier-imap-4.0.1-r1-gentoo-pop3d-ssl.rc
new file mode 100644
index 0000000..5b1dd5d
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.1-r1-gentoo-pop3d-ssl.rc
@@ -0,0 +1,36 @@
+#!/bin/bash
+# $Id: courier-imap-4.0.1-r1-gentoo-pop3d-ssl.rc,v 1.1 2005/02/11 15:34:49 robbat2 Exp $
+#
+# Copyright 1998 - 2000 Double Precision, Inc.
+# See COPYING for distribution information.
+
+prefix=/usr
+exec_prefix=/usr
+bindir=/usr/sbin
+libexecdir=/usr/lib/courier-imap
+
+source /etc/courier-imap/pop3d
+source /etc/courier-imap/pop3d-ssl
+
+# The new courier-authlib doesn't use these settings.
+#LIBAUTHMODULES=""
+#for f in `echo $AUTHMODULES`
+#do
+#	LIBAUTHMODULES="$LIBAUTHMODULES /usr/lib/courier-imap/authlib/$f"
+#done
+
+export POP3_TLS=1
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/pop3d | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/pop3d-ssl | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+
+eval $PRERUN \
+/usr/lib/courier-imap/couriertcpd -address=$SSLADDRESS \
+	-stderrlogger=/usr/lib/courier-imap/courierlogger \
+	-stderrloggername=pop3d-ssl \
+	-maxprocs=$MAXDAEMONS -maxperip=$MAXPERIP \
+	-pid=$SSLPIDFILE $TCPDOPTS \
+	$SSLPORT $COURIERTLS -server -tcpd \
+	${exec_prefix}/sbin/pop3login \
+		/usr/lib/courier-imap/courier-pop3d.indirect ${MAILDIR}
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.1-r1-gentoo-pop3d.rc b/net-mail/courier-imap/files/courier-imap-4.0.1-r1-gentoo-pop3d.rc
new file mode 100644
index 0000000..7e5cb7d
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.1-r1-gentoo-pop3d.rc
@@ -0,0 +1,36 @@
+#!/bin/bash
+# $Id: courier-imap-4.0.1-r1-gentoo-pop3d.rc,v 1.1 2005/02/11 15:34:49 robbat2 Exp $
+#
+# Copyright 1998 - 2000 Double Precision, Inc.
+# See COPYING for distribution information.
+
+prefix=/usr
+exec_prefix=/usr
+bindir=/usr/sbin
+libexecdir=/usr/lib/courier-imap
+
+source /etc/courier-imap/pop3d-ssl
+source /etc/courier-imap/pop3d
+
+# The new courier-authlib doesn't use these settings.
+#LIBAUTHMODULES=""
+#for f in `echo $AUTHMODULES`
+#do
+#	LIBAUTHMODULES="$LIBAUTHMODULES /usr/lib/courier-imap/authlib/$f"
+#done
+
+export POP3DSTARTTLS=$POP3_STARTTLS
+TLS_PROTOCOL=$TLS_STARTTLS_PROTOCOL
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/pop3d | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/pop3d-ssl | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+
+eval $PRERUN \
+/usr/lib/courier-imap/couriertcpd -address=$ADDRESS \
+	-stderrlogger=/usr/lib/courier-imap/courierlogger \
+	-stderrloggername=pop3d \
+	-maxprocs=$MAXDAEMONS -maxperip=$MAXPERIP \
+	-pid=$PIDFILE $TCPDOPTS \
+	$PORT ${exec_prefix}/sbin/pop3login \
+		/usr/lib/courier-imap/courier-pop3d.indirect ${MAILDIR}
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.4-courier-imapd-ssl.rc6 b/net-mail/courier-imap/files/courier-imap-4.0.4-courier-imapd-ssl.rc6
new file mode 100644
index 0000000..4968008
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.4-courier-imapd-ssl.rc6
@@ -0,0 +1,42 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-mail/courier-imap/files/courier-imap-4.0.4-courier-imapd-ssl.rc6,v 1.1 2005/08/08 09:57:05 flameeyes Exp $
+
+depend() {
+	need net courier-authlib
+	use famd
+}
+
+source /etc/courier-imap/imapd-ssl
+
+checkconfig() {
+	if [ ! -e /etc/courier-imap/imapd-ssl ] ; then
+		eerror "You need an /etc/courier-imap/imapd-ssl file to run courier-imapd"
+		return 1
+	fi
+	source /etc/courier-imap/imapd-ssl || {
+		eerror "There are syntax errors in /etc/courier-imap/imapd-ssl"
+		eerror "Please correct them before trying to start imapd-ssl"
+		return 3
+	}
+	if [ ! -e "${TLS_CERTFILE}" ] ; then
+		eerror "You need to create a SSL certificate to use IMAP over SSL"
+		eerror "Edit /etc/courier-imap/imapd.cnf, then run: mkimapdcert"
+		return 2
+	fi
+}
+
+start() {
+	checkconfig || return 1
+	ebegin "Starting courier-imapd over SSL"
+	/usr/bin/env - /usr/lib/courier-imap/gentoo-imapd-ssl.rc \
+		--pid=$SSLPIDFILE
+	eend $?
+}
+
+stop() {
+	ebegin "Stopping courier-imapd over SSL"
+	start-stop-daemon --quiet --stop --pid=$SSLPIDFILE
+	eend $?
+}
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.4-courier-imapd.rc6 b/net-mail/courier-imap/files/courier-imap-4.0.4-courier-imapd.rc6
new file mode 100644
index 0000000..57e5a53
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.4-courier-imapd.rc6
@@ -0,0 +1,37 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-mail/courier-imap/files/courier-imap-4.0.4-courier-imapd.rc6,v 1.1 2005/08/08 09:57:05 flameeyes Exp $
+
+depend() {
+	need net courier-authlib
+	use famd
+}
+
+source /etc/courier-imap/imapd
+
+checkconfig() {
+	if [ ! -e /etc/courier-imap/imapd ] ; then
+		eerror "You need an /etc/courier-imap/imapd file to run courier-imapd"
+		return 1
+	fi
+	source /etc/courier-imap/imapd || {
+		eerror "There are syntax errors in /etc/courier-imap/imapd"
+		eerror "Please correct them before trying to start imapd"
+		return 2
+	}
+}
+
+start() {
+	checkconfig || return 1
+	ebegin "Starting courier-imapd"
+	/usr/bin/env - /usr/lib/courier-imap/gentoo-imapd.rc \
+		--pid=$PIDFILE
+	eend $?
+}
+
+stop() {
+	ebegin "Stopping courier-imapd"
+	start-stop-daemon --quiet --stop --pid=$PIDFILE
+	eend $?
+}
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.4-courier-pop3d-ssl.rc6 b/net-mail/courier-imap/files/courier-imap-4.0.4-courier-pop3d-ssl.rc6
new file mode 100644
index 0000000..9a0579b
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.4-courier-pop3d-ssl.rc6
@@ -0,0 +1,42 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-mail/courier-imap/files/courier-imap-4.0.4-courier-pop3d-ssl.rc6,v 1.1 2005/08/08 09:57:05 flameeyes Exp $
+
+depend() {
+	need net courier-authlib
+	use famd
+}
+
+source /etc/courier-imap/pop3d-ssl
+
+checkconfig() {
+	if [ ! -e /etc/courier-imap/pop3d-ssl ] ; then
+		eerror "You need an /etc/courier-imap/pop3d-ssl file to run courier-pop3d"
+		return 1
+	fi
+	source /etc/courier-imap/pop3d-ssl || {
+		eerror "There are syntax errors in /etc/courier-imap/pop3d-ssl"
+		eerror "Please correct them before trying to start pop3d-ssl"
+		return 3
+	}
+	if [ ! -e "${TLS_CERTFILE}" ] ; then
+		eerror "You need to create a SSL certificate to use POP3 over SSL"
+		eerror "Edit /etc/courier-imap/pop3d.cnf, then run: mkpop3dcert"
+		return 2
+	fi
+}
+
+start() {
+	checkconfig || return 1
+	ebegin "Starting courier-pop3d over SSL"
+	/usr/bin/env - /usr/lib/courier-imap/gentoo-pop3d-ssl.rc \
+		--pidfile $SSLPIDFILE
+	eend $?
+}
+
+stop() {
+	ebegin "Stopping courier-pop3d over SSL"
+	start-stop-daemon --quiet --stop --pidfile $SSLPIDFILE
+	eend $?
+}
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.4-courier-pop3d.rc6 b/net-mail/courier-imap/files/courier-imap-4.0.4-courier-pop3d.rc6
new file mode 100644
index 0000000..69925db
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.4-courier-pop3d.rc6
@@ -0,0 +1,37 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-mail/courier-imap/files/courier-imap-4.0.4-courier-pop3d.rc6,v 1.1 2005/08/08 09:57:05 flameeyes Exp $
+
+depend() {
+	need net courier-authlib
+	use famd
+}
+
+source /etc/courier-imap/pop3d
+
+checkconfig() {
+	if [ ! -e /etc/courier-imap/pop3d ] ; then
+		eerror "You need an /etc/courier-imap/pop3d file to run courier-pop3d"
+		return 1
+	fi
+	source /etc/courier-imap/pop3d || {
+		eerror "There are syntax errors in /etc/courier-imap/pop3d"
+		eerror "Please correct them before trying to start pop3d"
+		return 2
+	}
+}
+
+start() {
+	checkconfig || return 1
+	ebegin "Starting courier-pop3d"
+	/usr/bin/env - /usr/lib/courier-imap/gentoo-pop3d.rc \
+		--pidfile $PIDFILE
+	eend $?
+}
+
+stop() {
+	ebegin "Stopping courier-pop3d"
+	start-stop-daemon --quiet --stop --pidfile $PIDFILE
+	eend $?
+}
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.6-aclocal-fix.patch b/net-mail/courier-imap/files/courier-imap-4.0.6-aclocal-fix.patch
new file mode 100644
index 0000000..14e9cda
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.6-aclocal-fix.patch
@@ -0,0 +1,10 @@
+--- configure.in.orig	2006-12-30 09:28:52.000000000 -0500
++++ configure.in	2007-02-27 12:13:38.000000000 -0500
+@@ -16,7 +16,6 @@
+ AC_PROG_INSTALL
+ AC_PROG_LN_S
+ AC_PROG_MAKE_SET
+-AC_PROG_SYSCONFTOOL
+ AC_LIBTOOL_DLOPEN
+ AM_PROG_LIBTOOL
+ 
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.6-db4-bdbobj_configure.in.patch b/net-mail/courier-imap/files/courier-imap-4.0.6-db4-bdbobj_configure.in.patch
new file mode 100644
index 0000000..4f14d72
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.6-db4-bdbobj_configure.in.patch
@@ -0,0 +1,35 @@
+--- bdbobj/configure.in.orig	2001-09-18 18:26:28.000000000 -0700
++++ bdbobj/configure.in	2004-08-14 16:15:08.469316646 -0700
+@@ -21,15 +21,23 @@
+ dnl Checks for libraries.
+ 
+ saveLIBS="$LIBS"
+-AC_CHECK_LIB(db, dbopen, [ LIBDB=-ldb ; LIBS="-ldb $LIBS" ],
+-	AC_CHECK_LIB(db, db_open, [ LIBDB=-ldb ; LIBS="-ldb $LIBS"],
+-	AC_CHECK_LIB(db, db_env_create, [ LIBDB=-ldb; LIBS="-ldb $LIBS"])
+-	))
+-
+-FOUND_DB=0
+-AC_CHECK_FUNC(dbopen, FOUND_DB=1)
+-AC_CHECK_FUNC(db_open, FOUND_DB=1)
+-AC_CHECK_FUNC(db_env_create, FOUND_DB=1)
++for dbname in db-4.4 db4.4 db44 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db-4.0 db4.0 db-4 db40 db4 db
++  do
++        AC_CHECK_LIB($dbname, db_create_4004, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ],
++        	AC_CHECK_LIB($dbname, db_create_4003, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ],
++        		AC_CHECK_LIB($dbname, db_create_4002, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ],
++          		AC_CHECK_LIB($dbname, db_create_4001, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ],
++            		AC_CHECK_LIB($dbname, db_create_4000, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ],
++              		AC_CHECK_LIB($dbname, db_create, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ]))))))
++
++  done
++FOUND_DB=0
++AC_CHECK_FUNC(db_create_4004, FOUND_DB=1)
++AC_CHECK_FUNC(db_create_4003, FOUND_DB=1)
++AC_CHECK_FUNC(db_create_4002, FOUND_DB=1)
++AC_CHECK_FUNC(db_create_4001, FOUND_DB=1)
++AC_CHECK_FUNC(db_create_4000, FOUND_DB=1)
++AC_CHECK_FUNC(db_create, FOUND_DB=1)
+ 
+ LIBS="$saveLIBS"
+ 
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.6-db4-configure.in.patch b/net-mail/courier-imap/files/courier-imap-4.0.6-db4-configure.in.patch
new file mode 100644
index 0000000..03d2c03
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.6-db4-configure.in.patch
@@ -0,0 +1,34 @@
+--- configure.in.orig	2004-11-16 16:02:11.045791896 -0800
++++ configure.in	2004-11-16 16:03:06.743324584 -0800
+@@ -150,16 +149,22 @@
+ 
+ if test "$db" != "gdbm"
+ then
++  for dbname in db-4.4 db4.4 db44 db-4.3 db4.3 db43 db-4.2 db4.2 db42 db-4.1 db4.1 db41 db-4.0 db4.0 db-4 db40 db4 db
++    do
++	AC_CHECK_LIB($dbname, db_create_4004, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ],
++		AC_CHECK_LIB($dbname, db_create_4003, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ],
++			AC_CHECK_LIB($dbname, db_create_4002, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ],
++ 	  	AC_CHECK_LIB($dbname, db_create_4001, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ],
++ 	    	AC_CHECK_LIB($dbname, db_create_4000, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ],
++ 	      	AC_CHECK_LIB($dbname, db_create, [ LIBDB=-l$dbname ; LIBS="-l$dbname $LIBS"; break ]))))))
++    done
++  AC_CHECK_FUNC(db_create_4004, HAVE_BDB=1)
++  AC_CHECK_FUNC(db_create_4003, HAVE_BDB=1)
++  AC_CHECK_FUNC(db_create_4002, HAVE_BDB=1)
++  AC_CHECK_FUNC(db_create_4001, HAVE_BDB=1)
++  AC_CHECK_FUNC(db_create_4000, HAVE_BDB=1)
++  AC_CHECK_FUNC(db_create, HAVE_BDB=1)
+ 
+-	AC_CHECK_LIB(db, dbopen, [ LIBDB=-ldb ; LIBS="-ldb $LIBS" ],
+-		AC_CHECK_LIB(db, db_open, [ LIBDB=-ldb ; LIBS="-ldb $LIBS"],
+-		AC_CHECK_LIB(db, db_env_create,
+-				[ LIBDB=-ldb; LIBS="-ldb $LIBS"])
+-	))
+-
+-	AC_CHECK_FUNC(dbopen, HAVE_BDB=1)
+-	AC_CHECK_FUNC(db_open, HAVE_BDB=1)
+-	AC_CHECK_FUNC(db_env_create, HAVE_BDB=1)
+ fi
+ 
+ LIBS="$saveLIBS"
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.6-db4-tcpd_configure.in.patch b/net-mail/courier-imap/files/courier-imap-4.0.6-db4-tcpd_configure.in.patch
new file mode 100644
index 0000000..6fdff76
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.6-db4-tcpd_configure.in.patch
@@ -0,0 +1,11 @@
+--- tcpd/configure.in.orig	2007-02-02 17:20:18.000000000 +0100
++++ tcpd/configure.in	2007-02-02 17:20:58.000000000 +0100
+@@ -84,7 +84,7 @@
+ 	USE_GDBM=0
+ 	LIBGDBM=""
+ 	dblibrary=../bdbobj/libbdbobj.la
+-	LIBDB="-Wl,$LIBDB"
++	LIBDB="$LIBDB"
+ 	;;
+ *)
+ 	COURIERTCPD=""
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.6-r1-courier-imapd-ssl.rc6 b/net-mail/courier-imap/files/courier-imap-4.0.6-r1-courier-imapd-ssl.rc6
new file mode 100644
index 0000000..e1460be
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.6-r1-courier-imapd-ssl.rc6
@@ -0,0 +1,41 @@
+#!/sbin/runscript
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-mail/courier-imap/files/courier-imap-4.0.6-r1-courier-imapd-ssl.rc6,v 1.2 2007/04/07 01:08:00 chtekk Exp $
+
+depend() {
+	need net courier-authlib
+	use famd
+}
+
+source /etc/courier-imap/imapd-ssl
+
+checkconfig() {
+	if [[ ! -e /etc/courier-imap/imapd-ssl ]] ; then
+		eerror "You need an /etc/courier-imap/imapd-ssl file to run courier-imapd-ssl"
+		return 1
+	fi
+	source /etc/courier-imap/imapd-ssl || {
+		eerror "There are syntax errors in /etc/courier-imap/imapd-ssl"
+		eerror "Please correct them before trying to start courier-imapd-ssl"
+		return 3
+	}
+	if [[ ! -e "${TLS_CERTFILE}" ]] ; then
+		eerror "You need to create a SSL certificate to use IMAP over SSL"
+		eerror "Edit /etc/courier-imap/imapd.cnf, then run: mkimapdcert"
+		return 2
+	fi
+}
+
+start() {
+	checkconfig || return 1
+	ebegin "Starting courier-imapd over SSL"
+	/usr/bin/env - /usr/GENTOO_LIBDIR/courier-imap/gentoo-imapd-ssl.rc --pid=${SSLPIDFILE}
+	eend $?
+}
+
+stop() {
+	ebegin "Stopping courier-imapd over SSL"
+	start-stop-daemon --quiet --stop --pid=${SSLPIDFILE}
+	eend $?
+}
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.6-r1-courier-imapd.indirect b/net-mail/courier-imap/files/courier-imap-4.0.6-r1-courier-imapd.indirect
new file mode 100644
index 0000000..2367ae0
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.6-r1-courier-imapd.indirect
@@ -0,0 +1,3 @@
+#!/bin/bash
+XMAILDIR="$1"
+eval ${LOGINRUN} /usr/sbin/courier-imapd "${XMAILDIR}"
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.6-r1-courier-imapd.rc6 b/net-mail/courier-imap/files/courier-imap-4.0.6-r1-courier-imapd.rc6
new file mode 100644
index 0000000..f5433f2
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.6-r1-courier-imapd.rc6
@@ -0,0 +1,36 @@
+#!/sbin/runscript
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-mail/courier-imap/files/courier-imap-4.0.6-r1-courier-imapd.rc6,v 1.2 2007/04/07 01:08:00 chtekk Exp $
+
+depend() {
+	need net courier-authlib
+	use famd
+}
+
+source /etc/courier-imap/imapd
+
+checkconfig() {
+	if [[ ! -e /etc/courier-imap/imapd ]] ; then
+		eerror "You need an /etc/courier-imap/imapd file to run courier-imapd"
+		return 1
+	fi
+	source /etc/courier-imap/imapd || {
+		eerror "There are syntax errors in /etc/courier-imap/imapd"
+		eerror "Please correct them before trying to start courier-imapd"
+		return 2
+	}
+}
+
+start() {
+	checkconfig || return 1
+	ebegin "Starting courier-imapd"
+	/usr/bin/env - /usr/GENTOO_LIBDIR/courier-imap/gentoo-imapd.rc --pid=${PIDFILE}
+	eend $?
+}
+
+stop() {
+	ebegin "Stopping courier-imapd"
+	start-stop-daemon --quiet --stop --pid=${PIDFILE}
+	eend $?
+}
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.6-r1-courier-pop3d-ssl.rc6 b/net-mail/courier-imap/files/courier-imap-4.0.6-r1-courier-pop3d-ssl.rc6
new file mode 100644
index 0000000..0142446
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.6-r1-courier-pop3d-ssl.rc6
@@ -0,0 +1,41 @@
+#!/sbin/runscript
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-mail/courier-imap/files/courier-imap-4.0.6-r1-courier-pop3d-ssl.rc6,v 1.2 2007/04/07 01:08:00 chtekk Exp $
+
+depend() {
+	need net courier-authlib
+	use famd
+}
+
+source /etc/courier-imap/pop3d-ssl
+
+checkconfig() {
+	if [[ ! -e /etc/courier-imap/pop3d-ssl ]] ; then
+		eerror "You need an /etc/courier-imap/pop3d-ssl file to run courier-pop3d-ssl"
+		return 1
+	fi
+	source /etc/courier-imap/pop3d-ssl || {
+		eerror "There are syntax errors in /etc/courier-imap/pop3d-ssl"
+		eerror "Please correct them before trying to start courier-pop3d-ssl"
+		return 3
+	}
+	if [[ ! -e "${TLS_CERTFILE}" ]] ; then
+		eerror "You need to create a SSL certificate to use POP3 over SSL"
+		eerror "Edit /etc/courier-imap/pop3d.cnf, then run: mkpop3dcert"
+		return 2
+	fi
+}
+
+start() {
+	checkconfig || return 1
+	ebegin "Starting courier-pop3d over SSL"
+	/usr/bin/env - /usr/GENTOO_LIBDIR/courier-imap/gentoo-pop3d-ssl.rc --pidfile ${SSLPIDFILE}
+	eend $?
+}
+
+stop() {
+	ebegin "Stopping courier-pop3d over SSL"
+	start-stop-daemon --quiet --stop --pidfile ${SSLPIDFILE}
+	eend $?
+}
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.6-r1-courier-pop3d.indirect b/net-mail/courier-imap/files/courier-imap-4.0.6-r1-courier-pop3d.indirect
new file mode 100644
index 0000000..4651a04
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.6-r1-courier-pop3d.indirect
@@ -0,0 +1,3 @@
+#!/bin/bash
+XMAILDIR="$1"
+eval ${LOGINRUN} /usr/sbin/courier-pop3d "${XMAILDIR}"
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.6-r1-courier-pop3d.rc6 b/net-mail/courier-imap/files/courier-imap-4.0.6-r1-courier-pop3d.rc6
new file mode 100644
index 0000000..6eeb51c
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.6-r1-courier-pop3d.rc6
@@ -0,0 +1,36 @@
+#!/sbin/runscript
+# Copyright 1999-2007 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-mail/courier-imap/files/courier-imap-4.0.6-r1-courier-pop3d.rc6,v 1.2 2007/04/07 01:08:00 chtekk Exp $
+
+depend() {
+	need net courier-authlib
+	use famd
+}
+
+source /etc/courier-imap/pop3d
+
+checkconfig() {
+	if [[ ! -e /etc/courier-imap/pop3d ]] ; then
+		eerror "You need an /etc/courier-imap/pop3d file to run courier-pop3d"
+		return 1
+	fi
+	source /etc/courier-imap/pop3d || {
+		eerror "There are syntax errors in /etc/courier-imap/pop3d"
+		eerror "Please correct them before trying to start courier-pop3d"
+		return 2
+	}
+}
+
+start() {
+	checkconfig || return 1
+	ebegin "Starting courier-pop3d"
+	/usr/bin/env - /usr/GENTOO_LIBDIR/courier-imap/gentoo-pop3d.rc --pidfile ${PIDFILE}
+	eend $?
+}
+
+stop() {
+	ebegin "Stopping courier-pop3d"
+	start-stop-daemon --quiet --stop --pidfile ${PIDFILE}
+	eend $?
+}
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.6-r1-gentoo-imapd-ssl.rc b/net-mail/courier-imap/files/courier-imap-4.0.6-r1-gentoo-imapd-ssl.rc
new file mode 100644
index 0000000..1379b0d
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.6-r1-gentoo-imapd-ssl.rc
@@ -0,0 +1,32 @@
+#!/bin/bash
+# $Header: /var/cvsroot/gentoo-x86/net-mail/courier-imap/files/courier-imap-4.0.6-r1-gentoo-imapd-ssl.rc,v 1.2 2007/04/07 01:08:00 chtekk Exp $
+#
+# Copyright 1998 - 2000 Double Precision, Inc.
+# See COPYING for distribution information.
+
+prefix=/usr
+exec_prefix=/usr
+bindir=/usr/sbin
+libexecdir=/usr/GENTOO_LIBDIR/courier-imap
+
+source /etc/courier-imap/imapd
+source /etc/courier-imap/imapd-ssl
+
+ulimit -d ${IMAP_ULIMITD}
+
+export IMAP_TLS=1
+
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/imapd | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/imapd-ssl | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+
+eval ${PRERUN} ${libexecdir}/couriertcpd \
+	-address=${SSLADDRESS} \
+	-stderrlogger=${libexecdir}/courierlogger \
+	-stderrloggername=imapd-ssl \
+	-maxprocs=${MAXDAEMONS} -maxperip=${MAXPERIP} \
+	-pid=${SSLPIDFILE} ${TCPDOPTS} ${SSLPORT} \
+	${COURIERTLS} -server -tcpd \
+	${bindir}/imaplogin \
+	${libexecdir}/courier-imapd.indirect "${MAILDIR}"
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.6-r1-gentoo-imapd.rc b/net-mail/courier-imap/files/courier-imap-4.0.6-r1-gentoo-imapd.rc
new file mode 100644
index 0000000..b40614f
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.6-r1-gentoo-imapd.rc
@@ -0,0 +1,33 @@
+#!/bin/bash
+# $Header: /var/cvsroot/gentoo-x86/net-mail/courier-imap/files/courier-imap-4.0.6-r1-gentoo-imapd.rc,v 1.2 2007/04/07 01:08:00 chtekk Exp $
+#
+# Copyright 1998 - 2000 Double Precision, Inc.
+# See COPYING for distribution information.
+
+prefix=/usr
+exec_prefix=/usr
+bindir=/usr/sbin
+libexecdir=/usr/GENTOO_LIBDIR/courier-imap
+
+source /etc/courier-imap/imapd-ssl
+source /etc/courier-imap/imapd
+
+ulimit -d ${IMAP_ULIMITD}
+
+IMAP_STARTTLS="${IMAPDSTARTTLS}"
+export IMAPDSTARTTLS IMAP_STARTTLS
+TLS_PROTOCOL="${TLS_STARTTLS_PROTOCOL}"
+
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/imapd | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/imapd-ssl | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+
+eval ${PRERUN} ${libexecdir}/couriertcpd \
+	-address=${ADDRESS} \
+	-stderrlogger=${libexecdir}/courierlogger \
+	-stderrloggername=imapd \
+	-maxprocs=${MAXDAEMONS} -maxperip=${MAXPERIP} \
+	-pid=${PIDFILE} ${TCPDOPTS} ${PORT} \
+	${bindir}/imaplogin \
+	${libexecdir}/courier-imapd.indirect "${MAILDIR}"
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.6-r1-gentoo-pop3d-ssl.rc b/net-mail/courier-imap/files/courier-imap-4.0.6-r1-gentoo-pop3d-ssl.rc
new file mode 100644
index 0000000..57d3515
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.6-r1-gentoo-pop3d-ssl.rc
@@ -0,0 +1,30 @@
+#!/bin/bash
+# $Header: /var/cvsroot/gentoo-x86/net-mail/courier-imap/files/courier-imap-4.0.6-r1-gentoo-pop3d-ssl.rc,v 1.2 2007/04/07 01:08:00 chtekk Exp $
+#
+# Copyright 1998 - 2000 Double Precision, Inc.
+# See COPYING for distribution information.
+
+prefix=/usr
+exec_prefix=/usr
+bindir=/usr/sbin
+libexecdir=/usr/GENTOO_LIBDIR/courier-imap
+
+source /etc/courier-imap/pop3d
+source /etc/courier-imap/pop3d-ssl
+
+export POP3_TLS=1
+
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/pop3d | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/pop3d-ssl | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+
+eval ${PRERUN} ${libexecdir}/couriertcpd \
+	-address=${SSLADDRESS} \
+	-stderrlogger=${libexecdir}/courierlogger \
+	-stderrloggername=pop3d-ssl \
+	-maxprocs=${MAXDAEMONS} -maxperip=${MAXPERIP} \
+	-pid=${SSLPIDFILE} ${TCPDOPTS} ${SSLPORT} \
+	${COURIERTLS} -server -tcpd \
+	${bindir}/pop3login \
+	${libexecdir}/courier-pop3d.indirect "${MAILDIR}"
diff --git a/net-mail/courier-imap/files/courier-imap-4.0.6-r1-gentoo-pop3d.rc b/net-mail/courier-imap/files/courier-imap-4.0.6-r1-gentoo-pop3d.rc
new file mode 100644
index 0000000..1a2b44d
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.0.6-r1-gentoo-pop3d.rc
@@ -0,0 +1,31 @@
+#!/bin/bash
+# $Header: /var/cvsroot/gentoo-x86/net-mail/courier-imap/files/courier-imap-4.0.6-r1-gentoo-pop3d.rc,v 1.2 2007/04/07 01:08:00 chtekk Exp $
+#
+# Copyright 1998 - 2000 Double Precision, Inc.
+# See COPYING for distribution information.
+
+prefix=/usr
+exec_prefix=/usr
+bindir=/usr/sbin
+libexecdir=/usr/GENTOO_LIBDIR/courier-imap
+
+source /etc/courier-imap/pop3d-ssl
+source /etc/courier-imap/pop3d
+
+POP3DSTARTTLS="${POP3_STARTTLS}"
+export POP3_STARTTLS POP3DSTARTTLS
+TLS_PROTOCOL="${TLS_STARTTLS_PROTOCOL}"
+
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/pop3d | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/pop3d-ssl | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+
+eval ${PRERUN} ${libexecdir}/couriertcpd \
+	-address=${ADDRESS} \
+	-stderrlogger=${libexecdir}/courierlogger \
+	-stderrloggername=pop3d \
+	-maxprocs=${MAXDAEMONS} -maxperip=${MAXPERIP} \
+	-pid=${PIDFILE} ${TCPDOPTS} ${PORT} \
+	${bindir}/pop3login \
+	${libexecdir}/courier-pop3d.indirect "${MAILDIR}"
diff --git a/net-mail/courier-imap/files/courier-imap-4.1.2-as-needed.patch b/net-mail/courier-imap/files/courier-imap-4.1.2-as-needed.patch
new file mode 100644
index 0000000..3eff0a8
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.1.2-as-needed.patch
@@ -0,0 +1,12 @@
+Index: courier-imap-4.1.2/gdbmobj/Makefile.am
+===================================================================
+--- courier-imap-4.1.2.orig/gdbmobj/Makefile.am
++++ courier-imap-4.1.2/gdbmobj/Makefile.am
+@@ -15,6 +15,7 @@ noinst_LTLIBRARIES=libgdbmobj.la
+ noinst_PROGRAMS=testgdbm
+ 
+ libgdbmobj_la_SOURCES=$(LIBGDBMSOURCES)
++libgdbmobj_la_LIBADD=@LIBGDBM@
+ 
+ testgdbm_SOURCES=$(TESTGDBMSOURCES)
+ 
diff --git a/net-mail/courier-imap/files/courier-imap-4.3.0-as-needed.patch b/net-mail/courier-imap/files/courier-imap-4.3.0-as-needed.patch
new file mode 100644
index 0000000..4eac183
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-4.3.0-as-needed.patch
@@ -0,0 +1,12 @@
+Index: courier-imap-4.3.0/gdbmobj/Makefile.am
+===================================================================
+--- courier-imap-4.3.0.orig/gdbmobj/Makefile.am
++++ courier-imap-4.3.0/gdbmobj/Makefile.am
+@@ -15,6 +15,7 @@ noinst_LTLIBRARIES=libgdbmobj.la
+ noinst_PROGRAMS=testgdbm
+ 
+ libgdbmobj_la_SOURCES=$(LIBGDBMSOURCES)
++libgdbmobj_la_LIBADD=@LIBGDBM@
+ 
+ testgdbm_SOURCES=$(TESTGDBMSOURCES)
+ 
diff --git a/net-mail/courier-imap/files/courier-imap-gentoo.readme b/net-mail/courier-imap/files/courier-imap-gentoo.readme
new file mode 100644
index 0000000..b11a804
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imap-gentoo.readme
@@ -0,0 +1,75 @@
+// This quick guide is for mysql authentication support base on the Gentoo Virtual Mailhosting Guide
+// turn ON mysql USE flag for courier-authlib. Need to authenticate against mysql database backend.
+localhost ~ # nano -w /etc/portage/package.use
+net-libs/courier-authlib mysql
+net-mail/courier-imap mysql
+localhost ~ # emerge courier-imap
+// limit to mysql module only, instead load all of them.
+localhost ~ # nano -w /etc/courier/authlib/authdaemonrc
+authmodulelist="authmysql"
+
+// set variables to match your setup.
+localhost ~ # nano -w /etc/courier/authlib/authmysqlrc
+MYSQL_SERVER            localhost
+MYSQL_USERNAME          mailsql_admin_username
+MYSQL_PASSWORD          password
+MYSQL_DATABASE          mailsql_database
+MYSQL_USER_TABLE        users
+# MYSQL_CRYPT_PWFIELD   crypt (commented this out if you want CRAM-MD5)
+MYSQL_CLEAR_PWFIELD     clear
+MYSQL_LOGIN_FIELD       email
+MYSQL_HOME_FIELD        homedir
+MYSQL_MAILDIR_FIELD     maildir
+
+// Start authdaemond
+localhost ~ # etc/init.d/courier-authlib start
+* Starting courier-authlib: authdaemond ...                                               [ ok ]
+
+### Courier-IMAP' ssl certificate setup
+localhost ~ # nano -w /etc/courier-imap/imapd.cnf
+localhost ~ # nano -w /etc/courier-imap/pop3.cnf
+// change to match your site.
+[ req_dn ]
+C=US
+ST=NY
+L=New York
+O=Courier Mail Server
+OU=Automatically-generated IMAP SSL key
+CN=mailhost.example.com
+emailAddress=postmaster@example.com
+
+// Generate Certificate
+localhost ~ # mkimapdcert
+...
+writing new private key to '/etc/courier-imap/imapd.pem'
+...
+localhost ~ # mkpop3dcert
+...
+writing new private key to '/etc/courier-imap/pop3d.pem'
+...
+
+### Secure Authentication Setup (CRAM-MD5)
+localhost ~ # nano -w /etc/courier-imap/imapd
+IMAP_CAPABILITY="IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE AUTH=CRAM-MD5"
+
+### Start Courier-imap daemons.
+localhost ~ # /etc/init.d/courier-pop3d start
+localhost ~ # /etc/init.d/courier-pop3d-ssl start
+localhost ~ # /etc/init.d/courier-imapd start
+localhost ~ # /etc/init.d/courier-imapd-ssl start
+
+### Checking authentication.
+// From your favorite client send an email to user@your_domain.com
+// so your mail user's maildir created by your MTA.
+// you can not login unless user maildir has been created.
+localhost ~ $ telnet mailexample.com 143
+Trying xxx.xxx.xxx.xxx...
+Connected to mail.example.com (xxx.xxx.xxx.xxx).
+Escape character is '^]'.
+* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE AUTH=CRAM-MD5 ACL ACL2=UNION STARTTLS] Courier-IMAP ready. Copyright 1998-2004 Double Precision, Inc.  See COPYING for distribution information.
+a login user@example.com password
+a OK LOGIN Ok.
+ OK LOGOUT completed
+Connection closed by foreign host.
+
+### That's all folks.
diff --git a/net-mail/courier-imap/files/courier-imapd-ssl.rc6-3.0.5 b/net-mail/courier-imap/files/courier-imapd-ssl.rc6-3.0.5
new file mode 100644
index 0000000..abf0f02
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imapd-ssl.rc6-3.0.5
@@ -0,0 +1,42 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-mail/courier-imap/files/courier-imapd-ssl.rc6-3.0.5,v 1.1 2004/06/26 23:30:58 robbat2 Exp $
+
+depend() {
+	need net authdaemond
+	use famd
+}
+
+source /etc/courier-imap/imapd-ssl
+
+checkconfig() {
+	if [ ! -e /etc/courier-imap/imapd-ssl ] ; then
+		eerror "You need an /etc/courier-imap/imapd-ssl file to run courier-imapd"
+		return 1
+	fi
+	source /etc/courier-imap/imapd-ssl || {
+		eerror "There are syntax errors in /etc/courier-imap/imapd-ssl"
+		eerror "Please correct them before trying to start imapd-ssl"
+		return 3
+	}
+	if [ ! -e "${TLS_CERTFILE}" ] ; then
+		eerror "You need to create a SSL certificate to use IMAP over SSL"
+		eerror "Edit /etc/courier-imap/imapd.cnf, then run: mkimapdcert"
+		return 2
+	fi
+}
+
+start() {
+	checkconfig || return 1
+	ebegin "Starting courier-imapd over SSL"
+	start-stop-daemon --quiet --start --exec /usr/bin/env - /usr/lib/courier-imap/gentoo-imapd-ssl.rc \
+		--pid=$SSLPIDFILE
+	eend $?
+}
+
+stop() {
+	ebegin "Stopping courier-imapd over SSL"
+	start-stop-daemon --quiet --stop --pid=$SSLPIDFILE
+	eend $?
+}
diff --git a/net-mail/courier-imap/files/courier-imapd.rc6 b/net-mail/courier-imap/files/courier-imapd.rc6
new file mode 100755
index 0000000..a322e37
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-imapd.rc6
@@ -0,0 +1,37 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-mail/courier-imap/files/courier-imapd.rc6,v 1.6 2004/06/26 23:30:58 robbat2 Exp $
+
+depend() {
+	need net authdaemond
+	use famd
+}
+
+source /etc/courier-imap/imapd
+
+checkconfig() {
+	if [ ! -e /etc/courier-imap/imapd ] ; then
+		eerror "You need an /etc/courier-imap/imapd file to run courier-imapd"
+		return 1
+	fi
+	source /etc/courier-imap/imapd || {
+		eerror "There are syntax errors in /etc/courier-imap/imapd"
+		eerror "Please correct them before trying to start imapd"
+		return 2
+	}
+}
+
+start() {
+	checkconfig || return 1
+	ebegin "Starting courier-imapd"
+	start-stop-daemon --quiet --start --exec /usr/bin/env - /usr/lib/courier-imap/gentoo-imapd.rc \
+		--pid=$PIDFILE
+	eend $?
+}
+
+stop() {
+	ebegin "Stopping courier-imapd"
+	start-stop-daemon --quiet --stop --pid=$PIDFILE
+	eend $?
+}
diff --git a/net-mail/courier-imap/files/courier-pop3d-ssl.rc6-3.0.5 b/net-mail/courier-imap/files/courier-pop3d-ssl.rc6-3.0.5
new file mode 100644
index 0000000..b2ea433
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-pop3d-ssl.rc6-3.0.5
@@ -0,0 +1,42 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-mail/courier-imap/files/courier-pop3d-ssl.rc6-3.0.5,v 1.1 2004/06/26 23:30:58 robbat2 Exp $
+
+depend() {
+	need net authdaemond
+	use famd
+}
+
+source /etc/courier-imap/pop3d-ssl
+
+checkconfig() {
+	if [ ! -e /etc/courier-imap/pop3d-ssl ] ; then
+		eerror "You need an /etc/courier-imap/pop3d-ssl file to run courier-pop3d"
+		return 1
+	fi
+	source /etc/courier-imap/pop3d-ssl || {
+		eerror "There are syntax errors in /etc/courier-imap/pop3d-ssl"
+		eerror "Please correct them before trying to start pop3d-ssl"
+		return 3
+	}
+	if [ ! -e "${TLS_CERTFILE}" ] ; then
+		eerror "You need to create a SSL certificate to use POP3 over SSL"
+		eerror "Edit /etc/courier-imap/pop3d.cnf, then run: mkpop3dcert"
+		return 2
+	fi
+}
+
+start() {
+	checkconfig || return 1
+	ebegin "Starting courier-pop3d over SSL"
+	start-stop-daemon --quiet --start --exec /usr/bin/env - /usr/lib/courier-imap/gentoo-pop3d-ssl.rc \
+		--pidfile $SSLPIDFILE
+	eend $?
+}
+
+stop() {
+	ebegin "Stopping courier-pop3d over SSL"
+	start-stop-daemon --quiet --stop --pidfile $SSLPIDFILE
+	eend $?
+}
diff --git a/net-mail/courier-imap/files/courier-pop3d.rc6 b/net-mail/courier-imap/files/courier-pop3d.rc6
new file mode 100755
index 0000000..159a74e
--- /dev/null
+++ b/net-mail/courier-imap/files/courier-pop3d.rc6
@@ -0,0 +1,37 @@
+#!/sbin/runscript
+# Copyright 1999-2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/net-mail/courier-imap/files/courier-pop3d.rc6,v 1.6 2004/06/26 23:30:58 robbat2 Exp $
+
+depend() {
+	need net authdaemond
+	use famd
+}
+
+source /etc/courier-imap/pop3d
+
+checkconfig() {
+	if [ ! -e /etc/courier-imap/pop3d ] ; then
+		eerror "You need an /etc/courier-imap/pop3d file to run courier-pop3d"
+		return 1
+	fi
+	source /etc/courier-imap/pop3d || {
+		eerror "There are syntax errors in /etc/courier-imap/pop3d"
+		eerror "Please correct them before trying to start pop3d"
+		return 2
+	}
+}
+
+start() {
+	checkconfig || return 1
+	ebegin "Starting courier-pop3d"
+	start-stop-daemon --quiet --start --exec /usr/bin/env - /usr/lib/courier-imap/gentoo-pop3d.rc \
+		--pidfile $PIDFILE
+	eend $?
+}
+
+stop() {
+	ebegin "Stopping courier-pop3d"
+	start-stop-daemon --quiet --stop --pidfile $PIDFILE
+	eend $?
+}
diff --git a/net-mail/courier-imap/files/gentoo-imapd-1.7.3-r1.rc b/net-mail/courier-imap/files/gentoo-imapd-1.7.3-r1.rc
new file mode 100755
index 0000000..5075c8c
--- /dev/null
+++ b/net-mail/courier-imap/files/gentoo-imapd-1.7.3-r1.rc
@@ -0,0 +1,37 @@
+#!/bin/bash
+# $Id: gentoo-imapd-1.7.3-r1.rc,v 1.2 2004/06/26 23:30:58 robbat2 Exp $
+#
+# Copyright 1998 - 2000 Double Precision, Inc.
+# See COPYING for distribution information.
+
+prefix=/usr
+exec_prefix=/usr
+bindir=/usr/sbin
+libexecdir=/usr/lib/courier-imap
+
+source /etc/courier-imap/imapd-ssl
+source /etc/courier-imap/imapd
+
+LIBAUTHMODULES=""
+for f in `echo $AUTHMODULES`
+do
+	LIBAUTHMODULES="$LIBAUTHMODULES /usr/lib/courier-imap/authlib/$f"
+done
+
+ulimit -d $IMAP_ULIMITD
+IMAP_STARTTLS="$IMAPDSTARTTLS"
+export IMAPDSTARTTLS IMAP_STARTTLS
+TLS_PROTOCOL=$TLS_STARTTLS_PROTOCOL
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/imapd | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/imapd-ssl | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+
+eval $PRERUN \
+/usr/lib/courier-imap/couriertcpd -address=$ADDRESS \
+	-stderrlogger=/usr/lib/courier-imap/courierlogger \
+	-stderrloggername=imapd \
+	-maxprocs=$MAXDAEMONS -maxperip=$MAXPERIP \
+	-pid=$PIDFILE $TCPDOPTS \
+	$PORT ${exec_prefix}/sbin/imaplogin $LIBAUTHMODULES \
+		/usr/sbin/courier-imapd ${MAILDIR}
diff --git a/net-mail/courier-imap/files/gentoo-imapd-ssl-1.7.3-r1.rc b/net-mail/courier-imap/files/gentoo-imapd-ssl-1.7.3-r1.rc
new file mode 100755
index 0000000..59e4ce7
--- /dev/null
+++ b/net-mail/courier-imap/files/gentoo-imapd-ssl-1.7.3-r1.rc
@@ -0,0 +1,36 @@
+#!/bin/bash
+# $Id: gentoo-imapd-ssl-1.7.3-r1.rc,v 1.2 2004/06/26 23:30:58 robbat2 Exp $
+#
+# Copyright 1998 - 2000 Double Precision, Inc.
+# See COPYING for distribution information.
+
+prefix=/usr
+exec_prefix=/usr
+bindir=/usr/sbin
+libexecdir=/usr/lib/courier-imap
+
+source /etc/courier-imap/imapd
+source /etc/courier-imap/imapd-ssl
+
+LIBAUTHMODULES=""
+for f in `echo $AUTHMODULES`
+do
+	LIBAUTHMODULES="$LIBAUTHMODULES /usr/lib/courier-imap/authlib/$f"
+done
+
+ulimit -d $IMAP_ULIMITD
+export IMAP_TLS=1
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/imapd | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/imapd-ssl | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+
+eval $PRERUN \
+/usr/lib/courier-imap/couriertcpd -address=$SSLADDRESS \
+	-stderrlogger=/usr/lib/courier-imap/courierlogger \
+	-stderrloggername=imapd-ssl \
+	-maxprocs=$MAXDAEMONS -maxperip=$MAXPERIP \
+	-pid=$SSLPIDFILE $TCPDOPTS \
+	$SSLPORT $COURIERTLS -server -tcpd \
+	${exec_prefix}/sbin/imaplogin $LIBAUTHMODULES \
+		/usr/sbin/courier-imapd ${MAILDIR}
diff --git a/net-mail/courier-imap/files/gentoo-pop3d-1.7.3-r1.rc b/net-mail/courier-imap/files/gentoo-pop3d-1.7.3-r1.rc
new file mode 100755
index 0000000..707b0f8
--- /dev/null
+++ b/net-mail/courier-imap/files/gentoo-pop3d-1.7.3-r1.rc
@@ -0,0 +1,35 @@
+#!/bin/bash
+# $Id: gentoo-pop3d-1.7.3-r1.rc,v 1.2 2004/06/26 23:30:58 robbat2 Exp $
+#
+# Copyright 1998 - 2000 Double Precision, Inc.
+# See COPYING for distribution information.
+
+prefix=/usr
+exec_prefix=/usr
+bindir=/usr/sbin
+libexecdir=/usr/lib/courier-imap
+
+source /etc/courier-imap/pop3d-ssl
+source /etc/courier-imap/pop3d
+
+LIBAUTHMODULES=""
+for f in `echo $AUTHMODULES`
+do
+	LIBAUTHMODULES="$LIBAUTHMODULES /usr/lib/courier-imap/authlib/$f"
+done
+
+export POP3DSTARTTLS=$POP3_STARTTLS
+TLS_PROTOCOL=$TLS_STARTTLS_PROTOCOL
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/pop3d | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/pop3d-ssl | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+
+eval $PRERUN \
+/usr/lib/courier-imap/couriertcpd -address=$ADDRESS \
+	-stderrlogger=/usr/lib/courier-imap/courierlogger \
+	-stderrloggername=pop3d \
+	-maxprocs=$MAXDAEMONS -maxperip=$MAXPERIP \
+	-pid=$PIDFILE $TCPDOPTS \
+	$PORT ${exec_prefix}/sbin/pop3login $LIBAUTHMODULES \
+		/usr/sbin/courier-pop3d ${MAILDIR}
diff --git a/net-mail/courier-imap/files/gentoo-pop3d-ssl-1.7.3-r1.rc b/net-mail/courier-imap/files/gentoo-pop3d-ssl-1.7.3-r1.rc
new file mode 100755
index 0000000..3c68062
--- /dev/null
+++ b/net-mail/courier-imap/files/gentoo-pop3d-ssl-1.7.3-r1.rc
@@ -0,0 +1,35 @@
+#!/bin/bash
+# $Id: gentoo-pop3d-ssl-1.7.3-r1.rc,v 1.2 2004/06/26 23:30:58 robbat2 Exp $
+#
+# Copyright 1998 - 2000 Double Precision, Inc.
+# See COPYING for distribution information.
+
+prefix=/usr
+exec_prefix=/usr
+bindir=/usr/sbin
+libexecdir=/usr/lib/courier-imap
+
+source /etc/courier-imap/pop3d
+source /etc/courier-imap/pop3d-ssl
+
+LIBAUTHMODULES=""
+for f in `echo $AUTHMODULES`
+do
+	LIBAUTHMODULES="$LIBAUTHMODULES /usr/lib/courier-imap/authlib/$f"
+done
+
+export POP3_TLS=1
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/pop3d | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+eval `sed -n '/^#/d;/=/p' </etc/courier-imap/pop3d-ssl | \
+	sed 's/=.*//;s/^/export /;s/$/;/'`
+
+eval $PRERUN \
+/usr/lib/courier-imap/couriertcpd -address=$SSLADDRESS \
+	-stderrlogger=/usr/lib/courier-imap/courierlogger \
+	-stderrloggername=pop3d-ssl \
+	-maxprocs=$MAXDAEMONS -maxperip=$MAXPERIP \
+	-pid=$SSLPIDFILE $TCPDOPTS \
+	$SSLPORT $COURIERTLS -server -tcpd \
+	${exec_prefix}/sbin/pop3login $LIBAUTHMODULES \
+		/usr/sbin/courier-pop3d ${MAILDIR}
diff --git a/net-mail/courier-imap/files/mkimapdcert b/net-mail/courier-imap/files/mkimapdcert
new file mode 100755
index 0000000..1261e12
--- /dev/null
+++ b/net-mail/courier-imap/files/mkimapdcert
@@ -0,0 +1,39 @@
+#! /bin/sh
+#
+# mkimapdcert,v 1.1 2001/01/02 03:54:25 drobbins Exp
+#
+# Copyright 2000 Double Precision, Inc.  See COPYING for
+# distribution information.
+#
+# This is a short script to quickly generate a self-signed X.509 key for
+# IMAP over SSL.  Normally this script would get called by an automatic
+# package installation routine.
+
+test -x /usr/bin/openssl || exit 0
+
+prefix="/usr"
+pemfile="/etc/courier-imap/imapd.pem"
+randfile="/etc/courier-imap/imapd.rand"
+
+if test -f $pemfile
+then
+	echo "$pemfile already exists."
+	exit 1
+fi
+
+cp /dev/null $pemfile
+chmod 600 $pemfile
+chown root $pemfile
+
+cleanup() {
+	rm -f $pemfile
+	rm -f $randfile
+	exit 1
+}
+
+dd if=/dev/urandom of=$randfile count=1 2>/dev/null
+/usr/bin/openssl req -new -x509 -days 365 -nodes \
+	-config /etc/courier-imap/imapd.cnf -out $pemfile -keyout $pemfile || cleanup
+/usr/bin/openssl gendh -rand $randfile 512 >> $pemfile || cleanup
+/usr/bin/openssl x509 -subject -dates -fingerprint -noout -in $pemfile || cleanup
+rm -f $randfile
diff --git a/net-mail/courier-imap/files/mkpop3dcert b/net-mail/courier-imap/files/mkpop3dcert
new file mode 100755
index 0000000..6a55e99
--- /dev/null
+++ b/net-mail/courier-imap/files/mkpop3dcert
@@ -0,0 +1,39 @@
+#! /bin/sh
+#
+# mkimapdcert,v 1.1 2001/01/02 03:54:25 drobbins Exp
+#
+# Copyright 2000 Double Precision, Inc.  See COPYING for
+# distribution information.
+#
+# This is a short script to quickly generate a self-signed X.509 key for
+# IMAP over SSL.  Normally this script would get called by an automatic
+# package installation routine.
+
+test -x /usr/bin/openssl || exit 0
+
+prefix="/usr"
+pemfile="/etc/courier-imap/pop3d.pem"
+randfile="/etc/courier-imap/pop3d.rand"
+
+if test -f $pemfile
+then
+	echo "$pemfile already exists."
+	exit 1
+fi
+
+cp /dev/null $pemfile
+chmod 600 $pemfile
+chown root $pemfile
+
+cleanup() {
+	rm -f $pemfile
+	rm -f $randfile
+	exit 1
+}
+
+dd if=/dev/urandom of=$randfile count=1 2>/dev/null
+/usr/bin/openssl req -new -x509 -days 365 -nodes \
+	-config /etc/courier-imap/pop3d.cnf -out $pemfile -keyout $pemfile || cleanup
+/usr/bin/openssl gendh -rand $randfile 512 >> $pemfile || cleanup
+/usr/bin/openssl x509 -subject -dates -fingerprint -noout -in $pemfile || cleanup
+rm -f $randfile