httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin Erenkrantz <jerenkra...@ebuilt.com>
Subject [PATCH] Make mod_auth_dbm only use APR-util's dbm
Date Mon, 07 Jan 2002 18:25:39 GMT
I think this is the way to go.  apr-util is going to snarf in any
DB libraries it can find and provide a portable way to access them.
The only thing we can do in mod_auth_dbm is shoot ourselves in the
foot by attempting to conflict.  Therefore, I see no reason to keep
this cruft.

And on a related note, anyone else want to remove mod_auth_db?  If
I don't hear any screams, I'll toss it under the lazy consensus
model.  =)  (There's been a note in STATUS about removing it for a 
long time...)  -- justin

Index: modules/aaa/config.m4
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/aaa/config.m4,v
retrieving revision 1.51
diff -u -r1.51 config.m4
--- modules/aaa/config.m4	16 Oct 2001 21:32:40 -0000	1.51
+++ modules/aaa/config.m4	7 Jan 2002 18:18:55 -0000
@@ -7,23 +7,7 @@
 APACHE_MODULE(access, host-based access control, , , yes)
 APACHE_MODULE(auth, user-based access control, , , yes)
 APACHE_MODULE(auth_anon, anonymous user access, , , most)
-APACHE_MODULE(auth_dbm, DBM-based access databases, , , most, [
-  AC_SEARCH_LIBS(dbm_open,[c db1],,enable_auth_dbm=no)
-  dnl Glibc 2.1's ndbm.h includes <db.h> in ndbm.h.  So, we need to find
-  dnl where db.h lives.  (glibc 2.2 includes <db1/db.h>.)
-  AC_TRY_COMPILE([#include "ndbm.h"], [dbm_open("/dev/null", 0, 0)],
-                 ap_good_db_path="yes", ap_good_db_path="no")
-  if test "$ap_good_db_path" = "no"; then
-    ap_old_cppflags=$CPPFLAGS
-    CPPFLAGS="$CPPFLAGS -I/usr/include/db1"
-    AC_TRY_COMPILE([#include "ndbm.h"], [dbm_open("/dev/null", 0, 0)],
-                 ap_good_db_path="yes", ap_good_db_path="no")
-    if test "$ap_good_db_path" = "no"; then
-      CPPFLAGS=$ap_old_cppflags
-      enable_auth_dbm=no
-    fi
-  fi
-])
+APACHE_MODULE(auth_dbm, DBM-based access databases, , , most)
 
 APACHE_MODULE(auth_db, DB-based access databases, , , , [
   AC_CHECK_HEADERS(db.h,,enable_auth_db=no)
Index: modules/aaa/mod_auth_dbm.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/aaa/mod_auth_dbm.c,v
retrieving revision 1.41
diff -u -r1.41 mod_auth_dbm.c
--- modules/aaa/mod_auth_dbm.c	7 Jan 2002 18:10:54 -0000	1.41
+++ modules/aaa/mod_auth_dbm.c	7 Jan 2002 18:18:55 -0000
@@ -75,16 +75,7 @@
 #define APR_WANT_STRFUNC
 #include "apr_want.h"
 #include "apr_strings.h"
-
-#if defined(AP_AUTH_DBM_USE_APR)
 #include "apr_dbm.h"
-#define DBM apr_dbm_t
-#define datum apr_datum_t
-
-#define dbm_close apr_dbm_close
-#else
-#include <ndbm.h>
-#endif
 
 #include "httpd.h"
 #include "http_config.h"
@@ -160,14 +151,12 @@
 static char *get_dbm_pw(request_rec *r, 
                         char *user, 
                         char *auth_dbmpwfile, 
-                        char*dbtype)
+                        char *dbtype)
 {
-    DBM *f;
-    datum d, q;
+    apr_dbm_t *f;
+    apr_datum_t d, q;
     char *pw = NULL;
-#ifdef AP_AUTH_DBM_USE_APR
     apr_status_t retval;
-#endif
     q.dptr = user;
 #ifndef NETSCAPE_DBM_COMPAT
     q.dsize = strlen(q.dptr);
@@ -175,37 +164,21 @@
     q.dsize = strlen(q.dptr) + 1;
 #endif
 
-#ifdef AP_AUTH_DBM_USE_APR
-    retval  = apr_dbm_open_ex(&f, dbtype, auth_dbmpwfile, APR_DBM_READONLY, 
-                              APR_OS_DEFAULT, r->pool);
+    retval = apr_dbm_open_ex(&f, dbtype, auth_dbmpwfile, APR_DBM_READONLY, 
+                             APR_OS_DEFAULT, r->pool);
     if (retval != APR_SUCCESS) {
         ap_log_rerror(APLOG_MARK, APLOG_ERR, retval, r,
                       "could not open dbm (type %s) auth file: %s", dbtype, 
                       auth_dbmpwfile);
         return NULL;
     }
-    if (apr_dbm_fetch(f, q, &d) == APR_SUCCESS)
-        /* sorry for the obscurity ... falls through to the 
-         * if (d.dptr) {  block ...
-         */
-
-#else
-    if (!(f = dbm_open(auth_dbmpwfile, O_RDONLY, 0664))) {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
-            "could not open dbm auth file: %s", auth_dbmpwfile);
-        return NULL;
-    }
-    d = dbm_fetch(f, q);
-
-#endif
-
-    if (d.dptr) {
+    if (apr_dbm_fetch(f, q, &d) == APR_SUCCESS && d.dptr) {
         pw = apr_palloc(r->pool, d.dsize + 1);
         strncpy(pw, d.dptr, d.dsize);
         pw[d.dsize] = '\0'; /* Terminate the string */
     }
 
-    dbm_close(f);
+    apr_dbm_close(f);
     return pw;
 }
 


Mime
View raw message