You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Rob Tanner <rt...@onlinemac.com> on 2000/06/04 06:50:58 UTC

Can't create custom configuration directives

Hi all,

I'm trying to create several custom configuration directives, and have
pretty mucg followed the eample in the eagle book (pp 387-394).

I start Apache up -- get no configuration complaints and apachectl comes
back saying Apache started.  The info messages in the error log,
however, indicate otherwise.  To wit: 

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

In Makefile.PL, I include:	    
my @directives = (
		  { name         => 'MirrorWiseKeyFile',
		    errmsg       => 'location of password DB key file',
		    args_how     => 'TAKE1',
		    req_override => 'OR_ALL' },
                  {
                    <a second directive here but not yet 
                        added to httpd.conf>  },
                 );

command_table(\@directives);

# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
	      'NAME'		  => __PACKAGE__,
	      'VERSION_FROM'	  => 'MirrorWise.pm',
	      'INC'		  => Apache::src->new->inc,
	      'INSTALLSITEARCH'   => $install_here,
	      'INSTALLSITELIB'    => $install_here,
	     );

1;

The $install_here, above, is simply a scalar set to the module root 
in the Apache doc root (currently: /usr/local/apache/lib/perl).

In the module, I include:

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


# Configuration Processing Callbacks

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

Right now I'm not doing anything fancy in the callback -- I'm just
trying to read the value.  It's actually the name of a file that must 
be opened with root privilege, so that will get added later.

If I comment out DynaLoader or mess up the directive's syntax (e.g.,
give it two args, not one), the startup complains, for example:

MirrorWiseKeyFile takes one argument, location of password DB key file

The complaint prints to my screen, and it's just what I would expect. 
It 
suggests to me that Apache is reading and correctly parsing the
directive.
Moreover, I can add a print statement in the callback and confirm both
that it is being called and that it is getting the proper value from the
directive in the httpd.conf file.

But take the print statements out, uncomment DynaLoader and fix the
syntax,
and apachectl starts up apache with no complaints whatsoever, and comes
back with httpd started.  Yet the error_log still says the directive is
invalid.

I'm using perl 5.6, mod_perl 1.23 and apache 1.3.12. Mod_perl is
compiled
in to the server.

Any clues?  Thanks.

-- Rob


       _ _ _ _           _    _ _ _ _ _
      /\_\_\_\_\        /\_\ /\_\_\_\_\_\
     /\/_/_/_/_/       /\/_/ \/_/_/_/_/_/  QUIDQUID LATINE DICTUM SIT,
    /\/_/__\/_/ __    /\/_/    /\/_/          PROFUNDUM VIDITUR
   /\/_/_/_/_/ /\_\  /\/_/    /\/_/
  /\/_/ \/_/  /\/_/_/\/_/    /\/_/         (Whatever is said in Latin
  \/_/  \/_/  \/_/_/_/_/     \/_/              appears profound)
  
  Rob Tanner
  McMinnville, Oregon
  rtanner@onlinemac.com

Re: Can't create custom configuration directives

Posted by Rob Tanner <rt...@onlinemac.com>.
Matt Sergeant wrote:
> 
> On Sun, 4 Jun 2000, Rob Tanner wrote:
> 
> > > That you define $VERSION before the bootstrap line.
> > >
> >
> > As below:
> >
> > $VERSION = '0.9b';
> >
> > if ( $ENV{'MOD_PERL'} ) {
> >   no strict;
> >   @ISA = qw(DynaLoader);
> >   __PACKAGE__->bootstrap($VERSION);
> > }
> 
> That might represent a problem. $VERSION is supposed to be a real
> number. Perl uses internal numeric comparison operators on them.
> 

Matt,

Thanks for your suggestions.

