OpenLDAP 2.3.43

コンパイル時の注意点

--enable-cryptと--enable-lmpasswdを同時に有効にすると矛盾が生じます のでどちらかにします。
--enable-perlはSolarisにperlの64bitライブラリがないためリンクに失敗 します。よって64bitでperlをコンパイルしてインストールするか有効にし ないようにします。
Solaris 10 6/06から/usr/include/sys/avl.hが登場してOpenLDAPパッケー ジのavl.hと衝突し、コンパイルが失敗します。このリリースを使う場合 は-D_AVL_HをCPPFLAGSで定義します。

Solaris Crypto Framework対応

Ultra SPARC T1/2 内蔵の暗号高速化エンジンを利用できるようにSolaris Crypto Frameworkを使います。なお、他のプロセッサでもSolaris Crypto Frameworkを使えば若干の高速化が望めるため、とにかくこれを有効にしま す。
ソースコードに以下のパッチを適用します。

--- libraries/libldap/tls.c.orig        2008-02-12 08:24:12.000000000 +0900
+++ libraries/libldap/tls.c     2009-03-11 13:43:05.819235000 +0900
@@ -43,6 +43,11 @@
 #include <openssl/err.h>
 #include <openssl/rand.h>
 #include <openssl/safestack.h>
+#ifdef PKCS11ENGINE
+#include <openssl/engine.h>
+ENGINE *e;
+const char *engine_id = "pkcs11";
+#endif /* PKCS11ENGINE */
 #elif defined( HAVE_SSL_H )
 #include <ssl.h>
 #endif
@@ -193,6 +198,29 @@
        tls_init_threads();
 #endif

+#ifdef PKCS11ENGINE
+       /* Additional code to use of HW accelerators */
+
+       ENGINE_load_builtin_engines();
+
+       e = ENGINE_by_id(engine_id);
+       if(!e){
+               printf("error ENGINE_byid\n");
+               return;
+       }
+       if(!ENGINE_init(e)){
+               printf("error ENGINE_init\n");
+               ENGINE_free(e);
+               return;
+       }
+       if(!ENGINE_set_default_RSA(e)){
+               printf("error ENGINE_set_default_RSA\n");
+               abort();
+       }
+       ENGINE_set_default_DSA(e);
+       ENGINE_set_default_ciphers(e);
+#endif   /* PKCS11ENGINE */
+
        SSL_load_error_strings();
        SSLeay_add_ssl_algorithms();

@@ -535,6 +563,12 @@
        SSL_free( p->ssl );
        LBER_FREE( sbiod->sbiod_pvt );
        sbiod->sbiod_pvt = NULL;
+
+#ifdef PKCS11ENGINE
+       ENGINE_finish(e);
+       ENGINE_free(e);
+#endif   /* PKCS11ENGINE */
+
        return 0;
 }

コンパイル

以下のようなスクリプトを実行します。

#!/bin/sh

if [ $# -eq 1 ]; then
        . ../setup-pre.sh $1
else
        . ../setup-pre.sh
fi

CPPFLAGS="-D_AVL_H -DPKCS11ENGINE $CPPFLAGS"; export CPPFLAGS
LIBS="-ldb"; export LIBS

./configure $CONFDIRS \
    --localstatedir=/var \
    --libexecdir=/usr/local/libexec/$ISA \
    --mandir=/usr/local/share/man \
    --enable-dynamic \
    --enable-crypt \
    --enable-spasswd \
    --enable-modules \
    --enable-slp \
    --enable-bdb=mod \
    --enable-dnssrv=mod \
    --enable-hdb=mod \
    --enable-ldap=mod \
    --enable-meta=mod \
    --enable-monitor=mod \
    --enable-null=mod \
    --enable-passwd=mod \
    --enable-relay=mod \
    --enable-overlays=mod
% ./setup.sh [sparcv9|sparcv8plus|i386|amd64]

生成されたlibtoolを置き換えます。

% cp /usr/local/bin/$ISA/libtool .

makeしてインストールします。

% gmake depend
% gmake
# gmake install

ISA自動起動リンクを作るために、以下のスクリプトを実行します。

#!/bin/sh
#
SBINPROG="slapacl slapauth slaptest slappasswd slapindex slapdn slapcat slapadd"
BINPROG="ldapadd ldapcompare ldapwhoami ldappasswd ldapmodrdn ldapdelete ldapmodify ldapsearch"
LIBEXECPROG="slurpd slapd"
if [ "${SBINPROG}" != "" ]; then
  cd ${SBINDIR}
  for prog in ${SBINPROG}
  do
    rm -f $prog
    ln /usr/lib/isaexec $prog
    echo $prog
  done
fi

if [ "${BINPROG}" != "" ]; then
  cd ${BINDIR}
  for prog in ${BINPROG}
  do
    rm -f $prog
    ln /usr/lib/isaexec $prog
    echo $prog
  done
fi

設定

# groupadd -g 389 ldap
# useradd -u 389 -g 389 -d /noexistent -s /bin/false -c "OpenLDAP Server" ldap
# mkdir /var/openldap-data
# mkdir /etc/openldap
# chown ldap:ldap /var/openldap-data
# chown ldap:ldap /etc/openldap/slapd.conf
# chmod 700 /var/openldap-data
# chmod 600 /etc/openldap/slapd.conf

Solaris 10 SMF

/var/svc/manifest/network/ldap/server.xml

<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM
	  "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
        $Id: openldap.html,v 1.7 2009/03/11 10:01:00 hiraga Exp $

        Service manifest for the OpenLDAP slapd service.
-->

<service_bundle type='manifest' name='slapd'>

<service
        name='network/ldap/server'
        type='service'
        version='1'>

        <create_default_instance enabled='false' />

        <single_instance />

        <dependency
            name='fs-local'
            grouping='require_all'
            restart_on='none'
            type='service'>
                <service_fmri value='svc:/system/filesystem/local' />
        </dependency>

        <dependency
            name='network-service'
            grouping='require_all'
            restart_on='none'
            type='service'>
                <service_fmri value='svc:/network/service' />
        </dependency>

        <dependency
            name='system-log'
            grouping='optional_all'
            restart_on='none'
            type='service'>
                <service_fmri value='svc:/system/system-log' />
        </dependency>

        <dependency name='config_data'
                grouping='require_all'
                restart_on='restart'
                type='path'>
                <service_fmri
                        value='file://localhost/etc/openldap/slapd.conf'
                />
        </dependency>

        <exec_method
                 type='method'
                 name='start'
                 exec='/lib/svc/method/slapd start'
                 timeout_seconds='-1'>
        </exec_method>

        <exec_method
                 type='method'
                 name='stop'
                 exec='/lib/svc/method/slapd stop'
                 timeout_seconds='-1'>
        </exec_method>

        <exec_method
                 type='method'
                 name='restart'
                 exec='/lib/svc/method/slapd restart'
                 timeout_seconds='-1'>
        </exec_method>

        <template>
                <common_name>
                        <loctext xml:lang='C'>
slapd, OpenLDAP LDAP server.
                        </loctext>
                </common_name>
                <documentation>
                        <manpage title='slapd' section='1M'
                                manpath='/usr/local/man' />
                </documentation>
        </template>
</service>

</service_bundle>

/lib/svc/method/slapd

#!/sbin/sh
#
# OpenLDAP LDAP server
# $Id: openldap.html,v 1.7 2009/03/11 10:01:00 hiraga Exp $
#

. /lib/svc/share/smf_include.sh

UID=ldap
GID=ldap
URI="ldapi:/// ldap:/// ldaps:///"
SLAPD=/usr/local/libexec/slapd
CONF=/etc/openldap/slapd.conf
RUNDIR=/var/run/openldap
PIDFILE=$RUNDIR/slapd.pid

case "$1" in
start)
        if [ ! -d ${RUNDIR} ]; then
                mkdir ${RUNDIR}
        fi
        if [ -d ${RUNDIR} ]; then
                chown ${UID}:${GID} ${RUNDIR}
        fi

        [ -f "${CONF}" ] && [ -f "${SLAPD}" ] || exit 0
        ${SLAPD} -f ${CONF} -u ${UID} -g ${GID} -h "${URI}" 2>&1 &
        ;;

stop)
        /usr/bin/pkill slapd
        if [ -d ${RUNDIR} ]; then
                rmdir ${RUNDIR}
        fi
        ;;

restart)
        stop
        while /usr/bin/pgrep slapd > /dev/null
        do
                sleep 5
        done
        start
        ;;

*)
        echo "Usage: $0 { start | stop }"
        exit 1
        ;;
esac
exit 0

manifestのimport

# chown root:bin /lib/svc/method/slapd
# chmod 555 /lib/svc/method/slapd
# chown root:sys /var/svc/manifest/network/ldap/server.xml
# chmod 444 /var/svc/manifest/network/ldap/server.xml
# /usr/sbin/svccfg validate /var/svc/manifest/network/ldap/server.xml
# /usr/sbin/svccfg -v import /var/svc/manifest/network/ldap/server.xml

有効化

# svcadm enable svc:/network/ldap/server

Solaris 8/9

/etc/init.d/slapd:
#!/sbin/sh
#

UID=ldap
GID=ldap
SLAPD=/usr/local/libexec/slapd
URI="ldap:/// ldaps:///"
RUN=/var/run/openldap
CONF=/etc/openldap/slapd.conf

case "$1" in
start)
        if [ ! -d $RUN ]; then
                mkdir $RUN
                chown ${UID}:${GID} $RUN
        fi

        [ -f "$CONF" ] && [ -f "$SLAPD" ] || exit 0
        $SLAPD -f $CONF -h "$URI" 2>&1 &
        ;;

stop)
        [ -f "$SLAPD" ] && pkill slapd
        ;;

*)
        echo "Usage: $0 { start | stop }"
        exit 1
        ;;

esac
exit 0

hiraga@next-hop.net
Last modified: $Date: 2009/03/11 10:01:00 $
Apache