Monday 21 November 2011

Openldap2.4.26, BerkeleyDB-5.2 and Sasl from scratch

In these days I've deployed a openldap server with openldap-2.4.26, BerkeleyDB.5.2 and cyrus-sasl-2.1.23.

First of all make sure no *-dev packeges are installed for bdb or for sasl.

Start with BerkeleyDB: download from the oracle site, expand and:
cd db-5.2.36/
cd build_unix && ../dist/configure --prefix=/usr/local/BerkeleyDB.5.2/
make
sudo make install

Now it's time for sasl. I got the cyrus-sasl-2.1.23.tar.gz package from: http://cyrusimap.web.cmu.edu/mediawiki/index.php/Cyrus_SASL

Expand it and apply patch: http://repos.archlinuxppc.org/wsvn/filedetails.php?repname=packages&path=%2Fcyrus-sasl-plugins%2Ftrunk%2Fcyrus-sasl-2.1.23-db5-fix.patch.

The patch is actually a patch to two files. To apply a patch a
patch -p1 < patchfile
should work. If there are rejected chunks, move to the dir of the file to be modified and apply only the part of the patch that refers to that file. Write a compile script:
#!/bin/bash

export LDFLAGS="-L/usr/local/BerkeleyDB.5.2/lib"
export LD_LIBRARY_PATH=/usr/local/BerkeleyDB.5.2/lib/

sed -i.bak 's/#elif WITH_DES/#elif defined(WITH_DES)/' \
    plugins/digestmd5.c &&
env CPPFLAGS="-I/usr/local/BerkeleyDB.5.2/include/" \
LDFLAGS="-L/usr/local/BerkeleyDB.5.2/lib/ -R/usr/local/BerkeleyDB.5.2/lib" \
./configure --with-dblib=berkeley --prefix=/usr/local/sasl-2.1.23/
Execute the compile script followed by make and sudo make install. Remember to create the soft link from /usr/local/sasl-2.1.23/lib/sasl2 to /usr/lib/sasl2.
sudo ln -s /usr/local/sasl-2.1.23/lib/sasl2 .
To compile openldap, download and expand the packege, write a compilation script:
#!/bin/bash

export LDFLAGS="-L/usr/local/BerkeleyDB.5.2/lib"
export LD_LIBRARY_PATH=/usr/local/BerkeleyDB.5.2/lib/

env CPPFLAGS="-I/usr/local/BerkeleyDB.5.2/include/ \
 -I/usr/local/sasl-2.1.23/include/" \
LDFLAGS="-L/usr/local/BerkeleyDB.5.2/lib/ -L/usr/local/sasl-2.1.23/lib/" \
./configure --enable-crypt --enable-hdb=yes --enable-ppolicy \
--with-cyrus-sasl --with-tls=openssl --enable-overlays \
--enable-valsort --localstatedir=/var/lib/ --prefix=/usr/local/openldap-2.4.26

Then run the command, make depend, make and sudo make install.