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/08 18:24:19 UTC

Can't create custom config directives (long)

Hi All,

(This message is VERY long --I'm trying to include as much information as I 
can)

Back on June 3 I posted a message about a problem I was having installing 
custom configuration directives.  Since then, I have been going over 
everything with a fine tooth comb -- which was probably not worth the 
effort at all because the whole process (at least as explained in the eagle 
book) is a piece of cake.  Basically, perl does all the hard work and all I 
do is a couple of tables.

Last night I rebuilt apache and mod_perl (versions 1.3.12 and 1.23 
respectively -- mod_perl being compiled in and not a dso) in order to build 
mod_perl with the PERL_TRACE option, and also to discover if there was 
something flaky in the previous build.  If the latter is the case, the 
flakiness carried over since it still fails.

Basically, when you invoke httpd as a daemon, it starts up successfully, 
parses the httpd.conf file, finds no problem and returns with an exit code 
of '0', meaning that it found no problem and forked off the daemonm copy. 
Thus, apachectl reports that apache was successfully started.  Howver, the 
daemon dies quickly and reports in the error_log:

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

If I actually mess with the directive, spell it wrong or add or remove an 
argument, when apache originally parses the httpd.conf file it finds reason 
to complain, and apachectl does not come back and report a successful 
startup.  Rather, it report an error, run "apachectl configtest" to see the 
error.  Also, when I add various debug hooks into the callback for the 
directive, I can confirm that it's being invoked and getting the argument 
(it's a TAKE1).  So, whatever is going on is something else, and it's 
happening after the initial fork.

I have included the debug output below, tracing was set to "all".

> [root@cheshire apache]# bin/httpd -X
> perl_parse args: '/dev/null' ...allocating perl interpreter...ok
> constructing perl interpreter...ok
> ok
> running perl interpreter...ok
> mod_perl: 0 END blocks encountered during server startup
> PerlRequire: arg=`conf/startup.pl'
> attempting to require `conf/startup.pl'
> loading perl module 'Apache::Constants::Exports'...ok
> perl_cmd_fresh_restart: 1
> perl_cmd_setenv: 'PERL_DESTRUCT_LEVEL' = '-1'
> perl_cmd_setenv: 'DBMauthFile' = 'private/authen/passwdMD5'
> loading perl module 'Apache'...ok
> PerlModule: arg='Apache::MirrorWise'
> loading perl module 'Apache::MirrorWise'...ok
> init `PerlHandler' stack
> perl_cmd_push_handlers: @PerlHandler, 'Apache::MirrorWise'
> pushing `Apache::MirrorWise' into `PerlHandler' handlers
> blessing cmd_parms=(0xbfffda68)

However, in the error log we read:

> Syntax error on line 16 of /usr/local/apache/conf/perl.conf:
> Invalid command 'MirrorWiseKeyFile', perhaps mis-spelled or defined by a 
> module not included in the server configuration

This is the perl.conf file that contains the directive:


> PerlRequire		conf/startup.pl
> PerlFreshRestart	On
>
> #<Location /hello/world>
> #  SetHandler perl-script
> #  PerlHandler Apache::Hello
> #</Location>
> #
> PerlSetEnv PERL_DESTRUCT_LEVEL -1
> PerlSetEnv DBMauthFile private/authen/passwdMD5
> #
> PerlModule  Apache::MirrorWise
> SetHandler  perl-script
> PerlHandler Apache::MirrorWise
> #
> MirrorWiseKeyFile conf/keyfile
>

Anybody have any ideas?

Thanks,
Rob


ATTACHED HISTORY:

Here follows the original post and a dialogue I had with another member of 
the list.  His suggestions were helpful, but did not resolve the issue.

> 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.
>

Here follows the significant part of a dialogue a had with Matt Sergeant on 
the list:

> 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?



       _ _ _ _           _    _ _ _ _ _
      /\_\_\_\_\        /\_\ /\_\_\_\_\_\
     /\/_/_/_/_/       /\/_/ \/_/_/_/_/_/  QUIDQUID LATINE DICTUM SIT,
    /\/_/__\/_/ __    /\/_/    /\/_/          PROFUNDUM VIDITUR
   /\/_/_/_/_/ /\_\  /\/_/    /\/_/
  /\/_/ \/_/  /\/_/_/\/_/    /\/_/         (Whatever is said in Latin
  \/_/  \/_/  \/_/_/_/_/     \/_/              appears profound)

  Rob Tanner
  McMinnville, Oregon
  rtanner@onlinemac.com