summaryrefslogtreecommitdiff
path: root/modules/mappers/mod_dir.c
diff options
context:
space:
mode:
Diffstat (limited to 'modules/mappers/mod_dir.c')
-rw-r--r--modules/mappers/mod_dir.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/modules/mappers/mod_dir.c b/modules/mappers/mod_dir.c
index 4364ff95..2a359c7f 100644
--- a/modules/mappers/mod_dir.c
+++ b/modules/mappers/mod_dir.c
@@ -29,21 +29,23 @@
#include "http_log.h"
#include "http_main.h"
#include "util_script.h"
+#include "mod_rewrite.h"
module AP_MODULE_DECLARE_DATA dir_module;
typedef enum {
- SLASH_OFF = 0,
- SLASH_ON,
- SLASH_UNSET
-} slash_cfg;
+ MODDIR_OFF = 0,
+ MODDIR_ON,
+ MODDIR_UNSET
+} moddir_cfg;
#define REDIRECT_OFF 0
#define REDIRECT_UNSET 1
typedef struct dir_config_struct {
apr_array_header_t *index_names;
- slash_cfg do_slash;
+ moddir_cfg do_slash;
+ moddir_cfg checkhandler;
int redirect_index;
const char *dflt;
} dir_config_rec;
@@ -66,7 +68,7 @@ static const char *add_index(cmd_parms *cmd, void *dummy, const char *arg)
/* peek to see if "disabled" is first in a series of arguments */
const char *tt = t;
const char *ww = ap_getword_conf(cmd->temp_pool, &tt);
- if (ww == NULL || !ww[0]) {
+ if (ww[0] == '\0') {
/* "disabled" is first, and alone */
apr_array_clear(d->index_names);
break;
@@ -83,7 +85,14 @@ static const char *configure_slash(cmd_parms *cmd, void *d_, int arg)
{
dir_config_rec *d = d_;
- d->do_slash = arg ? SLASH_ON : SLASH_OFF;
+ d->do_slash = arg ? MODDIR_ON : MODDIR_OFF;
+ return NULL;
+}
+static const char *configure_checkhandler(cmd_parms *cmd, void *d_, int arg)
+{
+ dir_config_rec *d = d_;
+
+ d->checkhandler = arg ? MODDIR_ON : MODDIR_OFF;
return NULL;
}
static const char *configure_redirect(cmd_parms *cmd, void *d_, const char *arg1)
@@ -123,6 +132,8 @@ static const command_rec dir_cmds[] =
"a list of file names"),
AP_INIT_FLAG("DirectorySlash", configure_slash, NULL, DIR_CMD_PERMS,
"On or Off"),
+ AP_INIT_FLAG("DirectoryCheckHandler", configure_checkhandler, NULL, DIR_CMD_PERMS,
+ "On or Off"),
AP_INIT_TAKE1("DirectoryIndexRedirect", configure_redirect,
NULL, DIR_CMD_PERMS, "On, Off, or a 3xx status code."),
@@ -134,7 +145,8 @@ static void *create_dir_config(apr_pool_t *p, char *dummy)
dir_config_rec *new = apr_pcalloc(p, sizeof(dir_config_rec));
new->index_names = NULL;
- new->do_slash = SLASH_UNSET;
+ new->do_slash = MODDIR_UNSET;
+ new->checkhandler = MODDIR_UNSET;
new->redirect_index = REDIRECT_UNSET;
return (void *) new;
}
@@ -147,7 +159,9 @@ static void *merge_dir_configs(apr_pool_t *p, void *basev, void *addv)
new->index_names = add->index_names ? add->index_names : base->index_names;
new->do_slash =
- (add->do_slash == SLASH_UNSET) ? base->do_slash : add->do_slash;
+ (add->do_slash == MODDIR_UNSET) ? base->do_slash : add->do_slash;
+ new->checkhandler =
+ (add->checkhandler == MODDIR_UNSET) ? base->checkhandler : add->checkhandler;
new->redirect_index=
(add->redirect_index == REDIRECT_UNSET) ? base->redirect_index : add->redirect_index;
new->dflt = add->dflt ? add->dflt : base->dflt;
@@ -260,6 +274,15 @@ static int fixup_dir(request_rec *r)
return HTTP_MOVED_PERMANENTLY;
}
+ /* we're running between mod_rewrites fixup and its internal redirect handler, step aside */
+ if (!strcmp(r->handler, REWRITE_REDIRECT_HANDLER_NAME)) {
+ return DECLINED;
+ }
+
+ if (d->checkhandler == MODDIR_ON && strcmp(r->handler, DIR_MAGIC_TYPE)) {
+ return DECLINED;
+ }
+
if (d->index_names) {
names_ptr = (char **)d->index_names->elts;
num_names = d->index_names->nelts;