You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by st...@ps.ge.com on 2003/04/15 10:09:50 UTC

RE: Mixed-case environment variables in Win32 don't get handled c orrectly

Thanks for your quick reply:-

I don't have access to a diff with a "-u" option - :(

But the diff was showing the output from mod_perl versus mod_cgi.

All the keys in UPPERCASE come from mod_cgi.

	DOWNGRADE_1_0="1"
	FORCE_RESPONSE_1_0="1"
	NOKEEPALIVE="1"
	SSL_SERVER_I_DN_EMAIL="steve.sparling@ps.ge.com"
	SSL_SERVER_S_DN_EMAIL="steve.sparling@ps.ge.com"
	SSL_UNCLEAN_SHUTDOWN="1"
	SYSTEMROOT="C:\WINDOWS"

All the keys in MixedCase come from mod_perl.

	downgrade-1.0=""
	force-response-1.0=""
	nokeepalive=""
	SSL_SERVER_I_DN_Email=""
	SSL_SERVER_S_DN_Email=""
	ssl-unclean-shutdown=""
	SystemRoot="C:\WINDOWS"

BTW: If you debug the keys and values in modperl_env_hv_store()
[modperl_env.c],
     you can see that the keys are in mixed case + the values are correct.
     However, when the hv_store() is performed, the same mixed-case key is
used.
     Now when the perl runtime accesses %ENV, it will automatically
uppercase the input key
     and hence not find the 'real' value.

Steve




-----Original Message-----
From: Stas Bekman [mailto:stas@stason.org]
Sent: 15 April 2003 00:33
To: Sparling, Steve (PS, GENS)
Cc: dev@perl.apache.org
Subject: Re: Mixed-case environment variables in Win32 don't get handled
c orrectly


steve.sparling@ps.ge.com wrote:
> Hi,
> 
> Make test works OK.

Great. Thanks Steve.

> Here's a diff of the standard "cgi-bin/printenv.pl" output from a mod_perl
> vs. straight perl :-

You probably mean mod_perl vs. mod_cgi. Can you use a unified diff (diff
-u), 
I can't follow who gets the env keys mangled. Is that mod_perl's output that

is not correct? it just calls subprocess_env, I wonder why is it different 
from mod_cgi.

