is it mod or just perl?

2003-09-25 Thread perl
how do i know i'm using mod_perl versus just perl?

thanks,
-rkl


Using mysql

2003-09-25 Thread perl
Is this the correct database package, DBI, to use with mod_perl 2?

Also is there a connection caching?

thanks,
-rkl


Re: AW: Using mysql

2003-09-26 Thread perl
I haven't looked at Apache::DBI but will the following code for DBI work
for the Apache::DBI?

use DBI;
$dbh = DBI->connect('dbi:mysql:mydb','foo', 'hoo');
$sql = "SELECT * FROM mytab";
$sth = $dbh->prepare($sql);
$sth->execute || die "Could not execute SQL statement: $!\n";

thanks,
-rkl

> I would  use Apache::DBI.
>
> Denis
>
>
>
>
> Lust auf mehr - http://maedls.at
>
> "THINK THE WEB WAY."
> ---
>   NCM - NET COMMUNICATION MANAGEMENT GmbH
> ---[  Denis Banovic - CTO
>   mailto:[EMAIL PROTECTED]
> ---[  Mühlstrasse 4a
>   AT - 5023 Salzburg
>   Tel. 0662 / 644 688
> ---[  Fax: 0662 / 644 688 - 88
>   http://www.ncm.at
> ---
>
>
> -Ursprüngliche Nachricht-
> Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Gesendet: Freitag, 26. September 2003 08:19
> An: [EMAIL PROTECTED]
> Betreff: Using mysql
>
>
> Is this the correct database package, DBI, to use with mod_perl 2?
>
> Also is there a connection caching?
>
> thanks,
> -rkl
>



Can't locate module.pm file

2003-09-29 Thread perl
I have a problem calling a module in my mod_perl dir using apache on
redhat 9. I have a mystuff.pm in the same directory as the calling perl
program. I got it working running on the command line but in apache
mod_perl, it can't find the module.

Questions:
 - Where should the mystuff.pm be located in?
 - The only place i know about mod_perl configuration file is:
/etc/httpd/conf.d/perl.conf. This contains the Alias and Directory
directive.

Error message:
Can't locate mystuff.pm in @INC (@INC contains:
/usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl
/usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 .)

Any help would be great.
By the way, I just getting started with perl.
-rkl


To quotes or not quotes parameter

2003-09-29 Thread perl
what is the proper way to pass a parameter for something like
$cgi-param(username)?

as far as i know it, this works for me:

$cgi-param(username);
$cgi->param("username");
$cgi->param('username');

thanks,
-rkl


Perl Class destory

2003-09-30 Thread perl
under mod_perl, does the module being called in the web that create
classes get cleaned up w/o calling destroy explicitly? That is, if I
create a DBI handler wrapper class, closes the db connection, finish the
code but never call the destroy on explicitly. Or for any Class object?

I'm using DBI not Apache::DBI.

thanks,
-rkl


invoking sub/methods shortcut

2003-10-01 Thread perl
Can I do something like this?
from
 $sth = getVUser($dbh, $u, $d);
 return $sth->rows();
to
 return (getVUser($dbh,$u,$d))->rows();

a move from java->perl ;)

thanks,
-rkl



Simple mod_perl Session and Persistent Script

2003-10-04 Thread perl
I have redhat 9 with mod_perl-1.99_07-5.

I'm just beginning into mod_perl.

Without loading any other library than the one loaded with redhat, Is
there a session variable and how can I hold a persistence object? I'm
looking for a simple example:

#!/usr/bin/perl

use strict;
use warnings;

#I guess I would need the type of declaration my, our, ...

$counter  #persistent object or global or what

$sess #get the session var

print "session: " . $sess . " counter: " . $counter ."\n";

thanks,
rkl


Re: Simple mod_perl Session and Persistent Script

2003-10-04 Thread perl
> [EMAIL PROTECTED] wrote:
>
>> I have redhat 9 with mod_perl-1.99_07-5.
>
> That's more than a year out of date, and many bugs have been fixed since
> then, as you can see here:
> http://perl.apache.org/dist/mod_perl-2.0-current/Changes
>
> If you plan to do anything much with it, you should upgrade to the most
> recent release (or switch to apache 1.x and mod_perl 1.x if you need a
> stable platform).
>
>> Without loading any other library than the one loaded with redhat, Is
>> there a session variable and how can I hold a persistence object?
>
> No, there is no concept of a session built into mod_perl.  That's
> because mod_perl is an API for building apache modules in Perl, and
> doesn't make assumptions about how you want your application to work.
> There are easy-to-use session options available on CPAN.  I'd suggest
> looking at CGI::Session or Apache::Session (both work with mod_perl) or
> a more complete development system like Apache::ASP (also on CPAN).
> Also, have a look here for more development frameworks that run on
> mod_perl:
> http://perl.apache.org/products/app-server.html
>
> - Perrin
>
>



Re: Simple mod_perl Session and Persistent Script

2003-10-04 Thread perl
Lets say I find the latest mod_perl rpm.

- Is there a mod_perl rpm for redhat?

- If yes, is the redhat rpm different than other rpm?

- I don't know anything about configuring mod_perl;so, is the
/etc/httpd/conf.d/perl.conf the only configurable I need to worry about on
upgrading?

- Do I just un rpm the previous version and add the new
  or do I just add the latest rpm?

thanks
-rkl

> [EMAIL PROTECTED] wrote:
>
>> I have redhat 9 with mod_perl-1.99_07-5.
>
> That's more than a year out of date, and many bugs have been fixed since
> then, as you can see here:
> http://perl.apache.org/dist/mod_perl-2.0-current/Changes
>
> If you plan to do anything much with it, you should upgrade to the most
> recent release (or switch to apache 1.x and mod_perl 1.x if you need a
> stable platform).
>
>> Without loading any other library than the one loaded with redhat, Is
>> there a session variable and how can I hold a persistence object?
>
> No, there is no concept of a session built into mod_perl.  That's
> because mod_perl is an API for building apache modules in Perl, and
> doesn't make assumptions about how you want your application to work.
> There are easy-to-use session options available on CPAN.  I'd suggest
> looking at CGI::Session or Apache::Session (both work with mod_perl) or
> a more complete development system like Apache::ASP (also on CPAN).
> Also, have a look here for more development frameworks that run on
> mod_perl:
> http://perl.apache.org/products/app-server.html
>
> - Perrin
>
>



Installing/Updgrade mod_perl on Redhat 9

2003-10-05 Thread perl
I want to upgrade the mod_perl to the latest mod_perl2

from mod_perl-1.99_07-5
to   mod_perl-199_10 (same as mod_perl-2.0-current?)

My system as canned installation from redhat:
 -redhat 9
 -httpd-2.0.40-21.5 (apache)
 -mod_perl-1.99_07-5
 -php-4.2.2-17.2

I don't know too much about rpm and I can't find one that is later than
what is already installed. So, I will download the mod_perl source, rpm -e
mod_perl, and try to install with instructions as below INSTALL. Here are
my questions:

 -Is removing the existig mod_perl with rpm remove affect php?

 -My redhat installed does have the the following:
  /usr/sbin/apxs
  /usr/lib/httpd/modules/mod_perl.so

 -Do I need the source or just the apxs?

 -Giving my canned redhat installation should my setting be
MP_APXS=/usr/sbin/apxs?

 -anything else or that's all?

thanks,
rkl


mod_perl INSTALL file
-
Simple install:

% perl Makefile.PL MP_APXS=/usr/local/apache2/bin/apxs
% make && make test
% make install

If Apache was built but not installed yet or if apxs is not available
and Apache was installed under a single tree (e.g.,
/usr/local/apache2), you should use the MP_AP_PREFIX option, which
points that the Apache tree:

% perl Makefile.PL MP_AP_PREFIX=/usr/local/apache2

See docs/user/install/install.pod for details.

Simple config:

LoadModule perl_module modules/mod_perl.so

If the MP_INST_APACHE2=1 option was given to Makefile.PL, you'll want
to configure:

PerlModule Apache2

For compat with the 1.x version, you'll want to configure:

PerlModule Apache::compat

See docs/user/config/config.pod for details.




File Security of the pm files?

2003-10-17 Thread perl
Can people on the web accessing the modperl see the content of the pm files?

thanks
rkl


-
eMail solutions by 
http://www.swanmail.com


What session avail for mod_perl

2003-10-18 Thread perl
Can someone point the way to using session with mod_perl and apache 2?

thanks,


-
eMail solutions by 
http://www.swanmail.com


Where is the source for APache::Session

2003-10-20 Thread perl
I'm looking for the download of Apache::Session.
There is a lot of docs on it but where is the download?

thanks



-
eMail solutions by 
http://www.swanmail.com


Apache::Session vs CGI:Session?

2003-10-20 Thread perl
Can someone comment on some advantages/disadvantages?

Does opening a new browser causes a new session in either of the two?

thanks


-
eMail solutions by 
http://www.swanmail.com


Re: Apache::Session vs CGI:Session?

2003-10-20 Thread perl
> ... If you
> actually start another copy of IE, that does NOT have the same
> non-persistant cookies, and its a different session.

Is this behavior the same for both Apache::Session and CGI::Session?

-thanks

> On Mon, 20 Oct 2003 [EMAIL PROTECTED] wrote:
>
>> Can someone comment on some advantages/disadvantages?
>>
>> Does opening a new browser causes a new session in either of the two?
>
> well, in IE, cookes are relevant to processes, not to windows.  That is,
> you can have one process with multiple windows (file->new->window) that
> all have the same non-persistant cookies, hence, sessions.  If you
> actually start another copy of IE, that does NOT have the same
> non-persistant cookies, and its a different session.
>
> In either case, as long as the two 'windows' share the cookie on which the
> session state is based, they will be in the same session.  :)
>
> Skylos
>
> - [EMAIL PROTECTED]
> - The best part about the internet is nobody knows you're a dog.
>   (Peter Stiener, The New Yorker, July 5, 1993)
> - Dogs like... TRUCKS!  (Nissan commercial, 1996)
> - PGP key: http://dogpawz.com/skylos/mykey.asc
>



-
eMail solutions by 
http://www.swanmail.com


Re: Apache::Session vs CGI:Session?

2003-10-20 Thread perl
Well, I think I understand what you are saying but if I can clarify my
understanding.

My thought is that openining multiple browser (new process) will be a new
and separate session. Is this correct?

thanks

> On Mon, 20 Oct 2003 [EMAIL PROTECTED] wrote:
>
>> > ... If you
>> > actually start another copy of IE, that does NOT have the same
>> > non-persistant cookies, and its a different session.
>>
>> Is this behavior the same for both Apache::Session and CGI::Session?
>
> May I quote myself:
>
>> > In either case, as long as the two 'windows' share the cookie on which
>> the
>> > session state is based, they will be in the same session.  :)
>
> Perhaps I need to clarify.
>
> Without some sort of repeating token, the server cannot correlate one page
> request with another page request.  There's only a loose correlation
> outside of the token.  Why?  Because many people can use the same IP, and
> the same session can (and does) use multiple separate server connections.
>
> Hence, in order to correlate any sequence of requests into a session, it
> has to identify the user somehow!
>
> This is done by having the browser, in some manner send a token that the
> server can use to identify that user uniquely.
>
> I think the most precise answer that can be given is that when this token
> is shared by both browsers/windows, and ONLY then, will they will both be
> in the same session.
>
> Otherwise, there is no correlation, they are not in the same session.
>
> this is true regardless of what sessioning mechanism, program, library, or
> utility you are using.
>
> Does that answer the question?
>
> Maybe you're really asking for the behavior of your particular browser
> that you're using.
>
> I do believe that both the libraries you inquired about utilize a normal,
> non-persistant cookie for session tracking.
>
> As to what the browsers do with it, depends on the browser.
>
> Skylos
>
>> -thanks
>>
>> > On Mon, 20 Oct 2003 [EMAIL PROTECTED] wrote:
>> >
>> >> Can someone comment on some advantages/disadvantages?
>> >>
>> >> Does opening a new browser causes a new session in either of the two?
>> >
>> > well, in IE, cookes are relevant to processes, not to windows.  That
>> is,
>> > you can have one process with multiple windows (file->new->window)
>> that
>> > all have the same non-persistant cookies, hence, sessions.  If you
>> > actually start another copy of IE, that does NOT have the same
>> > non-persistant cookies, and its a different session.
>> >
>> > In either case, as long as the two 'windows' share the cookie on which
>> the
>> > session state is based, they will be in the same session.  :)
>> >
>> > Skylos
>> >
>> > - [EMAIL PROTECTED]
>> > - The best part about the internet is nobody knows you're a dog.
>> >   (Peter Stiener, The New Yorker, July 5, 1993)
>> > - Dogs like... TRUCKS!  (Nissan commercial, 1996)
>> > - PGP key: http://dogpawz.com/skylos/mykey.asc
>> >
>>
>>
>>
>> -
>> eMail solutions by
>> http://www.swanmail.com
>>
>>
>
> - [EMAIL PROTECTED]
> - The best part about the internet is nobody knows you're a dog.
>   (Peter Stiener, The New Yorker, July 5, 1993)
> - Dogs like... TRUCKS!  (Nissan commercial, 1996)
> - PGP key: http://dogpawz.com/skylos/mykey.asc
>



-
eMail solutions by 
http://www.swanmail.com


Getting new id with every calls with Apache::Session

2003-10-20 Thread perl
I'm getting a new id with every refresh click; so, how am I suppose to
know it is the same session? Here's my code:

#!/usr/bin/perl
use Apache::Session::File;
use strict;
use warnings;

my %session;
my $sessId;

#I'm suppose to put the session id at the undef
#but how am i suppose to #know what it is the next time around?
#tie %session, 'Apache::Session::File', undef,
# { Directory => '/tmp', LockDirectory =>'/tmp' };

tie %session, 'Apache::Session::File';
$sessId = $session{_session_id};
print "Content-type: text/html\n\n";
print "id: " . $sessId . "\n";

...

What am I doing wrong?

thanks



-
eMail solutions by 
http://www.swanmail.com


Re: Getting new id with every calls with Apache::Session

2003-10-21 Thread perl
I made two calls to ties for a test and the server comsume alot of CPU and
never return. So I don't know what is going on.

...
print "Content-type: text/html\n\n";
tie %session, 'Apache::Session::File', undef;
$sessId = $session{_session_id};
print "id: " . $sessId . "\n";

#the prog get hung when I added this line
tie %session, 'Apache::Session::File', $sessId;
$sessId = $session{_session_id};
print "id: " . $sessId . "\n";
...

In any case, are you saying that I have to pass the sessionId to the
client as a cookie as in the doc? If so, isn;t there a package that
already wraps this up for me?

thanks


> Hello.
> Have you read `perldoc Apache::Session`? There is two examples.
>
> [EMAIL PROTECTED] wrote:
>
>>I'm getting a new id with every refresh click; so, how am I suppose to
>>know it is the same session? Here's my code:
>>
>>#!/usr/bin/perl
>>use Apache::Session::File;
>>use strict;
>>use warnings;
>>
>>my %session;
>>my $sessId;
>>
>>#I'm suppose to put the session id at the undef
>>#but how am i suppose to #know what it is the next time around?
>>#tie %session, 'Apache::Session::File', undef,
>># { Directory => '/tmp', LockDirectory =>'/tmp' };
>>
>>tie %session, 'Apache::Session::File';
>>
> What about third argument??? It have to be session_id if you wnat old
> one or undef if you want new.
> So you have to store session_id somewhere on the client side!
>
>>$sessId = $session{_session_id};
>>print "Content-type: text/html\n\n";
>>print "id: " . $sessId . "\n";
>>
>>...
>>
>>What am I doing wrong?
>>
>>thanks
>>
>>
>>
>
>
>
>



-
eMail solutions by 
http://www.swanmail.com


booking should be captured only on the last page

2007-09-21 Thread Perl

I have two different pages having different form. All the forms are having
the same Action(input.htm). I need to modify  the code such that that the
details can be recorded in the database only after parsing the second page
.That means for the first page it should go to the loop (Declined)and for
the second page reverse.

 unless ( ($r->method eq "POST") && ($r->uri =~ /$bookingURL/)) 
  {
$log->info("$moduleName: skipping ". $r->method ." request to ", $r->uri
);
$log->info("$moduleName: Declining...");

return Apache2::Const::DECLINED;
  }



Page 1.html
Form
Id  NameMethod  Action
member  member  postinput.htm


Page 2.html
Form
Id  NameMethod  Action
bookerConfirm   bookerConfirm   postinput.htm

Thanks.
-- 
View this message in context: 
http://www.nabble.com/booking-should-be-captured-only-on-the-last-page-tf4493025.html#a12814096
Sent from the mod_perl - General mailing list archive at Nabble.com.



rewrite urls to modperl handler

2008-11-02 Thread perl
Hi all,

I am new to mod_perl and am having a difficult time with rewrites.
Either I am doing it the most wrong way, or it's so easy that I'm over
looking it. I have searched and found nothing that seems to relate to
what I want.

I am working on a perl based wiki, to help me learn more about how perl
works. I am looking for a way to create friendly URLs that get passed to a
mod_perl handler, without having the handler location name in the url.


For instance currently I have:
http://example.com/ex_perl_h/docName

and I want:
http://example.com/docName



>From my apache config:

PerlModule ExamplePackage::WC

    SetHandler perl-script
PerlResponseHandler ExamplePackage::WC





I have mod rewrite setup to redirect request that don't an existing
file or directory to the perl handler.


RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/(.*) /ex_perl_h [L]


but this doesn't work. 



I think what I am looking for is a mod_perl based front controler that
would handle ALL site request for URLs that don't point to a real file
or directory.

So for http://example.com/docName docName would be passed somehow to the
mod_perl script ExamplePackage::WC , similar to
http:://example.com/wc.pl?arg=docName , but done in the mod_per style.

Thanks.

Uk1ah Smith





memory usage

2004-05-10 Thread perl mod


Hi,

On my test server running Red Hat Linux 7.1 Linux version 2.4.2-2

shared memory is 18.71 MB


On my production server Red Hat Linux 7.3 Linux version 2.4.20-20.7

shared memory is 4.32 MB

use GTop;
my $gtop = GTop->new;
my $share = $gtop->proc_mem($$)->share;

I've also noticed the same difference in top on both machines.

Any ideas what could cause the huge difference?

both machines are

Apache/1.3.27 (Unix) PHP/4.3.4 DAV/1.0.3 mod_perl/1.29 configured

Scott

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html



libapreq2-2.06-dev apreq_xs_postperl.h

2006-01-17 Thread Ken Perl
 perl Makefile.PL --with-apache2-apxs=/usr/local/apache2/bin/apxs is succes.
but make failed,
cc -c  -I/root/.cpan/build/libapreq2-2.06-dev/glue/perl/xs
-I/root/.cpan/build/libapreq2-2.06-dev/include
-I/root/.cpan/build/libapreq2-2.06-dev/glue/perl/xsbuilder
-I/usr/include/apache2  -I/usr/include/apache2  -D_REENTRANT
-D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing
-I/usr/lib/perl5/5.8.3/i586-linux-thread-multi/CORE -DMOD_PERL
-DMP_COMPAT_1X -DLINUX=2 -D_XOPEN_SOURCE=500 -D_BSD_SOURCE
-D_SVID_SOURCE -O2 -march=i586 -mcpu=i686 -fmessage-length=0 -Wall
-Wall -pipe   -DVERSION=\"2.06-dev\" -DXS_VERSION=\"2.06-dev\" -fPIC
"-I/usr/lib/perl5/5.8.3/i586-linux-thread-multi/CORE"   Apache2.c
In file included from Apache2.xs:39:
/root/.cpan/build/libapreq2-2.06-dev/glue/perl/xsbuilder/apreq_xs_postperl.h:21:34:
modperl_perl_unembed.h: No such file or directory
/root/.cpan/build/libapreq2-2.06-dev/glue/perl/xsbuilder/apreq_xs_postperl.h:24:33:
modperl_common_util.h: No such file or directory
In file included from Apache2.xs:45:
/root/.cpan/build/libapreq2-2.06-dev/glue/perl/xsbuilder/APR/Request/Apache2/APR__Request__Apache2.h:1:22:
mod_perl.h: No such file or directory
Apache2.c: In function `XS_APR__Request__Apache2_handle':
Apache2.c:65: warning: implicit declaration of function
`modperl_xs_sv2request_rec'
Apache2.c:65: warning: initialization makes pointer from integer without a cast
make[6]: *** [Apache2.o] Error 1

where these .h could be found?

--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

hardware prerequisite

