httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew <and...@aaaaaaaa.demon.co.uk>
Subject mod_env.c 0.0.5, UnsetEnv
Date Sat, 24 Feb 1996 17:42:25 GMT
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.

Mime
View raw message