Gentoo Archives: gentoo-commits

From: "Robin H. Johnson" <robbat2@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-nds/openldap/
Date: Sat, 02 May 2020 23:15:06
Message-Id: 1588461146.4bf2f1709bbb8b087c56a2e01ce735d0dac58c2b.robbat2@gentoo
1 commit: 4bf2f1709bbb8b087c56a2e01ce735d0dac58c2b
2 Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
3 AuthorDate: Sat May 2 23:12:26 2020 +0000
4 Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
5 CommitDate: Sat May 2 23:12:26 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4bf2f170
7
8 net-nds/openldap: bump for security CVE-2020-12243
9
10 Also update mirrors to use HTTPS/HTTPS, because upstream's official
11 download URL is a FTP site which seems to be broken.
12
13 Bug: https://bugs.gentoo.org/641576
14 Bug: https://bugs.gentoo.org/719960
15 Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>
16
17 net-nds/openldap/Manifest | 1 +
18 net-nds/openldap/openldap-2.4.50.ebuild | 907 ++++++++++++++++++++++++++++++++
19 2 files changed, 908 insertions(+)
20
21 diff --git a/net-nds/openldap/Manifest b/net-nds/openldap/Manifest
22 index 097a02925b8..535c953b507 100644
23 --- a/net-nds/openldap/Manifest
24 +++ b/net-nds/openldap/Manifest
25 @@ -1,3 +1,4 @@
26 DIST openldap-2.4.48.tgz 5704883 BLAKE2B ef856ff0b22c9187e68e9c09583a176fe4c2ee1f5bfe6b169f03bc0058294170ec4d1aa1b164e28eecd2ef6bafab539c1b942b0bd74e93852205beeaff39aeef SHA512 cf694a415be0bd55cc7f606099da2ed461748efd276561944cd29d7f5a8252a9be799d8778fac2d4fa9f382731eb4ca48c6b85630cb58a3b8249843561ae8feb
27 DIST openldap-2.4.49.tgz 5704723 BLAKE2B ee777588d758f6704b0d38b90feb85b27e2307510a05d1d147324e9958a6f6fc5bc7dd521a1462971c3f707429ad38fab734f508d71fd88b447770e112e844a2 SHA512 99d1943d126b06e62865e31e5825fcff2cb15415f7f85ae4962fa0e7425bc3b58db5b9639150d7b09e3642c80257724c745e47c25ab4fcb1bba0ba771011dd49
28 +DIST openldap-2.4.50.tgz 5712635 BLAKE2B 6a7d864a44c411b82cf703585c4a81954a02497e8510c84e29070dd120da0181e8425fd2b8bb7616e42e6e26d0f06db5ffdf50fb1cd97943d23f9914eb4f1260 SHA512 f528043ff9de36f7b65d8816c9a9c24f0ac400041b2969965178ee6eae62c92a11af33a0a883e4954e5fff98a0738a9f9aa2faf5b385d21974754e045aab31ae
29 DIST rfc2307bis.schema-20140524 12262 BLAKE2B 98031f49e9bde1e4821e637af3382364d8344ed7017649686a088070d96a632dffa6c661552352656b1b159c0fd962965580069a64c7f3d5bb6a3ed75f60fd99 SHA512 83b89a1deeefc8566b97e7e865b9b6d04541099cbdf719e24538a7d27d61b6209e87ab9003a9f140bd9afd018ec569e71721e3a24090e1902c8b6659d2ba103e
30
31 diff --git a/net-nds/openldap/openldap-2.4.50.ebuild b/net-nds/openldap/openldap-2.4.50.ebuild
32 new file mode 100644
33 index 00000000000..0a53058f874
34 --- /dev/null
35 +++ b/net-nds/openldap/openldap-2.4.50.ebuild
36 @@ -0,0 +1,907 @@
37 +# Copyright 1999-2020 Gentoo Authors
38 +# Distributed under the terms of the GNU General Public License v2
39 +
40 +EAPI=7
41 +
42 +inherit autotools db-use flag-o-matic multilib-minimal ssl-cert toolchain-funcs user systemd
43 +
44 +BIS_PN=rfc2307bis.schema
45 +BIS_PV=20140524
46 +BIS_P="${BIS_PN}-${BIS_PV}"
47 +
48 +DESCRIPTION="LDAP suite of application and development tools"
49 +HOMEPAGE="http://www.OpenLDAP.org/"
50 +
51 +# upstream mirrors are mostly not working, using canonical URI
52 +SRC_URI="
53 + https://openldap.org/software/download/OpenLDAP/openldap-release/${P}.tgz
54 + http://gpl.savoirfairelinux.net/pub/mirrors/openldap/openldap-release/${P}.tgz
55 + http://repository.linagora.org/OpenLDAP/openldap-release/${P}.tgz
56 + http://mirror.eu.oneandone.net/software/openldap/openldap-release/${P}.tgz
57 + mirror://gentoo/${BIS_P}"
58 +
59 +LICENSE="OPENLDAP GPL-2"
60 +SLOT="0"
61 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~ppc-aix ~amd64-linux ~x86-linux ~x86-solaris"
62 +
63 +IUSE_DAEMON="crypt samba tcpd experimental minimal"
64 +IUSE_BACKEND="+berkdb"
65 +IUSE_OVERLAY="overlays perl"
66 +IUSE_OPTIONAL="gnutls iodbc sasl ssl odbc debug ipv6 libressl +syslog selinux static-libs test"
67 +IUSE_CONTRIB="smbkrb5passwd kerberos kinit pbkdf2 sha2"
68 +IUSE_CONTRIB="${IUSE_CONTRIB} -cxx"
69 +IUSE="${IUSE_DAEMON} ${IUSE_BACKEND} ${IUSE_OVERLAY} ${IUSE_OPTIONAL} ${IUSE_CONTRIB}"
70 +
71 +RESTRICT="!test? ( test )"
72 +REQUIRED_USE="cxx? ( sasl )
73 + pbkdf2? ( ssl )
74 + test? ( berkdb )
75 + ?? ( test minimal )"
76 +
77 +# always list newer first
78 +# Do not add any AGPL-3 BDB here!
79 +# See bug 525110, comment 15.
80 +# Advanced usage: OPENLDAP_BDB_SLOTS in the environment can be used to force a slot during build.
81 +BDB_SLOTS="${OPENLDAP_BDB_SLOTS:=5.3 5.1 4.8 4.7 4.6 4.5 4.4}"
82 +BDB_PKGS=''
83 +for _slot in $BDB_SLOTS; do BDB_PKGS="${BDB_PKGS} sys-libs/db:${_slot}" ; done
84 +
85 +# openssl is needed to generate lanman-passwords required by samba
86 +COMMON_DEPEND="
87 + ssl? (
88 + !gnutls? (
89 + !libressl? ( >=dev-libs/openssl-1.0.1h-r2:0=[${MULTILIB_USEDEP}] )
90 + libressl? ( dev-libs/libressl:0=[${MULTILIB_USEDEP}] )
91 + )
92 + gnutls? (
93 + >=net-libs/gnutls-2.12.23-r6:=[${MULTILIB_USEDEP}]
94 + >=dev-libs/libgcrypt-1.5.3:0=[${MULTILIB_USEDEP}]
95 + )
96 + )
97 + sasl? ( dev-libs/cyrus-sasl:= )
98 + !minimal? (
99 + sys-devel/libtool
100 + sys-libs/e2fsprogs-libs
101 + >=dev-db/lmdb-0.9.18:=
102 + tcpd? ( sys-apps/tcp-wrappers )
103 + odbc? ( !iodbc? ( dev-db/unixODBC )
104 + iodbc? ( dev-db/libiodbc ) )
105 + perl? ( dev-lang/perl:=[-build(-)] )
106 + samba? (
107 + !libressl? ( dev-libs/openssl:0= )
108 + libressl? ( dev-libs/libressl:0= )
109 + )
110 + berkdb? (
111 + <sys-libs/db-6.0:=
112 + || ( ${BDB_PKGS} )
113 + )
114 + smbkrb5passwd? (
115 + !libressl? ( dev-libs/openssl:0= )
116 + libressl? ( dev-libs/libressl:0= )
117 + kerberos? ( app-crypt/heimdal )
118 + )
119 + kerberos? (
120 + virtual/krb5
121 + kinit? ( !app-crypt/heimdal )
122 + )
123 + cxx? ( dev-libs/cyrus-sasl:= )
124 + )
125 +"
126 +DEPEND="${COMMON_DEPEND}
127 + sys-apps/groff
128 +"
129 +RDEPEND="${COMMON_DEPEND}
130 + selinux? ( sec-policy/selinux-ldap )
131 +"
132 +# for tracking versions
133 +OPENLDAP_VERSIONTAG=".version-tag"
134 +OPENLDAP_DEFAULTDIR_VERSIONTAG="/var/lib/openldap-data"
135 +
136 +MULTILIB_WRAPPED_HEADERS=(
137 + # USE=cxx
138 + /usr/include/LDAPAsynConnection.h
139 + /usr/include/LDAPAttrType.h
140 + /usr/include/LDAPAttribute.h
141 + /usr/include/LDAPAttributeList.h
142 + /usr/include/LDAPConnection.h
143 + /usr/include/LDAPConstraints.h
144 + /usr/include/LDAPControl.h
145 + /usr/include/LDAPControlSet.h
146 + /usr/include/LDAPEntry.h
147 + /usr/include/LDAPEntryList.h
148 + /usr/include/LDAPException.h
149 + /usr/include/LDAPExtResult.h
150 + /usr/include/LDAPMessage.h
151 + /usr/include/LDAPMessageQueue.h
152 + /usr/include/LDAPModList.h
153 + /usr/include/LDAPModification.h
154 + /usr/include/LDAPObjClass.h
155 + /usr/include/LDAPRebind.h
156 + /usr/include/LDAPRebindAuth.h
157 + /usr/include/LDAPReferenceList.h
158 + /usr/include/LDAPResult.h
159 + /usr/include/LDAPSaslBindResult.h
160 + /usr/include/LDAPSchema.h
161 + /usr/include/LDAPSearchReference.h
162 + /usr/include/LDAPSearchResult.h
163 + /usr/include/LDAPSearchResults.h
164 + /usr/include/LDAPUrl.h
165 + /usr/include/LDAPUrlList.h
166 + /usr/include/LdifReader.h
167 + /usr/include/LdifWriter.h
168 + /usr/include/SaslInteraction.h
169 + /usr/include/SaslInteractionHandler.h
170 + /usr/include/StringList.h
171 + /usr/include/TlsOptions.h
172 +)
173 +
174 +PATCHES=(
175 + "${FILESDIR}"/${PN}-2.4.17-gcc44.patch
176 +
177 + "${FILESDIR}"/${PN}-2.2.14-perlthreadsfix.patch
178 + "${FILESDIR}"/${PN}-2.4.15-ppolicy.patch
179 +
180 + # bug #116045 - still present in 2.4.28
181 + "${FILESDIR}"/${PN}-2.4.35-contrib-smbk5pwd.patch
182 + # bug #408077 - samba4
183 + "${FILESDIR}"/${PN}-2.4.35-contrib-samba4.patch
184 +
185 + # bug #189817
186 + "${FILESDIR}"/${PN}-2.4.11-libldap_r.patch
187 +
188 + # bug #233633
189 + "${FILESDIR}"/${PN}-2.4.45-fix-lmpasswd-gnutls-symbols.patch
190 +
191 + # bug #281495
192 + "${FILESDIR}"/${PN}-2.4.28-gnutls-gcrypt.patch
193 +
194 + # bug #294350
195 + "${FILESDIR}"/${PN}-2.4.6-evolution-ntlm.patch
196 +
197 + # unbreak /bin/sh -> dash
198 + "${FILESDIR}"/${PN}-2.4.28-fix-dash.patch
199 +
200 + # bug #420959
201 + "${FILESDIR}"/${PN}-2.4.31-gcc47.patch
202 +
203 + # unbundle lmdb
204 + "${FILESDIR}"/${PN}-2.4.42-mdb-unbundle.patch
205 +
206 + # bug #622464
207 + "${FILESDIR}"/${PN}-2.4.47-libressl.patch
208 +
209 + # fix some compiler warnings
210 + "${FILESDIR}"/${PN}-2.4.47-warnings.patch
211 +)
212 +
213 +openldap_filecount() {
214 + local dir="$1"
215 + find "${dir}" -type f ! -name '.*' ! -name 'DB_CONFIG*' | wc -l
216 +}
217 +
218 +openldap_find_versiontags() {
219 + # scan for all datadirs
220 + local openldap_datadirs=()
221 + if [[ -f "${EROOT}"/etc/openldap/slapd.conf ]]; then
222 + openldap_datadirs=( $(awk '{if($1 == "directory") print $2 }' "${EROOT}"/etc/openldap/slapd.conf) )
223 + fi
224 + openldap_datadirs+=( ${OPENLDAP_DEFAULTDIR_VERSIONTAG} )
225 +
226 + einfo
227 + einfo "Scanning datadir(s) from slapd.conf and"
228 + einfo "the default installdir for Versiontags"
229 + einfo "(${OPENLDAP_DEFAULTDIR_VERSIONTAG} may appear twice)"
230 + einfo
231 +
232 + # scan datadirs if we have a version tag
233 + openldap_found_tag=0
234 + have_files=0
235 + for each in ${openldap_datadirs[@]} ; do
236 + CURRENT_TAGDIR="${ROOT}$(sed "s:\/::" <<< ${each})"
237 + CURRENT_TAG="${CURRENT_TAGDIR}/${OPENLDAP_VERSIONTAG}"
238 + if [[ -d "${CURRENT_TAGDIR}" ]] && [[ "${openldap_found_tag}" == 0 ]] ; then
239 + einfo "- Checking ${each}..."
240 + if [[ -r "${CURRENT_TAG}" ]] ; then
241 + # yey, we have one :)
242 + einfo " Found Versiontag in ${each}"
243 + source "${CURRENT_TAG}"
244 + if [[ "${OLDPF}" == "" ]] ; then
245 + eerror "Invalid Versiontag found in ${CURRENT_TAGDIR}"
246 + eerror "Please delete it"
247 + eerror
248 + die "Please kill the invalid versiontag in ${CURRENT_TAGDIR}"
249 + fi
250 +
251 + OLD_MAJOR=$(ver_cut 2-3 ${OLDPF})
252 +
253 + [[ "$(openldap_filecount ${CURRENT_TAGDIR})" -gt 0 ]] && have_files=1
254 +
255 + # are we on the same branch?
256 + if [[ "${OLD_MAJOR}" != "${PV:0:3}" ]] ; then
257 + ewarn " Versiontag doesn't match current major release!"
258 + if [[ "${have_files}" == "1" ]] ; then
259 + eerror " Versiontag says other major and you (probably) have datafiles!"
260 + echo
261 + openldap_upgrade_howto
262 + else
263 + einfo " No real problem, seems there's no database."
264 + fi
265 + else
266 + einfo " Versiontag is fine here :)"
267 + fi
268 + else
269 + einfo " Non-tagged dir ${each}"
270 + [[ "$(openldap_filecount ${each})" -gt 0 ]] && have_files=1
271 + if [[ "${have_files}" == "1" ]] ; then
272 + einfo " EEK! Non-empty non-tagged datadir, counting `ls -a ${each} | wc -l` files"
273 + echo
274 +
275 + eerror
276 + eerror "Your OpenLDAP Installation has a non tagged datadir that"
277 + eerror "possibly contains a database at ${CURRENT_TAGDIR}"
278 + eerror
279 + eerror "Please export data if any entered and empty or remove"
280 + eerror "the directory, installation has been stopped so you"
281 + eerror "can take required action"
282 + eerror
283 + eerror "For a HOWTO on exporting the data, see instructions in the ebuild"
284 + eerror
285 + openldap_upgrade_howto
286 + die "Please move the datadir ${CURRENT_TAGDIR} away"
287 + fi
288 + fi
289 + einfo
290 + fi
291 + done
292 + [[ "${have_files}" == "1" ]] && einfo "DB files present" || einfo "No DB files present"
293 +
294 + # Now we must check for the major version of sys-libs/db linked against.
295 + SLAPD_PATH="${EROOT}/usr/$(get_libdir)/openldap/slapd"
296 + if [[ "${have_files}" == "1" ]] && [[ -f "${SLAPD_PATH}" ]]; then
297 + OLDVER="$(/usr/bin/ldd ${SLAPD_PATH} \
298 + | awk '/libdb-/{gsub("^libdb-","",$1);gsub(".so$","",$1);print $1}')"
299 + if use berkdb; then
300 + # find which one would be used
301 + for bdb_slot in ${BDB_SLOTS} ; do
302 + NEWVER="$(db_findver "=sys-libs/db-${bdb_slot}*")"
303 + [[ -n "${NEWVER}" ]] && break
304 + done
305 + fi
306 + local fail=0
307 + if [[ -z "${OLDVER}" ]] && [[ -z "${NEWVER}" ]]; then
308 + :
309 + # Nothing wrong here.
310 + elif [[ -z "${OLDVER}" ]] && [[ -n "${NEWVER}" ]]; then
311 + eerror " Your existing version of OpenLDAP was not built against"
312 + eerror " any version of sys-libs/db, but the new one will build"
313 + eerror " against ${NEWVER} and your database may be inaccessible."
314 + echo
315 + fail=1
316 + elif [[ -n "${OLDVER}" ]] && [[ -z "${NEWVER}" ]]; then
317 + eerror " Your existing version of OpenLDAP was built against"
318 + eerror " sys-libs/db:${OLDVER}, but the new one will not be"
319 + eerror " built against any version and your database may be"
320 + eerror " inaccessible."
321 + echo
322 + fail=1
323 + elif [[ "${OLDVER}" != "${NEWVER}" ]]; then
324 + eerror " Your existing version of OpenLDAP was built against"
325 + eerror " sys-libs/db:${OLDVER}, but the new one will build against"
326 + eerror " ${NEWVER} and your database would be inaccessible."
327 + echo
328 + fail=1
329 + fi
330 + [[ "${fail}" == "1" ]] && openldap_upgrade_howto
331 + fi
332 +
333 + echo
334 + einfo
335 + einfo "All datadirs are fine, proceeding with merge now..."
336 + einfo
337 +}
338 +
339 +openldap_upgrade_howto() {
340 + local d l i
341 + eerror
342 + eerror "A (possible old) installation of OpenLDAP was detected,"
343 + eerror "installation will not proceed for now."
344 + eerror
345 + eerror "As major version upgrades can corrupt your database,"
346 + eerror "you need to dump your database and re-create it afterwards."
347 + eerror
348 + eerror "Additionally, rebuilding against different major versions of the"
349 + eerror "sys-libs/db libraries will cause your database to be inaccessible."
350 + eerror ""
351 + d="$(date -u +%s)"
352 + l="/root/ldapdump.${d}"
353 + i="${l}.raw"
354 + eerror " 1. /etc/init.d/slapd stop"
355 + eerror " 2. slapcat -l ${i}"
356 + eerror " 3. egrep -v '^(entry|context)CSN:' <${i} >${l}"
357 + eerror " 4. mv /var/lib/openldap-data/ /var/lib/openldap-data-backup/"
358 + eerror " 5. emerge --update \=net-nds/${PF}"
359 + eerror " 6. etc-update, and ensure that you apply the changes"
360 + eerror " 7. slapadd -l ${l}"
361 + eerror " 8. chown ldap:ldap /var/lib/openldap-data/*"
362 + eerror " 9. /etc/init.d/slapd start"
363 + eerror "10. check that your data is intact."
364 + eerror "11. set up the new replication system."
365 + eerror
366 + if [[ "${FORCE_UPGRADE}" != "1" ]]; then
367 + die "You need to upgrade your database first"
368 + else
369 + eerror "You have the magical FORCE_UPGRADE=1 in place."
370 + eerror "Don't say you weren't warned about data loss."
371 + fi
372 +}
373 +
374 +pkg_setup() {
375 + if ! use sasl && use cxx ; then
376 + die "To build the ldapc++ library you must emerge openldap with sasl support"
377 + fi
378 + # Bug #322787
379 + if use minimal && ! has_version "net-nds/openldap" ; then
380 + einfo "No datadir scan needed, openldap not installed"
381 + elif use minimal && has_version 'net-nds/openldap[minimal]' ; then
382 + einfo "Skipping scan for previous datadirs as requested by minimal useflag"
383 + else
384 + openldap_find_versiontags
385 + fi
386 +
387 + # The user/group are only used for running daemons which are
388 + # disabled in minimal builds, so elide the accounts too.
389 + if ! use minimal ; then
390 + enewgroup ldap 439
391 + enewuser ldap 439 -1 /usr/$(get_libdir)/openldap ldap
392 + fi
393 +}
394 +
395 +src_prepare() {
396 + # ensure correct SLAPI path by default
397 + sed -e 's,\(#define LDAPI_SOCK\).*,\1 "'"${EPREFIX}"'/var/run/openldap/slapd.sock",' \
398 + -i include/ldap_defaults.h || die
399 +
400 + default
401 + rm -r libraries/liblmdb || die
402 +
403 + pushd build &>/dev/null || die "pushd build"
404 + einfo "Making sure upstream build strip does not do stripping too early"
405 + sed -i.orig \
406 + -e '/^STRIP/s,-s,,g' \
407 + top.mk || die "Failed to block stripping"
408 + popd &>/dev/null || die
409 +
410 + # wrong assumption that /bin/sh is /bin/bash
411 + sed \
412 + -e 's|/bin/sh|/bin/bash|g' \
413 + -i tests/scripts/* || die "sed failed"
414 +
415 + AT_NOEAUTOMAKE=yes eautoreconf
416 +}
417 +
418 +build_contrib_module() {
419 + # <dir> <sources> <outputname>
420 + pushd "${S}/contrib/slapd-modules/$1" &>/dev/null || die "pushd contrib/slapd-modules/$1"
421 + einfo "Compiling contrib-module: $3"
422 + # Make sure it's uppercase
423 + local define_name="$(LC_ALL=C tr '[:lower:]' '[:upper:]' <<< "SLAPD_OVER_${1}")"
424 + "${lt}" --mode=compile --tag=CC \
425 + "${CC}" \
426 + -D${define_name}=SLAPD_MOD_DYNAMIC \
427 + -I"${BUILD_DIR}"/include \
428 + -I../../../include -I../../../servers/slapd ${CFLAGS} \
429 + -o ${2%.c}.lo -c $2 || die "compiling $3 failed"
430 + einfo "Linking contrib-module: $3"
431 + "${lt}" --mode=link --tag=CC \
432 + "${CC}" -module \
433 + ${CFLAGS} \
434 + ${LDFLAGS} \
435 + -rpath "${EPREFIX}"/usr/$(get_libdir)/openldap/openldap \
436 + -o $3.la ${2%.c}.lo || die "linking $3 failed"
437 + popd &>/dev/null || die
438 +}
439 +
440 +src_configure() {
441 + # Bug 408001
442 + use elibc_FreeBSD && append-cppflags -DMDB_DSYNC=O_SYNC -DMDB_FDATASYNC=fsync
443 +
444 + # connectionless ldap per bug #342439
445 + append-cppflags -DLDAP_CONNECTIONLESS
446 +
447 + multilib-minimal_src_configure
448 +}
449 +
450 +multilib_src_configure() {
451 + local myconf=()
452 +
453 + use debug && myconf+=( $(use_enable debug) )
454 +
455 + # ICU exists only in the configure, nowhere in the codebase, bug #510858
456 + export ac_cv_header_unicode_utypes_h=no ol_cv_lib_icu=no
457 +
458 + if ! use minimal && multilib_is_native_abi; then
459 + local CPPFLAGS=${CPPFLAGS}
460 +
461 + # re-enable serverside overlay chains per bug #296567
462 + # see ldap docs chaper 12.3.1 for details
463 + myconf+=( --enable-ldap )
464 +
465 + # backends
466 + myconf+=( --enable-slapd )
467 + if use berkdb ; then
468 + einfo "Using Berkeley DB for local backend"
469 + myconf+=( --enable-bdb --enable-hdb )
470 + DBINCLUDE=$(db_includedir ${BDB_SLOTS})
471 + einfo "Using ${DBINCLUDE} for sys-libs/db version"
472 + # We need to include the slotted db.h dir for FreeBSD
473 + append-cppflags -I${DBINCLUDE}
474 + else
475 + myconf+=( --disable-bdb --disable-hdb )
476 + fi
477 + for backend in dnssrv ldap mdb meta monitor null passwd relay shell sock; do
478 + myconf+=( --enable-${backend}=mod )
479 + done
480 +
481 + myconf+=( $(use_enable perl perl mod) )
482 +
483 + myconf+=( $(use_enable odbc sql mod) )
484 + if use odbc ; then
485 + local odbc_lib="unixodbc"
486 + if use iodbc ; then
487 + odbc_lib="iodbc"
488 + append-cppflags -I"${EPREFIX}"/usr/include/iodbc
489 + fi
490 + myconf+=( --with-odbc=${odbc_lib} )
491 + fi
492 +
493 + # slapd options
494 + myconf+=(
495 + $(use_enable crypt)
496 + --disable-slp
497 + $(use_enable samba lmpasswd)
498 + $(use_enable syslog)
499 + )
500 + if use experimental ; then
501 + myconf+=(
502 + --enable-dynacl
503 + --enable-aci=mod
504 + )
505 + fi
506 + for option in aci cleartext modules rewrite rlookups slapi; do
507 + myconf+=( --enable-${option} )
508 + done
509 +
510 + # slapd overlay options
511 + # Compile-in the syncprov, the others as module
512 + myconf+=( --enable-syncprov=yes )
513 + use overlays && myconf+=( --enable-overlays=mod )
514 +
515 + else
516 + myconf+=(
517 + --disable-backends
518 + --disable-slapd
519 + --disable-bdb
520 + --disable-hdb
521 + --disable-mdb
522 + --disable-overlays
523 + --disable-syslog
524 + )
525 + fi
526 +
527 + # basic functionality stuff
528 + myconf+=(
529 + $(use_enable ipv6)
530 + $(multilib_native_use_with sasl cyrus-sasl)
531 + $(multilib_native_use_enable sasl spasswd)
532 + $(use_enable tcpd wrappers)
533 + )
534 +
535 + # Some cross-compiling tests don't pan out well.
536 + tc-is-cross-compiler && myconf+=(
537 + --with-yielding-select=yes
538 + )
539 +
540 + local ssl_lib="no"
541 + if use ssl || ( ! use minimal && use samba ) ; then
542 + ssl_lib="openssl"
543 + use gnutls && ssl_lib="gnutls"
544 + fi
545 +
546 + myconf+=( --with-tls=${ssl_lib} )
547 +
548 + for basicflag in dynamic local proctitle shared; do
549 + myconf+=( --enable-${basicflag} )
550 + done
551 +
552 + tc-export AR CC CXX
553 + CONFIG_SHELL="/bin/bash" \
554 + ECONF_SOURCE="${S}" \
555 + STRIP=/bin/true \
556 + econf \
557 + --libexecdir="${EPREFIX}"/usr/$(get_libdir)/openldap \
558 + $(use_enable static-libs static) \
559 + "${myconf[@]}"
560 + emake depend
561 +}
562 +
563 +src_configure_cxx() {
564 + # This needs the libraries built by the first build run.
565 + # So we have to run it AFTER the main build, not just after the main
566 + # configure.
567 + local myconf_ldapcpp=(
568 + --with-ldap-includes="${S}"/include
569 + )
570 +
571 + mkdir -p "${BUILD_DIR}"/contrib/ldapc++ || die
572 + pushd "${BUILD_DIR}/contrib/ldapc++" &>/dev/null || die "pushd contrib/ldapc++"
573 +
574 + local LDFLAGS=${LDFLAGS} CPPFLAGS=${CPPFLAGS}
575 + append-ldflags -L"${BUILD_DIR}"/libraries/liblber/.libs \
576 + -L"${BUILD_DIR}"/libraries/libldap/.libs
577 + append-cppflags -I"${BUILD_DIR}"/include
578 + ECONF_SOURCE=${S}/contrib/ldapc++ \
579 + econf "${myconf_ldapcpp[@]}" \
580 + CC="${CC}" \
581 + CXX="${CXX}"
582 + popd &>/dev/null || die
583 +}
584 +
585 +multilib_src_compile() {
586 + tc-export AR CC CXX
587 + emake CC="${CC}" AR="${AR}" SHELL="${EPREFIX}"/bin/bash
588 + local lt="${BUILD_DIR}/libtool"
589 + export echo="echo"
590 +
591 + if ! use minimal && multilib_is_native_abi ; then
592 + if use cxx ; then
593 + einfo "Building contrib library: ldapc++"
594 + src_configure_cxx
595 + pushd "${BUILD_DIR}/contrib/ldapc++" &>/dev/null || die "pushd contrib/ldapc++"
596 + emake CC="${CC}" CXX="${CXX}"
597 + popd &>/dev/null || die
598 + fi
599 +
600 + if use smbkrb5passwd ; then
601 + einfo "Building contrib-module: smbk5pwd"
602 + pushd "${S}/contrib/slapd-modules/smbk5pwd" &>/dev/null || die "pushd contrib/slapd-modules/smbk5pwd"
603 +
604 + MY_DEFS="-DDO_SHADOW"
605 + if use samba ; then
606 + MY_DEFS="${MY_DEFS} -DDO_SAMBA"
607 + MY_KRB5_INC=""
608 + fi
609 + if use kerberos ; then
610 + MY_DEFS="${MY_DEFS} -DDO_KRB5"
611 + MY_KRB5_INC="$(krb5-config --cflags)"
612 + fi
613 +
614 + emake \
615 + DEFS="${MY_DEFS}" \
616 + KRB5_INC="${MY_KRB5_INC}" \
617 + LDAP_BUILD="${BUILD_DIR}" \
618 + CC="${CC}" libexecdir="${EPREFIX}/usr/$(get_libdir)/openldap"
619 + popd &>/dev/null || die
620 + fi
621 +
622 + if use overlays ; then
623 + einfo "Building contrib-module: samba4"
624 + pushd "${S}/contrib/slapd-modules/samba4" &>/dev/null || die "pushd contrib/slapd-modules/samba4"
625 +
626 + emake \
627 + LDAP_BUILD="${BUILD_DIR}" \
628 + CC="${CC}" libexecdir="/usr/$(get_libdir)/openldap"
629 + popd &>/dev/null || die
630 + fi
631 +
632 + if use kerberos ; then
633 + if use kinit ; then
634 + build_contrib_module "kinit" "kinit.c" "kinit"
635 + fi
636 + pushd "${S}/contrib/slapd-modules/passwd" &>/dev/null || die "pushd contrib/slapd-modules/passwd"
637 + einfo "Compiling contrib-module: pw-kerberos"
638 + "${lt}" --mode=compile --tag=CC \
639 + "${CC}" \
640 + -I"${BUILD_DIR}"/include \
641 + -I../../../include \
642 + ${CFLAGS} \
643 + $(krb5-config --cflags) \
644 + -DHAVE_KRB5 \
645 + -o kerberos.lo \
646 + -c kerberos.c || die "compiling pw-kerberos failed"
647 + einfo "Linking contrib-module: pw-kerberos"
648 + "${lt}" --mode=link --tag=CC \
649 + "${CC}" -module \
650 + ${CFLAGS} \
651 + ${LDFLAGS} \
652 + -rpath "${EPREFIX}"/usr/$(get_libdir)/openldap/openldap \
653 + -o pw-kerberos.la \
654 + kerberos.lo || die "linking pw-kerberos failed"
655 + popd &>/dev/null || die
656 + fi
657 +
658 + if use pbkdf2; then
659 + pushd "${S}/contrib/slapd-modules/passwd/pbkdf2" &>/dev/null || die "pushd contrib/slapd-modules/passwd/pbkdf2"
660 + einfo "Compiling contrib-module: pw-pbkdf2"
661 + "${lt}" --mode=compile --tag=CC \
662 + "${CC}" \
663 + -I"${BUILD_DIR}"/include \
664 + -I../../../../include \
665 + ${CFLAGS} \
666 + -o pbkdf2.lo \
667 + -c pw-pbkdf2.c || die "compiling pw-pbkdf2 failed"
668 + einfo "Linking contrib-module: pw-pbkdf2"
669 + "${lt}" --mode=link --tag=CC \
670 + "${CC}" -module \
671 + ${CFLAGS} \
672 + ${LDFLAGS} \
673 + -rpath "${EPREFIX}"/usr/$(get_libdir)/openldap/openldap \
674 + -o pw-pbkdf2.la \
675 + pbkdf2.lo || die "linking pw-pbkdf2 failed"
676 + popd &>/dev/null || die
677 + fi
678 +
679 + if use sha2 ; then
680 + pushd "${S}/contrib/slapd-modules/passwd/sha2" &>/dev/null || die "pushd contrib/slapd-modules/passwd/sha2"
681 + einfo "Compiling contrib-module: pw-sha2"
682 + "${lt}" --mode=compile --tag=CC \
683 + "${CC}" \
684 + -I"${BUILD_DIR}"/include \
685 + -I../../../../include \
686 + ${CFLAGS} \
687 + -o sha2.lo \
688 + -c sha2.c || die "compiling pw-sha2 failed"
689 + "${lt}" --mode=compile --tag=CC \
690 + "${CC}" \
691 + -I"${BUILD_DIR}"/include \
692 + -I../../../../include \
693 + ${CFLAGS} \
694 + -o slapd-sha2.lo \
695 + -c slapd-sha2.c || die "compiling pw-sha2 failed"
696 + einfo "Linking contrib-module: pw-sha2"
697 + "${lt}" --mode=link --tag=CC \
698 + "${CC}" -module \
699 + ${CFLAGS} \
700 + ${LDFLAGS} \
701 + -rpath "${EPREFIX}"/usr/$(get_libdir)/openldap/openldap \
702 + -o pw-sha2.la \
703 + sha2.lo slapd-sha2.lo || die "linking pw-sha2 failed"
704 + popd &>/dev/null || die
705 + fi
706 +
707 + # We could build pw-radius if GNURadius would install radlib.h
708 + pushd "${S}/contrib/slapd-modules/passwd" &>/dev/null || die "pushd contrib/slapd-modules/passwd"
709 + einfo "Compiling contrib-module: pw-netscape"
710 + "${lt}" --mode=compile --tag=CC \
711 + "${CC}" \
712 + -I"${BUILD_DIR}"/include \
713 + -I../../../include \
714 + ${CFLAGS} \
715 + -o netscape.lo \
716 + -c netscape.c || die "compiling pw-netscape failed"
717 + einfo "Linking contrib-module: pw-netscape"
718 + "${lt}" --mode=link --tag=CC \
719 + "${CC}" -module \
720 + ${CFLAGS} \
721 + ${LDFLAGS} \
722 + -rpath "${EPREFIX}"/usr/$(get_libdir)/openldap/openldap \
723 + -o pw-netscape.la \
724 + netscape.lo || die "linking pw-netscape failed"
725 +
726 + #build_contrib_module "acl" "posixgroup.c" "posixGroup" # example code only
727 + #build_contrib_module "acl" "gssacl.c" "gss" # example code only, also needs kerberos
728 + build_contrib_module "addpartial" "addpartial-overlay.c" "addpartial-overlay"
729 + build_contrib_module "allop" "allop.c" "overlay-allop"
730 + build_contrib_module "allowed" "allowed.c" "allowed"
731 + build_contrib_module "autogroup" "autogroup.c" "autogroup"
732 + build_contrib_module "cloak" "cloak.c" "cloak"
733 + # build_contrib_module "comp_match" "comp_match.c" "comp_match" # really complex, adds new external deps, questionable demand
734 + build_contrib_module "denyop" "denyop.c" "denyop-overlay"
735 + build_contrib_module "dsaschema" "dsaschema.c" "dsaschema-plugin"
736 + build_contrib_module "dupent" "dupent.c" "dupent"
737 + build_contrib_module "lastbind" "lastbind.c" "lastbind"
738 + # lastmod may not play well with other overlays
739 + build_contrib_module "lastmod" "lastmod.c" "lastmod"
740 + build_contrib_module "noopsrch" "noopsrch.c" "noopsrch"
741 + #build_contrib_module "nops" "nops.c" "nops-overlay" https://bugs.gentoo.org/641576
742 + #build_contrib_module "nssov" "nssov.c" "nssov-overlay" RESO:LATER
743 + build_contrib_module "trace" "trace.c" "trace"
744 + popd &>/dev/null || die
745 + # build slapi-plugins
746 + pushd "${S}/contrib/slapi-plugins/addrdnvalues" &>/dev/null || die "pushd contrib/slapi-plugins/addrdnvalues"
747 + einfo "Building contrib-module: addrdnvalues plugin"
748 + "${CC}" -shared \
749 + -I"${BUILD_DIR}"/include \
750 + -I../../../include \
751 + ${CFLAGS} \
752 + -fPIC \
753 + ${LDFLAGS} \
754 + -o libaddrdnvalues-plugin.so \
755 + addrdnvalues.c || die "Building libaddrdnvalues-plugin.so failed"
756 + popd &>/dev/null || die
757 + fi
758 +}
759 +
760 +multilib_src_test() {
761 + if multilib_is_native_abi; then
762 + cd tests || die
763 + emake tests
764 + fi
765 +}
766 +
767 +multilib_src_install() {
768 + local lt="${BUILD_DIR}/libtool"
769 + emake DESTDIR="${D}" SHELL="${EPREFIX}"/bin/bash install
770 +
771 + if ! use minimal && multilib_is_native_abi; then
772 + # openldap modules go here
773 + # TODO: write some code to populate slapd.conf with moduleload statements
774 + keepdir /usr/$(get_libdir)/openldap/openldap/
775 +
776 + # initial data storage dir
777 + keepdir /var/lib/openldap-data
778 + use prefix || fowners ldap:ldap /var/lib/openldap-data
779 + fperms 0700 /var/lib/openldap-data
780 +
781 + echo "OLDPF='${PF}'" > "${ED}${OPENLDAP_DEFAULTDIR_VERSIONTAG}/${OPENLDAP_VERSIONTAG}"
782 + echo "# do NOT delete this. it is used" >> "${ED}${OPENLDAP_DEFAULTDIR_VERSIONTAG}/${OPENLDAP_VERSIONTAG}"
783 + echo "# to track versions for upgrading." >> "${ED}${OPENLDAP_DEFAULTDIR_VERSIONTAG}/${OPENLDAP_VERSIONTAG}"
784 +
785 + # use our config
786 + rm "${ED}"/etc/openldap/slapd.conf
787 + insinto /etc/openldap
788 + newins "${FILESDIR}"/${PN}-2.4.40-slapd-conf slapd.conf
789 + configfile="${ED}"/etc/openldap/slapd.conf
790 +
791 + # populate with built backends
792 + ebegin "populate config with built backends"
793 + for x in "${ED}"/usr/$(get_libdir)/openldap/openldap/back_*.so; do
794 + einfo "Adding $(basename ${x})"
795 + sed -e "/###INSERTDYNAMICMODULESHERE###$/a# moduleload\t$(basename ${x})" -i "${configfile}" || die
796 + done
797 + sed -e "s:###INSERTDYNAMICMODULESHERE###$:# modulepath\t${EPREFIX}/usr/$(get_libdir)/openldap/openldap:" -i "${configfile}"
798 + use prefix || fowners root:ldap /etc/openldap/slapd.conf
799 + fperms 0640 /etc/openldap/slapd.conf
800 + cp "${configfile}" "${configfile}".default || die
801 + eend
802 +
803 + # install our own init scripts and systemd unit files
804 + einfo "Install init scripts"
805 + sed -e "s,/usr/lib/,/usr/$(get_libdir)/," "${FILESDIR}"/slapd-initd-2.4.40-r2 > "${T}"/slapd || die
806 + doinitd "${T}"/slapd
807 + newconfd "${FILESDIR}"/slapd-confd-2.4.28-r1 slapd
808 +
809 + einfo "Install systemd service"
810 + sed -e "s,/usr/lib/,/usr/$(get_libdir)/," "${FILESDIR}"/slapd.service > "${T}"/slapd.service || die
811 + systemd_dounit "${T}"/slapd.service
812 + systemd_install_serviced "${FILESDIR}"/slapd.service.conf
813 + systemd_newtmpfilesd "${FILESDIR}"/slapd.tmpfilesd slapd.conf
814 +
815 + # If built without SLP, we don't need to be before avahi
816 + sed -i \
817 + -e '/before/{s/avahi-daemon//g}' \
818 + "${ED}"/etc/init.d/slapd \
819 + || die
820 +
821 + if use cxx ; then
822 + einfo "Install the ldapc++ library"
823 + cd "${BUILD_DIR}/contrib/ldapc++" || die
824 + emake DESTDIR="${D}" libexecdir="${EPREFIX}/usr/$(get_libdir)/openldap" install
825 + cd "${S}"/contrib/ldapc++ || die
826 + newdoc README ldapc++-README
827 + fi
828 +
829 + if use smbkrb5passwd ; then
830 + einfo "Install the smbk5pwd module"
831 + cd "${S}/contrib/slapd-modules/smbk5pwd" || die
832 + emake DESTDIR="${D}" \
833 + LDAP_BUILD="${BUILD_DIR}" \
834 + libexecdir="${EPREFIX}/usr/$(get_libdir)/openldap" install
835 + newdoc README smbk5pwd-README
836 + fi
837 +
838 + if use overlays ; then
839 + einfo "Install the samba4 module"
840 + cd "${S}/contrib/slapd-modules/samba4" || die
841 + emake DESTDIR="${D}" \
842 + LDAP_BUILD="${BUILD_DIR}" \
843 + libexecdir="/usr/$(get_libdir)/openldap" install
844 + newdoc README samba4-README
845 + fi
846 +
847 + einfo "Installing contrib modules"
848 + cd "${S}/contrib/slapd-modules" || die
849 + for l in */*.la */*/*.la; do
850 + [[ -e ${l} ]] || continue
851 + "${lt}" --mode=install cp ${l} \
852 + "${ED}"/usr/$(get_libdir)/openldap/openldap || \
853 + die "installing ${l} failed"
854 + done
855 +
856 + dodoc "${FILESDIR}"/DB_CONFIG.fast.example
857 + docinto contrib
858 + doman */*.5
859 + #newdoc acl/README*
860 + newdoc addpartial/README addpartial-README
861 + newdoc allop/README allop-README
862 + newdoc allowed/README allowed-README
863 + newdoc autogroup/README autogroup-README
864 + newdoc dsaschema/README dsaschema-README
865 + newdoc passwd/README passwd-README
866 + cd "${S}/contrib/slapi-plugins" || die
867 + insinto /usr/$(get_libdir)/openldap/openldap
868 + doins */*.so
869 + docinto contrib
870 + newdoc addrdnvalues/README addrdnvalues-README
871 +
872 + insinto /etc/openldap/schema
873 + newins "${DISTDIR}"/${BIS_P} ${BIS_PN}
874 +
875 + docinto back-sock ; dodoc "${S}"/servers/slapd/back-sock/searchexample*
876 + docinto back-shell ; dodoc "${S}"/servers/slapd/back-shell/searchexample*
877 + docinto back-perl ; dodoc "${S}"/servers/slapd/back-perl/SampleLDAP.pm
878 +
879 + dosbin "${S}"/contrib/slapd-tools/statslog
880 + newdoc "${S}"/contrib/slapd-tools/README README.statslog
881 + fi
882 +
883 + if ! use static-libs ; then
884 + find "${ED}" \( -name '*.a' -o -name '*.la' \) -delete || die
885 + fi
886 +}
887 +
888 +multilib_src_install_all() {
889 + dodoc ANNOUNCEMENT CHANGES COPYRIGHT README
890 + docinto rfc ; dodoc doc/rfc/*.txt
891 +}
892 +
893 +pkg_preinst() {
894 + # keep old libs if any
895 + preserve_old_lib /usr/$(get_libdir)/{liblber,libldap_r,liblber}-2.3$(get_libname 0)
896 + # bug 440470, only display the getting started help there was no openldap before,
897 + # or we are going to a non-minimal build
898 + ! has_version net-nds/openldap || has_version 'net-nds/openldap[minimal]'
899 + OPENLDAP_PRINT_MESSAGES=$((! $?))
900 +}
901 +
902 +pkg_postinst() {
903 + if ! use minimal ; then
904 + # You cannot build SSL certificates during src_install that will make
905 + # binary packages containing your SSL key, which is both a security risk
906 + # and a misconfiguration if multiple machines use the same key and cert.
907 + if use ssl; then
908 + install_cert /etc/openldap/ssl/ldap
909 + use prefix || chown ldap:ldap "${EROOT}"/etc/openldap/ssl/ldap.*
910 + ewarn "Self-signed SSL certificates are treated harshly by OpenLDAP 2.[12]"
911 + ewarn "Self-signed SSL certificates are treated harshly by OpenLDAP 2.[12]"
912 + ewarn "add 'TLS_REQCERT allow' if you want to use them."
913 + fi
914 +
915 + if use prefix; then
916 + # Warn about prefix issues with slapd
917 + eerror "slapd might NOT be usable on Prefix systems as it requires root privileges"
918 + eerror "to start up, and requires that certain files directories be owned by"
919 + eerror "ldap:ldap. As Prefix does not support changing ownership of files and"
920 + eerror "directories, you will have to manually fix this yourself."
921 + fi
922 +
923 + # These lines force the permissions of various content to be correct
924 + if [[ -d "${EROOT}"/var/run/openldap ]]; then
925 + use prefix || { chown ldap:ldap "${EROOT}"/var/run/openldap || die; }
926 + chmod 0755 "${EROOT}"/var/run/openldap || die
927 + fi
928 + use prefix || chown root:ldap "${EROOT}"/etc/openldap/slapd.conf{,.default}
929 + chmod 0640 "${EROOT}"/etc/openldap/slapd.conf{,.default} || die
930 + use prefix || chown ldap:ldap "${EROOT}"/var/lib/openldap-data
931 + fi
932 +
933 + if has_version 'net-nds/openldap[-minimal]' && ((${OPENLDAP_PRINT_MESSAGES})); then
934 + elog "Getting started using OpenLDAP? There is some documentation available:"
935 + elog "Gentoo Guide to OpenLDAP Authentication"
936 + elog "(https://wiki.gentoo.org/wiki/Centralized_authentication_using_OpenLDAP)"
937 + elog "---"
938 + elog "An example file for tuning BDB backends with openldap is"
939 + elog "DB_CONFIG.fast.example in /usr/share/doc/${PF}/"
940 + fi
941 +
942 + preserve_old_lib_notify /usr/$(get_libdir)/{liblber,libldap,libldap_r}-2.3$(get_libname 0)
943 +}