Well, since nobody replied I started digging myself. Here's what I
found.

The problem below is caused by push_handlers method in Authorization
handler.

You can reproduce it if you use the following set up.
----------------------- module ------------
package Apache::MasterAuth;

use Apache::Constants qw(:common);

use strict;

sub authz1_handler{
    my $r = shift;
    $r->warn('Session handling' . $r->is_initial_req);
    return OK;# unless $r->is_initial_req;
}

sub authen_handler{
    my $r = shift;
    my $log = $r->log;
    $log->warn("AUTN: Checking " . $r->filename() . 'Initial ' . $r->is_initial_req());

    return OK;# unless $r->is_initial_req;
}

sub authz_handler{
    my $r = shift;
    my $log = $r->log;
    $log->warn("AUTZ: Checking " . $r->filename() . ' Initial '. $r->is_initial_req());
    return OK unless $r->is_initial_req;
    $r->push_handlers('PerlAuthzHandler' , \&authz1_handler);
    return OK;
}

1;
--------------------------- configuration ---

<Directory /docroot/mydirectory>
DirectoryIndex index.html
AuthType Basic
AuthName "test"

  PerlAuthenHandler Apache::MasterAuth::authen_handler
  PerlAuthzHandler  Apache::MasterAuth::authz_handler

Options FollowSymLinks
AllowOverride None
require valid-user
</Directory>
----------------------------------

As soon as you comment out the line with push_handlers from perl
module everything starts working fine.

The set up which I have Linux box, Apache1.3.9, mod_perl 1.21 with
patch for fixing corrupted PATH aplied, perl 5.004_4

It is important because I couldn't reproduce this problem on the
system with perl 5.005_3 and without patch for PATH corruption.

In both cases Apache is statically linked.

While testing this stuff I hit one unclear situation. push_handlers is
supposed to install new handler for duration of one request only. But
when subrequests (or internal redirects) happen does it mean that new
handlers I've installed during initial request are still going to be
called in subrequests? 

I'm asking because in the error log I can clearly see that after
internal redirect the handler that I've installed using push_handlers
is not called.

Some specualtions of mine :)

As the side note I should mention that this has also helped problem
with "Attempts to free unreferenced scalar..." error. It almost
completely is gone. I still use push_handlers in other handlers but
that doesn't happen very often and probably this explains why there's
just few of those errors.

Andrei

PS. If this is problem due to older version of perl then it's
great. I'll just upgrade perl. If on the other hand this is problem
with patch for PATH then this needs fix. Just in case here's the patch
I've used.

--- mod_perl.h  1999/08/03 22:56:09     1.84
+++ mod_perl.h  1999/08/04 02:53:38
@@ -286,9 +286,10 @@
 #define mp_setenv(key, val) \
 { \
     int klen = strlen(key); \
-    hv_store(GvHV(envgv), key, klen, newSVpv(val,0), FALSE); \
+    SV *sv = newSVpv(val,0); \
+    hv_store(GvHV(envgv), key, klen, sv, FALSE); \
     HV_SvTAINTED_on(GvHV(envgv), key, klen); \
-    my_setenv(key, val); \
+    my_setenv(key, SvPVX(sv)); \
 }
 
 #define mp_SetEnv(key, val) \






> <Directory /doc/root>
> ........
>   PerlAuthenHandler        Apache::MyAuth::authen_handler
> .........
> </Directory>
> 
> Everything works fine except for retrieving index files for
> directories. Requests for http://my.site.com/any/dir/
> end up with message "you don't have permission to access
> /any/dir/ on this server" and line in error log
> "Directory index forbidden by rule: /proj/Web/94dec/any/dir/"
> 
> I'm running Apache 1.3.9, mod_perl 1.21 staticaly linked on Linux box.
> 
> And unfortunately I can't rewrite my configuration to use <Files ...>
> And there is DirectoryIndex directive in my configuration files.
> And my authentication/authorization handler doesn't care about the URL being
> requested, only the require field values.
> 
> Anyone has looked into that really?
> 
> Andrei
> 
> -- 

-- 

Reply via email to