rse 98/09/19 05:12:36
Modified: src CHANGES
src/modules/standard mod_auth_db.module mod_auth_db.c
Log:
Add support for Berkeley-DB/2.x (in addition to Berkeley-DB/1.x) to
mod_auth_db to both be friendly to users who wants to use this version
and to avoid problems under platforms where only version 2.x is present.
Submitted by: Dan Jacobowitz <[EMAIL PROTECTED]>
Enhanced by: Ralf S. Engelschall
Revision Changes Path
1.1069 +5 -0 apache-1.3/src/CHANGES
Index: CHANGES
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v
retrieving revision 1.1068
retrieving revision 1.1069
diff -u -r1.1068 -r1.1069
--- CHANGES 1998/09/18 04:29:06 1.1068
+++ CHANGES 1998/09/19 12:12:34 1.1069
@@ -1,5 +1,10 @@
Changes with Apache 1.3.2
+ *) Add support for Berkeley-DB/2.x (in addition to Berkeley-DB/1.x) to
+ mod_auth_db to both be friendly to users who wants to use this version
+ and to avoid problems under platforms where only version 2.x is present.
+ [Dan Jacobowitz <[EMAIL PROTECTED]>, Ralf S. Engelschall]
+
*) When using ap_log_rerror(), make the error message available to the
*ERROR_NOTES envariables by default. [Ken Coar]
1.6 +31 -15 apache-1.3/src/modules/standard/mod_auth_db.module
Index: mod_auth_db.module
===================================================================
RCS file:
/export/home/cvs/apache-1.3/src/modules/standard/mod_auth_db.module,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- mod_auth_db.module 1998/03/05 12:42:32 1.5
+++ mod_auth_db.module 1998/09/19 12:12:35 1.6
@@ -1,20 +1,36 @@
Name: db_auth_module
ConfigStart
- if ./helpers/TestCompile func dbopen; then
- :
+ DB_VERSION=''
+ DB_LIB=''
+ if ./helpers/TestCompile func db_open; then
+ DB_VERSION='Berkeley-DB/2.x'
else
- case "$PLAT" in
- *-linux*)
- # many systems have -ldb installed
- DB_LIB=""
- if ./helpers/TestCompile lib db dbopen; then
- DB_LIB="-ldb"
- fi
- ;;
- esac
- LIBS="$LIBS $DB_LIB"
- if [ "X$DB_LIB" != "X" ]; then
- echo " + using $DB_LIB for mod_auth_db"
- fi
+ if ./helpers/TestCompile lib db db_open; then
+ DB_VERSION='Berkeley-DB/2.x'
+ DB_LIB='-ldb'
+ else
+ if ./helpers/TestCompile func dbopen; then
+ DB_VERSION='Berkeley-DB/1.x'
+ else
+ if ./helpers/TestCompile lib db dbopen; then
+ DB_VERSION='Berkeley-DB/1.x'
+ DB_LIB='-ldb'
+ fi
+ fi
+ fi
+ fi
+ if [ ".$DB_VERSION" != . ]; then
+ if [ ".$DB_LIB" != . ]; then
+ LIBS="$LIBS $DB_LIB"
+ echo " using $DB_VERSION for mod_auth_db ($DB_LIB)"
+ else
+ echo " using $DB_VERSION for mod_auth_db (-lc)"
+ fi
+ else
+ echo "Error: Neither Berkeley-DB/1.x nor Berkeley-DB/2.x library
found."
+ echo " Either disable mod_auth_db or provide us with the paths"
+ echo " to the Berkeley-DB include and library files."
+ echo " (Hint: INCLUDES, LDFLAGS, LIBS)"
+ exit 1
fi
ConfigEnd
1.33 +16 -0 apache-1.3/src/modules/standard/mod_auth_db.c
Index: mod_auth_db.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_auth_db.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- mod_auth_db.c 1998/08/06 17:30:55 1.32
+++ mod_auth_db.c 1998/09/19 12:12:36 1.33
@@ -97,6 +97,10 @@
#include "http_protocol.h"
#include <db.h>
+#if defined(DB_VERSION_MAJOR) && (DB_VERSION_MAJOR == 2)
+#define DB2
+#endif
+
typedef struct {
char *auth_dbpwfile;
@@ -154,19 +158,31 @@
q.data = user;
q.size = strlen(q.data);
+#ifdef DB2
+ if (db_open(auth_dbpwfile, DB_HASH, O_RDONLY, 0664, NULL, NULL, &f) !=
0) {
+#else
if (!(f = dbopen(auth_dbpwfile, O_RDONLY, 0664, DB_HASH, NULL))) {
+#endif
ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
"could not open db auth file: %s", auth_dbpwfile);
return NULL;
}
+#ifdef DB2
+ if (!((f->get) (f, NULL, &q, &d, 0))) {
+#else
if (!((f->get) (f, &q, &d, 0))) {
+#endif
pw = ap_palloc(r->pool, d.size + 1);
strncpy(pw, d.data, d.size);
pw[d.size] = '\0'; /* Terminate the string */
}
+#ifdef DB2
+ (f->close) (f, 0);
+#else
(f->close) (f);
+#endif
return pw;
}