diff --git a/acconfig.h b/acconfig.h index 4ef0398be..9dabe370e 100644 --- a/acconfig.h +++ b/acconfig.h @@ -48,14 +48,6 @@ static /**/const char *const rcsid[] = { (const char *)rcsid, "\100(#)" msg } #define SGTTY #endif -/* - * Define NDBM if you are using the 4.3 ndbm library (which is part of - * libc). If not defined, 4.2 dbm will be assumed. - */ -#if defined(HAVE_DBM_FIRSTKEY) -#define NDBM -#endif - /* telnet stuff ----------------------------------------------- */ #if defined(ENCRYPTION) && !defined(AUTHENTICATION) diff --git a/appl/ftp/ftpd/Makefile.am b/appl/ftp/ftpd/Makefile.am index b7443754d..2b75834a0 100644 --- a/appl/ftp/ftpd/Makefile.am +++ b/appl/ftp/ftpd/Makefile.am @@ -52,5 +52,4 @@ LDADD = ../common/libcommon.a \ $(LIB_krb5) \ $(LIB_krb4) \ $(LIB_des) \ - $(LIB_roken) \ - $(DBLIB) + $(LIB_roken) diff --git a/appl/otp/Makefile.am b/appl/otp/Makefile.am index 7d65962f8..88fa65831 100644 --- a/appl/otp/Makefile.am +++ b/appl/otp/Makefile.am @@ -10,7 +10,4 @@ otpprint_SOURCES = otpprint.c otp_locl.h man_MANS = otp.1 otpprint.1 LDADD = \ - $(top_builddir)/lib/otp/libotp.la \ - $(LIB_des) \ - $(LIB_roken) \ - $(DBLIB) + $(top_builddir)/lib/otp/libotp.la diff --git a/cf/db.m4 b/cf/db.m4 index f5e9cd0e4..0de703cb8 100644 --- a/cf/db.m4 +++ b/cf/db.m4 @@ -9,32 +9,140 @@ if test "$withval" = no; then berkeley_db="" fi ]) + +db_type=unknown + if test "$berkeley_db"; then + AC_CHECK_HEADERS([ \ db.h \ db_185.h \ ]) -fi -AC_FIND_FUNC_NO_LIBS2(dbopen, $berkeley_db, [ -#include -#if defined(HAVE_DB_185_H) -#include -#elif defined(HAVE_DB_H) -#include -#endif -],[NULL, 0, 0, 0, NULL]) +dnl db_create is used by db3 -AC_FIND_FUNC_NO_LIBS(dbm_firstkey, $berkeley_db gdbm ndbm) -AC_FIND_FUNC_NO_LIBS(db_create, $berkeley_db) + AC_FIND_FUNC_NO_LIBS(db_create, $berkeley_db, [ + #include + #include + ],[NULL, NULL, 0]) -DBLIB="$LIB_dbopen" -if test "$LIB_dbopen" != "$LIB_db_create"; then - DBLIB="$DBLIB $LIB_db_create" -fi -if test "$LIB_dbopen" != "$LIB_dbm_firstkey"; then - DBLIB="$DBLIB $LIB_dbm_firstkey" -fi + if test "$ac_cv_func_db_create" = "yes"; then + db_type=db3 + if test "$ac_cv_funclib_db_create" != "yes"; then + DBLIB="$ac_cv_funclib_db_create" + else + DBLIB="" + fi + AC_DEFINE(HAVE_DB3, 1, [define if you have a berkeley db3 library]) + else + +dnl dbopen is used by db1/db2 + + AC_FIND_FUNC_NO_LIBS(dbopen, $berkeley_db, [ + #include + #if defined(HAVE_DB_185_H) + #include + #elif defined(HAVE_DB_H) + #include + #else + #error no db.h + #endif + ],[NULL, 0, 0, 0, NULL]) + + if test "$ac_cv_func_dbopen" = "yes"; then + db_type=db1 + if test "$ac_cv_funclib_dbopen" != "yes"; then + DBLIB="$ac_cv_funclib_dbopen" + else + DBLIB="" + fi + AC_DEFINE(HAVE_DB1, 1, [define if you have a berkeley db1/2 library]) + fi + fi + +dnl test for ndbm compatability + + AC_FIND_FUNC_NO_LIBS2(dbm_firstkey, $ac_cv_funclib_dbopen, [ + #include + #define DB_DBM_HSEARCH 1 + #include + DBM *dbm; + ],[NULL]) + + if test "$ac_cv_func_dbm_firstkey" = "yes"; then + if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then + LIB_NDBM="$ac_cv_funclib_dbm_firstkey" + else + LIB_NDBM="" + fi + AC_DEFINE(HAVE_DB_NDBM, 1, [define if you have ndbm compat in db]) + else + $as_unset ac_cv_func_dbm_firstkey + $as_unset ac_cv_funclib_dbm_firstkey + fi + +fi # berkeley db + +if test "$db_type" = "unknown" -o "$ac_cv_func_dbm_firstkey" = ""; then + + AC_CHECK_HEADERS([ \ + dbm.h \ + ndbm.h \ + ]) + + AC_FIND_FUNC_NO_LIBS(dbm_firstkey, ndbm, [ + #include + #if defined(HAVE_DBM_H) + #include + #elif defined(HAVE_NDBM_H) + #include + #else + #error no ndbm.h + #endif + DBM *dbm; + ],[NULL]) + + if test "$ac_cv_func_dbm_firstkey" = "yes"; then + if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then + LIB_NDBM="$ac_cv_funclib_dbm_firstkey" + else + LIB_NDBM="" + fi + AC_DEFINE(HAVE_NDBM, 1, [define if you have a ndbm library])dnl + if test "$db_type" = "unknown"; then + db_type=ndbm + DBLIB="$LIB_NDBM" + fi + else + + $as_unset ac_cv_func_dbm_firstkey + $as_unset ac_cv_funclib_dbm_firstkey + + AC_CHECK_HEADERS([ \ + gdbm/ndbm.h \ + ]) + + AC_FIND_FUNC_NO_LIBS(dbm_firstkey, gdbm, [ + #include + #include + DBM *dbm; + ],[NULL]) + + if test "$ac_cv_func_dbm_firstkey" = "yes"; then + if test "$ac_cv_funclib_dbm_firstkey" != "yes"; then + LIB_NDBM="$ac_cv_funclib_dbm_firstkey" + else + LIB_NDBM="" + fi + AC_DEFINE(HAVE_NDBM, 1, [define if you have a ndbm library])dnl + if test "$db_type" = "unknown"; then + db_type=ndbm + DBLIB="$LIB_NDBM" + fi + fi + fi + +fi # unknown AC_SUBST(DBLIB)dnl - +AC_SUBST(LIB_NDBM)dnl ]) diff --git a/configure.in b/configure.in index bf0956c7e..da0e6c504 100644 --- a/configure.in +++ b/configure.in @@ -251,20 +251,17 @@ AC_CHECK_HEADERS([\ bsdsetjmp.h \ crypt.h \ curses.h \ - dbm.h \ dirent.h \ dlfcn.h \ err.h \ errno.h \ fcntl.h \ fnmatch.h \ - gdbm/ndbm.h \ grp.h \ inttypes.h \ io.h \ limits.h \ maillock.h \ - ndbm.h \ net/if.h \ netdb.h \ netinet/in.h \ @@ -279,7 +276,6 @@ AC_CHECK_HEADERS([\ pty.h \ pwd.h \ resolv.h \ - rpcsvc/dbm.h \ sac.h \ security/pam_modules.h \ sgtty.h \ diff --git a/lib/hdb/db.c b/lib/hdb/db.c index c4ac81d19..f5643b7ed 100644 --- a/lib/hdb/db.c +++ b/lib/hdb/db.c @@ -35,7 +35,13 @@ RCSID("$Id$"); -#if defined(HAVE_DB_H) && DB_VERSION_MAJOR < 3 +#if HAVE_DB1 + +#if defined(HAVE_DB_185_H) +#include +#elif defined(HAVE_DB_H) +#include +#endif static krb5_error_code DB_close(krb5_context context, HDB *db) @@ -290,4 +296,4 @@ hdb_db_create(krb5_context context, HDB **db, return 0; } -#endif +#endif /* HAVE_DB1 */ diff --git a/lib/hdb/db3.c b/lib/hdb/db3.c index 9a084b014..7d62181c6 100644 --- a/lib/hdb/db3.c +++ b/lib/hdb/db3.c @@ -35,7 +35,10 @@ RCSID("$Id$"); -#if defined(HAVE_DB_H) && DB_VERSION_MAJOR == 3 +#if HAVE_DB3 + +#include + static krb5_error_code DB_close(krb5_context context, HDB *db) { @@ -322,4 +325,4 @@ hdb_db_create(krb5_context context, HDB **db, (*db)->destroy = DB_destroy; return 0; } -#endif +#endif /* HAVE_DB3 */ diff --git a/lib/hdb/hdb.c b/lib/hdb/hdb.c index f8dddcc05..890fd4c1a 100644 --- a/lib/hdb/hdb.c +++ b/lib/hdb/hdb.c @@ -41,18 +41,18 @@ struct hdb_method { }; static struct hdb_method methods[] = { -#ifdef HAVE_DB_H +#if HAVE_DB1 || HAVE_DB3 {"db:", hdb_db_create}, #endif -#if defined(HAVE_NDBM_H) || defined(HAVE_GDBM_NDBM_H) +#if HAVE_NDBM {"ndbm:", hdb_ndbm_create}, #endif #ifdef OPENLDAP {"ldap:", hdb_ldap_create}, #endif -#ifdef HAVE_DB_H +#if HAVE_DB1 || HAVE_DB3 {"", hdb_db_create}, -#elif defined(HAVE_NDBM_H) +#elif defined(HAVE_NDBM) {"", hdb_ndbm_create}, #elif defined(OPENLDAP) {"", hdb_ldap_create}, diff --git a/lib/hdb/hdb_locl.h b/lib/hdb/hdb_locl.h index e7aaee439..61e43ceff 100644 --- a/lib/hdb/hdb_locl.h +++ b/lib/hdb/hdb_locl.h @@ -65,16 +65,4 @@ #include #include -#if defined(HAVE_DB_185_H) -#include -#elif defined(HAVE_DB_H) -#include -#endif - -#if defined(HAVE_NDBM_H) -#include -#elif defined(HAVE_GDBM_NDBM_H) -#include -#endif - #endif /* __HDB_LOCL_H__ */ diff --git a/lib/hdb/ndbm.c b/lib/hdb/ndbm.c index a86009af8..c3660d222 100644 --- a/lib/hdb/ndbm.c +++ b/lib/hdb/ndbm.c @@ -35,7 +35,15 @@ RCSID("$Id$"); -#if defined(HAVE_NDBM_H) || defined(HAVE_GDBM_NDBM_H) +#if HAVE_NDBM + +#if defined(HAVE_GDBM_NDBM_H) +#include +#elif defined(HAVE_DBM_H) +#include +#elif defined(HAVE_NDBM_H) +#include +#endif struct ndbm_db { DBM *db; @@ -350,4 +358,4 @@ hdb_ndbm_create(krb5_context context, HDB **db, return 0; } -#endif +#endif /* HAVE_NDBM */ diff --git a/lib/otp/Makefile.am b/lib/otp/Makefile.am index ac6b745fe..11a780719 100644 --- a/lib/otp/Makefile.am +++ b/lib/otp/Makefile.am @@ -6,16 +6,15 @@ INCLUDES += $(INCLUDE_krb4) noinst_PROGRAMS = otptest -otptest_LDADD = libotp.la \ - $(LIB_des) \ - $(LIB_roken) \ - $(DBLIB) +check_PROGRAMS = otptest + +otptest_LDADD = libotp.la include_HEADERS = otp.h lib_LTLIBRARIES = libotp.la libotp_la_LDFLAGS = -version-info 1:2:1 -libotp_la_LIBADD = $(LIB_des) ../roken/libroken.la +libotp_la_LIBADD = $(LIB_des) $(LIB_roken) $(LIB_NDBM) libotp_la_SOURCES = \ otp.c \ diff --git a/lib/roken/xdbm.h b/lib/roken/xdbm.h index 31c3e36c2..1e50e4de9 100644 --- a/lib/roken/xdbm.h +++ b/lib/roken/xdbm.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -38,23 +38,20 @@ #ifndef __XDBM_H__ #define __XDBM_H__ -#if defined(HAVE_DB_H) +#if HAVE_DB_NDBM #define DB_DBM_HSEARCH 1 #include -#endif - -#ifndef DBM_INSERT -#if defined(HAVE_NDBM_H) -#include -#elif defined(HAVE_GDBM_NDBM_H) +#elif HAVE_NDBM +#if defined(HAVE_GDBM_NDBM_H) #include #elif defined(HAVE_DBM_H) #include -#elif defined(HAVE_RPCSVC_DBM_H) -#include -#endif +#elif defined(HAVE_NDBM_H) +#include #endif +#endif /* HAVE_NDBM */ +#if 0 /* Macros to convert ndbm names to dbm names. * Note that dbm_nextkey() cannot be simply converted using a macro, since * it is invoked giving the database, and nextkey() needs the previous key. @@ -75,5 +72,6 @@ typedef char DBM; #else #define dbm_next(db,key) dbm_nextkey(db) #endif +#endif #endif /* __XDBM_H__ */