I have traced my problem to the following subroutine which populates the Hash I use to keep track of mappings of URL's to Modules (handlers) to use.
As you will see, at the very end of my parse_file subroutine I have two lines commented out. IF I uncomment these lines out, I end up overwriting the data in my hash with the clean data I supply. When I do this my Apache Multiplexer (the thing which does the $r->push_handlers($handler_bf)) works fine and all is fine. However if I leave the line commented out - as is here - I get the following error:-
 
[Tue Sep 17 22:41:35 2002] [error] Undefined subroutine &MyMod::Apache::Test1 called, <GEN2> line 2.
 
 
 
So I'm at a loss, any further help you could give would be useful,
 
Marty
 
 
Here is a sample file:-
/test1/   =  MyMod::Apache::Test1
/test2/   =  MyMod::Apache::Test2

Here is a file parsing subroutine I use to read the above file and populate a hash, which I export to another routine.:-
 
our (%HANDLERS);
 
sub _is_tainted
{
  not eval
  {
    join("",@_), kill 0;
    1;
  };
}
 
sub parse_file
{
  my $file=shift;
  print STDERR "Parsing file $file\n";
  open (FILE,"<$file") or die "Cannot open file for reading $file";
  while (my $line=<FILE>)
  {
    chomp $line;
    if ($line=~/^\#/)
    {
      next;
    }
    else
    {
      my ($keyname,$varname)=split/\=/,$line;
      print STDERR "Initial $keyname = $varname\n";
      $keyname=~s/^\s*//;
      $varname=~s/^\s*//;
      $keyname=~s/\s*$//;
      $varname=~s/\s*$//;
      $keyname=~s/'//g;
      $varname=~s/'//g;
      $keyname=~s/"//g;
      $varname=~s/"//g;
 
      $keyname=~s/^\///;
      $keyname=~s/\/$//;
      my @tmp=split /\//, $keyname;
      my $untainted_keyname;
      while (@tmp)
      {
        my $tainted_var=shift @tmp;
        if ($tainted_var =~/^([\w-]+)$/)
        {
          $tainted_var=$1;
          die "$tainted_var is Tainted" if (&_is_tainted($tainted_var));
          $untainted_keyname.='/'.$tainted_var;
          die "$untainted_keyname is Tainted" if (&_is_tainted($untainted_keyname));
        }
        else
        {
          die "Taint Check failed for $tainted_var\n";
        }
      }
      $untainted_keyname.='/';
      if ($varname=~/^([-:\w]+)$/)
      {
        $varname=$1;
        die "$varname is Tainted" if (&_is_tainted($varname));
      }
      else
      {
        die "Taint Check failed for $varname\n";
      }
      $HANDLERS{$untainted_keyname}=$varname;
      print STDERR "Added $keyname = $varname\n";
    }
  }
  #$HANDLERS{'/test1/'}='MyMod::Apache::Test1';
  #$HANDLERS{'/test2/'} = 'MyMod::Apache::Test2';
  close (FILE);
}
----- Original Message -----
Sent: Tuesday, September 17, 2002 2:13 AM
Subject: problem with $r->push_handlers()

All,
 
can anybody provide any help with this problem  - and maybe explain why I get the following anomoly?
I've been trying to find the cause of the issue but to no avail:-(
 
I have MyMod::Apache::Test  pre-loaded in my httpd.conf file.
 
Here is an extract of code:-
($handler is defined from a Hash defined within this Code)
($handler_bf is defined from a hash exported by a module used in this code. to get to the stage in the code where the following lines commence, I already have read the value from the exported hash and it is held in the variable $handler_bf)
 
#$r->push_handlers(PerlHandler => $handler);
$r->push_handlers(PerlHandler => $handler_bf);

print STDERR "They match\n ($handler) = ($handler_bf)\n" if ($handler eq $handler_bf);
 
 
When I run the code I get the following error:-
 
MyMod::Apache::Multiplex Matched /test/ to MyMod::Apache::Test (MyMod::Apache::Test) for /
mod_perl_push_handlers: Not a subroutine name or CODE reference! at /usr/local/lib/perl//MyMod/Apache/Multiplex.pm line 101.
They match
 (MyMod::Apache::Test) = (MyMod::Apache::Test)
 
WHEREAS if I use the following code:-
 
#$r->push_handlers(PerlHandler => $handler);
$r->push_handlers(PerlHandler => $handler_bf);

print STDERR "They match\n ($handler) = ($handler_bf)\n" if ($handler eq $handler_bf);
 
It works and I get this output :-
 
MyMod::Apache::Multiplex Matched /reconciler/test/ to MyMod::Apache::Test (MyMod::Apache::Test) for /
They match
 (MyMod::Apache::Test) = (MyMod::Apache::Test)
 
 
So I'm still at a loss. I've tried checking for tainted variables as the handler hash which fails is populated by reading the contents of files, whereas the other is simply defined in the script.
I'm guessing this is something more subtle like a configuration problem.
 
I've tried stopping a starting apache after making each change to the script. so each test is run on a fresh server.
 
Anyway, Answers on a Postcard please:-)
 
Regards
 
Marty
 

Reply via email to