You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Andrew <an...@aaaaaaaa.demon.co.uk> on 1996/02/24 18:42:25 UTC

mod_env.c 0.0.5, UnsetEnv

Hi,

	http://www.apache.org/dist/contrib/modules/mod_env.c

has been upgraded to version 0.0.5 and tested against Apache versions
1.0.3 and 1.1b0.  Virtual hosts now 'inherit' all the environment
variables specified for the default server and are then able to
add, override and remove variables selectively to tune their own
environment.

For example, consider the following fragment of a configuration
file:

        # default server environment
        PassEnv FOO
        SetEnv SPECIAL 123

        # virtual host environments
        <VirtualHost www.some.host>
        SetEnv SPECIAL "some quoted string"
        <VirtualHost>

        <VirtualHost www.another.host>
        PassEnv BAR
        UnsetEnv SPECIAL
        <VirtualHost>

CGI scripts running under the default server see the variables
'FOO' and 'SPECIAL', where FOO is set in the environment of the
shell which invoked httpd.

The virtual host www.some.host inherits 'FOO' from the default
server's configuration and overrides the value of 'SPECIAL'.  

The virtual host www.another.host imports the variable 'BAR' from
the environment of the shell which invoked httpd.  Note that the
default server didn't do this, so the variable couldn't be inherited
from the default server by www.another.host .  In addition, the
variable 'SPECIAL' is removed from the environment by the new
directive 'UnsetEnv'.  The semantics of UnsetEnv are the same as
for ordinary UNIX shells.

*** Note that the way that virtual hosts inherit their environment 
    variables from the default server's configuration has changed.
    You should test your configuration carefully before accepting
    this version of the module in a live webserver which used older
    versions of the module.

---

On a technical point.  The UnsetEnv directive uses the function
mod_env_table_unset() which completely removes an element
from a table and seems to be something which Apache hasn't needed
to do before.  There are a number of ways to do this and mets()
chooses the easiest way out.  A more efficient implementation could
identify the element to be deleted and then perform a bcopy() to
shift the remaining elements on top of it.  Alternatively, comments
in other parts of the server hint that using a key of NULL could
indicate that an element has been deleted, though this would need
a slight recoding of some of the routines in alloc.c

As it stands, mod_env_table_unset() could be renamed table_unset()
and moved to alloc.c, but I thought I'd wait till mod_env.c survives
a couple more weeks without breaking before working up a patch.

Cheers,
Ay.

Re: mod_env.c 0.0.5, UnsetEnv

Posted by Alexei Kosut <ak...@nueva.pvt.k12.ca.us>.
On Sat, 24 Feb 1996, Andrew wrote:

> has been upgraded to version 0.0.5 and tested against Apache versions
> 1.0.3 and 1.1b0.  Virtual hosts now 'inherit' all the environment
> variables specified for the default server and are then able to
> add, override and remove variables selectively to tune their own
> environment.

Sounds good. Haven't gotten a chance to try it yet, but I would like to 
see this module part of the 1.1 distribtuion. Andrew, do you have any 
problems with that? Certainly, if there are any bugs, they'll have a 
chance to get fixed, but I think it's a useful module. Useful enough to 
come standard with the server, I think.

--// Alexei Kosut // <ak...@nueva.pvt.k12.ca.us> // Lefler on IRC --//
-----------------// <http://www.nueva.pvt.k12.ca.us/~akosut> -------// 
"To get the full affect of Pat Buchanan's speeches, they should be
read in the original German." //--------------------------------------