I have written a small patch to solve this problem. Please have a look
at it. If it looks good, I will write tests and submit the patch.
The scheme is :
1. Populate %ENV before all <Perl>..</Perl>, PerlRequire and PerlModule.
2. After every <Perl>..</Perl>, PerlRequire and PerlModule, sync
server tables ( scfg->SetEnv & scfg->PassEnv ) with %ENV.
Thanks,
Pratik
diff -ru mp2src/mod_perl-2.0.0-RC1/src/modules/perl/modperl_cmd.c
patches/mymp2/mod_perl-2.0.0-RC1/src/modules/perl/modperl_cmd.c
--- mp2src/mod_perl-2.0.0-RC1/src/modules/perl/modperl_cmd.c 2004-12-12
13:49:11.000000000 -0800
+++ patches/mymp2/mod_perl-2.0.0-RC1/src/modules/perl/modperl_cmd.c
2004-12-22
09:12:22.000000000 -0800
@@ -219,9 +219,11 @@
MP_TRACE_d(MP_FUNC, "load PerlModule %s\n", arg);
MP_PERL_OVERRIDE_CONTEXT;
+ modperl_env_configure_server(aTHX_ parms->pool, parms->server);
if (!modperl_require_module(aTHX_ arg, FALSE)) {
error = SvPVX(ERRSV);
}
+ modperl_env_sync_server(aTHX_ parms->pool, parms->server);
MP_PERL_RESTORE_CONTEXT;
return error;
@@ -250,11 +252,13 @@
char *error = NULL;
MP_TRACE_d(MP_FUNC, "load PerlRequire %s\n", arg);
+ modperl_env_configure_server(aTHX_ parms->pool, parms->server);
MP_PERL_OVERRIDE_CONTEXT;
if (!modperl_require_file(aTHX_ arg, FALSE)) {
error = SvPVX(ERRSV);
}
+ modperl_env_sync_server(aTHX_ parms->pool, parms->server);
MP_PERL_RESTORE_CONTEXT;
return error;
@@ -544,7 +548,9 @@
ENTER;SAVETMPS;
save_scalar(gv); /* local $0 */
sv_setpv_mg(GvSV(gv), directive->filename);
+ modperl_env_configure_server(aTHX_ p, s);
eval_pv(arg, FALSE);
+ modperl_env_sync_server(aTHX_ p, s);
FREETMPS;LEAVE;
}
@@ -640,6 +646,7 @@
if ((errmsg = modperl_cmd_modules(parms, mconfig, arg))) {
return errmsg;
}
+ modperl_env_sync_server(aTHX_ parms->pool, parms->server);
return NULL;
}
diff -ru mp2src/mod_perl-2.0.0-RC1/src/modules/perl/modperl_env.c
patches/mymp2/mod_perl-2.0.0-RC1/src/modules/perl/modperl_env.c
--- mp2src/mod_perl-2.0.0-RC1/src/modules/perl/modperl_env.c 2004-12-12
13:49:11.000000000 -0800
+++ patches/mymp2/mod_perl-2.0.0-RC1/src/modules/perl/modperl_env.c
2004-12-22
09:12:47.000000000 -0800
@@ -153,6 +153,43 @@
"PATH", "TZ", NULL
};
+static void modperl_env_sync_table(pTHX_ apr_table_t *table)
+{
+ HV *hv = ENVHV;
+ U32 mg_flags;
+ int i;
+ const apr_array_header_t *array;
+ apr_table_entry_t *elts;
+
+ modperl_env_untie(mg_flags);
+
+ array = apr_table_elts(table);
+ elts = (apr_table_entry_t *)array->elts;
+
+ for (i = 0; i < array->nelts; i++) {
+ char *val;
+
+ if (!elts[i].key || !elts[i].val) {
+ continue;
+ }
+ val = getenv(elts[i].key);
+ apr_table_set(table, elts[i].key, val);
+ }
+
+ modperl_env_tie(mg_flags);
+}
+
+void modperl_env_sync_server(pTHX_ apr_pool_t *p, server_rec *s)
+{
+ MP_dSCFG(s);
+
+ /* Make per-server PerlSetEnv and PerlPassEnv in sync with %ENV
+ * at config time
+ */
+ modperl_env_sync_table(aTHX_ scfg->SetEnv);
+ modperl_env_sync_table(aTHX_ scfg->PassEnv);
+}
+
void modperl_env_configure_server(pTHX_ apr_pool_t *p, server_rec *s)
{
MP_dSCFG(s);
diff -ru mp2src/mod_perl-2.0.0-RC1/src/modules/perl/modperl_env.h
patches/mymp2/mod_perl-2.0.0-RC1/src/modules/perl/modperl_env.h
--- mp2src/mod_perl-2.0.0-RC1/src/modules/perl/modperl_env.h 2004-12-12
13:49:11.000000000 -0800
+++ patches/mymp2/mod_perl-2.0.0-RC1/src/modules/perl/modperl_env.h
2004-12-22
09:12:34.000000000 -0800
@@ -33,6 +33,8 @@
void modperl_env_clear(pTHX);
+void modperl_env_sync_server(pTHX_ apr_pool_t *p, server_rec *s);
+
void modperl_env_configure_server(pTHX_ apr_pool_t *p, server_rec *s);
void modperl_env_configure_request_srv(pTHX_ request_rec *r);
--
http://pratik.syslock.org
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]