From 4e842d60f1384c44325b705bcab7914c6000440a Mon Sep 17 00:00:00 2001 From: "William A. Rowe Jr" Date: Fri, 8 Dec 2000 18:27:53 +0000 Subject: [PATCH] The feature macro may appear a bit odd. I'm open to any better suggest. Define AP_AUTH_DBM_USE_APR for apr dbm access, and apply the symbol to the win32 build. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87265 13f79535-47bb-0310-9956-ffa450edef68 --- modules/aaa/mod_auth_dbm.c | 31 +++++++++++++++++++------------ modules/aaa/mod_auth_dbm.dsp | 4 ++-- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/modules/aaa/mod_auth_dbm.c b/modules/aaa/mod_auth_dbm.c index c00cc699a8..faf2eff8f4 100644 --- a/modules/aaa/mod_auth_dbm.c +++ b/modules/aaa/mod_auth_dbm.c @@ -77,13 +77,13 @@ #include "http_protocol.h" #include "http_request.h" /* for ap_hook_(check_user_id | auth_checker)*/ -#if defined(WIN32) /* XXX: A better feature test is needed here */ -#include "sdbm.h" -#define DBM SDBM -#define datum sdbm_datum -#define dbm_open sdbm_open -#define dbm_fetch sdbm_fetch -#define dbm_close sdbm_close +#if defined(AP_AUTH_DBM_USE_APR) +#include "apr_dbm.h" +#define DBM apr_dbm_t +#define datum apr_datum_t +#define dbm_open apr_dbm_open +#define dbm_fetch apr_dbm_fetch +#define dbm_close apr_dbm_close #elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) \ && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 #include @@ -160,7 +160,7 @@ static char *get_dbm_pw(request_rec *r, char *user, char *auth_dbmpwfile) DBM *f; datum d, q; char *pw = NULL; -#ifdef WIN32 /* this is only used on Windows, so only define it on Windows */ +#ifdef AP_AUTH_DBM_USE_APR apr_status_t retval; #endif q.dptr = user; @@ -170,20 +170,27 @@ static char *get_dbm_pw(request_rec *r, char *user, char *auth_dbmpwfile) q.dsize = strlen(q.dptr) + 1; #endif -#ifdef WIN32 /* XXX: Same bad symbol here - need feature macro */ - if (!(retval = dbm_open(&f, auth_dbmpwfile, O_RDONLY, 0664, r->pool))) { +#ifdef AP_AUTH_DBM_USE_APR + if (!(retval = dbm_open(&f, auth_dbmpwfile, APR_DBM_READONLY, r->pool))) { ap_log_rerror(APLOG_MARK, APLOG_ERR, retval, r, "could not open sdbm auth file: %s", auth_dbmpwfile); + return NULL; + } + if (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); -#endif return NULL; } - d = dbm_fetch(f, q); +#endif + if (d.dptr) { pw = apr_palloc(r->pool, d.dsize + 1); strncpy(pw, d.dptr, d.dsize); diff --git a/modules/aaa/mod_auth_dbm.dsp b/modules/aaa/mod_auth_dbm.dsp index 89fec9a039..498115e902 100644 --- a/modules/aaa/mod_auth_dbm.dsp +++ b/modules/aaa/mod_auth_dbm.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /I "..\..\srclib\apr\include" /I "../../srclib/apr-util/include" /I "..\..\srclib\sdbm" /I "..\..\os\win32" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /I "..\..\srclib\apr\include" /I "../../srclib/apr-util/include" /I "..\..\srclib\sdbm" /I "..\..\os\win32" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "AP_AUTH_DBM_USE_APR" /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "NDEBUG" @@ -69,7 +69,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\include" /I "..\..\srclib\apr\include" /I "../../srclib/apr-util/include" /I "..\..\srclib\sdbm" /I "..\..\os\win32" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\include" /I "..\..\srclib\apr\include" /I "../../srclib/apr-util/include" /I "..\..\srclib\sdbm" /I "..\..\os\win32" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "AP_AUTH_DBM_USE_APR" /FD /c # ADD BASE MTL /nologo /D "_DEBUG" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x809 /d "_DEBUG" -- 2.40.0