--- apache_1.3.6_orig/src/modules/standard/mod_setenvif.c.orig Sun May 30 19:54:19 1999 +++ apache_1.3.6/src/modules/standard/mod_setenvif.c Sun May 30 21:29:07 1999 @@ -136,6 +136,7 @@ enum special, special_type,4); unsigned icase : 1; /* ignoring case? */ + unsigned requiressl; /* do we require ssl? */ } sei_entry; typedef struct { @@ -168,7 +169,7 @@ #define ICASE_MAGIC ((void *)(&setenvif_module)) static const char *add_setenvif_core(cmd_parms *cmd, void *mconfig, - char *fname, const char *args) + char *fname, const char *args, int requiressl) { char *regex; const char *feature; @@ -209,6 +210,7 @@ if (i < 0 || entries[i].name != fname || entries[i].icase != icase + || entries[i].requiressl != requiressl || strcmp(entries[i].regex, regex)) { /* no match, create a new entry */ @@ -217,6 +219,7 @@ new->name = fname; new->regex = regex; new->icase = icase; + new->requiressl = requiressl; new->preg = ap_pregcomp(cmd->pool, regex, (REG_EXTENDED | REG_NOSUB | (icase ? REG_ICASE : 0))); @@ -287,7 +290,21 @@ return ap_pstrcat(cmd->pool, "Missing header-field name for ", cmd->cmd->name, NULL); } - return add_setenvif_core(cmd, mconfig, fname, args); + return add_setenvif_core(cmd, mconfig, fname, args, 0); +} + +static const char *add_sslsetenvif(cmd_parms *cmd, void *mconfig, + const char *args) +{ + char *fname; + + /* get header name */ + fname = ap_getword_conf(cmd->pool, &args); + if (!*fname) { + return ap_pstrcat(cmd->pool, "Missing header-field name for ", + cmd->cmd->name, NULL); + } + return add_setenvif_core(cmd, mconfig, fname, args, 1); } /* @@ -297,7 +314,7 @@ */ static const char *add_browser(cmd_parms *cmd, void *mconfig, const char *args) { - return add_setenvif_core(cmd, mconfig, "User-Agent", args); + return add_setenvif_core(cmd, mconfig, "User-Agent", args, 0); } static const command_rec setenvif_module_cmds[] = @@ -310,6 +327,10 @@ RSRC_CONF, 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." }, + { "SSLSetEnvIf", add_sslsetenvif, NULL, + RSRC_CONF, RAW_ARGS, "A header-name, regex and a list of variables." }, + { "SSLSetEnvIfNoCase", add_sslsetenvif, ICASE_MAGIC, + RSRC_CONF, RAW_ARGS, "a header-name, regex and a list of variables." }, { NULL }, }; @@ -322,7 +343,9 @@ const char *val; int i, j; char *last_name; + int ssl; + ssl = ap_ctx_get(r->connection->client->ctx, "ssl") != NULL; sconf = (sei_cfg_rec *) ap_get_module_config(s->module_config, &setenvif_module); entries = (sei_entry *) sconf->conditionals->elts; @@ -371,7 +394,7 @@ val = ""; } - if (!regexec(b->preg, val, 0, NULL, 0)) { + if (!regexec(b->preg, val, 0, NULL, 0) && (!b->requiressl || ssl)) { array_header *arr = ap_table_elts(b->features); elts = (table_entry *) arr->elts;