I got my hopes up, changed it to '0.9' but no go :-(  Even tried '1.0'
in case doesn't like number below one.  Same thing.  :-(

Shucks and golly!  Is it possible that there is some apache or mod_perl
compile time parameter that needed to be set and wasn't, and if so, what
might that be?  Since the process of adding these directives is pretty
much automated there's not much I can do to mess it up, and then I would
expect it to be glaring -- i.e., apache fails to start with an exit code
other than '0', but that's not the case. And I know that apache invokes
the callback routine because I stuck a print statement in could see it. 
What's left?

Signed,
One Frustrated Dude


-- Rob


       _ _ _ _           _    _ _ _ _ _
      /\_\_\_\_\        /\_\ /\_\_\_\_\_\
     /\/_/_/_/_/       /\/_/ \/_/_/_/_/_/  QUIDQUID LATINE DICTUM SIT,
    /\/_/__\/_/ __    /\/_/    /\/_/          PROFUNDUM VIDITUR
   /\/_/_/_/_/ /\_\  /\/_/    /\/_/
  /\/_/ \/_/  /\/_/_/\/_/    /\/_/         (Whatever is said in Latin
  \/_/  \/_/  \/_/_/_/_/     \/_/              appears profound)
  
  Rob Tanner
  McMinnville, Oregon
  rtanner@onlinemac.com

Re: Can't create custom configuration directives

Posted by Matt Sergeant <ma...@sergeant.org>.
On Sun, 4 Jun 2000, Rob Tanner wrote:

> > That you define $VERSION before the bootstrap line.
> > 
> 
> As below:
> 
> $VERSION = '0.9b';
> 
> if ( $ENV{'MOD_PERL'} ) {
>   no strict;
>   @ISA = qw(DynaLoader);
>   __PACKAGE__->bootstrap($VERSION);
> }

That might represent a problem. $VERSION is supposed to be a real
number. Perl uses internal numeric comparison operators on them.

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org http://xml.sergeant.org


Re: Can't create custom configuration directives

Posted by Rob Tanner <rt...@onlinemac.com>.
Matt Sergeant wrote:
> 
> I've snipped the lengthy explanation. Here's a few things you can check:
> 
> There's no old version of your module in the ordinary perl lib directory,
> rather than the i386-foo/ directory.

Interesting thought, so I checked it.  My module is actually under the
Apache server root ($SERVER_ROOT/lib/perl/Apache/module.pm), but the
linux system I'm using (Caldera 2.3) was loaded with an earlier version
of perl from the installer.  But, nope, that didn't pan out.  No
duplicates anywhere.  Everything is 5.6.

> That you use DynaLoader.

Yep.  When I tried commenting DynaLoader out just to see what would
happen, Apache complained to STDERR directly and not the error_log
file.  In the failure mode I'm dealing with,apache returns an exit code
of '0' on startup, and apachectl reports that the daemon is started. 
That much I can see in the strace.  The last thing it does is fork a
detached copy of itself, and it's that first forked copy that's failing.

BTW: when I strace with the '-f' option (follow the child), the first
thing that the child process appears to do is go looking for a
DESTROY.al module in a subdirectory under my module name which it does
not find, following the order in @INC.  I'm not yet sufficiently
familiar with all the bits and bytes or what goes on behind the scenes
using objects, so I'm not sure if that's a clue or not.  After that, the
child opens httpd.conf and looks for each LoadModule and then dies with
the invalid directive error. 

> That you define $VERSION before the bootstrap line.
> 

As below:

$VERSION = '0.9b';

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


# Configuration Processing Callbacks

sub MirrorWiseKeyFile ($$$) {
  my($cfg, $parms, $keyfile) = @_;
  print "MirrorWiseKeyFile: $keyfile\n";
  $cfg->{'MirrorWiseKeyFile'} = $keyfile;
}


> --
> <Matt/>
> 
> Fastnet Software Ltd. High Performance Web Specialists
> Providing mod_perl, XML, Sybase and Oracle solutions
> Email for training and consultancy availability.
> http://sergeant.org http://xml.sergeant.org


-- Rob


       _ _ _ _           _    _ _ _ _ _
      /\_\_\_\_\        /\_\ /\_\_\_\_\_\
     /\/_/_/_/_/       /\/_/ \/_/_/_/_/_/  QUIDQUID LATINE DICTUM SIT,
    /\/_/__\/_/ __    /\/_/    /\/_/          PROFUNDUM VIDITUR
   /\/_/_/_/_/ /\_\  /\/_/    /\/_/
  /\/_/ \/_/  /\/_/_/\/_/    /\/_/         (Whatever is said in Latin
  \/_/  \/_/  \/_/_/_/_/     \/_/              appears profound)
  
  Rob Tanner
  McMinnville, Oregon
  rtanner@onlinemac.com

Re: Can't create custom configuration directives

Posted by Matt Sergeant <ma...@sergeant.org>.
I've snipped the lengthy explanation. Here's a few things you can check:

There's no old version of your module in the ordinary perl lib directory,
rather than the i386-foo/ directory.

That you use DynaLoader.

That you define $VERSION before the bootstrap line.

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org http://xml.sergeant.org