1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
7 KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~mips ppc ppc64 s390 sparc x86"
9 DESCRIPTION="Courier authentication library"
10 SRC_URI="mirror://sourceforge/courier/${P}.tar.bz2"
11 HOMEPAGE="https://www.courier-mta.org/authlib/"
14 IUSE="berkdb crypt debug gdbm ldap libressl mysql pam postgres sqlite static-libs"
16 RESTRICT="!berkdb? ( test )"
18 DEPEND="net-mail/mailbase
19 >=net-libs/courier-unicode-2.1
20 gdbm? ( sys-libs/gdbm )
21 !gdbm? ( sys-libs/db:= )
22 !libressl? ( dev-libs/openssl:0= )
23 libressl? ( dev-libs/libressl:= )
24 ldap? ( >=net-nds/openldap-1.2.11 )
25 mysql? ( dev-db/mysql-connector-c )
27 postgres? ( dev-db/postgresql:= )
28 sqlite? ( dev-db/sqlite:3 )"
33 if ! has_version 'dev-tcltk/expect' ; then
34 ewarn 'The dev-tcltk/expect package is not installed.'
35 ewarn 'Without it, you will not be able to change system login passwords.'
36 ewarn 'However non-system authentication modules (LDAP, MySQL, PostgreSQL,'
37 ewarn 'and others) will work just fine.'
42 filter-flags -fomit-frame-pointer
46 ewarn "Both gdbm and berkdb selected. Using gdbm."
51 use gdbm && myconf="--with-db=gdbm"
52 use debug && myconf+=" debug=true"
53 use sqlite && myconf+=" --with-sqlite-libs"
56 --sysconfdir=/etc/courier \
57 --datadir=/usr/share/courier \
58 --localstatedir=/var/lib/courier \
59 --sharedstatedir=/var/lib/courier/com \
60 --with-authdaemonvar=/var/lib/courier/authdaemon \
63 --with-mailuser=mail \
64 --with-mailgroup=mail \
65 --cache-file="${S}/configuring.cache" \
66 $(use_with pam authpam) \
67 $(use_with ldap authldap) \
68 $(use_with mysql authmysql) \
69 $(use_with postgres authpgsql) \
70 $(use_with sqlite authsqlite) \
75 file="${D}/etc/courier/authlib/${1}" ; option="${2}" ; param="${3}"
76 if [[ -e "${file}" ]] ; then
77 orig="$(grep ^${option}= ${file} | cut -d\" -f 2)"
78 new="${option}=\"${param} `echo ${orig} | sed -e\"s/${param}//g\" -e\"s/ / /g\"`\""
79 sed -i -e "s/^${option}=.*$/${new}/" "${file}" || die
85 /etc/courier/authlib /etc/courier /etc/courier-imap \
86 /usr/lib/courier/etc /usr/lib/courier-imap/etc \
87 /usr/local/etc /usr/local/etc/courier /usr/local/courier/etc \
88 /usr/local/lib/courier/etc /usr/local/lib/courier-imap/etc \
89 /usr/local/share/sqwebmail /usr/local/etc/courier-imap ; do
90 if [[ -e "${dir}/userdb" ]] ; then
91 einfo "Found userdb at: ${dir}/userdb"
92 cp -fR "${dir}/userdb" "${D}/etc/courier/authlib/" || die
93 chmod go-rwx "${D}/etc/courier/authlib/userdb" || die
100 diropts -o mail -g mail
102 keepdir /var/lib/courier/authdaemon
103 keepdir /etc/courier/authlib
104 emake DESTDIR="${D}" install
105 [[ ! -e "${D}/etc/courier/authlib/userdb" ]] && finduserdb
106 emake DESTDIR="${D}" install-configure
107 rm -f "${D}"/etc/courier/authlib/*.bak
108 chown mail:mail "${D}"/etc/courier/authlib/* || die
109 for y in "${D}"/etc/courier/authlib/*.dist ; do
110 [[ ! -e "${y%%.dist}" ]] && cp -f "${y}" "${y%%.dist}"
112 use pam && orderfirst authdaemonrc authmodulelist authpam
113 use ldap && orderfirst authdaemonrc authmodulelist authldap
114 use sqlite && orderfirst authdaemonrc authmodulelist authsqlite
115 use postgres && orderfirst authdaemonrc authmodulelist authpgsql
116 use mysql && orderfirst authdaemonrc authmodulelist authmysql
118 DOCS=( AUTHORS ChangeLog* INSTALL NEWS README )
119 HTML_DOCS=( README.html README_authlib.html NEWS.html INSTALL.html README.authdebug.html )
121 DOCS+=( README.authmysql.myownquery )
122 HTML_DOCS+=( README.authmysql.html )
124 if use postgres ; then
125 HTML_DOCS+=( README.authpostgres.html README.authmysql.html )
128 DOCS+=( README.ldap )
129 dodir /etc/openldap/schema
130 cp -f authldap.schema "${D}/etc/openldap/schema/" || die
133 HTML_DOCS+=( README.authsqlite.html README.authmysql.html )
137 newinitd "${FILESDIR}/${PN}-r2" "${PN}"
139 use static-libs || find "${D}" -name "*.a" -delete
143 if [[ -e /etc/courier/authlib/userdb ]] ; then
144 einfo "Running makeuserdb ..."
145 chmod go-rwx /etc/courier/authlib/userdb || die