2006-02-02 Thread Ken Perl
My machine which cpu is celeron 266Mhz is running Debian 3.1, and
apche2 modperl2 are configured for running the content manager program
WebGUI which needs modperl2.
Now my issue is the performance is very bad and very slow even I click
edit a link.
The question is what is hardware prereuisite for modperl2 and apache2 ?

--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

Re: hardware prerequisite

2006-02-02 Thread Ken Perl
I could run WebGUI with apache very well before, but apache2 is very
slow, so I doubt some bugs in apache2 or modperl2, but I can't finger
this out.

On 2/2/06, Mark Galbreath <[EMAIL PROTECTED]> wrote:
> I wasn't aware you could run any modern software on a CPU that slow.  Use
> that machine for a doorstop, dude, and upgrade to something manufactured in
> the last 3 years.
>
> mark
>
> >>> Ken Perl <[EMAIL PROTECTED]> 02-Feb-06 04:15 AM >>>
>
> My machine which cpu is celeron 266Mhz is running Debian 3.1, and
> apche2 modperl2 are configured for running the content manager program
> WebGUI which needs modperl2.
> Now my issue is the performance is very bad and very slow even I click
> edit a link.
> The question is what is hardware prereuisite for modperl2 and apache2 ?
>
> --
> perl -e 'print
> unpack(u,"62V5N\"FME;G\!E ")'
>


--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

debug modperl program

2006-02-04 Thread Ken Perl
hi,
Debuging a perl program at command line is using -d option, but this
can't be used in a modperl program, any doc or examples on this topic
about how to debug a modperl program?

--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

MP2 dir_config

2006-02-05 Thread Ken Perl
sub handler {
my $r = shift;
my $s = Apache2::ServerUtil->server;

$s->dir_config('WRoot');
$r->dir_config('WConfig');
}

which module api doc that I could find description about the two
dir_config? I want to know more info about them.

--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

reload or restart httpd

2006-02-06 Thread Ken Perl
When code is updated during developing period, httpd progress must be
reload or restart so that to see the change. If is it possible to see
the change without reload httpd?

--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

Re: reload or restart httpd

2006-02-06 Thread Ken Perl
Yes, I am using Apache2, the doc is very useful.
in httpd.conf file, I use PerlInitHandler example.pm's handler() as
starting point, when I update the code in handler(), I didn't see the
updates, so I asked previous question.
After I read the head of the doc, I make sense that I need to modify
the global %INC after server is started.
I am going to do like this
sub handler {
my $r = shift;
my $s = Apache2::ServerUtil->server;
my $WRoot = $s->dir_config('WRoot');
use lib "$FindBin::Bin/$WRoot";
}

Am I correct?

On 2/6/06, Sean Davis <[EMAIL PROTECTED]> wrote:
>
> On 2/6/06 7:10 AM, "Ken Perl" <[EMAIL PROTECTED]> wrote:
>
> > When code is updated during developing period, httpd progress must be
> > reload or restart so that to see the change. If is it possible to see
> > the change without reload httpd?
>
>
> You didn't say which version of mod_perl you are using, but try looking
> here:
>
> <http://search.cpan.org/~pgollucci/mod_perl-2.0.2/docs/api/Apache2/Reload.po
> d>
>
> Sean
>
>
>


--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

interactive debuging modperl2 using Apache::DB

2006-02-06 Thread Ken Perl
Hi,
I configured Apache::DB in my modperl2 and got a notice message in
apache2 startup error.log,
[notice] Apache::DB initialized in child 1123

I think I have setuped it successfully.
And I also see the debugger welcome message,
Loading DB routines from perl5db.pl version 1.28
Editor support available.

Enter h or `h h' for help, or `man perldebug' for more help.

But I don't know to interactive with modperl to debug my program, I
can only see  DB<1>  prompt symbol in the log file.

--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

timestamp of Apache::DB

2006-02-06 Thread Ken Perl
when Apache::DB is initialized it will write a line of log into
error.log, but without a timestamp,
[notice] Apache::DB initialized in child 1957
May I add one?

--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

[MP2] set breakpoint

2006-02-07 Thread Ken Perl
hi,
I'd like to set a breakpoint at the first line in the module's handler,
sub handler {
my $r = shift;   <-- here
 ...  ...
   $r->set_handlers(PerlResponseHandler => \&contentHandler);
}

So, I tried PerFixupHandler, PerlHandler  and PerlInitHander
respectively in below Location directive, but all didn't stop at the
point I wanted, instead, It always stopped at  the line of
'&contentHandler',

PerlInitHandler +Apache::DB
    

what I did wrong?

--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

Re: [MP2] set breakpoint

2006-02-07 Thread Ken Perl
No IDE for me too, I am using vi on a Debian terminal too.
warn is easy and good, I also want a more common and more powerful
interactive debugger tool, now I am trying Apache::DB and have this
trouble.

On 2/7/06, John ORourke <[EMAIL PROTECTED]> wrote:
> What sort of IDE, debugger, and platform are you using?
>
> Personally for debugging handlers I find it easier to just stick a line
> like: warn "got here, r=$r\n"
>
> then just tail -f the error_log.  Proper old school.  Then again I
> develop with vi on an 80x24 terminal, am I missing out on something?
>
> John
>
> Ken Perl wrote:
>
> >hi,
> >I'd like to set a breakpoint at the first line in the module's handler,
> >sub handler {
> >my $r = shift;   <-- here
> > ...  ...
> >   $r->set_handlers(PerlResponseHandler => \&contentHandler);
> >}
> >
> >So, I tried PerFixupHandler, PerlHandler  and PerlInitHander
> >respectively in below Location directive, but all didn't stop at the
> >point I wanted, instead, It always stopped at  the line of
> >'&contentHandler',
> >
> >    PerlInitHandler +Apache::DB
> >
> >
> >what I did wrong?
> >
> >--
> >perl -e 'print unpack(u,"62V5N\"FME;G\!E >")'
> >
> >
> >
>
>


--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

Re: timestamp of Apache::DB

2006-02-07 Thread Ken Perl
Cool, I guess you mean add these lines into the conf file,


use CGI::Carp;


Thanks, It works.

On 2/7/06, John Doe <[EMAIL PROTECTED]> wrote:
> Ken Perl am Dienstag, 7. Februar 2006 07.44:
> > when Apache::DB is initialized it will write a line of log into
> > error.log, but without a timestamp,
> > [notice] Apache::DB initialized in child 1957
> > May I add one?
> >
> > --
> > perl -e 'print unpack(u,"62V5N\"FME;G\!E > ")'
>
> yes, by putting the line
>
> use CGI::Carp
>
> into the httpd.conf file :-)
>
> hth,
> joe
>


--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

Re: reload or restart httpd

2006-02-07 Thread Ken Perl
tried adding the two lines to the conf file, didn't work.

On 2/6/06, Sean Davis <[EMAIL PROTECTED]> wrote:
>
>
>
> On 2/6/06 9:06 AM, "Ken Perl" <[EMAIL PROTECTED]> wrote:
>
> > Yes, I am using Apache2, the doc is very useful.
> > in httpd.conf file, I use PerlInitHandler example.pm's handler() as
> > starting point, when I update the code in handler(), I didn't see the
> > updates, so I asked previous question.
> > After I read the head of the doc, I make sense that I need to modify
> > the global %INC after server is started.
> > I am going to do like this
> > sub handler {
> > my $r = shift;
> > my $s = Apache2::ServerUtil->server;
> > my $WRoot = $s->dir_config('WRoot');
> > use lib "$FindBin::Bin/$WRoot";
> > }
>
> Unless I am misunderstanding what you are trying to do, I think you just
> need to add these two lines to your httpd.conf to have any changed modules
> reloaded:
>
>  PerlModule Apache2::Reload
>  PerlInitHandler Apache2::Reload
>
> I don't think you have to do anything special with %INC.
>
> Sean
>
>
>


--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

Re: reload or restart httpd

2006-02-07 Thread Ken Perl
I also turned the debug on, but didn't see any debug message in the
error.log, anyone knows why?

 PerlSetVar ReloadDebug On


On 2/7/06, Ken Perl <[EMAIL PROTECTED]> wrote:
> tried adding the two lines to the conf file, didn't work.
>
> On 2/6/06, Sean Davis <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > On 2/6/06 9:06 AM, "Ken Perl" <[EMAIL PROTECTED]> wrote:
> >
> > > Yes, I am using Apache2, the doc is very useful.
> > > in httpd.conf file, I use PerlInitHandler example.pm's handler() as
> > > starting point, when I update the code in handler(), I didn't see the
> > > updates, so I asked previous question.
> > > After I read the head of the doc, I make sense that I need to modify
> > > the global %INC after server is started.
> > > I am going to do like this
> > > sub handler {
> > > my $r = shift;
> > > my $s = Apache2::ServerUtil->server;
> > > my $WRoot = $s->dir_config('WRoot');
> > > use lib "$FindBin::Bin/$WRoot";
> > > }
> >
> > Unless I am misunderstanding what you are trying to do, I think you just
> > need to add these two lines to your httpd.conf to have any changed modules
> > reloaded:
> >
> >  PerlModule Apache2::Reload
> >  PerlInitHandler Apache2::Reload
> >
> > I don't think you have to do anything special with %INC.
> >
> > Sean
> >
> >
> >
>
>
> --
> perl -e 'print unpack(u,"62V5N\"FME;G\!E ")'
>


--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

Re: [MP2] set breakpoint

2006-02-07 Thread Ken Perl
You catched my problem, I didn't load debugger before this handler, thanks.
After I changed the order in the httpd config file, my problem is
solved,  It stopped at the point I wanted,

 my $r = shift;

Thanks again.

On 2/8/06, Perrin Harkins <[EMAIL PROTECTED]> wrote:
> On Tue, 2006-02-07 at 16:10 +0800, Ken Perl wrote:
> > hi,
> > I'd like to set a breakpoint at the first line in the module's handler,
> > sub handler {
> > my $r = shift;   <-- here
> >  ...  ...
> >$r->set_handlers(PerlResponseHandler => \&contentHandler);
> > }
> >
> > So, I tried PerFixupHandler, PerlHandler  and PerlInitHander
> > respectively in below Location directive, but all didn't stop at the
> > point I wanted, instead, It always stopped at  the line of
> > '&contentHandler',
> > 
> > PerlInitHandler +Apache::DB
> > 
> >
> > what I did wrong?
>
> Did you load this handler before you loaded the debugger?  You should
> call Apache::DB->init() explicitly before loading any of the code you
> want to debug, or it won't get debugging symbols.  See the documentation
> for Apache::DB.
>
> - Perrin
>
>


--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

module bug?

2006-02-07 Thread Ken Perl
I see a info in the error.log when I access the uri / and works fine,
[Wed Feb 08 13:22:35 2006] [info] [client 10.0.0.1] Module bug? 
Request filename is missing for URI /

Is the info reported by modperl2? anything wrong?

--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

Re: module bug?

2006-02-08 Thread Ken Perl
Sounds reasonable.
Based on your anaIysis,  I added

   warn "reach last line of WebGUI.pm";

into the handler before the last line.

sub handler{
... ...
else {
$r->set_handlers(PerlResponseHandler => \&contentHandler);
$r->set_handlers(PerlTransHandler => sub { return Apache2::Const
::OK});
}
warn "reach last line of WebGUI.pm";
return Apache2::Const::DECLINED;
}

then I got these two lines of log message like this,
[Wed Feb  8 20:45:57 2006] -e: got last line of WebGUI.pm at
/data/WebGUI/lib/WebGUI.pm line 65.
[Wed Feb 08 20:45:57 2006] [info] [client 10.0.0.1] Module bug? 
Request filename is missing for URI /

You may notice that the "Module bug?" message written out after the
debug message I added, so I think, the info is not caused by
PerlTransHander. True?


On 2/8/06, Torsten Foertsch <[EMAIL PROTECTED]> wrote:
> On Wednesday 08 February 2006 07:13, Ken Perl wrote:
> > I see a info in the error.log when I access the uri / and works fine,
> > [Wed Feb 08 13:22:35 2006] [info] [client 10.0.0.1] Module bug?
> > Request filename is missing for URI /
> >
> > Is the info reported by modperl2? anything wrong?
>
> You have written a translation handler that doesn't set $r->filename and
> returns OK, right?
>
> The info you are seeing is generated by the core-maptostorage handler. You can
> avoid it either
>
> a) by setting $r->filename prior to maptostorage or
>
> b) by returning DECLINED from your translation handler and thus letting the
> core translation handler figure the filename out or
>
> c) by inserting a PerlMapToStorage handler that returns OK and thus skipping
> the core-maptostorage handler.
>
> Torsten
>
>
>


--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

Re: timestamp of Apache::DB

2006-02-08 Thread Ken Perl
That helps already, but need to add the statement into the 
directory and works fine!

On 2/8/06, John Doe <[EMAIL PROTECTED]> wrote:
> Perrin Harkins am Dienstag, 7. Februar 2006 18.45:
> > On Tue, 2006-02-07 at 08:56 +0100, John Doe wrote:
> > > Ken Perl am Dienstag, 7. Februar 2006 07.44:
> > > > when Apache::DB is initialized it will write a line of log into
> > > > error.log, but without a timestamp,
> > > > [notice] Apache::DB initialized in child 1957
> > > > May I add one?
> > >
> > > yes, by putting the line
> > >
> > > use CGI::Carp
> > >
> > > into the httpd.conf file :-)
> >
> > Huh?  How is that going to help?
>
> It doesn't help in this early startup phase; I misread the question. :-(
>


--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

Re: module bug?

2006-02-08 Thread Ken Perl
And I found just now, I got the info message before the root / page is returned.

On 2/8/06, Ken Perl <[EMAIL PROTECTED]> wrote:
> Sounds reasonable.
> Based on your anaIysis,  I added
>
>   warn "reach last line of WebGUI.pm";
>
> into the handler before the last line.
>
> sub handler{
>... ...
>else {
>$r->set_handlers(PerlResponseHandler => \&contentHandler);
>$r->set_handlers(PerlTransHandler => sub { return 
> Apache2::Const
> ::OK});
>}
>warn "reach last line of WebGUI.pm";
>return Apache2::Const::DECLINED;
> }
>
> then I got these two lines of log message like this,
> [Wed Feb  8 20:45:57 2006] -e: got last line of WebGUI.pm at
> /data/WebGUI/lib/WebGUI.pm line 65.
> [Wed Feb 08 20:45:57 2006] [info] [client 10.0.0.1] Module bug?
> Request filename is missing for URI /
>
> You may notice that the "Module bug?" message written out after the
> debug message I added, so I think, the info is not caused by
> PerlTransHander. True?
>
>
> On 2/8/06, Torsten Foertsch <[EMAIL PROTECTED]> wrote:
> > On Wednesday 08 February 2006 07:13, Ken Perl wrote:
> > > I see a info in the error.log when I access the uri / and works fine,
> > > [Wed Feb 08 13:22:35 2006] [info] [client 10.0.0.1] Module bug?
> > > Request filename is missing for URI /
> > >
> > > Is the info reported by modperl2? anything wrong?
> >
> > You have written a translation handler that doesn't set $r->filename and
> > returns OK, right?
> >
> > The info you are seeing is generated by the core-maptostorage handler. You 
> > can
> > avoid it either
> >
> > a) by setting $r->filename prior to maptostorage or
> >
> > b) by returning DECLINED from your translation handler and thus letting the
> > core translation handler figure the filename out or
> >
> > c) by inserting a PerlMapToStorage handler that returns OK and thus skipping
> > the core-maptostorage handler.
> >
> > Torsten
> >
> >
> >
>
>
> --
> perl -e 'print unpack(u,"62V5N\"FME;G\!E ")'
>


--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

the modperl book link is broken

2006-02-08 Thread Ken Perl
Hi,
The page 
http://perl.apache.org/docs/offsite/books.html#The_mod_perl_Developer_s_Cookbook
introduces two books, their links http://modperlbook.org/ and
http://www.modperlcookbook.org/ are both broken now, Does anyone have
these two ebooks?

--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

Re: the modperl book link is broken

2006-02-08 Thread Ken Perl
I still can't connect the site, : -(

I prefer e-book and appreciate that if anyone who have those two books
could send me the e-book copy.

On 2/8/06, Perrin Harkins <[EMAIL PROTECTED]> wrote:
> Ken Perl wrote:
> > The page 
> > http://perl.apache.org/docs/offsite/books.html#The_mod_perl_Developer_s_Cookbook
> > introduces two books, their links http://modperlbook.org/ and
> > http://www.modperlcookbook.org/ are both broken now
>
> Those links both work fine for me.  Maybe there's a network problem on
> your end.  If you network is too unreliable to read them on-line, you
> can purchase both of these books in print.
>
> - Perrin
>


--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

Apache2::SizeLimit with non-threaded MPMs

2006-02-08 Thread Ken Perl
I know Apache2:SizeLimit works ony with non-threaded MPMs, but I don't
know how to fix the issue, any comments?

