INN commit: branches/2.5 (5 files)

INN Commit rra at isc.org
Sun Aug 25 13:50:55 UTC 2013


    Date: Sunday, August 25, 2013 @ 06:50:55
  Author: iulius
Revision: 9532

improve the detection of ndbm compatibility layer

When INN is configured with Berkeley DB support, ckpasswd tries to
use the ndbm compatibility layer provided by Berkeley DB even though
Berkeley DB was not built with ndbm support.
This patch fixes that, by detecting at configure time that Berkeley DB
really has its ndbm compatibility layer.

Also add support for gdbm libraries in ckpasswd.

Modified:
  branches/2.5/authprogs/ckpasswd.c
  branches/2.5/configure.ac
  branches/2.5/doc/pod/ckpasswd.pod
  branches/2.5/doc/pod/news.pod
  branches/2.5/m4/berkeleydb.m4

----------------------+
 authprogs/ckpasswd.c |    9 +++++----
 configure.ac         |   13 +++++++------
 doc/pod/ckpasswd.pod |   10 +++++-----
 doc/pod/news.pod     |    6 +++---
 m4/berkeleydb.m4     |   39 ++++++++++++++++++++++++++++++++++++++-
 5 files changed, 58 insertions(+), 19 deletions(-)

Modified: authprogs/ckpasswd.c
===================================================================
--- authprogs/ckpasswd.c	2013-08-25 13:13:57 UTC (rev 9531)
+++ authprogs/ckpasswd.c	2013-08-25 13:50:55 UTC (rev 9532)
@@ -21,6 +21,7 @@
 #if HAVE_CRYPT_H
 # include <crypt.h>
 #endif
+
 #include <fcntl.h>
 #include <pwd.h>
 #include <grp.h>
@@ -30,8 +31,8 @@
 **  If compiling with Berkeley DB, use its ndbm compatibility layer
 **  in preference to other libraries.
 */
-#if defined(HAVE_DBM) || defined(HAVE_BDB_DBM)
-# if HAVE_BDB_DBM
+#if defined(HAVE_DBM) || defined(HAVE_BDB_NDBM)
+# if HAVE_BDB_NDBM
 #  define DB_DBM_HSEARCH 1
 #  include <db.h>
 # elif HAVE_NDBM_H
@@ -153,7 +154,7 @@
 **  password, if found, is returned as a newly allocated string; otherwise,
 **  NULL is returned.
 */
-#if !(defined(HAVE_DBM) || defined(HAVE_BDB_DBM))
+#if !(defined(HAVE_DBM) || defined(HAVE_BDB_NDBM))
 static char *
 password_dbm(char *user UNUSED, const char *file UNUSED)
 {
@@ -182,7 +183,7 @@
     dbm_close(database);
     return password;
 }
