Apache and mod_perl question

Apache and mod_perl question

am 30.03.2008 00:45:56 von fzarabozo

Hello All,

I might not be in the right mailing list for this question, but I think
there a lot of people here that might be able to answer it. I apologize in
advance if I'm wrong.

I'm using Apache 2.2 with mod_perl. I'm trying to write a module to analyze
certain aspects of each request made to Apache (basically, specific
malicious requests) and, if some conditions are met, give a special
response. I'm not having trouble with that part. The problem I have is that
I can't find the right way to let Apache continue with the normal request if
the module has nothing to do after the request analysis.

I'm trying something like this:

-----------------------
In httpd.conf:
-----------------------

SetHandler perl-script
PerlResponseHandler MyRequestAnalyzer



------------------------
In MyRequestAnalyzer.pm:
------------------------
package MyRequestAnalyzer;
use strict;
use warnings;
use Apache2::RequestRec ();
use Apache2::RequestIO ();
use Apache2::Const -compile => ':common';

sub handler {
my $r = shift;
if ( someConditionsMet($r) ) {
# Here I give a special response, no problem here.
return Apache2::Const::OK; # or else for that matter
} else {
# Here's my problem.
# How do I make Apache continue with the normal request?
# What kind of return value should I send to Apache?
}
}

1;
-------------------------------

As I said, this is working great when the conditions I expect are met. The
problem is that when they're not met, the module has nothing else to do and
I need to let Apache continue with the request just as if it was never
trapped by this module. I've tried a lot of different return values from
Apache2 constants, but I can't find one that works yet.

I hope someone can give me some advice to accomplish this. Thank you very
much in advance.

Cheers,

Paco Zarabozo






_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: Apache and mod_perl question

am 02.04.2008 01:21:27 von Mike Gillis

On 29-Mar-08, at 4:45 PM, Zarabozo, Francisco (GE, Corporate) wrote:

> I'm using Apache 2.2 with mod_perl. I'm trying to write a module to
> analyze
> certain aspects of each request made to Apache (basically, specific
> malicious requests) and, if some conditions are met, give a special
> response. I'm not having trouble with that part. The problem I have
> is that
> I can't find the right way to let Apache continue with the normal
> request if
> the module has nothing to do after the request analysis.

Hi Francisco,

Isn't that achieved by returning 'Apache2::Const::DECLINED'? You
mention that you have tried a number of return values in an attempt to
get this behaviour -- if you've tried this, what's happened instead of
normal execution?

Incidentally, if you're looking for malicious requests, you may get
better results if you use a PerlPostReadRequestHandler or
PerlHeaderParserHandler (depending on whether you need to see pre- or
post-rewrite requests), or PerlFixupHandler (if you only want to
handle post-authorization/authentication requests). All 3 of those
phases are "RUN_ALL" type, rather than "RUN_FIRST" type (which is what
PerlResponseHandler is), so returning Apache2::Const::OK from a
handler for those phases only means "I've completed successfully"
rather than "processing is now done" - but you can still return HTTP
codes (like Apache2::Const::HTTP_FORBIDDEN) to interrupt the normal
execution path.

Cheers,
Mike Gillis

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs