]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Merge of 1891019,1891023 from trunk:
authorStefan Eissing <icing@apache.org>
Fri, 4 Mar 2022 09:30:28 +0000 (09:30 +0000)
committerStefan Eissing <icing@apache.org>
Fri, 4 Mar 2022 09:30:28 +0000 (09:30 +0000)
  *) dbm: Split the loading of a dbm driver from the opening of a dbm file. When
     an attempt to load a dbm driver fails, log clearly which driver triggered
     the error (not "default"), and what the error was.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1898590 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/aaa/mod_authn_dbm.c
modules/aaa/mod_authz_dbm.c
modules/cache/mod_cache_socache.c
modules/cache/mod_socache_dbm.c
modules/dav/fs/dbm.c
modules/dav/lock/locks.c
modules/mappers/mod_rewrite.c
modules/proxy/mod_proxy_express.c

diff --git a/CHANGES b/CHANGES
index b198da2457aae54bd6bcd283addea331a5b09d1b..d485d9470e18b7614c484750aa3c599253cf74e7 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,10 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.4.53
 
+  *) dbm: Split the loading of a dbm driver from the opening of a dbm file. When
+     an attempt to load a dbm driver fails, log clearly which driver triggered
+     the error (not "default"), and what the error was. [Graham Leggett]
+
   *) mod_proxy: Use the maxium of front end and backend timeouts instead of the
      minimum when tunneling requests (websockets, CONNECT requests).
      Backend timeouts can be configured more selectively (per worker if needed)
index 6eae9e052ab455d960fbf06d62d2a5423b5a731a..9f4735047340e1d98489990a4ef747af3ae45fcd 100644 (file)
 
 #include "mod_auth.h"
 
+#include "apr_version.h"
+#if !APR_VERSION_AT_LEAST(2,0,0)
+#include "apu_version.h"
+#endif
+
 static APR_OPTIONAL_FN_TYPE(ap_authn_cache_store) *authn_cache_store = NULL;
 #define AUTHN_CACHE_STORE(r,user,realm,data) \
     if (authn_cache_store != NULL) \
@@ -72,18 +77,39 @@ static const command_rec authn_dbm_cmds[] =
 
 module AP_MODULE_DECLARE_DATA authn_dbm_module;
 
-static apr_status_t fetch_dbm_value(const char *dbmtype, const char *dbmfile,
-                                    const char *user, char **value,
-                                    apr_pool_t *pool)
+static apr_status_t fetch_dbm_value(request_rec *r, const char *dbmtype,
+                                    const char *dbmfile,
+                                    const char *user, char **value)
 {
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+    const apr_dbm_driver_t *driver;
+    const apu_err_t *err;
+#endif
     apr_dbm_t *f;
     apr_datum_t key, val;
     apr_status_t rv;
 
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+    rv = apr_dbm_get_driver(&driver, dbmtype, &err, r->pool);
+
+    if (rv != APR_SUCCESS) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(10284)
+                "could not load '%s' dbm library: %s",
+                     err->reason, err->msg);
+        return rv;
+    }
+
+    rv = apr_dbm_open2(&f, driver, dbmfile, APR_DBM_READONLY,
+                         APR_OS_DEFAULT, r->pool);
+#else
     rv = apr_dbm_open_ex(&f, dbmtype, dbmfile, APR_DBM_READONLY,
-                         APR_OS_DEFAULT, pool);
+                         APR_OS_DEFAULT, r->pool);
+#endif
 
     if (rv != APR_SUCCESS) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(10285)
+                      "could not open dbm (type %s) file: %s",
+                      dbmtype, dbmfile);
         return rv;
     }
 