-#endif /* HAVE_DBM || HAVE_BDB_DBM */
+#endif /* HAVE_DBM || HAVE_BDB_NDBM */
 
 
 /*

Modified: configure.ac
===================================================================
--- configure.ac	2013-08-25 13:13:57 UTC (rev 9531)
+++ configure.ac	2013-08-25 13:50:55 UTC (rev 9532)
@@ -355,15 +355,16 @@
 dnl The dbm libraries are a special case.  If we're building with Berkeley DB,
 dnl just use the ndbm support provided by it.
 if test x"$DB_LIBS" != x ; then
+    INN_LIB_BERKELEYDB_NDBM
+fi
+if test x"$inn_cv_lib_berkeleydb_ndbm_works" != xyes ; then
+    INN_SEARCH_AUX_LIBS([dbm_open], [ndbm dbm gdbm "gdbm_compat -lgdbm"], [DBM_LIBS],
+        [AC_DEFINE([HAVE_DBM], 1, [Define if you have a dbm library.])])
+    DBM_CPPFLAGS=
+else
     DBM_CPPFLAGS="$DB_CPPFLAGS"
     DBM_LIBS="$DB_LDFLAGS $DB_LIBS"
     AC_SUBST([DBM_LIBS])
-    AC_DEFINE([HAVE_BDB_DBM], 1,
-        [Define if the Berkeley DB dbm compatibility layer is available.])
-else
-    INN_SEARCH_AUX_LIBS([dbm_open], [ndbm dbm], [DBM_LIBS],
-        [AC_DEFINE([HAVE_DBM], 1, [Define if you have a dbm library.])])
-    DBM_CPPFLAGS=
 fi
 AC_SUBST([DBM_CPPFLAGS])
 

Modified: doc/pod/ckpasswd.pod
===================================================================
--- doc/pod/ckpasswd.pod	2013-08-25 13:13:57 UTC (rev 9531)
+++ doc/pod/ckpasswd.pod	2013-08-25 13:50:55 UTC (rev 9532)
@@ -41,10 +41,10 @@
 
 =item B<-d> I<database>
 
-Read passwords from a database (ndbm or dbm format depending on what your
-system has) rather than by using getpwnam(3).  B<ckpasswd> expects
-I<database>.dir and I<database>.pag to exist and to be a database keyed by
-username with the encrypted passwords as the values.
+Read passwords from a database (ndbm, gdbm or dbm format depending on
+what your system has) rather than by using getpwnam(3).  B<ckpasswd>
+expects I<database>.dir and I<database>.pag to exist and to be a database
+keyed by username with the encrypted passwords as the values.
 
 While INN doesn't come with a program intended specifically to create such
 databases, on most systems it's fairly easy to write a Perl script to do
@@ -72,7 +72,7 @@
 start.  Sometimes a program like this will be available with the name
 B<dbmpasswd>.
 
-This option will not be available on systems without dbm or ndbm
+This option will not be available on systems without ndbm, gdbm or dbm
 libraries.
 
 =item B<-f> I<filename>

Modified: doc/pod/news.pod
===================================================================
--- doc/pod/news.pod	2013-08-25 13:13:57 UTC (rev 9531)
+++ doc/pod/news.pod	2013-08-25 13:50:55 UTC (rev 9532)
@@ -52,9 +52,9 @@
 
 =item *
 
-If compiling with S<Berkeley DB>, use its ndbm compatibility layer for
-B<ckpasswd> in preference to the GNU dbm library that appears to be
-broken on a few systems.
+B<ckpasswd> no longer tries to use the ndbm compatibility layer provided
+by S<Berkeley DB> if S<Berkeley DB> has been built without ndbm support.
+Also add support for gdbm libraries in B<ckpasswd>.
 
 =item *
 

Modified: m4/berkeleydb.m4
===================================================================
--- m4/berkeleydb.m4	2013-08-25 13:13:57 UTC (rev 9531)
+++ m4/berkeleydb.m4	2013-08-25 13:50:55 UTC (rev 9532)
@@ -1,10 +1,14 @@
-dnl berkeleydb.m4 -- Find the path to the Berkeley DB libraries.
+dnl berkeleydb.m4 -- Various checks for the Berkeley DB libraries.
 dnl $Id$
 dnl
 dnl This file provides INN_LIB_BERKELEYDB, which defines the --with-berkeleydb
 dnl command-line option and probes for the location of Berkeley DB if that
 dnl option is used without an optional path.  It looks for Berkeley DB in $prefix,
 dnl /usr/local and /usr.  It then exports DB_LDFLAGS, DB_CPPFLAGS, and DB_LIBS.
+dnl
+dnl This file also provides INN_LIB_BERKELEYDB_NDBM, which checks whether
+dnl Berkeley DB has ndbm support.  It then defines HAVE_BDB_NDBM if ndbm
+dnl compatibility layer for Berkely DB is available.
 
 AC_DEFUN([INN_LIB_BERKELEYDB],
 [DB_CPPFLAGS=
@@ -43,3 +47,36 @@
 AC_SUBST([DB_CPPFLAGS])
 AC_SUBST([DB_LDFLAGS])
 AC_SUBST([DB_LIBS])])
+
+dnl Source used by INN_LIB_BERKELEYDB_NDBM.
+AC_DEFUN([_INN_LIB_BERKELEYDB_NDBM_SOURCE], [[
+#include <stdio.h>
+#define DB_DBM_HSEARCH 1
+#include <db.h>
+
+int
+main(void) {
+    DBM *database;
+    database = dbm_open("test", 0, 0600);
+    dbm_close(database);
+    return 0;
+}
+]])
+
+dnl Check whether Berkeley DB was compiled with ndbm compatibily layer.
+dnl If so, set HAVE_BDB_NDBM.
+AC_DEFUN([INN_LIB_BERKELEYDB_NDBM],
+[inn_save_LDFLAGS="$LDFLAGS"
+inn_save_CFLAGS="$CFLAGS"
+LDFLAGS="$LDFLAGS $DB_LDFLAGS $DB_LIBS"
+CFLAGS="$CFLAGS $DB_CPPFLAGS"
+AC_CACHE_CHECK([for working nbdm compatibility layer with Berkeley DB],
+    [inn_cv_lib_berkeleydb_ndbm_works],
+    [AC_LINK_IFELSE([AC_LANG_SOURCE([_INN_LIB_BERKELEYDB_NDBM_SOURCE])],
+        [inn_cv_lib_berkeleydb_ndbm_works=yes],
+        [inn_cv_lib_berkeleydb_ndbm_works=no])])
+AS_IF([test x"$inn_cv_lib_berkeleydb_ndbm_works" = xyes],
+    [AC_DEFINE([HAVE_BDB_NDBM], 1,
+        [Define if the Berkeley DB ndbm compatibility layer is available.])])
+LDFLAGS="$inn_save_LDFLAGS"
+CFLAGS="$inn_save_CFLAGS"])



More information about the inn-committers mailing list