File openldap2-client.spec of Package openldap2.4917

# spec file for package openldap2-client
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via

%define run_test_suite 0
%define version_main 2.4.41

%if ! %{defined _rundir}
%define _rundir %{_localstatedir}/run

Name:           openldap2-client
Summary:        The OpenLDAP commandline client tools
License:        OLDAP-2.8
Group:          Productivity/Networking/LDAP/Clients
Version:        2.4.41
Release:        0
Source:         openldap-%{version_main}.tgz
Source1:        openldap-rc.tgz
Source2:        addonschema.tar.gz
Source3:        DB_CONFIG
Source4:        sasl-slapd.conf
Source6:        README.dynamic-overlays
Source7:        schema2ldif
Source8:        baselibs.conf
Source100:      openldap-2.3.37.tgz
Patch1:         0001-build-adjustments.dif
Patch2:         0002-slapd.conf.dif
Patch3:         0003-LDAPI-socket-location.dif
Patch4:         0004-libldap-use-gethostbyname_r.dif
Patch5:         0005-pie-compile.dif
Patch6:         0006-No-Build-date-and-time-in-binaries.dif
Patch7:         0007-Recover-on-DB-version-change.dif
Patch8:         0008-In-monitor-backend-do-not-return-Connection0-entries.patch
Patch9:         0009-Fix-ldap-host-lookup-ipv6.patch
Patch10:        0010-Revert-Revert-ITS-8240-remove-obsolete-assert.patch
Patch11:        0011-Enforce-minimum-DH-size-of-1024.patch
Patch12:        0012-ITS-8203-more-fixes-for-8036-7904.patch
Patch13:        0013-ITS-8203-plug-leak-in-prev-commit.patch
Patch14:        0014-Fix-double-free-of-search-base-with-page-size-0.patch
Patch15:        0015-ITS-8631-Initialize-sal.patch
Patch16:        0016-retain-non-blocking-status-on-socket.patch
Patch17:        0017-Plug-a-socket-leak-in-ldap_new_connection-made-by-un.patch
Patch100:       openldap-2.3.37.dif
Patch101:       openldap-2.3.37-libldap-suid.diff
Patch102:       openldap-2.3.37-libldap-ldapi_url.dif
Patch103:       openldap-2.3.37-libldap-ntlm.diff
Patch104:       openldap-2.3.37-libldap-gethostbyname_r.dif
Patch105:       openldap-2.3.37-libldap-sasl-max-buff-size.dif
Patch106:       openldap-2.3.37-libldap-utf8-ADcanonical.dif
Patch107:       openldap-2.3.37-liblber-length-decoding.dif
Patch108:       openldap-2.3.37-libldap-ld_defconn-ldap_free_connection.dif
Patch109:       openldap-2.3.37-libldap-tls_chkhost-its6239.dif
Patch110:       openldap-2.3.37-libldap-ssl.dif
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  cyrus-sasl-devel
BuildRequires:  groff
BuildRequires:  libopenssl-devel
BuildRequires:  libtool
%if "%{name}" == "openldap2"
BuildRequires:  db-devel
BuildRequires:  openslp-devel
BuildRequires:  tcpd-devel
BuildRequires:  unixODBC-devel
Conflicts:      openldap
Requires:       libldap-2_4-2 = %{version_main}
PreReq:         %insserv_prereq %fillup_prereq /usr/sbin/useradd /usr/sbin/groupadd /usr/bin/grep
%if 0%{?suse_version} >= 1140
# avoid cycle with krb5
BuildRequires:  krb5-mini
BuildRequires:  pkgconfig(systemd)
Conflicts:      openldap-client
Requires:       libldap-2_4-2 = %{version_main}
# For /usr/bin/strings
Requires(pre):  binutils

%if "%{name}" == "openldap2"

The Lightweight Directory Access Protocol (LDAP) is used to access
online directory services. It runs directly over TCP and can be used to
access a stand-alone LDAP directory service or to access a directory
service that has an X.500 back-end.

%package      -n openldap2-back-perl
Summary:        OpenLDAP Perl Back-End
License:        OLDAP-2.8
Group:          Productivity/Networking/LDAP/Servers
Requires:       openldap2 = %{version_main}
Requires:       perl = %{perl_version}

%description -n openldap2-back-perl
The OpenLDAP Perl back-end allows you to execute Perl code specific to
different LDAP operations.

