Wednesday, October 26, 2022

[SOLVED] How to build openldap with custom libopenssl

Issue

I need to build libldap under linux (and windows, but that's a different story).

When I do

./configure --prefix="$OPENLDAP_BUILD_PATH" --disable-slapd
make
make install
make clean

I get with ldd that libldap is linked with system libraries libssl.so and libcrypto.so. And what I need is to link it with my custom builds of this libraries.

I also tried this:

OPENLDAP2_BUILD_PATH="$BUILD_PATH/openldap2"
mkdir "$OPENLDAP2_BUILD_PATH"

OPENSSL_DEPENDENCY_PATH="$BUILD_PATH/openssl"

LD_LIBRARY_PATH="$OPENSSL_DEPENDENCY_PATH/lib:$LD_LIBRARY_PATH"
CPPFLAGS="-l$OPENSSL_DEPENDENCY_PATH/include/openssl"
LDFLAGS="-L$OPENSSL_DEPENDENCY_PATH/lib"

./configure --prefix="$OPENLDAP2_BUILD_PATH" --disable-slapd
make
make install
make clean

With no success either.

ldd libldap.so shows this:

linux-vdso.so.1 =>  (0x00007ffc91923000)
liblber-2.4.so.2 => /home/me/Work-U14/proj/shared/BUILD/openldap2/lib/liblber-2.4.so.2 (0x00007ff0ef638000)
libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007ff0ef3f8000)
libssl.so.1.0.0 => /lib/x86_64-linux-gnu/libssl.so.1.0.0 (0x00007ff0ef198000)
libcrypto.so.1.0.0 => /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 (0x00007ff0eedbc000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff0ee9f4000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff0ee7ef000)
/lib64/ld-linux-x86-64.so.2 (0x000056386adf5000)

Solution

It's not a good solution, but a well-enough workaround for me.

  1. I've written build.sh as follows:

    #!/bin/sh

    if [ -z "$BUILD_PATH" ] then echo "Variable BUILD_PATH isn't specified!" exit fi

    OPENLDAP2_BUILD_PATH="$BUILD_PATH/openldap2"

    export MY_OPENSSL_ROOT="$BUILD_PATH/openssl"

    ./configure --prefix=$OPENLDAP2_BUILD_PATH --disable-slapd >/home/sherst/Desktop/configure_log.openldap2 2>&1 make >/home/sherst/Desktop/make_log.openldap2 2>&1 make install >/home/sherst/Desktop/make_install_log.openldap2 2>&1

  2. I've patched configure file as such:

LINE 15485 LIBS="-Wl,-rpath=$ORIGIN/ -L. -lssl -lcrypto $LIBS"

LINE 15582 TLS_LIBS="-Wl,-rpath=$MY_OPENSSL_ROOT/lib -L$MY_OPENSSL_ROOT/lib -lssl -lcrypto -lRSAglue -lrsaref"

LINE 15584 TLS_LIBS="-Wl,-rpath=$MY_OPENSSL_ROOT/lib -L$MY_OPENSSL_ROOT/lib -lssl -lcrypto"

  1. In such way (I'm quite sure that it's very crude and overabundant) I've achieved that ldd shows links to my openssl libs. TO hard code them is a bad idea, but when, in distro, there will be no such paths, I expect ld to find them in local dir, where we plan to put them.

  2. openldap faq says this should be achieved ain such way:

    env CPPFLAGS=-I/path/to/openssl/include \ LDFLAGS=-L/path/to/openssl/lib-dir \ configure --with-tls ...

But that didn't work for me (perhaps, I did it wrong).



Answered By - sdd
Answer Checked By - Willingham (WPSolving Volunteer)