Randy Kobes wrote:
On Tue, 29 Jul 2003, ColinB wrote:


Well I commented out the following line in
perl/lib/site_perl/5.8.0/sun4-solaris/Apache2/ModPerl/RegistryCooker.pm
like this:

#*chdir_file = \&NOP;

and added an identical definition to the above in my startup.pl file
like this:

sub ModPerl::RegistryCooker::chdir_file {
   use File::Basename();
   my $file = @_ == 2 ? $_[1] : $_[0]->filename;
   my $dir = File::Basename::dirname($file);
   chdir $dir or die "Can't chdir to $dir: $!";
}

and then in my httpd.conf I replaced
  PerlResponseHandler Apache::Registry
with
  PerlResponseHandler ModPerl::Registry
and then re-started the server.

But the printenv script just displays the working directory as "/".


Try the following, instead of ModPerl::RegistryCooker::chdir_file
above:

 sub chdir_file_normal {
     use File::Basename();
     my $file = @_ == 2 ? $_[1] : $_[0]->{FILENAME};
     my $dir = File::Basename::dirname($file);
     chdir $dir or die "Can't chdir to $dir: $!";
 }


Don't mess with the cooker, try using a subclass, e.g.:

# ModPerl/RegistryPrefork.pm

package ModPerl::RegistryPrefork;

use strict;
use warnings FATAL => 'all';

our $VERSION = '0.01';

use base qw(ModPerl::Registry);

use File::Basename ();

sub handler : method {
    my $class = (@_ >= 2) ? shift : __PACKAGE__;
    my $r = shift;
    return $class->new($r)->default_handler();
}

sub chdir_file {
    use File::Basename();
    my $file = @_ == 2 ? $_[1] : $_[0]->{FILENAME};
    my $dir = File::Basename::dirname($file);
    chdir $dir or die "Can't chdir to $dir: $!";
}

1;
__END__

now configure it as before but use the package name ModPerl::RegistryPrefork;

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com



Reply via email to