%package      -n openldap2-back-meta
Summary:        OpenLDAP Meta Back-End
License:        OLDAP-2.8
Group:          Productivity/Networking/LDAP/Servers
Requires:       openldap2 = %{version_main}
Provides:       openldap2:/usr/share/man/man5/slapd-meta.5.gz

%description -n openldap2-back-meta
The OpenLDAP Meta back-end is able to perform basic LDAP proxying with
respect to a set of remote LDAP servers. The information contained in
these servers can be presented as belonging to a single Directory
Information Tree (DIT).

%package      -n openldap2-back-sql
Summary:        OpenLDAP SQL Back-End
License:        OLDAP-2.8
Group:          Productivity/Networking/LDAP/Servers
Requires:       openldap2 = %{version_main}

%description -n openldap2-back-sql
The primary purpose of this OpenLDAP backend is to present information
stored in a Relational (SQL) Database as an LDAP subtree without the need
to do any programming.

%package      -n openldap2-doc
Summary:        OpenLDAP Documentation
License:        OLDAP-2.8
Group:          Documentation/Other
Provides:       openldap2:/usr/share/doc/packages/openldap2/drafts/README
%if 0%{?suse_version} > 1110
BuildArch:      noarch

%description -n openldap2-doc
The OpenLDAP Admin Guide plus a set of OpenLDAP related IETF internet drafts

%package      -n compat-libldap-2_3-0
Summary:        OpenLDAP Client Libraries
License:        BSD-3-Clause AND OLDAP-2.8 AND OLDAP-2.8
Group:          Productivity/Networking/LDAP/Clients
Version:        2.3.37
Release:        0

%description -n compat-libldap-2_3-0
This package contains the OpenLDAP client libraries.

    The OpenLDAP Project <>


This package contains the OpenLDAP client utilities.

%package      -n openldap2-devel
Summary:        Libraries, Header Files and Documentation for OpenLDAP
# bug437293
License:        OLDAP-2.8
Group:          Development/Libraries/C and C++
%ifarch ppc64
Obsoletes:      openldap2-devel-64bit
Conflicts:      openldap-devel
Requires:       libldap-2_4-2 = %{version_main}

%description -n openldap2-devel
This package provides the OpenLDAP libraries, header files, and

%package -n openldap2-devel-static
Summary:        Static libraries for the OpenLDAP libraries
License:        OLDAP-2.8
Group:          Development/Libraries/C and C++
Requires:       cyrus-sasl-devel
Requires:       libopenssl-devel
Requires:       openldap2-devel = %version

%description -n openldap2-devel-static
This package provides the static versions of the OpenLDAP libraries
for development.

%package      -n libldap-2_4-2
Summary:        OpenLDAP Client Libraries
License:        OLDAP-2.8
Group:          Productivity/Networking/LDAP/Clients

%description -n libldap-2_4-2
This package contains the OpenLDAP client libraries.


%setup -q -n openldap-%{version_main} -a1 -a2 -b100
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
%patch17 -p1
cp %{SOURCE6} .
cd ../openldap-2.3.37
%patch109 -p1

%{?suse_update_config:%{suse_update_config -f build}}
libtoolize --force
export STRIP=""
%configure \
        --localstatedir=%{_rundir}/slapd \
        --libexecdir=/usr/lib/openldap \
        --enable-wrappers \
        --enable-spasswd \
        --enable-modules \
        --enable-shared \
        --enable-dynamic \
        --with-tls \
        --with-cyrus-sasl \
        --enable-crypt \
        --enable-ipv6=yes \
%if "%{name}" == "openldap2"
        --enable-aci \
        --enable-bdb \
        --enable-hdb \
        --enable-rewrite \
        --enable-ldap=yes \
        --enable-meta=mod \
        --enable-monitor=yes \
        --enable-perl=mod \
        --enable-sql=mod \
        --enable-mdb=yes \
        --enable-slp \
        --enable-overlays=mod \
        --enable-syncprov=yes \
        --enable-ppolicy=yes \
        --disable-slapd \
        --enable-lmpasswd \
