httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremie Miller <jmil...@subcellar.mwci.net>
Subject Re: mod_env
Date Sun, 03 Nov 1996 04:19:02 GMT
Sorry, ben had earlier brought up the possibility of making SetEnv 
work within a <Directory>, so I attempted to make the change and mailed 
him the patch.  Since you were listed in the source I CC'd you.

I didn't post it directly to the list since it was my first hack to 
apache, and first real C in years, and I was queasy 'bout the patch.

Sorry about the confusion, I will be more clear next time.

Jeremie Miller
jmiller@mwci.net

On Sun, 3 Nov 1996, Andrew Wilson wrote:

> Will someone *please* tell me what is going on here?  Perhaps I'm
> missing a day's installment of apache@91210...
> 
> Ay.
> 
> > > > > What else is involved with this besides changing the RSRC_CONF to

> > > > > OR_ALL to accomplish this.  Again, I am not the best at c, that is
why I am asking.
> > > > 
> > > > You have to store the info in the per-dir config instead of the per-server
> > > > config.
> > > > 
> > > > Cheers,
> > > > 
> > > > Ben.
> > > 
> > > I see that, and after playing with it, I seem to have found a 
> > > great talent for generating core dumps!  I don't think my C is robust 
> > > enough for this, but I am going to print it all out and visit the 
> > > Lazyboy for some time, then see what I can pull off.
> > 
> > OK, I thuroughly enjoyed learning apache, anyway, I think this patch 
> > will do it, if I am in err, please let me know.  If all my tests go 
> > ok, I may post it to new-httpd.  It dooesn't seem like it will affect 
> > any existing configurations, but I may be wrong!
> > 
> > Thanks for you help!
> > 
> > Jeremie Miller
> > jmiller@mwci.net
> > 
> > 
> > 
> > *** mod_env.c.orig	Sat Nov  2 15:33:29 1996
> > --- mod_env.c	Sat Nov  2 15:46:53 1996
> > ***************
> > *** 91,96 ****
> > --- 91,98 ----
> >    *       *** configuration carefully before accepting this       
> >    *** *       *** version of the module in a live webserver which
> >    used *** *	 *** older versions of the module.                      
> >     ***
> > +  * 02.Nov.96 Changed structures to per-dir config. 
> > +  *           Jeremie Miller <jmiller@mwci.net>
> >    */
> > 
> >   #include "httpd.h"
> > ***************
> > *** 100,125 ****
> >       table *vars;
> >       char *unsetenv;
> >       int vars_present;
> > ! } env_server_config_rec;
> > 
> >   module env_module;
> > 
> > ! void *create_env_server_config (pool *p, server_rec *dummy)
> >   {
> > !     env_server_config_rec *new =
> > !       (env_server_config_rec *) palloc (p,
> > !       sizeof(env_server_config_rec));
> >       new->vars = make_table (p, 50);
> >       new->unsetenv = "";
> >       new->vars_present = 0;
> >       return (void *) new;
> >   }
> > 
> > ! void *merge_env_server_configs (pool *p, void *basev, void *addv)
> >   {
> > !     env_server_config_rec *base = (env_server_config_rec *)basev;
> > !     env_server_config_rec *add = (env_server_config_rec *)addv;
> > !     env_server_config_rec *new =
> > !       (env_server_config_rec *)palloc (p,
> > !       sizeof(env_server_config_rec));
> > 
> >       table *new_table;
> >       table_entry *elts;
> > --- 102,127 ----
> >       table *vars;
> >       char *unsetenv;
> >       int vars_present;
> > ! } env_dir_config_rec;
> > 
> >   module env_module;
> > 
> > ! void *create_env_dir_config (pool *p, char *dummy)
> >   {
> > !     env_dir_config_rec *new =
> > !       (env_dir_config_rec *) palloc (p, sizeof(env_dir_config_rec));
> >       new->vars = make_table (p, 50);
> >       new->unsetenv = "";
> >       new->vars_present = 0;
> >       return (void *) new;
> >   }
> > 
> > ! void *merge_env_dir_configs (pool *p, void *basev, void *addv)
> >   {
> > !     env_dir_config_rec *base = (env_dir_config_rec *)basev;
> > !     env_dir_config_rec *add = (env_dir_config_rec *)addv;
> > !     env_dir_config_rec *new =
> > !       (env_dir_config_rec *)palloc (p, sizeof(env_dir_config_rec));
> > 
> >       table *new_table;
> >       table_entry *elts;
> > ***************
> > *** 159,170 ****
> >       return new;
> >   }
> > 
> > ! const char *add_env_module_vars_passed (cmd_parms *cmd, char
> > ! *struct_ptr,
> >         const char *arg)
> >   {
> > !     env_server_config_rec *sconf =
> > !       get_module_config (cmd->server->module_config, &env_module);
> > !     table *vars = sconf->vars;
> >       char *env_var;
> >       char *name_ptr;
> > 
> > --- 161,170 ----
> >       return new;
> >   }
> > 
> > ! const char *add_env_module_vars_passed (cmd_parms *cmd,
> > ! env_dir_config_rec *dconf,
> >         const char *arg)
> >   {
> > !     table *vars = dconf->vars;
> >       char *env_var;
> >       char *name_ptr;
> > 
> > ***************
> > *** 172,190 ****
> >           name_ptr = getword_conf (cmd->pool, &arg);
> >           env_var = getenv(name_ptr);
> >           if ( env_var != NULL ) { 
> > !             sconf->vars_present = 1;
> >               table_set (vars, name_ptr, env_var);
> >           }
> >       }
> >       return NULL;
> >   }
> > 
> > ! const char *add_env_module_vars_set (cmd_parms *cmd, char
> > ! *struct_ptr,
> >            const char *arg)
> >   {
> > !     env_server_config_rec *sconf =
> > !       get_module_config (cmd->server->module_config, &env_module);
> > !     table *vars = sconf->vars;
> >       char *name, *value;
> > 
> >       name = getword_conf( cmd->pool, &arg );
> > --- 172,188 ----
> >           name_ptr = getword_conf (cmd->pool, &arg);
> >           env_var = getenv(name_ptr);
> >           if ( env_var != NULL ) { 
> > !             dconf->vars_present = 1;
> >               table_set (vars, name_ptr, env_var);
> >           }
> >       }
> >       return NULL;
> >   }
> > 
> > ! const char *add_env_module_vars_set (cmd_parms *cmd,
> > ! env_dir_config_rec *dconf,
> >            const char *arg)
> >   {
> > !     table *vars = dconf->vars;
> >       char *name, *value;
> > 
> >       name = getword_conf( cmd->pool, &arg );
> > ***************
> > *** 199,240 ****
> >    return "SetEnv takes one or two arguments.  An environment variable
> >    name and an optional value to pass to CGI." ;
> >       }
> > 
> > !     sconf->vars_present = 1;
> >       table_set (vars, name, value);
> > 
> >       return NULL;
> >   }
> > 
> > ! const char *add_env_module_vars_unset (cmd_parms *cmd, char
> > ! *struct_ptr,
> >              char *arg)
> >   {
> > !     env_server_config_rec *sconf =
> > !       get_module_config (cmd->server->module_config, &env_module);
> > !     sconf->unsetenv = sconf->unsetenv ? 
> > ! 	pstrcat( cmd->pool, sconf->unsetenv, " ", arg, NULL ) : 
> >    pstrdup( cmd->pool, arg );
> >       return NULL;
> >   }
> > 
> >   command_rec env_module_cmds[] = {
> >   { "PassEnv", add_env_module_vars_passed, NULL,
> > !     RSRC_CONF, RAW_ARGS, "a list of environment variables to pass to
> > !     CGI." },
> >   { "SetEnv", add_env_module_vars_set, NULL,
> > !     RSRC_CONF, RAW_ARGS, "an environment variable name and a value
> > !     to pass to CGI." },
> >   { "UnsetEnv", add_env_module_vars_unset, NULL,
> > !     RSRC_CONF, RAW_ARGS, "a list of variables to remove from the CGI
> > !     environment." },
> >   { NULL },
> >   };
> > 
> >   int fixup_env_module(request_rec *r)
> >   {
> >       table *e = r->subprocess_env;
> > !     server_rec *s = r->server;
> > !     env_server_config_rec *sconf = get_module_config
> > !     (s->module_config,
> >            &env_module);
> > !     table *vars = sconf->vars;
> > 
> > !     if ( !sconf->vars_present ) return DECLINED;
> > 
> >       r->subprocess_env = overlay_tables( r->pool, e, vars );
> > 
> > --- 197,235 ----
> >    return "SetEnv takes one or two arguments.  An environment variable
> >    name and an optional value to pass to CGI." ;
> >       }
> > 
> > !     dconf->vars_present = 1;
> >       table_set (vars, name, value);
> > 
> >       return NULL;
> >   }
> > 
> > ! const char *add_env_module_vars_unset (cmd_parms *cmd,
> > ! env_dir_config_rec *dconf,
> >              char *arg)
> >   {
> > !     dconf->unsetenv = dconf->unsetenv ? 
> > ! 	pstrcat( cmd->pool, dconf->unsetenv, " ", arg, NULL ) : 
> >    pstrdup( cmd->pool, arg );
> >       return NULL;
> >   }
> > 
> >   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 },
> >   };
> > 
> >   int fixup_env_module(request_rec *r)
> >   {
> >       table *e = r->subprocess_env;
> > !     env_dir_config_rec *dconf = get_module_config
> > !     (r->per_dir_config,
> >            &env_module);
> > !     table *vars = dconf->vars;
> > 
> > !     if ( !dconf->vars_present ) return DECLINED;
> > 
> >       r->subprocess_env = overlay_tables( r->pool, e, vars );
> > 
> > ***************
> > *** 244,253 ****
> >   module env_module = {
> >      STANDARD_MODULE_STUFF,
> >      NULL,			/* initializer */
> > !    NULL,			/* dir config creater */
> > !    NULL,			/* dir merger --- default is to override */
> > !    create_env_server_config,	/* server config */
> > !    merge_env_server_configs,	/* merge server configs */
> >      env_module_cmds,		/* command table */
> >      NULL,			/* handlers */
> >      NULL,			/* filename translation */
> > --- 239,248 ----
> >   module env_module = {
> >      STANDARD_MODULE_STUFF,
> >      NULL,			/* initializer */
> > !    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 */
> >      NULL,			/* filename translation */
> > 
> 
> 

Mime
View raw message