@@ -97,7 +123,7 @@ static apr_status_t fetch_dbm_value(const char *dbmtype, const char *dbmfile,
     *value = NULL;
 
     if (apr_dbm_fetch(f, key, &val) == APR_SUCCESS && val.dptr) {
-        *value = apr_pstrmemdup(pool, val.dptr, val.dsize);
+        *value = apr_pstrmemdup(r->pool, val.dptr, val.dsize);
     }
 
     apr_dbm_close(f);
@@ -118,13 +144,9 @@ static authn_status check_dbm_pw(request_rec *r, const char *user,
     char *dbm_password;
     char *colon_pw;
 
-    rv = fetch_dbm_value(conf->dbmtype, conf->pwfile, user, &dbm_password,
-                         r->pool);
+    rv = fetch_dbm_value(r, conf->dbmtype, conf->pwfile, user, &dbm_password);
 
     if (rv != APR_SUCCESS) {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01754)
-                      "could not open dbm (type %s) auth file: %s",
-                      conf->dbmtype, conf->pwfile);
         return AUTH_GENERAL_ERROR;
     }
 
@@ -156,14 +178,11 @@ static authn_status get_dbm_realm_hash(request_rec *r, const char *user,
     char *dbm_hash;
     char *colon_hash;
 
-    rv = fetch_dbm_value(conf->dbmtype, conf->pwfile,
+    rv = fetch_dbm_value(r, conf->dbmtype, conf->pwfile,
                          apr_pstrcat(r->pool, user, ":", realm, NULL),
-                         &dbm_hash, r->pool);
+                         &dbm_hash);
 
     if (rv != APR_SUCCESS) {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01755)
-                      "Could not open dbm (type %s) hash file: %s",
-                      conf->dbmtype, conf->pwfile);
         return AUTH_GENERAL_ERROR;
     }
 
index 843d9a8e43f9c6cf68714541afdc1a9cf6c78aaf..f11de6897e612834ec9ef9d1ce5e620fe10885e9 100644 (file)
 #include "apr_dbm.h"
 #include "apr_md5.h"
 
+#include "apr_version.h"
+#if !APR_VERSION_AT_LEAST(2,0,0)
+#include "apu_version.h"
+#endif
+
 #include "httpd.h"
 #include "http_config.h"
 #include "ap_provider.h"
@@ -96,14 +101,35 @@ static apr_status_t get_dbm_grp(request_rec *r, char *key1, char *key2,
                                 const char *dbmgrpfile, const char *dbtype,
                                 const char ** out)
 {
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+    const apr_dbm_driver_t *driver;
+    const apu_err_t *err;
+#endif
     char *grp_colon, *val;
     apr_status_t retval;
     apr_dbm_t *f;
 
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+    retval = apr_dbm_get_driver(&driver, dbtype, &err, r->pool);
+
+    if (retval != APR_SUCCESS) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, retval, r, APLOGNO(10286)
+                "could not load '%s' dbm library: %s",
+                     err->reason, err->msg);
+        return retval;
+    }
+
+    retval = apr_dbm_open2(&f, driver, dbmgrpfile, APR_DBM_READONLY,
+                             APR_OS_DEFAULT, r->pool);
+#else
     retval = apr_dbm_open_ex(&f, dbtype, dbmgrpfile, APR_DBM_READONLY,
                              APR_OS_DEFAULT, r->pool);
+#endif
 
     if (retval != APR_SUCCESS) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, retval, r, APLOGNO(01799)
+                      "could not open dbm (type %s) group access "
+                      "file: %s", dbtype, dbmgrpfile);
         return retval;
     }
 
@@ -166,9 +192,6 @@ static authz_status dbmgroup_check_authorization(request_rec *r,
                              user, conf->grpfile, conf->dbmtype, &groups);
 
         if (status != APR_SUCCESS) {
-            ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(01799)
-                          "could not open dbm (type %s) group access "
-                          "file: %s", conf->dbmtype, conf->grpfile);
             return AUTHZ_GENERAL_ERROR;
         }
 
