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