mod_authn_dbm.c revision 724ddc1dd163506ec738717f761ca3f09f9bb5fe
a78048ccbdb6256da15e6b0e7e95355e480c2301nd/* Copyright 2002-2004 Apache Software Foundation
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * Licensed under the Apache License, Version 2.0 (the "License");
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * you may not use this file except in compliance with the License.
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * You may obtain a copy of the License at
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * Unless required by applicable law or agreed to in writing, software
96ad5d81ee4a2cc66a4ae19893efc8aa6d06fae7jailletc * distributed under the License is distributed on an "AS IS" BASIS,
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * See the License for the specific language governing permissions and
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * limitations under the License.
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * http_auth: authentication
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen * Rob McCool & Brian Behlendorf.
a78048ccbdb6256da15e6b0e7e95355e480c2301nd * Adapted to Apache by rst.
4aa603e6448b99f9371397d439795c91a93637eand#include "http_request.h" /* for ap_hook_(check_user_id | auth_checker)*/
a78048ccbdb6256da15e6b0e7e95355e480c2301ndtypedef struct {
a78048ccbdb6256da15e6b0e7e95355e480c2301ndstatic void *create_authn_dbm_dir_config(apr_pool_t *p, char *d)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd authn_dbm_config_rec *conf = apr_palloc(p, sizeof(*conf));
a78048ccbdb6256da15e6b0e7e95355e480c2301nd const char *arg)
a78048ccbdb6256da15e6b0e7e95355e480c2301nd OR_AUTHCFG, "dbm database file containing user IDs and passwords"),
a78048ccbdb6256da15e6b0e7e95355e480c2301ndstatic apr_status_t fetch_dbm_value(const char *dbmtype, const char *dbmfile,
a78048ccbdb6256da15e6b0e7e95355e480c2301nd rv = apr_dbm_open_ex(&f, dbmtype, dbmfile, APR_DBM_READONLY,
0d0ba3a410038e179b695446bb149cce6264e0abnd if (apr_dbm_fetch(f, key, &val) == APR_SUCCESS && val.dptr) {
727872d18412fc021f03969b8641810d8896820bhumbedooh *value = apr_pstrmemdup(pool, val.dptr, val.dsize);
ac082aefa89416cbdc9a1836eaf3bed9698201c8humbedoohstatic authn_status check_dbm_pw(request_rec *r, const char *user,
0d0ba3a410038e179b695446bb149cce6264e0abnd const char *password)
0d0ba3a410038e179b695446bb149cce6264e0abnd authn_dbm_config_rec *conf = ap_get_module_config(r->per_dir_config,
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen rv = fetch_dbm_value(conf->dbmtype, conf->pwfile, user, &dbm_password,
a78048ccbdb6256da15e6b0e7e95355e480c2301nd "could not open dbm (type %s) auth file: %s",
return AUTH_GENERAL_ERROR;
if (!dbm_password) {
return AUTH_USER_NOT_FOUND;
if (colon_pw) {
return AUTH_DENIED;
return AUTH_GRANTED;
char *dbm_hash;
char *colon_hash;
return AUTH_GENERAL_ERROR;
if (!dbm_hash) {
return AUTH_USER_NOT_FOUND;
if (colon_hash) {
return AUTH_USER_FOUND;