@@ -241,9 +264,6 @@ static authz_status dbmfilegroup_check_authorization(request_rec *r,
                          user, conf->grpfile, conf->dbmtype, &groups);
 
     if (status != APR_SUCCESS) {
-        ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(01803)
-                      "could not open dbm (type %s) group access "
-                      "file: %s", conf->dbmtype, conf->grpfile);
         return AUTHZ_DENIED;
     }
 
index f369004a417c4df3ccbac60d62bf11f9bc2b32c5..5f9e1d6c66181459c5a6172633979aa6b3a642ed 100644 (file)
 #include "apr_file_io.h"
 #include "apr_strings.h"
 #include "apr_buckets.h"
+
+#include "apr_version.h"
+#if !APR_VERSION_AT_LEAST(2,0,0)
+#include "apu_version.h"
+#endif
+
 #include "httpd.h"
 #include "http_config.h"
 #include "http_log.h"
index 67246457cd9871c5808823018da323e3edd66bbc..df97573096bd9a6061aee7218f26cb32d2bd3979 100644 (file)
@@ -121,6 +121,10 @@ static apr_status_t socache_dbm_init(ap_socache_instance_t *ctx,
                                      const struct ap_socache_hints *hints,
                                      server_rec *s, apr_pool_t *p)
 {
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+    const apr_dbm_driver_t *driver;
+    const apu_err_t *err;
+#endif
     apr_dbm_t *dbm;
     apr_status_t rv;
 
@@ -142,6 +146,22 @@ static apr_status_t socache_dbm_init(ap_socache_instance_t *ctx,
     /* open it once to create it and to make sure it _can_ be created */
     apr_pool_clear(ctx->pool);
 
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+    if ((rv = apr_dbm_get_driver(&driver, NULL, &err,
+            ctx->pool) != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(10277)
+                "Cannot load socache DBM library '%s': %s",
+                     err->reason, err->msg);
+        return rv;
+    }
+    if ((rv = apr_dbm_open2(&dbm, driver, ctx->data_file,
+            APR_DBM_RWCREATE, DBM_FILE_MODE, ctx->pool)) != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00804)
+                     "Cannot create socache DBM file `%s'",
+                     ctx->data_file);
+        return DECLINED;
+    }
+#else
     if ((rv = apr_dbm_open(&dbm, ctx->data_file,
             APR_DBM_RWCREATE, DBM_FILE_MODE, ctx->pool)) != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00804)
@@ -149,6 +169,7 @@ static apr_status_t socache_dbm_init(ap_socache_instance_t *ctx,
                      ctx->data_file);
         return rv;
     }
