%ENV

2001-03-15 Thread Gene Dascher

Is the ENV hash sanitized and repopulated between the time the Perl*Auth
handlers are run and the requested cgi is executed?  I am setting an ENV key
in one of my handlers that I'd like to use in a cgi that resides in a
protected directory.  Is it possible to retain that variable throughout the
entire process, or will it always get wiped out?

Example:
I use my browser to call a cgi that is in a protected directory.  In the
PerlAuthenHandler, I set $ENV{'TEST_VAR'} = 1.  I can pull the value of
$ENV{'TEST_VAR'} in the PerlAuthzHandler, but when I try and fetch the value
in the cgi that I called, the key 'TEST_VAR' does not exist.

Thanks,

Gene Dascher




RE: %ENV

2001-03-15 Thread Gene Dascher

Well, with the subprocess_env(), I can see the key that I set in my cgi now,
but the value that I set the key to is a Hash reference that I need to use
in my cgi.  Unfortunately, all I get now is ENV{'TEST_VAR'} =
HASH(0x860a278), and I can't pull my values out.

Thanks for the help; it looks like we are headed in the right direction.
Now, is there any way to set an ENV key to a hash or hash reference and use
that later on in a cgi program?

Thanks,

Gene

-Original Message-
From: darren chamberlain [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 15, 2001 6:19 AM
To: modperl
Subject: Re: %ENV


Gene Dascher ([EMAIL PROTECTED]) said something to this effect on
03/15/2001:
 Is the ENV hash sanitized and repopulated between the time the Perl*Auth
 handlers are run and the requested cgi is executed?  I am setting an ENV
key
 in one of my handlers that I'd like to use in a cgi that resides in a
 protected directory.  Is it possible to retain that variable throughout
the
 entire process, or will it always get wiped out?

 Example:
 I use my browser to call a cgi that is in a protected directory.  In the
 PerlAuthenHandler, I set $ENV{'TEST_VAR'} = 1.  I can pull the value of
 $ENV{'TEST_VAR'} in the PerlAuthzHandler, but when I try and fetch the
value
 in the cgi that I called, the key 'TEST_VAR' does not exist.

Try fiddling with $r-subprocess_env; I've had good results that way. e.g.:

$r-subprocess_env('TEST_VAR', 1);

I haven't tried using %ENV, but I was under the impression it was
tied to the same internal Apache::Table object as
$r-subprocess_env, which means that setting $ENV{'TEST_VAR'}
should work as well.

Make sure you are setting this in the parent request, if you are
in a subrequest:

$r = ($r-is_main) ? $r : $r-main;

(darren)
--
The world is coming to an end!  Repent and return those library books!




Handler without handler()

2001-03-13 Thread Gene Dascher

I have a handler that I want to contain all of my methods for access
control, authentication and authorization.  I have created the file with 3
different methods named access($$), authentication($$) and
authorization($$).  I have these methods set up thusly in the httpd.conf
file:

Directory /usr/local/cgi-bin
PerlHandler Apache::Registry
AuthType Me::MyHandler
AuthName Me
PerlAccessHandler Me::MyHandler-access
PerlAuthenHandler Me::MyHandler-authenticate
PerlAuthzHandler Me::MyHandler-authorize
PerlInitHandler Apache::StatINC
PerlSetVar StatINCDebug On
require valid-user
/Directory

Unfortunately, every time I try and access a cgi in that directory, I get
the following errors:

Can't locate object method "access" via package "Me::MyHandler"
access.pm: Can't locate access.pm in @INC

So I have a couple of questions:
1) Can I write a handler that doesn't have a method named 'handler'?
2) If so, what do I have to put in the httpd.conf file to allow Apache to
properly access the handler methods?

Thanks,

Gene Dascher




Apache request object

2001-03-12 Thread Gene Dascher

How can I access the Apache Request object from a Perl package that I am
calling from a Perl Authorization handler?

Example:

Package TestPackage.pm
---
Package Apache::TestPackage.pm

@EXPORT qw ($home_url);

my $home_url = "http:" . "//" . $ENV{'SERVER_NAME'};

1;
---

Handler TestHandler.pm
---
Package Apache::TestHandler.pm

use Apache::TestPackage.pm

sub handler()
{
my $r = shift;

$r-log_error("Home URL = $home_url");
return OK;
}

1;
-

When I use the handler above, the $home_url does not print out because the
$ENV{'SERVER_NAME'} has not been set at the time that the TestHandler is
called.

I tried using the following code in TestPackage.pm:

my $r = Apache-request();
my $s = $r-server;

but the error I get is: Can't call method "server" on an undefined value.

I also tried using the server_name() function from CGI, but that also relies
on the $ENV{'SERVER_NAME'} as well.  I get $home_url = "localhost" when I
call that function from the Package.

Thanks,

Gene Dascher