mod_authz_host.c revision b4a287513d176e4355dd56ea47b27228e0e5d75f
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
*
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
*/
/*
* 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 "httpd.h"
#include "http_core.h"
#include "http_config.h"
#include "http_log.h"
#include "http_request.h"
#endif
enum allowdeny_type {
T_IP,
};
typedef struct {
union {
char *from;
} x;
enum allowdeny_type type;
} allowdeny;
/* things in the 'order' array */
#define DENY_THEN_ALLOW 0
#define ALLOW_THEN_DENY 1
#define MUTUAL_FAILURE 2
typedef struct {
{
int i;
for (i = 0; i < METHODS; ++i) {
}
return (void *)conf;
}
{
int i, o;
o = ALLOW_THEN_DENY;
o = DENY_THEN_ALLOW;
o = MUTUAL_FAILURE;
else
return "unknown order";
for (i = 0; i < METHODS; ++i)
d->order[i] = o;
return NULL;
}
const char *where_c)
{
allowdeny *a;
char *s;
char msgbuf[120];
return "allow and deny must be followed by 'from'";
a->x.from += 4;
}
}
*s++ = '\0';
if(APR_STATUS_IS_EINVAL(rv)) {
/* looked nothing like an IP address */
return "An IP address was expected";
}
else if (rv != APR_SUCCESS) {
}
}
if (rv != APR_SUCCESS) {
}
}
else { /* no slash, didn't look like an IP address => must be a host */
}
return NULL;
}
static char its_an_allow;
static const command_rec authz_host_cmds[] =
{
"'allow,deny', 'deny,allow', or 'mutual-failure'"),
"'from' followed by hostnames or IP-address wildcards"),
"'from' followed by hostnames or IP-address wildcards"),
{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;
}
}
{
int i;
int gothost = 0;
const char *remotehost = NULL;
for (i = 0; i < a->nelts; ++i) {
continue;
}
case T_ENV:
return 1;
}
break;
case T_ALL:
return 1;
case T_IP:
return 1;
}
break;
case T_HOST:
if (!gothost) {
int remotehost_is_ip;
r->per_dir_config,
gothost = 1;
}
else {
gothost = 2;
}
}
return 1;
}
break;
case T_FAIL:
/* do nothing? */
break;
}
}
return 0;
}
static int check_dir_access(request_rec *r)
{
int method = r->method_number;
authz_host_dir_conf *a = (authz_host_dir_conf *)
}
}
}
}
}
}
else {
}
else {
}
}
if (ret == HTTP_FORBIDDEN
"client denied by server configuration: %s",
r->filename);
}
return ret;
}
static void register_hooks(apr_pool_t *p)
{
/* This can be access checker since we don't require r->user to be set. */
}
{
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 */
};