+#endif
     apr_dbm_close(dbm);
 
     ctx->expiry_interval = (hints && hints->expiry_interval
@@ -193,6 +214,10 @@ static apr_status_t socache_dbm_store(ap_socache_instance_t *ctx,
                                       unsigned char *ucaData,
                                       unsigned int nData, apr_pool_t *pool)
 {
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+    const apr_dbm_driver_t *driver;
+    const apu_err_t *err;
+#endif
     apr_dbm_t *dbm;
     apr_datum_t dbmkey;
     apr_datum_t dbmval;
@@ -228,6 +253,25 @@ static apr_status_t socache_dbm_store(ap_socache_instance_t *ctx,
     /* and store it to the DBM file */
     apr_pool_clear(ctx->pool);
 
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+    if ((rv = apr_dbm_get_driver(&driver, NULL, &err,
+            ctx->pool) != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(10278)
+                "Cannot load socache DBM library '%s' (store): %s",
+                     err->reason, err->msg);
+        free(dbmval.dptr);
+        return rv;
+    }
+    if ((rv = apr_dbm_open2(&dbm, driver, ctx->data_file,
+            APR_DBM_RWCREATE, DBM_FILE_MODE, ctx->pool)) != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00807)
+                     "Cannot open socache DBM file `%s' for writing "
+                     "(store)",
+                     ctx->data_file);
+        free(dbmval.dptr);
+        return rv;
+    }
+#else
     if ((rv = apr_dbm_open(&dbm, ctx->data_file,
                            APR_DBM_RWCREATE, DBM_FILE_MODE, ctx->pool)) != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00807)
@@ -237,6 +281,7 @@ static apr_status_t socache_dbm_store(ap_socache_instance_t *ctx,
         free(dbmval.dptr);
         return rv;
     }
+#endif
     if ((rv = apr_dbm_store(dbm, dbmkey, dbmval)) != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00808)
                      "Cannot store socache object to DBM file `%s'",
@@ -261,6 +306,10 @@ static apr_status_t socache_dbm_retrieve(ap_socache_instance_t *ctx, server_rec
                                          unsigned char *dest, unsigned int *destlen,
                                          apr_pool_t *p)
 {
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+    const apr_dbm_driver_t *driver;
+    const apu_err_t *err;
+#endif
     apr_dbm_t *dbm;
     apr_datum_t dbmkey;
     apr_datum_t dbmval;
@@ -281,6 +330,23 @@ static apr_status_t socache_dbm_retrieve(ap_socache_instance_t *ctx, server_rec
      * do the apr_dbm_close? This would make the code a bit cleaner.
      */
     apr_pool_clear(ctx->pool);
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+    if ((rv = apr_dbm_get_driver(&driver, NULL, &err,
+            ctx->pool) != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(10279)
+                "Cannot load socache DBM library '%s' (fetch): %s",
+                     err->reason, err->msg);
+        return rc;
+    }
+    if ((rv = apr_dbm_open2(&dbm, driver, ctx->data_file,
+            APR_DBM_RWCREATE, DBM_FILE_MODE, ctx->pool)) != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, rc, s, APLOGNO(00809)
+                     "Cannot open socache DBM file `%s' for reading "
+                     "(fetch)",
+                     ctx->data_file);
+        return rc;
+    }
+#else
     if ((rc = apr_dbm_open(&dbm, ctx->data_file, APR_DBM_RWCREATE,
                            DBM_FILE_MODE, ctx->pool)) != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_ERR, rc, s, APLOGNO(00809)
@@ -289,6 +355,7 @@ static apr_status_t socache_dbm_retrieve(ap_socache_instance_t *ctx, server_rec
                      ctx->data_file);
         return rc;
     }
+#endif
     rc = apr_dbm_fetch(dbm, dbmkey, &dbmval);
     if (rc != APR_SUCCESS) {
         apr_dbm_close(dbm);
@@ -326,6 +393,10 @@ static apr_status_t socache_dbm_remove(ap_socache_instance_t *ctx,
                                        server_rec *s, const unsigned char *id,
                                        unsigned int idlen, apr_pool_t *p)
 {
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+    const apr_dbm_driver_t *driver;
+    const apu_err_t *err;
+#endif
     apr_dbm_t *dbm;
     apr_datum_t dbmkey;
     apr_status_t rv;
@@ -337,6 +408,23 @@ static apr_status_t socache_dbm_remove(ap_socache_instance_t *ctx,
     /* and delete it from the DBM file */
     apr_pool_clear(ctx->pool);
 
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+    if ((rv = apr_dbm_get_driver(&driver, NULL, &err,
+            ctx->pool) != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(10280)
+                "Cannot load socache DBM library '%s' (delete): %s",
+                     err->reason, err->msg);
+        return rv;
+    }
+    if ((rv = apr_dbm_open2(&dbm, driver, ctx->data_file,
+            APR_DBM_RWCREATE, DBM_FILE_MODE, ctx->pool)) != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00810)
+                     "Cannot open socache DBM file `%s' for writing "
+                     "(delete)",
+                     ctx->data_file);
+        return rv;
+    }
+#else
     if ((rv = apr_dbm_open(&dbm, ctx->data_file, APR_DBM_RWCREATE,
                            DBM_FILE_MODE, ctx->pool)) != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00810)
@@ -345,6 +433,7 @@ static apr_status_t socache_dbm_remove(ap_socache_instance_t *ctx,
                      ctx->data_file);
         return rv;
     }
+#endif
     apr_dbm_delete(dbm, dbmkey);
     apr_dbm_close(dbm);
 
@@ -353,6 +442,10 @@ static apr_status_t socache_dbm_remove(ap_socache_instance_t *ctx,
 
 static void socache_dbm_expire(ap_socache_instance_t *ctx, server_rec *s)
 {
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+    const apr_dbm_driver_t *driver;
+    const apu_err_t *err;
+#endif
     apr_dbm_t *dbm;
     apr_datum_t dbmkey;
     apr_datum_t dbmval;
@@ -378,6 +471,16 @@ static void socache_dbm_expire(ap_socache_instance_t *ctx, server_rec *s)
 
     ctx->last_expiry = now;
 
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+    if ((rv = apr_dbm_get_driver(&driver, NULL, &err,
+            ctx->pool) != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(10281)
+                "Cannot load socache DBM library '%s' (expire): %s",
+                     err->reason, err->msg);
+        return rv;
+    }
+#endif
+
     /*
      * Here we have to be very carefully: Not all DBM libraries are
      * smart enough to allow one to iterate over the elements and at the
@@ -401,6 +504,16 @@ static void socache_dbm_expire(ap_socache_instance_t *ctx, server_rec *s)
 
         /* pass 1: scan DBM database */
         keyidx = 0;
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+        if ((rv = apr_dbm_open2(&dbm, driver, ctx->data_file, APR_DBM_RWCREATE,
+                               DBM_FILE_MODE, ctx->pool)) != APR_SUCCESS) {
+            ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00811)
+                         "Cannot open socache DBM file `%s' for "
+                         "scanning",
+                         ctx->data_file);
+            break;
+        }
+#else
         if ((rv = apr_dbm_open(&dbm, ctx->data_file, APR_DBM_RWCREATE,
                                DBM_FILE_MODE, ctx->pool)) != APR_SUCCESS) {
             ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00811)
@@ -409,6 +522,7 @@ static void socache_dbm_expire(ap_socache_instance_t *ctx, server_rec *s)
                          ctx->data_file);
             break;
         }
