mod_authn_dbd.c revision a72211e92bab814bfa28ee086ca9b2a1a6095c92
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ap_provider.h"
#include "httpd.h"
#include "http_config.h"
#include "http_log.h"
#include "http_request.h"
#include "apr_lib.h"
#include "apr_dbd.h"
#include "mod_dbd.h"
#include "apr_strings.h"
#include "mod_auth.h"
#include "apr_md5.h"
#include "apu_version.h"
typedef struct {
const char *user;
const char *realm;
typedef struct {
const char *label;
const char *query;
/* optional function - look it up once in post_config */
{
return ret;
}
{
return ret;
}
{
static unsigned int label_num = 0;
char *label;
if (authn_dbd_prepare_fn == NULL) {
if (authn_dbd_prepare_fn == NULL) {
return "You must load mod_dbd to enable AuthDBD functions";
}
}
/* save the label here for our own use */
}
static const command_rec authn_dbd_cmds[] =
{
"Query used to fetch password for user"),
"Query used to fetch password for user+realm"),
{NULL}
};
const char *password)
{
const char *dbd_password = NULL;
"Failed to acquire database connection to look up "
"user '%s'", user);
return AUTH_GENERAL_ERROR;
}
"No AuthDBDUserPWQuery has been specified");
return AUTH_GENERAL_ERROR;
}
"A prepared statement could not be found for "
return AUTH_GENERAL_ERROR;
}
"Query execution error looking up '%s' "
"in database", user);
return AUTH_GENERAL_ERROR;
}
rv != -1;
if (rv != 0) {
"Error retrieving results while looking up '%s' "
"in database", user);
return AUTH_GENERAL_ERROR;
}
if (dbd_password == NULL) {
/* add the rest of the columns to the environment */
int i = 1;
const char *name;
name,
NULL);
while (str[j]) {
if (!apr_isalnum(str[j])) {
str[j] = '_';
}
else {
}
j++;
}
i++;
}
#endif
}
/* we can't break out here or row won't get cleaned up */
}
if (!dbd_password) {
return AUTH_USER_NOT_FOUND;
}
if (rv != APR_SUCCESS) {
return AUTH_DENIED;
}
return AUTH_GRANTED;
}
{
"Failed to acquire database connection to look up "
return AUTH_GENERAL_ERROR;
}
"No AuthDBDUserRealmQuery has been specified");
return AUTH_GENERAL_ERROR;
}
"A prepared statement could not be found for "
return AUTH_GENERAL_ERROR;
}
"Query execution error looking up '%s:%s' "
return AUTH_GENERAL_ERROR;
}
rv != -1;
if (rv != 0) {
"Error retrieving results while looking up '%s:%s' "
return AUTH_GENERAL_ERROR;
}
/* add the rest of the columns to the environment */
int i = 1;
const char *name;
name,
NULL);
while (str[j]) {
if (!apr_isalnum(str[j])) {
str[j] = '_';
}
else {
}
j++;
}
i++;
}
#endif
}
/* we can't break out here or row won't get cleaned up */
}
if (!dbd_hash) {
return AUTH_USER_NOT_FOUND;
}
return AUTH_USER_FOUND;
}
static void authn_dbd_hooks(apr_pool_t *p)
{
static const authn_provider authn_dbd_provider = {
};
}
{
NULL,
NULL,
};