INN commit: trunk (5 files)

INN Commit rra at isc.org
Tue Aug 6 21:31:04 UTC 2013


    Date: Tuesday, August 6, 2013 @ 14:31:03
  Author: iulius
Revision: 9525

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:
  trunk/authprogs/ckpasswd.c
  trunk/configure.ac
  trunk/doc/pod/ckpasswd.pod
  trunk/doc/pod/news.pod
  trunk/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-01 20:10:57 UTC (rev 9524)
+++ authprogs/ckpasswd.c	2013-08-06 21:31:03 UTC (rev 9525)
@@ -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-01 20:10:57 UTC (rev 9524)
+++ configure.ac	2013-08-06 21:31:03 UTC (rev 9525)
@@ -333,15 +333,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"$HAVE_BDB_NDBM" = x ; 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-01 20:10:57 UTC (rev 9524)
+++ doc/pod/ckpasswd.pod	2013-08-06 21:31:03 UTC (rev 9525)
@@ -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-01 20:10:57 UTC (rev 9524)
+++ doc/pod/news.pod	2013-08-06 21:31:03 UTC (rev 9525)
@@ -181,9 +181,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-01 20:10:57 UTC (rev 9524)
+++ m4/berkeleydb.m4	2013-08-06 21:31:03 UTC (rev 9525)
@@ -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