You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Kevin Murphy <ke...@boojiboy.eorbit.net> on 2000/04/13 02:49:33 UTC

Problems with custom configuration handlers

I've written an access handler which takes some custom configuration
directives based on the instructions in chaper 8 of the Eagle book. 

Everything makes and installs fine, and I am able to load the module
with a PerlModule directive, but when I try to use the directives
defined in my module I get an error:

"Invalid command 'WhiteListAllow', perhaps mis-spelled or defined by a
module not included in the server configuration"

Apache 1.3.11, Perl 5.00503, mod_perl 1.22.

My Makefile.PL:
-----
package Emusic::WhiteList;

use ExtUtils::MakeMaker;

use Apache::ExtUtils qw(command_table);
use Apache::src;

my @directives = (
        { name       => 'WhiteListAllow',
        errmessg     => 'a domain name to allow',
        args_how     => 'ITERATE',
        req_override => 'OR_AUTHCFG'
        },
        { name       => 'WhiteListDenyURI',
        errmessg     => 'uri to redirect denied clients to',
        args_how     => 'TAKE1',
        req_override => 'OR_AUTHCFG'
        },
        );

command_table(\@directives);

WriteMakefile(
    'NAME'      => __PACKAGE__,
    'VERSION_FROM' => 'WhiteList.pm', # finds $VERSION
    'INC'       => Apache::src->new->inc,     # e.g.,
'-I/usr/include/other',
    'INSTALLSITEARCH'   => '/usr/local/apache/lib/perl',
    'INSTALLSITEARCH'   => '/usr/local/apache/lib/perl',
);
__END__   
----


The relevant portions of the module:

-----

package Emusic::WhiteList;

use strict;
use vars qw($VERSION);
use Apache::Constants qw(:common REDIRECT);
use Apache::ModuleConfig ();

use DynaLoader ();


$VERSION = '1.00';

if ($ENV{MOD_PERL}) {
    no strict;
    @ISA = qw(DynaLoader);
    __PACKAGE__->bootstrap($VERSION);
}

sub handler {
.
.
.
}

sub WhiteListAllow ($$@){
    my ($cfg,$parms,$domain) = @_;
    $cfg->{WhiteListAllow}{$domain}++;
}

sub WhiteListDenyURI ($$$){
    my ($cfg,$parms,$uri) = @_;
    $cfg->{WhiteListDenyURI}=$uri;
}


1;
__END__   

-----

The configuration portion is simple - I merely:

PerlRequire Emusic::WhiteList

and in a directory block:

<Directory /foo/>
  PerlAccessHandler Emusic::WhiteList
  WhiteListAllow  foo.com
  WhiteListDenyURI http://www.foo.com/bar/baz.html
</Directory>

I'm stumped. For the most part, I copied and pasted my code directly
from the book.

Has anyone else hit this problem? 

-- 
Kevin  | "Though there are ... few restrictions on the vote nowadays ... 
Murphy | some standards are still upheld ... at last report, the votes 
       | from the entire God-forsaken state of Texas are still thrown, 
       | uncounted and burning, into the River Charles." - T.H. Zweibel

Re: Problems with custom configuration handlers

Posted by Kevin Murphy <ke...@boojiboy.eorbit.net>.
Doug MacEachern wrote:
> what options did you give mod_perl's Makefile.PL?  

perl Makefile.PL \
     APACHE_PREFIX=/usr/local/apache/ \
     APACHE_SRC=/usr/local/apache/src\
     DO_HTTPD=1 \
     USE_APACI=1 \
     APACI_ARGS='--enable-module=rewrite --enable-module=so
--enable-module=proxy' \
     EVERYTHING=1 \
     PERL_TRACE=1    

> how to you load
> Emusic::WhiteList?
> 
> PerlModule Emusic::WhiteList
> before WhiteListAllow should work.
> if not, try this in httpd.conf:

Aha! I think I've found the problem.

I have all my mod_perl configuration options <Include>ed from a seperate
mod_perl.conf file.

When I put the PerlModule in the main httpd.conf, it works. I'm guessing
that Apache needs to have all of its configuration structures loaded
before it starts parsing external configuration files?

This is fine for the time being, but it would be nice if I could keep
all of the mod_perl configuration options together. Any chance of a
work-around?


-- 
Kevin  | "Though there are ... few restrictions on the vote nowadays ... 
Murphy | some standards are still upheld ... at last report, the votes 
       | from the entire God-forsaken state of Texas are still thrown, 
       | uncounted and burning, into the River Charles." - T.H. Zweibel

Re: Problems with custom configuration handlers

Posted by Doug MacEachern <do...@covalent.net>.
On Wed, 12 Apr 2000, Kevin Murphy wrote:

> I've written an access handler which takes some custom configuration
> directives based on the instructions in chaper 8 of the Eagle book. 
> 
> Everything makes and installs fine, and I am able to load the module
> with a PerlModule directive, but when I try to use the directives
> defined in my module I get an error:
> 
> "Invalid command 'WhiteListAllow', perhaps mis-spelled or defined by a
> module not included in the server configuration"

> package Emusic::WhiteList;

what options did you give mod_perl's Makefile.PL?  how to you load
Emusic::WhiteList?

PerlModule Emusic::WhiteList

before WhiteListAllow should work.
if not, try this in httpd.conf:

<Perl>
require Emusic::WhiteList;
delete $INC{'Emusic/WhiteList.pm'};
#this is what mod_perl is supposed to do internally
</Perl>

WhiteListAllow ...