+#endif
         apr_dbm_firstkey(dbm, &dbmkey);
         while (dbmkey.dptr != NULL) {
             elts++;
@@ -434,6 +548,16 @@ static void socache_dbm_expire(ap_socache_instance_t *ctx, server_rec *s)
         apr_dbm_close(dbm);
 
         /* pass 2: delete expired elements */
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+        if (apr_dbm_open2(&dbm, driver, ctx->data_file, APR_DBM_RWCREATE,
+                         DBM_FILE_MODE, ctx->pool) != APR_SUCCESS) {
+            ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00812)
+                         "Cannot re-open socache DBM file `%s' for "
+                         "expiring",
+                         ctx->data_file);
+            break;
+        }
+#else
         if (apr_dbm_open(&dbm, ctx->data_file, APR_DBM_RWCREATE,
                          DBM_FILE_MODE, ctx->pool) != APR_SUCCESS) {
             ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00812)
@@ -442,6 +566,7 @@ static void socache_dbm_expire(ap_socache_instance_t *ctx, server_rec *s)
                          ctx->data_file);
             break;
         }
+#endif
         for (i = 0; i < keyidx; i++) {
             apr_dbm_delete(dbm, keylist[i]);
             deleted++;
@@ -461,6 +586,10 @@ static void socache_dbm_expire(ap_socache_instance_t *ctx, server_rec *s)
 static void socache_dbm_status(ap_socache_instance_t *ctx, request_rec *r,
                                int flags)
 {
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+    const apr_dbm_driver_t *driver;
+    const apu_err_t *err;
+#endif
     apr_dbm_t *dbm;
     apr_datum_t dbmkey;
     apr_datum_t dbmval;
@@ -473,14 +602,32 @@ static void socache_dbm_status(ap_socache_instance_t *ctx, request_rec *r,
     size = 0;
 
     apr_pool_clear(ctx->pool);
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+    if ((rv = apr_dbm_get_driver(&driver, NULL, &err,
+            ctx->pool) != APR_SUCCESS) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(10282)
+                "Cannot load socache DBM library '%s' (status retrieval): %s",
+                     err->reason, err->msg);
+        return;
+    }
+    if ((rv = apr_dbm_open2(&dbm, driver, ctx->data_file, APR_DBM_RWCREATE,
+                           DBM_FILE_MODE, ctx->pool)) != APR_SUCCESS) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(00814)
+                     "Cannot open socache DBM file `%s' for status "
+                     "retrieval",
+                     ctx->data_file);
+        return;
+    }
+#else
     if ((rv = apr_dbm_open(&dbm, ctx->data_file, APR_DBM_RWCREATE,
                            DBM_FILE_MODE, ctx->pool)) != APR_SUCCESS) {
         ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(00814)
                      "Cannot open socache DBM file `%s' for status "
-                     "retrival",
+                     "retrieval",
                      ctx->data_file);
         return;
     }
