Re: Problem with Stream-oriented Output Filter

2002-11-22 Thread Esteban Fernandez Stafford
On Thu, 21 Nov 2002, Stas Bekman wrote:

 Esteban Fernandez Stafford wrote:
 
  Hello,
 
  I am currently developing a modperl filter that uses the streaming
  approach. I started off with the example in
 
  
http://perl.apache.org/docs/2.0/user/handlers/filters.html#Stream_oriented_Output_Filter
 
sub handler {
my $filter = shift;
 
my $left_over = '';
while ($filter-read(my $buffer, BUFF_LEN)) {
$buffer = $left_over . $buffer;
$left_over = '';
while ($buffer =~ /([^\r\n]*)([\r\n]*)/g) {
$left_over = $1, last unless $2;
$filter-print(scalar(reverse $1), $2);
}
}
$filter-print(scalar reverse $left_over) if length $left_over;
 
Apache::OK;
}
 
  This seems to work OK when the file is small (smaller than 8192). When
  the file is larger, then there is a line that gets cut. This is
  because the handler gets called more than once for big requests. Is
  there a nice way to overcome this problem?  I was thinking using
  filter context to store variable $left_over, but then I dont know how
  to detect the real end of the stream.

 The problem is that I've written a patch that makes the $filter-print()
   outside the while() loop work, but it was never committed. So the doc
 is out of sync with the core code. For now please apply this patch:
 http://marc.theaimsgroup.com/?l=apache-modperl-devm=102828686110352w=2

 I'll see that it gets into the core asap.


Thanks Stas,

the patch you sent me solved some of my trouble. The bad news is that I
still have problems when I filter large files. I have written an example
to expose this behaviour. It consists of modified versions of the beloved
SendAlphaNum.pm and FilterReverse1.pm.



package MyApache::SendAlphaNum;

use strict;
use warnings;

use Apache::RequestRec ();
use Apache::RequestIO ();

use Apache::Const -compile = qw(OK);

sub handler {
my $r = shift;

$r-content_type('text/plain');

foreach(1..300)
{
   $r-print(1..9, 0, 'a'..'z', \n);
}
Apache::OK;
}
1;



package MyApache::FilterReverse1;

use strict;
use warnings;

use base qw(Apache::Filter);

use Apache::Const -compile = qw(OK);

use constant BUFF_LEN = 1024;

