Re: PerlAuthenHandler advice needed.

2000-09-28 Thread Carlos Ramirez

Here's a simple handler that will set the AuthType and AuthName
dynamically and handle the authentication for you. This handler will
prompt you for a password when you try to acess /manual with the
AuthName, "The Manual" and prompt with the AuthName "The Icons" when you
try to access /icons. These urls are part of Apaches basic installation
(that's if you did not remove the manual from your htdocs directory).
The authentication phase will let you in just as long you supply a
username and password. You can of course code such that it you can
authenicate against a .htpassword file, using Apache::Htpasswd.

Anyhow, this should show you that you can indeed change the AuthName
on-the-fly and also handle 
authentication without having to include AuthName,AuthType,AuthUserFile
explicitly in your httpd.conf.

Note: the authentication subroutine acted flaky, sometimes it worked and
other times it didn't. But the realms did change for the each uri. 

i hope this helps youhave fun ;)


Setting it up:

In your httpd.conf ( in a global area):

PerlHeaderParserHandler Apache::SetRealm;


=code

package Apache::SetRealm;

use Apache;
use Apache::Constants qw(:common);
sub handler {
my $r   = shift;

## Make Apache aware the we want to also handle the Authentication
phase using a custom
## handler, in this case the subroutine authenticate()
  $r-push_handlers(PerlAuthenHandler = \authenticate);
my $uri = $r-uri;

   ## only handle uri that are defined as protected, in this case the
only protected
   ## uri's are /icons and /manuals
return OK unless is_protected($r);
my $realm = get_realm($r);

## Construct the Header Field containing the type of authenticate
(Basic) and our
   ## realmname return by get_realm()
my $authheader = 'Basic realm="'.$realm.'"';

$r-header_out("WWW-Authenticate" ,$authheader);

## Return 401 to browser and prompt for login
$r-status(AUTH_REQUIRED);
$r-send_http_header("text/html");
return AUTH_REQUIRED;
}

sub get_realm {
 ## Get the AuthName for a specific uri. You can probably read these
off of a file that
 ## contains a list of uri's and realmNames
  my $r = shift;
  return "The Icons"  if ($r-uri =~ /\/icons/);
  return "The Manual" if ($r-uri =~ /\/manual/);
}

sub is_protected {
  ## Check the $uri requested matches our set of "Restricted"
locations
 ## 1 = isProtected, 0 = NotProtected
 ## You can probably have these protected areas in a seperate file,
the eagle book
 ## has some excellent ideas on how to acomplish this
  my $r = shift;
  my @protected = ('\/manual','\/icons');

  for (@protected) { return 1 if ($r-uri =~ /$_/); }
  return 0;
}

sub authenticate {
  ## Straight out of the Eagle Book
my $r = shift;

return OK if $r-sub_request;

my ($res,$password) = $r-get_basic_auth_pw;
return $res if $res != OK;

my $username = $r-connection-user;
unless ($username  $pass) {
   $r-note_basic_auth_failure;
   $r-log_reason("Did not provide username");
   return AUTH_REQUIRED;
}

## Now that you have the $username and $password you can
## include your code to open your AuthUserFile to check the password
and username
## I suggest using Apache::Htpasswd, it provides all the
methods/functions that you need to
## accomplish this part of the task...

$r-log_reason("WELCOME $user");
return OK;

}

1;


-Carlos


Todd Chapman wrote:
 
 Please explain again how to get my AuthHandler called without setting
 AuthName or AuthType in httpd.conf.
 
 Thanks.
 
 -Todd
 
 On Wed, 27 Sep 2000, Carlos Ramirez wrote:
 
  By choosing to use your custom AuthHandler, you basically override Apache's way of
  handling the particular phase, in this case the authentication phase.  So you must
  handle prompting the user and also checking the password.
 
  You might want to read the Apache Guide (http://perl.apache.org/) on how to write 
you
  own handler and also the eagle book.
 
  After reviewing our previous conversation, I think you might need to send
  WWW-Authenticate header field in another phase (preferable at the
  PerlHeaderParserHandler)  before the Authentication phase is called.
 
  Your PerlHeaderParserHandler can check the $r-uri for any password protected
  requests, i.e., if it matches /companyA, you can then set the WWW-Authenticate: 
Basic
  $realm and push it along it's merry way.
 
  Then your PerlAuthHandler will get the username and password and check it against 
the
  realms' AuthUserFile.  Apache will handle the initial prompting for the
  username/password.
 
  Your requirements imply that you will have a file(??) that has a list of UserFiles
  for each Realm/path_info so that your authentication handler will know what file to
  check against.
 
  I hope this make sense ;) my coffee is running low...
 
  -Carlos
 
 
  Todd Chapman wrote:
 
   Thanks for the help. I was hoping that Apache would 

NOT_FOUND from a PerlHandler causing problems with ErrorDocument

2000-09-28 Thread Bjørn Ola Smievoll

[Sorry for being so verbose, hope somebody still have the time and
patience to read it all].

I have a setup where a PerlTransHandler registers a PerlContentHandler
based simply on whether $r-uri ends with '.html' or not.  The
TransHandler does no verifying of the existence of the file, that
doesn't happen until the ContentHandler kicks in.  For an unsuccessful
'-e' test, NOT_FOUND is returned from the ContentHandler.  All this
worked fine until I added an perl-based handler for the 404 using the
ErrorDocument parameter in httpd.conf[1].

Now, when a request for a non-existent document is sent the httpd
child starts looping, writing file not found errors (for the
ErrorDocument handler) in the log, repeatedly returning the error from
the ErrorDocument handler to the client and hogging memory.

What I get in the error_log is this:

[Thu Sep 28 11:56:24 2000] [error] [client 129.240.148.10] File does not exist: 
/local/www/htdocs/http_error


To me that seems like an indication that the location setup for
/http_err isn't read and the loop follows quite naturally after that.
Still the code is actually run, as seen from the time stamps I've
added to the output (see the example below).  The code for UiO:ErrDoc
is in the bottom of this mail[2].

Another point is that returning NOT_FOUND from the TransHandler does
not yield this problem.  Moving the check to the TransHandler is of
course the logical work around and probably the right way to do it
anyways, but I'd still like to get an explanation for this.

Well, thats about as far as I've gotten tracking this problem; not
very far and I really don't know where to look next.  Any help and/or
hints will be greatly appreciated.


I'll include an example request to fill out any blanks in the above
description:

$ telnet host 80
Trying xxx.xxx.xxx.xxx
Connected to host.
Escape character is '^]'.
GET /h.html HTTP/1.0

HTTP/1.1 404 Not Found
Date: Thu, 28 Sep 2000 09:56:24 GMT
Server: Apache/1.3.12 (Unix) PHP/3.0.16 mod_perl/1.22
Connection: close
Content-Type: text/plain

404 - Not found

[ ... ]

HTTP/1.1 404 Not Found
Date: Thu, 28 Sep 2000 10:27:19 GMT
Server: Apache/1.3.12 (Unix) PHP/3.0.16 mod_perl/1.22
Connection: close
Content-Type: text/plain

404 - Not found - Thu Sep 28 12:27:21 2000

HTTP/1.1 404 Not Found
Date: Thu, 28 Sep 2000 10:27:19 GMT
Server: Apache/1.3.12 (Unix) PHP/3.0.16 mod_perl/1.22
Connection: close
Content-Type: text/plain

404 - Not found - Thu Sep 28 12:27:22 2000

^]
telnet close
Connection closed.

After the first burst of about 50-60 repetitions, the output frq drops
but does not seem to stop completely.  The httpd child, using all
available cpu time, gradually increases in size (the largest I've had
before killing it was about 135 MB).


The error_log looks like this, the second line is from the content
handler (UiO::Profile) just before it returns NOT_FOUND.


[Thu Sep 28 11:56:24 2000] [debug] /local/www/site/perl/lib/UHTML/Identifier.pm(21): 
[client 129.240.148.10] Adding UiO::Profile as handler for /local/www/htdocs/h.html
[Thu Sep 28 11:56:24 2000] [error] Document file do not exist: /local/www/htdocs/h.html
[Thu Sep 28 11:56:24 2000] [error] [client 129.240.148.10] File does not exist: 
/local/www/htdocs/http_error
[Thu Sep 28 11:56:24 2000] [error] [client 129.240.148.10] File does not exist: 
/local/www/htdocs/http_error

And so on.



[1]  My setup looks like this:

PerlTransHandler UiO:Identifier

Location /http_err
SetHandler perl-script
PerlHandler UiO::ErrDoc
/Location

ErrorDocument 404 /http_err


[2] The code of UiO::ErrDoc:

package UiO::ErrDoc;

use strict;
use Apache::Constants qw(OK);
use vars qw($VERSION $REVISION);

$VERSION = '0.01';
$REVISION = q/$Id$/;

sub handler {
my $r = shift;
my %status_lines = (200 = 'OK',
400 = 'Bad Request',
401 = 'Unauthorized',
403 = 'Forbidden',
404 = 'Not found',
500 = 'Internal Server Error');

my $output = $r-status .' - '. $status_lines{$r-status} .' - '.
scalar localtime;

$r-send_http_header;
return OK if $r-header_only;

$r-print("$output\n\n");
return OK;
}

1;
__END__



Re: suggestions needed re. required files and persistent data

2000-09-28 Thread darren chamberlain

John Reid ([EMAIL PROTECTED]) said something to this effect:
 Hi Guys

*snip*

 server start. I experimented with IPC::Shareable, but when I attempted
 to do anything with it in my startup.pl file it segfaulted the server
 and httpd would not start.

Hi John,

If IPC::Sharable is failing for you, possibly Apache::Session can be
used to share global data (it can be shared read only and read-write
this way). Apache::Session works by tying a hash to an underlying
data structure, and, as of 1.51, is very easy to extend.

From perldoc Apache::Session:

Sharing data between Apache processes

   When you share data between Apache processes, you need to
   decide on a session ID number ahead of time and make sure
   that an object with that ID number is in your object store
   before starting you Apache.  How you accomplish that is
   your own business.  I use the session ID "1".  Here is a
   short program in which we use Apache::Session to store out
   database access information.

use Apache;
use Apache::Session::File;
use DBI;

use strict;

my %global_data;

eval {
tie %global_data, 'Apache::Session::File', 1,
   {Directory = '/tmp/sessiondata'};
};
if ($@) {
   die "Global data is not accessible: $@";
}

my $dbh = DBI-connect($global_data{datasource},
   $global_data{username}, $global_data{password})
  || die $DBI::errstr;

undef %global_data;

#program continues...

   As shown in this example, you should undef or untie your
   session hash as soon as you are done with it.  This will
   free up any locks associated with your process.

Hope this helps...

(darren)

-- 
One man's "magic" is another man's engineering.  "Supernatural" is a null word.
-- Robert Heinlein



Re: NOT_FOUND from a PerlHandler causing problems with ErrorDocument

2000-09-28 Thread darren chamberlain

Bjørn Ola Smievoll ([EMAIL PROTECTED]) said something to this effect:
 [Sorry for being so verbose, hope somebody still have the time and
 patience to read it all].
 
 I have a setup where a PerlTransHandler registers a PerlContentHandler
 based simply on whether $r-uri ends with '.html' or not.  The
 TransHandler does no verifying of the existence of the file, that
 doesn't happen until the ContentHandler kicks in.  For an unsuccessful
 '-e' test, NOT_FOUND is returned from the ContentHandler.  All this
 worked fine until I added an perl-based handler for the 404 using the
 ErrorDocument parameter in httpd.conf[1].

Why are you so averse to handling it in the translation phase? I think it
makes the content handler much cleaner.

 Now, when a request for a non-existent document is sent the httpd
 child starts looping, writing file not found errors (for the
 ErrorDocument handler) in the log, repeatedly returning the error from
 the ErrorDocument handler to the client 