+#endif
     /*
      * XXX - Check the return value of apr_dbm_firstkey, apr_dbm_fetch - TBD
      */
@@ -516,6 +663,10 @@ static apr_status_t socache_dbm_iterate(ap_socache_instance_t *ctx,
                                         ap_socache_iterator_t *iterator,
                                         apr_pool_t *pool)
 {
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+    const apr_dbm_driver_t *driver;
+    const apu_err_t *err;
+#endif
     apr_dbm_t *dbm;
     apr_datum_t dbmkey;
     apr_datum_t dbmval;
@@ -528,6 +679,22 @@ static apr_status_t socache_dbm_iterate(ap_socache_instance_t *ctx,
      * make sure the expired records are omitted
      */
     now = apr_time_now();
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+    if ((rv = apr_dbm_get_driver(&driver, NULL, &err,
+            ctx->pool) != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(10283)
+                "Cannot load socache DBM library '%s' (iterating): %s",
+                     err->reason, err->msg);
+        return rv;
+    }
+    if ((rv = apr_dbm_open2(&dbm, driver, ctx->data_file, APR_DBM_RWCREATE,
+                           DBM_FILE_MODE, ctx->pool)) != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00815)
+                     "Cannot open socache DBM file `%s' for "
+                     "iterating", ctx->data_file);
+        return rv;
+    }
+#else
     if ((rv = apr_dbm_open(&dbm, ctx->data_file, APR_DBM_RWCREATE,
                            DBM_FILE_MODE, ctx->pool)) != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00815)
@@ -535,6 +702,7 @@ static apr_status_t socache_dbm_iterate(ap_socache_instance_t *ctx,
                      "iterating", ctx->data_file);
         return rv;
     }
