mod_authz_host.c revision 682be2c89aa7c96a729f630dc925f827313a9001
/* Copyright 2002-2005 The Apache Software Foundation or its licensors, as
* applicable.
*
* Licensed 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.
*/
/*
* Security options etc.
*
* Module derived from code originally written by Rob McCool
*
*/
#include "apr_strings.h"
#include "apr_network_io.h"
#include "apr_md5.h"
#define APR_WANT_STRFUNC
#define APR_WANT_BYTEFUNC
#include "apr_want.h"
#include "ap_config.h"
#include "ap_provider.h"
#include "httpd.h"
#include "http_core.h"
#include "http_config.h"
#include "http_log.h"
#include "http_protocol.h"
#include "http_request.h"
#include "mod_auth.h"
#endif
typedef struct {
int dummy; /* just here to stop compiler warnings for now. */
{
return (void *)conf;
}
static const command_rec authz_host_cmds[] =
{
{NULL}
};
{
return 0;
}
/* Make sure we matched an *entire* subdomain --- if the user
* to be able to get in.
*/
return 1; /* matched whole thing */
}
else {
}
}
else {
return 0;
}
}
{
const char *t, *w;
/* The 'env' provider will allow the configuration to specify a list of
env variables to check rather than a single variable. This is different
from the previous host based syntax. */
t = require_line;
while ((w = ap_getword_conf(r->pool, &t)) && w[0]) {
if (apr_table_get(r->subprocess_env, w)) {
return AUTHZ_GRANTED;
}
}
"access to %s failed, reason: env variable list does not meet "
"'require'ments for user '%s' to be allowed access",
return AUTHZ_DENIED;
}
{
const char *t, *w;
/* The 'ip' provider will allow the configuration to specify a list of
ip addresses to check rather than a single address. This is different
from the previous host based syntax. */
t = require_line;
while ((w = ap_getword_conf(r->pool, &t)) && w[0]) {
char *s;
char msgbuf[120];
int got_ip = 0;
*s++ = '\0';
if(APR_STATUS_IS_EINVAL(rv)) {
/* looked nothing like an IP address */
"an ip address 'require' list appears to be invalid ");
}
else if (rv != APR_SUCCESS) {
"an ip address 'require' list appears to be invalid; %s ",
msgbuf);
}
else
got_ip = 1;
}
if (rv != APR_SUCCESS) {
"an ip address 'require' list appears to be invalid; %s ",
msgbuf);
}
else
got_ip = 1;
}
return AUTHZ_GRANTED;
}
}
"access to %s failed, reason: ip address list does not meet "
"'require'ments for user '%s' to be allowed access",
return AUTHZ_DENIED;
}
{
const char *t, *w;
const char *remotehost = NULL;
int remotehost_is_ip;
r->per_dir_config,
"access to %s failed, reason: unable to get the "
"remote host name", r->uri);
}
else {
/* The 'host' provider will allow the configuration to specify a list of
host names to check rather than a single name. This is different
from the previous host based syntax. */
t = require_line;
while ((w = ap_getword_conf(r->pool, &t)) && w[0]) {
if (in_domain(w, remotehost)) {
return AUTHZ_GRANTED;
}
}
"access to %s failed, reason: host name list does not meet "
"'require'ments for user '%s' to be allowed access",
}
return AUTHZ_DENIED;
}
{
/* If the argument to the 'all' provider is 'granted' then just let
everybody in. This would be equivalent to the previous syntax of
'allow from all'. If the argument is anything else, this would
be equivalent to 'deny from all' Of course the opposite would be
true if the 'all' provider is invoked by the 'reject' directive */
return AUTHZ_GRANTED;
}
return AUTHZ_DENIED;
}
static const authz_provider authz_env_provider =
{
};
static const authz_provider authz_ip_provider =
{
};
static const authz_provider authz_host_provider =
{
};
static const authz_provider authz_all_provider =
{
};
static void register_hooks(apr_pool_t *p)
{
}
{
create_authz_host_dir_config, /* dir config creater */
NULL, /* dir merger --- default is to override */
NULL, /* server config */
NULL, /* merge server config */
register_hooks /* register hooks */
};