You don't mention how you are setting the error document handler. Are you
using

$r-internal_redirect('/http_err');

or

$r-push_handler(PerlHandler = \UiO::ErrDoc::handler);
return DECLINED;

or some other method? How you are setting it might be significant.

I think that Apache does the file stating and such during the translation
phase, so returning NOT_FOUND from the content phase might be too late for
Apache to step in and take over with the sending of the ErrorDocument. In
other words, its too late for Apache to do the Alias translation. Of course,
I may be wrong about this as well.

 and hogging memory.

As an aside, especially during development (when things like this are likely
to happen), see these documents:

http://perl.apache.org/guide/performance.html#Limiting_the_Size_of_the_Process
http://perl.apache.org/guide/performance.html#Limiting_Other_Resources_Used_by

(darren)

--
There are trivial truths and there are great Truths. The opposite of a
trival truth is obviously false. The opposite of a great Truth is also true.
-- Neils Bohr



Re: PerlAuthenHandler advice needed.

2000-09-28 Thread Doug MacEachern

On Wed, 27 Sep 2000, Todd Chapman wrote:

 
 Problems with your suggestion:
 
 1. The realm will not be known until I get path_info so
 Location/Location directives will not work.

you can use $r-auth_name($realm) to set it at request time.
 
 2. How can I get Perl to do the password lookup in the dynamically
 selected AuthUserFile?

since mod_auth.c's structure defs are private to mod_auth.c, there's no
$r-api for this.  what you can do use .htaccess like so:

Perl
my $r = Apache-request;

my $testing = $r-path_info =~ /test/;

$AuthType = "Basic";
$AuthName =  $testing ? "Testing" : "Whatever";
$Require = "user dougm";
$AuthUserFile = $testing ? "/tmp/htpasswd" : "/whatever/htpasswd";

/Perl

also, i just committed this patch that makes $r-auth_type writable, the
same way $r-auth_name is.  and, defaults auth_type to Basic when unset
and $r-get_basic_auth_pw is called.

Index: src/modules/perl/Apache.xs
===
RCS file: /home/cvs/modperl/src/modules/perl/Apache.xs,v
retrieving revision 1.110
diff -u -r1.110 Apache.xs
--- src/modules/perl/Apache.xs  2000/09/27 19:44:23 1.110
+++ src/modules/perl/Apache.xs  2000/09/27 23:43:33
@@ -824,8 +824,9 @@
 char *val
 
 const char *
-auth_type(r)
+mod_perl_auth_type(r, val=NULL)
 Apacher
+char *val
 
 const char *
 document_root(r, ...)
@@ -887,6 +888,9 @@
 int ret;
 
 PPCODE:
+if (!auth_type(r)) {
+(void)mod_perl_auth_type(r, "Basic");
+}
 ret = get_basic_auth_pw(r, sent_pw);
 XPUSHs(sv_2mortal((SV*)newSViv(ret)));
 if(ret == OK)
Index: src/modules/perl/mod_perl.h
===
RCS file: /home/cvs/modperl/src/modules/perl/mod_perl.h,v
retrieving revision 1.103
diff -u -r1.103 mod_perl.h
--- src/modules/perl/mod_perl.h 2000/09/22 18:51:59 1.103
+++ src/modules/perl/mod_perl.h 2000/09/27 23:43:46
@@ -1185,6 +1185,7 @@
 perl_require_module("Apache", s)
 
 char *mod_perl_auth_name(request_rec *r, char *val);
+char *mod_perl_auth_type(request_rec *r, char *val);
 
 module *perl_get_module_ptr(char *name, int len);
 void *perl_merge_server_config(pool *p, void *basev, void *addv);
Index: src/modules/perl/perl_config.c
===
RCS file: /home/cvs/modperl/src/modules/perl/perl_config.c,v
retrieving revision 1.105
diff -u -r1.105 perl_config.c
--- src/modules/perl/perl_config.c  2000/09/27 15:37:33 1.105
+++ src/modules/perl/perl_config.c  2000/09/27 23:44:03
@@ -158,6 +158,24 @@
 #endif
 }
 
+char *mod_perl_auth_type(request_rec *r, char *val)
+{
+#ifndef WIN32 
+core_dir_config *conf = 
+  (core_dir_config *)get_module_config(r-per_dir_config, core_module); 
+
+if(val) {
+   conf-auth_type = pstrdup(r-pool, val);
+   set_module_config(r-per_dir_config, core_module, (void*)conf); 
+   MP_TRACE_g(fprintf(stderr, "mod_perl: setting auth_type to %s\n", 
+conf-auth_name));
+}
+
+return conf-auth_type;
+#else
+return (char *) auth_type(r);
+#endif
+}
+
 void mod_perl_dir_env(request_rec *r, perl_dir_config *cld)
 {
 if(MP_HASENV(cld)) {






OT: use problem (need interpolation)

2000-09-28 Thread Jerrad Pierce

Is there anyway to fool perl into letting you do a:

use Foo ($bar, 'baz', 'quux');

??

Foo is only getting 'baz' and 'quux', the value of $bar is lost in the
ether.
I have tried many ways of trying to sneak it past but none seems to work...

Thanks



GPL auction system based on mod_perl, Mason, Postgres

2000-09-28 Thread Louis-David Mitterrand

Hello,

I have started a free auction system project at http://www.apartia.org
which is closely tied to mod_perl/Mason and PostgreSQL.

The Apartia project already supports all main types of auctions:
classic, dutch, decreasing price, fixed, bids. 

Latest features added are:

- seller, bidder, watch-list notification,
- auction closing, expiration, archiving
- entire category trees can be imported from a simple indented text file
  into the DB in one pass

Information about the project is available at:

http://www.apartia.org/Project/

where details about CVS access and mailing list are provided.

Suggestions, criticism, comments welcome.

Cheers,

-- 
Louis-David Mitterrand - [EMAIL PROTECTED] - http://www.apartia.org

Veni, Vidi, VISA.



Re: OT: use problem (need interpolation)

2000-09-28 Thread Matthew Byng-Maddick

On Thu, 28 Sep 2000, Jerrad Pierce wrote:
 Is there anyway to fool perl into letting you do a:
 use Foo ($bar, 'baz', 'quux');
 ??
 Foo is only getting 'baz' and 'quux', the value of $bar is lost in the
 ether.
 I have tried many ways of trying to sneak it past but none seems to work...

use is syntactically equiavalent to
BEGIN
{
require Foo;
Foo-import(@argarray);
}

so $baz will need to be defined at compile time, ie. within its own BEGIN
block.

MBM

-- 
Matthew Byng-Maddick   Home: [EMAIL PROTECTED]  +44 20  8981 8633  (Home)
http://colondot.net/   Work: [EMAIL PROTECTED] +44 7956 613942  (Mobile)
Genius may have  its limitations,  but stupidity  is not thus handicapped.
 -- Elbert Hubbard




Re: PerlAuthenHandler advice needed.

2000-09-28 Thread Doug MacEachern

On Wed, 27 Sep 2000, Carlos Ramirez wrote:

 my $authheader = 'Basic realm="'.$realm.'"';
 
 $r-header_out("WWW-Authenticate" ,$authheader);

there's a cleaner way for that:
$r-auth_name($realm);
$r-note_basic_auth_failure;
 
 $r-status(AUTH_REQUIRED);

no need for that.

 $r-send_http_header("text/html");

or this because..

 return AUTH_REQUIRED;

..apache will send the headers when you return an error

 return OK if $r-sub_request;

there's no Apache::sub_request method 

 my ($res,$password) = $r-get_basic_auth_pw;

this will core dump if AuthName is not set in the configuration file.
not with the current cvs though, see previous message.

$r-note_basic_auth_failure;

this won't work right unless you've set $r-auth_name($val)





Re: OT: use problem (need interpolation)

2000-09-28 Thread David Mitchell

 From: Jerrad Pierce [EMAIL PROTECTED]
 Is there anyway to fool perl into letting you do a:
 
 use Foo ($bar, 'baz', 'quux');

'use' lines are executed very early on during script loading:

use Foo x y z

is roughly equivalent to

BEGIN { require Foo; import Foo x y z }

so $bar is likely to be undefined unless you also set it in
a BEGIN section, eg

BEGIN { $bar =  }
use Foo ($bar, 'baz', 'quux');

or use 'require' instead of 'use' if you can tolerate the module being
loaded late, eg

$bar = ;
require Foo;
import Foo ($bar, 'baz', 'quux');



* Dave Mitchell, Operations Manager,
* Fretwell-Downing Facilities Ltd, UK.  [EMAIL PROTECTED]
* Tel: +44 114 281 6113.The usual disclaimers
*
* Standards (n). Battle insignia or tribal totems




RE: OT: use problem (need interpolation)

2000-09-28 Thread Jerrad Pierce

Thanks...

as It turns out I had to use both a BEGIN{} to set the variables and an
eval{} around the use (don't ask, it's some rather ugly stuff...).

autouse wasn't quite whta I needed (the module I'm using contains no
functions, just a big hash)

-Original Message-
From: David Mitchell [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 28, 2000 10:53 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: OT: use problem (need interpolation)


 From: Jerrad Pierce [EMAIL PROTECTED]
 Is there anyway to fool perl into letting you do a:
 
 use Foo ($bar, 'baz', 'quux');

'use' lines are executed very early on during script loading:

   use Foo x y z
   
is roughly equivalent to

   BEGIN { require Foo; import Foo x y z }
   
so $bar is likely to be undefined unless you also set it in
a BEGIN section, eg

   BEGIN { $bar =  }
   use Foo ($bar, 'baz', 'quux');

or use 'require' instead of 'use' if you can tolerate the module being
loaded late, eg

   $bar = ;
   require Foo;
   import Foo ($bar, 'baz', 'quux');



* Dave Mitchell, Operations Manager,
* Fretwell-Downing Facilities Ltd, UK.  [EMAIL PROTECTED]
* Tel: +44 114 281 6113.The usual disclaimers
*
* Standards (n). Battle insignia or tribal totems




Re: recursion in Apache::Constants::AUTOLOAD?

2000-09-28 Thread Doug MacEachern

On Mon, 26 Jun 2000, Jim Winstead wrote:

 We were seeing some servers spin out of control (allocating memory
 slowly) in Apace::Constants::AUTOLOAD (which apparently has been
 reported in the mailing list before).
 
 The attached patch fixes the problems for us. Could someone who
 understands what is going on here shed some light?

i still don't understand how __AUTOLOAD can be undefined inside the
server.  this patch adds an extra check that will prevent recursion if
__AUTOLOAD is somehow undefined and print a stacktrace to give some idea
where the problem is.

Index: Constants/Constants.pm
===
RCS file: /home/cvs/modperl/Constants/Constants.pm,v
retrieving revision 1.20
diff -u -r1.20 Constants.pm
--- Constants/Constants.pm  2000/03/03 20:42:01 1.20
+++ Constants/Constants.pm  2000/09/28 15:12:36
@@ -17,9 +17,16 @@
 if ($ENV{MOD_PERL}) {
 #outside of mod_perl this will recurse looking for __AUTOLOAD, grr
 *AUTOLOAD  = sub {
-   #why must we stringify first???
-   __AUTOLOAD() if "$Apache::Constants::AUTOLOAD"; 
-   goto $Apache::Constants::AUTOLOAD;
+if (defined __AUTOLOAD) { #make extra sure we don't recurse
+#why must we stringify first???
+__AUTOLOAD() if "$Apache::Constants::AUTOLOAD";
+goto $Apache::Constants::AUTOLOAD;
+}
+else {
+require Carp;
+Carp::confess("__AUTOLOAD is undefined, ",
+  "trying to AUTOLOAD $Apache::Constants::AUTOLOAD");
+}
 };
 }
 




Re: PerlAuthenHandler advice needed.

2000-09-28 Thread Todd Chapman


Thanks for the help Doug. This is what I have now but all I get is a
segementation fault in the log.

Any ideas?

-Todd

package Apache::SetRealm;

## Usage: PerlHeaderParserHandler Apache::SetRealm

use strict;
use Apache::Constants qw(:common);

sub handler {
my $r = shift;

   # find the name of the realm
   # if realm does not exist error
   # else see if Auth header set
   # if auth header not set return AUTH_REQUIRED
   # else return OK

# If Auth header is set a future PerlAuthenHandler will check the
password.
# When that happens we can't use get_basic_auth_info because AuthName is
# not set in the config file. We will have to parse the Auth header manually.
# The realm will be determined from path_info.
return OK if $r-header_in('Authorization');

my $realm = get_realm($r);

# Prompt for authentication info in the proper realm
$r-auth_name($realm);
$r-note_basic_auth_failure;
return AUTH_REQUIRED;
}

sub get_realm {
 ## Get the AuthName for a specific uri. You can probably read these off of a file 
that ## contains a list of uri's and realmNames
  my $r = shift;
  $r-uri =~ /\/modperl\/(.*)/;
  return $1 if $1;
  return "Top Level";
}

1;






Re: recursion in Apache::Constants::AUTOLOAD?

2000-09-28 Thread David Alan Pisoni

Sorry I don't have much in the way of details, but we had this problem several months 
ago (probably in a previous version of mod_perl), but it silently went away.
(I'm reminded of it because recently I was reviewing the handler() of our recently 
open-sourced embedded parser, Apache::XPP, and found that the constants had been 
hard-coded to avoid the AUTOLOAD() spinning.  I put the constant calls back in :-)

Enjoy,
David

At 8.17 -0700 9/28/2000, Doug MacEachern wrote:
On Mon, 26 Jun 2000, Jim Winstead wrote:

 We were seeing some servers spin out of control (allocating memory
 slowly) in Apace::Constants::AUTOLOAD (which apparently has been
 reported in the mailing list before).

 The attached patch fixes the problems for us. Could someone who
 understands what is going on here shed some light?

i still don't understand how __AUTOLOAD can be undefined inside the
server.  this patch adds an extra check that will prevent recursion if
__AUTOLOAD is somehow undefined and print a stacktrace to give some idea
where the problem is.

Index: Constants/Constants.pm
===
RCS file: /home/cvs/modperl/Constants/Constants.pm,v
retrieving revision 1.20
diff -u -r1.20 Constants.pm
--- Constants/Constants.pm 2000/03/03 20:42:01 1.20
+++ Constants/Constants.pm 2000/09/28 15:12:36
@@ -17,9 +17,16 @@
 if ($ENV{MOD_PERL}) {
 #outside of mod_perl this will recurse looking for __AUTOLOAD, grr
 *AUTOLOAD  = sub {
-  #why must we stringify first???
-  __AUTOLOAD() if "$Apache::Constants::AUTOLOAD";
-  goto $Apache::Constants::AUTOLOAD;
+if (defined __AUTOLOAD) { #make extra sure we don't recurse
+#why must we stringify first???
+__AUTOLOAD() if "$Apache::Constants::AUTOLOAD";
+goto $Apache::Constants::AUTOLOAD;
+}
+else {
+require Carp;
+Carp::confess("__AUTOLOAD is undefined, ",
+  "trying to AUTOLOAD $Apache::Constants::AUTOLOAD");
+}
 };
 }
 




Re: mod_perl and DBI::Proxy

2000-09-28 Thread Tim Bunce

It has promise but needs someone to polish it up.
(I didn't write it and have barely looked at the code.)

Tim.

On Tue, Sep 19, 2000 at 12:50:57PM -0700, Tom Lancaster wrote:
 I know, seems promising, doesn't it, especially after the overview in
 the DBI book. On the other hand, you can do most things another way -
 SSH port forwarding for encrypted data transmission, straight DBI/DBD
 available for most dbs, etc.
 
 
 Bill McCabe wrote:
  
  That's a shame. I can see good use for it. Is it the RPC chunk that is slow
  and unreliable or the DBI part? Or has no one really pursued making a
  production-quality module out of it?
  
  Bill
  
  At 11:24 AM -0700 9/19/00, Tom Lancaster wrote:
  My experience of using DBI::Proxy several months ago is that it's
  terribly slow, and breaks all the time.
  It's not meant to be used in a production environment ( and that's
  according to the authors ).
  
  I managed to get it running, on linux and NT, but due to the lack of a
  working fork() or threads support in perl on NT, I could only use a
  single instance of the server at a time.
  If you can get it working *nix to *nix, your mileage may be better.
  
  Regards.
  
  Bill McCabe wrote:
  
   Hi All
  
   I'm thinking of restructuring my setup so that I have my apache/mod_perl
   servers access database servers remotely using DBI::Proxy, rather than
   locally. Does anyone have a sense of what kind of performance degradation I
   should expect? Will it come chiefly from network latency (leaving
   encryption out for the moment)? Also, I've never managed to install
   DBI::Proxy successfully on any system (AIX 4.2.1/4.3.2/4.3.3, Red Hat
   6.0/1/2; perl 5.005/5.6.0; apache 1.3.12/mod_perl 1.24). The tests always
   fails for the RPC piece. Is the RPC module typically this problematic?
  
   TIA
  
   Bill



open - does not work

2000-09-28 Thread Vsevolod Ilyushchenko

Hi,

Why does this script give no output under mod_perl, but works fine from the command 
line:

#!/usr/bin/perl -w

use CGI;

print CGI-header();

open (AAA, "-");

print AAA "Test string";

close AAA;

The directory where the script lives is configured as:

AllowOverride None
Order allow,deny
Allow from all
SetHandler  perl-script
PerlHandler Apache::PerlRun
Options +ExecCGI

Thanks,
Simon
-- 
 _
|   x |   Simon (Vsevolod ILyushchenko) [EMAIL PROTECTED]   
| y = e   |
|_|   http://www.simonf.com[EMAIL PROTECTED]   
| 
 
Disclaimer: This is not me.
This is just my mailer talking to your mailer...



Re: Logging real HTTP status

2000-09-28 Thread Doug MacEachern

On Wed, 13 Sep 2000, brian d foy wrote:

 
 let's suppose that i want to change the HTTP status to be something other
 than i'm going to return from the handler().  is there a way to get the
 logging phase to log the status that the user-agent got rather than the
 return value of the handler()?
 
 here's my small script which illustrates what i'm trying to do:
 
   sub mod_perl_error
   {
   # a request object is the first argument
   # in handler, return mod_perl_error($r);
   $_[0]-status( SERVER_ERROR );
   $_[0]-content_type('text/html');
   $_[0]-send_http_header;
   
   $_[0]-print("There was an oopsie.");
   
   return DONE; # the log ends up with status 200  
   }

argh, because Apache.xs:send_http_header does this:
r-status = 200; /* XXX, why??? */

i think this was to deal with Apache::cgi_header_out() (used by CGI.pm).
if it modified $r-status, then Apache::send_cgi_header() would call
$r-send_http_header and Apache would also call send_http_header() because
mod_perl returned that status, indicating error or redirect.
with this patch, you don't need to touch $r-status and a 500 will be
properly logged.

Index: src/modules/perl/Apache.xs
===
RCS file: /home/cvs/modperl/src/modules/perl/Apache.xs,v
retrieving revision 1.111
diff -u -r1.111 Apache.xs
--- src/modules/perl/Apache.xs  2000/09/27 23:51:33 1.111
+++ src/modules/perl/Apache.xs  2000/09/28 16:11:02
@@ -929,7 +929,6 @@
 r-content_type = pstrdup(r-pool, type);
 send_http_header(r);
 mod_perl_sent_header(r, 1);
-r-status = 200; /* XXX, why??? */
 
 #ifndef PERL_OBJECT
 
Index: Apache/Apache.pm
===
RCS file: /home/cvs/modperl/Apache/Apache.pm,v
retrieving revision 1.53
diff -u -r1.53 Apache.pm
--- Apache/Apache.pm2000/08/31 05:49:05 1.53
+++ Apache/Apache.pm2000/09/28 16:11:12
@@ -180,7 +180,8 @@
else {
$not_sent = 1;
}
-   $r-send_http_header if $not_sent;
+   $r-send_http_header if
+  $not_sent and $r-status == 200;
$r-print($headers); #send rest of buffer, without stripping newlines!!!
last;
}




Undefined subroutine error (only now and then)

2000-09-28 Thread Paulo Narciso Filho

I'm using Apache and mod_perl to develop a dynamic web site. When I 
execute a specific script for the first time (after restarting 
Apache, for instance), it always works. If I reload the page, I
(sometimes) get the following message in my apache error log:

[error] Undefined subroutine Apache::ROOTagv_2eembra
co::perl::agvs::agvs_2ecgi::GetUser called at (file_location) line 
19, frame2 chunk 35.

The subroutine is there (it executes in the first time). If I keep 
trying to reload the page, sometimes it works, sometimes it doesn't.
The same error happens to other scripts, with different subroutines 
being called, but never happens if I run them from the command line
(with the scripts slightly modified).

some things from the server configuration:

PerlInitHandler Apache::StatINC

Location stuff
SetHandler perl-script
PerlHandler Apache::Registry
Options ExecCGI
allow from all
PerlSendHeader on


Can anyone help?
Thanx

Paulo



Re: Apache::Registry error_log quirk

2000-09-28 Thread Doug MacEachern

On Fri, 22 Sep 2000, Martin Wood wrote:

 We have a collection of CGIs in a single directory handled by Apache::Registry, 
however if we enter the name of a resource under that location that doesn't exist, 
say www.noddy.com/registry_dir/dont_exist.cgi this is not recorded in the error_log, 
just the access log, yet the correct 404 "File not found" response is displayed to 
the client. 
 
 For locations managed by default handlers, attempts to access non-existent files is 
logged in both the access and error logs. Is is possible to activate this behaviour 
for the Apache::Registry handled location?

i guess that's because Apache::Registry doesn't log an error,
whoopsie.  this patch fixes that.

Index: lib/Apache//PerlRun.pm
===
RCS file: /home/cvs/modperl/lib/Apache/PerlRun.pm,v
retrieving revision 1.29
diff -u -r1.29 PerlRun.pm
--- lib/Apache//PerlRun.pm  2000/06/01 21:07:56 1.29
+++ lib/Apache//PerlRun.pm  2000/09/28 16:31:12
@@ -60,6 +60,7 @@
$pr-{'mtime'} = -M _;
return wantarray ? (OK, $pr-{'mtime'}) : OK;
 }
+$pr-log_error("$filename not found or unable to stat");
 return NOT_FOUND;
 }
 
Index: lib/Apache//Registry.pm
===
RCS file: /home/cvs/modperl/lib/Apache/Registry.pm,v
retrieving revision 1.32
diff -u -r1.32 Registry.pm
--- lib/Apache//Registry.pm 2000/08/02 15:53:15 1.32
+++ lib/Apache//Registry.pm 2000/09/28 16:31:15
@@ -165,6 +165,7 @@
 #  }
return $r-status($old_status);
 } else {
+$r-log_error("$filename not found or unable to stat");
return NOT_FOUND unless $Debug  $Debug  2;
return Apache::Debug::dump($r, NOT_FOUND);
 }




Re: PerlAuthenHandler advice needed.

2000-09-28 Thread Carlos Ramirez


$r->auth_name($realm), $r->auth_type($basic) did not work for me, which
is why I used the $r->header_out method. Also, after I set the outgoing
header and returned AUTH_REQUIRED, I got prompted but the $realm did not
show. Instead it displayed 'unknown' as the realm name. But when I set
the $r->status and sent out the response via $r->send_http_header and returned
AUTH_REQUIRED, the $realm name showed?
I read the docs as i started this exercise and was aware of $r->auth_name,
$r->auth_type, but since they did'nt work and I kept getting segfaults
when using them I decided to try other routes. But anyways I'm glad that
I read the docs right and that you can indeed set the AuthName using $r->auth_name.
As for the authenticate subroutine, I just copied that from the eagle
book, just as a demonstration...
I'll upgrade my mod_perl from 1.2.1 -> latest and see if these work
for me.
Thanks for the helpful insights and explanations DougI have seen
the light ;)
-Carlos




