summaryrefslogtreecommitdiff
path: root/modules/aaa
diff options
context:
space:
mode:
authorGraham Leggett <minfrin@apache.org>2021-06-24 10:27:49 +0000
committerGraham Leggett <minfrin@apache.org>2021-06-24 10:27:49 +0000
commit95592b5dda6c7e4876f5674976f5c7902b330cd2 (patch)
treefbe581ba59a136c84b18d3b65c886a92900123e1 /modules/aaa
parentf2e9880ac9a508259488a83ad89791a3908680de (diff)
downloadhttpd-95592b5dda6c7e4876f5674976f5c7902b330cd2.tar.gz
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/trunk@1891019 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/aaa')
-rw-r--r--modules/aaa/mod_authn_dbm.c49
-rw-r--r--modules/aaa/mod_authz_dbm.c32
2 files changed, 60 insertions, 21 deletions
diff --git a/modules/aaa/mod_authn_dbm.c b/modules/aaa/mod_authn_dbm.c
index e54058563b..a612f371a0 100644
--- a/modules/aaa/mod_authn_dbm.c
+++ b/modules/aaa/mod_authn_dbm.c
@@ -38,6 +38,11 @@
#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) \
@@ -71,18 +76,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()
+ "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()
+ "could not open dbm (type %s) file: %s",
+ dbmtype, dbmfile);
return rv;
}
@@ -96,7 +122,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);
@@ -117,13 +143,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;
}
@@ -155,14 +177,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;
}
diff --git a/modules/aaa/mod_authz_dbm.c b/modules/aaa/mod_authz_dbm.c
index 843d9a8e43..90d35b07f1 100644
--- a/modules/aaa/mod_authz_dbm.c
+++ b/modules/aaa/mod_authz_dbm.c
@@ -20,6 +20,11 @@
#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()
+ "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;
}