[Thu Feb 09 13:46:21 2006] [error] [client 221.219.202.148] failed to
resolve handler `Apache2::SizeLimit': Apache2::SizeLimit at the moment
works only with non-threaded MPMs at /usr/share/perl/5.8/CGI/Carp.pm
line 314.\nBEGIN failed--compilation aborted at
/usr/lib/perl5/Apache2/SizeLimit.pm line 97.\nCompilation failed in
require at (eval 913) line 3.\n

--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

debugger command always return IO::Handle::DESTROY

2006-02-09 Thread Ken Perl
I am using Apache::DB as debugger to debug my modperl2 program. No
breakpoints are defined, I input many 'r' and the return is always
like below, and the home page can't be displayed in the debug mode
while turning off debug mode it home page can be rendered as normal.

  DB<1> r
void context return from IO::Handle::DESTROY
IO::Handle::DESTROY(/usr/lib/perl/5.8/IO/Handle.pm:75):
75: sub DESTROY {}
  DB<1> r
void context return from IO::Handle::DESTROY
Apache2::SizeLimit::handler(/usr/lib/perl5/Apache2/SizeLimit.pm:248):
248:my $r = shift;

Anybody knows about the problem in it?

--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

detecting server start, stop, graceful in startup.pl

2006-02-11 Thread Ken Perl
>From the Apache2::ServerUtil API doc, to do something only when server
restarts (httpd -k start or httpd -k graceful), check whether
restart_count() is bigger than 1:

  my $cnt = Apache2::ServerUtil::restart_count();
  do_something() if $cnt > 1;

However, the API doesn't work as above. I tried to add some debug code
to my startup.pl script and tried all the command options of
apache2ctl, start, stop, graceful, the $cnt is always equal 1.
I also tried to write the value $cnt to a /tmp/out file just like in
the API doc and got same result, that is
 % apache2ctl -k start
  cnt: 1
  cnt: 2

  % apache2ctl -k graceful
  cnt: 1
  cnt: 3

  % apache2ctl -k graceful
  cnt: 1
  cnt: 4

  % apache2ctl -k stop
  cnt: 1

But, I can't detecting start, stop, graceful in startup.pl coding just
like in the API doc, Could you give me some comments? thanks.

--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

Re: debugger command always return IO::Handle::DESTROY

2006-02-12 Thread Ken Perl
And I also can't quit Apache::DB by entering many 'q' commands,
  DB<5> q
IO::Handle::DESTROY(/usr/lib/perl/5.8/IO/Handle.pm:75):
75: sub DESTROY {}
  DB<5> q
IO::Handle::DESTROY(/usr/lib/perl/5.8/IO/Handle.pm:75):
75: sub DESTROY {}
  DB<5> q
IO::Handle::DESTROY(/usr/lib/perl/5.8/IO/Handle.pm:75):
75: sub DESTROY {}
  DB<5> q

the last 'q' command hang there, any comments?


On 2/9/06, Ken Perl <[EMAIL PROTECTED]> wrote:
> I am using Apache::DB as debugger to debug my modperl2 program. No
> breakpoints are defined, I input many 'r' and the return is always
> like below, and the home page can't be displayed in the debug mode
> while turning off debug mode it home page can be rendered as normal.
>
>  DB<1> r
> void context return from IO::Handle::DESTROY
> IO::Handle::DESTROY(/usr/lib/perl/5.8/IO/Handle.pm:75):
> 75: sub DESTROY {}
>  DB<1> r
> void context return from IO::Handle::DESTROY
> Apache2::SizeLimit::handler(/usr/lib/perl5/Apache2/SizeLimit.pm:248):
> 248:    my $r = shift;
>
> Anybody knows about the problem in it?
>
> --
> perl -e 'print unpack(u,"62V5N\"FME;G\!E ")'
>


--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

Re: detecting server start, stop, graceful in startup.pl

2006-02-12 Thread Ken Perl
No, I want to do something in the startup.pl script.
When apache start, I also want to say my modperl program is starting
and started, when stop, I want to say my modperl program is stopping
and stopped. When graceful, I want to say reloading and reloaded.
But I didn't find a API could help, any ideas?

On 2/12/06, Frank Wiles <[EMAIL PROTECTED]> wrote:
> On Sun, 12 Feb 2006 15:02:38 +0800
> Ken Perl <[EMAIL PROTECTED]> wrote:
>
> > >From the Apache2::ServerUtil API doc, to do something only when
> > >server
> > restarts (httpd -k start or httpd -k graceful), check whether
> > restart_count() is bigger than 1:
> >
> >   my $cnt = Apache2::ServerUtil::restart_count();
> >   do_something() if $cnt > 1;
> >
> > However, the API doesn't work as above.
> >
> > [...snip...]
> >
> > But, I can't detecting start, stop, graceful in startup.pl coding just
> > like in the API doc, Could you give me some comments? thanks.
>
>  I think you are misreading what the docs are saying.
>  Apache2::ServerUtil::restart_count() is just that a count of the
>  number of times the server was restarted.  So a start will show a
>  count of two and gracefuls would be greater than two.
>
>  The server restarts itself at least once during start up and you
>  typically do not want to do anything during that initial restart.
>
>  -
>   Frank Wiles <[EMAIL PROTECTED]>
>   http://www.wiles.org
>  -
>
>


--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

Re: detecting server start, stop, graceful in startup.pl

2006-02-12 Thread Ken Perl
I add your code to my startup.pl, but it doesn't work.

# apache2ctl -k start
Program is starting
Stopping...

#apache2ctl -k graceful


# apache2ctl -k stop


On 2/13/06, Frank Wiles <[EMAIL PROTECTED]> wrote:
> On Mon, 13 Feb 2006 09:17:57 +0800
> Ken Perl <[EMAIL PROTECTED]> wrote:
>
> > No, I want to do something in the startup.pl script.
> > When apache start, I also want to say my modperl program is starting
> > and started, when stop, I want to say my modperl program is stopping
> > and stopped. When graceful, I want to say reloading and reloaded.
> > But I didn't find a API could help, any ideas?
>
>  Hi Ken,
>
>  I haven't tested this, but it should work. In your startup.pl do
>  something like this:
>
>  my $started = 0;
>  my $cnt = Apache2::ServerUtil::restart_count();
>
>  if( !$started and $cnt == 1 ) {
>   $started = 1;
>   print "Program is starting\n";
>  }
>
>  if( $cnt > 2 ) {
>   print "Restarting";
>  }
>
>  if( $started and $cnt == 1 ) {
>   print "Stopping...";
>  }
>
>  -
>   Frank Wiles <[EMAIL PROTECTED]>
>   http://www.wiles.org
>  -
>
>


--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

Re: debugger command always return IO::Handle::DESTROY

2006-02-12 Thread Ken Perl
I tried to stop apache by issuing apache2ctl -k stop in another
terminal, the command exit without any output, but the debugger is
still hung there. I have to send signal KILL to the process.

On 2/12/06, Frank Wiles <[EMAIL PROTECTED]> wrote:
> On Sun, 12 Feb 2006 18:55:13 +0800
> Ken Perl <[EMAIL PROTECTED]> wrote:
>
> > And I also can't quit Apache::DB by entering many 'q' commands,
> >   DB<5> q
> > IO::Handle::DESTROY(/usr/lib/perl/5.8/IO/Handle.pm:75):
> > 75: sub DESTROY {}
> >   DB<5> q
> > IO::Handle::DESTROY(/usr/lib/perl/5.8/IO/Handle.pm:75):
> > 75: sub DESTROY {}
> >   DB<5> q
> > IO::Handle::DESTROY(/usr/lib/perl/5.8/IO/Handle.pm:75):
> > 75: sub DESTROY {}
> >   DB<5> q
> >
> > the last 'q' command hang there, any comments?
>
>  I believe you have to stop Apache to exit the debugger when using it.
>  If that doesn't fix it let me know.
>
>  -
>   Frank Wiles <[EMAIL PROTECTED]>
>   http://www.wiles.org
>  -
>
>


--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

Re: debugger command always return IO::Handle::DESTROY

2006-02-12 Thread Ken Perl
Normaly, ctrl +c works for a simple modperl program, I am trying to
debug a more complex modperl program.

I'd like to provide all info you need, maybe I need some guide on what's needed.

What I want to do is stepping into the modperl2 WebGUI
program(https://svn.webgui.org/svnroot/WebGUI/ and fix some bugs.

When I request the home page, I get the prompt of the debugger, then I
input command 'r' to let debugger return from the contentHandler(),
and input many other 'r' to return too, I just want to see if I can
see the home page under debugging mode, but I can't, only lots of
IO::Handle::DESTROY, and finally, hang there,
I can't input any more debugger command, kill the apache2 process is
the only thing left could be done.
And on the browser side, I see from the status bar it is still waiting
to dowload the .gif images, however, if trun the debugging mode off,
home page can be displayed smoothly.

In my httpd.conf, I enabled Apache2::Reload and Apache2::Status.

Anything I missed or anything you want to know, please let me know.

On 2/13/06, Perrin Harkins <[EMAIL PROTECTED]> wrote:
> Ken Perl wrote:
> > I tried to stop apache by issuing apache2ctl -k stop in another
> > terminal, the command exit without any output, but the debugger is
> > still hung there. I have to send signal KILL to the process.
>
> That will work, but the usual way to stop is to hit Ctrl-C in the
> debugger terminal.  The apache2ctl script probably fails because you are
> running with a single process so the PID file isn't there or isn't accurate.
>
> I haven't seen your IO::Handle issue before, but I suspect the debugger
> is just informing you about some code that ran after your return.  The
> real issue is why your home page doesn't display as you expect.  To help
> you with that, you need to give us more details about what happens and
> what was supposed to happen.
>
> - Perrin
>


--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

Re: debugger command always return IO::Handle::DESTROY

2006-02-13 Thread Ken Perl
Yes, my browser gets most of the home page back if I input lots of
'r', except some images are still waiting for downloading.
If starting server with -X only the page could be retrieved complete
successfully.


On 2/14/06, Perrin Harkins <[EMAIL PROTECTED]> wrote:
> On Mon, 2006-02-13 at 14:27 +0800, Ken Perl wrote:
> > Normaly, ctrl +c works for a simple modperl program, I am trying to
> > debug a more complex modperl program.
>
> I don't see how that would a make difference.  You're just trying to
> send a signal to the httpd process by hitting Ctrl-C.
>
> > I'd like to provide all info you need, maybe I need some guide on what's 
> > needed.
>
> Your previous message said that it didn't work, but didn't say what
> would have happened if it did work, or what it actually did.  The
> information you gave here is better.
>
> > When I request the home page, I get the prompt of the debugger
>
> That's good.
>
> > then I
> > input command 'r' to let debugger return from the contentHandler(),
> > and input many other 'r' to return too, I just want to see if I can
> > see the home page under debugging mode, but I can't
>
> Your browser never gets anything back?  Try using telnet or lwp-get to
> test it, so you can see if anything gets sent back.  You don't need to
> test the images.
>
> > only lots of
> > IO::Handle::DESTROY, and finally, hang there,
> > I can't input any more debugger command, kill the apache2 process is
> > the only thing left could be done.
> > And on the browser side, I see from the status bar it is still waiting
> > to dowload the .gif images, however, if trun the debugging mode off,
> > home page can be displayed smoothly.
>
> What happens if you run the server with -X but don't add the debugger?
> Can you get the page then?
>
> - Perrin
>
>


--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

Re: detecting server start, stop, graceful in startup.pl

2006-02-17 Thread Ken Perl
Better than before, but only 'start' works.

debian:~/WebGUI# apache2ctl -k start
[Fri Feb 17 22:34:21 2006] preload.perl: Program is starting
Loading WebGUI.conf
debian:~/WebGUI# apache2ctl -k graceful
[Fri Feb 17 22:34:55 2006] preload.perl: Program is starting
Loading WebGUI.conf
[Fri Feb 17 22:34:57 2006] -e: I am shutting down at
/root/WebGUI/sbin/preload.perl line 33.
debian:~/WebGUI# apache2ctl -k stop
[Fri Feb 17 22:35:28 2006] preload.perl: Program is starting
Loading WebGUI.conf
[Fri Feb 17 22:35:29 2006] -e: I am shutting down at
/root/WebGUI/sbin/preload.perl line 33.

On 2/17/06, Philippe M. Chiasson <[EMAIL PROTECTED]> wrote:
> Ken Perl wrote:
> > I add your code to my startup.pl, but it doesn't work.
>
> Change 'print' to warn and you should see the expected behaviour.
>
> The only exception is stop, that doesn't go thru a restart cycle, so the
> correct way to detect a shutdown is to register a server_shutdown callback
> like this :
>
> Apache2::ServerUtil::server_shutdown_cleanup_register(sub { warn "I am 
> shutting down" });
>
> > # apache2ctl -k start
> > Program is starting
> > Stopping...
> >
> > #apache2ctl -k graceful
> > 
> >
> > # apache2ctl -k stop
> > 
> >
> > On 2/13/06, Frank Wiles <[EMAIL PROTECTED]> wrote:
> >
> >>On Mon, 13 Feb 2006 09:17:57 +0800
> >>Ken Perl <[EMAIL PROTECTED]> wrote:
> >>
> >>
> >>>No, I want to do something in the startup.pl script.
> >>>When apache start, I also want to say my modperl program is starting
> >>>and started, when stop, I want to say my modperl program is stopping
> >>>and stopped. When graceful, I want to say reloading and reloaded.
> >>>But I didn't find a API could help, any ideas?
> >>
> >> Hi Ken,
> >>
> >> I haven't tested this, but it should work. In your startup.pl do
> >> something like this:
> >>
> >> my $started = 0;
> >> my $cnt = Apache2::ServerUtil::restart_count();
> >>
> >> if( !$started and $cnt == 1 ) {
> >>  $started = 1;
> >>  print "Program is starting\n";
> >> }
> >>
> >> if( $cnt > 2 ) {
> >>  print "Restarting";
> >> }
> >>
> >> if( $started and $cnt == 1 ) {
> >>  print "Stopping...";
> >> }
> >>
>
> 
> Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 
> 88C3A5A5
> http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 
> 88C3A5A5
>
>
>


--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

Re: detecting server start, stop, graceful in startup.pl

2006-02-19 Thread Ken Perl
Though it will write to the log and it is wrong as the console.

On 2/18/06, Philippe M. Chiasson <[EMAIL PROTECTED]> wrote:
> Ken Perl wrote:
> > Better than before, but only 'start' works.
> >
> > debian:~/WebGUI# apache2ctl -k start
> > [Fri Feb 17 22:34:21 2006] preload.perl: Program is starting
> > Loading WebGUI.conf
> > debian:~/WebGUI# apache2ctl -k graceful
> > [Fri Feb 17 22:34:55 2006] preload.perl: Program is starting
> > Loading WebGUI.conf
> > [Fri Feb 17 22:34:57 2006] -e: I am shutting down at
> > /root/WebGUI/sbin/preload.perl line 33.
> > debian:~/WebGUI# apache2ctl -k stop
> > [Fri Feb 17 22:35:28 2006] preload.perl: Program is starting
> > Loading WebGUI.conf
> > [Fri Feb 17 22:35:29 2006] -e: I am shutting down at
> > /root/WebGUI/sbin/preload.perl line 33.
>
> the restarts should show up too in your error_log, not on the console.
>
> --
> Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 
> 88C3A5A5
> http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 
> 88C3A5A5
>
>
>
>


--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

due core cpu

2006-02-22 Thread Ken Perl
Will a modperl2 program run faster on a cue core cpu machine than a
single cpu machine if we assume their speeds are same? In other words,
should I buy a new due core cpu machine?

--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

clusters

2006-05-09 Thread Ken Perl

Is it possible to make a modperl application to run in cluster? if
yes, how to do that? any doc?

--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

Re: clusters

2006-05-09 Thread Ken Perl

Do you mean that the pound work great with apache 2.0 and apache 1.3 both?

On 5/9/06, Harmen <[EMAIL PROTECTED]> wrote:

On Tue, May 09, 2006 at 04:47:14PM +0800, Ken Perl wrote:
> Is it possible to make a modperl application to run in cluster? if
> yes, how to do that? any doc?

Take a few mod_perl servers and put one pound (http://www.apsis.ch/poung/) 
reverse
proxy in front of them.
Works great.

--
The Moon is Waxing Gibbous (85% of Full)




--
perl -e 'print unpack(u,"62V5N\"FME;G\!E

how to use Apache::DBI

2007-07-30 Thread Ken Perl
I've configured  the Apache::DBI in httpd.conf like this,

PerlModule Apache::DBI

I didn't have  Apache::DBI->connect_on_init($data_source, $username,
$auth, \%attr) in startup.pl since we don't use startup.pl. and the
doc says to config it in httpd.conf is OK.

my question is I can not find any persistent connections for my CGI
script. any usage error here?

-- 
perl -e 'print unpack(u,"62V5N\"FME;G\!E

Re: how to use Apache::DBI

2007-07-30 Thread Ken Perl
I didn't run it under ModPerl::Registry, is there any risk to use the
module? maybe I have to run lots of testing to the existing scripts.

Could I just run use the previous connections via DBI->connect_cache
instead of the Apache::DBI in one single cgi script(but the script
will call other modules which may make new db connections with same db
password and attributes)? In my testing, I saw some different database
handlers returned instead of the same hash reference address.

On 7/30/07, Clinton Gormley <[EMAIL PROTECTED]> wrote:
> On Mon, 2007-07-30 at 18:21 +0800, Ken Perl wrote:
> > I've configured  the Apache::DBI in httpd.conf like this,
> >
> > PerlModule Apache::DBI
> >
> > I didn't have  Apache::DBI->connect_on_init($data_source, $username,
> > $auth, \%attr) in startup.pl since we don't use startup.pl. and the
> > doc says to config it in httpd.conf is OK.
> >
> > my question is I can not find any persistent connections for my CGI
> > script. any usage error here?
>
> Persistent connections will not work for straight CGI scripts, because
> CGI is not persistent.
>
> For each CGI request, a new perl interpreter is loaded, your script is
> compiled, run, and the Perl process exits.
>
> mod_perl IS persistent, as are your CGI scripts run via
> ModPerl::Registry etc.
>
> You don't need connect_on_init to work, but you do need mod_perl
>
> Clint
> >
>
>


-- 
perl -e 'print unpack(u,"62V5N\"FME;G\!E

Re: how to use Apache::DBI

2007-07-30 Thread Ken Perl
OK, got it. Is it possible to use the same db connections in one
request? if yes, could you please show me how to implement this if a
cgi script calls many times other perl modules which requests db
connections to work.

On 7/31/07, Perrin Harkins <[EMAIL PROTECTED]> wrote:
> On 7/30/07, Ken Perl <[EMAIL PROTECTED]> wrote:
> > I didn't run it under ModPerl::Registry
>
> Did you run it under some other mod_perl module, like
> ModPerl::PerlRun?  If it's a CGI script, and you aren't running it
> through something like this, then you aren't running it through
> mod_perl and you won't be able to use persistent connections.
>
> > Could I just run use the previous connections via DBI->connect_cache
> > instead of the Apache::DBI in one single cgi script
>
> Not if you aren't running it through mod_perl.  CGI scripts exit after
> each request, so they can't do persistent connections.
>
> - Perrin
>


-- 
perl -e 'print unpack(u,"62V5N\"FME;G\!E

Re: how to use Apache::DBI

2007-08-01 Thread Ken Perl
ok, I'll try connect_cached too.

On 8/1/07, Perrin Harkins <[EMAIL PROTECTED]> wrote:
> On 7/31/07, Clinton Gormley <[EMAIL PROTECTED]> wrote:
> > What you could do instead is to use DBI's connect_cached method, which
> > provides similar functionality.  I actually use this instead of
> > Apache::DBI, even when running under mod_perl.
>
> I also use connect_cached in many cases.  Just be aware of what you're
> missing out on, because Apache::DBI does some extra things to protect
> you.
>
> Here are the main differences:
> - Apache::DBI doesn't require code changes.  connect_cached() does.
> - Apache::DBI will avoid caching a connection that you open during
> server startup, so that you don't accidentally try to use the same
> connection in multiple processes (due to forking).
> - Apache::DBI issues an automatic rollback at the end of every
> request, so that if your code dies while it has a transaction going,
> that will be freed before the next request.  (This is only if you open
> your handles with AutoCommit off though.)
>
> Hmm, maybe this should be in the Apache::DBI documentation.
>
> - Perrin
>


-- 
perl -e 'print unpack(u,"62V5N\"FME;G\!E

Re: how to use Apache::DBI

2007-08-01 Thread Ken Perl
it is really good gotchas and should be included to the
ModPerl::Registry document. thanks a lot.

On 7/31/07, Clinton Gormley <[EMAIL PROTECTED]> wrote:
> On Tue, 2007-07-31 at 10:09 +0800, Ken Perl wrote:
> > I didn't run it under ModPerl::Registry, is there any risk to use the
> > module? maybe I have to run lots of testing to the existing scripts.
> >
>
>
> There is a risk to using this module, but also a significant benefit:
> speed.
>
> The risks come from:
>
>  - the fact that your script has been written to run one and then exit,
>so you may have a number of variables that aren't initialised
>properly - this can produce unexpected errors
>
>  - ModPerl::Registry wraps your script in another sub, which may produce
>unexpected closures (you would see warnings about variables not
>remaining shared in your log)
>
> So if you move to using Registry, then you will need to check your
> scripts.
>
> However, using Registry means that your script is loaded and compiled
> once, avoiding this performance hit for subsequent requests - hence it
> runs faster.
>
> Have a look at this post that I wrote about gotchas under Registry, it
> may help you migrate:
> http://www.gossamer-threads.com/lists/modperl/modperl/94203#94203
>
> Clint
>
>
>


-- 
perl -e 'print unpack(u,"62V5N\"FME;G\!E

mod_perl and CGI::Application.. Strange Behaviour

2007-10-26 Thread Perl Modulator

Hi everyone,

Recently I have ported my Apache server to mod_perl and the server is
working fine. I can say this by checking the error log and it says:

[Fri Oct 26 10:52:16 2007] [notice] SIGHUP received.  Attempting to restart
[Fri Oct 26 10:52:17 2007] [warn] module mod_php4.c is already added,
skipping
[Fri Oct 26 10:52:17 2007] [notice] Apache/1.3.33 (Darwin) PHP/4.3.9
mod_perl/1.26 configured -- resuming normal operations
[Fri Oct 26 10:52:17 2007] [notice] Accept mutex: flock (Default: flock)

And I am running this Apache on MAC. The entries for mod_perl in httpd.conf
is as follows:

Alias /perl /docroot/cgi-perl
PerlModule Apache::Registry

   SetHandler perl-script
   PerlHandlerApache::Registry
   PerlSendHeader On
   Options+ExecCGI


Problem

I am trying to create mod_perl based appln using CGI::Application and I am
just printing a message. Here is the Perl Module Test.pm, which will be
loaded.


package Test ;
use strict;
#our @ISA = qw[ CGI::Application ];
use base 'CGI::Application';

sub setup {

   my $self = shift;
   $self->run_modes( 'mode1' => 'mode1_sub' );
   $self->start_mode( 'mode1' );

}

sub mode1_sub {

   my $self = shift;
   my $req = $self->query();

   $req->content_type( 'text/html' );
   $req->send_http_header;

   return "using CGI::Application and mod_perl";
}

1;

Here is my CGI Script test.cgi:

use strict;
use lib '/docroot/cgi-perl/test';
use Test;

my $webapp = Test->new();
$webapp->run();

Both the CGI script and the module are in same directory. I am getting
following error message in my error log and I am just could not understand,
where I am doing wrong. 

[Fri Oct 26 11:05:39 2007] [error] Can't locate object method "new" via
package "Test" at /docroot/cgi-perl/test/test.cgi line 5.\n

Please guide me in this regard and it will be great help for my application.

Thanks.
-- 
View this message in context: 
http://www.nabble.com/mod_perl-and-CGI%3A%3AApplication..-Strange-Behaviour-tf4697759.html#a13428708
Sent from the mod_perl - General mailing list archive at Nabble.com.



[Newbie] MP2.0: PerlSendHeader versus PerlOptions (and Apache::Registry grrr...)

2008-04-24 Thread Perl Junkie
Okay, it's been a while, despite the name, that I've done any serious 
playing around with MP.  Since 1.0.  I've just installed and gotten 
running MP 2.0 on Apache 2.2.8...  I'm doing the "ground up" and trying 
to get registry scripts working first and I've run into the following, 
right-off-the-bat head scratchers:


(1) The documentation says that:


 |ParseHeaders|
 
<http://perl.apache.org/docs/2.0/user/config/config.html#toc_C_ParseHeaders_>

   Scan output for HTTP headers, same functionality as mod_perl 1.0's
   |PerlSendHeader|, but more robust. This option is usually needs to
   be enabled for registry scripts which send the HTTP header with:

 print "Content-type: text/html\n\n";


Doesn't work for me...  When I run registry scripts using in httpd.conf:

   Alias /mp "/var/www/mp"
   PerlModule ModPerl::Registry
   
  SetHandler perl-script
  Options +ExecCGI
  PerlHandler ModPerl::Registry
  *PerlOptions ParseHeaders*
  Order allow,deny
  Allow from all
   

The content-type is never sent and the response delivers text/plain -- I 
see the HTML in plain text.  When I go back to the MP 1.0 way in 
httpd.conf, it works:


   Alias /mp "/var/www/mp"
   PerlModule ModPerl::Registry
   
  SetHandler perl-script
  Options +ExecCGI
  PerlHandler ModPerl::Registry
  *PerlSendHeader On*
  Order allow,deny
  Allow from all
   

What's the story here?

ALSO...

(2) It took me a while to figure out that Apache::Registry has become 
ModPerl::Registry.  I saw nothing and still see nothing in the MP 2.0 
docs about this, what I would consider MAJOR change, and as I said, it 
took me a while to realize what happened here...  What gives?  What was 
wrong with Apache::Registry???


I had Stas' book, which I know was written during MP 1.0, so between 
these two things,  it leaves me wondering how much more of the book is 
now practically worthless??  I'm fast beginning to feel MP 2.0 has now 
become the domain of "old MP 1.0 hands" and if you didn't follow MP from 
1.0 days -- which I did not in a consistent way, then you are out of 
luck...  Where can I get the latest MP 2.0 beef?  I think the MP 2.0 
documentation at perl.apache.org leaves a lot to be desired...


Anyways, if someone can explain the ParseHeaders versus PerlSendHeader 
and the ModPerl::Registry versus Apache::Registry changes, that would 
help at least get registry scripts running in the optimal way.  If the 
MP 2.0 docs say that ParseHeaders is better, than I'd like to be able to 
use it, but right now, it doesn't seem to work as the docs say. :-(


-PJ



Re: [Newbie] MP2.0: PerlSendHeader versus PerlOptions (and Apache::Registry grrr...)

2008-04-24 Thread Perl Junkie

Perrin Harkins wrote:

On Fri, Apr 25, 2008 at 12:18 AM, Perl Junkie <[EMAIL PROTECTED]> wrote:
  

PerlOptions ParseHeaders



I think that should be +ParseHeaders.  See
http://perl.apache.org/docs/2.0/user/porting/compat.html#C_PerlSendHeader_
  
I did finally see that in another section.  I *have* to bother thousands 
of people with a question before I find it in the docs, even if I've 
already looked.  I have no idea why it works out that way. :-(  :-)
  

 (2) It took me a while to figure out that Apache::Registry has become
ModPerl::Registry.  I saw nothing and still see nothing in the MP 2.0 docs
about this, what I would consider MAJOR change, and as I said, it took me a
while to realize what happened here...  What gives?  What was wrong with
Apache::Registry???



This is answered in the migration guide for converting from 1.x to 2.x:
http://perl.apache.org/docs/2.0/user/porting/compat.html#C_Apache__Registry___C_Apache__PerlRun__and_Friends
  

Nice.
  

 I had Stas' book, which I know was written during MP 1.0, so between these
two things,  it leaves me wondering how much more of the book is now
practically worthless??



The information about system architecture, performance tuning,
debugging techniques, and general perl issues is all applicable, but
of course the API for mod_perl 2 is different and there's no way
around that.  There is a new book by Stas and Jim Brandt about
mod_perl 2:
http://modperl2book.org/
  

I'll look into it.  Thanks.  Sounds invaluable.
  

I think the MP 2.0 documentation at
perl.apache.org leaves a lot to be desired...



Sorry to hear you don't like the documentation.  If you have some
ideas for how to improve it, send them over.
  
H, seems like maybe my ability to spot the right information IN the 
docs is what is leaving a lot to be desired right now. :-)  Maybe I need 
to just settle down and read some more first before assuming it's "not 
there."  Thanks!


The only suggestion so far would be to make that one section I quoted on 
the ParseHeaders option a little more clearer than it is albeit it's 
documented elsewhere, as you pointed out above.


What nice people here at MP... :-)  Alright, I'll leave y'all alone and 
do some more reading first.  The migration guide seems like a good place 
to start to convert all my past (way, way back in the past) remembrances 
into the new MP2 reality.


-PJ



Re: decline and fall of modperl?

2009-03-23 Thread Perl Junkie

Byrne Reese wrote:
The problem is that there are no very many big sites that use perl 
either.
I knew that Amazon used Perl, than tried to use Java, than... I don't 
know what they use now.
Google uses Python, Yahoo uses PHP, Microsoft probably uses DotNet 
and Sun probably uses Java.


I will add:

* LiveJournal
* TypePad
* Vox
* Popular MT sites like:
  - Huffington Post
  - Gothamist
  - Talking Points Memo
  - many, many, many more of course


As far as I know, these sites also use Perl or mod_perl:

o Internet Movie Database (Amazon)
o TicketMaster (last I checked, but that was a couple of years ago and 
they were recently sold or bought or something)

o CitySearch.com
o ArtToday.com
o PBS Online

I also know that a very large international cosmetics company uses 
mod_perl quite extensively.  I've done some work for them and I don't 
know if or how they would care for their name being mentioned here, so I 
won't, but...  If you want "large" -- they define "large."


-
I wouldn't "count" a company that uses a Perl "product" or CMS or some 
sort (such as MT) as a "perl site" in the strict sense of the word.  
Some of the techies at places like Huffington Post may be aware of the 
underlying technology, but I doubt very much that "Perl" itself drove 
the decision as much as the great work that Ben and Mena Trott did at 
SixApart.com in creating such a product.


-
And I have to chime in and say I've seen plenty of ugly, ridiculous code 
written in every language imaginable (everyone's precious "Java" and JEE 
very much included.)  It's not a product of the language as much as the 
language bearer.  Sorry.  That's always been the case.  Margin for error 
on a tight mountain road doesn't automatically a bad driver make -- only 
the one who will not heed the type of road and car he's in in the 
situation.  Anyone can zoom through an intersection full of traffic on a 
wide-open, flat country road as well.  The road being the intent and 
direction and the car being Perl (and pretty cotton-pickin' good one, I 
might add), I don't see the correlation here.  Again, this is clever 
smoke and mirrors by consultants with a different agenda and product to 
sell.  The craft of programming and development are only slightly 
impacted by these kinds of things.


-pj



Re: decline and fall of modperl?

2009-03-23 Thread Perl Junkie

Alexandr Ciornii wrote:

Hi.

It possible to encrypt perl sources with same safety as with PHP -
with possibility of source decryption. But Perl developers are in
general more advanced than PHP developers so they know how to decrypt
it, in contrast to PHP developers that do not know that encrypted PHP
sources can easily be decrypted. There are also some bytecode
compilers for Perl (alpha stage).

2009/3/23 Octavian Râsnita :

  

PHP, C#, Java are much more prefered, because the programs created with them
can hide the source code much better, while this is not possible with Perl.
This is a big reason why the software companies that create custom programs
for their clients prefer to use those languages and not perl. Not because
perl is bad.



  
Not to keep the PHP thing going, but I would tend to de-classify about 
30% of the people who call themselves "PHP developers."  There is a VERY 
high propensity among many in this community to go out and "borrow code" 
and "retrofit it."  I'm not saying Perl developers don't do this, but I 
don't believe there are very many heavily invested in the Perl community 
who have this bent -- many are devoted to the craft of true, honest to 
goodness OO development.


I also left out a very important and I would say very well known Perl 
*powerhouse* in corporate America:


WhitePages.com

Some of the best of the best work there.  You can't even get a sniff 
from them (eg. interview) without being in the upper crust of Perl 
development.  No Perl "wanna-bes" allowed there.  All very solid OO 
development only.


-pj



Re: test

2018-05-22 Thread Practical Perl
welcome.

On Tue, May 22, 2018 at 5:34 AM, Jie Gao  wrote:

> test
>
>


CPAN will shutdown

2018-05-22 Thread Practical Perl
 *search.cpan.org <http://search.cpan.org> is shutting down*
For details read Perl NOC
<https://log.perl.org/2018/05/goodbye-search-dot-cpan-dot-org.html>. After
June 25th this page will redirect to MetaCPAN.org <http://search.mcpan.org/>


So does as well as Perl?


Output filters, data encoding

2019-11-13 Thread tomcat/perl

Hi.
I'm writing a new PerlOutputFilter, stream version.
I have written several working ones before, so I know the general scheme.
But in this latest filter, I have a problem with the data encoding, which I did not 
encounter previously.
I did not find an answer in the on-line mod_perl documentation, which seems silent about 
any encoding of the data that one might read in a filter.

(I also tried the WWW, without any more success).

To read the response data coming from upstream, I use the standard $f->read(), 
as in

while (my $sz = $f->read(my $buffer, BUFF_LEN)) {
..

and then I need to pass this data to another module for processing 
(Template::Toolkit).
To make a long story short, Template::Toolkit misinterprets the data I'm sending to it, 
because this data /is/ actually UTF-8, but apparently not marked so internally by the 
$f->read(). So TT2 re-encodes it, leading to double UTF-8 encoding.


My question is : can I - and how -, set the filehandle that corresponds to the $f->read(), 
to a UTF-8 layer ?

I have tried

line 155: binmode($f,'encoding:(UTF-8)');

and that triggers an error :
 Not a GLOB reference at (my filter) line 155.\n
)

Or do I need to read the data 'as is', and separately do an

 $decoded_buffer = decode('UTF-8', $buffer);

?

Note 1 : I can of course do the above decode(), but it seems more elegant to just insert 
the I/O layer.


Note 2 : I know that the pre-filter data is UTF-8 (or at least I choose to believe that it 
is), because I check $f->r->content_type(), which returns "text/html;charset=UTF-8".
Also, the filter otherwise works as expected, and I get the expected output in the 
browser, except that e.g. "München" becomes "München".


Thanks in advance for any tips
André


Re: Output filters, data encoding

2019-11-13 Thread tomcat/perl

On 13.11.2019 19:17, p...@cpan.org wrote:

On Wednesday 13 November 2019 19:12:10 André Warnier (tomcat/perl) wrote:

My question is : can I - and how -, set the filehandle that corresponds to
the $f->read(), to a UTF-8 layer ?
I have tried

line 155: binmode($f,'encoding:(UTF-8)');


Hi André! When specifying PerlIO layer for file handle, you need to
write colon character before layer name. So correct binmode call is:

   binmode($f, ':encoding(UTF-8)');


and that triggers an error :
  Not a GLOB reference at (my filter) line 155.\n
)


Thanks. Ooops, that was a typo (also in my filter, not only in the list 
message).
But correcting it, does not change the GLOB error message.



Re: Output filters, data encoding

2019-11-13 Thread tomcat/perl

On 13.11.2019 19:53, p...@cpan.org wrote:

On Wednesday 13 November 2019 19:52:25 André Warnier (tomcat/perl) wrote:

On 13.11.2019 19:17, p...@cpan.org wrote:

On Wednesday 13 November 2019 19:12:10 André Warnier (tomcat/perl) wrote:

My question is : can I - and how -, set the filehandle that corresponds to
the $f->read(), to a UTF-8 layer ?
I have tried

line 155: binmode($f,'encoding:(UTF-8)');


Hi André! When specifying PerlIO layer for file handle, you need to
write colon character before layer name. So correct binmode call is:

binmode($f, ':encoding(UTF-8)');


and that triggers an error :
   Not a GLOB reference at (my filter) line 155.\n
)


Thanks. Ooops, that was a typo (also in my filter, not only in the list 
message).
But correcting it, does not change the GLOB error message.


Ok. What is the $f? It is object or what kind of scalar?


It is the Apache2::Filter object.
See : http://perl.apache.org/docs/2.0/api/Apache2/Filter.html
Configured in httpd as :   PerlOutputFilterHandler MyFilter
See also :  http://perl.apache.org/docs/2.0/user/handlers/filters.html

My (hopeful) thinking was that considering the
$f->read()
the Apache2::Filter object may also be a FileHandle, hence the attempt at
binmode($f,..)
But that seems to be incorrect.
(And I don't see any (documented) method of Apache2::Filter that would return the 
underlying FileHandle either)




Re: Output filters, data encoding

2019-11-13 Thread tomcat/perl

On 13.11.2019 19:37, Damyan Ivanov wrote:

-=| André Warnier (tomcat/perl), 13.11.2019 19:12:10 +0100 |=-

while (my $sz = $f->read(my $buffer, BUFF_LEN)) {
..

and then I need to pass this data to another module for processing 
(Template::Toolkit).
To make a long story short, Template::Toolkit misinterprets the data I'm
sending to it, because this data /is/ actually UTF-8, but apparently not
marked so internally by the $f->read(). So TT2 re-encodes it, leading to
double UTF-8 encoding.

My question is : can I - and how -, set the filehandle that corresponds to
the $f->read(), to a UTF-8 layer ?
I have tried

line 155: binmode($f,'encoding:(UTF-8)');

and that triggers an error :
  Not a GLOB reference at (my filter) line 155.\n
)

Or do I need to read the data 'as is', and separately do an

  $decoded_buffer = decode('UTF-8', $buffer);


There's a middle ground - partial decoding. See Encode(1)/FB_QUIET:

If CHECK is set to "Encode::FB_QUIET", encoding and decoding
immediately return the portion of the data that has been processed so
far when an error occurs. The data argument is overwritten with
everything after that point; that is, the unprocessed portion of the
data.  This is handy when you have to call "decode" repeatedly in the
case where your source data may contain partial multi-byte character
sequences, (that is, you are reading with a fixed-width buffer). Here's
some sample code to do exactly that:

my($buffer, $string) = ("", "");
while (read($fh, $buffer, 256, length($buffer))) {
$string .= decode($encoding, $buffer, Encode::FB_QUIET);
# $buffer now contains the unprocessed partial character
}

Looks exactly like your case.


Thanks for the response and the tip.

My idea of adding a UTF-8 layer to the filehandle through which Apache2::Filter reads the 
incoming data was probably wrong anyway : it cannot do that, because it gets this data 
originally in chunks, as "bucket brigades" from Apache httpd.  And there is no guarantee 
that such a bucket brigade would always end in "complete" UTF-8 character sequences.

At the very least, this would probably complicate the code underlying 
$f->read() quite a bit.
It is clearer to handle that in the filter itself.

The Encode::FB_QUIET flag above, with the incremental buffer read, is really 
smart.
Unfortunately, the Apache2::Filter read() method does not allow as many arguments, and all 
one has is something like this :


my $accumulated_content = "";
while (my $sz = $f->read(my $buffer, BUFF_LEN)) {
$accumulated_content .= $buffer;
}

Luckily, in this case, I have to accumulate the complete response content anyway, before I 
can decide to call Template::Toolkit on it or not. So I can do a single decode() on 
$accumulated_content. Not the most efficient memory-wise, but good enough in this case.





Re: Output filters, data encoding

2019-11-14 Thread tomcat/perl

On 14.11.2019 01:09, Hua, Yong wrote:

Hi

on 2019/11/14 2:12, André Warnier (tomcat/perl) wrote:

I'm writing a new PerlOutputFilter, stream version.


Can you give a more general introduction for what is "stream version"?

Thank you.

You shoud read the pages which I referred to previously, they explain this better than I 
could do :

1) http://perl.apache.org/docs/2.0/user/handlers/filters.html
2) http://perl.apache.org/docs/2.0/api/Apache2/Filter.html

See in particular here :
http://perl.apache.org/docs/2.0/user/handlers/filters.html#Two_Methods_for_Manipulating_Data




Re: decrypt the posted content

2019-11-20 Thread tomcat/perl

On 20.11.2019 10:26, Tillman Peng wrote:

hello

My client post the data body which is encrypted with public-key.
the private key is deployed in web server,powered by mp2.
How can I correctly decrypt the data with private key from within modperl 
handler?



Hi.
Do you have a separate command-line program on the server which can decrypt 
that content ?
If yes : if you do not find an appropriate perl module to do this decryption, your 
mod_perl handler can always execute that external program using the system() function.

(See : https://perldoc.perl.org/5.30.0/functions/system.html)

General idea :
- get the encrypted content from the request
- write this encrypted content to a file in some appropriate work directory on 
the server
- compose the external command that reads the encrypted data, and writes the decrypted 
content to a file

- execute that command with system()
- check for errors
- read the decrypted results file
- clean up

If you end up using this method, and you are doing this from within an Apache/mod_perl 
handler, you have to be extra careful about many aspects, such as :
- catching any errors which may happen in the external program, and interpret them 
correctly in the calling module.

- logging the errors properly, so that if "it doesn't work", you can find out 
why
- taking into account that your webserver may receive several simultaneous requests for 
such content, and thus that there may be several instances of that external command 
running at the same time (think about the temporary files that you may need, and make sure 
that each instance uses its own unique files)

- cleaning up after succesfully running the command
- maybe selectively "not cleaning up" if there were any problems, so that you can inspect 
what happened
- check permissions (the external program will run under the same user-id as the 
webserver, so whatever it writes, must be in a directory writeable by the webserver)
- verify that the external command cannot be running for too long, causing the client to 
time-out waiting for a response, and closing the connection to the webserver
- make extra sure that the client cannot, through some malicious use of the parameters 
that it sends to the server (e.g. filenames), result in damage on your server

(e.g. system("program > /etc/passwd"))
- etc.

If you prefer to use a perl module to do the decryption, you will have to look at what is 
available on CPAN.  Most modules that relate to encryption/decryption are in the "Crypt" 
namespace, such as : https://metacpan.org/search?q=crypt%3A%3A






installing mod_perl on Windows 10

2020-01-08 Thread tomcat/perl

Hi.
After (very) long and faithful service, I had to replace my old Windows XP development 
laptop by a new one, which of course came with Windows 10.

And I am having problems installing Apache 2.4 + Strawberry perl + mod_perl.

Apache 2.4 is from ApacheLounge 
(https://www.apachelounge.com/download/VS16/binaries/httpd-2.4.41-win64-VS16.zip) and 
installed under C:\apache24

Strawberry perl is (see below)
and both seem to work separately.

Next I try to install mod_perl2 from CPAN and I get the following, see below.
Any clue as to what I'm doing wrong ?

(Note : prior to this, I tried to install mod_perl manually from the downloaded file 
"mod_perl-2.0.10-strawberryperl-5.26.1.1-64bit.zip", but this seems to result in modules 
having wrong line endings and crashing the compiler).


C:\Users\aw>cpan mod_perl2
Loading internal null logger. Install Log::Log4perl for logging messages
CPAN: CPAN::SQLite loaded ok (v0.211)
CPAN: LWP::UserAgent loaded ok (v6.33)
CPAN: Time::HiRes loaded ok (v1.9758)
Fetching with LWP:
http://cpan.strawberryperl.com/authors/01mailrc.txt.gz
CPAN: YAML::XS loaded ok (v0.69)
Fetching with LWP:
http://cpan.strawberryperl.com/modules/02packages.details.txt.gz
Fetching with LWP:
http://cpan.strawberryperl.com/modules/03modlist.data.gz
Creating database file ...
Done!
Running install for module 'mod_perl2'
Fetching with LWP:
http://cpan.strawberryperl.com/authors/id/S/SH/SHAY/mod_perl-2.0.11.tar.gz
CPAN: Digest::SHA loaded ok (v6.01)
Fetching with LWP:
http://cpan.strawberryperl.com/authors/id/S/SH/SHAY/CHECKSUMS
CPAN: Compress::Zlib loaded ok (v2.081)
Checksum for 
C:\STRAWB~1\cpan\sources\authors\id\S\SH\SHAY\mod_perl-2.0.11.tar.gz ok
CPAN: Archive::Tar loaded ok (v2.26)
CPAN: CPAN::Meta::Requirements loaded ok (v2.140)
CPAN: Parse::CPAN::Meta loaded ok (v2.150010)
CPAN: CPAN::Meta loaded ok (v2.150010)
Configuring S/SH/SHAY/mod_perl-2.0.11.tar.gz with Makefile.PL
no conflicting prior mod_perl version found - good.

Next we need to know where the 'apxs' script is located. This script
provides a lot of information about the Apache installation, and makes
it easier to find things on your system. Normally it's located in the
same directory as the 'httpd' executable.

If you don't yet have Apache installed you can build Apache against
the Apache source code, but you won't be able to run the test suite (a
very important step). Therefore you may want to install Apache before
proceeding.


Please provide a full path to 'apxs' executable
(press Enter if you don't have it installed):


Configure mod_perl with C:\Apache24? [y] y
Configuring Apache/2.4.41 mod_perl/2.0.11 Perl/v5.26.2
Use of uninitialized value $httpd_version in string lt at 
lib/ModPerl/MapUtil.pm line 51.
Checking if your kit is complete...
Looks good
Warning (mostly harmless): No library found for 
C:/STRAWB~1/cpan/build/mod_perl-2.0.11-0/src/modules/perl/mod_perl.lib
ERROR from evaluation of 
C:\STRAWB~1\cpan\build\mod_perl-2.0.11-0\Apache-Reload/Makefile.PL: Use of uninitialized 
value $v in substitution (s///) at Apache-Test/lib/Apache/TestRun.pm line 1100.

Warning: No success on command[C:\Strawberry\perl\bin\perl.exe Makefile.PL]
  SHAY/mod_perl-2.0.11.tar.gz
  C:\Strawberry\perl\bin\perl.exe Makefile.PL -- NOT OK
Stopping: 'install' failed for 'mod_perl2'.

C:\Users\aw>

Perl :
C:\Users\aw>perl -V
Summary of my perl5 (revision 5 version 26 subversion 2) configuration:

  Platform:
osname=MSWin32
osvers=10.0.16299.371
archname=MSWin32-x64-multi-thread
uname='Win32 strawberry-perl 5.26.2.1 #1 Sun Apr 15 13:52:49 2018 x64'
config_args='undef'
hint=recommended
useposix=true
d_sigaction=undef
useithreads=define
usemultiplicity=define
use64bitint=define
use64bitall=undef
uselongdouble=undef
usemymalloc=n
default_inc_excludes_dot=define
bincompat5005=undef
  Compiler:
cc='gcc'
ccflags =' -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -D__USE_MINGW_ANSI_STDIO 
-DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -fwrapv 
-fno-strict-aliasing -mms-bitfields'

optimize='-s -O2'
cppflags='-DWIN32'
ccversion=''
gccversion='7.1.0'
gccosandvers=''
intsize=4
longsize=4
ptrsize=8
doublesize=8
byteorder=12345678
doublekind=3
d_longlong=define
longlongsize=8
d_longdbl=define
longdblsize=16
longdblkind=3
ivtype='long long'
ivsize=8
nvtype='double'
nvsize=8
Off_t='long long'
lseeksize=8
alignbytes=8
prototype=define
  Linker and Libraries:
ld='g++'
ldflags ='-s -L"C:\STRAWB~1\perl\lib\CORE" -L"C:\STRAWB~1\c\lib"'
libpth=C:\STRAWB~1\c\lib C:\STRAWB~1\c\x86_64-w64-mingw32\lib 
C:

Re: installing mod_perl on Windows 10

2020-01-08 Thread tomcat/perl

On 08.01.2020 17:19, Edward J. Sabol wrote:

On Jan 8, 2020, at 10:17 AM, André Warnier (tomcat/perl)  
wrote:

Please provide a full path to 'apxs' executable
(press Enter if you don't have it installed):


Configure mod_perl with C:\Apache24? [y] y


It seems to me you didn’t provide the *full* path to the apxs executable. I 
would think that the full path should end with “\bin\apxs”.

Hope this helps,
Ed



In fact it never really asks. The only thing I entered, was the "cpan 
mod_perl2" command.
All the rest is just output, without any prompt.
For example here :

>> Configure mod_perl with C:\Apache24? [y] y

the "y" answer was not entered by me, it did it itself.



Re: installing mod_perl on Windows 10

2020-01-14 Thread tomcat/perl

Hi.
One more time.
I am trying to install Apache 2.4 (64-bit, ApacheLounge) + perl (Strawberry, 5.26.2, 
64-bit) + mod_perl 2 (all versions shown below in cpanm output), on a (German) Windows 10 
laptop. (*)


The work directory below is leftover from a previous command "cpanm mod_perl2".
Apache 2.4 is installed and starts up (as a service), error log :
[Wed Jan 08 14:38:40.071509 2020] [mpm_winnt:notice] [pid 15800:tid 820] AH00455: 
Apache/2.4.41 (Win64) configured -- resuming normal operations

..
(note : the c:\apache24\bin directory contains no apxs script, and according to the source 
files of mod_perl, apxs does not seem to work under MSWin anyway)


perl works

but the mod_perl install breaks, build log below.
Any clues anyone ?

log (in Windows 10 command window, run as administrator) :

C:\Users\aw\.cpanm\work\1578998136.19100\mod_perl-2.0.11>
C:\Users\aw\.cpanm\work\1578998136.19100\mod_perl-2.0.11>cpanm --interactive 
--prompt .
--> Working on .
Configuring mod_perl-2.0.11 ... no conflicting prior mod_perl version found - 
good.

Next we need to know where the 'apxs' script is located. This script
provides a lot of information about the Apache installation, and makes
it easier to find things on your system. Normally it's located in the
same directory as the 'httpd' executable.

If you don't yet have Apache installed you can build Apache against
the Apache source code, but you won't be able to run the test suite (a
very important step). Therefore you may want to install Apache before
proceeding.


Please provide a full path to 'apxs' executable
(press Enter if you don't have it installed):


Configure mod_perl with C:\Apache24? [y] y
Configuring Apache/2.4.41 mod_perl/2.0.11 Perl/v5.26.2
Checking if your kit is complete...
Looks good
Warning (mostly harmless): No library found for 
C:/Users/aw/.cpanm/work/1578998136.19100/mod_perl-2.0.11/src/modules/perl/mod_perl.lib
ERROR from evaluation of 
C:\Users\aw\.cpanm\work\1578998136.19100\mod_perl-2.0.11\Apache-Reload/Makefile.PL: Use of 
uninitialized value $v in substitution (s///) at Apache-Test/lib/Apache/TestRun.pm line 1100.

Configuring  failed.
You can s)kip, r)etry, e)xamine build log, or l)ook ? [s] l
...


(*) which may interfere with the process in unfathomable ways.
E.g. there is no directory "c:\users" visible in Windows Explorer, it is instead called 
"C:\Benutzer". But that does not seem to immediately stop the command-line process from 
changing to the work directory  C:/Users/aw/.cpanm/work/, go figure..




mod_perl, compilation issues

2020-01-14 Thread tomcat/perl

Hi.

OS : Windows 10
Apache httpd 2.4.41
perl (Strawberry) : perl 5, version 26, subversion 2 (v5.26.2) built for 
MSWin32-x64-multi-thread

mod_perl : from Steve Hay's mod_perl-2.0.10-strawberryperl-5.26.1.1-64bit.zip,
as per Apache log :
Apache/2.4.41 (Win64) mod_perl/2.0.10 Perl/v5.26.2 configured

Problem :

C:\>perl -cw D:\develop\06_SVN\AP2lib\trunk\modlib\AUTH\UMA2.pm
Can't load 'C:/Strawberry/perl/site/lib/auto/ModPerl/Const/Const.dll' for module 
ModPerl::Const: load_file:Das angegebene Modul wurde nicht gefunden at 
C:/Strawberry/perl/lib/DynaLoader.pm line 193.

  at C:/Strawberry/perl/site/lib/Apache2/Const.pm line 19.
Compilation failed in require at C:/Strawberry/perl/site/lib/Apache2/Const.pm 
line 19.
BEGIN failed--compilation aborted at 
C:/Strawberry/perl/site/lib/Apache2/Const.pm line 19.
Compilation failed in require at 
D:\develop\06_SVN\AP2lib\trunk\modlib\AUTH\UMA2.pm line 28.
BEGIN failed--compilation aborted at D:\develop\06_SVN\AP2lib\trunk\modlib\AUTH\UMA2.pm 
line 28.


Line 28 of UMA2.pm is :

use Apache2::Const -compile => qw(:common :http :methods :override :proxy :log REDIRECT 
AUTHZ_GRANTED AUTHZ_DENIED AUTHZ_DENIED_NO_USER AUTHZ_GENERAL_ERROR);


(wrapping due to email)

C:/Strawberry/perl/site/lib/Apache2/Const.pm line 19 is :

use ModPerl::Const ();

File C:\strawberry\perl\site\lib\ModPerl\Const.pm exists, but has no 
"load_file" in it.

The file C:/Strawberry/perl/site/lib/auto/ModPerl/Const/Const.dll exists.

For non-german-speakers, the above message "load_file:Das angegebene Modul wurde nicht 
gefunden" translates as "load_file:the specified module was not found".


The above module "UMA2.pm" compiles without error on a Linux server with similar httpd, 
perl and mod_perl versions.


Any clue or additional questions welcome.
Thanks


mod_perl, compilation issues, cont

2020-01-16 Thread tomcat/perl

Can anyone tell me what the error below really means ?
(and if possible, give me a clue as to what may be happening ?)

To get possibly more details, I re-ran the compile command after setting PERL_DL_DEBUG in 
the environment (just something I found in Dynaloader.pm). It does give some more detail, 
but I am still stumped..


Full config described below.
D:\develop\06_SVN\AP2lib\trunk\modlib\AUTH\UMA2.pm is my module, which compiles just fine 
on Linux servers with similar software installed (Apache, mod_perl, perl).



C:\>perl -cw D:\develop\06_SVN\AP2lib\trunk\modlib\AUTH\UMA2.pm
DynaLoader.pm loaded (C:/Strawberry/perl/site/lib C:/Strawberry/perl/vendor/lib 
C:/Strawberry/perl/lib, C:\STRAWB~1\c\lib C:\STRAWB~1\c\x86_64-w64-mingw32\lib 
C:\STRAWB~1\c\lib\gcc\x86_64-w64-mingw32\7.1.0)

DynaLoader::bootstrap for ModPerl::Const (auto/ModPerl/Const/Const.xs.dll)
dl_findfile(-LC:/Strawberry/perl/site/lib/auto/ModPerl/Const -LC:/Strawberry/perl/site/lib 
-LC:/Strawberry/perl/vendor/lib -LC:/Strawberry/perl/lib Const)

 checking in C:/Strawberry/perl/site/lib/auto/ModPerl/Const for Const.xs.dll
 checking in C:/Strawberry/perl/site/lib/auto/ModPerl/Const for Const.dll
dl_findfile found: C:/Strawberry/perl/site/lib/auto/ModPerl/Const/Const.dll
Can't load 'C:/Strawberry/perl/site/lib/auto/ModPerl/Const/Const.dll' for module 
ModPerl::Const: load_file:Das angegebene Modul wurde nicht gefunden at 
C:/Strawberry/perl/lib/DynaLoader.pm line 193.

  at C:/Strawberry/perl/site/lib/Apache2/Const.pm line 19.
Compilation failed in require at C:/Strawberry/perl/site/lib/Apache2/Const.pm 
line 19.
BEGIN failed--compilation aborted at 
C:/Strawberry/perl/site/lib/Apache2/Const.pm line 19.
Compilation failed in require at 
D:\develop\06_SVN\AP2lib\trunk\modlib\AUTH\UMA2.pm line 28.
BEGIN failed--compilation aborted at D:\develop\06_SVN\AP2lib\trunk\modlib\AUTH\UMA2.pm 
line 28.


-

OS : Windows 10
Apache httpd 2.4.41
perl (Strawberry) : perl 5, version 26, subversion 2 (v5.26.2) built for 
MSWin32-x64-multi-thread

mod_perl : from Steve Hay's mod_perl-2.0.10-strawberryperl-5.26.1.1-64bit.zip,
as per Apache log :
Apache/2.4.41 (Win64) mod_perl/2.0.10 Perl/v5.26.2 configured

Problem :

C:\>perl -cw D:\develop\06_SVN\AP2lib\trunk\modlib\AUTH\UMA2.pm
Can't load 'C:/Strawberry/perl/site/lib/auto/ModPerl/Const/Const.dll' for module 
ModPerl::Const: load_file:Das angegebene Modul wurde nicht gefunden at 
C:/Strawberry/perl/lib/DynaLoader.pm line 193.

  at C:/Strawberry/perl/site/lib/Apache2/Const.pm line 19.
Compilation failed in require at C:/Strawberry/perl/site/lib/Apache2/Const.pm 
line 19.
BEGIN failed--compilation aborted at 
C:/Strawberry/perl/site/lib/Apache2/Const.pm line 19.
Compilation failed in require at 
D:\develop\06_SVN\AP2lib\trunk\modlib\AUTH\UMA2.pm line 28.
BEGIN failed--compilation aborted at D:\develop\06_SVN\AP2lib\trunk\modlib\AUTH\UMA2.pm 
line 28.


Line 28 of UMA2.pm is :

use Apache2::Const -compile => qw(:common :http :methods :override :proxy :log REDIRECT 
AUTHZ_GRANTED AUTHZ_DENIED AUTHZ_DENIED_NO_USER AUTHZ_GENERAL_ERROR);


(wrapping due to email)

C:/Strawberry/perl/site/lib/Apache2/Const.pm line 19 is :

use ModPerl::Const ();

File C:\strawberry\perl\site\lib\ModPerl\Const.pm exists, but has no 
"load_file" in it.

The file C:/Strawberry/perl/site/lib/auto/ModPerl/Const/Const.dll exists.

For non-german-speakers, the above message "load_file:Das angegebene Modul wurde nicht 
gefunden" translates as "load_file:the specified module was not found".


The above module "UMA2.pm" compiles without error on a Linux server with similar httpd, 
perl and mod_perl versions.


Any clue or additional questions welcome.
Thanks


Re: mod_perl, compilation issues, cont

2020-02-03 Thread tomcat/perl

Thank you very much for your reply below. I was getting desperate of getting 
any at all.
I will check the permissions issue and post back to the list.

Maybe in the mneantime an additional question to the list : has *anyone at all* succeeded 
in installing (and using) Apache 2.4 / perl 5.20+ / mod_perl 2.x on a Windows 10 platform ?
Knowing that someone else has been able to do that, would already help me in focusing my 
debugging efforts to something specific to my laptop.



On 31.01.2020 16:45, Bruce Johnson wrote:
I am not a Windows expert by any means, but it it possible that it’s a permissions issue 
on that DLL file or enclosing directory(s)?  Folder permissions in Windows will let you 
grant directory listing rights but not read rights for the process that’s doing the 
compilation…


See: 
https://www.online-tech-tips.com/computer-tips/set-file-folder-permissions-windows/ under 
Permission Types; the specific right is ‘List Folder Contents’


This would account for both dl_findfile working and the ‘Can’t Load file’ error because 
the first utilizes the listing rights and the second needs to actually read the file.




On Jan 16, 2020, at 1:34 AM, André Warnier (tomcat/perl) <mailto:a...@ice-sa.com>> wrote:


Can anyone tell me what the error below really means ?
(and if possible, give me a clue as to what may be happening ?)

To get possibly more details, I re-ran the compile command after setting PERL_DL_DEBUG 
in the environment (just something I found in Dynaloader.pm). It does give some more 
detail, but I am still stumped..


Full config described below.
D:\develop\06_SVN\AP2lib\trunk\modlib\AUTH\UMA2.pm is my module, which compiles just 
fine on Linux servers with similar software installed (Apache, mod_perl, perl).



C:\>perl -cw D:\develop\06_SVN\AP2lib\trunk\modlib\AUTH\UMA2.pm
DynaLoader.pm loaded (C:/Strawberry/perl/site/lib C:/Strawberry/perl/vendor/lib 
C:/Strawberry/perl/lib, C:\STRAWB~1\c\lib C:\STRAWB~1\c\x86_64-w64-mingw32\lib 
C:\STRAWB~1\c\lib\gcc\x86_64-w64-mingw32\7.1.0)

DynaLoader::bootstrap for ModPerl::Const (auto/ModPerl/Const/Const.xs.dll)
dl_findfile(-LC:/Strawberry/perl/site/lib/auto/ModPerl/Const 
-LC:/Strawberry/perl/site/lib -LC:/Strawberry/perl/vendor/lib -LC:/Strawberry/perl/lib 
Const)

checking in C:/Strawberry/perl/site/lib/auto/ModPerl/Const for Const.xs.dll
checking in C:/Strawberry/perl/site/lib/auto/ModPerl/Const for Const.dll
dl_findfile found: C:/Strawberry/perl/site/lib/auto/ModPerl/Const/Const.dll
Can't load 'C:/Strawberry/perl/site/lib/auto/ModPerl/Const/Const.dll' for module 
ModPerl::Const: load_file:Das angegebene Modul wurde nicht gefunden at 
C:/Strawberry/perl/lib/DynaLoader.pm line 193.

 at C:/Strawberry/perl/site/lib/Apache2/Const.pm line 19.
Compilation failed in require at C:/Strawberry/perl/site/lib/Apache2/Const.pm 
line 19.
BEGIN failed--compilation aborted at 
C:/Strawberry/perl/site/lib/Apache2/Const.pm line 19.
Compilation failed in require at 
D:\develop\06_SVN\AP2lib\trunk\modlib\AUTH\UMA2.pm line 28.
BEGIN failed--compilation aborted at D:\develop\06_SVN\AP2lib\trunk\modlib\AUTH\UMA2.pm 
line 28.


-

OS : Windows 10
Apache httpd 2.4.41
perl (Strawberry) : perl 5, version 26, subversion 2 (v5.26.2) built for 
MSWin32-x64-multi-thread

mod_perl : from Steve Hay's mod_perl-2.0.10-strawberryperl-5.26.1.1-64bit.zip,
as per Apache log :
Apache/2.4.41 (Win64) mod_perl/2.0.10 Perl/v5.26.2 configured

Problem :

C:\>perl -cw D:\develop\06_SVN\AP2lib\trunk\modlib\AUTH\UMA2.pm
Can't load 'C:/Strawberry/perl/site/lib/auto/ModPerl/Const/Const.dll' for module 
ModPerl::Const: load_file:Das angegebene Modul wurde nicht gefunden at 
C:/Strawberry/perl/lib/DynaLoader.pm line 193.

 at C:/Strawberry/perl/site/lib/Apache2/Const.pm line 19.
Compilation failed in require at C:/Strawberry/perl/site/lib/Apache2/Const.pm 
line 19.
BEGIN failed--compilation aborted at 
C:/Strawberry/perl/site/lib/Apache2/Const.pm line 19.
Compilation failed in require at 
D:\develop\06_SVN\AP2lib\trunk\modlib\AUTH\UMA2.pm line 28.
BEGIN failed--compilation aborted at D:\develop\06_SVN\AP2lib\trunk\modlib\AUTH\UMA2.pm 
line 28.


Line 28 of UMA2.pm is :

use Apache2::Const -compile => qw(:common :http :methods :override :proxy :log REDIRECT 
AUTHZ_GRANTED AUTHZ_DENIED AUTHZ_DENIED_NO_USER AUTHZ_GENERAL_ERROR);


(wrapping due to email)

C:/Strawberry/perl/site/lib/Apache2/Const.pm line 19 is :

use ModPerl::Const ();

File C:\strawberry\perl\site\lib\ModPerl\Const.pm exists, but has no 
"load_file" in it.

The file C:/Strawberry/perl/site/lib/auto/ModPerl/Const/Const.dll exists.

For non-german-speakers, the above message "load_file:Das angegebene Modul wurde nicht 
gefunden" translates as "load_file:the specified module was not found".


The above module "UMA2.pm" compiles without error on a Linux server with similar httpd, 
perl and mod_perl versions.


Any 

Re: mod_perl, compilation issues, cont

2020-02-03 Thread tomcat/perl

Additional info :

I checked the permissions of all below c:/strawberry/perl, and one thing I can say is that 
all directories and files below that point have at least permissions read/write/execute 
for all "authenticated users".


On the other hand, I also ran the following (why did I not think of that before ?), just 
to make sure that the issue would be reproducible with only the "vanilla" installed Apache 
2.4, perl 5.26.3, mod_perl 2.x :


C:\strawberry\perl\site>set PERL_DL_DEBUG=1

C:\strawberry\perl\site>perl -cw C:/Strawberry/perl/site/lib/Apache2/Const.pm
DynaLoader.pm loaded (C:/Strawberry/perl/site/lib C:/Strawberry/perl/vendor/lib 
C:/Strawberry/perl/lib, C:\STRAWB~1\c\lib C:\STRAWB~1\c\x86_64-w64-mingw32\lib 
C:\STRAWB~1\c\lib\gcc\x86_64-w64-mingw32\7.1.0)

DynaLoader::bootstrap for ModPerl::Const (auto/ModPerl/Const/Const.xs.dll)
dl_findfile(-LC:/Strawberry/perl/site/lib/auto/ModPerl/Const -LC:/Strawberry/perl/site/lib 
-LC:/Strawberry/perl/vendor/lib -LC:/Strawberry/perl/lib Const)

 checking in C:/Strawberry/perl/site/lib/auto/ModPerl/Const for Const.xs.dll
 checking in C:/Strawberry/perl/site/lib/auto/ModPerl/Const for Const.dll
dl_findfile found: C:/Strawberry/perl/site/lib/auto/ModPerl/Const/Const.dll
Can't load 'C:/Strawberry/perl/site/lib/auto/ModPerl/Const/Const.dll' for module 
ModPerl::Const: load_file:Das angegebene Modul wurde nicht gefunden at 
C:/Strawberry/perl/lib/DynaLoader.pm line 193.

  at C:/Strawberry/perl/site/lib/Apache2/Const.pm line 19.
Compilation failed in require at C:/Strawberry/perl/site/lib/Apache2/Const.pm 
line 19.
BEGIN failed--compilation aborted at 
C:/Strawberry/perl/site/lib/Apache2/Const.pm line 19.

(Note : to make extra sure, I also ran this in a CMD window "run as administrator"; the 
results are the same.)



Any other clue, anyone ?

>perl -V :

 C:\strawberry\perl\site>perl -V
Summary of my perl5 (revision 5 version 26 subversion 3) configuration:

  Platform:
osname=MSWin32
osvers=10.0.17134.407
archname=MSWin32-x64-multi-thread
uname='Win32 strawberry-perl 5.26.3.1 #1 Sun Dec  2 22:57:44 2018 x64'
config_args='undef'
hint=recommended
useposix=true
d_sigaction=undef
useithreads=define
usemultiplicity=define
use64bitint=define
use64bitall=undef
uselongdouble=undef
usemymalloc=n
default_inc_excludes_dot=define
bincompat5005=undef
  Compiler:
cc='gcc'
ccflags =' -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -D__USE_MINGW_ANSI_STDIO 
-DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -fwrapv 
-fno-strict-aliasing -mms-bitfields'

optimize='-s -O2'
cppflags='-DWIN32'
ccversion=''
gccversion='7.1.0'
gccosandvers=''
intsize=4
longsize=4
ptrsize=8
doublesize=8
byteorder=12345678
doublekind=3
d_longlong=define
longlongsize=8
d_longdbl=define
longdblsize=16
longdblkind=3
ivtype='long long'
ivsize=8
nvtype='double'
nvsize=8
Off_t='long long'
lseeksize=8
alignbytes=8
prototype=define
  Linker and Libraries:
ld='g++'
ldflags ='-s -L"C:\STRAWB~1\perl\lib\CORE" -L"C:\STRAWB~1\c\lib"'
libpth=C:\STRAWB~1\c\lib C:\STRAWB~1\c\x86_64-w64-mingw32\lib 
C:\STRAWB~1\c\lib\gcc\x86_64-w64-mingw32\7.1.0
libs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 
-lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 
-lodbccp32 -lcomctl32
perllibs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 
-lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 
-lodbccp32 -lcomctl32

libc=
so=dll
useshrplib=true
libperl=libperl526.a
gnulibc_version=''
  Dynamic Linking:
dlsrc=dl_win32.xs
dlext=xs.dll
d_dlsymun=undef
ccdlflags=' '
cccdlflags=' '
lddlflags='-mdll -s -L"C:\STRAWB~1\perl\lib\CORE" -L"C:\STRAWB~1\c\lib"'


Characteristics of this binary (from libperl):
  Compile-time options:
HAS_TIMES
HAVE_INTERP_INTERN
MULTIPLICITY
PERLIO_LAYERS
PERL_COPY_ON_WRITE
PERL_DONT_CREATE_GVSV
PERL_IMPLICIT_CONTEXT
PERL_IMPLICIT_SYS
PERL_MALLOC_WRAP
PERL_OP_PARENT
PERL_PRESERVE_IVUV
USE_64_BIT_INT
USE_ITHREADS
USE_LARGE_FILES
    USE_LOCALE
USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
USE_LOCALE_TIME
    USE_PERLIO
USE_PERL_ATOF
  Built under MSWin32
  Compiled at Dec  2 2018 23:03:33
  %ENV:
PERL_DL_DEBUG="1"
  @INC:
C:/Strawberry/perl/site/lib
C:/Strawberry/perl/vendor/lib
C:/Strawberry/perl/lib

C:\strawberry\perl\site>

Environment :
C:\

Re: POST large amount of data causes segmentation fault

2020-02-10 Thread tomcat/perl

On 09.02.2020 16:26, Vincent Veyron wrote:

On Sun, 9 Feb 2020 10:57:04 +
Scott Alexander  wrote:


I meant I'm posting data from a form, javascript is collecting a series of numbers 
from a  as a string.


Not really clear what happens here? I guess Javascript writes the content of 
the text input?


Javascript seperates each number with a '/' then I use split within Perl to get 
the list of numbers into an array.



I have a  with list of users and GSM numbers. If that list is about 600 
users it has worked fine. I was testing with about 4000 users when I came across this 
problem.



I just tried the line of code you posted earlier (@number = split /\//, 
$req->param("numbers")) on a form that I use, it processes a text input of 50 
000 ten digit numbers separated by a slash with no problem.

I use Apache/2.4.25 (Debian), libapache2-mod-per 2.0.10-2+deb9u and 
libapache2-request-perl 2.13-7~deb9u1



Might it not have something to do with the *format* used for the POST (from javascript / 
). I mean

Content-type : application/x-www-form-urlencoded
or
Content-type : multipart/form-data
or even
Content-type : text/plain

The parser for that data is certainly different on the server side, and one may be running 
against different limits/quirks.


of course a segfault is not nice anyway..

Re (e.g.9 . 
https://dev.to/sidthesloth92/understanding-html-form-encoding-url-encoded-and-multipart-forms-3lpa


Re: Building mod_perl2.pm

2020-02-13 Thread tomcat/perl

On 12.02.2020 23:01, Ruben Safir wrote:

On Tue, Feb 11, 2020 at 07:04:56PM -0600, Steven Lembark wrote:



Hello,
I am trying to use Apache::DBI module. I got it installed on the SUSE
Linux 11SP4 on my dev box.

It has a dependency of mod_perl2. But when I try to install
mod_perl2, I get

Please repair your Module::CoreList at lib/Apache2/Build.pm line 51.
BEGIN failed--compilation aborted at lib/Apache2/Build.pm line 66.
Compilation failed in require at Makefile.PL line 39.
BEGIN failed--compilation aborted at Makefile.PL line 39.

Going by the code in Build.pm, I think the version between Corelist
and Embed is not matching. But the same is installed on our test
servers and I am not sure what is different. Probably it has
Apache::DBI for Apache 1.x installed? How do I check? and any help to
resolve the above error?


You will probably find that maintaining your own copy of Perl is
less work than depending on the pre-compiled [mess] in most
distro's is less work. Building Perl takes little enough time: just
install it into /opt/perl/ via:

 ./Configure --prefix=/opt/perl -de;



This is really true and this is really a problem.  It would be nice to
get some alternate packages made for the larger distros



Just a comment here : we have been installing and using mod_perl2 for many years on many 
servers with Linux Debian, and installing it using the normal Debian package manager 
commands, without any problems that I can recall.


e.g.

root@kunz:~# uname -a
Linux kunz 4.9.0-11-amd64 #1 SMP Debian 4.9.189-3+deb9u2 (2019-11-11) x86_64 
GNU/Linux

root@kunz:~# apt-cache search mod_perl
[ .. long list, among which ..]

libapache2-mod-perl2 - Integration of perl with the Apache2 web server
libapache2-mod-perl2-dev - Integration of perl with the Apache2 web server - 
development files
libapache2-mod-perl2-doc - Integration of perl with the Apache2 web server - 
documentation

root@kunz:~# apt-get install libapache2-mod-perl2
Reading package lists... Done
Building dependency tree
Reading state information... Done
libapache2-mod-perl2 is already the newest version (2.0.10-2+deb9u1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@kunz:~#

So I guess that your issue above does indeed have to do with the specific SUSE packages, 
and you should probably discuss that with them.











(you can see examples of building it in some of my talks on
slideshare.net if you like). After that:

 cd /opt/perl;
 rm *;
 ln -fs /* .;

 [ -d /opt/bin ] || mkdir /opt/bin;
 cd /opt/bin;
 ln -fs ../perl/bin/* .;

and add "/opt/bin" to your path. After that "cpan FooBar" will
install any modules you require, probably with less hassle than
working around O/S issues with library versions.

You could spend a week or so banging your head out deciphering
whatever bone-headed assumptions the distro builders made or
just get it right the first time yourself.

The process may look daunting the first time around but after
a while you'll notice it takes only a few of your favorite
beverages a month to maintain and induces far less annoyance...

Enjoy

--
Steven Lembark3646 Flora Place
Workhorse ComputingSt. Louis, MO 63110
lemb...@wrkhors.com+1 888 359 3508






Apache 2.4, AAA, Shibboleth

2020-03-06 Thread tomcat/perl

Hi experts.

In our Apache 2.4(+mod_perl) setups, we use the following kind of thing :

...
PerlAddAuthzProvider UMA-user AUTH::UMA2->authz_user
...

  AuthName ALUtop
  AuthType shibboleth
  PerlSetVar UMA_AuthType "SAML2"
  ShibRequestSetting requireSession 1
  ShibRequestMapperAuthz Off
  ShibUseHeaders On
  ShibUseEnvironment Off
  PerlSetVar UMA_Debug 3
  
Require UMA-user valid-user
Require shibboleth
  
...


which basically means :
we combine 2 AAA methods :
- one is our own (AUTH::UMA2 above, mod_perl based)
- the other is SAML, via Shibboleth (and all the directives above with "shib" in them, 
correspond to the Shibboleth installation instructions)


(The reason being : the corporate user authentication happens via SAML, but it does not 
provide us enough information about the user. So we run another additional scheme, which 
supplements the user information, in order to feed more complete data to our applications.)


Our own AAA method is such, that once the user has been authenticated once, we set a 
token, such that for subsequent requests we do not need to re-authenticate the user.

But no matter what we do at that level, the Shibboleth authentication runs 
anyway.(*)

And my question is : considering the above setup, would mod_perl provide a way, through 
some mod_perl API, to disable the Shibboleth authentication (on a request-by-request 
base), when our own authz module determines that we do not need it to run anymore for the 
current request ?


(replace Shibboleth by any other authentication that would be configured in addition to 
our own; I'm looking for some "generic" mechanism, not only for Shibboleth).


Or is it so that different authentication methods/modules don't insert themselves in any 
standard way which can easily be interfaced with in order to dynamically disable them ?


Note: Shibboleth itself does caching of its prior authentication, and it is not really a 
big performance hit to re-run it each time, and we can live with it as it is. But in the 
absolute, it is unnecessary for 90% of the accesses to the applications, so it just sounds 
like disabling it would be a nice/efficient thing to do.


I thought of dynamically removing the "Require shibboleth" e.g., but there does not seem 
to be an API to do that.





Re: Apache 2.4, AAA, Shibboleth

2020-03-06 Thread tomcat/perl

On 06.03.2020 17:18, Russell Lundberg wrote:

Andy, could your custom auth handler run before Shiboleth, test for a Shiboleth 
token? If not present, use push_handler to run Shiboleth? If the Shiboleth 
token or cookie is present, don’t run Shiboleth?


Well, the problem is that Shibboleth is quite "invasive" (no complaint here, it works that 
way it is supposed to and documented), in the sense that there are quite a few directives 
for it (as you can see below), and I am not quite sure if I can configure a section "with 
Shibboleth but not its handler", in order to only push the handler later.
For example, I have the feeling that just indicating "AuthType Shibboleth" (which is 
required) already puts the handler in the chain.

On the other hand, if I could just insert the "require shibbolet"
dynamically (instead of in the static config), that might do it.
But there seems to be no mod_perl API to add a "require" on-the-fly. "Requires" are just a 
list that the AUTHZ handler gets when called, and apparently each such handler only gets 
its own.
For example, the "Require UMA-user valid-user" below, results in our AUTHZ function 
"AUTH::UMA2->authz_user" being called, but in the list of requires we just get (our own) 
"valid-user".


But thanks for the suggestion. It /is/ the kind of thing I'm looking for.
Only maybe the opposite : how to "pop" the Shibboleth handler when it's there, and just 
for the current request.





Russell

Sent from my iPhone


On Mar 6, 2020, at 08:26, André Warnier (tomcat/perl)  wrote:

Hi experts.

In our Apache 2.4(+mod_perl) setups, we use the following kind of thing :

...
PerlAddAuthzProvider UMA-user AUTH::UMA2->authz_user
...

  AuthName ALUtop
  AuthType shibboleth
  PerlSetVar UMA_AuthType "SAML2"
  ShibRequestSetting requireSession 1
  ShibRequestMapperAuthz Off
  ShibUseHeaders On
  ShibUseEnvironment Off
  PerlSetVar UMA_Debug 3
  
Require UMA-user valid-user
Require shibboleth
  
...


which basically means :
we combine 2 AAA methods :
- one is our own (AUTH::UMA2 above, mod_perl based)
- the other is SAML, via Shibboleth (and all the directives above with "shib" 
in them, correspond to the Shibboleth installation instructions)

(The reason being : the corporate user authentication happens via SAML, but it 
does not provide us enough information about the user. So we run another 
additional scheme, which supplements the user information, in order to feed 
more complete data to our applications.)

Our own AAA method is such, that once the user has been authenticated once, we 
set a token, such that for subsequent requests we do not need to 
re-authenticate the user.
But no matter what we do at that level, the Shibboleth authentication runs 
anyway.(*)

And my question is : considering the above setup, would mod_perl provide a way, 
through some mod_perl API, to disable the Shibboleth authentication (on a 
request-by-request base), when our own authz module determines that we do not 
need it to run anymore for the current request ?

(replace Shibboleth by any other authentication that would be configured in addition to 
our own; I'm looking for some "generic" mechanism, not only for Shibboleth).

Or is it so that different authentication methods/modules don't insert 
themselves in any standard way which can easily be interfaced with in order to 
dynamically disable them ?

Note: Shibboleth itself does caching of its prior authentication, and it is not 
really a big performance hit to re-run it each time, and we can live with it as 
it is. But in the absolute, it is unnecessary for 90% of the accesses to the 
applications, so it just sounds like disabling it would be a nice/efficient 
thing to do.

I thought of dynamically removing the "Require shibboleth" e.g., but there does 
not seem to be an API to do that.






Re: Apache 2.4, AAA, Shibboleth

2020-03-06 Thread tomcat/perl

Genius !
Yes, I'll try that.
Why did I not think of that myself ?
If anything, it'll be fun to watch the log lines of authz_core and try to make 
sense of them.
I don't even think that I have to extend our module, it should work just as well with 
"require UMA-user valid-user" in both cases.


One more question : why the top-level  ?

On 07.03.2020 00:59, Paul B. Henson wrote:

On Sat, Mar 07, 2020 at 12:22:35AM +0100, André Warnier (tomcat/perl) wrote:


Does anyone have an idea how I could do the equivalent of a "pop the
'require shibboleth' but just for this request" ?


Would you be willing to extend your local custom module to achieve this?

You could do something like:



Require UMA-token

Require shibboleth
Require UMA-user valid-user




Your custom module would get called first, which would check to see if
your custom session token was valid. If so, it would return success and
nothing else would be processed. Otherwise, the shibboleth module would
run, then your custom module which would establish your session token so
on the next access the shib auth would be bypassed.


ShibRequestMapperAuthz Off
ShibUseHeaders On
ShibUseEnvironment Off
PerlSetVar UMA_Debug 3

  Require UMA-user valid-user
  Require shibboleth

...


which basically means :
we combine 2 AAA methods :
- one is our own (AUTH::UMA2 above, mod_perl based)
- the other is SAML, via Shibboleth (and all the directives above with
"shib" in them, correspond to the Shibboleth installation instructions)

(The reason being : the corporate user authentication happens via SAML, but
it does not provide us enough information about the user. So we run another
additional scheme, which supplements the user information, in order to feed
more complete data to our applications.)

Our own AAA method is such, that once the user has been authenticated once,
we set a token, such that for subsequent requests we do not need to
re-authenticate the user.
But no matter what we do at that level, the Shibboleth authentication runs 
anyway.(*)

And my question is : considering the above setup, would mod_perl provide a
way, through some mod_perl API, to disable the Shibboleth authentication (on
a request-by-request base), when our own authz module determines that we do
not need it to run anymore for the current request ?

(replace Shibboleth by any other authentication that would be configured in
addition to our own; I'm looking for some "generic" mechanism, not only for
Shibboleth).

Or is it so that different authentication methods/modules don't insert
themselves in any standard way which can easily be interfaced with in order
to dynamically disable them ?

Note: Shibboleth itself does caching of its prior authentication, and it is
not really a big performance hit to re-run it each time, and we can live
with it as it is. But in the absolute, it is unnecessary for 90% of the
accesses to the applications, so it just sounds like disabling it would be a
nice/efficient thing to do.

I thought of dynamically removing the "Require shibboleth" e.g., but there
does not seem to be an API to do that.








Re: Apache 2.4, AAA, Shibboleth

2020-03-06 Thread tomcat/perl

Thanks.
That's an interesting idea, and I'm quite sure that we could make that work, if only as a 
proof of concept.
The main issue I see with it, is that it would basically double a lot of our configuration 
sections - of which we have many - and make our configuration even more obscure than what 
it already is. My application developers and support people would not be so keen on that.


Does anyone have an idea how I could do the equivalent of a "pop the 'require shibboleth' 
but just for this request" ?

(from within my mod_perl handler of course)
Or is that simply impossible, given the current mod_perl API ?

(Note: It doesn't have to be a guaranteed thing.  Whatever idea there is, I'll try it, and 
if it causes a segfault or other nasty things, I'll drop it. The only requirement for me 
is that it has to be perl code..)




On 06.03.2020 21:14, Paul B. Henson wrote:

Generally in SAML apps that want to convert the SSO auth into their own
token and not require a SAML session to be established every time they
have a different URL for the auth case.

For example, you could have /esearchs-sso/ have both shibboleth and your
auth type enabled. When someone hits that, you generate your own
session state and then redirect them to /esearchs/, which only has your
auth enabled.

If someone hits /esearchs/ without your auth session, it sends them to
/esearchs-sso/ to do auth, which then sends them back to /esearchs/ with
the proper session.

--
Signet - The Art of Access
https://www.signet.id/


On Fri, Mar 06, 2020 at 04:26:06PM +0100, André Warnier (tomcat/perl) wrote:

Hi experts.

In our Apache 2.4(+mod_perl) setups, we use the following kind of thing :

...
 PerlAddAuthzProvider UMA-user AUTH::UMA2->authz_user
...
 
   AuthName ALUtop
   AuthType shibboleth
   PerlSetVar UMA_AuthType "SAML2"
   ShibRequestSetting requireSession 1
   ShibRequestMapperAuthz Off
   ShibUseHeaders On
   ShibUseEnvironment Off
   PerlSetVar UMA_Debug 3
   
 Require UMA-user valid-user
 Require shibboleth
   
...


which basically means :
we combine 2 AAA methods :
- one is our own (AUTH::UMA2 above, mod_perl based)
- the other is SAML, via Shibboleth (and all the directives above with
"shib" in them, correspond to the Shibboleth installation instructions)

(The reason being : the corporate user authentication happens via SAML, but
it does not provide us enough information about the user. So we run another
additional scheme, which supplements the user information, in order to feed
more complete data to our applications.)

Our own AAA method is such, that once the user has been authenticated once,
we set a token, such that for subsequent requests we do not need to
re-authenticate the user.
But no matter what we do at that level, the Shibboleth authentication runs 
anyway.(*)

And my question is : considering the above setup, would mod_perl provide a
way, through some mod_perl API, to disable the Shibboleth authentication (on
a request-by-request base), when our own authz module determines that we do
not need it to run anymore for the current request ?

(replace Shibboleth by any other authentication that would be configured in
addition to our own; I'm looking for some "generic" mechanism, not only for
Shibboleth).

Or is it so that different authentication methods/modules don't insert
themselves in any standard way which can easily be interfaced with in order
to dynamically disable them ?

Note: Shibboleth itself does caching of its prior authentication, and it is
not really a big performance hit to re-run it each time, and we can live
with it as it is. But in the absolute, it is unnecessary for 90% of the
accesses to the applications, so it just sounds like disabling it would be a
nice/efficient thing to do.

I thought of dynamically removing the "Require shibboleth" e.g., but there
does not seem to be an API to do that.






Re: Apache2:AuthCookie With httpd 2.4

2020-05-14 Thread tomcat/perl

Hi.
Just some tips, to simplify the issue, below in the text :


On 14.05.2020 06:09, Scott Alexander wrote:

Hi,

Thanks for your answer, but for me this is confusing.

I have

Apache2_4::AuthCookie is up to date. (3.30)
Apache2::AuthCookie is up to date. (3.30)   <--- you do not need this with 
Apache 2.4
Server version: Apache/2.4.6 (CentOS)
Server built:   Apr  2 2020 13:13:23

at the end of /etc/httpd/conf.d/ssl.conf there is include 
/systems/achilles/config/mine_auth_cookie_mod_perl_server_apache2.conf


my @inc has /systems/achilles/lib
and I have /systems/achilles/lib/Apache2/AuthCookieHandler.pm
and /systems/achilles/lib/Apache2_4/AuthCookieHandler.pm

in both AuthCookieHandler.pm I've renamed the package line to eg
package Apache2_4::AuthCookieHandler;


In the directory I want to protect should I have



Not with Apache 2.4 :


AuthType Apache2::AuthCookieHandler
AuthName WhatEver
PerlAuthenHandler Apache2::AuthCookieHandler->authenticate
Require valid-user

or



this is what you need with Apache 2.4 :


AuthType Apache2_4::AuthCookieHandler
AuthName WhatEver
PerlAuthenHandler Apache2_4::AuthCookieHandler->authenticate
Require valid-user

And then what subs/methods I need to add into which AuthCookieHandler.pm ?

in startup.pl should I have both or just one?




use Apache2::AuthCookie ;  <-- you do not need this
use Apache2_4::AuthCookie ; <-- this is correct for Apache 2.4



I am not porting from 2.2. I have used Shibboleth until now to protect directories but 
this project I can not use Shibboleth.




And how exactly do you want the user to authenticate ? via a login page where they enter 
their id and password ?

And what is the way in which you are going to check that these id and password 
are correct ?
(in other words : where are the user ids and passwords stored ?)
And how many different users are you planning to have ?





Terveisin/Regards
**
*Scott Alexander*

scott.alexan...@humak.fi <mailto:scott.alexan...@humak.fi>

--
*From:* Edward J. Sabol 
*Sent:* 12 May 2020 00:58
*To:* Scott Alexander 
*Cc:* mod_perl list 
*Subject:* Re: Apache2:AuthCookie With httpd 2.4
On May 11, 2020, at 8:58 AM, Scott Alexander  wrote:
I've included using https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmanpages.debian.org%2Funstable%2Flibapache2-authcookie-perl%2FApache2_4%3A%3AAuthCookie.3pm.en.html&data=02%7C01%7C%7Cfdafa4a140a44a1c47ed08d7f5f66767%7Ca30a558eb6084b2c8f39a7fa426fa49d%7C0%7C0%7C637248310956933568&sdata=XwSR%2FO7jCwZrZLuYRSWWhp%2Fwz7tCtWkCzjs0fTRTIDk%3D&reserved=0 

as an example


# In httpd.conf or .htaccess:
PerlModule Sample::Apache2::AuthCookieHandler
PerlSetVar WhatEverPath / . 


to my ssl.conf file

No changes made to httpd.conf or ssl.conf.


Those two statements seem to be conflicting? I keep my authentication/authorization 
information in httpd.conf, personally.


When trying to access the page I get the errors above. 


That sample configuration from the POD assumes that you are subclassing 
Apache2::AuthCookie and that the name of your subclass is 
Sample::Apache2::AuthCookieHandler. It's meant to be illustrative. I'm guessing you don't 
actually have such a subclass. Try just removing the "Sample::" part. You can probably 
also find working examples in the tests in the "t" subdirectory.



I've read this 
https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmetacpan.org%2Fpod%2Fdistribution%2FApache-AuthCookie%2FREADME.apache-2.4.pod&data=02%7C01%7C%7Cfdafa4a140a44a1c47ed08d7f5f66767%7Ca30a558eb6084b2c8f39a7fa426fa49d%7C0%7C0%7C637248310956933568&sdata=SyqV%2FQzJyud4W6ENIgEY9nk%2F9uBzBGf7p6gmShAqivc%3D&reserved=0
which unfortunately doesn't make sense to me. 


That POD is meant for people developing (or porting from Apache 2.2.x) their own Perl 
modules for doing authentication and authorization under Apache 2.4.x. AuthCookie already 
handles all of this for you, assuming you only need or use AuthCookie. It might apply if 
you are subclassing from AuthCookie and you get into the gritty details, such as 
implementing your own AuthzProvider. Check out Apache2_4::AuthCookieDBI for an example of 
that.


https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmetacpan.org%2Fpod%2FApache2_4%3A%3AAuthCookieDBI&data=02%7C01%7C%7Cfdafa4a140a44a1c47ed08d7f5f66767%7Ca30a558eb6084b2c8f39a7fa426fa49d%7C0%7C0%7C637248310956933568&sdata=ew5g7VpZFmfs%2FHN9NAdA9YqHtLY11o36UBl9ljp0zN0%3D&reserved=0

Regards,
Ed





problem with Apache apreq2 on SLES 12 SP1

2020-05-30 Thread tomcat/perl

Hi.

Since the following is quite long, here is the question :
does the following ring any bell to anyone here ?

Thanks in advance.
André

Description:

We get the following issue on a customer system on which we install an 
application.
The system was initially installed by the customer's own IT specialists.

The OS version is SLES 12 SP1 (Suse).

Initial versions:

Information for package apache2:

Repository: SLES12-SP1-Updates
Name: apache2
Version: 2.4.16-19.1
Arch: x86_64
Vendor: SUSE LLC <https://www.suse.com/>

Information for package apache2-mod_perl:
-
Repository: SLES12-SP1-Pool
Name: apache2-mod_perl
Version: 2.0.8-11.43
Arch: x86_64
Vendor: SUSE LLC <https://www.suse.com/>

Generally-speaking, mod_perl and the application are working, but
when trying to access a specific Template::Toolkit controlled page, we got an error in the 
Apache log, that Apache2::Cookie is missing. Trying to install it via cpan failed, due to 
a missing apxs binary. That is in apache2-devel, but no -devel packages where available

on the system initially.

That was changed via

SUSEConnect -p sle-sdk/12.1/x86_64 # "sdk" contains the -devel packages
zypper install apache2-devel

Information for package apache2-devel:
--
Repository: SLE-SDK12-SP1-Updates
Name: apache2-devel
Version: 2.4.16-19.1
Arch: x86_64
Vendor: SUSE LLC <https://www.suse.com/>


Other packages that where at some point installed, I'm not quite sure on the
order:


Information for package libapr1:

Repository: SLES12-SP1-Pool
Name: libapr1
Version: 1.5.1-2.7
Arch: x86_64
Vendor: SUSE LLC <https://www.suse.com/>

Information for package libapr1-devel:
--
Repository: SLE-SDK12-SP1-Pool
Name: libapr1-devel
Version: 1.5.1-2.7
Arch: x86_64
Vendor: SUSE LLC <https://www.suse.com/>

Information for package libapr-util1:
-
Repository: SLES12-SP1-Pool
Name: libapr-util1
Version: 1.5.3-1.77
Arch: x86_64
Vendor: SUSE LLC <https://www.suse.com/>

Information for package libapr-util1-devel:
---
Repository: SLE-SDK12-SP1-Pool
Name: libapr-util1-devel
Version: 1.5.3-1.77
Arch: x86_64
Vendor: SUSE LLC <https://www.suse.com/>

Installing Apache2::Cookie still failed with:


/root/.cpanm/work/1590841954.10393/libapreq2-2.13/glue/perl/xsbuilder/apreq_xs_postperl.h:22:34: 
fatal error: modperl_perl_unembed.h: No such file or directory


The missing file is in mod_perl-devel, which doesn't exist in SLES12 SP1,
but I found a matching version here, which I donwnloaded an installed:


http://download.takehoa.org/SLES/12.4/SDK/DVD1/suse/x86_64/apache2-mod_perl-devel-2.0.8-11.43.x86_64.rpm

Information for package apache2-mod_perl-devel:
---
Repository: @System
Name: apache2-mod_perl-devel
Version: 2.0.8-11.43
Arch: x86_64
Vendor: SUSE LLC <https://www.suse.com/>


Installing Apache2::Cookie now worked. build.log is attached.


But with this :

LoadModule perl_module /usr/lib64/apache2/mod_perl.so
LoadModule apreq2_module /usr/lib64/apache2/mod_apreq2.so

in the httpd config, httpd doesn't start with:

httpd-prefork: Syntax error in -C/-c directive: Syntax error on line 26 of 
/etc/apache2/sysconfig.d/loadmodule.conf: Can't locate API module structure 
`apreq2_module' in file /usr/lib64/apache2/mod_apreq2.so: 
/usr/lib64/apache2/mod_apreq2.so: undefined symbol: apreq2_module


