[WISH] A Perlish way to detect mod_perl major version (= not $ENV{MOD_PERL})

[prev] [thread] [next] [Date index for 2005/03/17]

From: Dominique Quatravaux
Subject: [WISH] A Perlish way to detect mod_perl major version (= not $ENV{MOD_PERL})
Date: 16:39 on 17 Mar 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

I have a few places in my code where I clobber %ENV for various
reasons (mostly taint-safety). The problem is that I can no longer use
$ENV{MOD_PERL} to detect whether I'm running under mod_perl or not.

And to be frank, I don't think detecting an API version from an
environment variable is a good idea at all. Imagine that for some
reason, CGI script 1 delegates to CGI script 2 using system(). What
will happen if I run CGI script 1 under mod_perl, is that CGI script 2
will be led to believe it runs under mod_perl too, when in fact it
doesn't.

So how about introducing a mod_perl::VERSION XS sub? I am still
clueless in XS, but this sounds like the perfect introductory exercise
:-) and I'm willing to give it a try if you would accept the patch.

For the record I use the following dubious hack as an interim measure:

sub modperl_major_version {
~    use DynaLoader ();
~    return 1 if DynaLoader::dl_find_symbol_anywhere("XS_Apache_define");
~    return 2 if
DynaLoader::dl_find_symbol_anywhere("XS_ModPerl__Util_exit");
~    return undef;
}

- --
Dominique QUATRAVAUX                           Ingénieur senior
01 44 42 00 08                                 IDEALX

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCObK5MJAKAU3mjcsRAnJIAKDBpblutdztOnJ5Eaa6RC3f+zTZbACgijMp
00oLNTphfYkD5YQ5WdoSD6U=
=4/6q
-----END PGP SIGNATURE-----


[WISH] A Perlish way to detect mod_perl major version (= not $ENV{MOD_PERL})
Dominique Quatravaux 16:39 on 17 Mar 2005

Generated at 15:10 on 27 Mar 2005 by mariachi v0.52