make depend
make %{?_smp_mflags}
%if "%{name}" == "openldap2"
#%if %suse_version < 1130
# build a static slapcat binary from the OpenLDAP 2.3 release
# to be able to update existing databases
cd ../openldap-2.3.37
%{?suse_update_config:%{suse_update_config -f build}}
# update config.sub for recent architectures
cp -a ../openldap-%{version_main}/build/config.sub build/config.sub
libtoolize --force
#aclocal -I build
export CFLAGS="$RPM_OPT_FLAGS  -Wno-format-extra-args -fno-strict-aliasing -DLDAP_DEPRECATED -DLDAP_CONNECTIONLESS"
%configure --localstatedir=%{_rundir}/slapd --libexecdir=/usr/lib/openldap \
        --enable-aci \
        --enable-hdb --enable-bdb --enable-ldbm --enable-crypt \
        --enable-ipv6=no \
        --enable-ldap --enable-monitor --enable-meta --enable-rewrite \
        --enable-dynamic=no --enable-shared=yes
make depend
make -C libraries %{?_smp_mflags}


%if %run_test_suite
# calculate the base port to be use in the test-suite
if [ -f /.buildenv ] ; then
    . /.buildenv
%ifnarch %arm alpha
rm -f tests/scripts/test019-syncreplication-cascade
rm -f tests/scripts/test022-ppolicy
rm -f tests/scripts/test023-refint
rm -f tests/scripts/test033-glue-syncrepl
#rm -f tests/scripts/test036-meta-concurrency
#rm -f tests/scripts/test039-glue-ldap-concurrency
rm -f tests/scripts/test043-delta-syncrepl
#rm -f tests/scripts/test045-syncreplication-proxied
rm -f tests/scripts/test048-syncrepl-multiproxy
rm -f tests/scripts/test050-syncrepl-multimaster
rm -f tests/scripts/test058-syncrepl-asymmetric
make SLAPD_DEBUG=0 test

