mod_authn_dbm.c revision 807dcf9d7b1b1e1f34b8274d08a40f5435987110
08cb74ca432a8c24e39f17dedce527e6a47b8001jerenkrantz/* ====================================================================
08cb74ca432a8c24e39f17dedce527e6a47b8001jerenkrantz * The Apache Software License, Version 1.1
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * reserved.
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * Redistribution and use in source and binary forms, with or without
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * modification, are permitted provided that the following conditions
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * 1. Redistributions of source code must retain the above copyright
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * notice, this list of conditions and the following disclaimer.
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * 2. Redistributions in binary form must reproduce the above copyright
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * notice, this list of conditions and the following disclaimer in
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * the documentation and/or other materials provided with the
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * distribution.
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * 3. The end-user documentation included with the redistribution,
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * if any, must include the following acknowledgment:
b6055b7832a0e4d0818416252fff5925aaebae4brbb * "This product includes software developed by the
2d71630471d1c23f0137309e3c3957c633ecbfd6rbb * Apache Software Foundation (http://www.apache.org/)."
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * Alternately, this acknowledgment may appear in the software itself,
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * if and wherever such third-party acknowledgments normally appear.
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * 4. The names "Apache" and "Apache Software Foundation" must
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * not be used to endorse or promote products derived from this
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * software without prior written permission. For written
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * permission, please contact apache@apache.org.
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * 5. Products derived from this software may not be called "Apache",
3d96ee83babeec32482c9082c9426340cee8c44dwrowe * nor may "Apache" appear in their name, without prior written
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * permission of the Apache Software Foundation.
2d84861186d70e5396751ba308bb90c8a7db47acnd * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
2d84861186d70e5396751ba308bb90c8a7db47acnd * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2d84861186d70e5396751ba308bb90c8a7db47acnd * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
2d84861186d70e5396751ba308bb90c8a7db47acnd * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
2d84861186d70e5396751ba308bb90c8a7db47acnd * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
2d84861186d70e5396751ba308bb90c8a7db47acnd * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * SUCH DAMAGE.
4f9a74ad7e44b0464f7cf56525a205d788becacbtrawick * ====================================================================
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * This software consists of voluntary contributions made by many
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * individuals on behalf of the Apache Software Foundation. For more
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * information on the Apache Software Foundation, please see
066877f1a045103acfdd376d48cdd473c33f409bdougm * Portions of this software are based upon public domain software
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * originally written at the National Center for Supercomputing Applications,
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * University of Illinois, Urbana-Champaign.
2d84861186d70e5396751ba308bb90c8a7db47acnd * http_auth: authentication
2d84861186d70e5396751ba308bb90c8a7db47acnd * Rob McCool & Brian Behlendorf.
2d84861186d70e5396751ba308bb90c8a7db47acnd * Adapted to Apache by rst.
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding#include "apr_md5.h" /* for apr_password_validate */
2d84861186d70e5396751ba308bb90c8a7db47acnd#include "http_request.h" /* for ap_hook_(check_user_id | auth_checker)*/
1ccd992d37d62c8cb2056126f2234f64ec189bfddougmtypedef struct {
0f081398cf0eef8cc7c66a535d450110a92dc8aefieldingstatic void *create_authn_dbm_dir_config(apr_pool_t *p, char *d)
2d84861186d70e5396751ba308bb90c8a7db47acnd authn_dbm_config_rec *conf = apr_palloc(p, sizeof(*conf));
3f65070bf58882ab06bfa08cc4e04c7c90ac04f8wrowe const char *arg)
3f65070bf58882ab06bfa08cc4e04c7c90ac04f8wrowe OR_AUTHCFG, "dbm database file containing user IDs and passwords"),
3f65070bf58882ab06bfa08cc4e04c7c90ac04f8wrowe OR_AUTHCFG, "what type of DBM file the user file is"),
3f65070bf58882ab06bfa08cc4e04c7c90ac04f8wrowestatic apr_status_t fetch_dbm(const char *dbmtype, const char *dbmfile,
2d84861186d70e5396751ba308bb90c8a7db47acnd rv = apr_dbm_open_ex(&f, dbmtype, dbmfile, APR_DBM_READONLY,
0f081398cf0eef8cc7c66a535d450110a92dc8aefieldingstatic authn_status check_dbm_pw(request_rec *r, const char *user,
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding const char *password)
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding authn_dbm_config_rec *conf = ap_get_module_config(r->per_dir_config,
d54c6537f5f5a7bc54ec37ce8dbe04193605043astoddard rv = fetch_dbm(conf->dbmtype, conf->pwfile, user, &dbm_pw, r->pool);
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding "could not open dbm (type %s) auth file: %s",
3f65070bf58882ab06bfa08cc4e04c7c90ac04f8wrowe dbm_password = apr_pstrmemdup(r->pool, dbm_pw.dptr, dbm_pw.dsize);