With only:

LoadModule perl_module /usr/lib64/apache2/mod_perl.so

httpd does start, but upon accessing a page, which results in the usage of 
Apache2::Cookie, we get :


/usr/sbin/httpd-prefork: symbol lookup error: 
/usr/lib/perl5/site_perl/5.18.2/x86_64-linux-thread-multi/auto/APR/Request/Apache2/Apache2.so: 
undefined symbol: apreq_handle_apache2


Maybe also relevant:

# ldd -r /usr/lib64/apache2/mod_perl.so
  linux-vdso.so.1 (0x7ffe9ebe7000)
  libperl.so => /usr/lib/perl5/5.18.2/x86_64-linux-thread-multi/CORE/libperl.so 
(0x7f24397dd000)

  libdl.so.2 => /lib64/libdl.so.2 (0x7f24395d9000)
  libpthread.so.0 => /lib64/libpthread.so.0 (0x7f24393bc000)
  libc.so.6 => /lib64/libc.so.6 (0x7f2439014000)
  libm.so.6 => /lib64/libm.so.6 (0x7f2438d13000)
  libcrypt.so.1 => /lib64/libcrypt.so.1 (0x7f2438ad8000)
  /lib64/ld-linux-x86-64.so.2 (0x7f2439db1000)
undefined symbol: apr_bucket_shared_split   (/usr/lib64/apache2/mod_perl.so)
undefined symbol: apr_bucket_share

