mod_authn_dbd.c revision df9ae8c422035307555bba24cc1d5f5c208890dc
6ae232055d4d8a97267517c5e50074c2c819941and/* Licensed to the Apache Software Foundation (ASF) under one or more
6ae232055d4d8a97267517c5e50074c2c819941and * contributor license agreements. See the NOTICE file distributed with
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * this work for additional information regarding copyright ownership.
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * The ASF licenses this file to You under the Apache License, Version 2.0
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * (the "License"); you may not use this file except in compliance with
6ae232055d4d8a97267517c5e50074c2c819941and * the License. You may obtain a copy of the License at
6ae232055d4d8a97267517c5e50074c2c819941and *
6ae232055d4d8a97267517c5e50074c2c819941and * http://www.apache.org/licenses/LICENSE-2.0
6ae232055d4d8a97267517c5e50074c2c819941and *
96ad5d81ee4a2cc66a4ae19893efc8aa6d06fae7jailletc * Unless required by applicable law or agreed to in writing, software
6ae232055d4d8a97267517c5e50074c2c819941and * distributed under the License is distributed on an "AS IS" BASIS,
6ae232055d4d8a97267517c5e50074c2c819941and * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * See the License for the specific language governing permissions and
2e545ce2450a9953665f701bb05350f0d3f26275nd * limitations under the License.
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen */
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen
6ae232055d4d8a97267517c5e50074c2c819941and#include "ap_provider.h"
6ae232055d4d8a97267517c5e50074c2c819941and#include "httpd.h"
6ae232055d4d8a97267517c5e50074c2c819941and#include "http_config.h"
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen#include "http_log.h"
3f08db06526d6901aa08c110b5bc7dde6bc39905nd#include "http_request.h"
6ae232055d4d8a97267517c5e50074c2c819941and#include "apr_lib.h"
6ae232055d4d8a97267517c5e50074c2c819941and#include "apr_dbd.h"
6ae232055d4d8a97267517c5e50074c2c819941and#include "mod_dbd.h"
b43f840409794ed298e8634f6284741f193b6c4ftakashi#include "apr_strings.h"
6ae232055d4d8a97267517c5e50074c2c819941and#include "mod_auth.h"
6ae232055d4d8a97267517c5e50074c2c819941and#include "apr_md5.h"
6ae232055d4d8a97267517c5e50074c2c819941and#include "apu_version.h"
b43f840409794ed298e8634f6284741f193b6c4ftakashi
d28579afd45cc42da1422161721fb12f9cf366b9ndmodule AP_MODULE_DECLARE_DATA authn_dbd_module;
6ae232055d4d8a97267517c5e50074c2c819941and
1ac39787115a288f5e848344b1b1e8dccb1c58f1ndtypedef struct {
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung const char *user;
6ae232055d4d8a97267517c5e50074c2c819941and const char *realm;
b43f840409794ed298e8634f6284741f193b6c4ftakashi} authn_dbd_conf;
b43f840409794ed298e8634f6284741f193b6c4ftakashitypedef struct {
b43f840409794ed298e8634f6284741f193b6c4ftakashi const char *label;
b43f840409794ed298e8634f6284741f193b6c4ftakashi const char *query;
6ae232055d4d8a97267517c5e50074c2c819941and} authn_dbd_rec;
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941and/* optional function - look it up once in post_config */
6ae232055d4d8a97267517c5e50074c2c819941andstatic ap_dbd_t *(*authn_dbd_acquire_fn)(request_rec*) = NULL;
6ae232055d4d8a97267517c5e50074c2c819941andstatic void (*authn_dbd_prepare_fn)(server_rec*, const char*, const char*) = NULL;
6ae232055d4d8a97267517c5e50074c2c819941andstatic APR_OPTIONAL_FN_TYPE(ap_authn_cache_store) *authn_cache_store = NULL;
6ae232055d4d8a97267517c5e50074c2c819941and#define AUTHN_CACHE_STORE(r,user,realm,data) \
6ae232055d4d8a97267517c5e50074c2c819941and if (authn_cache_store != NULL) \
6ae232055d4d8a97267517c5e50074c2c819941and authn_cache_store((r), "dbd", (user), (realm), (data))
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941andstatic void *authn_dbd_cr_conf(apr_pool_t *pool, char *dummy)
6ae232055d4d8a97267517c5e50074c2c819941and{
6ae232055d4d8a97267517c5e50074c2c819941and authn_dbd_conf *ret = apr_pcalloc(pool, sizeof(authn_dbd_conf));
6ae232055d4d8a97267517c5e50074c2c819941and return ret;
6ae232055d4d8a97267517c5e50074c2c819941and}
6ae232055d4d8a97267517c5e50074c2c819941andstatic void *authn_dbd_merge_conf(apr_pool_t *pool, void *BASE, void *ADD)
6ae232055d4d8a97267517c5e50074c2c819941and{
6ae232055d4d8a97267517c5e50074c2c819941and authn_dbd_conf *add = ADD;
6ae232055d4d8a97267517c5e50074c2c819941and authn_dbd_conf *base = BASE;
6ae232055d4d8a97267517c5e50074c2c819941and authn_dbd_conf *ret = apr_palloc(pool, sizeof(authn_dbd_conf));
6ae232055d4d8a97267517c5e50074c2c819941and ret->user = (add->user == NULL) ? base->user : add->user;
6ae232055d4d8a97267517c5e50074c2c819941and ret->realm = (add->realm == NULL) ? base->realm : add->realm;
6ae232055d4d8a97267517c5e50074c2c819941and return ret;
6ae232055d4d8a97267517c5e50074c2c819941and}
6ae232055d4d8a97267517c5e50074c2c819941andstatic const char *authn_dbd_prepare(cmd_parms *cmd, void *cfg, const char *query)
6ae232055d4d8a97267517c5e50074c2c819941and{
6ae232055d4d8a97267517c5e50074c2c819941and static unsigned int label_num = 0;
6ae232055d4d8a97267517c5e50074c2c819941and char *label;
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941and if (authn_dbd_prepare_fn == NULL) {
6ae232055d4d8a97267517c5e50074c2c819941and authn_dbd_prepare_fn = APR_RETRIEVE_OPTIONAL_FN(ap_dbd_prepare);
6ae232055d4d8a97267517c5e50074c2c819941and if (authn_dbd_prepare_fn == NULL) {
6ae232055d4d8a97267517c5e50074c2c819941and return "You must load mod_dbd to enable AuthDBD functions";
6ae232055d4d8a97267517c5e50074c2c819941and }
6ae232055d4d8a97267517c5e50074c2c819941and authn_dbd_acquire_fn = APR_RETRIEVE_OPTIONAL_FN(ap_dbd_acquire);
f4cbda69df0490c6deaacb8d04f103d200ddd183nd }
6ae232055d4d8a97267517c5e50074c2c819941and label = apr_psprintf(cmd->pool, "authn_dbd_%d", ++label_num);
1462ff536f1b939bb337766b2056109c29664c4erbowen
6ae232055d4d8a97267517c5e50074c2c819941and authn_dbd_prepare_fn(cmd->server, query, label);
aded39829fe5f862c6c8095f42f7cc38e3407978rbowen
6ae232055d4d8a97267517c5e50074c2c819941and /* save the label here for our own use */
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh return ap_set_string_slot(cmd, cfg, label);
1f1b6bf13313fdd14a45e52e553d3ff28689b717coar}
f4cbda69df0490c6deaacb8d04f103d200ddd183ndstatic const command_rec authn_dbd_cmds[] =
f4cbda69df0490c6deaacb8d04f103d200ddd183nd{
f4cbda69df0490c6deaacb8d04f103d200ddd183nd AP_INIT_TAKE1("AuthDBDUserPWQuery", authn_dbd_prepare,
f4cbda69df0490c6deaacb8d04f103d200ddd183nd (void *)APR_OFFSETOF(authn_dbd_conf, user), ACCESS_CONF,
f4cbda69df0490c6deaacb8d04f103d200ddd183nd "Query used to fetch password for user"),
df4578cbf77fc9e35ccade1f01b137b7eea5ede6nd AP_INIT_TAKE1("AuthDBDUserRealmQuery", authn_dbd_prepare,
f4cbda69df0490c6deaacb8d04f103d200ddd183nd (void *)APR_OFFSETOF(authn_dbd_conf, realm), ACCESS_CONF,
f4cbda69df0490c6deaacb8d04f103d200ddd183nd "Query used to fetch password for user+realm"),
f4cbda69df0490c6deaacb8d04f103d200ddd183nd {NULL}
f4cbda69df0490c6deaacb8d04f103d200ddd183nd};
f4cbda69df0490c6deaacb8d04f103d200ddd183ndstatic authn_status authn_dbd_password(request_rec *r, const char *user,
df4578cbf77fc9e35ccade1f01b137b7eea5ede6nd const char *password)
f4cbda69df0490c6deaacb8d04f103d200ddd183nd{
f4cbda69df0490c6deaacb8d04f103d200ddd183nd apr_status_t rv;
f4cbda69df0490c6deaacb8d04f103d200ddd183nd const char *dbd_password = NULL;
6ae232055d4d8a97267517c5e50074c2c819941and apr_dbd_prepared_t *statement;
6ae232055d4d8a97267517c5e50074c2c819941and apr_dbd_results_t *res = NULL;
6ae232055d4d8a97267517c5e50074c2c819941and apr_dbd_row_t *row = NULL;
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941and authn_dbd_conf *conf = ap_get_module_config(r->per_dir_config,
6ae232055d4d8a97267517c5e50074c2c819941and &authn_dbd_module);
6ae232055d4d8a97267517c5e50074c2c819941and ap_dbd_t *dbd = authn_dbd_acquire_fn(r);
6ae232055d4d8a97267517c5e50074c2c819941and if (dbd == NULL) {
6ae232055d4d8a97267517c5e50074c2c819941and ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
6ae232055d4d8a97267517c5e50074c2c819941and "Failed to acquire database connection to look up "
6ae232055d4d8a97267517c5e50074c2c819941and "user '%s'", user);
6ae232055d4d8a97267517c5e50074c2c819941and return AUTH_GENERAL_ERROR;
6ae232055d4d8a97267517c5e50074c2c819941and }
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941and if (conf->user == NULL) {
6ae232055d4d8a97267517c5e50074c2c819941and ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
6ae232055d4d8a97267517c5e50074c2c819941and "No AuthDBDUserPWQuery has been specified");
6ae232055d4d8a97267517c5e50074c2c819941and return AUTH_GENERAL_ERROR;
6ae232055d4d8a97267517c5e50074c2c819941and }
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941and statement = apr_hash_get(dbd->prepared, conf->user, APR_HASH_KEY_STRING);
6ae232055d4d8a97267517c5e50074c2c819941and if (statement == NULL) {
6ae232055d4d8a97267517c5e50074c2c819941and ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
6ae232055d4d8a97267517c5e50074c2c819941and "A prepared statement could not be found for "
6ae232055d4d8a97267517c5e50074c2c819941and "AuthDBDUserPWQuery with the key '%s'", conf->user);
6ae232055d4d8a97267517c5e50074c2c819941and return AUTH_GENERAL_ERROR;
6ae232055d4d8a97267517c5e50074c2c819941and }
6ae232055d4d8a97267517c5e50074c2c819941and if (apr_dbd_pvselect(dbd->driver, r->pool, dbd->handle, &res, statement,
6ae232055d4d8a97267517c5e50074c2c819941and 0, user, NULL) != 0) {
6ae232055d4d8a97267517c5e50074c2c819941and ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
6ae232055d4d8a97267517c5e50074c2c819941and "Query execution error looking up '%s' "
6ae232055d4d8a97267517c5e50074c2c819941and "in database", user);
6ae232055d4d8a97267517c5e50074c2c819941and return AUTH_GENERAL_ERROR;
6ae232055d4d8a97267517c5e50074c2c819941and }
6ae232055d4d8a97267517c5e50074c2c819941and for (rv = apr_dbd_get_row(dbd->driver, r->pool, res, &row, -1);
6ae232055d4d8a97267517c5e50074c2c819941and rv != -1;
6ae232055d4d8a97267517c5e50074c2c819941and rv = apr_dbd_get_row(dbd->driver, r->pool, res, &row, -1)) {
6ae232055d4d8a97267517c5e50074c2c819941and if (rv != 0) {
6ae232055d4d8a97267517c5e50074c2c819941and ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
6ae232055d4d8a97267517c5e50074c2c819941and "Error retrieving results while looking up '%s' "
6ae232055d4d8a97267517c5e50074c2c819941and "in database", user);
6ae232055d4d8a97267517c5e50074c2c819941and return AUTH_GENERAL_ERROR;
6ae232055d4d8a97267517c5e50074c2c819941and }
6ae232055d4d8a97267517c5e50074c2c819941and if (dbd_password == NULL) {
6ae232055d4d8a97267517c5e50074c2c819941and#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 3)
6ae232055d4d8a97267517c5e50074c2c819941and /* add the rest of the columns to the environment */
6ae232055d4d8a97267517c5e50074c2c819941and int i = 1;
1462ff536f1b939bb337766b2056109c29664c4erbowen const char *name;
1462ff536f1b939bb337766b2056109c29664c4erbowen for (name = apr_dbd_get_name(dbd->driver, res, i);
1462ff536f1b939bb337766b2056109c29664c4erbowen name != NULL;
1462ff536f1b939bb337766b2056109c29664c4erbowen name = apr_dbd_get_name(dbd->driver, res, i)) {
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf
1462ff536f1b939bb337766b2056109c29664c4erbowen char *str = apr_pstrcat(r->pool, AUTHN_PREFIX,
1462ff536f1b939bb337766b2056109c29664c4erbowen name,
1462ff536f1b939bb337766b2056109c29664c4erbowen NULL);
1462ff536f1b939bb337766b2056109c29664c4erbowen int j = sizeof(AUTHN_PREFIX)-1; /* string length of "AUTHENTICATE_", excluding the trailing NIL */
1462ff536f1b939bb337766b2056109c29664c4erbowen while (str[j]) {
1462ff536f1b939bb337766b2056109c29664c4erbowen if (!apr_isalnum(str[j])) {
1462ff536f1b939bb337766b2056109c29664c4erbowen str[j] = '_';
1462ff536f1b939bb337766b2056109c29664c4erbowen }
b43f840409794ed298e8634f6284741f193b6c4ftakashi else {
b43f840409794ed298e8634f6284741f193b6c4ftakashi str[j] = apr_toupper(str[j]);
b43f840409794ed298e8634f6284741f193b6c4ftakashi }
1462ff536f1b939bb337766b2056109c29664c4erbowen j++;
6ae232055d4d8a97267517c5e50074c2c819941and }
6ae232055d4d8a97267517c5e50074c2c819941and apr_table_set(r->subprocess_env, str,
6ae232055d4d8a97267517c5e50074c2c819941and apr_dbd_get_entry(dbd->driver, row, i));
6ae232055d4d8a97267517c5e50074c2c819941and i++;
6ae232055d4d8a97267517c5e50074c2c819941and }
6ae232055d4d8a97267517c5e50074c2c819941and#endif
6ae232055d4d8a97267517c5e50074c2c819941and dbd_password = apr_dbd_get_entry(dbd->driver, row, 0);
6ae232055d4d8a97267517c5e50074c2c819941and }
6ae232055d4d8a97267517c5e50074c2c819941and /* we can't break out here or row won't get cleaned up */
6ae232055d4d8a97267517c5e50074c2c819941and }
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941and if (!dbd_password) {
6ae232055d4d8a97267517c5e50074c2c819941and return AUTH_USER_NOT_FOUND;
6ae232055d4d8a97267517c5e50074c2c819941and }
6ae232055d4d8a97267517c5e50074c2c819941and AUTHN_CACHE_STORE(r, user, NULL, dbd_password);
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941and rv = apr_password_validate(password, dbd_password);
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941and if (rv != APR_SUCCESS) {
6ae232055d4d8a97267517c5e50074c2c819941and return AUTH_DENIED;
6ae232055d4d8a97267517c5e50074c2c819941and }
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941and return AUTH_GRANTED;
6ae232055d4d8a97267517c5e50074c2c819941and}
6ae232055d4d8a97267517c5e50074c2c819941andstatic authn_status authn_dbd_realm(request_rec *r, const char *user,
6ae232055d4d8a97267517c5e50074c2c819941and const char *realm, char **rethash)
6ae232055d4d8a97267517c5e50074c2c819941and{
6ae232055d4d8a97267517c5e50074c2c819941and apr_status_t rv;
6ae232055d4d8a97267517c5e50074c2c819941and const char *dbd_hash = NULL;
6ae232055d4d8a97267517c5e50074c2c819941and apr_dbd_prepared_t *statement;
6ae232055d4d8a97267517c5e50074c2c819941and apr_dbd_results_t *res = NULL;
6ae232055d4d8a97267517c5e50074c2c819941and apr_dbd_row_t *row = NULL;
6ae232055d4d8a97267517c5e50074c2c819941and
6ae232055d4d8a97267517c5e50074c2c819941and authn_dbd_conf *conf = ap_get_module_config(r->per_dir_config,
6ae232055d4d8a97267517c5e50074c2c819941and &authn_dbd_module);
6ae232055d4d8a97267517c5e50074c2c819941and ap_dbd_t *dbd = authn_dbd_acquire_fn(r);
6ae232055d4d8a97267517c5e50074c2c819941and if (dbd == NULL) {
6ae232055d4d8a97267517c5e50074c2c819941and ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
6ae232055d4d8a97267517c5e50074c2c819941and "Failed to acquire database connection to look up "
6ae232055d4d8a97267517c5e50074c2c819941and "user '%s:%s'", user, realm);
6ae232055d4d8a97267517c5e50074c2c819941and return AUTH_GENERAL_ERROR;
6ae232055d4d8a97267517c5e50074c2c819941and }
6ae232055d4d8a97267517c5e50074c2c819941and if (conf->realm == NULL) {
6ae232055d4d8a97267517c5e50074c2c819941and ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
6ae232055d4d8a97267517c5e50074c2c819941and "No AuthDBDUserRealmQuery has been specified");
6ae232055d4d8a97267517c5e50074c2c819941and return AUTH_GENERAL_ERROR;
6ae232055d4d8a97267517c5e50074c2c819941and }
6ae232055d4d8a97267517c5e50074c2c819941and statement = apr_hash_get(dbd->prepared, conf->realm, APR_HASH_KEY_STRING);
6ae232055d4d8a97267517c5e50074c2c819941and if (statement == NULL) {
6ae232055d4d8a97267517c5e50074c2c819941and ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
6ae232055d4d8a97267517c5e50074c2c819941and "A prepared statement could not be found for "
6ae232055d4d8a97267517c5e50074c2c819941and "AuthDBDUserRealmQuery with the key '%s'", conf->realm);
6ae232055d4d8a97267517c5e50074c2c819941and return AUTH_GENERAL_ERROR;
6ae232055d4d8a97267517c5e50074c2c819941and }
6ae232055d4d8a97267517c5e50074c2c819941and if (apr_dbd_pvselect(dbd->driver, r->pool, dbd->handle, &res, statement,
6ae232055d4d8a97267517c5e50074c2c819941and 0, user, realm, NULL) != 0) {
aded39829fe5f862c6c8095f42f7cc38e3407978rbowen ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
aded39829fe5f862c6c8095f42f7cc38e3407978rbowen "Query execution error looking up '%s:%s' "
aded39829fe5f862c6c8095f42f7cc38e3407978rbowen "in database", user, realm);
aded39829fe5f862c6c8095f42f7cc38e3407978rbowen return AUTH_GENERAL_ERROR;
aded39829fe5f862c6c8095f42f7cc38e3407978rbowen }
aded39829fe5f862c6c8095f42f7cc38e3407978rbowen for (rv = apr_dbd_get_row(dbd->driver, r->pool, res, &row, -1);
aded39829fe5f862c6c8095f42f7cc38e3407978rbowen rv != -1;
aded39829fe5f862c6c8095f42f7cc38e3407978rbowen rv = apr_dbd_get_row(dbd->driver, r->pool, res, &row, -1)) {
aded39829fe5f862c6c8095f42f7cc38e3407978rbowen if (rv != 0) {
60ee73f225a3fd9bb1e561ec3aadda7fcd8243a9igalic ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
6ae232055d4d8a97267517c5e50074c2c819941and "Error retrieving results while looking up '%s:%s' "
6ae232055d4d8a97267517c5e50074c2c819941and "in database", user, realm);
6ae232055d4d8a97267517c5e50074c2c819941and return AUTH_GENERAL_ERROR;
b43f840409794ed298e8634f6284741f193b6c4ftakashi }
d28579afd45cc42da1422161721fb12f9cf366b9nd if (dbd_hash == NULL) {
6ae232055d4d8a97267517c5e50074c2c819941and#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 3)
1ac39787115a288f5e848344b1b1e8dccb1c58f1nd /* add the rest of the columns to the environment */
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung int i = 1;
727872d18412fc021f03969b8641810d8896820bhumbedooh const char *name;
0d0ba3a410038e179b695446bb149cce6264e0abnd for (name = apr_dbd_get_name(dbd->driver, res, i);
727872d18412fc021f03969b8641810d8896820bhumbedooh name != NULL;
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedooh name = apr_dbd_get_name(dbd->driver, res, i)) {
0d0ba3a410038e179b695446bb149cce6264e0abnd
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedooh char *str = apr_pstrcat(r->pool, AUTHN_PREFIX,
727872d18412fc021f03969b8641810d8896820bhumbedooh name,
0d0ba3a410038e179b695446bb149cce6264e0abnd NULL);
0d0ba3a410038e179b695446bb149cce6264e0abnd int j = sizeof(AUTHN_PREFIX)-1; /* string length of "AUTHENTICATE_", excluding the trailing NIL */
0d0ba3a410038e179b695446bb149cce6264e0abnd while (str[j]) {
ac082aefa89416cbdc9a1836eaf3bed9698201c8humbedooh if (!apr_isalnum(str[j])) {
0d0ba3a410038e179b695446bb149cce6264e0abnd str[j] = '_';
0d0ba3a410038e179b695446bb149cce6264e0abnd }
0d0ba3a410038e179b695446bb149cce6264e0abnd else {
727872d18412fc021f03969b8641810d8896820bhumbedooh str[j] = apr_toupper(str[j]);
0d0ba3a410038e179b695446bb149cce6264e0abnd }
0d0ba3a410038e179b695446bb149cce6264e0abnd j++;
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh }
205f749042ed530040a4f0080dbcb47ceae8a374rjung apr_table_set(r->subprocess_env, str,
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen apr_dbd_get_entry(dbd->driver, row, i));
0d0ba3a410038e179b695446bb149cce6264e0abnd i++;
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd }
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd#endif
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd dbd_hash = apr_dbd_get_entry(dbd->driver, row, 0);
6ae232055d4d8a97267517c5e50074c2c819941and }
/* we can't break out here or row won't get cleaned up */
}
if (!dbd_hash) {
return AUTH_USER_NOT_FOUND;
}
AUTHN_CACHE_STORE(r, user, realm, dbd_hash);
*rethash = apr_pstrdup(r->pool, dbd_hash);
return AUTH_USER_FOUND;
}
static void opt_retr(void)
{
authn_cache_store = APR_RETRIEVE_OPTIONAL_FN(ap_authn_cache_store);
}
static void authn_dbd_hooks(apr_pool_t *p)
{
static const authn_provider authn_dbd_provider = {
&authn_dbd_password,
&authn_dbd_realm
};
ap_register_auth_provider(p, AUTHN_PROVIDER_GROUP, "dbd",
AUTHN_PROVIDER_VERSION,
&authn_dbd_provider, AP_AUTH_INTERNAL_PER_CONF);
ap_hook_optional_fn_retrieve(opt_retr, NULL, NULL, APR_HOOK_MIDDLE);
}
AP_DECLARE_MODULE(authn_dbd) =
{
STANDARD20_MODULE_STUFF,
authn_dbd_cr_conf,
authn_dbd_merge_conf,
NULL,
NULL,
authn_dbd_cmds,
authn_dbd_hooks
};