Doug MacEachern wrote:
On Wed, 27 Sep 2000, Carlos Ramirez wrote:
> my $authheader = 'Basic realm="'.$realm.'"';
>
> $r->header_out("WWW-Authenticate" ,$authheader);
there's a cleaner way for that:
$r->auth_name($realm);
$r->note_basic_auth_failure;
> $r->status(AUTH_REQUIRED);
no need for that.
> $r->send_http_header("text/html");
or this because..
> return AUTH_REQUIRED;
..apache will send the headers when you return an error
> return OK if $r->sub_request;
there's no Apache::sub_request method
> my ($res,$password) = $r->get_basic_auth_pw;
this will core dump if AuthName is not set in the configuration file.
not with the current cvs though, see previous message.
>
$r->note_basic_auth_failure;
this won't work right unless you've set $r->auth_name($val)

--
---
Carlos Ramirez + Boeing + Reusable Space Systems + 714.372.4181
---
- Someday I'll find that peer and reset his connection!



RE: Undefined subroutine error (only now and then)

2000-09-28 Thread Geoffrey Young



 -Original Message-
 From: Paulo Narciso Filho [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, September 28, 2000 12:23 PM
 To: [EMAIL PROTECTED]
 Subject: Undefined subroutine error (only now and then)
 
 
 I'm using Apache and mod_perl to develop a dynamic web site. When I 
 execute a specific script for the first time (after restarting 
 Apache, for instance), it always works. If I reload the page, I
 (sometimes) get the following message in my apache error log:
 
 [error] Undefined subroutine Apache::ROOTagv_2eembra
 co::perl::agvs::agvs_2ecgi::GetUser called at (file_location) line 
 19, frame2 chunk 35.

I think this is related to Apache::StatINC - I've seen it now and again when
using StatINC, and IIRC it has been reported by others on the list...

StatINC is only really for development anyway - you may want to check out
Apache::Reload as a StatINC substitute if it's really bothersome.

HTH

--Geoff

 
 The subroutine is there (it executes in the first time). If I keep 
 trying to reload the page, sometimes it works, sometimes it doesn't.
 The same error happens to other scripts, with different subroutines 
 being called, but never happens if I run them from the command line
 (with the scripts slightly modified).
 
 some things from the server configuration:
 
 PerlInitHandler Apache::StatINC
 
 Location stuff
 SetHandler perl-script
 PerlHandler Apache::Registry
 Options ExecCGI
 allow from all
 PerlSendHeader on
 
 
 Can anyone help?
 Thanx
 
 Paulo
 



Re: crash in modperl-1.24

2000-09-28 Thread Michael J Schout

On Wed, 16 Aug 2000, Matt Sergeant wrote:

 On Tue, 15 Aug 2000, Mark D. Anderson wrote:
 
  The problem was the symbol conflict between XML::Parser and apache when
  built with expat. This has been apparently known for over a year, but has
  still not been fixed last i checked, presumably because it involves 4
  different products interacting: apache builds with expat, modperl gets
  linked in, then modperl pulls in XML::Parser which pulls in expat again.

[snip]

 name!!! Anyway, this is a much larger problem than you expect. Not only is
 XML::Parser pulling in a custom non-dso expat, but so is PHP, and so is
 Sablotron (XSLT processor), and so is some TCL module... We need a single
 DSO expat that is used by everyone, but I don't have the time or resources
 to fix it... :-(

This problem has just bitten us as well.  We were building apache with expat,
and then loading XML::Parser 2.29 in.  Things became unstable very quickly.  As
a quick fix, we just disabled EXPAT from our apache builds.

So I guess there is no hope of running any combination of mod_dav, XML::Parser,
PHP, Sablotron at the same time at this point?  Bummer :).

I suppose the issue is that expat needs to be maintained and someone needs to
incorporate all of hte separate patches (e.g. XML::Parser patches expat, I
assume PHP/Sablotron etc are doing the same)  into a single expat and create a
shared library?   I may be able to devote some time to this, depending on how
much merging is involved.  I will try to take a look at it over the next few
days.

Mike




RE: Undefined subroutine error (only now and then)

2000-09-28 Thread Michael

  The subroutine is there (it executes in the first time). If I keep 
  trying to reload the page, sometimes it works, sometimes it doesn't.
  The same error happens to other scripts, with different subroutines 
  being called, but never happens if I run them from the command line
  (with the scripts slightly modified).
  

If you run the server as single server mode

/usr/local/apache/bin/httpd -X

you should get the error every time the script runs. The reason you 
don't see it often is that you hit a new child which loads a fresh 
version and will not produce the error until the second load attempt. 

I never satisfactorialy solved the problem except to remove all 
subroutines from the parent script and put them in a "require" 
document. Since the require resources are only compiled once, the 
problem goes away.
[EMAIL PROTECTED]



Re: Seg Fault with Apache::Include

2000-09-28 Thread Doug MacEachern

On Wed, 27 Sep 2000, Magnus Erixzon wrote:

 
 I am having some problems with Apache::Include.
 When I include more than one file with it, the httpd seg faults.
 The script can be as simple as this:
 
 #!/usr/bin/perl
 use Apache::Include ();
 print "Content-type: text/html\n\n";
 Apache::Include-virtual('/perl-bin/helloworld');
 Apache::Include-virtual('/perl-bin/helloworld');

it's been in the ToDo list for a while.  in the meantime you can fix by
changing to:

 #!/usr/bin/perl
 use Apache::Include ();   

 my $r = shift;
 print "Content-type: text/html\n\n";
 Apache::Include-virtual('/perl-bin/helloworld', $r);
 Apache::Include-virtual('/perl-bin/helloworld', $r);






Re: PerlAuthenHandler advice needed.

2000-09-28 Thread Doug MacEachern

On Thu, 28 Sep 2000, Todd Chapman wrote:

 
 Thanks for the help Doug. This is what I have now but all I get is a
 segementation fault in the log.

 $r-note_basic_auth_failure;

if AuthType is not set, this will core dump.  i just expanded the change
that defaults AuthType to Basic for get_basic_auth_pw to include
note_basic_auth_failure, in the cvs tree.




Re: suggestions needed re. required files and persistent data

2000-09-28 Thread Perrin Harkins

On Thu, 28 Sep 2000, John Reid wrote:
 The problem I am facing is with our database definition files. These are
 custom files which are required at run time. The file consists of a long
 series of subroutine calls with arguments that refer to the definitions
 of fields, tables, etc. They are used in conjunction with a series of
 internal libraries to provide information for displaying data, handling
 file upload locations, etc. The subroutines modify data in global
 variables.
 
 The subroutines called exist in the calling module's namespace. When
 used as supplied they caused a significant memory leak (~120K per
 request). I have done a lot of work over the past few days to try and
 deal with the system to make it function as expected, but with no
 success. It would be nice if this data could be read and compiled at
 server start. I experimented with IPC::Shareable, but when I attempted
 to do anything with it in my startup.pl file it segfaulted the server
 and httpd would not start.

If you are just loading them at server start and not changing them at all
while running, you don't need IPC:: anything.  Just bring them in from
your startup.pl and put the data in globals.  If that's what you tried and
it isn't working, please post a little bit of your code for us.

- Perrin




RE: does notes() work with custom_response()?

2000-09-28 Thread Doug MacEachern

On Thu, 14 Sep 2000, brian d foy wrote:
 
 okay - i got that to work.  i was getting confused because notes from the
 handler() were showing up in the current request's notes for the
 custom_response() handler *and* (as i've discovered) in the previous
 notes.  should that happen? 

it shouldn't, i don't see that happening with this test:

sub MyThrow::handler {
my $r = shift;

$r-notes("Throw" = "whoopsie");
$r-custom_response(500, "/catch");

500;
}

sub MyCatch::handler {
my $r = shift;

$r-send_http_header;

print "notes:\n";
$r-notes-do(sub { print "   @_\n"; 1 });

print "prev-notes:\n";
$r-prev-notes-do(sub { print "   @_\n"; 1 });

0;
}

Location /throw
SetHandler perl-script
PerlHandler MyThrow::handler
/Location
Location /catch
SetHandler perl-script
PerlHandler MyCatch::handler
/Location

% telnet localhost 8529
Trying 127.0.0.1...
Connected to localhost (127.0.0.1).
Escape character is '^]'.
GET /throw http/1.0

HTTP/1.1 500 Internal Server Error
Date: Thu, 28 Sep 2000 18:08:31 GMT
Server: Apache/1.3.13-dev (Unix) mod_perl/1.24_01-dev Perl/v5.7.0
Connection: close
Content-Type: text/plain

notes:
   PERL_CUR_HOOK PerlHandler
   setenvif-phase-flag post-read done
prev-notes:
   PERL_CUR_HOOK PerlHandler
   setenvif-phase-flag post-read done
   Throw whoopsie
Connection closed by foreign host.





Re: PerlAuthenHandler advice needed.

2000-09-28 Thread Doug MacEachern

On Thu, 28 Sep 2000, Carlos Ramirez wrote:

 $r-auth_name($realm), $r-auth_type($basic) did not work for me, which
 is why I used the $r-header_out method. Also, after I set the outgoing
 header and returned AUTH_REQUIRED, I got prompted but the $realm did not
 show. Instead it displayed 'unknown' as the realm name. But when I set
 the $r-status and sent out the response via $r-send_http_header and
 returned AUTH_REQUIRED, the $realm name showed?

$r-auth_name($realm) works fine, provided you call
$r-note_basic_auth_failure, rather than
$r-header_out('WWW-Authenticate',...)

$r-auth_type did not become writeable until the patch i posted earlier.
 
 I read the docs as i started this exercise and was aware of
 $r-auth_name, $r-auth_type, but since they did'nt work and I kept
 getting segfaults when using them I decided to try other routes. But
 anyways I'm glad that I read the docs right and that you can indeed set
 the AuthName using $r-auth_name.

until the recent change where $r-auth_type became writeable, and
get_basic_auth_pw/note_basic_auth_failure default AuthType to Basic if it
is not configured, those methods would segfault.




Re: PerlAuthenHandler advice needed.

2000-09-28 Thread Todd Chapman


Thanks Doug but I (and my customer) don't want to live on the CVS bleeding
edge right now. Can you suggest something else?

Original problem:

I need to set the realm for virtual documents based on path_info and use
Basic authentication. Otherwise I may have to move to some cooie based
authentication but I don't want to do that.

-Todd

On Thu, 28 Sep 2000, Doug MacEachern wrote:

 On Thu, 28 Sep 2000, Todd Chapman wrote:
 
  
  Thanks for the help Doug. This is what I have now but all I get is a
  segementation fault in the log.
 
  $r-note_basic_auth_failure;
 
 if AuthType is not set, this will core dump.  i just expanded the change
 that defaults AuthType to Basic for get_basic_auth_pw to include
 note_basic_auth_failure, in the cvs tree.
 




Re: Make test error!!

2000-09-28 Thread Doug MacEachern

On Fri, 15 Sep 2000, [iso-8859-1] François Chenais wrote:

 Hello
 
 Using perl 5.6.0
   apache_1.3.9
 
 I 'm trying to build DSO mod_perl.1.24
 
   = perl Makefile.PL USE_DSO=1  EVERYTHING=1 PERL_DEBUG=1
 
 All is ok but "make test" says :
 
 ---
 ./apache_1.3.9/src/httpd -f `pwd`/t/conf/httpd.conf -X -d `pwd`/t 
 httpd listening on port 8529
 will write error_log to: t/logs/error_log
 letting apache warm up...\c
 done
 /usr/local/bin/perl t/TEST 0
 still waiting for server to warm up...not ok
 server failed to start! (please examine t/logs/error_log) at t/TEST line
 95.
 make: *** [run_tests] Error 111
 ---
 
 
 t/logs/error_log
 ---
 [notice] END block called for startup.pl
 [notice] Destruction-DESTROY called for $global_object
 [Fri Sep 15 10:34:40 2000] [warn] [notice] child_init for process 10374,
 report
 any problems to [no address given]
 ---

is the server still running?  check:

% ps -flags | grep httpd
or
% netstat -a | grep 8529
or 
% telnet localhost 8529

if it core dumped, run (in the mod_perl-x.xx directory):

% gdb ../apache-x.xx/src/htttpd
(gdb) thttpd
[if you get a core dump]
(gdb) bt

and post the output of that, along with your 'perl -V' and Makefile.PL
options.




Re: Having difficulties with Tie::DBI and mod_perl

2000-09-28 Thread Doug MacEachern

On Wed, 20 Sep 2000 [EMAIL PROTECTED] wrote:

 PerlFreshRestartOn

try turning that Off.  does DBI/DBD::mysql work for you without
Tie::DBI?




Re: The case of the disappearing routine

2000-09-28 Thread Doug MacEachern

On Thu, 21 Sep 2000, Chris Downes-Ward wrote:

 Dear all,
 
 We have a server which has a virtual server on it, this virtual server has a
 number of locations, one of which has a
 perl access handler defined, this server is a development server and is not
 heavily loaded. Every now and then (I wish I could be more precise) the
 entry point routine for the access handler "disappears". The error message
 in the log is "[error] Undefined subroutine routine name called". If I
 restart httpd the routine reappears.

what does your mod_perl configuration look like?




RE: Apache::Request-new() problem

2000-09-28 Thread Doug MacEachern

On Tue, 26 Sep 2000, Herrington, Jack wrote:

 I'm using Mason in process with mod_perl.  I have also tried using mod_perl
 handlers direct with Apache::Request with no success.

what do you see if you configure Apache::Status and open the url:
/perl-status?Apache::Request

?

also, any difference if you change Apache/Request.pm from:
__PACKAGE__-mod_perl::boot($VERSION);

to:

DynaLoader::bootstrap(__PACKAGE__, $VERSION);

?




Re: mod-perl as DSO (solaris)

2000-09-28 Thread Doug MacEachern

On Tue, 26 Sep 2000, Ricardo Stella wrote:

 Solaris 2.8
 Apache 1.3.12
 GCC 2.95.2
 Perl 5.6.0
 Enterprise 250 (64bitish)
 Modperl 1.24
 
 I can't get modperl compiled as a DSO neither via the 'flexible-method'
 nor the APXS method.
 
 The first method, seg faults.
 
 The second method won't configure, stating I should not build mod-perl
 as a DSO or compile perl with -Ubincompat5005.
 
 My current perl was compiled with bincompat5005 (perl -V:bincompat5005
 shows as 'defined')

exactly, -Ubincompat5005 will _un_ define bincompat5005, perl
-V:bincompat5005 should report: bincompat5005='undef';

this is a requirement for solaris (or any Perl where Perl's malloc is
used, rather than system malloc) , because Perl's malloc with 
bincompat5005 will pollute malloc() and free() into the main server, then
when mod_perl's dso is closed (it is closed/re-opened at startup), the
everything in the main server using free/malloc now has a function pointer
into la-la land.  when you turn off bincompat5005, then Perl's malloc/free
are namespace protected, so only Perl uses Perl's malloc.




Re: perl installation on hpux : cc vs gcc

2000-09-28 Thread Doug MacEachern

On Tue, 26 Sep 2000, Dhananjay Naniwadekar wrote:

 
 I am trying to install perl-5.6.0 on hpux.
 It is choosing cc as the c compiler. I don't know why. If I install an
 earlier version
 of perl, it chooses gcc.
 I have an env-variable named CC which is set to gcc .

try Configure -Dcc=gcc




Re: Why isn't PerlSetEnv working for me?

2000-09-28 Thread Doug MacEachern

On Tue, 26 Sep 2000, Keith G. Murphy wrote:

 I'm running Apache 1.3.9 with mod_perl embedded, on Debian GNU/Linux.
 
 I have the following lines towards the end of my httpd.conf:
 
 PerlSetEnv PERL5LIB /usr/local/MyPerl/lib
 PerlRequire startup.pl
 Include perllocs.conf
 
 However, upon system startup, my startup.pl fails because it can't find
 a particular module in the @INC list.
 
 If I start Apache from the command line, it works.  This is undoubtedly
 because PERL5LIB is set up in my /etc/profile, to the same path.
 
 I've looked at this until I'm crosseyed.  Seemingly PerlSetEnv just
 doesn't work.
 
 Any ideas?  Yes, I know the workaround: 'use lib' in startup.pl.  But
 why?

PerlSetEnv PERL5LIB works fine for me, and should work regardless of
PerlTaintCheck, because mod_perl treats it special (note for the guide,
stas).

mod_perl-x.xx/t/conf/httpd.conf has this config:

Location /perl/perl-status
PerlSetVar StatusOptionsAll On
SetHandler perl-script
PerlHandler +Apache::Status
PerlSetEnv PERL5LIB /home/dougm/lib/perl
/Location

which i can see as the last @INC entry printed by:
/perl-status?inc




Re: Why isn't PerlSetEnv working for me?

2000-09-28 Thread Doug MacEachern

On Wed, 27 Sep 2000, Keith G. Murphy wrote:
 
 Upon further investigation, what I am seeing is that PERL5LIB gets
 passed into %ENV just fine.  It's just not being used to locate modules;
 it is not in @INC.  Could the part of Perl that pushes the PERL5LIB
 setting to @INC have already executed prior to my PerlSetEnv statement?

i don't think so, it's set by mod_perl.c on every request, in
perl_per_request_init():
/* SetEnv PERL5LIB */
if (!MP_INCPUSH(cld)) {
char *path = (char *)table_get(r-subprocess_env, "PERL5LIB");

if (path) {
perl_incpush(path);
MP_INCPUSH_on(cld);
}
}

what version of mod_perl are you using?




Re: crash in modperl-1.24

2000-09-28 Thread Matt Sergeant

On Thu, 28 Sep 2000, Michael J Schout wrote:

 On Wed, 16 Aug 2000, Matt Sergeant wrote:
 
  On Tue, 15 Aug 2000, Mark D. Anderson wrote:
  
   The problem was the symbol conflict between XML::Parser and apache when
   built with expat. This has been apparently known for over a year, but has
   still not been fixed last i checked, presumably because it involves 4
   different products interacting: apache builds with expat, modperl gets
   linked in, then modperl pulls in XML::Parser which pulls in expat again.
 
 [snip]
 
  name!!! Anyway, this is a much larger problem than you expect. Not only is
  XML::Parser pulling in a custom non-dso expat, but so is PHP, and so is
  Sablotron (XSLT processor), and so is some TCL module... We need a single
  DSO expat that is used by everyone, but I don't have the time or resources
  to fix it... :-(
 
 This problem has just bitten us as well.  We were building apache with expat,
 and then loading XML::Parser 2.29 in.  Things became unstable very quickly.  As
 a quick fix, we just disabled EXPAT from our apache builds.
 
 So I guess there is no hope of running any combination of mod_dav, XML::Parser,
 PHP, Sablotron at the same time at this point?  Bummer :).
 
 I suppose the issue is that expat needs to be maintained and someone needs to
 incorporate all of hte separate patches (e.g. XML::Parser patches expat, I
 assume PHP/Sablotron etc are doing the same)  into a single expat and create a
 shared library?   I may be able to devote some time to this, depending on how
 much merging is involved.  I will try to take a look at it over the next few
 days.

No don't - its being done now. Clark Cooper is running the project over on
source forge. However I know that Clark can be quite slow at times, so
maybe he could do with some help.

-- 
Matt/

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org | AxKit: http://axkit.org




Re: Apache::Status Memory Usage metrics

2000-09-28 Thread Doug MacEachern

On Tue, 29 Aug 2000, Lyle D. Brooks wrote:

 This is my first time posting to this list, so forgive me
 if this question has been asked before (I did not see it in
 the archives or in the mod_perl guide).
 
 Apache::Status seems like a nice module, but I don't understand
 what the Memory usage section is telling me.
 
 For a given package, I have a function foo() that has a line 
 like this.
 
 
 foo   48293 bytes   |   1172 OPs
 
 
 Here's my questions...
 
 1) 48293 bytes is what?  Is that code?, stack?, data? or a combination
of some of the three?  

TerseSize measures the sizeof() all structures (and strlen() of any 
strings) pointed to by the syntax (op) tree, lexical variables and
globals.

 2) 1172 OPs - what's an OPs?  Is it good to have more or less?  How does 
that affect memory usage?

see matt's explanation.  less is better.
 
 3) Without changing the code, I can reload the memory usage page and the 
same function foo() will generally have the same number of bytes, but 
not always.  The OPs always seem to remain the same number however.  The
bytes can vary but they don't seem to grow a great deal.  Is this varying
number a memory leak in the function?  If not, what causes the number to
vary from one invocation to the next?

i'm not sure if stas has added a section to guide, but this has been
explained a bunch of times here on the list.  in a nutshell, Perl hangs
onto many of the allocations your scripts makes, such as the first
time a variable is used by a script (they are all NULL at compile
time), string copies, array and hash sizes, scratch pads for things like
join, concatination, etc.  B-LexInfo includes a handler to show this
behavior in action.




Re: PerlAuthenHandler advice needed.

2000-09-28 Thread Doug MacEachern

On Thu, 28 Sep 2000, Todd Chapman wrote:

 
 Thanks Doug but I (and my customer) don't want to live on the CVS bleeding
 edge right now. Can you suggest something else?

yeah, add this to httpd.conf:

AuthType Basic





RE: Core file (debugging info turned on/stack trace)

2000-09-28 Thread Doug MacEachern

On Tue, 26 Sep 2000, Shane Adams wrote:

 Well I did a little more investigation - it seems that we are dieing in
 Expat.pm line 451. The offending Function is:
...

is this something you can reproduce at will?  if you can give me a tiny
test case that i can drop and i run, i'll take a look.
 
 As I recall, Doug, you helped me patch part of HTML::Mason dealing with
 typeglobs under an eval ... I believe that * is a typeglob in perl yes?

right.




Re: NOT_FOUND from a PerlHandler causing problems with ErrorDocument

2000-09-28 Thread Doug MacEachern

On 28 Sep 2000, Bjørn Ola Smievoll wrote:

 [Sorry for being so verbose, hope somebody still have the time and
 patience to read it all].
 
 I have a setup where a PerlTransHandler registers a PerlContentHandler
 based simply on whether $r-uri ends with '.html' or not.  The
 TransHandler does no verifying of the existence of the file, that
 doesn't happen until the ContentHandler kicks in.  For an unsuccessful
 '-e' test, NOT_FOUND is returned from the ContentHandler.  All this
 worked fine until I added an perl-based handler for the 404 using the
 ErrorDocument parameter in httpd.conf[1].

your error handler works fine for me with 404's.  what is your
PerlTransHandler doing?




Re: Problem with Apache::SIG

2000-09-28 Thread Bill Moseley

At 01:25 PM 04/20/00 -0700, Doug MacEachern wrote:
On Wed, 12 Apr 2000 [EMAIL PROTECTED] wrote:

 Hi All,
...
 [Mon Apr 10 22:27:01 2000] [error]  at
 /usr/lib/perl5/site_perl/5.005/i386-linux/Apache/SIG.pm line 31.
 
 Line 31 is Apache::exit($s);

Apache::exit() calls die() underneath to halt script execution.  it tie's
$@ so it appears empty to avoid such messages, somehow the magic was lost.
so the message in this case is nothing more than annoying.

Is there a way to make that message go away?

sub check_not_modified {
my $r = shift;
...
$r-status( HTTP_NOT_MODIFIED );
$r-exit;
}

Since check_not_modified() may be a number of subs deep I now must return a
code that heads back to the initial handler where it can simply return
HTTP_NOT_MODIFIED, but it would be better to just exit().

Is there a better way to exit?


Bill Moseley
mailto:[EMAIL PROTECTED]



iconv/LD_PRELOAD question

2000-09-28 Thread Rajit Singh

To Whom It May Concern,

I have a question with regards using LD_PRELOAD (or something more appropriate) to 
load libiconv_plug.so and override any other iconv implementation.  (Would be grateful 
is someone can help).

I'm running Apache with mod_perl 1.24 on Solaris 2.6.  I'm using XML::Sablotron, and 
get it to convert to the iso-8859-1 character set.  This isn't supported by default on 
Solaris, because its default iconv installation doesn't support Unicode (which is what 
Sablotron converts from).  So I installed a new iconv implementation - and in the 
installation it advises using LD_PRELOAD=/usr/local/lib/libiconv_plug.so to override 
the default iconv implementation.

When running my scripts under normal CGI circumstances I used SetEnv in httpd.conf in 
the Directory/ configuration to set LD_PRELOAD.  When trying the script under 
mod_perl, I've tried a number of methods to get libiconv_plug.so to override the 
default iconv implementation to no avail.

I've tried SetEnv (out of desperation... I already knew it wouldn't work)
I tried compiling Sablotron with iconv_plug.so, but I figured that wouldn't work, 
'cause then it's loaded after the default implementation
I tried set LD_PRELOAD and then running apachectl.
I tried setting LD_PRELOAD inside apachectl.

Really... I'd be grateful if someone has an answer for this.

Thanks in advance,
Rajit



Re: Why is Apache::PerlRun a subclass of Apache?

2000-09-28 Thread Doug MacEachern

On Fri, 25 Aug 2000, Ken Williams wrote:

ken, you're right, has-a relationship is the right way to go.  your patch
is perfect, applied, thanks!!  i guess this will break some things, like
Apache::RegistryLexInfo, but changes should be minimal and
RegistryNG/PerlRun is still considered experimental-ish.




?? Server-push or sending multipart (multiple pages) data to client

2000-09-28 Thread Lang, Cliff


With Apache 1.3, mod_perl 1.21 

How can I gererate multiple pages returned from one request?  I don't see
how to create the multi-part return, when the data comes from multiple
static files:

eg.

request : www.mysite.com/userdir/index.html  When this request comes in and
based on some settings in the authen-db, we need to generate not only the
data from index.html, but also send the file www.mysite.com/core/info.html
which would be opened in another window.

And to make things worse - even though I called index.html in my exaple, I
really need to trigger the second file whenever "ANY" request comes in to
the users directory.  This means it may be a static file, a directory
listing, or dynamic info created by a module.  The last of which is my main
problem.  I am trying to do this without doing a sepate lwp-request, pulling
into a local array and resending - 

If this is my only way then is it worth it?  Wouldn't the performance hit be
quite high?  80-90% of the users would require this second page.  Are there
a better approach?  

I have found the CGI::Push::do_push, but this only works for dynamic data,
or data in a local @array.  Is there a way to tie Apache to CGI::Push, and
let me pass in a uri?  Or have one leg do a lookup_uri($user_request_uri);,
and the other do a static $r-lookup("/file.html"); ?


do_push(-next_page = \main_request,
 -last_page =  \secondary_page,
 -delay = 0.0,
);


sub main_page {
my($q,$counter) = @_;  # $q, $counter are
passed in automagically
return undef if $counter = 2;  # second time
through it terminates the loop
return $r-lookup_uri($user_request_uri);
 }

sub secondary_page {
my($q,$counter) = @_;
   return $r-lookup_file("/some_file.html");
}



TIA -



Re: Apache-request($r) broken?

2000-09-28 Thread Doug MacEachern

On Thu, 24 Aug 2000, Ken Williams wrote:

 Hi all,
 
 It looks like setting Apache-request($r) doesn't work as documented.  I
 can't get it to install a subclass of Apache as the request object.
 
 Here's some code in a handler:
 _
 warn "blessing $r into ", __PACKAGE__;
 Apache-request($r = bless { _r = $r});
 warn "\$r is $r";
 warn "Apache-request is ", Apache-request;
 _
 
 And the result in the error logs:
 _
 blessing Apache=SCALAR(0x1401eaeb8) into Apache::Filter at ...
 $r is Apache::Filter=HASH(0x140088028) at ... 
 Apache-request is Apache=SCALAR(0x1401fdab8) at ... 
 _
 
 Notice that even after I call Apache-request($r), Apache-request still
 returns an object blessed into the 'Apache' class, not the class of the
 object I gave it.

it is broken in this respect, i just added this to ToDo:
- Apache-request($r) digs the request_rec out of $r regardless of the 
  type/class, e.g. Apache-request(bless {r = $r}, 'My::Apache')

with your PerlRun patch applied, your in no rush to have this fixed,
right?




Re: iconv/LD_PRELOAD question

2000-09-28 Thread Doug MacEachern

how about using mod_so's LoadFile directive?

On Thu, 28 Sep 2000, Rajit Singh wrote:

 To Whom It May Concern,
 
 I have a question with regards using LD_PRELOAD (or something more appropriate) to 
load libiconv_plug.so and override any other iconv implementation.  (Would be 
grateful is someone can help).
 
 I'm running Apache with mod_perl 1.24 on Solaris 2.6.  I'm using XML::Sablotron, and 
get it to convert to the iso-8859-1 character set.  This isn't supported by default 
on Solaris, because its default iconv installation doesn't support Unicode (which is 
what Sablotron converts from).  So I installed a new iconv implementation - and in 
the installation it advises using LD_PRELOAD=/usr/local/lib/libiconv_plug.so to 
override the default iconv implementation.
 
 When running my scripts under normal CGI circumstances I used SetEnv in httpd.conf 
in the Directory/ configuration to set LD_PRELOAD.  When trying the script under 
mod_perl, I've tried a number of methods to get libiconv_plug.so to override the 
default iconv implementation to no avail.
 
 I've tried SetEnv (out of desperation... I already knew it wouldn't work)
 I tried compiling Sablotron with iconv_plug.so, but I figured that wouldn't work, 
'cause then it's loaded after the default implementation
 I tried set LD_PRELOAD and then running apachectl.
 I tried setting LD_PRELOAD inside apachectl.
 
 Really... I'd be grateful if someone has an answer for this.
 
 Thanks in advance,
 Rajit
 




OOP and mod_perl question

2000-09-28 Thread Andreas Grupp

Hello

I am trying to develop for the first time a perl module. It should work on a 
server with mod_perl. The objects are not using mod_perl ($r) and are just 
solving some of my work in a nicer way. Since I'm new in OOP on perl (I only 
know C++) I would hear from some experts that the following is allowed in Perl 
OO modules and does not conflict with mod_perl.

The question belongs to the constructor. I have $self as a class reference on 
the brandnew object. Now in the rest of my constructor I do some Querys on a 
MySQL database to get information about the authenticated user (.htaccess with 
AuthenDBI). Afterwards I store the user-data retrieved from the database in a 
hash-variable and put a reference to this hash in the $self object in the 
following way:

$self-{'userdata'}-$hashref

Now I can get the different parts of userdata in other instance-methods with 
code like the following ($po is an object of this class):

my $po = new Peseta;
print "pThis desk belongs to: " . $po-{'userdata'}-{'ulname'} . "/p";

My question is now: Can I be sure that there are no conflicts when several 
users are requesting pages that work with this module? Can I be sure that the 
object data is not shared between different requests and the object has really 
only data corresponding to the actual request when I follow the general rules 
for OOP under perl?

Thanks a lot for your answers

  Andreas

--


Elektronikschule Tettnang   http://www.elektronikschule.de/~grupp
Oberhofer Str. 25   mailto:[EMAIL PROTECTED]
88069 Tettnang  PGP-Key available via mail. Use subject
Tel.: +49 7542 9372-33  Use subject: send pgp-public-key
Fax.: +49 7542 9372-40



Re: PerlAuthenHandler advice needed.

2000-09-28 Thread Todd Chapman


Duh! Thanks.

Now, is there any way to determine the realm the browser thinks it's
authentication to? Is the realm stored in the Authorization header or any
other headers?

-Todd

On Thu, 28 Sep 2000, Doug MacEachern wrote:

 On Thu, 28 Sep 2000, Todd Chapman wrote:
 
  
  Thanks Doug but I (and my customer) don't want to live on the CVS bleeding
  edge right now. Can you suggest something else?
 
 yeah, add this to httpd.conf:
 
 AuthType Basic
 
 




Re: Problem with Apache::SIG

2000-09-28 Thread Doug MacEachern

On Thu, 28 Sep 2000, Bill Moseley wrote:
 
 Is there a way to make that message go away?

maybe if you can give me a small example that reproduces the message.  it
works fine for me:

shift-send_http_header;

print "hi\n";

exit;

print "bye\n";

nothing in the error_log.

actually, the patch below might fix it.  lemme know.

--- src/modules/perl/perl_util.c2000/08/15 19:36:34 1.41
+++ src/modules/perl/perl_util.c2000/09/28 20:43:14
@@ -424,7 +424,7 @@
 static I32
 errgv_empty_set(IV ix, SV* sv)
 { 
-sv_setpv(sv, "");
+sv_setsv(sv, sv_no);
 return TRUE;
 }
 





Re: open - does not work

2000-09-28 Thread Doug MacEachern

On Thu, 28 Sep 2000, Vsevolod Ilyushchenko wrote:

 Hi,
 
 Why does this script give no output under mod_perl, but works fine from the command 
line:
 
 #!/usr/bin/perl -w
 
 use CGI;
 
 print CGI-header();
 
 open (AAA, "-");

because the C level stdout is not hooked up to the client.  you can do
this as an alternative:

if ($ENV{MOD_PERL}) {
tie *AAA, 'Apache';
}
else {
open (AAA, "-");
}




Re: PerlSendHeader Off socket persistence (was Re: question: usingApache for non-HTML messages)

2000-09-28 Thread Doug MacEachern

On Wed, 27 Sep 2000, B. Burke wrote:

 When I set PerlSendHeader to Off in my perl.conf it doesn't send headers,
 which
 is good.  The bad part is that it seems to break socket persistence for some
 reason.
 When I have PerlSendHeader set to On, I can open a socket with my test client,
 
 and make multiple queries on the same socket.

what is your test client?  apache will close the connection after the
first request, unless keep-alive is maintained between client/server.




Re: [WOT] MakeMaker

2000-09-28 Thread Doug MacEachern

try DIR = []




Re: Patch for easy testing of Apache::* modules (resend)

2000-09-28 Thread Doug MacEachern

On Mon, 17 Jul 2000, Ken Williams wrote:

 Hi all,
 
 Here's a resend of the Apache::test patch that I sent yesterday, this time
 sent as type text/plain from a Unix mailer.  Rick Myers noted that the
 version I sent before was encoded with Macintosh BinHex, which is probably
 not the most appropriate choice for this list. ;-)

looks great ken, applied, thanks!
btw, when i first skimmed the patch, i thought it modified the
mod_perl Makefile.PL test foo, which is why i was holding off.




Re: open - does not work

2000-09-28 Thread Vsevolod Ilyushchenko

  Why does this script give no output under mod_perl, but works fine from the 
