You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Torsten Förtsch <to...@gmx.net> on 2004/10/08 14:42:49 UTC
[mp2] Handler Order
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I know one can specify the handler invocation order of the request phases. But
how to do it?
My problem is, I want to know if a request came in over http or https in the
fixup phase. With mp1 I had configured by the LoadModule order that a
mod_perl handler was called after the mod_ssl handler. Since mod_ssl sets up
subprocess_env in the fixup phase I could check subprocess_env('HTTPS') in a
mod_perl fixup handler.
How can I define that my mod_perl fixup handler is to be called after the
mod_ssl fixup handler?
Or how can I access the SSL related stuff from mod_perl prior to the response
phase?
I am using 1.99_12 from suse 9.1.
Thanks,
Torsten
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFBZotOwicyCTir8T4RAk1zAJ9YxWelAnOfhe0B+0wg8Oywl9VUHQCgyLBs
ZSDVfjTPfdu8496Ktzxaghw=
=/q06
-----END PGP SIGNATURE-----
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp2] Handler Order
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
Torsten Förtsch wrote:
> Hi,
>
> I know one can specify the handler invocation order of the request phases. But
> how to do it?
>
> My problem is, I want to know if a request came in over http or https in the
> fixup phase. With mp1 I had configured by the LoadModule order that a
> mod_perl handler was called after the mod_ssl handler. Since mod_ssl sets up
> subprocess_env in the fixup phase I could check subprocess_env('HTTPS') in a
> mod_perl fixup handler.
>
> How can I define that my mod_perl fixup handler is to be called after the
> mod_ssl fixup handler?
the only way to do this currently is to alter the mod_perl source. after
running 'perl Makefile.PL' open modperl_hooks.c and look for this line:
ap_hook_fixup(modperl_fixup_handler, NULL, NULL, APR_HOOK_REALLY_FIRST);
to get mod_perl to run after mod_ssl, change APR_HOOK_REALLY_FIRST to
APR_HOOK_LAST (since mod_ssl runs fixups as APR_HOOK_MIDDLE).
I started working on a way to dynamically alter module order at config time,
just like you used to do with LoadModule or ClearModuleList/AddModule, but
unfortunately I haven't had the time to follow up on it. understand,
however, that this isn't a mod_perl specific thing - apache 2.0 has removed
the ability for users to specify the order that modules will run, pending a
core change (which is what I was working on :)
>
> Or how can I access the SSL related stuff from mod_perl prior to the response
> phase?
it doesn't look like you can, at least from my glancing over the source.
--Geoff
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp2] Handler Order
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
Joe Orton wrote:
> On Tue, Nov 02, 2004 at 04:49:55PM -0500, Geoffrey Young wrote:
>
>>I've been meaning to take care of this since you mentioned it.
>>
>>http://www.modperlcookbook.org/~geoff/modules/Apache-SSLLookup-2.00_01.tar.gz
>>
>>I'll probably move it to cpan in the next day or so.
>
>
> Very nice! Now can I just borrow some of your round tuits?
>
> Did you try #include'ing mod_ssl.h to pick up the optional function
> declarations rather than copy'n'pasting them? It should work OK with
> recent 2.0 releases.
I'm pretty sure I did and things bombed, then I saw the warning in
mod_rewrite and removed it. but it was early on in the dev process so the
problem may have been elsewhere.
anyway, I'll play around with it a bit more and try again. I actually only
tested against 2.0.52, though I meant to try 2.0.47 but apparently forgot.
I did make sure it worked both with and without mod_ssl installed, though.
btw, for those that are interested, as an exercise I created an
Apache::RequestRec subclass entirely from XS, which required a few minor
acrobatics.
--Geoff
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp2] Handler Order
Posted by Joe Orton <jo...@redhat.com>.
On Tue, Nov 02, 2004 at 08:37:42PM -0500, Geoffrey Young wrote:
>
> > Did you try #include'ing mod_ssl.h to pick up the optional function
> > declarations rather than copy'n'pasting them? It should work OK with
> > recent 2.0 releases.
...
> /apache/2.0.52/ssl/perl-5.8.5/include/mod_ssl.h:91:17: ssl.h: No such file
> or directory
> In file included from /apache/2.0.52/ssl/perl-5.8.5/include/mod_ssl.h:92,
> from SSLLookup.xs:5:
>
> which I gather is because mod_perl does not include the
> -I/usr/include/openssl that apache does when I activate mod_ssl. I can't
> find the list of includes in apxs or apr-config either, so I'm not sure how
> we could expect mod_perl to retain this information and pass it along in
> WriteMakefile.
> I'm not really the best at this kind of thing, so suggestions welcome.
> otherwise, I guess the declaration stays.
Fair enough, yes, it's probably in there somewhere but apxs in 2.0 is
not most helpful about this stuff...
> as an aside, do you know why mod_rewrite doesn't list mod_ssl as a
> predecessor when calling register_hooks? it would seem that mod_rewrite
> could be loaded after mod_ssl and thus not get access to those optional
> functions. but I've only used the optional stuff a few times, mainly with
> mod_include's stuff, so maybe things are different here.
The optional functions are registered in a pre_config hook and extracted
in a post_config hook which ensures that (I presume this is true for
mod_ssl, haven't checked).
joe
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp2] Handler Order
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> Did you try #include'ing mod_ssl.h to pick up the optional function
> declarations rather than copy'n'pasting them? It should work OK with
> recent 2.0 releases.
just putting in
# include "mod_ssl.h"
gives
cc -c -I/apache/2.0.52/ssl/perl-5.8.5/include -D_REENTRANT -D_GNU_SOURCE
-DTHREADS_HAVE_PIDS -DDEBUGGING -fno-strict-aliasing -pipe
-I/usr/local/include -I/usr/include/gdbm
-I/perl/perl-5.8.5/lib/5.8.5/i686-linux-thread-multi/CORE -DMOD_PERL -Wall
-Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Werror
-DAP_DEBUG -DAP_HAVE_DESIGNATED_INITIALIZER -DMP_DEBUG -DMP_TRACE -DLINUX=2
-D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_SVID_SOURCE -DAP_DEBUG -g
-DVERSION=\"2.00_01\" -DXS_VERSION=\"2.00_01\" -fpic
"-I/perl/perl-5.8.5/lib/5.8.5/i686-linux-thread-multi/CORE" SSLLookup.c
In file included from SSLLookup.xs:5:
/apache/2.0.52/ssl/perl-5.8.5/include/mod_ssl.h:91:17: ssl.h: No such file
or directory
In file included from /apache/2.0.52/ssl/perl-5.8.5/include/mod_ssl.h:92,
from SSLLookup.xs:5:
which I gather is because mod_perl does not include the
-I/usr/include/openssl that apache does when I activate mod_ssl. I can't
find the list of includes in apxs or apr-config either, so I'm not sure how
we could expect mod_perl to retain this information and pass it along in
WriteMakefile.
I'm not really the best at this kind of thing, so suggestions welcome.
otherwise, I guess the declaration stays.
as an aside, do you know why mod_rewrite doesn't list mod_ssl as a
predecessor when calling register_hooks? it would seem that mod_rewrite
could be loaded after mod_ssl and thus not get access to those optional
functions. but I've only used the optional stuff a few times, mainly with
mod_include's stuff, so maybe things are different here.
--Geoff
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp2] Handler Order
Posted by Joe Orton <jo...@redhat.com>.
On Tue, Nov 02, 2004 at 04:49:55PM -0500, Geoffrey Young wrote:
> I've been meaning to take care of this since you mentioned it.
>
> http://www.modperlcookbook.org/~geoff/modules/Apache-SSLLookup-2.00_01.tar.gz
>
> I'll probably move it to cpan in the next day or so.
Very nice! Now can I just borrow some of your round tuits?
Did you try #include'ing mod_ssl.h to pick up the optional function
declarations rather than copy'n'pasting them? It should work OK with
recent 2.0 releases.
joe
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp2] Handler Order
Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> The best thing to do is to use the ssl_var_lookup hook which the C
> interface to mod_ssl exports, or better yet, if using 2.0.51 or later,
> the ssl_is_https hook. This means you don't have to use "SSLOptions
> +StdEnvVars" to get SSL variables via subprocess_env, which adds a lot
> of overhead since you probably don't need most of them, and the hook
> orderings don't matter.
>
> You'd have to right Perl bindings for this first of course!
I've been meaning to take care of this since you mentioned it.
http://www.modperlcookbook.org/~geoff/modules/Apache-SSLLookup-2.00_01.tar.gz
I'll probably move it to cpan in the next day or so.
--Geoff
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
Re: [mp2] Handler Order
Posted by Joe Orton <jo...@redhat.com>.
On Fri, Oct 08, 2004 at 02:42:49PM +0200, Torsten Förtsch wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
>
> I know one can specify the handler invocation order of the request phases. But
> how to do it?
>
> My problem is, I want to know if a request came in over http or https in the
> fixup phase. With mp1 I had configured by the LoadModule order that a
> mod_perl handler was called after the mod_ssl handler. Since mod_ssl sets up
> subprocess_env in the fixup phase I could check subprocess_env('HTTPS') in a
> mod_perl fixup handler.
>
> How can I define that my mod_perl fixup handler is to be called after the
> mod_ssl fixup handler?
>
> Or how can I access the SSL related stuff from mod_perl prior to the response
> phase?
The best thing to do is to use the ssl_var_lookup hook which the C
interface to mod_ssl exports, or better yet, if using 2.0.51 or later,
the ssl_is_https hook. This means you don't have to use "SSLOptions
+StdEnvVars" to get SSL variables via subprocess_env, which adds a lot
of overhead since you probably don't need most of them, and the hook
orderings don't matter.
You'd have to right Perl bindings for this first of course!
joe
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html