mod_env.c revision fd0edaa8e3d4dd67d0604ccef2e96b071db96643
8a77240a809197c92c0736c431b4b88947a7bac1Christian Maeder/* ====================================================================
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * Copyright (c) 1995-1999 The Apache Group. All rights reserved.
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder *
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder * Redistribution and use in source and binary forms, with or without
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder * modification, are permitted provided that the following conditions
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder * are met:
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder *
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu Prodescu * 1. Redistributions of source code must retain the above copyright
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * notice, this list of conditions and the following disclaimer.
6820f0de92751e29d73d64db48e776591f529a76Christian Maeder *
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * 2. Redistributions in binary form must reproduce the above copyright
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * notice, this list of conditions and the following disclaimer in
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * the documentation and/or other materials provided with the
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * distribution.
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder *
6820f0de92751e29d73d64db48e776591f529a76Christian Maeder * 3. All advertising materials mentioning features or use of this
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * software must display the following acknowledgment:
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * "This product includes software developed by the Apache Group
6820f0de92751e29d73d64db48e776591f529a76Christian Maeder * for use in the Apache HTTP server project (http://www.apache.org/)."
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder *
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * 4. The names "Apache Server" and "Apache Group" must not be used to
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * endorse or promote products derived from this software without
6820f0de92751e29d73d64db48e776591f529a76Christian Maeder * prior written permission. For written permission, please contact
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * apache@apache.org.
6820f0de92751e29d73d64db48e776591f529a76Christian Maeder *
6820f0de92751e29d73d64db48e776591f529a76Christian Maeder * 5. Products derived from this software may not be called "Apache"
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * nor may "Apache" appear in their names without prior written
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * permission of the Apache Group.
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder *
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * 6. Redistributions of any form whatsoever must retain the following
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * acknowledgment:
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * "This product includes software developed by the Apache Group
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * for use in the Apache HTTP server project (http://www.apache.org/)."
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder *
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * IT'S CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
c56a356d3fcc5e123efa790aab320781d94df3c7Jonathan von Schroeder * OF THE POSSIBILITY OF SUCH DAMAGE.
c56a356d3fcc5e123efa790aab320781d94df3c7Jonathan von Schroeder * ====================================================================
c56a356d3fcc5e123efa790aab320781d94df3c7Jonathan von Schroeder *
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * This software consists of voluntary contributions made by many
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * individuals on behalf of the Apache Group and was originally based
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * on public domain software written at the National Center for
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * Supercomputing Applications, University of Illinois, Urbana-Champaign.
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * For more information on the Apache Group and the Apache HTTP server
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * project, please see <http://www.apache.org/>.
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder *
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder */
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder/*
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * mod_env.c
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * version 0.0.5
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * status beta
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * Pass environment variables to CGI/SSI scripts.
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder *
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * Andrew Wilson <Andrew.Wilson@cm.cf.ac.uk> 06.Dec.95
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder *
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * Change log:
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * 08.Dec.95 Now allows PassEnv directive to appear more than once in
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * conf files.
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * 10.Dec.95 optimisation. getenv() only called at startup and used
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * to build a fast-to-access table. table used to build
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * per-server environment for each request.
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * robustness. better able to handle errors in configuration
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * files:
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * 1) PassEnv directive present, but no environment variable listed
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * 2) PassEnv FOO present, but $FOO not present in environment
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * 3) no PassEnv directive present
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * 23.Dec.95 Now allows SetEnv directive with same semantics as 'sh' setenv:
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * SetEnv Var sets Var to the empty string
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * SetEnv Var Val sets Var to the value Val
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * Values containing whitespace should be quoted, eg:
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * SetEnv Var "this is some text"
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * Environment variables take their value from the last instance
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * of PassEnv / SetEnv to be reached in the configuration file.
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * For example, the sequence:
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * PassEnv FOO
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * SetEnv FOO override
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * Causes FOO to take the value 'override'.
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * 23.Feb.96 Added UnsetEnv directive to allow environment variables
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * to be removed.
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * Virtual hosts now 'inherit' parent server environment which
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder * they're able to overwrite with their own directives or
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder * selectively ignore with UnsetEnv.
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * *** IMPORTANT - the way that virtual hosts inherit their ***
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * *** environment variables from the default server's ***
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * *** configuration has changed. You should test your ***
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * *** configuration carefully before accepting this ***
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * *** version of the module in a live webserver which used ***
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * *** older versions of the module. ***
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder */
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder#include "httpd.h"
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder#include "http_config.h"
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder#include "http_request.h"
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroedertypedef struct {
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder table *vars;
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder char *unsetenv;
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder int vars_present;
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder} env_dir_config_rec;
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroedermodule MODULE_VAR_EXPORT env_module;
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroederstatic void *create_env_dir_config(pool *p, char *dummy)
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder{
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder env_dir_config_rec *new =
c56a356d3fcc5e123efa790aab320781d94df3c7Jonathan von Schroeder (env_dir_config_rec *) ap_palloc(p, sizeof(env_dir_config_rec));
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder new->vars = ap_make_table(p, 50);
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder new->unsetenv = "";
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder new->vars_present = 0;
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder return (void *) new;
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder}
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroederstatic void *merge_env_dir_configs(pool *p, void *basev, void *addv)
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder{
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder env_dir_config_rec *base = (env_dir_config_rec *) basev;
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder env_dir_config_rec *add = (env_dir_config_rec *) addv;
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder env_dir_config_rec *new =
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder (env_dir_config_rec *) ap_palloc(p, sizeof(env_dir_config_rec));
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder table *new_table;
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder table_entry *elts;
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder array_header *arr;
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder int i;
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder const char *uenv, *unset;
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder /*
80d2ec8f37d5ddec13c14b17b1bab01e9c94630aChristian Maeder * new_table = copy_table( p, base->vars );
a669e4685b32ff5ca1bca785eacc5e30a545b010Christian Maeder * foreach $element ( @add->vars ) {
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder * table_set( new_table, $element.key, $element.val );
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder * };
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * foreach $unsetenv ( @UNSETENV ) {
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder * table_unset( new_table, $unsetenv );
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder * }
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder */
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder new_table = ap_copy_table(p, base->vars);
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder arr = ap_table_elts(add->vars);
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder elts = (table_entry *)arr->elts;
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder for (i = 0; i < arr->nelts; ++i) {
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder ap_table_setn(new_table, elts[i].key, elts[i].val);
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder }
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder unset = add->unsetenv;
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder uenv = ap_getword_conf(p, &unset);
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder while (uenv[0] != '\0') {
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder ap_table_unset(new_table, uenv);
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder uenv = ap_getword_conf(p, &unset);
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder }
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder new->vars = new_table;
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder new->vars_present = base->vars_present || add->vars_present;
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder return new;
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder}
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroederstatic const char *add_env_module_vars_passed(cmd_parms *cmd,
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder env_dir_config_rec *sconf,
ece3b1a5353a9af3c966a1d5453594ed35334f7bJonathan von Schroeder const char *arg)
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder{
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder table *vars = sconf->vars;
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder char *env_var;
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder char *name_ptr;
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder while (*arg) {
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder name_ptr = ap_getword_conf(cmd->pool, &arg);
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder env_var = getenv(name_ptr);
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder if (env_var != NULL) {
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder sconf->vars_present = 1;
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder ap_table_setn(vars, name_ptr, ap_pstrdup(cmd->pool, env_var));
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder }
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder }
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder return NULL;
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder}
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroederstatic const char *add_env_module_vars_set(cmd_parms *cmd,
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder env_dir_config_rec *sconf,
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder const char *arg)
d71447e45047d07006b4c20409fbd8ea287df01fJonathan von Schroeder{
b35e053c2c5a5ea0f13decfd0303894861d82b4dJonathan von Schroeder table *vars = sconf->vars;
char *name, *value;
name = ap_getword_conf(cmd->pool, &arg);
value = ap_getword_conf(cmd->pool, &arg);
/* name is mandatory, value is optional. no value means
* set the variable to an empty string
*/
if ((*name == '\0') || (*arg != '\0')) {
return "SetEnv takes one or two arguments. An environment variable name and an optional value to pass to CGI.";
}
sconf->vars_present = 1;
ap_table_setn(vars, name, value);
return NULL;
}
static const char *add_env_module_vars_unset(cmd_parms *cmd,
env_dir_config_rec *sconf,
char *arg)
{
sconf->unsetenv = sconf->unsetenv ?
ap_pstrcat(cmd->pool, sconf->unsetenv, " ", arg, NULL) :
arg;
return NULL;
}
static const command_rec env_module_cmds[] =
{
{"PassEnv", add_env_module_vars_passed, NULL,
OR_FILEINFO, RAW_ARGS, "a list of environment variables to pass to CGI."},
{"SetEnv", add_env_module_vars_set, NULL,
OR_FILEINFO, RAW_ARGS, "an environment variable name and a value to pass to CGI."},
{"UnsetEnv", add_env_module_vars_unset, NULL,
OR_FILEINFO, RAW_ARGS, "a list of variables to remove from the CGI environment."},
{NULL},
};
static int fixup_env_module(request_rec *r)
{
table *e = r->subprocess_env;
env_dir_config_rec *sconf = ap_get_module_config(r->per_dir_config,
&env_module);
table *vars = sconf->vars;
if (!sconf->vars_present)
return DECLINED;
r->subprocess_env = ap_overlay_tables(r->pool, e, vars);
return OK;
}
static void register_hooks(void)
{
ap_hook_fixups(fixup_env_module,NULL,NULL,HOOK_MIDDLE);
}
module MODULE_VAR_EXPORT env_module =
{
STANDARD20_MODULE_STUFF,
create_env_dir_config, /* dir config creater */
merge_env_dir_configs, /* dir merger --- default is to override */
NULL, /* server config */
NULL, /* merge server configs */
env_module_cmds, /* command table */
NULL, /* handlers */
register_hooks /* register hooks */
};