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/05/06 12:33:16 UTC
[mp2.0] Win32 ENV still not compatible with mod_cgi
1. Problem Description:
%ENV still not compatible with mod_cgi regarding mixed case variable names.
I had previously reported this problem with mod_perl-1.99_08 and I was
delighted to find an update in
mod_perl-1.99_09 regarding Win32 env. However, the fix does not address the
problem.
The following diff shows what I've done in my local version to make it
compatible. I know that it probably
does not address the root cause, but it fixes the key name at the lowest
possible level to:-
a) Ensure that the first character of the name is not a digit (re mod_cgi)
b) All non alpha-numeric characters are replaced with '_' underscores (re
mod_cgi)
c) On Win32, all characters are UPPERCASE (implicitly done in mod_cgi by
invoking CreateProcess(...) with the env block)
--- modperl_env_orig.c Tue Oct 22 03:42:04 2002
+++ modperl_env.c Tue May 06 11:05:11 2003
@@ -4,22 +4,50 @@
#define EnvMgLen SvMAGIC((SV*)ENVHV)->mg_len
static MP_INLINE
+char *modperl_env_key_fixup(const char *inKey)
+{
+ char *outKey = strdup(inKey);
+ char *whack = outKey;
+
+ if (apr_isdigit(*whack)) {
+ *whack++ = '_';
+ }
+
+ while (*whack) {
+ if (!apr_isalnum(*whack) && *whack != '_') {
+ *whack = '_';
+ }
+#ifdef ENV_IS_CASELESS /* i.e. WIN32 */
+ else {
+ *whack = apr_toupper(*whack);
+ }
+#endif
+
+ ++whack;
+ }
+
+ return outKey;
+}
+
+static MP_INLINE
void modperl_env_hv_store(pTHX_ HV *hv, apr_table_entry_t *elt)
{
- I32 klen = strlen(elt->key);
- SV **svp = hv_fetch(hv, elt->key, klen, FALSE);
+ char *key = modperl_env_key_fixup(elt->key); /* Emulate CGI / Win32
behaviour */
+ I32 klen = strlen(key);
+ SV **svp = hv_fetch(hv, key, klen, FALSE);
if (svp) {
sv_setpv(*svp, elt->val);
}
else {
SV *sv = newSVpv(elt->val, 0);
- hv_store(hv, elt->key, klen, sv, FALSE);
- modperl_envelem_tie(sv, elt->key, klen);
+ hv_store(hv, key, klen, sv, FALSE);
+ modperl_envelem_tie(sv, key, klen);
svp = &sv;
}
SvTAINTED_on(*svp);
+ free(key);
}
typedef struct {
2. Used Components and their Configuration:
*** using lib/Apache/BuildConfig.pm
*** Makefile.PL options:
MP_AP_PREFIX => C:/Apache2
MP_COMPAT_1X => 1
MP_GENERATE_XS => 1
MP_LIBNAME => mod_perl
MP_USE_DSO => 1
MP_USE_STATIC => 1
*** C:/Apache2/bin/Apache.exe -V
Server version: Apache/2.0.45
Server built: Apr 2 2003 16:52:20
Server's Module Magic Number: 20020903:0
Architecture: 32-bit
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/winnt"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D HTTPD_ROOT="/apache"
-D SUEXEC_BIN="/apache/bin/suexec"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error.log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
*** C:\Perl\bin\perl.exe -V
Summary of my perl5 (revision 5 version 8 subversion 0) configuration:
Platform:
osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread
uname=''
config_args='undef'
hint=recommended, useposix=true, d_sigaction=undef
usethreads=undef use5005threads=undef useithreads=define
usemultiplicity=define
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cl', ccflags ='-nologo -Gf -W3 -MD -Zi -DNDEBUG -O1 -DWIN32
-D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT
-DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX',
optimize='-MD -Zi -DNDEBUG -O1',
cppflags='-DWIN32'
ccversion='', gccversion='', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64',
lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf
-libpath:"C:\Perl\lib\CORE" -machine:x86'
libpth="C:\Program Files\Microsoft Visual Studio\VC98\mfc\lib"
"C:\Program Files\Microsoft Visual Studio\VC98\lib" "C:\Perl\lib\CORE"
libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib
uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib
msvcrt.lib
perllibs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib
uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib
msvcrt.lib
libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl58.lib
gnulibc_version='undef'
Dynamic Linking:
dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug
-opt:ref,icf -libpath:"C:\Perl\lib\CORE" -machine:x86'
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES
PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS
Locally applied patches:
ActivePerl Build 805
Built under MSWin32
Compiled at Feb 4 2003 18:08:02
%ENV:
PERL_LWP_USE_HTTP_10="1"
@INC:
C:/Perl/lib
C:/Perl/site/lib
.
3. This is the core dump trace: (if you get a core dump):
[CORE TRACE COMES HERE]
This report was generated by t/REPORT on Tue May 6 10:17:01 2003 GMT.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org
Re: [mp2.0] Win32 ENV still not compatible with mod_cgi
Posted by Stas Bekman <st...@stason.org>.
steve.sparling@ps.ge.com wrote:
> 1. Problem Description:
>
> %ENV still not compatible with mod_cgi regarding mixed case variable names.
>
> I had previously reported this problem with mod_perl-1.99_08 and I was
> delighted to find an update in
> mod_perl-1.99_09 regarding Win32 env. However, the fix does not address the
> problem.
It addresses the first problem with PassEnv, on which you said it worked fine.
You haven't followed up on my further questions, so the other things weren't
resolved.
> The following diff shows what I've done in my local version to make it
> compatible. I know that it probably
> does not address the root cause, but it fixes the key name at the lowest
> possible level to:-
>
> a) Ensure that the first character of the name is not a digit (re mod_cgi)
> b) All non alpha-numeric characters are replaced with '_' underscores (re
> mod_cgi)
> c) On Win32, all characters are UPPERCASE (implicitly done in mod_cgi by
> invoking CreateProcess(...) with the env block)
Thanks for the patch, however it adds a potentially huge overhead on each
request (CPU cycles and memory).
Can you explain why do you want to make mod_cgi and mod_perl absolutely
compatible? Earlies you have shown this example:
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"
Do you need to use any of those keys?
And this is obviously wrong to s/\W/_/ for all platforms, since if I set the
env var Foo-Bar, I'd expect it to be Foo-Bar and not Foo_Bar. This change
would be very confusing to non-win32 users.
I've checked the mod_perl 1.0 sources and no such manipulation was done there
and I haven't heard any complaints about mod_perl 1.0 so far. I suppose that
the whole problem started from the need to detach the C environ struct from
perl's %ENV, because C's environ is not thread-local. Otherwise perl would
take care of handling the key correctly, as it does in mod_perl 1.0. Can you
please check whether this is an issue with mod_perl 1.0 as well?
__________________________________________________________________
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