+#endif
     rv = apr_dbm_firstkey(dbm, &dbmkey);
     while (rv == APR_SUCCESS && dbmkey.dptr != NULL) {
         expired = FALSE;
index 0d12831f0215cbd06f3d71fe9226655cb70ef4d5..347d75d8c59661274faf314fdcf9990c3f14e430 100644 (file)
 #define APR_WANT_BYTEFUNC
 #include "apr_want.h"       /* for ntohs and htons */
 
+#include "apr_version.h"
+#if !APR_VERSION_AT_LEAST(2,0,0)
+#include "apu_version.h"
+#endif
+
 #include "mod_dav.h"
 #include "repos.h"
 #include "http_log.h"
@@ -127,11 +132,30 @@ void dav_fs_ensure_state_dir(apr_pool_t * p, const char *dirname)
 dav_error * dav_dbm_open_direct(apr_pool_t *p, const char *pathname, int ro,
                                 dav_db **pdb)
 {
-    apr_status_t status;
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+    const apr_dbm_driver_t *driver;
+    const apu_err_t *err;
+#endif
     apr_dbm_t *file = NULL;
+    apr_status_t status;
 
     *pdb = NULL;
 
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+    if ((status = apr_dbm_get_driver(&driver, NULL, &err, p)) != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, status, ap_server_conf, APLOGNO(10289)
+                     "mod_dav_fs: The DBM library '%s' could not be loaded: %s",
+                             err->reason, err->msg);
+        return dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, 1, status,
+                "Could not load library for property database.");
+    }
+    if ((status = apr_dbm_open2(&file, driver, pathname,
+                               ro ? APR_DBM_READONLY : APR_DBM_RWCREATE,
+                               APR_OS_DEFAULT, p))
+                               != APR_SUCCESS && !ro) {
+        return dav_fs_dbm_error(NULL, p, status);
+    }
+#else
     if ((status = apr_dbm_open(&file, pathname,
                                ro ? APR_DBM_READONLY : APR_DBM_RWCREATE,
                                APR_OS_DEFAULT, p))
@@ -143,6 +167,7 @@ dav_error * dav_dbm_open_direct(apr_pool_t *p, const char *pathname, int ro,
            and we need to write */
         return dav_fs_dbm_error(NULL, p, status);
     }
+#endif
 
     /* may be NULL if we tried to open a non-existent db as read-only */
     if (file != NULL) {
index 17b9ee69c02588e4806c7e9485e8af7848fcefd3..0f072ec0647bc0f5dec1d926d837b0e81e60fddd 100644 (file)
 #define APR_WANT_MEMFUNC
 #include "apr_want.h"
 
+#include "apr_version.h"
+#if !APR_VERSION_AT_LEAST(2,0,0)
+#include "apu_version.h"
+#endif
+
 #include "httpd.h"
 #include "http_log.h"
+#include "http_main.h"      /* for ap_server_conf */
 
 #include "mod_dav.h"
 
@@ -311,16 +317,36 @@ static int dav_generic_compare_locktoken(const dav_locktoken *lt1,
  */
 static dav_error * dav_generic_really_open_lockdb(dav_lockdb *lockdb)
 {
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+    const apr_dbm_driver_t *driver;
+    const apu_err_t *er;
+#endif
     dav_error *err;
-    apr_status_t status;
+    apr_status_t status = APR_SUCCESS;
 
     if (lockdb->info->opened) {
         return NULL;
     }
 
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+    status = apr_dbm_get_driver(&driver, NULL, &er, lockdb->info->pool);
+
+    if (status) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, status, ap_server_conf, APLOGNO(10288)
+                     "mod_dav_lock: The DBM library '%s' could not be loaded: %s",
+                             er->reason, er->msg);
+        return dav_new_error(lockdb->info->pool, HTTP_INTERNAL_SERVER_ERROR, 1,
+                status, "Could not load library for property database.");
+    }
+
+    status = apr_dbm_open2(&lockdb->info->db, driver, lockdb->info->lockdb_path,
+                          lockdb->ro ? APR_DBM_READONLY : APR_DBM_RWCREATE,
+                          APR_OS_DEFAULT, lockdb->info->pool);
+#else
     status = apr_dbm_open(&lockdb->info->db, lockdb->info->lockdb_path,
                           lockdb->ro ? APR_DBM_READONLY : APR_DBM_RWCREATE,
                           APR_OS_DEFAULT, lockdb->info->pool);
+#endif
 
     if (status) {
         err = dav_generic_dbm_new_error(lockdb->info->db, lockdb->info->pool,
index 80fbc9e84ff3c09fd4b2a8909e68d4cfe30bceb6..943996560e5134ea9e64bcdd4ac13276332ef81e 100644 (file)
 #include "apr_global_mutex.h"
 #include "apr_dbm.h"
 #include "apr_dbd.h"
+
+#include "apr_version.h"
+#if !APR_VERSION_AT_LEAST(2,0,0)
+#include "apu_version.h"
+#endif
+
 #include "mod_dbd.h"
 
 #if APR_HAS_THREADS
@@ -1357,12 +1363,31 @@ static char *lookup_map_txtfile(request_rec *r, const char *file, char *key)
 static char *lookup_map_dbmfile(request_rec *r, const char *file,
                                 const char *dbmtype, char *key)
 {
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+    const apr_dbm_driver_t *driver;
+    const apu_err_t *err;
+#endif
     apr_dbm_t *dbmfp = NULL;
     apr_datum_t dbmkey;
     apr_datum_t dbmval;
     char *value;
     apr_status_t rv;
 
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+    if ((rv = apr_dbm_get_driver(&driver, dbmtype, &err,
+            r->pool)) != APR_SUCCESS) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(10287)
+                "mod_rewrite: can't load DBM library '%s': %s",
+                     err->reason, err->msg);
+        return NULL;
+    }
+    if ((rv = apr_dbm_open2(&dbmfp, driver, file, APR_DBM_READONLY,
+                              APR_OS_DEFAULT, r->pool)) != APR_SUCCESS) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(00656)
+                      "mod_rewrite: can't open DBM RewriteMap %s", file);
+        return NULL;
+    }
+#else
     if ((rv = apr_dbm_open_ex(&dbmfp, dbmtype, file, APR_DBM_READONLY,
                               APR_OS_DEFAULT, r->pool)) != APR_SUCCESS)
     {
@@ -1370,6 +1395,7 @@ static char *lookup_map_dbmfile(request_rec *r, const char *file,
                       "mod_rewrite: can't open DBM RewriteMap %s", file);
         return NULL;
     }
+#endif
 
     dbmkey.dptr  = key;
     dbmkey.dsize = strlen(key);
index 0f5d604295c06b08ceefb5a5bc4675e9ea88aeae..5d458c4a1c4c2aa10a7a2236a5bc32bf7278b422 100644 (file)
 
 module AP_MODULE_DECLARE_DATA proxy_express_module;
 
+#include "apr_version.h"
+#if !APR_VERSION_AT_LEAST(2,0,0)
+#include "apu_version.h"
+#endif
+
 static int proxy_available = 0;
 
 typedef struct {
@@ -115,6 +120,10 @@ static int xlate_name(request_rec *r)
     struct proxy_alias *ralias;
     proxy_dir_conf *dconf;
     express_server_conf *sconf;
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+    const apr_dbm_driver_t *driver;
+    const apu_err_t *err;
+#endif
 
     sconf = ap_get_module_config(r->server->module_config, &proxy_express_module);
     dconf = ap_get_module_config(r->per_dir_config, &proxy_module);
@@ -132,11 +141,31 @@ static int xlate_name(request_rec *r)
     ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01002)
                   "proxy_express: Opening DBM file: %s (%s)",
                   sconf->dbmfile, sconf->dbmtype);
+
+#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
+    rv = apr_dbm_get_driver(&driver, sconf->dbmtype, &err, r->pool);
+    if (rv != APR_SUCCESS) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
+                     APLOGNO(10275) "The dbm library '%s' could not be loaded: %s (%s: %d)",
+                     sconf->dbmtype, err->msg, err->reason, err->rc);
+        return DECLINED;
+    }
+
+    rv = apr_dbm_open2(&db, driver, sconf->dbmfile, APR_DBM_READONLY,
+                         APR_OS_DEFAULT, r->pool);
+    if (rv != APR_SUCCESS) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
+                     APLOGNO(10276) "The '%s' file '%s' could not be loaded",
+                     sconf->dbmtype, sconf->dbmfile);
+        return DECLINED;
+    }
+#else
     rv = apr_dbm_open_ex(&db, sconf->dbmtype, sconf->dbmfile, APR_DBM_READONLY,
                          APR_OS_DEFAULT, r->pool);
     if (rv != APR_SUCCESS) {
         return DECLINED;
     }
+#endif
 
     name = ap_get_server_name(r);
     ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01003)