my $count = 0;

   sub handler
   {
  my $filter = shift;
  $filter-print(\nI'm Starting: $count bytes so far...\n);
  my $left_over = '';
  while ($filter-read(my $buffer, BUFF_LEN)) {
  $count+=length($buffer);
  $buffer = $left_over . $buffer;
  $left_over = '';
  while ($buffer =~ /([^\r\n]*)([\r\n]*)/g) {
  $left_over = $1, last unless $2;
  $filter-print(scalar(reverse $1), $2);
  }
  }
  $filter-print(scalar reverse $left_over) if length $left_over;

  Apache::OK;
   }
1;



PerlModule MyApache::FilterReverse1
PerlModule MyApache::SendAlphaNum
Location /reverse1
   SetHandler modperl
   PerlResponseHandler  MyApache::SendAlphaNum
   PerlOutputFilterHandler  MyApache::FilterReverse1
/Location



As an output I get the following:

$ wget -q -O - http://fangorn:3000/reverse1

I'm Starting: 0 bytes so far...
zyxwvutsrqponmlkjihgfedcba0987654321
zyxwvutsrqponmlkjihgfedcba0987654321
# A lot of these...
zyxwvutsrqponmlkjihgfedcba0987654321
zyxwvutsrqponmlkjihgfedcba0987654321
edcba0987654321
I'm Starting: 8192 bytes so far...
zyxwvutsrqponmlkjihgf
zyxwvutsrqponmlkjihgfedcba0987654321
zyxwvutsrqponmlkjihgfedcba0987654321
# ... and some more...
zyxwvutsrqponmlkjihgfedcba0987654321
zyxwvutsrqponmlkjihgfedcba0987654321


As you can see the filter is called twice and therefore there is one line
that gets broken in two. I could always store $left_over in the context
of the filter and prepend it to what I read when the filter starts again.
But the problem I find is that I have no way to know when the real eos
is reached in order to flush $left_over to the output. I thought there may
be some sort of $filter-eos() call or something.

   E s  t  eb  a n!


:wq






Re: libperl.so: undefined symbol: PL_dowarn

2002-11-22 Thread Dennis
I added the following debian packages: libperl-dev libperl5.6
and recompiled it and the problem was gone.

Dennis,

- Original Message -
From: Stas Bekman [EMAIL PROTECTED]
To: Dennis [EMAIL PROTECTED]; Modperl [EMAIL PROTECTED]
Sent: Thursday, November 21, 2002 5:58 PM
Subject: Re: libperl.so: undefined symbol: PL_dowarn


 Dennis wrote:
  Hi,
 
  I have compiled mod_perl en installed it without any errors but wen i
try to
  start Apache witch mod_perl then i get the following error:
 
  Starting Apache 1.3.27:
  Syntax error on line 274 of /opt/apache-1.3.27/conf/httpd.conf:
  Cannot load /opt/apache/libexec/libperl.so into server:
  /opt/apache/libexec/libperl.so: undefined symbol: PL_dowarn
  /opt/apache/bin/apachectl startssl: httpd could not be started

 As gozer suggest next to me, you might have a stray header file from an
 older perl, which happened to be picked by the build. Any chance you
 have a few installations of perl? Trying install from scratch?


 --


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







How sub handler was called.

2002-11-22 Thread Ruslan U. Zakirov
 Hello, all!
May I understand in my handler sub how it was called?
Was it called by Apache process in stacked handlers chain or
it was called by some other module with call MyMod::handler($r)?
Could i do it without adding some special parametrs?
   Beforehead thanks, Ruslan.




RE: How Can I Install ModPerl on My ISP-based Website???

2002-11-22 Thread David Simcik
Thanks for the link...

So basically, according to the link listed below, there IS NO good way to
install modperl for just a local user account (I can't work some .htaccess
magic,etc.?)? I guess that would make sense -- seems like modperl is tightly
bound with the apache installation (one of dem dere apache modules I take
it). The memory/resource issues mentioned on that page facing ISPs seem a
bit justified as well. Sigh.

David

-Original Message-
From: Stas Bekman [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 21, 2002 11:30 AM
To: David Simcik
Cc: Modperl
Subject: Re: How Can I Install ModPerl on My ISP-based Website???


David Simcik wrote:
 I would LOVE to use mod_perl on my personal website -- I have the
diskspace
 to do so, but the question remains as to whether or not I have the rights.

The rights to do what?

 Can anyone point me to a guide for this? I've poked around the mod_perl
site
 and didn't find anything too specific.

My guess would be:
http://perl.apache.org/docs/general/multiuser/multiuser.html


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




Re: mod_Perl script and SSI need advice

2002-11-22 Thread Coexec
 C Here is an example of what I mean:
 C Here is a basic form built with cgi.pm.
 C Name the script test
 
 C print header;
 C if (param(foo)) {
 C print start_html,
 C You Entered: ,em(param(foo)),
 C }
 
 C else {
 C print start_html,
 C start_form(-action=/perl/test),
 C Enter something : ,textfield(foo),
 C submit,
 C end_form,
 C }
 C print end_html;
 
 C Works with no errors under CGI and
 Apache::Registry
 C Then I would add the above script as an include
 in the
 C following page (demo.shtml):
 
 C html
 C head
 C titleTest SSI Page/title
 C /head
 C body
 C pThis is a test page/pbr
 C !--#include virtual=/perl/test --
 C /body
 C /html
 
 C So the when I access demo.shtml, I see the text
 from
 C the HTML page and also the form from the included
 C scipt.
 
 C When I fill out the form and hit submit, the
 returned
 C data gets printed to the screen:
 
 C You Entered plus whatever you entered in the
 form.
 
 C What I would like to do is fill out the form,
 submit
 C it, and end up back to the shtml page with the
 result
 C of the script (rather than the form) included in
 the
 C shtml.
 
 C I understand why this is happening, I am not
 asking
 C why, all I am asking is what is the preferred
 method
 C of accomplishing this.
 C Thanks
 Form action have to be not perl script, but your
 *.shtml file.
 And in your include you must send QUERY_STRING to
 perl script.
 I don't remember exactly, but ther were problems
 with POST data,
 because it I've stoped using SSI.

Thanks for the reply, but what would you use rather
than SSI ?  I am not committed to SSI, it is just what
I know at this moment.

Thanks
 


__
Do you Yahoo!?
Yahoo! Mail Plus – Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



Session managing using PerlTransHandler

2002-11-22 Thread dima
How I Can redirect to page http://foo.bar/ses1/index.html from  PerlTransHandler 
Module?






Re: Session managing using PerlTransHandler

2002-11-22 Thread Enrico Sorcinelli
On Fri, 22 Nov 2002 19:09:25 +0200
[EMAIL PROTECTED] wrote:

 How I Can redirect to page http://foo.bar/ses1/index.html from  PerlTransHandler 
Module?

Hi,
the description of your problem is very... short.
The chapter 5 of 'eagle' book explain how to put and strip session ID
on the left to the left of the URI.

Moreover, the Apache::SessionManager module does things transparently for you.
It works in PerlTransHandler phase.
(http://www.cpan.org/modules/by-module/Apache/Apache-SessionManager-0.04.tar.gz)

Bye

- Enrico
 




RE: Obfusacating the source

2002-11-22 Thread Michael Robinton
I am in the process of releasing these two modules which together provide
perl source obfuscation. They are not uniquely Apache oriented though I've
never used them for anything else, thus the designation in Crypt. They
have been used in production for over 2 years with little in the way of
updates so they could be termed stable. The name has been changed so
that it fits into the CPAN hierarchy a little better.

Crypt-CapnMidNite-1.00.tar.gz
Crypt-License-2.00.tar.gz

They may be found at:

http://www.bizsystems.net/downloads/other

README from Crypt::License

Crypt::License

This module set provides tools to effectively obfuscate perl source
code and allow it to be decoded and executed based on host server, user,
expiration date and other parameters. Further, decoding and execution can
be set for a system wide key as well as a unique user key.

In addition, there are a set of utilities that provide email notification
of License expiration and indirect use of the encrypted modules by other
standard modules that may reside on the system. i.e. sub-process calls by
Apache-AuthCookie while not in user space.

Tools and Makefile.PL additions are included to allow the creation of
encrypted distribution binaries with commands

make crypt
make cryptdist

Basic operation:

Encryption uses a modified RC4 algorithim to convert the text perl file
into
a binary consisting of bits -- this is a non-text file. When perl
attempts
to load the module if first encounters use Crypt::License; at the
beginning of the file which in turn decrypts the stream of bits and
delivers it directly to the perl interpreter.

Details in the POD's

Michael




libperl.so: undefined symbol: PL_dowarn

2002-11-22 Thread Dennis Kruyt



Hi,

I have compiled mod_perl en installed it without 
any errors but wen i try to start Apache witch mod_perl then i get the following 
error:

Starting Apache 1.3.27:Syntax error on line 274 
of /opt/apache-1.3.27/conf/httpd.conf:Cannot load 
/opt/apache/libexec/libperl.so into server: /opt/apache/libexec/libperl.so: 
undefined symbol: PL_dowarn/opt/apache/bin/apachectl startssl: httpd could 
not be started
I use Apache 1.3.27 from source on a Debian 3 box, 
with the standard perl (5.6.1-7) that came with debian.

Here is the output from perl Makefile.PL 
:


packages:/opt/pkgs/src/mod_perl-1.27# perl 
Makefile.PL USE_APXS=1 WITH_APXS=/opt/apache/bin/apxs EVERYTHING=1Will 
configure via APXS 
(apxs=/opt/zx/apache/bin/apxs)PerlDispatchHandler.enabledPerlChildInitHandlerenabledPerlChildExitHandlerenabledPerlPostReadRequestHandler..enabledPerlTransHandlerenabledPerlHeaderParserHandler.enabledPerlAccessHandler...enabledPerlAuthenHandler...enabledPerlAuthzHandlerenabledPerlTypeHandler.enabledPerlFixupHandlerenabledPerlHandler.enabledPerlLogHandler..enabledPerlInitHandler.enabledPerlCleanupHandler..enabledPerlRestartHandler..enabledPerlStackedHandlers.enabledPerlMethodHandlers..enabledPerlDirectiveHandlers...enabledPerlTableApienabledPerlLogApi..enabledPerlUriApi..enabledPerlUtilApi.enabledPerlFileApi.enabledPerlConnectionApi...enabledPerlServerApi...enabledPerlSectionsenabledPerlSSI.enabledWill 
run tests as User: 'nobody' Group: 'root'Configuring mod_perl for building 
via APXS+ Creating a local mod_perl source tree+ Setting up 
mod_perl build environment (Makefile)+ id: mod_perl/1.27+ 
id: Perl/v5.6.1 (linux) [perl]Note (probably harmless): No library found for 
-lperlNow please type 'make' to build libperl.soChecking CGI.pm 
VERSION..okChecking for LWP::UserAgent..okChecking for 
HTML::HeadParserokChecking if your kit is complete...Looks 
goodWriting Makefile for ApacheWriting Makefile for 
Apache::ConnectionWriting Makefile for Apache::ConstantsWriting Makefile 
for Apache::FileWriting Makefile for Apache::LeakWriting Makefile for 
Apache::LogWriting Makefile for Apache::ModuleConfigWriting Makefile for 
Apache::PerlRunXSWriting Makefile for Apache::ServerWriting Makefile for 
Apache::SymbolWriting Makefile for Apache::TableWriting Makefile for 
Apache::URIWriting Makefile for Apache::UtilWriting Makefile for 
mod_perlpackages:/opt/pkgs/src/mod_perl-1.27#
What is the problem that i get this error 
libperl.so: undefined symbol: PL_dowarn?

Dennis,


Problem using variable with @PerlSetVar

2002-11-22 Thread Christopher Grau
Hi,

I have a fairly simple problem, but haven't had much luck finding the
solution on Google or the mailing list archives.  Basically, I have this
code in httpd.conf:

Perl
print Enter some value you don't want written down: ;
my $value = STDIN;
chomp $value;

print value = '$value'\n;

# The code works if I do this...
# $value = Foobar;

push @PerlSetVar, [Foo = $value];
/Perl

The value in $value prints to stdout, but the variable Foo doesn't get
set to $value.  However, if I were to set $value to something
explicitly, as in the comment above, the code works fine.

Based on that, I'm guessing the problem lies with reading from STDIN. 
What am I missing here?

Thanks.

-chris