You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by co...@locus.apache.org on 2000/06/05 18:08:22 UTC
cvs commit: apache-1.3/src/modules/standard mod_setenvif.c
coar 00/06/05 09:08:20
Modified: . STATUS
htdocs/manual/mod mod_setenvif.html
src CHANGES
src/modules/standard mod_setenvif.c
Log:
Make the SetEnvIf* and BrowserMatch* diectives usable in
.htaccess files.
PR: 3000
Revision Changes Path
1.823 +1 -4 apache-1.3/STATUS
Index: STATUS
===================================================================
RCS file: /home/cvs/apache-1.3/STATUS,v
retrieving revision 1.822
retrieving revision 1.823
diff -u -u -r1.822 -r1.823
--- STATUS 2000/06/04 02:48:00 1.822
+++ STATUS 2000/06/05 16:08:09 1.823
@@ -1,5 +1,5 @@
1.3 STATUS:
- Last modified at [$Date: 2000/06/04 02:48:00 $]
+ Last modified at [$Date: 2000/06/05 16:08:09 $]
Release:
@@ -42,9 +42,6 @@
- short/long name handling (?)
- better status page on current state of NT for users
> Basic answer the the last one - 2.0 is coming
-
- * Get the mod_setenvif change in for 1.3.13
- Ken Coar is working on this
* Complete the security hole in stat() by testing for anything
other than conventional file-not-found, permission-denied errors
1.9 +13 -9 apache-1.3/htdocs/manual/mod/mod_setenvif.html
Index: mod_setenvif.html
===================================================================
RCS file: /home/cvs/apache-1.3/htdocs/manual/mod/mod_setenvif.html,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -u -r1.8 -r1.9
--- mod_setenvif.html 2000/03/01 20:26:07 1.8
+++ mod_setenvif.html 2000/06/05 16:08:13 1.9
@@ -59,17 +59,18 @@
<A
HREF="directive-dict.html#Default"
REL="Help"
- ><STRONG>Default:</STRONG></A> <EM>none</EM>
+ ><STRONG>Default:</STRONG></A> <i>none</i>
<BR>
<A
HREF="directive-dict.html#Context"
REL="Help"
- ><STRONG>Context:</STRONG></A> server config
+ ><STRONG>Context:</STRONG></A> server config, virtual host, directory,
+ .htaccess
<BR>
<A
HREF="directive-dict.html#Override"
REL="Help"
- ><STRONG>Override:</STRONG></A> <EM>none</EM>
+ ><STRONG>Override:</STRONG></A> FileInfo
<BR>
<A
HREF="directive-dict.html#Status"
@@ -166,12 +167,13 @@
<A
HREF="directive-dict.html#Context"
REL="Help"
- ><STRONG>Context:</STRONG></A> server config
+ ><STRONG>Context:</STRONG></A> server config, virtual host, directory,
+ .htaccess
<BR>
<A
HREF="directive-dict.html#Override"
REL="Help"
- ><STRONG>Override:</STRONG></A> <EM>none</EM>
+ ><STRONG>Override:</STRONG></A> FileInfo
<BR>
<A
HREF="directive-dict.html#Status"
@@ -240,12 +242,13 @@
<A
HREF="directive-dict.html#Context"
REL="Help"
- ><STRONG>Context:</STRONG></A> server config
+ ><STRONG>Context:</STRONG></A> server config, virtual host, directory,
+ .htaccess
<BR>
<A
HREF="directive-dict.html#Override"
REL="Help"
- ><STRONG>Override:</STRONG></A> <EM>none</EM>
+ ><STRONG>Override:</STRONG></A> FileInfo
<BR>
<A
HREF="directive-dict.html#Status"
@@ -351,12 +354,13 @@
<A
HREF="directive-dict.html#Context"
REL="Help"
- ><STRONG>Context:</STRONG></A> server config
+ ><STRONG>Context:</STRONG></A> server config, virtual host, directory,
+ .htaccess
<BR>
<A
HREF="directive-dict.html#Override"
REL="Help"
- ><STRONG>Override:</STRONG></A> <EM>none</EM>
+ ><STRONG>Override:</STRONG></A> FileInfo
<BR>
<A
HREF="directive-dict.html#Status"
1.1547 +4 -0 apache-1.3/src/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apache-1.3/src/CHANGES,v
retrieving revision 1.1546
retrieving revision 1.1547
diff -u -u -r1.1546 -r1.1547
--- CHANGES 2000/06/03 00:11:09 1.1546
+++ CHANGES 2000/06/05 16:08:15 1.1547
@@ -1,5 +1,9 @@
Changes with Apache 1.3.13
+ *) Expand mod_setenvif so its directives can be used in <Files> and
+ <Directory> containers, and in .htaccess files when FileInfo
+ overriding is allowed. PR#3000 [Ken Coar]
+
*) Fix Win32 bug when pathname length exactly equals MAX_PATH.
This bug caused directory index to be displayed rather than
returning an error. [Allan Edwards <ak...@raleigh.ibm.com>]
1.30 +52 -16 apache-1.3/src/modules/standard/mod_setenvif.c
Index: mod_setenvif.c
===================================================================
RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_setenvif.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -u -r1.29 -r1.30
--- mod_setenvif.c 1999/06/04 18:40:00 1.29
+++ mod_setenvif.c 2000/06/05 16:08:18 1.30
@@ -145,7 +145,16 @@
module MODULE_VAR_EXPORT setenvif_module;
-static void *create_setenvif_config(pool *p, server_rec *dummy)
+/*
+ * These routines, the create- and merge-config functions, are called
+ * for both the server-wide and the per-directory contexts. This is
+ * because the different definitions are used at different times; the
+ * server-wide ones are used in the post-read-request phase, and the
+ * per-directory ones are used during the header-parse phase (after
+ * the URI has been mapped to a file and we have anything from the
+ * .htaccess file and <Directory> and <Files> containers).
+ */
+static void *create_setenvif_config(pool *p, char *dummy)
{
sei_cfg_rec *new = (sei_cfg_rec *) ap_palloc(p, sizeof(sei_cfg_rec));
@@ -163,24 +172,36 @@
return a;
}
-/* any non-NULL magic constant will do... used to indicate if REG_ICASE should
+/*
+ * any non-NULL magic constant will do... used to indicate if REG_ICASE should
* be used
*/
#define ICASE_MAGIC ((void *)(&setenvif_module))
+#define SEI_MAGIC_HEIRLOOM "setenvif-phase-flag"
static const char *add_setenvif_core(cmd_parms *cmd, void *mconfig,
char *fname, const char *args)
{
char *regex;
const char *feature;
- sei_cfg_rec *sconf = ap_get_module_config(cmd->server->module_config,
- &setenvif_module);
- sei_entry *new, *entries = (sei_entry *) sconf->conditionals->elts;
+ sei_cfg_rec *sconf;
+ sei_entry *new;
+ sei_entry *entries;
char *var;
int i;
int beenhere = 0;
unsigned icase;
+ /*
+ * Determine from our context into which record to put the entry.
+ * cmd->path == NULL means we're in server-wide context; otherwise,
+ * we're dealing with a per-directory setting.
+ */
+ sconf = (cmd->path != NULL)
+ ? (sei_cfg_rec *) mconfig
+ : (sei_cfg_rec *) ap_get_module_config(cmd->server->module_config,
+ &setenvif_module);
+ entries = (sei_entry *) sconf->conditionals->elts;
/* get regex */
regex = ap_getword_conf(cmd->pool, &args);
if (!*regex) {
@@ -202,7 +223,7 @@
}
}
- /* if the last entry has an idential headername and regex then
+ /* if the last entry has an identical headername and regex then
* merge with it
*/
i = sconf->conditionals->nelts - 1;
@@ -307,19 +328,27 @@
static const command_rec setenvif_module_cmds[] =
{
{ "SetEnvIf", add_setenvif, NULL,
- RSRC_CONF, RAW_ARGS, "A header-name, regex and a list of variables." },
+ OR_FILEINFO, RAW_ARGS, "A header-name, regex and a list of variables." },
{ "SetEnvIfNoCase", add_setenvif, ICASE_MAGIC,
- RSRC_CONF, RAW_ARGS, "a header-name, regex and a list of variables." },
+ OR_FILEINFO, RAW_ARGS, "a header-name, regex and a list of variables." },
{ "BrowserMatch", add_browser, NULL,
- RSRC_CONF, RAW_ARGS, "A browser regex and a list of variables." },
+ OR_FILEINFO, RAW_ARGS, "A browser regex and a list of variables." },
{ "BrowserMatchNoCase", add_browser, ICASE_MAGIC,
- RSRC_CONF, RAW_ARGS, "A browser regex and a list of variables." },
+ OR_FILEINFO, RAW_ARGS, "A browser regex and a list of variables." },
{ NULL },
};
+/*
+ * This routine gets called at two different points in request processing:
+ * once before the URI has been translated (during the post-read-request
+ * phase) and once after (during the header-parse phase). We use different
+ * config records for the two different calls to reduce overhead (by not
+ * re-doing the server-wide settings during directory processing), and
+ * signal which call it is by having the earlier one pass a flag to the
+ * later one.
+ */
static int match_headers(request_rec *r)
{
- server_rec *s = r->server;
sei_cfg_rec *sconf;
sei_entry *entries;
table_entry *elts;
@@ -327,8 +356,15 @@
int i, j;
char *last_name;
- sconf = (sei_cfg_rec *) ap_get_module_config(s->module_config,
- &setenvif_module);
+ if (ap_table_get(r->notes, SEI_MAGIC_HEIRLOOM) == NULL) {
+ ap_table_set(r->notes, SEI_MAGIC_HEIRLOOM, "post-read done");
+ sconf = (sei_cfg_rec *) ap_get_module_config(r->server->module_config,
+ &setenvif_module);
+ }
+ else {
+ sconf = (sei_cfg_rec *) ap_get_module_config(r->per_dir_config,
+ &setenvif_module);
+ }
entries = (sei_entry *) sconf->conditionals->elts;
last_name = NULL;
val = NULL;
@@ -403,8 +439,8 @@
{
STANDARD_MODULE_STUFF,
NULL, /* initializer */
- NULL, /* dir config creater */
- NULL, /* dir merger --- default is to override */
+ create_setenvif_config, /* dir config creater */
+ merge_setenvif_config, /* dir merger --- default is to override */
create_setenvif_config, /* server config */
merge_setenvif_config, /* merge server configs */
setenvif_module_cmds, /* command table */
@@ -416,7 +452,7 @@
NULL, /* type_checker */
NULL, /* fixups */
NULL, /* logger */
- NULL, /* input header parse */
+ match_headers, /* input header parse */
NULL, /* child (process) initialization */
NULL, /* child (process) rundown */
match_headers /* post_read_request */