Solarisでcyrus-sasl

2007年1月16日のエントリで書いたcyrus-saslライブラリのインストール。makeでエラーになったまま放置していましたが、今日ようやく解決。
前回引っかかったエラーはこういうもの。

$ ./configure
$ /usr/local/bin/make
(中略)
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I../include -I../lib -I../sasldb -I../include -Wall -W -g -O2 -MT digestmd5.lo -MD -MP -MF .deps/digestmd5.Tpo -c digestmd5.c  -fPIC -DPIC -o digestmd5.lo
digestmd5.c:279: warning: pointer targets in initialization differ in signedness
digestmd5.c: In function 'DigestCalcResponse':
digestmd5.c:366: warning: pointer targets in passing argument 2 of 'utils->MD5Update' differ in signedness
digestmd5.c: At top level:
digestmd5.c:812: error: expected specifier-qualifier-list before 'des_key_schedule'
digestmd5.c: In function 'dec_3des':
(後略)

digestmd5.cの812行目付近のソースはこんなのでした。

#ifdef WITH_DES
struct des_context_s {
    des_key_schedule keysched;  /* key schedule for des initialization */
    des_cblock ivec;            /* initial vector for encoding */
    des_key_schedule keysched2; /* key schedule for 3des initialization */
};

des_key_schedule keysched;となっているところが812行目。des_key_scheduleって型がわからないといっているように思われます。このdes_key_scheduleがどこで定義されているか調べると、同じdigestmd5.cの68行目にdefineが切ってあるのを見つけました。こんなのです。

/* DES support */
#ifdef WITH_DES
# ifdef WITH_SSL_DES
#  include <openssl/des.h>
#  include <openssl/opensslv.h>
#  if (OPENSSL_VERSION_NUMBER >= 0x0090700f) && \
      !defined(OPENSSL_ENABLE_OLD_DES_SUPPORT)
#   define des_cblock DES_cblock
#   define des_key_schedule DES_key_schedule
#   define des_key_sched(k,ks) \
           DES_key_sched((k),&(ks))
#   define des_cbc_encrypt(i,o,l,k,iv,e) \
           DES_cbc_encrypt((i),(o),(l),&(k),(iv),(e))
#   define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
           DES_ede2_cbc_encrypt((i),(o),(l),&(k1),&(k2),(iv),(e))
#  endif /* OpenSSL 0.9.7+ w/o old DES support */
# else /* system DES library */


WITH_DESとWITH_SSL_DESがdefineされていると、定義されている部分が有効になるようになっています。コンパイル時にエラーが発生するdigestmd5.cの812行目は引用ソースからもわかるようにWITH_DESは定義されています。すると、WITH_SSL_DESが定義されているとうまくいくのかな?早速やってみます。

$ /usr/local/bin/make distclean
$ export CFLAGS='-DWITH_SSL_DES'
$ ./configure
(中略)
$ /usr/local/bin/make
(中略)
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I../include -I../lib -I../sasldb -I../include -Wall -W -DWITH_SSL_DES -MT digestmd5.lo -MD -MP -MF .deps/digestmd5.Tpo -c digestmd5.c  -fPIC -DPIC -o digestmd5.lo
digestmd5.c:63:27: error: openssl/des.h: No such file or directory
digestmd5.c:64:32: error: openssl/opensslv.h: No such file or directory
digestmd5.c:279: warning: pointer targets in initialization differ in signedness
digestmd5.c: In function 'DigestCalcResponse':
digestmd5.c:366: warning: pointer targets in passing argument 2 of 'utils->MD5Update' differ in signedness
digestmd5.c: At top level:
digestmd5.c:812: error: expected specifier-qualifier-list before 'des_key_schedule'

openssl/des.hとopenssl/opensslv.hへのパスが見えていないようです。これもCFLAGSで定義してあげます。

$ /usr/local/bin/make distclean
$ export CFLAGS='-DWITH_SSL_DES -I/usr/local/ssl/include'
$ ./configure
(中略)
$ /usr/local/bin/make
(中略)
gcc  -DWITH_SSL_DES -I/usr/local/ssl/include   -o testsaslauthd  testsaslauthd.o utils.o -lresolv -lsocket -lnsl  -lresolv -lresolv  -lsocket
make[3]: Leaving directory `/export/home2/hoge/cyrus-sasl/cyrus-sasl-2.1.22/saslauthd'
make[2]: Leaving directory `/export/home2/hoge/cyrus-sasl/cyrus-sasl-2.1.22/saslauthd'
make[2]: Entering directory `/export/home2/hoge/cyrus-sasl/cyrus-sasl-2.1.22'
make[2]: Leaving directory `/export/home2/hoge/cyrus-sasl/cyrus-sasl-2.1.22'
make[1]: Leaving directory `/export/home2/hoge/cyrus-sasl/cyrus-sasl-2.1.22'
$

めでたくmake出来ました。make installも実施。

# /usr/local/bin/make install
(中略)
make[1]: Leaving directory `/export/home2/hoge/cyrus-sasl/cyrus-sasl-2.1.22/saslauthd'
make[1]: Entering directory `/export/home2/hoge/cyrus-sasl/cyrus-sasl-2.1.22'
make[2]: Entering directory `/export/home2/hoge/cyrus-sasl/cyrus-sasl-2.1.22'
********************************************************
* WARNING:
* Plugins are being installed into /usr/local/lib/sasl2,
* but the library will look for them in /usr/lib/sasl2.
* You need to make sure that the plugins will eventually
* be in /usr/lib/sasl2 -- the easiest way is to make a
* symbolic link from /usr/lib/sasl2 to /usr/local/lib/sasl2,
* but this may not be appropriate for your site, so this
* installation procedure won't do it for you.
*
* If you don't want to do this for some reason, you can
* set the location where the library will look for plugins
* by setting the environment variable SASL_PATH to the path
* the library should use.
********************************************************
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/export/home2/hoge/cyrus-sasl/cyrus-sasl-2.1.22'
make[1]: Leaving directory `/export/home2/hoge/cyrus-sasl/cyrus-sasl-2.1.22'
#
||<