mod_perl

George george at alink.co.za
Mon Sep 24 11:51:37 BST 2007


Hello All,

I'm having a problem with modperl and I can't figure out if it's my 
stupiditry or modperls'.  I'd love somebody with some modperl foo to 
give me a hand.

First, the config:

rembox# cat /etc/redhat-release
Red Hat Enterprise Linux ES release 4 (Nahant Update 4)

rembox# rpm -qa | egrep 'http|mod_perl'
httpd-2.0.52-32.3.ent
httpd-devel-2.0.52-32.3.ent
mod_perl-1.99_16-4.5
httpd-suexec-2.0.52-32.3.ent

rembox# cat /etc/httpd/conf.d/perl.conf | egrep -v "^#"
LoadModule perl_module modules/mod_perl.so

Alias /perlremedy /opt/arsperl/scripts/htdocs/

PerlModule ModPerl::Registry
PerlSwitches -I/opt/arsperl/scripts/htdocs/sec/
PerlModule Apache::compat

<Directory /opt/arsperl/scripts/htdocs/*.pl>
      SetHandler perl-script
      PerlResponseHandler ModPerl::Registry
      Options ExecCGI
      PerlOptions +ParseHeaders
</Directory>

<Directory /opt/arsperl/scripts/htdocs/sec/>
      SetHandler perl-script
      PerlResponseHandler ModPerl::Registry
      PerlAuthenHandler My::AuthTest
      Options ExecCGI
      PerlOptions +ParseHeaders +GlobalRequest

      AuthType Basic
      AuthName "Remedy access"
      Require valid-user
</Directory>

<Location /perl-status>
     SetHandler perl-script
     PerlResponseHandler Apache::Status
     Order deny,allow
     Deny from all
     Allow from .your-domain.com
</Location>

Here's the contents of My::AuthTest:

package My::AuthTest;
use Data::Dumper;
use Apache::Access;
use Apache::Const -compile => qw(OK DECLINED HTTP_UNAUTHORIZED);
use strict;

sub handler {
         my $r = shift ;
         open (FOO, ">/tmp/foo.george");

         # get the client-supplied credentials
         my $username = $r->user;
         my ($status, $password) = $r->get_basic_auth_pw;

         print FOO Dumper($username);
         print FOO Dumper($password);
         print FOO Dumper($status);

         close FOO;

         # only continue if Apache says everything is OK
         return $status unless $status == Apache::OK;

	# Until we figure how to get the username, lets just return OK.
	return Apache::OK;

}

1;

That handler lets the auth through so it's somewhat working.  The 
problem is $username is undef so I can't actually test a login or 
anything.  If I try get access to it from a script that's run after the 
auth (ie, the actual request), then it's not blank and I can see the 
username.  I've also tried $r->connection->user;

I've read a whole bunch of the docs, but what seems to be provided by 
RedHat bears to reference to what's on the interweb.

Can somebody tell me what I'm missing?

Cheers!

George




More information about the london.pm mailing list