Re: Can't locate object method "new" via package "CGI::Cookie"

2020-06-01 Thread tomcat/perl

On 31.05.2020 20:49, Vincent Veyron wrote:

Hi List,

I have two servers using mod_perl, both having the same modules installed and 
enabled; server1 got a fresh install of Debian Buster, while server2 was 
upgraded to Buster from Stretch.

This code :
my $cookie = CGI::Cookie->new(-name  => 'session',
  -value => $session_id,
  -domain => $hostname
) ;

generates the following error on server2 :

[Sun May 31 19:54:03.053725 2020] [perl:error] [pid 30663] [client 83.113.48.133:59196] Can't locate object 
method "new" via package "CGI::Cookie" (perhaps you forgot to load 
"CGI::Cookie"?) at /home/lib/Marica/Base/login.pm line 198.\n, referer: 
https://marica.fr/site/abonnes/index.html

It works fine if add "use CGI::Cookie" to my module.

What could be the reason why it works on server1 without "use CGI::Cookie" and 
not on server2?



Hi.
Since the two systems were installed/upgraded differently  ..

When I configure mod_perl on a Debian system, I usually have a "startup script" running 
from within the /etc/apache2/mod_enabled/perl.conf file, e.g. via


PerlPostConfigRequire "/etc/apache2/modperl2_startup.pl"

