PerlSetEnv not working consistently in libapache2-mod-perl

Bug #305646 reported by Vernon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
libapache2-mod-perl2 (Ubuntu)
Fix Released
Low
Unassigned

Bug Description

Binary package hint: libapache2-mod-perl2

PerlSetEnv does not work correctly, unless it appears after a <Perl></Perl> block.
This may also affect PerlPassEnv, SetEnv, or other directives.
This has been reported elsewhere on the web but no-one seems to take note.

Here's how to duplicate...

Test1 - In http.conf:

PerlModule Data::Dumper
PerlSetEnv BOB hello
<Perl>
warn Data::Dumper::Dumper(\%ENV);
</Perl>

Ok, so when we run apache2ctl configtest we get:
$VAR1 = {
          'PATH' => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games',
          'MOD_PERL_API_VERSION' => '2',
          'MOD_PERL' => 'mod_perl/2.0.4'
        };
Syntax OK

As you can see the environment variable BOB does not exist. So, next test...

Test2 - In http.conf:

PerlModule Data::Dumper
<Perl>

</Perl>
PerlSetEnv BOB hello
<Perl>
warn Data::Dumper::Dumper(\%ENV);
</Perl>

Note the empty <Perl></Perl> block with a blank line! (The blank line is important)
Ok, so when we run apache2ctl configtest we get:
$VAR1 = {
          'BOB' => 'hello',
          'PATH' => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games',
          'MOD_PERL_API_VERSION' => '2',
          'MOD_PERL' => 'mod_perl/2.0.4'
        };
Syntax OK

Suddenly the PerlSetEnv works! PerlSetEnv should work without the need to include a blank <Perl></Perl> block.
This is particularly important because scripts called with PerlRequire and other directives (PerlConfigRequire PerlPostConfigRequire) will NOT get the correct %ENV variables passed on to them.

This was tested on:
Linux ubuntu 2.6.27-9-generic (Ubuntu 8.10)
libapache2-mod-perl2 2.0.4-1ubuntu1
apache2 2.2.9-7ubuntu3

Revision history for this message
Chuck Short (zulcss) wrote :

Hi,

I was wondering if you were still having this problem?

Thanks
chuck

Changed in libapache2-mod-perl2 (Ubuntu):
importance: Undecided → Low
status: New → Incomplete
Revision history for this message
Vernon (vernonlyon) wrote :

I've tested this again in Ubuntu 9.04 using libapache2-mod-perl2 2.0.4-5ubuntu1,
and the problem seems to have been resolved.

The PerlSetEnv is actually working before any perl block is used and before PerlRequire (as early as possible) which is good!

I guess this can now be closed.

Revision history for this message
Chuck Short (zulcss) wrote :

Thanks for the quick response. I am closing this now.

Regards
chuck

Changed in libapache2-mod-perl2 (Ubuntu):
status: Incomplete → Fix Released
Revision history for this message
Joakim (bannan) wrote :
Download full text (4.0 KiB)

Hi, i am experiencing the same problem:

httpd.conf

        <Perl>

        </Perl>
        PerlSetEnv TESTENV "asdf"
          <Perl>
        warn Data::Dumper::Dumper(\%ENV);
        </Perl>

Output:

root@joakim-laptop:/etc/apache2# service apache2 start
 * Starting web server apache2 $VAR1 = {
          'TESTENV' => 'asdf',
          'PATH' => '/usr/local/bin:/usr/bin:/bin:/home/db2inst1/sqllib/bin:/home/db2inst1/sqllib/adm:/home/db2inst1/sqllib/misc:/home/db2inst1/sqllib/db2tss/bin',
          'MOD_PERL_API_VERSION' => 2,
          'MOD_PERL' => 'mod_perl/2.0.5'
        };

httpd.conf
        PerlSetEnv TESTENV "asdf"
          <Perl>
        warn Data::Dumper::Dumper(\%ENV);
        </Perl>

Output:
root@joakim-laptop:/etc/apache2# service apache2 start
 * Starting web server apache2 $VAR1 = {
          'PATH' => '/usr/local/bin:/usr/bin:/bin:/home/db2inst1/sqllib/bin:/home/db2inst1/sqllib/adm:/home/db2inst1/sqllib/misc:/home/db2inst1/sqllib/db2tss/bin',
          'MOD_PERL_API_VERSION' => 2,
          'MOD_PERL' => 'mod_perl/2.0.5'
        };

My configuration:
root@joakim-laptop:/etc/apache2# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=11.10
DISTRIB_CODENAME=oneiric
DISTRIB_DESCRIPTION="Ubuntu 11.10"
root@joakim-laptop:/etc/apache2# dpkg --get-selections | grep apache
apache2 install
apache2-mpm-worker install
apache2-threaded-dev install
apache2-utils install
apache2.2-bin install
apache2.2-common install
libapache2-mod-apreq2 install
libapache2-mod-perl2 install
libapache2-mod-perl2-dev install
libapache2-reload-perl install
libapache2-request-perl install
root@joakim-laptop:/etc/apache2# dpkg -s libapache2-mod-perl2
Package: libapache2-mod-perl2
Status: install ok installed
Priority: optional
Section: httpd
Installed-Size: 3736
Maintainer: Ubuntu Developers <email address hidden>
Architecture: i386
Version: 2.0.5-2ubuntu1
Depends: perl (>= 5.12.3-6ubuntu4), perlapi-5.12.3, libapr1 (>= 1.2.7), libaprutil1 (>= 1.2.7+dfsg), libc6 (>= 2.4), libperl5.12 (>= 5.12.3), apache2 | apache2-mpm-itk, apache2.2-common, libdevel-symdump-perl, liburi-perl, libwww-perl, netbase
Recommends: libbsd-resource-perl, libapache2-reload-perl
Conffiles:
 /etc/apache2/mods-available/perl.load 19ba69a03d3e3d23ac13407c2ad7bdbb
Description: Integration of perl with the Apache2 web server
 mod_perl allows the use of Perl for just about anything
 Apache-related, including <Perl> sections in the config
 files and the famous Apache::Registry module for caching
 compiled scripts.
 .
 It can produce anywhere from a 400% to 2000% speed increase
 on sites using perl scripts, and is used on many large script-
 based web sites - for example, http://slashdot.org.
Homepage: http://perl.apache.org/
Original-Maintainer: Debian Perl Group <email address hidden>
root@joakim-laptop:/etc/apache2# dpkg -s libapache2-mod-perl2-dev...

Read more...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.