mkdir -p $RPM_BUILD_ROOT/usr/lib/openldap/
mkdir -p $RPM_BUILD_ROOT/usr/sbin
mkdir -p $RPM_BUILD_ROOT/%{_unitdir}
install -m 755 start $RPM_BUILD_ROOT/usr/lib/openldap/start
install -m 644 slapd.service $RPM_BUILD_ROOT/%{_unitdir}
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/openldap/slapd.d
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/sasl2
install -m 644 %{SOURCE4} $RPM_BUILD_ROOT/%{_sysconfdir}/sasl2/slapd.conf
install -m 755 -d $RPM_BUILD_ROOT/var/lib/ldap
chmod a+x $RPM_BUILD_ROOT/%{_libdir}/*
chmod a+x $RPM_BUILD_ROOT/%{_libdir}/*
chmod a+x $RPM_BUILD_ROOT/%{_libdir}/*
install -m 755 %{SOURCE7} $RPM_BUILD_ROOT/usr/sbin/schema2ldif
%if "%{name}" == "openldap2"
%define DOCDIR %{_defaultdocdir}/%{name}
mkdir -p $RPM_BUILD_ROOT/var/adm/fillup-templates
install -m 644 sysconfig.openldap $RPM_BUILD_ROOT/var/adm/fillup-templates/sysconfig.openldap
install -m 644 *.schema $RPM_BUILD_ROOT/etc/openldap/schema
install -m 644 *.ldif $RPM_BUILD_ROOT/etc/openldap/schema
install -m 644 %{SOURCE3} $RPM_BUILD_ROOT/var/lib/ldap/DB_CONFIG
install -m 644 $RPM_BUILD_ROOT/etc/openldap/DB_CONFIG.example $RPM_BUILD_ROOT/var/lib/ldap/DB_CONFIG.example
install -d $RPM_BUILD_ROOT/etc/sysconfig/SuSEfirewall2.d/services/
install -m 644 SuSEfirewall2.openldap $RPM_BUILD_ROOT/etc/sysconfig/SuSEfirewall2.d/services/openldap
rm -f `find doc/guide ! -name *.html -a ! -name *.gif -a ! -name *.png -a !  -type d`
rm -rf doc/guide/release
install -d $RPM_BUILD_ROOT/%{DOCDIR}/adminguide \
           $RPM_BUILD_ROOT/%{DOCDIR}/images \
install -m 644 doc/guide/admin/* $RPM_BUILD_ROOT/%{DOCDIR}/adminguide
install -m 644 doc/guide/images/*.gif $RPM_BUILD_ROOT/%{DOCDIR}/images
install -m 644 doc/drafts/* $RPM_BUILD_ROOT/%{DOCDIR}/drafts
install -m 644 ANNOUNCEMENT \
               COPYRIGHT \
               LICENSE \
               README \
               CHANGES \
               %{SOURCE6} \
install -m 644 servers/slapd/slapd.ldif \
rm -f $RPM_BUILD_ROOT/etc/openldap/DB_CONFIG.example
rm -f $RPM_BUILD_ROOT/etc/openldap/schema/README
rm -f $RPM_BUILD_ROOT/etc/openldap/slapd.ldif*
rm -f $RPM_BUILD_ROOT%{_rundir}/slapd/openldap-data/DB_CONFIG.example
mv servers/slapd/back-sql/rdbms_depend servers/slapd/back-sql/examples
# Provide SUSE policy symlink /usr/sbin/rcFOO -> /etc/init.d/FOO
# /usr/sbin/service exists only since openSUSE 12.3:
%if 0%{?suse_version} > 1220
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rcslapd
ln -s /sbin/service %{buildroot}%{_sbindir}/rcslapd
%if %suse_version < 1130
# install 2.3 slapcat
install -m 755 ../openldap-2.3.37/servers/slapd/slapcat $RPM_BUILD_ROOT/usr/sbin/openldap-2.3-slapcat
echo "install sle-10 compat libraries (for SLE11)"
pushd ../openldap-2.3.37/libraries
rm -f $RPM_BUILD_ROOT/usr/lib/openldap/modules/*.a
rm -f $RPM_BUILD_ROOT/usr/share/man/man5/slapd-dnssrv.5
rm -f $RPM_BUILD_ROOT/usr/share/man/man5/slapd-ndb.5
rm -f $RPM_BUILD_ROOT/usr/share/man/man5/slapd-null.5
rm -f $RPM_BUILD_ROOT/usr/share/man/man5/slapd-passwd.5
rm -f $RPM_BUILD_ROOT/usr/share/man/man5/slapd-shell.5
rm -f $RPM_BUILD_ROOT/usr/share/man/man5/slapd-sock.5
rm -f $RPM_BUILD_ROOT/usr/share/man/man5/slapd-tcl.5
# Remove *.la files, libtool does not handle this correct
rm -f  $RPM_BUILD_ROOT%{_libdir}/lib*.la

#put filelists into files
cat >openldap2.filelist <<EOF
%config /etc/sysconfig/SuSEfirewall2.d/services/openldap
%dir /etc/sasl2
%dir /etc/openldap
%dir %attr(0770, ldap, ldap) /etc/openldap/slapd.d
%dir /etc/openldap/schema
%config /etc/openldap/schema/*.schema
%config /etc/openldap/schema/*.ldif
%config(noreplace) %attr(640, root, ldap) /etc/openldap/slapd.conf
%config(noreplace) %attr(640, ldap, ldap) /var/lib/ldap/DB_CONFIG
%config /var/lib/ldap/DB_CONFIG.example
%attr(640, root, ldap) /%{_sysconfdir}/openldap/slapd.conf.default
%config(noreplace) /etc/sasl2/slapd.conf
%dir /usr/lib/openldap
%dir /usr/lib/openldap/modules
%dir %attr(0700, ldap, ldap) /var/lib/ldap
%dir %attr(0755, ldap, ldap) %ghost %{_rundir}/slapd
%doc %{_mandir}/man8/sl*
%doc %{_mandir}/man5/slapd.*
%doc %{_mandir}/man5/slapd-bdb.*
%doc %{_mandir}/man5/slapd-config.*
%doc %{_mandir}/man5/slapd-hdb.*
%doc %{_mandir}/man5/slapd-ldbm.*
%doc %{_mandir}/man5/slapd-ldap.*
%doc %{_mandir}/man5/slapd-ldif.*
%doc %{_mandir}/man5/slapd-mdb.*
%doc %{_mandir}/man5/slapd-monitor.*
%doc %{_mandir}/man5/slapd-relay.*
%doc %{_mandir}/man5/slapo-*
%dir %{DOCDIR}
%doc %{DOCDIR}/slapd.ldif.default
%if %suse_version < 1130
cat >>openldap2.filelist <<EOF
cat > compat-libldap.filelist <<EOF
cat > openldap2-client.filelist <<EOF
%dir /etc/openldap
%config(noreplace) /etc/openldap/ldap.conf
%doc %{_mandir}/man1/ldap*
%doc %{_mandir}/man5/ldap.conf*
%doc %{_mandir}/man5/ldif.*
cat > libldap.filelist <<EOF
cat > openldap2-devel.filelist <<EOF
%doc %{_mandir}/man3/ber*
%doc %{_mandir}/man3/lber*
%doc %{_mandir}/man3/ld_errno*
%doc %{_mandir}/man3/ldap*
cat > openldap2-devel-static.filelist <<-EOF
cat > openldap2-back-perl.filelist <<EOF
%doc %{_mandir}/man5/slapd-perl.*
cat > openldap2-back-meta.filelist <<EOF
%doc %{_mandir}/man5/slapd-meta.*
cat > openldap2-back-sql.filelist <<EOF
%doc %{_mandir}/man5/slapd-sql.*
%doc servers/slapd/back-sql/examples
%doc servers/slapd/back-sql/docs/bugs
%doc servers/slapd/back-sql/docs/install
cat >openldap2-doc.filelist <<EOF
%dir %{DOCDIR}
%doc %{DOCDIR}/drafts
%doc %{DOCDIR}/adminguide
%doc %{DOCDIR}/images
#remove files from other spec file
%if "%{name}" == "openldap2"
cat openldap2-client.filelist libldap.filelist openldap2-devel.filelist \
	openldap2-devel-static.filelist |
cat openldap2.filelist openldap2-back-perl.filelist \
    openldap2-back-meta.filelist openldap2-back-sql.filelist \
    openldap2-doc.filelist compat-libldap.filelist |
  grep -v "%dir " |sed -e "s|^.* ||" |grep "^/" |while read name ; do
    rm -rf $RPM_BUILD_ROOT$name
%if "%{name}" == "openldap2"

/usr/sbin/groupadd -g 70 -o -r ldap || :
/usr/sbin/useradd -r -o -g ldap -u 76 -s /bin/bash -c "User for OpenLDAP" -d /var/lib/ldap ldap || :
# try to figure out if a db update is needed
if [ ${1:-0} -gt 1 ] && [ -f /usr/lib/openldap/slapd ] &&
    /usr/bin/strings /usr/lib/openldap/slapd | \
        grep "slapd 2.3" 2>&1 > /dev/null;
    # create a backup of the schema shipped with 2.3
    # at least core.schema changed between 2.3 and 2.4
    TEMPDIR=`mktemp -d /etc/openldap/schema.backup.XXXXXX`
    echo "Schema backup created in $TEMPDIR"
    cp -p --remove-destination /etc/openldap/schema/* $TEMPDIR
    echo $TEMPDIR > /etc/openldap/UPDATE_NEEDED ;
if /usr/bin/chkconfig ldap 2>&1 | grep -q on; then
    touch /var/run/enable_slapd_service
%service_add_pre slapd.service

if [ ${1:-0} -gt 1 ] && [ -f %{_libdir}/sasl2/slapd.conf ] ; then
  cp /etc/sasl2/slapd.conf /etc/sasl2/slapd.conf.rpmnew
  cp %{_libdir}/sasl2/slapd.conf /etc/sasl2/slapd.conf
%{fillup_only -n openldap ldap}
%{remove_and_set -n openldap OPENLDAP_RUN_DB_RECOVER}
%service_add_post slapd.service
if [ -f /var/run/enable_slapd_service ]; then
    /usr/bin/systemctl --quiet enable slapd

%service_del_preun slapd.service

%service_del_postun slapd.service

%post -n compat-libldap-2_3-0 -p /sbin/ldconfig

%postun -n compat-libldap-2_3-0 -p /sbin/ldconfig

%files -f openldap2.filelist

%files -n openldap2-back-perl -f openldap2-back-perl.filelist

%files -n openldap2-back-meta -f openldap2-back-meta.filelist

%files -n openldap2-back-sql -f openldap2-back-sql.filelist

%files -n openldap2-doc -f openldap2-doc.filelist

%files -n compat-libldap-2_3-0 -f compat-libldap.filelist


%post -n libldap-2_4-2 -p /sbin/ldconfig

%postun -n libldap-2_4-2 -p /sbin/ldconfig

%files -f openldap2-client.filelist

%files -n libldap-2_4-2 -f libldap.filelist

%files -n openldap2-devel -f openldap2-devel.filelist

%files -n openldap2-devel-static -f openldap2-devel-static.filelist

openSUSE Build Service is sponsored by