mod_dir.c revision e8f95a682820a599fe41b22977010636be5c2717
/* Copyright 1999-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.
*/
/*
* mod_dir.c: handle default index files, and trailing-/ redirects
*/
#include "apr_strings.h"
#include "ap_config.h"
#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
#include "http_request.h"
#include "http_protocol.h"
#include "http_log.h"
#include "http_main.h"
#include "util_script.h"
typedef enum {
SLASH_OFF = 0,
} slash_cfg;
typedef struct dir_config_struct {
#define DIR_CMD_PERMS OR_INDEXES
{
dir_config_rec *d = dummy;
if (!d->index_names) {
}
return NULL;
}
{
dir_config_rec *d = d_;
return NULL;
}
static const command_rec dir_cmds[] =
{
"a list of file names"),
"On or Off"),
{NULL}
};
{
return (void *) new;
}
{
return new;
}
static int fixup_dir(request_rec *r)
{
dir_config_rec *d;
char *dummy_ptr[1];
char **names_ptr;
int num_names;
int error_notfound = 0;
/* only handle requests against directories */
return DECLINED;
}
/* In case mod_mime wasn't present, and no handler was assigned. */
if (!r->handler) {
r->handler = DIR_MAGIC_TYPE;
}
/* Never tolerate path_info on dir requests */
return DECLINED;
}
&dir_module);
/* Redirect requests that are not '/' terminated */
{
char *ifile;
if (!d->do_slash) {
return DECLINED;
}
/* Only redirect non-get requests if we have no note to warn
* that this browser cannot handle redirs on non-GET requests
* (such as Microsoft's WebFolders).
*/
if ((r->method_number != M_GET)
return DECLINED;
}
}
else {
"/", NULL);
}
return HTTP_MOVED_PERMANENTLY;
}
if (d->index_names) {
}
else {
dummy_ptr[0] = AP_DEFAULT_INDEX;
num_names = 1;
}
/* XXX: Is this name_ptr considered escaped yet, or not??? */
/* Once upon a time args were handled _after_ the successful redirect.
* But that redirect might then _refuse_ the given r->args, creating
* a nasty tangle. It seems safer to consider the r->args while we
* determine if name_ptr is our viable index, and therefore set them
* up correctly on redirect.
*/
}
/* The sub request lookup is very liberal, and the core map_to_storage
* handler will almost always result in HTTP_OK as /foo/index.html
* may be /foo with PATH_INFO="/index.html", or even / with
* PATH_INFO="/foo/index.html". To get around this we insist that the
* the index be a regular filetype.
*
* Another reason is that the core handler also makes the assumption
* that if r->finfo is still NULL by the time it gets called, the
* file does not exist.
*/
return OK;
}
/* If the request returned a redirect, propagate it to the client */
rr->headers_out);
return error_notfound;
}
/* If the request returned something other than 404 (or 200),
* it means the module encountered some sort of problem. To be
* secure, we should return the error, rather than allow autoindex
* to create a (possibly unsafe) directory index.
*
* So we store the error, and if none of the listed files
* exist, we return the last error response we got, instead
* of a directory listing.
*/
}
}
if (error_notfound) {
return error_notfound;
}
/* nothing for us to do, pass on through */
return DECLINED;
}
static void register_hooks(apr_pool_t *p)
{
}
create_dir_config, /* create per-directory config structure */
merge_dir_configs, /* merge per-directory config structures */
NULL, /* create per-server config structure */
NULL, /* merge per-server config structures */
dir_cmds, /* command apr_table_t */
register_hooks /* register hooks */
};