>>DOWNGRADE_1_0="1"
> 
> < downgrade-1.0=""
> 
> 
>>FORCE_RESPONSE_1_0="1"
> 
> < force-response-1.0=""
> 
> 
>>NOKEEPALIVE="1"
> 
> < nokeepalive=""
> 
> < SSL_SERVER_I_DN_Email=""
> 
>>SSL_SERVER_I_DN_EMAIL="steve.sparling@ps.ge.com"
> 
> 
> < SSL_SERVER_S_DN_Email=""
> 
>>SSL_SERVER_S_DN_EMAIL="steve.sparling@ps.ge.com"
> 
> 
>>SSL_UNCLEAN_SHUTDOWN="1"
> 
> < ssl-unclean-shutdown=""
> 
> < SystemRoot="C:\WINDOWS"
> 
>>SYSTEMROOT="C:\WINDOWS"
> 
> 
> Most of these variables come from "mod_ssl" except "SystemRoot" - which
> comes from my
> standard XP environment.
> 
> Notice also, the difference in "-" vs "_" and "." vs "_".
> 
> The src I built already had the ENV_IS_CASELESS conversion in
> "modperl_cmd.c".
> 
> Hope this helps
> Cheers
> Steve
> 
> 
> 
> 
> -----Original Message-----
> From: Stas Bekman [mailto:stas@stason.org]
> Sent: 07 April 2003 08:29
> To: Sparling, Steve (PS, GENS)
> Cc: 'dev@perl.apache.org'
> Subject: Re: Mixed-case environment variables in Win32 don't get handled
> corre ctly
> 
> 
> Sparling, Steve (PS, GENS) wrote:
> 
>>Hi,
>>
>>Found a problem running mod_perl under Win32: (ME, 2K and XP).
>>
>>Mixed-case environment variables don't get handled correctly.
>>
>>They appear in the %ENV, but have no value.
>>
>>I've also identified in the source where the problem is + how to fix it -
>>please find attached bug report.
> 
> 
> Thanks Steve. In the future please inline the report, rather attach it.
> 
> Does 'make test' pass for you?
> 
> What kind of env vars you have a problem with? Where do you set them? Or
> which 
> ones do you expect to exist but they aren't there?
> 
> We populate %ENV with:
> 
>      modperl_env_table_populate(aTHX_ scfg->SetEnv);
>      modperl_env_table_populate(aTHX_ scfg->PassEnv);
> 
> and if PerlOptions +SetupEnv (or SetHandler perl-script) are enabled:
> 
>      modperl_env_table_populate(aTHX_ r->subprocess_env);
> 
> SetEnv is already handling the upcasing. I'm not sure about PassEnv should
> we 
> need to do the same (if so the patch below should do).
> 
> As for r->subprocess_env, doesn't httpd already does the right thing?
> 
> Index: src/modules/perl/modperl_cmd.c
> ===================================================================
> RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_cmd.c,v
> retrieving revision 1.45
> diff -u -r1.45 modperl_cmd.c
> --- src/modules/perl/modperl_cmd.c	4 Apr 2003 06:03:07 -0000	1.45
> +++ src/modules/perl/modperl_cmd.c	7 Apr 2003 07:23:21 -0000
> @@ -223,7 +223,15 @@
>   {
>       MP_dSCFG(parms->server);
>       char *val = getenv(arg);
> -
> +
> +#ifdef ENV_IS_CASELESS /* i.e. WIN32 */
> +    /* we turn off env magic during hv_store later, so do this now,
> +     * else lookups on keys with lowercase characters will fails
> +     * because Perl will uppercase them prior to lookup.
> +     */
> +    modperl_str_toupper((char *)arg);
> +#endif
> +
> 
> __________________________________________________________________
> Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
> http://stason.org/     mod_perl Guide ---> http://perl.apache.org
> mailto:stas@stason.org http://use.perl.org http://apacheweek.com
> http://modperlbook.org http://apache.org   http://ticketmaster.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
> For additional commands, e-mail: dev-help@perl.apache.org


-- 


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: Mixed-case environment variables in Win32 don't get handled c orrectly

Posted by Stas Bekman <st...@stason.org>.
Stas Bekman wrote:
> steve.sparling@ps.ge.com wrote:
> 
>> Thanks for your quick reply:-
>>
>> I don't have access to a diff with a "-u" option - :(
> 
> 
> No problem. Your further explanation now makes things clear.
> 
>> But the diff was showing the output from mod_perl versus mod_cgi.
>>
>> All the keys in UPPERCASE come from mod_cgi.
>>
>>     DOWNGRADE_1_0="1"
>>     FORCE_RESPONSE_1_0="1"
>>     NOKEEPALIVE="1"
>>     SSL_SERVER_I_DN_EMAIL="steve.sparling@ps.ge.com"
>>     SSL_SERVER_S_DN_EMAIL="steve.sparling@ps.ge.com"
>>     SSL_UNCLEAN_SHUTDOWN="1"
>>     SYSTEMROOT="C:\WINDOWS"
>>
>> All the keys in MixedCase come from mod_perl.
>>
>>     downgrade-1.0=""
>>     force-response-1.0=""
>>     nokeepalive=""
>>     SSL_SERVER_I_DN_Email=""
>>     SSL_SERVER_S_DN_Email=""
>>     ssl-unclean-shutdown=""
>>     SystemRoot="C:\WINDOWS"
> 
> 
> mod_cgi calls ap_create_environment() which performs this mangling.

I can see that ap_create_environment does s/\W/_/g:

	env[j] = apr_pstrcat(p, elts[i].key, "=", elts[i].val, NULL);
	whack = env[j];
	if (apr_isdigit(*whack)) {
	    *whack++ = '_';
	}
	while (*whack != '=') {
	    if (!apr_isalnum(*whack) && *whack != '_') {
		*whack = '_';
	    }
	    ++whack;
	}
	++j;

But I can't see where it calls toupper to get the upcased vars (for those that 
you have listed). Can you trace which code does that?

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: Mixed-case environment variables in Win32 don't get handled c orrectly

Posted by Stas Bekman <st...@stason.org>.
steve.sparling@ps.ge.com wrote:
> Thanks for your quick reply:-
> 
> I don't have access to a diff with a "-u" option - :(

No problem. Your further explanation now makes things clear.

> But the diff was showing the output from mod_perl versus mod_cgi.
> 
> All the keys in UPPERCASE come from mod_cgi.
> 
> 	DOWNGRADE_1_0="1"
> 	FORCE_RESPONSE_1_0="1"
> 	NOKEEPALIVE="1"
> 	SSL_SERVER_I_DN_EMAIL="steve.sparling@ps.ge.com"
> 	SSL_SERVER_S_DN_EMAIL="steve.sparling@ps.ge.com"
> 	SSL_UNCLEAN_SHUTDOWN="1"
> 	SYSTEMROOT="C:\WINDOWS"
> 
> All the keys in MixedCase come from mod_perl.
> 
> 	downgrade-1.0=""
> 	force-response-1.0=""
> 	nokeepalive=""
> 	SSL_SERVER_I_DN_Email=""
> 	SSL_SERVER_S_DN_Email=""
> 	ssl-unclean-shutdown=""
> 	SystemRoot="C:\WINDOWS"

mod_cgi calls ap_create_environment() which performs this mangling.

what's sure is that we need to do that for $r->subprocess_env for all 
platforms. So we stay 1:1 with mod_cgi on all platforms.

I wonder if we should call ap_create_environment's equivalent for 
PerlSetEnv/PerlPassEnv (need to check the SetEnv/PassEnv functionality)

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org