RE: Sticky Pages.

2002-01-07 Thread David LeBlanc

Ok, now i'm totally confused. From the top:

1. I have the following (and ONLY the following related to modperl) in my
httpd.conf file (of course there are other regular apache directives too):
LoadModule perl_module modules/mod_perl.so
AddModule mod_perl.c

In a subdirectory there's an .htaccess file containing this reference to
modperl:
Files *
SetHandler perl-script
PerlHandler Apache::Registry
Options ExecCGI
PerlSendHeader On
/Files

These are the only references to modperl that I have. TWiki is the only perl
app that I run, so I thought I only needed the lines in the .htaccess file.
I have changed the line reading PerlHandler Apache::Registry to
Perlhandler Apache::PerlRun as you suggested, and it results in the error
I reported to you.'

I would really appreciate it if you would tell me exactly what I should do
to implement this alternative you've suggested.

Sincerely,

Dave LeBlanc

 -Original Message-
 From: Stas Bekman [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, January 06, 2002 20:23
 To: David LeBlanc
 Subject: Re: Sticky Pages.


 David LeBlanc wrote:

  At first you suggested Apache::PerlRun, and this is the first mention of
  PerlModule Apache::PerlRun i've seen.


 Huh? It's the same module, but you need to load it!


  Where whould I add this directive, in the httpd.conf file or in my local
  .htaccess file?

 Man, this is what you should put into your httpd.conf file.

  PerlModule Apache::PerlRun
  Files *
SetHandler perl-script
PerlHandler Apache::PerlRun
Options ExecCGI
PerlSendHeader On
  /Files







  Dave LeBlanc
 
 
 -Original Message-
 From: Stas Bekman [mailto:[EMAIL PROTECTED]]
 Sent: Friday, January 04, 2002 18:22
 To: David LeBlanc
 Subject: Re: Sticky Pages.
 
 
 David LeBlanc wrote:
 
 
 As described in my original mail, mod_perl is only mentioned in the
 httpd.conf file in LoadModule/AddModule statements.
 
 
 I've suggested to add
 PerlModule Apache::PerlRun
 
 Did you do it?
 
 
 
 In the /Apache/TWiki/bin directory is an .htaccess file with this bit:
 
 Files *
SetHandler perl-script
PerlHandler Apache::Registry
Options ExecCGI
PerlSendHeader On
 /Files
 
 Changing the PerlHandler Apache::Registry line to PerlHandler
 Apache::PerlRun caused the error shown below:
 [Thu Jan 03 10:40:24 2002] [error] Can't locate object method
 
 filename via
 
 package Apache (perhaps you forgot to load Apache?) at
 J:/Perl/site/lib/Apache/PerlRun.pm line 24.
 
 FWIW, I tried installing Apache::Dbg, but it doesn't work on
 
 Windows. IIRC,
 
 it dies during the install build with a complaint about some
 
 SIG (signal)
 
 not being defined.
 
 Thanks for your patience and help.
 
 
 Please reply to the list and not to me in person. Other people can help
 too. And I'm not much of help with win32 systems as I don't work
 with these.
 
 
 
 Sincerely,
 
 Dave LeBlanc
 
 
 
 -Original Message-
 From: Stas Bekman [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, January 03, 2002 21:11
 To: David LeBlanc
 Cc: [EMAIL PROTECTED]
 Subject: Re: Sticky Pages.
 
 
 David LeBlanc wrote:
 
 
 
 Stan;
 
 I tried using Apache::PerlRun and got this in the error log:
 [Thu Jan 03 10:40:24 2002] [error] Can't locate object method
 
 
 filename via
 
 
 package Apache (perhaps you forgot to load Apache?) at
 J:/Perl/site/lib/Apache/PerlRun.pm line 24.
 
 What does this mean?
 
 
 You've to give us more information to help you solve the problem. What
 is the relevant configuration section? You should have simply replaced
 Apache::Registry with Apache::PerlRun in httpd.conf
 
 don't forget to load it! Something like this:
 
 
 PerlModule Apache::PerlRun
 Files *
   SetHandler perl-script
   PerlHandler Apache::PerlRun
   Options ExecCGI
   PerlSendHeader On
 /Files
 
 
 
 
 -Original Message-
 From: Stas Bekman [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, January 02, 2002 23:55
 To: David LeBlanc
 Cc: [EMAIL PROTECTED]
 Subject: Re: Sticky Pages.
 
 
 David LeBlanc wrote:
 
 
 
 
 Have a strange problem using modPerl as follows:
 
 OS:Windows 2000 Professional
 Webserver: Apache/1.3.22 (Win32)
 mod_perl:  mod_perl/1.26_01-dev
 
 mod_perl is loaded in the httpd.conf file (LoadModule perl_module
 modules/mod_perl.so AddModule mod_perl.c), and also appears in
 
 
 
 the .htaccess
 
 
 
 file for the TWiki directory:
 Files *
  SetHandler perl-script
  PerlHandler Apache::Registry
  Options ExecCGI
  PerlSendHeader On
 /Files
 
 The Application i'm using is called TWiki (http://Twiki.org),
 
 
 and if you
 
 
 view some page within Twiki, close the browser, open a new one
 
 
 
 and hit the
 
 
 
 link that takes you to the front page of Twiki, the last page
 
 
 
 you looked at
 
 
 
 in the just-deleted browser will be shown instead of the front
 
 
 
 page. TWiki
 
 
 
 does not exhibit this behavior when run as a CGI program, and
 
 
 
 

silly CGI::Cookie bug/frustrations

2002-01-07 Thread Neil Conway

Hi all,

I've spent the last couple hours trying to debug a seemingly simple
piece of code. I've come up with something that seems puzzling (but it's
probably just too early in the morning for me) -- any clarification
would be appreciated.

The code I'm writing is a cookie-based authentication scheme, inspired
by Apache::TicketAccess from the Eagle book (thanks Doug  Lincoln!).

I'm sending the client the ticket cookie like so:

use constant TICKET_NAME = 'AdminTicket';
# ... lots of code
my $ticket = CGI::Cookie-new(-name = TICKET_NAME,
  -path = '/'
  # more stuff
  );
$r-header_out('Set-Cookie' = $ticket);

Now, this seems to work fine. The browser is sent a cookie, and sends it
back to the server when it requests a page that requires authentication.
However, I can't seem to verify the cookie properly. Here's my
verification code:

sub verify_ticket {
my $self = shift;
my $r = $self-{_req};
print STDERR Cookie:  . $r-header_in('Cookie') . \n; #DEBUG
my %cookies = CGI::Cookie-parse($r-header_in('Cookie'));

return (0, 'user has no cookies') unless %cookies;
#DEBUG
my $cookie_name;
foreach (keys %cookies) {
print STDERR Cookie: [$_] - [$cookies{$_}]\n;
print STDERR Cookie name: [$_] ; Expected: [ . TICKET_NAME .
]\n;
print STDERR The cookies match.\n if $_ eq TICKET_NAME;
$cookie_name = $_; # HACK: remember a valid hash key
}

# this does NOT work
#return (0, 'user has no ticket') unless $cookies{TICKET_NAME};
# this works, strangely
return (0, 'user has no ticket') unless $cookies{$cookie_name};

# lots more code
}

(As you can tell, I've been banging my head against the wall for a
while, inserting print statements ;-) ).

I get the following log output:

Cookie:
AdminTicket=ip127.0.0.1expires15hashf6o%2BtYJ2AFm1aBy3plFrOigo1ygusernconwaytime1010403781
Cookie: [AdminTicket] -
[AdminTicket=ip127.0.0.1expires15hashf6o%2BtYJ2AFm1aBy3plFrOigo1ygusernconwaytime1010403781;
 path=/]
Cookie name: [AdminTicket] ; Expected: [AdminTicket]
The cookies match.

Now, this is as I expected it. However, the commented out code such as:

return (0, 'user has no ticket') unless $cookies{TICKET_NAME};

Doesn't work -- it seems to think that there is no such hash element as
TICKET_NAME.

Since there is only 1 cookie, I used the ugly hack above and iterated
through the keys of the hash and used the only actual hash element. The
weird that is that the value I get from this is 'eq' to TICKET_NAME --
yet, it works, but TICKET_NAME does not. IIRC, if I replace the
instances of TICKET_NAME with its literal value ('AdminTicket'), it also
does not work.

Would someone be kind enough to point out what I've missed? Because I'm
stumped...

Thanks in advance,

Neil

-- 
Neil Conway [EMAIL PROTECTED]
PGP Key ID: DB3C29FC




Re: Problems with cookies in Apache::AuthCookie

2002-01-07 Thread Øyvind Gjerstad

Charles Day wrote:

 key line must come first.  I used Portal instead of your PrisInformasjon,
 but you get the idea.


I tried that, but it made no difference.

I must be doing something wrong. I have now tried with a very similar 
setup on my linux box with apache 1.3.22, mod_perl 1.26 and all other 
modules fully up to date. No success. I rewrote my login-script to use 
plain perl instead of embperl. No success.

Any other ideas?

What should I get with lwp-request? I currently get this:
HTML
HEADTITLEAn Error Occurred/TITLE/HEAD
BODY
H1An Error Occurred/h1
403 Forbidden
/BODY
/HTML


I thought I should get the login-script output here? In a browser this 
seemmingly works. How can I test the redirect/cookie stuff?

 
 # key line must come first
 PerlSetVar PortalDBI_SecretKeyFile /somewhere/secured.key
 
 PerlModule Apache::AuthCookieDBI
 PerlSetVar PortalPath /
 PerlSetVar PortalLoginScript /login.pl
 PerlSetVar AuthCookieDebug 1
 PerlSetVar PortalDomain .mydomain.com
 PerlSetVar PortalDBI_DSN 'dbi:Pg:host=someserver port=5432 dbname=somedb'
 PerlSetVar PortalDBI_User username
 PerlSetVar PortalDBI_Password **
 PerlSetVar PortalDBI_UsersTable table
 PerlSetVar PortalDBI_UserField userid
 PerlSetVar PortalDBI_PasswordField passwd
 PerlSetVar PortalDBI_SessionLifeTime 00-12-00-00
 
 FilesMatch \.pl
  AuthType Apache::AuthCookieDBI
  AuthName Portal
  SetHandler perl-script
  PerlHandler Apache::Registry
  Options +ExecCGI
  PerlSendHeader On
 /FilesMatch
 
 # login.pl
 Files LOGIN
  AuthType Apache::AuthCookieDBI
  AuthName Portal
  SetHandler perl-script
  PerlHandler Apache::AuthCookieDBI-login
 /Files
 
 # website.
 Directory /home/httpd/html/secured
  PerlSetVar PortalDomain .mydomain.com
  PerlSetVar PortalLoginScript /login.pl
  AuthType Apache::AuthCookieDBI
  AuthName Portal
  PerlAuthenHandler Apache::AuthCookieDBI-authenticate
  PerlAuthzHandler Apache::AuthCookieDBI-authorize
  require valid-user
 /Directory
 
Here are the relevant parts (I think) from httpd.conf:

PerlSetVar PrisInformasjonPath /
PerlSetVar PrisInformasjonLoginScript /wwwappl/login.epl
PerlSetVar PrisInformasjonDomain .tollpost.no
PerlSetVar PrisInformasjonDBI_DSN DBI:Informix:testogj1
PerlSetVar PrisInformasjonDBI_SecretKeyFile /etc/opt/apache/secret.key
PerlSetVar PrisInformasjonDBI_UserField username
PerlSetVar AuthCookieDebug 3

PerlModule Apache::AuthCookieDBI

Directory /opt/www/tgweb/protected/
 AuthType Apache::AuthCookieDBI
 AuthName PrisInformasjon
 PerlAuthenHandler Apache::AuthCookieDBI-authenticate
 PerlAuthzHandler Apache::AuthCookieDBI-authorize
 require valid-user
/Directory

Files LOGIN
 AuthType Apache::AuthCookieDBI
 AuthName PrisInformasjon
 SetHandler perl-script
 PerlHandler Apache::AuthCookieDBI-login
/Files




-- 
Øyvind



**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager. (mailto:[EMAIL PROTECTED])

This footnote also confirms that this email message has been swept by
viruscheckers for the presence of computer viruses.
**




Re: Sticky Pages.

2002-01-07 Thread Perrin Harkins

 Ok, now i'm totally confused.

Have you read the documentation for Apache::PerlRun?  That might help.  Try
a perldoc Apache::PerlRun.

 1. I have the following (and ONLY the following related to modperl) in my
 httpd.conf file (of course there are other regular apache directives too):
 LoadModule perl_module modules/mod_perl.so
 AddModule mod_perl.c

 In a subdirectory there's an .htaccess file containing this reference to
 modperl:
 Files *
   SetHandler perl-script
   PerlHandler Apache::Registry
   Options ExecCGI
   PerlSendHeader On
 /Files

You are telling Apache what module to use for these files, but you also have
to tell it to load the module.  Put in PerlModule Apache::PerlRun before
your Files section as directed by Stas and the PerlRun documentation.

- Perrin




[ANNOUNCE] Apache::Handlers 0.02 / Perl::WhichPhase 0.01

2002-01-07 Thread James G Smith

The uploaded file

Apache-Handlers-0.02.tar.gz

has entered CPAN as

  file: $CPAN/authors/id/J/JS/JSMITH/Apache-Handlers-0.02.tar.gz
  size: 6720 bytes
   md5: 7b7174b3b60bb7258d388467e33cfbff

This module allows snippets of code to be run at any of the phases
during a request.  It can be prettier than using the Apache -
push_handlers method, and if done in the right way (either during the
configuration phase or via a `use' statement) will be persistant
across requests.



The uploaded file

Perl-WhichPhase-0.01.tar.gz

has entered CPAN as

  file: $CPAN/authors/id/J/JS/JSMITH/Perl-WhichPhase-0.01.tar.gz
  size: 1926 bytes
   md5: fc9bd37aa54d4af8e52c86a97880cec8

This module provides tests for execution within BEGIN, END, INIT, and
CHECK blocks.
--
James Smith [EMAIL PROTECTED], 979-862-3725
Texas AM CIS Operating Systems Group, Unix



problems with Apache::AuthTicket

2002-01-07 Thread Tomasz Konefal

greetings,

   i'm hoping that someone out there can help me out with my AuthTicket 
troubles.

   first, i require a simple way to authenticate and authorize users for 
a little intranet site.  from what i could find, AuthTicket looks like 
the best way to do this (is there something better?).  PageKit also 
looks nice, but it's probably overkill for what i need.

   i've installed AuthTicket onto a FreeBSD 4.4 box running Apache. 
here is a snippet from the http error log.

---snip---
[Mon Jan  7 11:11:57 2002] [error] ENTRY Apache::AuthTicket::dbi_connect 
[line 215]
returning [DBI:Pg:dbname=ftpfudb] for TicketDB at 
/usr/local/lib/perl5/site_perl
/5.005/Apache/AuthTicket.pm line 104.
returning [ftpfu] for TicketDBUser at 
/usr/local/lib/perl5/site_perl/5.005/Apache/AuthTicket.pm line 104.
returning [in10se] for TicketDBPassword at 
/usr/local/lib/perl5/site_perl/5.005/
Apache/AuthTicket.pm line 104.
 DESTROY CALLED  at 
/usr/local/lib/perl5/site_perl/5.005/Apache/AuthTicket.pm line 227.
---snip---

here is the relevant portion of my httpd.conf file:

---snip---
## set AuthTicket defaults
##
PerlModule Apache::AuthTicket
PerlSetVar FtpFuTicketDB DBI:Pg:dbname=ftpfudb
PerlSetVar FtpFuTicketDBUser ftpfu
PerlSetVar FtpFuTicketDBPassword mypass
PerlSetVar FtpFuTicketTable tickets:ticket_hash:ts
PerlSetVar FtpFuTicketUserTable users:username:passwd
PerlSetVar FtpFuTicketPasswordStyle cleartext
PerlSetVar FtpFuTicketSecretTable ticketsecrets:sec_version:sec_data
PerlSetVar FtpFuTicketExpires 15
PerlSetVar FtpFuTicketLogoutURI /authorized/ftpfu.cgi
PerlSetVar FtpFuTicketLoginHandler /ftpfulogin
PerlSetVar FtpFuTicketIdleTimeout 1
PerlSetVar FtpFuPath /
PerlSetVar FtpFuDomain .compt.com
PerlSetVar FtpFuSecure 1
PerlSetVar FtpFuLoginScript /ftpfuloginform

## set access restrictions
##
Location /authorized
 AuthTypeApache::AuthTicket
 AuthNameFtpFu
 PerlAuthenHandler   Apache::AuthTicket-authenticate
 PerlAuthzHandlerApache::AuthTicket-authorize
 require valid-user
/Location

## how to display login and logout forms
##
Location /ftpfuloginform
 AuthTypeApache::AuthTicket
 AuthNameFtpFu
 SetHandler  perl-script
 PerlHandler Apache::AuthTicket-login_screen
/Location

Location /ftpfulogin
 AuthTypeApache::AuthTicket
 AuthNameFtpFu
 SetHandler  perl-script
 PerlHandler Apache::AuthTicket-login
/Location

Location /authorized/logout
 AuthTypeApache::AuthTicket
 AuthNameFtpFu
 SetHandler  perl-script
 PerlHandler Apache::AuthTicket-logout
/Location
---snip---

i've set up a postgresql database with the appropriate tables and 
permissios.  this script can access this database without any difficulty:

---snip---
#!/usr/bin/perl
use DBI;
   my $dbh=DBI-connect('DBI:Pg:dbname=foodb', 'foouser', 'foopasswd')
   or die couldn't connect:  . DBI-errstr;
   $dbh-disconnect;
---snip---

when i try to access the 'authorized/' portion of the site i get the 
login page.  when i submit a blank login form, i get the above httpd 
error log.  if i fill it in, i also get that error log.  at no time am i 
prompted to set a cookie (mozilla is set to ask if i want to allow cookies).

another thing to note is that i've got two versions of perl installed. 
the original 5.005 which came with freebsd, and an updated one which i 
got from CPAN.  @INC shows:

 /usr/local/lib/perl5/5.6.1/i386-freebsd
 /usr/local/lib/perl5/5.6.1
 /usr/local/lib/perl5/site_perl/5.6.1/i386-freebsd
 /usr/local/lib/perl5/site_perl/5.6.1
 /usr/local/lib/perl5/site_perl/5.005/i386-freebsd
 /usr/local/lib/perl5/site_perl/5.005
 /usr/local/lib/perl5/site_perl

so, i'm hoping that's not the problem.

can anyone help me out with this difficulty?

thanks,
   twkonefal




Apache::Util segfaulting

2002-01-07 Thread dbohling

Hi all,

I'm having an odd problem with a particular registry script.

This script causes a segmentation fault at the first usage of 
Apache::Util::escape_uri(),

This same script also uses Apache::Util::escape_html() with no problems 
at all.

Other scripts on this same server use Apache::Util::escape_uri() without 
any problems.

I've tried to get a core dump with httpd -X but it won't leave one.

This is apache 1.3.14 with mod_perl/1.24_01 and php/3.0.17 both built 
against the same mysql libraries.

Any ideas?

 
--
Daniel Bohling
NewsFactor Network




ANNOUNCE: CGI::URI2param 1.00

2002-01-07 Thread Thomas Klausner

Hi!

The URL

http://domm.zsi.at/source_code/modules/CGI-URI2param-1.00.tar.gz

has entered CPAN as

  file: $CPAN/authors/id/D/DO/DOMM/CGI-URI2param-1.00.tar.gz
  size: 4133 bytes
   md5: 2b216c471242e72dbcfc73059431756e

The main thing that changed is that I included Apache::URI2param, a
PerlInitHandler. 

From the README:

CGI::URI2param - convert parts of an URL to param values

DESCRIPTION

CGI::URI2param takes a request object (as supplied by CGI.pm or
Apache::Request) and a hashref of keywords mapped to
regular expressions. It applies all of the regexes to the current URI
and adds everything that matched to the 'param' list of the request
object.

Why?

With CGI::URI2param you can instead of:

 http://somehost.org/db?id=1234style=fancy
 
 present a nicerlooking URL like this:
 
  http://somehost.org/db/style_fancy/id1234.html
  
To achieve this, simply do:
  
   CGI::URI2param::uri2param($r,{
 style = 'style_(\w+)',
 id= 'id(\d+)\.html'
   });
   
Now you can access the values like this:
   
my $id=$r-param('id');
my $style=$r-param('style');
 
If you are using mod_perl, please take a look at Apache::URI2param.
It provides an Apache PerlInitHandler to make running CGI::URI2param
easier for you. Apache::URI2param is distributed along with
CGI::URI2param.


-- 
 D_OMM  +  http://domm.zsi.at -+
 O_xyderkes |   neu:  Arbeitsplatz   |   
 M_echanen  | http://domm.zsi.at/d/d162.html |
 M_asteuei  ++





PREANNOUNCE Tied Request and Cookies Module

2002-01-07 Thread Jay Lawrence

Hello All,

I have written a couple modules to provide tied access to GET/POST arguments
of an Apache request. Basically hides the mechanics of libapreq behind a
tied hash. On a similiar vein I have one for cookies. The nice thing about
the cookies one is that it will set headers automatically for you when you
untie it. I will also be writing one for posted and PUT files.

Both are lazy in that they do not do any processing until the first access
of a hash element. I like this strategy since I often use templates. I want
to make all these features available to the templates but not incur
unnecessary processing overhead if the information is not used.

I am thinking of names such as:

Apache::Request::Tied
or Apache::Args::Tied
and
Apache::Cookies::Tied
and
Apache::RequestFiles::Tied

or possibly:
Apache::Tied::Request, etc.

Any interest, comments, suggestions,

Yours,
Jay




ANNOUNCE: Apache::AuthenNTLM

2002-01-07 Thread Gerald Richter

The URL

ftp://ftp.dev.ecos.de/pub/perl/ntlm/Apache-AuthenNTLM-0.11.tar.gz

has entered CPAN as

  file: $CPAN/authors/id/G/GR/GRICHTER/Apache-AuthenNTLM-0.11.tar.gz
  size: 50288 bytes
   md5: fa69872fe0a643de4a02921b9d4715be


The purpose of this module is to perform a user authentication via
Mircosofts
NTLM protocol. This protocol is supported by all versions of the Internet
Explorer and is mainly usefull for intranets. Depending on your preferences
setting IE will supply your windows logon credentials to the web server
when the server asks for NTLM authentication. This saves the user to type in
his/her password again.

A lot of ideas and information are taken from the similar Apache module
mod_ntlm,
which can be found at http://sourceforge.net/projects/modntlm/

The main advantage of the Perl implementaion is, that it can be easily
extented
to verfiy the user/password against other sources than a windows domain
controller.
The default implementaion is to go to the domain controller for the given
domain
and verify the user. If you want to verify the user against another source,
you
can inherit from Apache::AuthenNTLM and override it's methods.

To support users that aren't using Internet Explorer, Apache::AuthenNTLM can
also perform basic authentication depending on it's configuration.

Enjoy

Gerald

-
Gerald Richterecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:   Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: [EMAIL PROTECTED] Voice:+49 6133 925131
WWW:http://www.ecos.de  Fax:  +49 6133 925152
-






mod-perl, modules and initializations

2002-01-07 Thread Dave Morgan

Hi All,
My environment is Apache, mod-perl, Apache::DBI, oracle backend,  
everything works fine. The problem is always MY code :)

I'm trying to figure out the correct/efficient way to initialize
constants in a  module. What I need to do is initialize various
constants when Apache is started,   whether hard coded, read in from a
file or extracted from a database. I have managed   to thoroughly
confuse myself and have the following questions.

What is the difference between how a BEGIN block and an anonymous block
in a module loaded into mod_perl? At different times I understand,
though
I probably don't understand the implications of that in a mod-perl
environment. 
The reason I ask is: as a begin block my initializations do not take
effect 
yet as an anonymous block they do. Or is this based in my lack of 
understanding of perl? 

Are anonymous blocks in a module only read and executed when mod-perl
first loads them, ie once?

Another problem is when I try to build a SELECT HTML element with a
call to 
the CGI module. In my anonymous block all of a sudden the HTML form
variables 
are no longer available with the CGI::param call.  Yet I can build the
select  element later in the cgi scripts using the same variables
without a problem. 
Huh? Did I mention I'm confused and my head hurts  :}

In a simpler line, should I have a use DBI() in startup.pl as well as
the 
PerlModule Apache::DBI in httpd.conf?

I will summarize and post responses.
TIA 
Dave

Code snippets


# from httpd.conf
AddModule mod_perl.c

PerlSetEnv ORACLE_HOME /opt/oracle
PerlSetEnv DSOURCE dbi:Oracle:IMG
PerlSetEnv DATACLERK  public_tst
PerlSetEnv PSSWD  opentoall

PerlModule Apache::Registry
PerlModule Apache::DBI
PerlWarn On
PerlTaintCheck On

PerlRequire /opt/apache/conf/startup.pl


#
#all of startup.pl
 
use CGI ();
use COMMON ();
use WSERVICES ();

Apache::DBI-connect_on_init($ENV{DSOURCE}, $ENV{DATACLERK},
$ENV{PSSWD},
{ PrintError = 1, #warn() on errors
  RaiseError = 0, # don't die on error
  AutoCommit = 1, # commit executes immediately
}
);


###
# WSERVICES.pm
package WSERVICES;
require Exporter;

use strict;

use COMMON; # wrapper for basic file and db manipulation
use DBD::Oracle qw(:ora_types);
use CGI qw/:html :cgi :form/;

our(@DB_NAMES $FILE_NAME $NUMPERPAGE
$GEOCODED_LIST $LOCATION);

our @ISA= qw(Exporter);
our @EXPORT = qw(@DB_NAMES $FILE_NAME $NUMPERPAGE,
$GEOCODED_LIST $LOCATION example_sub);

# As a begin block none of the following initializations occur 
# all subs in COMMON.pm 
{
$NUMPERPAGE = 12;
$FILE_NAME = Readfile('file.txt');  #see COMMON.pm

Create_DB_Connection;  
@DB_NAMES = @{Get_Select_List()};
Destroy_DB_Connection;  

#following code destroys variables passed through CGI param sub
# yet exact same call will work if called in cgi script or subroutine

$GEOCODED_LIST = scrolling_list(-name='CITY_LOC',
-default=$LOCATION,
-values=\@DB_NAMES,
-size= 1);


}


sub examplesub{return 43;}

1;
##


-- 
Dave Morgan
[EMAIL PROTECTED]
403 399 2442
perl Makefile.PL; make install; is just way too convenient



Re: mod-perl, modules and initializations

2002-01-07 Thread ___cliff rayman___

the guide is your friend:
http://perl.apache.org/guide

Dave Morgan wrote:

 What is the difference between how a BEGIN block and an anonymous block

http://thingy.kcilink.com/modperlguide/porting/BEGIN_blocks.html


 Another problem is when I try to build a SELECT HTML element with a
 call to
 the CGI module. In my anonymous block all of a sudden the HTML form
 variables
 are no longer available with the CGI::param call.  Yet I can build the
 select  element later in the cgi scripts using the same variables
 without a problem.

the above is not clear.


 In a simpler line, should I have a use DBI() in startup.pl as well as
 the
 PerlModule Apache::DBI in httpd.conf?

you really only need one or the other.  not sure if one is preferable with
Apache::DBI.

http://thingy.kcilink.com/modperlguide/config/PerlModule_and_PerlRequire_Direc.html



 I will summarize and post responses.

not necessary.  as you can see, the guide is a professional job
of summarizing these types of questions.  i think you'll find it invaluable.
there is also a book by the author of mod_perl:
http://www.modperl.org/

if you want to do any serious mod_perl programming, you probably should read
through both.


--
___cliff [EMAIL PROTECTED]http://www.genwax.com/





[ANNOUNCE] Apache::UploadMeter-0.15

2002-01-07 Thread Issac Goldstand



Finally, after a month of being bogged down on [EMAIL PROTECTED], the barriers have being 
cleared and Apache::UploadMeter's hit CPAN!

The URL http://telia.dl.sourceforge.net/apache-umeter/Apache-UploadMeter-0.15.tar.gzhas 
entered CPAN as file: 
$CPAN/authors/id/I/IS/ISAAC/Apache-UploadMeter-0.15.tar.gz size: 5781 
bytes md5: 635457cab775fa4c169d74180b9219f6No action is 
required on your partRequest entered by: ISAAC (Isaac Goldstand)Request 
entered on: Tue, 08 Jan 2002 06:04:40 GMTRequest completed: Tue, 08 
Jan 2002 06:05:08 GMT
 Issac



cvs commit: modperl-2.0/xs/APR/PerlIO apr_perlio.c

2002-01-07 Thread dougm

dougm   02/01/07 17:06:20

  Modified:xs/APR/PerlIO apr_perlio.c
  Log:
  add some debug info
  
  Revision  ChangesPath
  1.9   +23 -2 modperl-2.0/xs/APR/PerlIO/apr_perlio.c
  
  Index: apr_perlio.c
  ===
  RCS file: /home/cvs/modperl-2.0/xs/APR/PerlIO/apr_perlio.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- apr_perlio.c  4 Jan 2002 09:29:50 -   1.8
  +++ apr_perlio.c  8 Jan 2002 01:06:20 -   1.9
  @@ -82,6 +82,13 @@
   st-pool = modperl_sv2pool(aTHX_ sv);
 
   rc = apr_file_open(st-file, path, apr_flag, APR_OS_DEFAULT, st-pool);
  +
  +#ifdef PERLIO_APR_DEBUG
  +Perl_warn(aTHX_ PerlIOAPR_open obj=0x%lx, file=0x%lx, name=%s, rc=%d\n,
  +  (unsigned long)f, (unsigned long)st-file,
  +  path ? path : (UNKNOWN), rc);
  +#endif
  +
   if (rc != APR_SUCCESS) {
   PerlIOBase(f)-flags |= PERLIO_F_ERROR;
   return NULL;
  @@ -110,6 +117,15 @@
   PerlIOAPR *ost = PerlIOSelf(o, PerlIOAPR);
   
   rc = apr_file_dup(fst-file, ost-file, ost-pool);
  +
  +#ifdef PERLIO_APR_DEBUG
  +Perl_warn(aTHX_ PerlIOAPR_dup obj=0x%lx, 
  +file=0x%lx = 0x%lx, rc=%d\n,
  +  (unsigned long)f,
  +  (unsigned long)ost-file,
  +  (unsigned long)fst-file, rc);
  +#endif
  +
   if (rc == APR_SUCCESS) {
   fst-pool = ost-pool;
   return f;
  @@ -190,9 +206,14 @@
   IV code = PerlIOBase_close(aTHX_ f);
   apr_status_t rc;
   
  -const char *new_path;
  +const char *new_path = NULL;
   apr_file_name_get(new_path, st-file);
  -/* Perl_warn(aTHX_ closing file %s\n, new_path); */
  +
  +#ifdef PERLIO_APR_DEBUG
  +Perl_warn(aTHX_ PerlIOAPR_close obj=0x%lx, file=0x%lx, name=%s\n,
  +  (unsigned long)f, (unsigned long)st-file,
  +  new_path ? new_path : (UNKNOWN));
  +#endif
   
   rc = apr_file_flush(st-file);
   if (rc != APR_SUCCESS) {
  
  
  



cvs commit: modperl-2.0/xs/APR/PerlIO apr_perlio.c

2002-01-07 Thread dougm

dougm   02/01/07 17:09:19

  Modified:xs/APR/PerlIO apr_perlio.c
  Log:
  work around bug where some PerlIOAPR filehandles are still open during perl_destruct
  
  Revision  ChangesPath
  1.10  +14 -2 modperl-2.0/xs/APR/PerlIO/apr_perlio.c
  
  Index: apr_perlio.c
  ===
  RCS file: /home/cvs/modperl-2.0/xs/APR/PerlIO/apr_perlio.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- apr_perlio.c  8 Jan 2002 01:06:20 -   1.9
  +++ apr_perlio.c  8 Jan 2002 01:09:19 -   1.10
  @@ -206,14 +206,26 @@
   IV code = PerlIOBase_close(aTHX_ f);
   apr_status_t rc;
   
  +#ifdef PERLIO_APR_DEBUG
   const char *new_path = NULL;
  -apr_file_name_get(new_path, st-file);
  +if (!PL_dirty) {
  +/* if this is called during perl_destruct we are in trouble */
  +apr_file_name_get(new_path, st-file);
  +}
   
  -#ifdef PERLIO_APR_DEBUG
   Perl_warn(aTHX_ PerlIOAPR_close obj=0x%lx, file=0x%lx, name=%s\n,
 (unsigned long)f, (unsigned long)st-file,
 new_path ? new_path : (UNKNOWN));
   #endif
  +
  +if (PL_dirty) {
  +/* there should not be any PerlIOAPR handles open
  + * during perl_destruct
  + */
  +Perl_warn(aTHX_ leaked PerlIOAPR handle 0x%lx,
  +  (unsigned long)f);
  +return -1;
  +}
   
   rc = apr_file_flush(st-file);
   if (rc != APR_SUCCESS) {
  
  
  



cvs commit: modperl-2.0/src/modules/perl mod_perl.c mod_perl.h modperl_interp.c

2002-01-07 Thread dougm

dougm   02/01/07 17:13:29

  Modified:src/modules/perl mod_perl.c mod_perl.h modperl_interp.c
  Log:
  fix so perl_destruct (and things like END blocks) are run in child
  processes when they are shutdown
  
  Revision  ChangesPath
  1.103 +30 -3 modperl-2.0/src/modules/perl/mod_perl.c
  
  Index: mod_perl.c
  ===
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.c,v
  retrieving revision 1.102
  retrieving revision 1.103
  diff -u -r1.102 -r1.103
  --- mod_perl.c6 Jan 2002 21:39:36 -   1.102
  +++ mod_perl.c8 Jan 2002 01:13:28 -   1.103
  @@ -128,6 +128,20 @@
   SAVEDESTRUCTOR_X(modperl_boot, 0);
   }
   
  +/*
  + * the server_pool is a subpool of the parent pool (aka pconf)
  + * this is where we register the cleanups that teardown the interpreter.
  + * the parent process will run the cleanups since server_pool is a subpool
  + * of pconf.  we manually clear the server_pool to run cleanups in the
  + * child processes
  + */
  +static apr_pool_t *server_pool = NULL;
  +
  +apr_pool_t *modperl_server_pool(void)
  +{
  +return server_pool;
  +}
  +
   PerlInterpreter *modperl_startup(server_rec *s, apr_pool_t *p)
   {
   AV *endav;
  @@ -198,8 +212,8 @@
   }
   
   #ifndef USE_ITHREADS
  -cdata = modperl_cleanup_data_new(p, (void*)perl);
  -apr_pool_cleanup_register(p, cdata,
  +cdata = modperl_cleanup_data_new(server_pool, (void*)perl);
  +apr_pool_cleanup_register(server_pool, cdata,
 modperl_shutdown, apr_pool_cleanup_null);
   #endif
   
  @@ -380,8 +394,10 @@
   int modperl_hook_init(apr_pool_t *pconf, apr_pool_t *plog, 
 apr_pool_t *ptemp, server_rec *s)
   {
  +apr_pool_create(server_pool, pconf);
  +
   modperl_sys_init();
  -apr_pool_cleanup_register(pconf, NULL,
  +apr_pool_cleanup_register(server_pool, NULL,
 modperl_sys_term, apr_pool_cleanup_null);
   modperl_init_globals(s, pconf);
   modperl_init(s, pconf);
  @@ -461,9 +477,20 @@
   return OK;
   }
   
  +static apr_status_t modperl_child_exit(void *data)
  +{
  +apr_pool_clear(server_pool);
  +server_pool = NULL;
  +
  +return APR_SUCCESS;
  +}
  +
   static void modperl_hook_child_init(apr_pool_t *p, server_rec *s)
   {
   modperl_perl_init_ids_server(s);
  +
  +apr_pool_cleanup_register(p, NULL, modperl_child_exit,
  +  apr_pool_cleanup_null);
   }
   
   void modperl_register_hooks(apr_pool_t *p)
  
  
  
  1.40  +1 -0  modperl-2.0/src/modules/perl/mod_perl.h
  
  Index: mod_perl.h
  ===
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.h,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- mod_perl.h24 Nov 2001 01:15:01 -  1.39
  +++ mod_perl.h8 Jan 2002 01:13:28 -   1.40
  @@ -45,6 +45,7 @@
   void modperl_pre_config_handler(apr_pool_t *p, apr_pool_t *plog,
   apr_pool_t *ptemp);
   void modperl_register_hooks(apr_pool_t *p);
  +apr_pool_t *modperl_server_pool(void);
   PerlInterpreter *modperl_startup(server_rec *s, apr_pool_t *p);
   void xs_init(pTHXo);
   
  
  
  
  1.39  +2 -1  modperl-2.0/src/modules/perl/modperl_interp.c
  
  Index: modperl_interp.c
  ===
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_interp.c,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- modperl_interp.c  5 Nov 2001 05:19:01 -   1.38
  +++ modperl_interp.c  8 Jan 2002 01:13:28 -   1.39
  @@ -191,6 +191,7 @@
   void modperl_interp_init(server_rec *s, apr_pool_t *p,
PerlInterpreter *perl)
   {
  +apr_pool_t *server_pool = modperl_server_pool();
   pTHX;
   MP_dSCFG(s);
   
  @@ -210,7 +211,7 @@
   /* this happens post-config in mod_perl.c:modperl_init_clones() */
   /* modperl_tipool_init(tipool); */
   
  -apr_pool_cleanup_register(p, (void*)mip,
  +apr_pool_cleanup_register(server_pool, (void*)mip,
 modperl_interp_pool_destroy,
 apr_pool_cleanup_null);
   
  
  
  



cvs commit: modperl-2.0/src/modules/perl modperl_util.c

2002-01-07 Thread dougm

dougm   02/01/07 17:29:23

  Modified:src/modules/perl modperl_util.c
  Log:
  plug leaking Apache::Table objects
  
  Revision  ChangesPath
  1.33  +1 -1  modperl-2.0/src/modules/perl/modperl_util.c
  
  Index: modperl_util.c
  ===
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_util.c,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- modperl_util.c14 Dec 2001 04:35:28 -  1.32
  +++ modperl_util.c8 Jan 2002 01:29:23 -   1.33
  @@ -367,7 +367,7 @@
  SV *tsv, void *p)
   {
   SV *hv = (SV*)newHV();
  -SV *rsv = newSViv(0);
  +SV *rsv = sv_newmortal();
   
   sv_setref_pv(rsv, classname, p);
   sv_magic(hv, rsv, PERL_MAGIC_tied, Nullch, 0);