This startup script, among other things, preloads frequently-used modules, so that they 
will be loaded and available later in any Apache child/thread. Like :


...
  use lib "some_path_with_proprietary_modules";
...
  use ModPerl::Registry ();
  use CGI ();
  CGI->compile(':all');
  use My::Module;
...

Maybe you forgot this on one of the systems, and not the other ?

P.S.
I also use the same startup script to log some information to the Apache error log at 
startup, such as this for example :


[Sun May 31 06:25:08.054152 2020] [:error] [pid 5519] mp2-startup: EFSDIR is : 
/home/EFS
[Sun May 31 06:25:08.054160 2020] [:error] [pid 5519] mp2-startup: 
AUTHZ_GRANTED is : 1
[Sun May 31 06:25:08.054166 2020] [:error] [pid 5519] mp2-startup: AUTHZ_DENIED 
is : 0
[Sun May 31 06:25:08.054173 2020] [:error] [pid 5519] mp2-startup: 
AUTHZ_DENIED_NO_USER is : 4
[Sun May 31 06:25:08.054184 2020] [:error] [pid 5519] mp2-startup: @INC is now : 
/home/EFS/lib / /etc/perl / /usr/local/lib/x86_64-linux-gnu/perl/5.20.2 / 
/usr/local/share/perl/5.20.2 / /usr/lib/x86_64-linux-gnu/perl5/5.20 / /usr/share/perl5 / 
/usr/lib/x86_64-linux-gnu/perl/5.20 / /usr/share/perl/5.20 / /usr/local/lib/site_perl / . 
/ /etc/apache2