command line:
 
  #!/usr/bin/perl -w
 
  use CGI;
 
  print CGI-header();
 
  open (AAA, "-");
 
 because the C level stdout is not hooked up to the client.  you can do
 this as an alternative:
 
 if ($ENV{MOD_PERL}) {
 tie *AAA, 'Apache';
 }
 else {
 open (AAA, "-");
 }

Doug,

Thanks, this works. However, it also gives me the following error:

Can't locate object method "FETCH" via package "Apache" at 
/usr/lib/perl5/site_perl/5.005/i386-linux/Apache/PerlRun.pm line 310.

Besides, what is the incantation to be able to open pipes to programs and capture 
their output:

open (AAA, "|some_program");

Simon
-- 
 _
|   x |   Simon (Vsevolod ILyushchenko) [EMAIL PROTECTED]   
| y = e   |
|_|   http://www.simonf.com[EMAIL PROTECTED]   
| 
 
Disclaimer: This is not me.
This is just my mailer talking to your mailer...



RE: open - does not work

2000-09-28 Thread Jerrad Pierce

No... that opens a handle to ehir INPUT

output is
open(OUT, "magic_open |");

Or you could just slurp in a string with

$_ = `normal_open`;

-Original Message-
From: Vsevolod Ilyushchenko [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 28, 2000 5:17 PM
To: Doug MacEachern
Cc: [EMAIL PROTECTED]
Subject: Re: open "-" does not work


  Why does this script give no output under mod_perl, but 
works fine from the command line:
 
  #!/usr/bin/perl -w
 
  use CGI;
 
  print CGI-header();
 
  open (AAA, "-");
 
 because the C level stdout is not hooked up to the client.  
you can do
 this as an alternative:
 
 if ($ENV{MOD_PERL}) {
 tie *AAA, 'Apache';
 }
 else {
 open (AAA, "-");
 }

Doug,

Thanks, this works. However, it also gives me the following error:

Can't locate object method "FETCH" via package "Apache" at 
/usr/lib/perl5/site_perl/5.005/i386-linux/Apache/PerlRun.pm line 310.

Besides, what is the incantation to be able to open pipes to 
programs and capture their output:

open (AAA, "|some_program");

Simon
-- 
 _
|   x |   Simon (Vsevolod ILyushchenko) [EMAIL PROTECTED]   
| y = e   |
|_|   http://www.simonf.com
[EMAIL PROTECTED]  
 
   Disclaimer: This is not me. 
   
   This is just my mailer talking to your mailer...




Update: Re: PerlSendHeader Off socket persistence (was Re: question: usingApache for non-HTML messages)

2000-09-28 Thread B. Burke


 what is your test client?
I wrote a command line client that just sends/receives basic messages for testing.

I have been opening a socket and sending this:
GET /perl/myscript HTTP/1.1
Connection: Keep-Alive
Host: myhost.mydomain.com\n\n

It worked as expected - I was able to keep the socket open and send  receive
multiple
messages.  When I set PerlSendHeader to Off, the socket closed after the 1st query.

I finally had success with socket persistence when I tried using CGI to print the
header
by replacing this:
print "Content-type: text/html\n\n";
with this:
print header();

Once I changed how I was printing the header from the script, the socket
persistence
worked with PerlSendHeader Off.  So I guess I solved my problem although I don't
really
know why.

Brian


Doug MacEachern wrote:

 On Wed, 27 Sep 2000, B. Burke wrote:

  When I set PerlSendHeader to Off in my perl.conf it doesn't send headers,
  which
  is good.  The bad part is that it seems to break socket persistence for some
  reason.
  When I have PerlSendHeader set to On, I can open a socket with my test client,
 
  and make multiple queries on the same socket.

 what is your test client?  apache will close the connection after the
 first request, unless keep-alive is maintained between client/server.




Re: PerlAuthenHandler advice needed.

2000-09-28 Thread Joe Schaefer

Todd Chapman [EMAIL PROTECTED] writes:

 Duh! Thanks.
 
 Now, is there any way to determine the realm the browser thinks it's
 authentication to? Is the realm stored in the Authorization header or any
 other headers?
 

I wouldn't try to use realms in any serious way- various browsers
do various things.  The only reliable way to have the browser send
different passwords to different locations is to use different 
server names.

-- 
Joe Schaefer



(possible bug) PerlAccessHandler called twice?

2000-09-28 Thread Adi

I am using mod_proxy_add_forward to get the correct IP address from the proxy
server, as described in the guide.  On my back-end mod_perl server, I want to
limit access only to requests coming from the proxy server.  I can't use simple
IP-based access control via mod_access because PerlPostReadRequestHandler runs
before PerlAccessHandler, so $r-remote_addr has already been changed to the
client's IP.

So, I wrote my own PerlAccessHandler that reads $r-notes to see if the request
came from the proxy:

Perl
sub My::ProxyAccessOnly {
my $r = shift;
my $from_proxy = $r-notes("PROXY_REQUEST");
$r-warn("from_proxy = '$from_proxy'");
return FORBIDDEN unless $from_proxy;
return OK;
}
/Perl
PerlAccessHandler My::ProxyAccessOnly


I added a line to Ask's My::ProxyRemoteAddr that sets $r-notes:

Perl
sub My::ProxyRemoteAddr($) {
my $r = shift;

# we'll only look at the X-Forwarded-For header if the requests
# comes from our proxy at localhost
return OK unless $r-connection-remote_ip eq '127.0.0.1';

if (my ($ip) = $r-header_in('X-Forwarded-For') =~ /([^,\s]+)$/) {
$r-notes("PROXY_REQUEST" = 1); #note that this comes from proxy
$r-connection-remote_ip($ip);
$r-warn("set remote ip to $ip");
}

return OK;
}
/Perl
PerlPostReadRequestHandler My::ProxyRemoteAddr


In my log I get, for each request:

[Thu Sep 28 17:02:25 2000] [warn] set remote ip to 192.168.178.13
[Thu Sep 28 17:02:25 2000] [warn] from_proxy = '1'
[Thu Sep 28 17:02:25 2000] [warn] from_proxy = '0'


As it turns out, the second call to My::ProxyAccessOnly is an internal redirect,
because if I add the following line, everything works as expected, and I only
get one log line.

return DECLINED if !$r-is_initial_req;

[Thu Sep 28 17:02:25 2000] [warn] set remote ip to 192.168.178.13
[Thu Sep 28 17:02:25 2000] [warn] from_proxy = '1'


Is there a logical reason why PerlAccessHandler should be called twice, the
second time from within Apache?  Also, is there a better way I should go about
accomplishing my desired goal of only allowing proxy-through requests to the
mod_perl server?

-Adi




[sOT] Apache::DBI Connection pooling vs. IIS (or Apache on NT)

2000-09-28 Thread Roderick A. Anderson

Slightly off topic but I think interesting.  If this have been covered
sometime before about 4 months ago please point me there.

I've taken on the support of a website that was designed as a student
project.  To make them feel warm and fuzzy the site was done using Windows
NT, MS IIS, SQL Server 6.5, ODBC, and VBScript(?) (You've probably already
seen some of my pleas for help and information).
   After finally getting it operating again I have to get prepared for a
pile of hits.  My reading indicates NT/IIS/SQL Server don't do well on a
single machine, whereas UNIX(Linux)/Apache/PostgreSQL do.  The things that
strike me as performance plus' are the persistant database connections,
pooled connections, and just mod_perl in general.

So the question is does IIS have these features?  If not, or even if so,
would Apache and PostgreSQL on NT have these benefits?
 

Rod
--
Roderick A. Anderson
[EMAIL PROTECTED]   Altoplanos Information Systems, Inc.
Voice: 208.765.6149212 S. 11th Street, Suite 5
FAX: 208.664.5299  Coeur d'Alene, ID 83814




[ OT - Job ]

2000-09-28 Thread Kip Cranford


We are looking for experienced mod_perl programmers for a large web
application project.  Startup environment, lots of autonomy, good $$.
Other desired skills: Perl/XS, C, C++, database experience.

The job is on-site, and we're in Dearborn, Michigan.

If anyone's interested, please contact me at this email address.

Thanks,

--kip



Re: ?? Server-push or sending multipart (multiple pages) data to clie nt

2000-09-28 Thread Joe Schaefer

"Lang, Cliff" [EMAIL PROTECTED] writes:


[...]

 request : www.mysite.com/userdir/index.html  When this request comes in and
 based on some settings in the authen-db, we need to generate not only the
 data from index.html, but also send the file www.mysite.com/core/info.html
 which would be opened in another window.

Server push has been dead for some time- IE5 doesn't even support the
x-multipart-replace header. The known IE5 "workaround" is to just send 
entire html../html bodies in sequence w/o additional header info, 
but you probably shouldn't invoke heavy browser voodoo unless you're 
seriously `charmed'.

A lesser (and safer) magic would be to insert a javascript snippet 
in each page. The javascript opens the window and makes the request for 
/core/info.html. Install an appropriate mod_perl content filter for 
"Location /userdir" with a line like

s/body/body onLoad='open("/core/info.html", "other_window")'/io;

Some variation on this might do the trick.

-- 
Joe Schaefer
[EMAIL PROTECTED]

SunStar Systems, Inc.



Zope functionality under mod_perl

2000-09-28 Thread Philip Molter

Recently, one of my co-employees has been messing around with Zope
(http://www.zope.org) and I was wondering if there's a package that
provides similar functionality using mod_perl and Apache rather
than its own web server.  Specically, what I want to do is define
template web objects that can be rendered as web pages or inherited
by other web objects.  The end result is that I should be able to
define a stylesheet or web template for each defined object and
simply use scripts/CGI/what-have-you to populate the objects,
returning the HTML to the web browser.
 
I've looked at AxKit, and I'm not quite sure if it's exactly what
I'm looking for, especially since the development team I'm working
for does not have much XML/XSL experience and I'd like to keep it
as perl/HTML oriented as possible.  I've also looked at several of
the templating tools, but they don't look like they provide the
object-oriented aspect I'm looking for (or do they; anyone have
experience down that path)?
 
Any information, opinions, or experiences would be greatly appreciated
Philip

* Philip Molter
* DataFoundry.net
* http://www.datafoundry.net/
* [EMAIL PROTECTED]



Re: Problem with Apache::SIG

2000-09-28 Thread Bill Moseley

At 01:43 PM 09/28/00 -0700, Doug MacEachern wrote:
On Thu, 28 Sep 2000, Bill Moseley wrote:
 
 Is there a way to make that message go away?

maybe if you can give me a small example that reproduces the message.  it
works fine for me:

package My::Hello;
use strict;
use Apache::Constants qw(HTTP_NOT_MODIFIED);

sub handler {
my $r = shift;
$r-status( HTTP_NOT_MODIFIED );
$r-exit;
}

PerlFreshRestart On
PerlTaintCheck On
PerlWarn On

Location /
PerlSendHeader off
SetHandler perl-module
PerlHandler My::Hello
Allow from all
/Location
1;

GET / http/1.0

HTTP/1.1 304 Not Modified
Date: Thu, 28 Sep 2000 22:18:36 GMT
Server: Apache/1.3.12 (Unix) mod_perl/1.24
Connection: close

[Thu Sep 28 15:18:36 2000] [error]  at /data/_g/lii/My/Hello.pm line 8.


actually, the patch below might fix it.  lemme know.

Nope.  I just downloaded a fresh 1.24, and 1.3.12 and built with

perl Makefile.PL \
APACHE_SRC=../apache_1.3.12/src \
DO_HTTPD=1 \
USE_APACI=1 \
EVERYTHING=1 \
APACI_ARGS='--enable-module=rewrite --disable-module=include'

BTW --disable-module=include causes:
modules/ssi.FAILED before any test output arrived

Any way to detect that SSI is disabled and not run the test?




Bill Moseley
mailto:[EMAIL PROTECTED]



Re: Zope functionality under mod_perl

2000-09-28 Thread Perrin Harkins

On Thu, 28 Sep 2000, Philip Molter wrote:
 Recently, one of my co-employees has been messing around with Zope
 (http://www.zope.org) and I was wondering if there's a package that
 provides similar functionality using mod_perl and Apache rather than
 its own web server.  Specically, what I want to do is define template
 web objects that can be rendered as web pages or inherited by other
 web objects.  The end result is that I should be able to define a
 stylesheet or web template for each defined object and simply use
 scripts/CGI/what-have-you to populate the objects, returning the HTML
 to the web browser.

My experience with Zope is that it's not as simple as it might initially
look and you have to write Python code to do anything useful.  However,
there are some Perl projects with a similar goal.  You might look at
http://wirm.org/ or http://sourceforge.net/projects/iaido/.

- Perrin




Re:RE: Remote Hosting

2000-09-28 Thread Allen Wilson

Okay...I have not used that before but I will definitely take a look at it.

Thanks...Allen..

Reply Separator
Subject:RE: Remote Hosting
Author: [EMAIL PROTECTED]
Date:   9/26/00 5:06 PM

Take a look at Apache::ProxyStuff. It may do exactly what you want and if it
doesn't it'll give you some ideas on how to do what you want.

On 26-Sep-2000 Allen Wilson wrote:
 Does anyone have an idea of how to set up a remote host request. I am
 attempting
 to set up a web system where the user makes a request and it is process from
 one
 server to another. The remote server will return a file that will be
 formatted
 in a web page. 
 
 I already have the formatting done...it is the connection and requesting from
 the remote server giving me the problem. I tried to run the remote shell
 (remsh
 ) but that failed.
 
 Any ideas would be appreciate.
 
 Allen

-- 
Jason Bodnar + [EMAIL PROTECTED] + Team Linux

If there was any justice, my face would be on a bunch of crappy merchandise!

-- Homer Simpson
   Flaming Moe's




Re: Why isn't PerlSetEnv working for me?

2000-09-28 Thread Stas Bekman

On Thu, 28 Sep 2000, Doug MacEachern wrote:

 On Tue, 26 Sep 2000, Keith G. Murphy wrote:
 
  I'm running Apache 1.3.9 with mod_perl embedded, on Debian GNU/Linux.
  
  I have the following lines towards the end of my httpd.conf:
  
  PerlSetEnv PERL5LIB /usr/local/MyPerl/lib
  PerlRequire startup.pl
  Include perllocs.conf
  
  However, upon system startup, my startup.pl fails because it can't find
  a particular module in the @INC list.
  
  If I start Apache from the command line, it works.  This is undoubtedly
  because PERL5LIB is set up in my /etc/profile, to the same path.
  
  I've looked at this until I'm crosseyed.  Seemingly PerlSetEnv just
  doesn't work.
  
  Any ideas?  Yes, I know the workaround: 'use lib' in startup.pl.  But
  why?
 
 PerlSetEnv PERL5LIB works fine for me, and should work regardless of
 PerlTaintCheck, because mod_perl treats it special (note for the guide,
 stas).

Hmm, I didn't take it out of my head, I cannot remember now when it was
added. Was it different before and I've missed the patch?

Anyway, that means that I should fix the guide, to remove the note about
PERL5LIB and PerlTaintMode, right?

 mod_perl-x.xx/t/conf/httpd.conf has this config:
 
 Location /perl/perl-status
 PerlSetVar StatusOptionsAll On
 SetHandler perl-script
 PerlHandler +Apache::Status
 PerlSetEnv PERL5LIB /home/dougm/lib/perl
 /Location
 
 which i can see as the last @INC entry printed by:
 /perl-status?inc
 
 



_
Stas Bekman  JAm_pH --   Just Another mod_perl Hacker
http://stason.org/   mod_perl Guide  http://perl.apache.org/guide 
mailto:[EMAIL PROTECTED]   http://apachetoday.com http://jazzvalley.com
http://singlesheaven.com http://perlmonth.com   perl.org   apache.org





Problems with proxying POST?

2000-09-28 Thread Chris Lewis

I'm writing a perl trans handler to invoke mod_proxy for non-proxy
requests.

Stronghold 3 on Solaris 2.6, server announces:

Stronghold/3.0 Apache/1.3.12 C2NetEU/3011 (Unix) PHP/3.0.16
mod_ssl/2.6.4 OpenSSL/0.9.5a mod_perl/1.22

I'm essentially using the code from page 371 of the Eagle book without
the URL translate::

 my $host = $r-get_server_name;
 add some headers etc. using $r-header_in
 my $newuri = Apache::URI-parse($r);
 my $scheme = $newuri-scheme;
 my $newuristring = "$scheme://$host" . $r-uri;
 if ($newuristring) {
$r-proxyreq(1);
$r-uri($newuristring);
$r-filename("proxy:$newuristring");
$r-handler('proxy-server');
return OK;
 }

It works to proxy the HTTP to the system fine, however, POST parameters
seem to get mangled and/or truncated.
 
I'm not actually even changing the URI, because the server's notion of
name resolution is different than the browser's.

In short: external DNS maps all of the sites this thing will proxy to do
the server itself.  The server has a /etc/hosts file that remaps all of
the host names to the real servers.  Hence, I don't actually have to
change the uris.

Shouldn't POST parameters go thru without playing around with
read/content?

When I try to reference $r-content the thing appears to hang.



Re: Zope functionality under mod_perl

2000-09-28 Thread John Saylor

Hi

( 00.09.28 17:29 -0500 ) Philip Molter:
 Recently, one of my co-employees has been messing around with Zope
 (http://www.zope.org) and I was wondering if there's a package that
 provides similar functionality using mod_perl and Apache rather
 than its own web server.

That would be mason
http://www.masonhq.com/


-- 
\js

A steak a day keeps the cows dead. 



error messages..

2000-09-28 Thread Sam Park

Anybody knows why I'm getting this messages...???
5744 Pinging 'prodcrank.excite.com~crank~crank~RaiseError=1'
5744 Apache::DBI already connected to
'prodcrank.excite.com~crank~crank~RaiseErr
or=1'
5744 Pinging 'prodcrank.excite.com~crank~crank~RaiseError=1'
5744 Apache::DBI already connected to
'prodcrank.excite.com~crank~crank~RaiseErr
or=1'
5744 Pinging 'prodcrank.excite.com~crank~crank~RaiseError=1'
5744 Apache::DBI already connected to
'prodcrank.excite.com~crank~crank~RaiseErr
or=1'
5744 Pinging 'prodcrank.excite.com~crank~crank~RaiseError=1'
5744 Apache::DBI already connected to
'prodcrank.excite.com~crank~crank~RaiseErr
or=1'
5744 Pinging 'prodcrank.excite.com~crank~crank~RaiseError=1'
5744 Apache::DBI already connected to
'prodcrank.excite.com~crank~crank~RaiseErr
or=1'

John Saylor wrote:

 Hi

 ( 00.09.28 17:29 -0500 ) Philip Molter:
  Recently, one of my co-employees has been messing around with Zope
  (http://www.zope.org) and I was wondering if there's a package that
  provides similar functionality using mod_perl and Apache rather
  than its own web server.

 That would be mason
 http://www.masonhq.com/

 --
 \js

 A steak a day keeps the cows dead.




cvs commit: modperl/Apache Apache.pm

2000-09-28 Thread dougm

dougm   00/09/28 09:19:59

  Modified:.Changes
   src/modules/perl Apache.xs
   Apache   Apache.pm
  Log:
  fix bug where Apache::send_http_header was resetting r-status = 200
  
  Revision  ChangesPath
  1.533 +3 -0  modperl/Changes
  
  Index: Changes
  ===
  RCS file: /home/cvs/modperl/Changes,v
  retrieving revision 1.532
  retrieving revision 1.533
  diff -u -r1.532 -r1.533
  --- Changes   2000/09/28 15:18:58 1.532
  +++ Changes   2000/09/28 16:19:52 1.533
  @@ -10,6 +10,9 @@
   
   =item 1.24_01-dev
   
  +fix bug where Apache::send_http_header was resetting r-status = 200
  +thanks to brian d foy for the spot
  +
   make extra sure Apache::Constants::AUTOLOAD does not recurse looking
   for sub __AUTOLOAD [Jim Winstead [EMAIL PROTECTED]]
   
  
  
  
  1.112 +0 -1  modperl/src/modules/perl/Apache.xs
  
  Index: Apache.xs
  ===
  RCS file: /home/cvs/modperl/src/modules/perl/Apache.xs,v
  retrieving revision 1.111
  retrieving revision 1.112
  diff -u -r1.111 -r1.112
  --- Apache.xs 2000/09/27 23:51:33 1.111
  +++ Apache.xs 2000/09/28 16:19:56 1.112
  @@ -929,7 +929,6 @@
   r-content_type = pstrdup(r-pool, type);
   send_http_header(r);
   mod_perl_sent_header(r, 1);
  -r-status = 200; /* XXX, why??? */
   
   #ifndef PERL_OBJECT
   
  
  
  
  1.54  +2 -1  modperl/Apache/Apache.pm
  
  Index: Apache.pm
  ===
  RCS file: /home/cvs/modperl/Apache/Apache.pm,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- Apache.pm 2000/08/31 05:49:05 1.53
  +++ Apache.pm 2000/09/28 16:19:56 1.54
  @@ -180,7 +180,8 @@
else {
$not_sent = 1;
}
  - $r-send_http_header if $not_sent;
  + $r-send_http_header if
  +  $not_sent and $r-status == 200;
$r-print($headers); #send rest of buffer, without stripping newlines!!!
last;
}
  
  
  



cvs commit: modperl/lib/Apache PerlRun.pm Registry.pm

2000-09-28 Thread dougm

dougm   00/09/28 09:35:54

  Modified:.Changes
   lib/Apache PerlRun.pm Registry.pm
  Log:
  Apache::{Registry,PerlRun} will now log an error if $filename is NOT_FOUND
  
  Revision  ChangesPath
  1.534 +3 -0  modperl/Changes
  
  Index: Changes
  ===
  RCS file: /home/cvs/modperl/Changes,v
  retrieving revision 1.533
  retrieving revision 1.534
  diff -u -r1.533 -r1.534
  --- Changes   2000/09/28 16:19:52 1.533
  +++ Changes   2000/09/28 16:35:50 1.534
  @@ -10,6 +10,9 @@
   
   =item 1.24_01-dev
   
  +Apache::{Registry,PerlRun} will now log an error if $filename is NOT_FOUND
  +thanks to Martin Wood for the spot
  +
   fix bug where Apache::send_http_header was resetting r-status = 200
   thanks to brian d foy for the spot
   
  
  
  
  1.30  +1 -0  modperl/lib/Apache/PerlRun.pm
  
  Index: PerlRun.pm
  ===
  RCS file: /home/cvs/modperl/lib/Apache/PerlRun.pm,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- PerlRun.pm2000/06/01 21:07:56 1.29
  +++ PerlRun.pm2000/09/28 16:35:52 1.30
  @@ -60,6 +60,7 @@
$pr-{'mtime'} = -M _;
return wantarray ? (OK, $pr-{'mtime'}) : OK;
   }
  +$pr-log_error("$filename not found or unable to stat");
   return NOT_FOUND;
   }
   
  
  
  
  1.33  +1 -0  modperl/lib/Apache/Registry.pm
  
  Index: Registry.pm
  ===
  RCS file: /home/cvs/modperl/lib/Apache/Registry.pm,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- Registry.pm   2000/08/02 15:53:15 1.32
  +++ Registry.pm   2000/09/28 16:35:53 1.33
  @@ -165,6 +165,7 @@
   #}
return $r-status($old_status);
   } else {
  +$r-log_error("$filename not found or unable to stat");
return NOT_FOUND unless $Debug  $Debug  2;
return Apache::Debug::dump($r, NOT_FOUND);
   }