trouble with using $r->lookup_uri()

2003-05-31 Thread Ryan Muldoon
I'm trying to write a authentication handler using mod_perl, and am
encountering some difficulty.  I have isolated my problem to the usage
of the lookup_uri($uri) function call - whenever I call it, my module
segfaults.  I have tested the input with both a variable string, and
just a quoted string, and get the same result.

My module is as follows:

package Apache::AuthNx509;

use strict;
use Apache::Constants qw(:common);
use Text::ParseWords  qw(quotewords);
use Apache::Log ();

sub handler {
my $r = shift;
my $c = $r->connection;
my $log = $r->log;

my $certcomponent = $r->dir_config('CertComponent') ||
'SSL_CLIENT_S_DN_O';
my $certcompvalue = $r->dir_config('CertComponentValue') ||
'University of Wisconsin';
my $usercomponent = $r->dir_config('RemoteUserCertComponent') ||
'SSL_CLIENT_S_DN_CN';
 
my $uri = $r->uri;
my $subr = $r->lookup_uri($uri);
my $apachecertcomp = $subr->subprocess_env($certcomponent);
$log->notice("hello: $apachecertcomp");
   if ($apachecertcomp eq $certcompvalue)
{
$log->notice("$certcompvalue good");
$c->user = $r->subprocess_env->{$usercomponent};
$log->notice("$c->user logged in successfully");
return OK;
}
$log->notice("cert no good: $r->subprocess_env->{$certcomponent}");
my $reason = "Client Cert not in correct form";
$r->note_basic_auth_failure;
$r->log_reason($reason, $r->filename);
return DECLINED;
}

1;
__END__

If I change
 my $subr = $r->lookup_uri($uri);
to
 my $subr = $r;
my program does not segfault, though I am unable to get access to the
apache table.  

If anyone has any ideas on how to fix this problem, or knows of another
way to get access to environment variables (provided by mod_ssl), I
would be very interested.  Thanks!

--Ryan


Re: trouble with using $r->lookup_uri()

2003-05-31 Thread Aaron Ross
> my $uri = $r->uri;
> my $subr = $r->lookup_uri($uri);

Is this recursing? the subrequest will run all phases but the content
handler, so
i would think you'll need to add

return unless $r->is_main();

or something like it at the beginning of the routine.

-- Aaron




RE: trouble with using $r->lookup_uri()

2003-06-02 Thread Frank Maas
> I'm trying to write a authentication handler using mod_perl, and am
> encountering some difficulty.  I have isolated my problem to the usage
> of the lookup_uri($uri) function call - whenever I call it, my module
> segfaults.  I have tested the input with both a variable string, and
> just a quoted string, and get the same result.

I don't know whether this will help you, but don't just focus on this
handler. I encountered problems using lookup_uri myself, because I did not
bear in mind that ->lookup_uri goes through a request cycle itself, thus
calling a far lot of the handlers defined for that uri. However it is not
a complete request, so things like ->pnotes etc. can fail. See
http://marc.theaimsgroup.com/?l=apache-modperl&m=105118150200822&w=2 for
my 'diary'.

--Frank


Re: trouble with using $r->lookup_uri()

2003-06-03 Thread Ryan Muldoon
Aaron,

It looks like this did the trickmy module doesn't quite work yet,
but it isn't segfaulting anymore.  Thanks!

--Ryan

On Fri, 2003-05-30 at 22:24, Aaron Ross wrote:
> > my $uri = $r->uri;
> > my $subr = $r->lookup_uri($uri);
> 
> Is this recursing? the subrequest will run all phases but the content
> handler, so
> i would think you'll need to add
> 
> return unless $r->is_main();
> 
> or something like it at the beginning of the routine.
> 
> -- Aaron
> 
>