precisely so that I would know what the perl module library search paths would be under 
Apache when it runs.




problem with SLES 12, Apache 2,4, mod_perl 2.0.8

2020-06-03 Thread tomcat/perl

Hi.
A few days ago, I posted an issue that we experienced with apreq2 on this same platform, 
which we could in the end resolve but via a somewhat unconventional and complicated route.


Now we find another issue with mod_perl, and we do not know how to tackle it.

The problem seems to be that with the mod_perl 2.0.8 on this platform, the Apache2::Const 
"AUTHZ" constants seem to all return the value 0.


In particular, we have a startup script which contains these lines :

		$server->log_error("mp2-startup: AUTHZ_GRANTED is : " . (Apache2::Const::AUTHZ_GRANTED + 
0));

$server->log_error("mp2-startup: AUTHZ_DENIED is : " . 
(Apache2::Const::AUTHZ_DENIED + 0));
		$server->log_error("mp2-startup: AUTHZ_DENIED_NO_USER is : " . 
(Apache2::Const::AUTHZ_DENIED_NO_USER + 0));


and on this platform it prints a value 0 for each of them, e.g.

[Wed Jun 03 16:21:13.381748 2020] [:error] [pid 113974] mp2-startup: 
AUTHZ_GRANTED is : 0
[Wed Jun 03 16:21:13.381752 2020] [:error] [pid 113974] mp2-startup: 
AUTHZ_DENIED is : 0
[Wed Jun 03 16:21:13.381754 2020] [:error] [pid 113974] mp2-startup: AUTHZ_DENIED_NO_USER 
is : 0



while on a bunch of other Apache 2.4/mod_perl platforms this prints e.g.

[Sun May 31 06:25:04.301983 2020] [:error] [pid 24489] mp2-startup: 
AUTHZ_GRANTED is : 1
[Sun May 31 06:25:04.301986 2020] [:error] [pid 24489] mp2-startup: 
AUTHZ_DENIED is : 0
[Sun May 31 06:25:04.301989 2020] [:error] [pid 24489] mp2-startup: AUTHZ_DENIED_NO_USER 
is : 4



We are not quite sure where this mod_perl 2.0.8 comes from, and it might be 
corrupted..
Or maybe mod_perl 2.0.8 did not really define these constants in Apache2::Const 
?

Does this ring a bell, anyone ?


Re: suggestions for perl as web development language [EXT]

2020-08-04 Thread tomcat/perl

On 04.08.2020 11:31, paul trader wrote:

On Tue, 4 Aug 2020 at 07:36, James Smith opined:

JS:Others will disagree but the best way I still believe is using mod_perl
JS:- but only if you use it's full power - and you probably need a special
JS:sort of mind set to use - but that can be said for any language.

i will second this motion.  mod_perls ability to hook into any step of the
process apache uses to serve up a page makes it easy to design a web
solution that can be tailored for any solution.



Let me agree and add to that.

If your purpose is simply to write "classic web applications" (in the sense of user 
interface etc), then there are probably nowadays easier and "more modern" tools than 
mod_perl; and indeed it is a problem to find young programmers who already know perl.
(It is not difficult however for a good young programmer, to learn perl. And I would 
always prefer a good young programmer who doesn't know perl yet, over a not so good young 
programmer who knows everything except perl.)


On the other hand, if your kind of project involves a very tight integration with all 
aspects of Apache httpd, then there really isn't any other tool than mod_perl to do it.
It is difficult in a short message like this to detail all the ways that you can interact 
with Apache httpd to get things done, but have a look at the schema here :


https://www.askapache.com/s/s.askapache.net/httpd/modules/modsecurity-apache_2.1.4/doc/html-multipage/04-processing-phases.html

and imagine that, with mod_perl, you can interact with Apache httpd and control virtually 
everything that happens within any of those boxes (and even between them).
Together, Apache httpd + mod_perl are a tool for creating complex web-based applications, 
which has no equivalent anywhere (not with any other webserver, not with any other 
programming language, not with any kind of OS)(in the open-source/free world).
In addition, using mod_perl does not prevent you from using any other Apache add-on module 
or any other development tool in addition (in whatever programming language you choose). 
mod_perl just allows you to do more, and faster.


A possible problem with mod_perl may be its continued support, considering the kind of 
discussions (hopefully temporary) going on at the moment in the perl 5.x/7.x development 
community.
But I believe that there is such a wide existing base of solid web applications based on 
perl, mod_perl and the (also incomparable) CPAN library, that any idea of dropping support 
for them, would be for some time quite far in the future.


P.S. As an example : I am at the moment working on expanding an Apache/mod_perl user 
authentication module, that has to be able to authenticate users using either of HTTP 
Basic, LDAP, SAML, SPNEGO (Windows), OpenId, SiteMinder (tm), client IP and and login-form 
based authentication, while delivering a consistent "user profile" to follow-up web 
applications.

And I cannot think of any other tool than Apache/mod_perl which would allow me 
to do this.
(except this : https://metacpan.org/pod/Apache2::AuthAny, but that is also 
mod_perl based)


Re: suggestions for perl as web development language [EXT]

2020-08-05 Thread tomcat/perl

On 04.08.2020 22:48, Mark Blackman wrote:
[...]
the web server handles all the complicated host or path rewrites and access control and 
the Perl app focuses on responding to the, now-sanitised, fully normalized, HTTP requests.


I'll agree to that, up to a point.

If you just want to write web applications which run in a sanitized, normalised HTTP 
environment, then there are plenty of tools available, and your best choice nowadays may 
not be perl as a development language.

(*)

Now in the real world, you may often have to do things which do NOT fit in such a 
sanitized and normalized environment, and the simplest and most efficient way to do them 
may be at the level of the HTTP server itself. And if you are in such a case, and if your 
webserver is Apache httpd, then for such things mod_perl has no equivalent (except if you 
are very good at writing Apache httpd extensions in C).


And in my experience - although I don't know if this is an advantage or an inconvenient in 
a general sense - once you start using mod_perl to resolve such issues, you will be 
learning a lot about how Apache httpd works, and how mod_perl fits in it, and you will 
start finding out how many of these apparently thorny issues /can/ be handled at the 
Apache httpd and mod_perl level, and you will probably never want to go back to work with 
another webserver and another scripting language for it.

So be careful : Apache httpd + mod_perl are addictive.


(*) Although if you pick another language, then you would also lose the advantage of the 
perl CPAN library which has, *in one place*, something for just about everything you may 
ever want to do - including very good documentation on just about everything you may ever 
want to do).
If you don't know CPAN, and you do not understand why I'm insisting on it, do the 
following experience :

- go to https://metacpan.org/
- in the search box, type a word related to some programming issue which you are currently 
having (**)

- then read the descriptions and click on some module which looks interesting 
for you

In terms of programming, this is as close to Wikipedia as one can get.
Thanks to the hundreds of authors who contributed there over the year, and to their 
general care about good documentation.

For me, that alone is already enough justification for using perl.

(**) suggestions, of the top of my head : "covid", "usa", "png", "soap", "ldap", 
"calculus", "spanish", "mail", "smtp", "ebay", "dictionary", .. have fun.


Re: Confused about two development utils

2020-12-22 Thread tomcat/perl

On 22.12.2020 06:49, Matthias Peng wrote:

Hello

I am developing a simple mp2 application.
I looked for the installation for mp2 utils, and found this two:

libapache2-mod-perl2

libapache2-mod-apreq2


what're their relations? Should I install both, or only the first one?



Hi.

They are different and independent packages and module libraries, and you can use the one 
or the other, or both, depending on your needs.

