perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sean P Quinlan <>
Subject Problem using PerlSection and global object in conf
Date Thu, 04 Jan 2007 22:13:54 GMT
I have an application I am in the process of upgrading to
Apache/mod_perl 2. While reading the docs, I came across this section:

Which I was really excited to try! My application handles user
authentication and authorization, but was designed to work from many
points, not just for web pages (though that is its main  function). The
core just underwent a major rewrite to a cleaner, inheritable OO
interface that I'm very happy with. The way the new version is designed,
a 'client' object will cache the user objects (relatively small, name,
email, phone etc) for users previously authenticated, using a session
token as a key. Reading the document above, it seemed I would be able to
create a client object at startup, which could cache 'currently'
authenticated users (cleanup on the configured timeout), saving a lot of
database accesses. As yet I have not been able to test the usefulness of
this approach however as I can't seem to get off the ground, getting
tangled with errors in configuration.

Here is the relevant part of the documentation I'm trying to work from:

      use Bird::Eagle;
      $Bird::Global::object = Bird::Eagle->new();
  PerlResponseHandler $Bird::Global::object->handler

And here is the relevant portions of my configuration file (located in

	$Apache2::PerlSections::Save = 1;
	use CAS::Apache::Auth;
	# The default CAS client for the admin location
	$CAS_admin_client = 1;
	$Auth_admin = CAS::Apache::Auth->new({CLIENT_ID => $CAS_admin_client});

<Location /CAS>
	AuthName CAS
	AuthType basic
	PerlAuthenHandler $Auth_admin->authen
#	PerlAuthzHandler $Auth_admin->authz
	require valid-user
#	Order deny,allow
#	Deny from all

Which returns the following error on configtest:
Syntax error on line 20 of /etc/apache2/conf.d/CAS.conf:
Unknown type 'CAS::Apache::Auth' for directive Auth_admin
at /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi/Apache2/ line 187.\n

Commenting out the PerlAuthenHandler directive in location has no effect
on the error. I've spent a day searching docs and the mailing list,
trying all sorts of variations, with no luck (and some annoyance, with
repeated references to docs like eg/perl_sections.txt which I can't find
in the distribution!). My main thought was to move the entire <Location>
section under <Perl>:

	use CAS::Apache::Auth;
	$CAS_admin_client = 1;
	$Auth_admin = CAS::Apache::Auth->new({CLIENT_ID => $CAS_admin_client});
	$Location{"/Cas"} = {
		PerlAuthenHandler => $Auth_admin->authen,
		AuthName => 'CAS',
		AuthType => 'basic',
		require => 'valid-user',

Which got me:
Syntax error on line 20 of /etc/apache2/conf.d/CAS.conf:
\t(in cleanup) Can't call method "get_basic_auth_pw" on an undefined
value at /usr/lib/perl5/site_perl/5.8.8/CAS/Apache/ line 57.\n
\t(in cleanup) \t(in cleanup) Can't call method "get_basic_auth_pw" on
an undefined value at /usr/lib/perl5/site_perl/5.8.8/CAS/Apache/
line 57.\n

Ah! The authen method gets $self and then $r, then gets the status and
password with $r->get_basic_auth_pw. Oops, I'm calling the method
instead of setting it as a handler. Perhaps setting it as a coderef? So
I changed PerlAuthenHandler to:

		PerlAuthenHandler => \$Auth_admin->authen,

But I still get:
Syntax error on line 20 of /etc/apache2/conf.d/CAS.conf:
\t(in cleanup) Can't call method "get_basic_auth_pw" on an undefined
value at /usr/lib/perl5/site_perl/5.8.8/CAS/Apache/ line 57.\n
\t(in cleanup) \t(in cleanup) Can't call method "get_basic_auth_pw" on
an undefined value at /usr/lib/perl5/site_perl/5.8.8/CAS/Apache/
line 57.\n

Is what I am trying to do actually possible? Do I have a stupid typo or
such somewhere? The first error (Unknown type 'CAS::Apache::Auth' for
directive Auth_admin), and other PerlSection docs seem to indicate to me
that under <Perl> sections, $Foo = 'bar'; is the equivalent of Foo bar
(Directive value), and does not create variables usable in other parts
of the conf. But I'm at a loss to understand why a code reference being
set as the target handler executes the code during configuration.

If in the handler I catch the call from conf and return harmlessly, will
calls while running work the way I think the docs indicate? Help solving
this to do what I want would be greatly appreciated!

Details, details:

SuSE 10.1 (net install)

267: 4:07pm % uname -a
Linux xxxxxxxx #1 Wed Dec 13 09:34:50 UTC 2006
i686 athlon i386 GNU/Linux

268: 3:50pm % /usr/sbin/apache2ctl -V
Server version: Apache/2.2.0
Server built:   Jul 27 2006 13:28:51
Server's Module Magic Number: 20051115:0
Architecture:   32-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D HTTPD_ROOT="/srv/www"
 -D SUEXEC_BIN="/usr/sbin/suexec2"
 -D DEFAULT_PIDLOG="/var/run/"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="/var/run/accept.lock"
 -D DEFAULT_ERRORLOG="/var/log/apache2/error_log"
 -D AP_TYPES_CONFIG_FILE="/etc/apache2/mime.types"
 -D SERVER_CONFIG_FILE="/etc/apache2/httpd.conf"

269: 4:06pm % perl -V
Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
    osname=linux, osvers=2.6.16, archname=i586-linux-thread-multi
    uname='linux tait 2.6.16 #1 smp tue mar 14 18:04:33 utc 2006 i686
i686 i386 gnulinux '
    config_args='-ds -e -Dprefix=/usr -Dvendorprefix=/usr
-Dinstallusrbinperl -Dusethreads -Di_db -Di_dbm -Di_ndbm -Di_gdbm
-Duseshrplib=true -Doptimize=-O2 -march=i586 -mtune=i686
-fmessage-length=0 -Wall -D_FORTIFY_SOURCE=2 -g -Wall -pipe'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
-DDEBUGGING -fno-strict-aliasing -pipe -Wdeclaration-after-statement
    optimize='-O2 -march=i586 -mtune=i686 -fmessage-length=0 -Wall
-D_FORTIFY_SOURCE=2 -g -Wall -pipe',
-fno-strict-aliasing -pipe -Wdeclaration-after-statement'
    ccversion='', gccversion='4.1.0 (SUSE Linux)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =''
    libpth=/lib /usr/lib /usr/local/lib
    libs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=/lib/, so=so, useshrplib=true,
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E
    cccdlflags='-fPIC', lddlflags='-shared'

Characteristics of this binary (from libperl):
  Built under linux
  Compiled at Apr 23 2006 00:26:41

Sean P Quinlan <>

View raw message