(We always install both, and we use both)

For mod_perl per se, you need only the /libapache2-mod-perl2/ package.
This gives you access to all the stuff documented here :
http://perl.apache.org/docs/2.0/api/index.html

*except* what is at the very end of that page :

"Part VI: Related Modules" -> libapreq modules
(this is what is contained in the separate /libapache2-mod-apreq2/ package)
The documentation for libapreq is at :
http://httpd.apache.org/apreq/docs/libapreq2/modules.html

It may be a bit confusing at first, because both (independent) packages use some common 
namespaces ("Apache2::" and "APR::"), and because each of mod_perl and libapreq2 have 
their own form of "Apache Request object", named very similarly :

- for mod_perl it is Apache2::RequestRec
- for libapreq it is Apache2::Request
(I guess that libapreq was first, that's why they got the better name ;-)

I am  a bit reluctant to try explaining the difference further (for fear of confusing you 
further), but here is a very rough summary :


- to deal with 99% of what has to do with controlling what happens within Apache httpd in 
terms of processing HTTP requests (or just to run your perl scripts faster), use the 
mod_perl package.

So install /libapache2-mod-perl2/ first, and start coding.

- if you finds out later that you have to do a lot of processing of CGI parameters (the 
request "query string") or cookies, you can then install and use use the libapreq API 
which (among other things) provide an alternative to what the CGI module provides.


In any case, there is a bit of a learning curve, but it is great fun and very 
powerful.






Re: Confused about two development utils

2020-12-23 Thread tomcat/perl

On 22.12.2020 14:20, Matthias Peng wrote:

Can I guess mod_perl is the upgraded version of apreq? Thanks Andre.


Not really.  They are really 2 different things.

The essence of mod_perl, is to embed a perl interpreter in Apache httpd.
This costs memory, and all the more since many perl modules are not thread-safe, so if you 
use them in your code, at this moment the only safe way to do it is to use the Apache 
httpd prefork model. This means that each Apache httpd child process has its own copy of 
the perl interpreter, which means that the memory used by this embedded perl interpreter 
has to be counted n times (as many times as there are Apache httpd child processes running 
at any one time).
This can be significant, but it is also relative : if you compare the memory used in the 
practice by an Apache httpd with mod_perl and compare it to other possible solutions for 
web applications (e.g. a java-based webserver, or back-end solutions running their own 
interpreter), you will see that this "bad side of mod_perl" is really not as bad as many 
perl and mod_perl detractors would want you to believe.
There are no miracles : if you want to do many complex things in parallel and do them 
fast, you are going to use memory and CPU time, no matter which techniques or tools you use.


Once you have admitted the above, having a perl interpreter embedded in Apache httpd 
through mod_perl leads to 2 major things :


1) anything written in perl and used by your web application can run *much* faster (with 
the right setup), because it will be pre-compiled by the perl interpreter the first time 
it is run, and then cached in some intermediate form, which will run say 100 times faster 
any subsequent time it is run after that (as long as it runs within the same Apache 
child). So, * if you know perl and like perl as a programming language, and you are - as I 
am - amazed by the incredible scope and quality and documentation of the perl CPAN library 
*, just that makes it worth having a good look at mod_perl.

But this is only one aspect of mod_perl.

2) the most important aspect (in my view), is that mod_perl allows you to really intervene 
and "do things", in perl, inside the logic of Apache httpd itself, at just about any step 
of the processing of a HTTP request by Apache. Not everyone is interested in doing this, 
but if you find that your applications could benefit from being able to inspect and/or 
modify the way in which Apache httpd is processing HTTP requests, there is not really any 
tool that compares to mod_perl in that respect.
In fact, what mod_perl really allows you to do, is to turn things around : instead of 
being this little perl toolbox that is added to httpd, it allows you to use Apache httpd - 
with all its finely tuned code and extensions - *as a toolbox* to do what you want in your 
perl application. That is the real power of mod_perl. If mod_perl did not exist, the only 
real alternative for doing that kind of thing, would be to write your own Apache add-on 
modules in C. (Which would mean "forget about CPAN" and start looking elsewhere for 
anything you need in addition).


In comparison to mod_perl, the apreq library is more limited and more focused. It's main 
aspect in my view, is to provide a more efficient alternative for the perl CGI module, in 
terms of processing cgi-bin script arguments and cookies (and maybe some other things 
which I admit I've never really looked at).


I guess that by now you know that I am really a perl and mod_perl fan.

As far as perl is concerned, as a programming language : there are people who like it, and 
others who don't, and it is quite pointless to try to convert the ones into the others.
But if what you want is a programming tool which allows you to do many different things 
quickly - even things of which you initially know very little about - there is still no 
real alternative to the conjunction of perl and the CPAN library.







On 22.12.2020 06:49, Matthias Peng wrote:
 > Hello
 >
 > I am developing a simple mp2 application.
 > I looked for the installation for mp2 utils, and found this two:
 >
 > libapache2-mod-perl2
 >
 > libapache2-mod-apreq2
 >
 >
 > what're their relations? Should I install both, or only the first one?
 >

Hi.

They are different and independent packages and module libraries, and you 
can use the one
or the other, or both, depending on your needs.
(We always install both, and we use both)

For mod_perl per se, you need only the /libapache2-mod-perl2/ package.
This gives you access to all the stuff documented here :
http://perl.apache.org/docs/2.0/api/index.html
<http://perl.apache.org/docs/2.0/api/index.html>

*except* what is at the very end of that page :

"Part VI: Related Modules" -> libapreq modules
(this is wh

Re: Confused about two development utils [EXT]

2020-12-25 Thread tomcat/perl

Hello James.
Bravo and many thanks for this excellent overview of your activities. Of course the setup 
(in your previous message) and the activities are very impressive by themselves.
But in addition, even though your message is not in itself a perl advocacy message, I feel 
that it would have its right place in some perl/mod_perl advocacy forum, because it 
touches on some general idea which are valid /also/ for perl and mod_perl.
It was very refreshing to read for once a clear exposé of why it is still important 
nowadays to think before programming, to program efficiently, and to choose the right tool 
for the job at hand (be it perl, mod_perl, or any other) without the kind of off-the-cuff 
general a-priori which tend to plague these discussions.


And even though our own (commercial) activities and setups do not have anything even close 
to the scope which you describe, I would like to say that the same basic principles which 
you mention in your exposé are just as valid when you scale-down as when you scale-up.

("--you can’t just throw memory, CPUs, power at a problem – you have to
think – how can I do what I need to do with the least resources..")
Even when you think of a single server, or a single server rack, at any one period in time 
there is always a practical limit as to how much memory or CPUs you can fit in a given 
server, or how many servers you can fit in a rack, or how many additional Gb of bandwidth 
you can allocate per server, beyond which there is a sudden "quantum jump" as to how 
practical and cost-effective a whole project becomes.
In that sense, I particulary enjoyed your examples of the database and of the additional 
power line.



On 24.12.2020 02:38, James Smith wrote:
We don’t use perl for everything, yes we use it for web data, yes we still use it as the 
glue language in a lot of cases, the most complex stuff is done with C (not even C++ as 
that is too slow). Others on site use Python, Java, Rust, Go, PHP, along with looking at 
using GPUs in cases where code can be highly parallelised


It is not just one application – but many, many applications… All with a common goal of 
understanding the human genome, and using it to assist in developing new understanding and 
techniques which can advance health care.


We are a very large sequencing centre (one of the largest in the world) – what I was 
pointing out is that you can’t just throw memory, CPUs, power at a problem – you have to 
think – how can I do what I need to do with the least resources. Rather than what 
resources can I throw at the problem.


Currently we are acting as the central repository for all COVID-19 sequencing in the UK, 
along with one of the largest “wet” labs sequencing data for it – and that is half the 
sequenced samples in the whole world. The UK is sequencing more COVID-19 genomes a day 
than most other countries have sequenced since the start of the pandemic in Feb/Mar. This 
has lead to us discovering a new more transmissible version of the virus, and it what part 
of the country the different strains are present – no other country in the world has the 
information, technology or infrastructure in place to achieve this.


But this is just a small part of the genomic sequencing we are looking at – we 
work on:
* other pathogens – e.g. Plasmodium (Malaria);
* cancer genomes (and how effective drugs are);
* are a major part of the Human Cell Atlas which is looking at how the expression of genes 
(in the simplest terms which ones are switched on and switched off) are different in 
different tissues;

* sequencing the genomes of other animals to understand their evolution;
* and looking at some other species in detail, to see what we can learn from them when 
they have defective genes;


Although all these are currently scaled back so that we can work relentlessly to support 
the medical teams and other researchers get on top of COVID-19.


What is interesting is that many of the developers we have on campus (well all wfh at the 
moment) are all (relatively) old as we learnt to develop code on machines with limited CPU 
and limited memory – so that things had to be efficient, had to be compact…. And that is 
as important now as it was 20 or 30 years ago – the data we handle is going up faster than 
Moore’s Law! Many of us have pride in doing things as efficiently as possible.


It took around 10 years to sequence and assemble the first human genome {well we are still 
tinkering with it and filling in the gaps} – now at the institute we can sequence and 
assemble around 400 human genomes in a day – to the same quality!


So most of our issues are due to the scale of the problems we face – e.g. the human genome 
has 3 billion base-pairs (A, C, G, Ts) , so normal solutions don’t scale to that (once 
many years ago we looked at setting up an Oracle database where there was at least 1 row 
for every base pair – recording all variants (think of them as spelling mistakes, for 
exampl

Re: Moving ExecCGI to mod_perl - performance and custom'modules'[EXT]

2021-02-08 Thread tomcat/perl

On 08.02.2021 10:09, Steven Haigh wrote:

On Sun, Feb 7, 2021 at 15:17, Chris  wrote:

Just remember to always write clean code that resets variables after doing 
tasks.


I'm a bit curious about this - whilst I'm still testing all this on a staging environment, 
how can I tell if things can leak between runs?


Is coding to normal 'use strict; use warnings;' standards good enough?


Hi. Read this, carefully :
http://perl.apache.org/docs/2.0/user/troubleshooting/troubleshooting.html#Variable__x_will_not_stay_shared_at

In particular the example below "An Easy Break-in".
(and replace
use vars ($authenticated);
by
our $authenticated;
)

("use vars" is deprecated, see https://perldoc.perl.org/vars)

The point is :
- imagine an Apache Prefork starting 5 children
- each child, when it starts, contains its own fresh copy of the perl 
interpreter
- requests which come in, are directed by the main Apache, to any child that is free at 
the time.
- when a child runs your script/module for the first time (with its particular perl 
interpreter), the script/module gets compiled, and then run, and the compiled code is 
cached by the corresponding perl interpreter
- global variables (such as $authenticated here) get defined during compilation, so are 
part of the cached script/module code.
- so the first time an Apache child runs your script, $authenticated is defined, but 
"empty" (undef). Then when the script runs, it assigns a value to it, so it is no longer 
undef.
- the next time your script is run *by the same Apache child*, the cached compiled version 
of the script is used (*), which already has $authenticated defined, and the previous 
value (set by the previous run) is still in it.
However, if it happens that the next request is run by another "fresh" Apache child, that 
one (its own instance of the perl interpreter) does not yet have a pre-compiled version of 
your script, so it gets compiled again, and in that instance $authenticated gets defined 
again, empty.


Since you cannot control which Apache child runs your script the next time you issue a 
request, the result may appear random (as far as $authenticated is concerned).


This "feature" can sometimes be very useful as an optimisation (for example, if you want 
to initialise a complex read-only structure only once per Apache child life), but in the 
general case, it will lead to strange things happening if you are not careful.


So to answer your question : "> how can I tell if things can leak between 
runs?",
a quick answer would be : just *assume* that everything "leaks" between runs, and make 
sure that you initialise every variable in a known way, before using it.


mod_perl is great fun, and the ability to run perl scripts much faster is only the tip of 
the iceberg.  But like every fun thing, it has some minor quirks like that. Do not let 
them discourage you.


(*) that's the point, and that's why it is much faster



Are there other ways to confirm correct operations?

--
Steven Haigh 📧 net...@crc.id.au <mailto:net...@crc.id.au>💻 https://www.crc.id.au 
<https://www.crc.id.au/>




Re: Moving ExecCGI to mod_perl - performance and custom 'modules' [EXT]

2021-02-11 Thread tomcat/perl
Isn't this discussion about connection pools and firewalls etc getting a bit far from the 
initial subject of the thread ?


On 09.02.2021 23:03, Mithun Bhattacharya wrote:
I would consider mine a small setup on an internal network and I have used both Sybase and 
SQL Server. In our case the DBA's preferred us to remain connected rather than make too 
many connections - we need DB access in bursts - it could be quiet for more than an hour 
and then suddenly we might need hundreds of connections within few minutes (if we didnt 
cache it). Another thing was we were connecting from forked processes so at some point 
everything gets reaped including the connections. Our style of coding has been to connect 
to the DB wherever we actually need to fire one or more SQLs and do connect_cached in the 
actual implementation (it is a separate library since we had to place a wrapper to 
acquire credentials)


On Tue, Feb 9, 2021 at 2:34 PM James Smith mailto:j...@sanger.ac.uk>> wrote:

Mithun,

I’m not sure on what scale you work – but these are from experience in 
sites with
small to medium load – and we rarely see an appreciable gain in using 
cached or pooled
connections, just the occasional heartache they cause.
If you are working on small applications with a minimal number of databases 
on the DB
server then you may see some performance improvement (but tbh not as much 
as you used
to – as the servers have changed) Unfortunately I don’t in both my main and 
secondary
roles, and I know many others who come across these limitations as well.

I’m not saying don’t use persistent or cached connections – but leaving it 
to some
hidden layers is not necessarily a good thing to do – it can have 
unforeseen side
effects {and Apache::DBI & PHP pconnect have both shown these up}

If you are working with e.g. with MySQL the overhead of the (socket) 
connection is
very small, but having more connections open to cope with persistent 
connections
{memory wise} often needs specifying a much large database server – or not 
being able
to do all the nice tricks to in memory indexes and queries [to increase 
query
performance]. Being able to chose which connections you keep open and which 
you
open/close on a per request basis gives you the benefits of caching without 
the risks
involved [other than the “lock table” issue].

__ __

__ __

*From:*Mithun Bhattacharya mailto:mit...@gmail.com>>
*Sent:* 09 February 2021 18:34
*To:* mod_perl list mailto:modperl@perl.apache.org>>
*Subject:* Re: Moving ExecCGI to mod_perl - performance and custom 
'modules' [EXT]

__ __

Connection caching does work for most use cases - we have to accept James 
works in
scenarios most developers can't fathom :) 

__ __

If you are just firing off simple SQL's without any triggers or named 
temporary tables
involved you should be good. The only times we recall tripping on cached 
connection is
when two different code snippets tried to create the same temporary table. 
Another
time the code was expecting the disconnect to complete the connection 
cleanup.

__ __

On Tue, Feb 9, 2021 at 11:47 AM Vincent Veyron mailto:vv.li...@wanadoo.fr>> wrote:

On Sun, 7 Feb 2021 20:21:34 +
James Smith mailto:j...@sanger.ac.uk>> wrote:

Hi James,

 > DBI sharing doesn't really gain you much - and can actually lead you 
into a
whole world of pain. It isn't actually worth turning it on at all.
 >

Never had a problem with it myself in years of using it, but I wrap my 
queries in
an eval { } and check $@, so that the scripts are not left hanging; 
also I have a
postgresql db ;-).

I ran some tests with ab, I do see an improvement in response speed :

my $dbh = DBI->connect()
Concurrency Level:      5
Time taken for tests:   22.198 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      8435000 bytes
HTML transferred:       8176000 bytes
Requests per second:    45.05 [#/sec] (mean)
Time per request:       110.990 [ms] (mean)
Time per request:       22.198 [ms] (mean, across all concurrent 
requests)
Transfer rate:          371.08 [Kbytes/sec] received

my $dbh = DBI->connect_cached()
Concurrency Level:      5
Time taken for tests:   15.133 seconds
Complete requests:      1000
Failed requests:        0
Total transferred:      8435000 bytes
HTML transferred:       8176000 bytes
Requests per second:    66.08 [#/sec] (mean)
Time per request:       75.664 [ms] (mean)
Time per request:       15.133 [ms] (mean, across all concurrent 
requests)
Transfer rate:          544.33 [Kbytes/sec] received


-- 


                             

Re: Moving ExecCGI to mod_perl - performance and custom 'modules' [EXT]

2021-02-12 Thread tomcat/perl
My comment was just basically so as to avoid the case where someone else would later be 
searching the archives of this mailing list for information about DBI, and never find 
these (useful for DBI) posts, because DBI is not in the subject.


On 12.02.2021 00:51, Chris wrote:

On Thu, Feb 11, 2021 at 09:52:16AM +0100, André Warnier (tomcat/perl) wrote:

Isn't this discussion about connection pools and firewalls etc getting a bit
far from the initial subject of the thread ?


Perhaps. But this has become a pretty low volume mailing list.
This "thread" has moved me to spend hours looking at changing and/or
better understanding the work I have done (pretty old code) and the
work I am now starting.

For me, I'm re-reading the manual pages for the DBI modules,
etc. I've also added another mailing list to follow about DBI.

And I will now have some threads to add in the near future.
Threads I wouldn't have thought of.
But this isn't my mailing list, so breaking these topics into new
threads is just fine. Not a problem at all. 8-)

Recently, something "clicked on" for me about mod_perl.
Which is pretty thrilling for me. ;-}

Chris




On 09.02.2021 23:03, Mithun Bhattacharya wrote:

I would consider mine a small setup on an internal network and I have
used both Sybase and SQL Server. In our case the DBA's preferred us to
remain connected rather than make too many connections - we need DB
access in bursts - it could be quiet for more than an hour and then
suddenly we might need hundreds of connections within few minutes (if we
didnt cache it). Another thing was we were connecting from forked
processes so at some point everything gets reaped including the
connections. Our style of coding has been to connect to the DB wherever
we actually need to fire one or more SQLs and do connect_cached in the
actual implementation (it is a separate library since we had to place a
wrapper to acquire credentials)

On Tue, Feb 9, 2021 at 2:34 PM James Smith mailto:j...@sanger.ac.uk>> wrote:

 Mithun,

 I’m not sure on what scale you work – but these are from experience in 
sites with
 small to medium load – and we rarely see an appreciable gain in using 
cached or pooled
 connections, just the occasional heartache they cause.
 If you are working on small applications with a minimal number of 
databases on the DB
 server then you may see some performance improvement (but tbh not as much 
as you used
 to – as the servers have changed) Unfortunately I don’t in both my main 
and secondary
 roles, and I know many others who come across these limitations as well.

 I’m not saying don’t use persistent or cached connections – but leaving it 
to some
 hidden layers is not necessarily a good thing to do – it can have 
unforeseen side
 effects {and Apache::DBI & PHP pconnect have both shown these up}

 If you are working with e.g. with MySQL the overhead of the (socket) 
connection is
 very small, but having more connections open to cope with persistent 
connections
 {memory wise} often needs specifying a much large database server – or not 
being able
 to do all the nice tricks to in memory indexes and queries [to increase 
query
 performance]. Being able to chose which connections you keep open and 
which you
 open/close on a per request basis gives you the benefits of caching 
without the risks
 involved [other than the “lock table” issue].

 __ __

 __ __

 *From:*Mithun Bhattacharya mailto:mit...@gmail.com>>
 *Sent:* 09 February 2021 18:34
 *To:* mod_perl list mailto:modperl@perl.apache.org>>
 *Subject:* Re: Moving ExecCGI to mod_perl - performance and custom 
'modules' [EXT]

 __ __

 Connection caching does work for most use cases - we have to accept James 
works in
 scenarios most developers can't fathom :) 

 __ __

 If you are just firing off simple SQL's without any triggers or named 
temporary tables
 involved you should be good. The only times we recall tripping on cached 
connection is
 when two different code snippets tried to create the same temporary table. 
Another
 time the code was expecting the disconnect to complete the connection 
cleanup.

 __ __

 On Tue, Feb 9, 2021 at 11:47 AM Vincent Veyron mailto:vv.li...@wanadoo.fr>> wrote:

 On Sun, 7 Feb 2021 20:21:34 +
 James Smith mailto:j...@sanger.ac.uk>> wrote:

 Hi James,

  > DBI sharing doesn't really gain you much - and can actually lead 
you into a
 whole world of pain. It isn't actually worth turning it on at all.
  >

 Never had a problem with it myself in years of using it, but I wrap my 
queries in
 an eval { } and check $@, so that the scripts are not left hanging; 
also I have a
 postgresql db ;-).

 I ran

  1   2   >