Re: mod_perl v2 Forking

2003-09-15 Thread Martin Langhoff
Cameron,

Have you tried issuing the command to `at`?  If you don't need to 
interact wih the report generator, and can pass all the parameters in 
the command line or via a tmp file, this is a great solution.

at (and the corresponding atd) will preserve your environment vars and 
other niceties.

regards,





martin



Re: How to restart the root server from within modperl?

2003-08-14 Thread Martin Langhoff
how can I restart the root httpd server from within modperl?

Use `at` to schedule it a minute in the future -- effectively forking it.

Note that normally apache starts as root and runs as an unprivileged 
user. If this is the case you _can_ achieve it using a suid wrapper or 
sudo, but you'll risk opening a very serious security hole in the 
system. So don't. Instead, run apache as a regular user, on a high port.

If you absolutely need to be in port 80, either setup a simple 
lightweight apache on port 80 as a reverse proxy (see the mod_perl 
guide) or, even simpler, do some port forwarding from port 80 to your 
high port of choice.

regards,



martin




Apache::AuthTicket lookalike for DBM files

2003-04-04 Thread Martin Langhoff
I am looking for a mod_perl implementation of mod_auth_dbm that takes
cookies instead of HTTP-AUTH Basic. Or perl implementation of
mod_auth_cookie, perhaps (I think mod_auth_cookie does exactly that).
I was sure I would find it in CPAN, and, sure enough, AuthTicket and
others are there, offering far more than I was expecting... But I could
not find one that deals with NDBM files. A search for Apache::Auth* is
not returning likely candidates.
Unless there is a DBI/DBD driver that would allow using NDBM files with
AuthTicket? There doesn't seem to be any :(
I am tempted to add NDBM support to AuthTicket but I am 99.9% certain
that there _has_ to be a module providing the functionality I am
thinking of.
Just to clarify, I don't need the 'ticket' mechanism, just cookie-based
auth against DBM files, with the same options that mod_auth_dbm offers.
Oh, and lazyness is one of my virtues ;)
cheers,



martin
--



Anyone using virtual server for mod_perl hosts?

2001-01-30 Thread Martin Langhoff

hi,

due to some fairly complex issues (money, or lack thereof), I am
considering turning a mod_perl server from co-location into a 'virtual
server' service, like Verio offers. 

Far from asking if it is a good solution (I know it is not) I'd like to
know if its feasible. I have been managing remote co-located servers for
quite a while, so I am already used to the impotence of not being able
to kick the box when it misbehaves. In fact, last time I got really
angry at a box I got a my fist cut, hitting it. So remote boxen might
turn out to be healthier for my temper ;)

Is anyone using a 'virtual server' succesfully? Or have a horror story?
Know of companies other than verio? 

Oh! and before anyone points it out, yes, it low -- low -- low traffic.
The current server never gets more than 0.5 load average.




Martin



Repost: Anyone using virtual server for mod_perl hosts?

2001-01-30 Thread Martin Langhoff


As many people understood I mean some kind of virtual host service, I
would like to restate my question.

There are companies (Verio at least) offering a 'virtual machine'
running a virtualized OS. Verio is offering NetBSD and Solaris. They
have a seriouly large iron where many virtual machines run, each virtual
machine gets a share of CPU, HD and RAM resources, an at least an IP
address. 

In there is a full OS, and you get to be root for about $150 a month.
It's a cheap alternative to co-location, a middle ground between a good
virtual hosting service and owning a box. You can run your own MTA,
compile whatever the hell you want, etc, although they offer a bunch of
services out-of-the-box and have a lot of useful --if annoying-- cron
jobs rotating your logs, monitoring the temperature of your daemons,
feeding the dog and whatnot. 

Of course, you get to share resources with a bunch of other customers.
It seems a great environment to set up a low traffic / highly customized
server, like apache+mod_perl. Now, I know and understand the services
they offer, but I have never actually used one with mod_perl. 

Now, has anyone tried this services? Do I have to worry about anything?
Why didn't Stas list them in his article? -- they don't appear in the
Guide either -- Do they have a fundamental or practical flaw I can't
see? 



Martin



Re: Repost: Anyone using virtual server for mod_perl hosts?

2001-01-30 Thread Martin Langhoff

Blue Lang wrote:
 
 Woah.. I had never heard of this. Have you actually been on a box? I'm
 calling them to see if a demo is available.
 

 I have been on such a box, once. Unluckily, I wasn't root, so I could
not do much there. Of course, if someone is eating up resources, I'll
have to fight them... spawn a few mod_perl processes in core, and I
guess every other virtual machine will be running from swap ;)


m



Re: Making PHP and mod_perl live together in Apache 1.3.14.

2001-01-27 Thread Martin Langhoff

Mr Wells,

I have succesfully built them together following this procedure. I am
also including mysql and imap support in PHP. Be aware that many lines
that should be a 'one-liner' have been broken by my mailer. 

untar apache 1.3.12, mod_perl 1.24, php 4.0.3 and c-client (from uw)

# build imap client code
cd imap-2000.RELEASE-CANDIDATE.7/
make lnp

# make some symlinks required by PHP
ln -s /usr/src/downloaded/imap-2000.RELEASE-CANDIDATE.7/ lib
ln -s /usr/src/downloaded/imap-2000.RELEASE-CANDIDATE.7/ include

# prep Apache [PHP needs it]
cd ../apache_1.3.12
./configure

# prep PHP 
# To avoid conflicts with mod_perl's DBI, we need to tell 
# it to use the system's mysql client, usually found at /usr 
# you can find it with `locate mysql.h`
cd ../php-4.0.3
./configure --with-apache=../apache_1.3.12 --enable-track-vars
--with-imap=/usr/src/downloaded/imap-2000.RELEASE-CANDIDATE.7/
--with-mysql=/usr
make ; make install

# prep mod_perl segn INSTALL.apaci
cd ../mod_perl-1.24
perl Makefile.PL EVERYTHING=1 PERL_TRACE=1
APACHE_SRC=../apache_1.3.12/src DO_HTTPD=1 PREP_HTTPD PERL_MARK_WHERE=1
USE_APACI=1
make
make install

# with this conf, the resulting apache is a STATICALLY LINKED APACHE
cd ../apache_1.3.12
./configure --prefix=/usr/local/apache.heavy
--activate-module=src/modules/perl/libperl.a --with-layout=Apache
--enable-module=all --activate-module=src/modules/php4/libphp4.a
make 
make install

# to make it shared, use --enable-shared=max 



[OT] All of Perldocs to HTML files

2001-01-16 Thread Martin Langhoff

Hi,

I know this is is wy OT. Kick me privately, please. I am looking
for a way to dump all of the available perldocs into an organized HTML
structure. Activestate people are doing it in their standard distro --
but I couldn't find how. They even get cross-module links ("See Also")
just fine. 

Is there a know script for that? A canonical way to do it?



Martin



[OT] Problems preparing a module for CPAN

2000-12-28 Thread Martin Langhoff

hi,

once again, steering off-topic ... :(

I've got a nice little module (Mail::Vmailmgr) I am trying to bundle in
the standard CPAN fashion, so that it has a proper Makefile.PL, etc.

I am following my Perl Cookbook, recipe 12.8 ... steps taken:

% h2xs -AX -n Mail::Vmailmgr
% cd Mail/
% vi Vmailmgr.pm 

and wrote all of my module there, picking what h2xs had prepared.
Now when I follow the next step, it fails:

% make dist
make: *** No rule to make target `dist'.  Stop.

And neither `man perlmod`, `man perlmodlib`, CPAN or O'Reilly's errata
page has any hint ... 

Now many fellow hackers here seem to be releasing successfully to
CPAN... so ... what's the secret? What am I missing? (a neuron or two,
maybe?)


martin



[OT]Problems with `use locale`

2000-12-20 Thread martin langhoff

hi,

sorry for being so OT. The problem is showing up in a mod_perl app, but
it's certainly not related at all. 

Dealing with Spanish as we are, we always have problems with regexp,
uc() and lc(). I've found that on my dev box, just adding `use locale`
at least uc() and lc() would work allright (meaning ñ got changed into Ñ
properly).

Now I've built a customer's machine with a newer distro and my uc() is
broken where it was working. 

The devbox has RHLinux 6.1 and perl 5.005_03-6
The customer's box has RHLinux 6.2 and perl 5.005_03-10

And the output of `locale` and `locale -a` is identical on both boxes.
Unluckily I'm not about to downgrade the box to 6.1 ... it's a complex
Compaq beast that doesn't like 6.1 ...

Have you seen anything similar? have any pointers? flames? rants? 

Thanks!



martin



Re: Email (mod_perl) Apache module?

2000-12-15 Thread martin langhoff

Jeremy Howard wrote:
 IMHO, the best open source WebMail servers are PHP based

true, I am using and patching TWIG quite a lot, and that made me see how
messy PHP gets when dealing with libraries and things. It's not nice to
see a large app written in PHP... at least not this one.

I have this dangling idea of building a TWIG lookalike (in Perl), with
a 'plug-in'/'module' structure, so I may write the email client, and
others fill with their desired modules. Anyway, it's a seriuos
undertaking, but it's in my plans to rip as much code and design choices
from stable OS webmails as possible.

It's  just a way to soak up all my holidays in perl code ... 




martin



Re: Email (mod_perl) Apache module?

2000-12-15 Thread martin langhoff

brian moseley wrote:

 (speaking as the author of a proprietary mod_perl
 webmail...)
 
 DO IT!!

my fear is that writing it as a mod_perl app, it'd be terribly niche,
and we wouldn't get it rolling. I'd rather write a bunch of modules,
that can be called from a CGI or a templating system. 

Then those modules can be reused on other apps.

Plus, we should be writing that is pure-CGI compatible -- y'know, we
won't be needing any actual mod_perl hooks, and CGI-compat means is more
usable under other configs, and keeps you honest.



martin



Re: Email (mod_perl) Apache module?

2000-12-15 Thread martin langhoff

Perrin Harkins wrote:

 Is there a reason you don't want to just hack on WING?

I've seen TWIG and its *very* clever, if ugly. It'll let you
authenticate against a lot of things. Use IMAP or POP. Use News. Use
mysql, Postgres, MySQL, or none. Use cookies or encoded links for state.
It's *very* flexible, and I've come to like that a lot. 

That's why I'd like to base most of my design choices on it. 



martin



Mem Sizing tool [was: splitting the code sets across more than one mod_perl server]

2000-12-13 Thread martin langhoff


hi,

[now to the list, also]

maybe all of these mathematical formulae can be made into a
smallish perl script that grabs this info from `top ax`. I am not sure
that top is the proper source of memory usage across platforms.

In fact, as I am not a unix old-timer, I should be asking
*where* to get that info reliably from. With that info, I could prepare
such a script ... it'd be quite useful, I'm building a few servers with
very low memory.

Stas wrote (privately) that there is no consistent cross platform
command that will reliably report memory usage for a given set of
processes. He also mentioned Apache::GTop, but I was thinking about an
external script. A script I can call from the command line and will
evaluate my three HTTPDs and their children, and report global and
detailed memory usage. 

It should be a general purpose tool, not something mod_perl-dependant
at all. It might be system dependant, of course. It could be checking
what OS it's on and call the proper command accordingly.



martin



Re: Smart installing (Re: mod_perl advocacy project resurrection)

2000-12-07 Thread martin langhoff

"Aaron E. Ross" wrote:

database abstraction and connection pooling = DBI
session management  = Apache::Session
load balancing  = mod_backhand??
data relational mapping = Tangram or Alzabo
templates or whatever you want to call them = HTML::Embperl/Mason/TemplateToolkit
ide = pick an editor with a few hooks to call make, install and restart


I'd say that load balancing is too involved an issue to make it
into a
package, I'd leave it aside, as anyone actually needing it will be
certainly building his apaches manually.

And I would also leave the IDE aside, (although I think I have a
great
candidate[1]). IDEs are very personal things, and users are sometimes
very attached to theirs ... so much that merely installing an IDE is
sometimes an offence.

[1] Having grown up in a cushioned, fancy VB 3.0 IDE, I still
find both
vi, emacs and textmode debug too harsh for me. So I've been toying with
the early releases of Komodo
(http://www.ActiveState.com/Products/Komodo.html) and I actually like it
although its far from finished. Has anyone used/tested it? 



martin

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: debuggers

2000-12-07 Thread martin langhoff

Perrin,

In fact, I've always been coding from NT machines -- for my *nix
servers, of course. Now the ActiveState people are building a
cross-platform and cross-language IDE that integrates with perldebug
nicely -- or so it seems. I'm actually starting to like it -- it's built
on top of mozilla, so its a bit bloated and slow -- but I like it, just
like mozilla ;)

And, on top of that, it's called Komodo, and that means 'comfort' -- in
Spanish, that is. 

All this talk about DDD is making me wonder if there is a suitable
(graphical) Perl IDE that I can run on Gnome. If there's one, maybe I'll
change my dev workstation from an NT box to RHLinux 6.1 ... 

Well, there's Komodo, for instance ;)


martin
pd: of course, in Spanish you'd say cómodo -- with a stress on the first
o.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: debuggers

2000-12-07 Thread martin langhoff

Perrin Harkins wrote:
 
 I don't know how easy it is to make it play with
 mod_perl though.  Apache::Debug normally just dumps you into the shell
 debugger.  Maybe setting an environment variable would do it.
 

I've always considered mod_perl to be completely debugger-unfriendly.
That's why I write modules that I can test from a standard script, and
then call those modules from Embperl pages or Registry scripts. 

I wonder how do those hardcore guys that develop using handlers debug.
Mhhh. They must write 'perlfect' code, I guess, and/or understand those
cryptic debuggers ...



martin

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: RFC: mod_perl advocacy project resurrection

2000-12-05 Thread martin langhoff

kevin montuori wrote:

   additionally, i think that some consideration should be given to
   how mod_perl is packaged. 


I think it's of crucial importance the fact that a distro as widespread
as RHLinux 6.x had mod_perl messed up. That has forced quite a lot of
developers that were trying to get their feet wet with mod_perl to get
in a complex compile sequence. That's a source of 'bad reputation', and
of php developers, as the included php was old but working ;)

I don't know how messed up are other distros regarding apache/mod_perl,
but making sure the main distros *do* get it right is paramount to make
mod_perl catch. 

Another item that we should really have is a good (and somehow
sanctioned) RPM that replaces the apache rpm (or deb) included in broken
distros. Then we can include in the guide and related pages a link for
[broken-distro-name] users, so they get a suitable replacement with a
similar config. That's an important issue, because a redhat user has
other non-standard modules included in his rpm, such as PHP, and
compiling a *complete* apache, with mod_perl, php and the kitchen sink
is a daunting task -- and too high an entry price. 

anyway, not an easy task ... mmhhh..



martin

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: RFC: mod_perl advocacy project resurrection

2000-12-05 Thread martin langhoff

Eric Strovink wrote:
 
 A number of people have been beating around this bush, so why not just mow it down?
 
 A huge win for advocacy would be a small set of complete example applications
 targetted at, say, the last two RedHat distros.  

I see a suitable target there ... maybe a SRPM bundling:

Apache + mod_perl + libapreq + DBI + DBD::Mysql + HTML::Embperl +
Apache::ASP + Template Toolkit ... 

I guess it's important that we build a SRPM so the build sequence uses
the local perl intallation



martín

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




OT: packing and unpacking help!

2000-11-23 Thread martin langhoff

hi,

sorry to bother the list, but I'm stuck trying to convert this code
into something more elegant, using pack() ... 

my $commandlength = length $command;
my $high= (($commandlength  (255  8))  8);
my $low = ($commandlength  255);
my $commandstr  = sprintf("\002%c%c%c", $high, $low+1, scalar @arg -1) .
$command;

the code is not mine, of course -- I don't know a drat about shifting
bits around--, its a rough conversion of some php code that we're using
in a module to administer qmail+vmailmgr via web-forms. the resulting
$command is going to be sent through a socket to a daemon that takes
care of administering the email server. 


of course, if anyone is willing to tell me to RTFM and stop posting OT,
I'd be more than thankful if he/she includes a link to the FM (besides
perldoc, of course).




martin

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: [OT] mod_perl evangelism

2000-11-14 Thread martin langhoff



[EMAIL PROTECTED] wrote:

 Having such tutorials will bring more crowds to mod_perl commutity. 

The mod_perl commutiny? I think I like it...



PerlSetEnv leaking outside its intended(?) scope

2000-11-10 Thread martin langhoff

hi list,

I guess it has to do with my terrible ignorance, but I had always
thought that PerlSetEnv placed inside a VirtualHost would be visible
only inside that particular vhost.

Re-reading the F***ing Manual (that is, The Guide), I find no clear
evidence of this. 

So, if
virtualhost foo.com
...
PerlSetEnv FOO true
/virtualhost

virtualhost bar.com
...
# PerlSetEnv FOO true   
/virtualhost

will scripts/handlers placed in bar.com be able to read $ENV{FOO} ?


martin



sharing Auth across proxied apaches

2000-11-09 Thread martin langhoff

hi,

I'm having a big headache with a complex Auth scheme I must implement.
It seems I'll have to code quite a bit anyway, but I'm pondering the
options I have. Currently, the server setup looks like this:

- apache.plain : running at port 80, serving all static content and
proxying (with mod_rewrite + mod_proxy) all dynamic requests to the
backend daemons.

- apache.perl : running at port 1800, serving all Apache::Registry and
HTML::Embperl content. Few children.

- apache.php : running at port 1801, serving PHP pages. Few children.

Now, I'm developing a complex website full of services. Some of these
services (webmail and various groupware apps) are provided by a patched
TWIG (a PHP app). All the other services will be provided by mod_perl
scripts. The user will be browsing across these services, unaware of the
different platforms I'm implementing for each service, but I need to
present one single point of authentication, and then share that
information across the 3 apache servers. 

The authentication will be done against a user/pw pair that is in a
mySQL. This same usr/pw auth data is valid against the IMAP server I'm
using. TWIG in fact can be configured to authorize against the IMAP
server. 

TWIG will track the user with cookies or encoding each link with a
token. I cannot follow the 'token' path because then I cannot link
'into' a TWIG page from a static page. So I'm stuck with using TWIG's
cookies, although right now I'm having problems as they seem to dislike
the proxying ... 

The TWIG Auth interface can be chosen to be FORMS, so I can fake it
POSTing or GETting the usr/pw pair at the right time. Also, if I can get
the information there (in %ENV, for instance), I may be able to hack
TWIG into believing the user has authenticated. 

Possible Solutions I'm pondering (and I do need some more!@):

A - Authenticate at the proxy, against a DBM build from the mySQL table.
Then pass the Auth information to the backend servers, maybe encoding it
in the url with mod_rewrite. 

B - Authenticate at TWIG, let it set its cookie, and use TWIG's cookie.
Of course, it menas I'll have to understand TWIG's cookie, and that it
may be impossible to use if the cookie uses some kind of 'secret' (on
the other hand, TWIG uses mySQL tables to keep state, so I might learn
to read TWIG's mySQL tables).

C - Authenticate at mod_perl and learn to fake TWIG's cookie. A bit more
complex, but basicallythe same as B.

D - Build one behemoth of an apache, (maybe discard all proxying) and
build mod_perl + mod_php. Then I can set the ENV vars from mod_perl,
authenticate using Apache::AuthCookie and pick up the Auth info in TWIG
just from the ENV. 


whew! a long post indeed. Well, those are my draft ideas. Anyone care
to comment before I choose one at random and start coding headlong?


martin



Re: conflicts between mod_perl and php4

2000-11-08 Thread martin langhoff

Andreas,

compile PHP *without* mysql support. Read the PHP docs, it's there...
don't worry, it'll still be able to use mysql connections...

Andreas Gietl wrote:
 i've got the following configuration:
 apache_1.3.12 with php and mod_perl statically linked. Php has
 compiled-in mysql-support and mod_perl of course uses DBI.



Re: how to really bang on a script?

2000-10-28 Thread martin langhoff

Chris,

i'd bet my head a few months ago someone announced an apache::bench
module, that would take a log and run it as a benchmarking secuence of
HTTP requests. just get to the list archives and start searching with
benchmarks and logs. CPAN is your friend, also.

there are at least 2 or 3 benching perl scripts available. I bet at
least one does what you need. but I may still loose my bet ... 




m



AARRRGH! The Apache Proxy is not transparent wrt cookies!

2000-10-19 Thread martin langhoff

hi,

after a lot of struggling, I finally set my multilayered apaches up,
and now I find that the proxy is eating my cookies along the way...
HEELP!

I am proxying through mod_rewrite commands, if that actually makes a
difference ... 


martin



[OT] Will a cookie traverse ports in the same domain?

2000-10-19 Thread martin langhoff

hi,

this HTTP protocol (definition and actual implementation) question is
making me mad. Will (and should) a cookie be valid withing the same
host/domain/subdirectory when changing PORT numbers?

All my cookies have stopped working as soon as I've set my mod_perl
apache on a high port with a proxying apache in port 80  [ see thread
"AARRRGH! The Apache Proxy is not transparent wrt cookies!" ]






martin



[OT]logging Apache processes w/rotatelogs

2000-10-17 Thread martin langhoff

hi,

is anyone using rotatelogs ? 

I have a bunch of virtualdomains, each with its own, separate log. Then
I'm running three different apache binaries (that resulting in a whole
lot of daemons). Now I'm trying to use rotatelogs, and I find the pipes
are kept open, so I have a *lot* of rotatelogs processes running. 

A *LOT* of them, believe me.

They don't seem to hurt the load averages nor the memory, but I wonder
if there might be any problem running so many of them, like, erm,
hitting a max-processes count?


martin



[mod_rewrite] Remember to set your logLevel down!

2000-10-09 Thread martin langhoff

hi,

I've got a 2 tier apache setup running a lightweight apache with
mod_rewrite proxying *.pl requests to the heavyweight apache. I'm
posting this to share a bit of practical info on how to build such a
setup on a per-file basis, as the Guide only deals with per
domain/directory rewriting/proxying.

The aim is to proxy requests to a mod_perl enabled apache running on a
high port, based on file extension, and enabling a transparent
transition from a monolothic one-apache setup to a 2 tier setup. As a
matter of fact, I keep a single apache on my dev box, and I'm upgrading
the production server to handle static + CGI + server-parsed content
with apache.plain, and proxy Registry and Embperl to apache.perl
(running on port 1800). Additionally, requests for any PHP content will
be proxied to apache.php at port 1801.

To achieve this, I used to have in httpd.conf

RewriteEngine ON
RewriteLogLevel 3
RewriteLog /projects/webserver/logs/rewrite_log
RewriteCond %{REQUEST_FILENAME}  \.(pl|ehtml)$
RewriteRule ^/(.*)   http://%{HTTP_HOST}:1800/$1 [P]

The issue is that PLAIN requests, that do not get proxied are getting a
performance hit because each hit executes 2 regexes on the URL: the
RewriteRule and the RewriteCond. At the beggining, I was horrified at
the performance, because I had logging on.  See:


Without Rewriting: 510 requests per second
With LogLevel 0: 418 req/s
With LogLevel 1: 365 req/s
With LogLevel 3: 300 req/s

Calling test.pl at port 1800: 85 req/s
Calling test.pl through proxy: 70 req/s

One of the interesting things I found is that the statically compiled
apache.perl serves static content a little slower than the mod_so
(ENABLE_SHARED=MAX) apache.plain: 510 req/s against 470 req/s. My guess
is that the extra handlers that mod_perl registers slow down things a
bit more than the usage of mod_so (which the docs estimate to be 5%). 


martin



Re: $r-header_only question (feeling a newbie!)

2000-10-03 Thread martin langhoff

 martin,
 check out:
 http://www.ora.com/catalog/wrapmod/errata/wrapmod.699

Well, I guess fair is fair, the correction for page 146 (unless = if)
was there,  I should've done my research better ... 

anyway I do seem to be needing 'use Apache::Constants qw(:common);' to
run under strict and ^W=1 ... 



martin



$r-header_only question (feeling a newbie!)

2000-10-02 Thread martin langhoff

hi,

I've been developing with mod_perl for a while, but, thanks to
Richter's Embperl module and the excellent backwards compatibility
(regarding CGI.pm) I had never got anywhere near Apache::Request -- for
production, that is. 

Now I have this very silly question, that I've boiled down to this
little snippet of code (which carries a remakable resemblance to the
example found in page 146 of the Eagle Book):
--
#!/usr/bin/perl -w 
use strict;
use Apache::Constants qw(:common); 

my $r = Apache-request;
$r-content_type('text/html');
$r-send_http_header;

return OK unless $r-header_only; # THIS is the line I'm wondering about

$r-print(END);
htmlbodyh1 Hello ! /h1
address martin/address/body/html
END
1;



The issue is that I don't understand clearly what is this line supposed
to do. As it is, it'll make my script return an empty body ('document
contains no data!' said Navigator). Commented out, the proper contents
are sent. Reading the Eagle and `man Apache::Request` led me to thing
that the line is there to stop processing if all the client wants are
the headers (maybe because of a 'If-Modified-Since' parameter?). 

Now  shouldn't it be an 'if' instead of an 'unless'?

Am I too dumb today? Or is it just that it's monday?



martin



Re: $r-header_only question (feeling a newbie!)

2000-10-02 Thread martin langhoff

... it made no difference ... :(

Drew Taylor wrote:
 I believe all you need to add is "return OK;" after your print
 statement. Without that, Apache doesn't know what the status of the
 request should be.



Re: $r-header_only question (feeling a newbie!)

2000-10-02 Thread martin langhoff

Thanks Tim and all,

my gathering is that the sample script on page 146 of the Eagle:
- needed a 'use Apache::Constants(:common);' line
- needed a 'return OK;' line at EOF
- had an 'unless' that should've been an 'if'.

for-the-record, I did check www.modperl.com looking for an
errata.
Doug? Lincoln? I mean, it's one of the *simple* scripts, I do LOVE the
book, but I guess I'll have to trust this list a hunderd times more than
the book.

And, unless it was all my mistake, for some unbeknownst reason,
a few
marks down for O'Reilly technical reviewers :p


martin

Tim Tompkins wrote:
 
 This should be an "if" instead of "unless"
 
 return OK if $r-header_only;
 
 header_only() will return true if the request method is HEAD.  You'll want
 to simply return OK once you've gathered all the necessary outgoing headers
 for HEAD requests.



One httpd.conf for both apache heavy and apache-light [IfModule]

2000-09-30 Thread martin langhoff

hi,

I'm trying to build a 2 tiered Apache setup, with one light httpd, one
mod_perl httpd and a mod_php4 httpd, all running on different ports on
the same machine/IP. Right now I'm solving the mod_rewrite mod_proxy
stuff (I want the light httpd to transparently proxy requests to the 2nd
tier httpd daemons). 

What I see in the not-so distant future is a hell of a configuration
nightmare. From the start, this box should be hosting about 30 vhosts,
and I don't really want to keep them in synch across 3 different files.
So I thought of using a single monolithic  vhosts.conf with lots of
IfModule sections. 

Is anyone using this directive?
Am I getting in a mess? 



martin



Re: One httpd.conf for both apache heavy and apache-light [IfModule]

2000-09-30 Thread martin langhoff

You mean you post-process your httpd.conf ? Phew!

mmmh. I'm flabbergasted (sp?) and certainly mesmerized, can you tell us
a bit more? 

Perrin Harkins wrote:
 Where I work, we use Template Toolkit to generate
 variations from one httpd.conf template.



Re: One httpd.conf for both apache heavy and apache-light [IfModule]

2000-09-30 Thread martin langhoff

Perrin, Robin, et al


at least I don't feel alone on this one :) 

now let me seize the opportunity and (while you're around,
having
admitted you're using a 2 tiered apache setup,) ask you if you are doing
the mod_rewrite/mod_proxy trick, and how were you able to pull it off. 

I'm reading the mod_rewrite guide right now and my head *is*
spinning.



[OT] DNS question (slightly mod_perl related...)

2000-08-31 Thread martin langhoff


the mod_perl related background:

I was recently asked if one of the domains we were hosting could have
its users folders mapped in the domain name. Something like
folder.domain.com, instead of domain.com/folder . My silly mind tumbled
around, mumbling at which apache request I was going to catch the domain
and turn it into a subrequest, and I mumbled 'yes, of course'. 

the catch:

As you may have imagined, it maybe trivial to do in Apache (I haven't
done it yet, but I hope it is). What is not trivial is to trick BIND
into saying it knows as many domains as folders I want. Or is it?

the question:

Is it possible to tell BIND to catch *.domain.com and answer the same
ip? 

the apologies:

I know. I know. I'm way off topic. Delete my msg ... I'm not a BIND
warrior, but a mod_perl developer bound to BIND woes ... 



martin



Re: [OT] DNS question (slightly mod_perl related...)

2000-08-31 Thread martin langhoff

Jim Winstead wrote:
 plan c: use a wildcard record and move on to real problems. :)

Bummer! I had thought I actually had a real problem ... 

gotta move on to find one !


martin [who can't believe this list's so great]



[OT]starting a long running script

2000-08-29 Thread martin langhoff

hi,

i need to start a long-running script from either mod_perl or mod_cgi,
and I'm facing all the well-known issues: the apache child waits, until
it waits no longer (maybe because the browser itself chose to close the
TCP connection, maybe because of an internal timeout), and then the
script gets killed. 

there is no useful information to echo back to the user, besides
teloing him the script started ok.

the problem is: while I'm familiar with the problems, but not with the
solutions. I've read that one possible solution is to use fork(), but I
have no experience with it, and not much understanding of its
implications, and after reading perlfunc I'm more confused than before. 

is there anyone kind enough to tell me where to start Reading TFM or
which particular FM contains useful leads? 

thanks!


martin



Acmemail vs WING (was Re: mod_perl-friendly webmail solutions?)

2000-08-23 Thread martin langhoff

I found the one that Luis suggested, (acmemail) and a few more,
including WING. These 2 are the only ones programmed to take advantage
of mod_perl. I fear the other ones are not mod_perl aware, so the may
not be safe/efficient under mod_perl, so my choices are mainly between
these two. 

Acmemail is nicely documented, and seems 'ready to go' (tempting!),
although I fear it may not be as configurable as I want. Do you know
anything about it? 

WING (http://users.ox.ac.uk/~mbeattie/wing) on the other hand, seems to
offer raw power, but all it offers is a bare webpage without much actual
implementation details. 

please don't think I was bought by the eyecandy in acmemail page
(http://www.astray.com/acmemail), but I need a working solution in a
reasonable timeframe. Acmemail seems to need some tweaking to make it
work. WING, well, either I didn't understand well or needs me to study
the man pages of its modules and design and code an implementation.



Re: Acmemail vs WING (was Re: mod_perl-friendly webmail solutions?)

2000-08-23 Thread martin langhoff

entropic,

is WING something I can deploy and configure/customize (like most
webmail solutions) or should code the interface to get it to work?

does it support imap folders and address books? 

martin

[EMAIL PROTECTED] wrote:
 
 Wing scales well.  Its the 'imap' server where you will have issues. I use
 wing with imap-uw and about 50 'trusted' users.



Apache::Registry spawning zombie shells?

2000-08-22 Thread martin langhoff

hi list,

while doing a silly thing (building a set of HTML files with info from
a DB file), I found that while the apache server was being crawled by
lwp-rget, a lots of zombie shells were being spawned and killed. 

top was telling me that there were quite a few processes like:

 6766 nobody 2   0 00 0 Z   0  0.3  0.0   0:00 sh
defunct

(I was looking at top because I was happy thinking how mod_perl was
speeding it all up)

so I checked and rechecked my code, 2 *very* silly cgi scripts hacked
in a hurry, that I renamed from .cgi to .pl so the crawling finished
faster. the scripts are at the bottom, but I don't think you'll find
much there. 

needless to say, when run under mod_cgi, no sh is ever spawned, and
when the crawling finished no more spawning took place (3 of the zombie
shells remained, though). So it's definitely something with mod_perl and
Apache::Registry. Maybe the DB_File module has something blame? Don't
really know.

these shells are not attached to any console, and they are sh shells,
while I use bash. queer. If it weren't because the server is
*disconnected* from the 'net I'd think the box was 'rooted'.

I've even got to catch the actuall call to sh from ps:

sh -c /bin/csh -cf 'set nonomatch; glob /table' 2/de

what can that mean? I'm off to search ... 


martin

system specs and scripts : 'Apache/1.3.12 (Unix) mod_perl/1.24'
--
Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
osname=linux, osvers=2.2.5-22smp, archname=i386-linux
uname='linux porky.devel.redhat.com 2.2.5-22smp #1 smp wed jun 2
09:11:51 ed
t 1999 i686 unknown '
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
cc='cc', optimize='-O2', gccversion=egcs-2.91.66 19990314/Linux
(egcs-1.1.2
release)
cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include'
ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include'
stdchar='char', d_stdstdio=undef, usevfork=false
intsize=4, longsize=4, ptrsize=4, doublesize=8
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -ldl -lm -lc -lposix -lcrypt
libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'


Characteristics of this binary (from libperl):
  Built under linux
  Compiled at Aug 30 1999 23:09:51
  @INC:
/usr/lib/perl5/5.00503/i386-linux
/usr/lib/perl5/5.00503
/usr/lib/perl5/site_perl/5.005/i386-linux
/usr/lib/perl5/site_perl/5.005



script letra.pl:
---
#!/usr/bin/perl -w


use strict;
use DB_File;


use CGI;
use URI::Escape;

my $cgi = new CGI;
print $cgi-header();
my $letra = $cgi-param('letra');
my %db;

my $records = 0;

tie (%db, "DB_File", 'voluntarios.db') or die $!; 

print 'htmlheadlink rel="stylesheet"
href="fedefa.css"/headbody';
print 'table width="600" border="1" bordercolor="#66"
align="center"';

foreach my $key (sort { lc($a) cmp lc($b) } keys %db){
if ($key =~ /^$letra/io){
$records++; 
print 'tr
td width="21" bgcolor="#FFDBAD"
img src="lib/flecha.gif" width="21" 
height="20"
/td
td bgcolor="#0078B3" width="550"
b';
print $cgi-a( {href='record.pl?record=' . uri_escape($key)} ,
qq{font color="#FF" face="Arial, Helvetica, sans-serif"
size="2"$key/font});
print '/font/b/td/tr';
}
};
unless ($records){
$letra = uc $letra;
print 'tr
td width="21" bgcolor="#FFDBAD"
img src="/fedefa/lib/flecha.gif" 
width="21" height="20"
/td
td bgcolor="#0078B3" width="550"
b';
print qq{font color="#FF" face="Arial, Helvetica, 
sans-serif"
size="2"No hay registros con la letra $letra/font};
print '/font/b/td/tr';
}
print '/table';


print '/body/html';
--
script record.pl
--
#!/usr/bin/perl -w


use strict;
use DB_File;


use CGI;
use 

mod_perl-friendly webmail solutions?

2000-08-22 Thread martin langhoff

hi,

i'm looking around, searching webmail solutions that run without
problems under mod_perl. Although I know there are many, most of them
are not very mod_perl friendly. 

now, the actual questions are

- is anyone here running (successfuly) a mod_perl webmail? 

- Which one? 

- How did you solve the 'create new user' issue? Which MTA are you
using?

- Did you get burned with any particular issue / webmail solution?


martin



mod_perl and the tied interface

2000-08-02 Thread martin langhoff

hi,

i'm using the Tie::DBI interface under some embperl/mod_perl modules,
and, worried about the implications of tying under mod_perl, happily
found Doug as one of the coders/authors of perltie. 

hopefully, Doug's reading and/or someone else can tame my fears. 

I'm tying a hash with Tie::DBI in a sub, and then returning a ref to
that hash, so the tied thing can be used. I somehow expect the hash to
be automagically untied when it goes out of scope, so as far as it
doesn't get trapped inside any persistent var (such as a global or avar
inside a closure) I won't be leaking memory nor keeping database
connections open.

I just want to sleep easy knowing I'm not doing something horribly
wrong. Of course, I'm paying with cpu cycles and ram my terrible
lazyness, I know that. But I won't trade no short term nap for nights
awake because of a crashing/leaking server... as far as I can manage it
of course. 


martin



Re: follow-up: very strange bug w/ tainting

2000-07-27 Thread martin langhoff

Alex, 

did you try this with apache in single process mode (I think it's httpd
-X). Your 30% failure rate seems to mean that your after you execute the
DBI script you only get the same process about 30% of the time.

martin



Re: mod_eprl or PHP

2000-07-26 Thread martin langhoff

Matt Sergeant wrote:
 
 On Wed, 26 Jul 2000 [EMAIL PROTECTED] wrote:
 
  PHP does not require mod_perl. They are completely seperate (and often do not
  like each other when loaded as DSOs).
 
 Has anyone figured out why that is yet?

wasn't it related to conflicting mysql or dbi libraries? i've seen a
few threads that achieved some kind of success disabling PHP's mysql
libraries. 

of course, it's all overheard, so i may well be wrong



martin



Re: module multi-config strategy

2000-07-25 Thread martin langhoff

Perrin,

you mean that I can actually set my environment per virtual-host?

that's encouraging in the one-implementation per site scenario. Now I
does block any use of persistent variables, unless I store them in a
RDBMS or in the 'Globals' module you mentioned. It could really be a
module that just exported references to internal hashes. I'm starting to
like it. 

A module that exported persistent hashes (not across server restarts,
just across requests ... short lived persistence). Maybe it could be
loading the 'config' hashes from disk every once in a while, say every
10 seconds, to be able to reconfig without restarting. And the ability
to commit a given hash ('config') to disk to make it permanent.

mmmh. an idea is shaping here in my tiny head ... anyone care to
comment?



martin

Perrin Harkins wrote:
 
 You can have a module full of globals that is different for each site (it
 doesn't have to go in the same directory as your other shared code), or
 you can put things in httpd.conf with PerlSetVar and read them with
 $r-dir_config(), which allows a separate configuration for each virtual
 host.
 
 - Perrin



module multi-config strategy

2000-07-24 Thread martin langhoff

hi list,

i'm about to start writing the first of a series of internal modules,
aimed at handling common features among sites we develop. Like, let's
say, a 'latest news' box or a product guide/database. 

Now, the idea is to have one codebase, written in a module that serves
all of our sites. Each site should have its own (rather complex) config.
Each and every subroutine must know in which context it's being called,
and I don't really want to pass the config as a parameter to every
damned sub. 

Currently, I keep the configs as a global hash inside the module,
that's good when you've got one module per implementation. I won't scale
further justlike that. 

Maybe I should have a hash inside the module, with the $ENV{HTTP_HOST}
or $ENV{'SERVER_NAME'} as key and the configs as values. Maybe this same
setup in a mysql table. But that'd allow only one implementation of each
module per domain. And I think that maybe I'll someday need, say, 2
product guides (under different brands) in the same site / page. 

So that's not 'THE' way. Maybe something intermediate. But I don't
really know how. Does anyone want to share his views on this? 

Maybe I could build a wrapper module, that manages the configs and sets
them up in the environment. That'd be nice to post in CPAN. 



martin



Installing mod_perl a dozen times ...

2000-07-18 Thread martin langhoff

hi,

i guess once you've been playing with mod_perl for a while, you
certainly installed perl, many modules, plus mod_perl, plus apache, plus
many more things ... 

I keep a personal list of all the modules I must d/l and install on a
virgin OS, and the correct order, versions and params (if needed). 

this helps me reduuce the time it takes to up/down-grade perl, for
instance. or mod_perl, maybe. I guess we all should have a list like
that, and it'd be useful to share it and cross-pollinate ideas/modules.
A goal might be making a bundle of key components to install. And maybe
make a srpm out of it, or a small perl script. 

what do you think? is it already done? maybe all of a sudden I've got
this oh so great idea just because I have not read the instructions to
download the latest bundle from CPAN.



martin



[OT] auth modules

2000-07-18 Thread martin langhoff

hi,

this is a question closely related to Perl, and my lazyness as a Perl
programmer. The marketing dept here wants something really weird: they
want to publish a datasheet in a 'protected' page, but the want the
usr/pw hashes to be 'one time only'. So the user must be deleted after
the first time it is used.

I was about to grab my Eagle's book authenz handler, and patch it
heavily, but maybe there's already a module withthat capability. Does
anyone know of one? At least one that'd be easily patched?




martin - [ trying to get CPAN to connect from here ]



Re: Installing mod_perl a dozen times ...

2000-07-18 Thread martin langhoff

I guess that's good and true for those with low-cost + hi-speed +
reliable connections. I have a few servers in here, and a dial-up
connection i'd rather be careful about ;)

anyway, I find it's very important to know all the modules I'm
needing/using. Is it me?

on the other hand, it'd be nice to be able to have a bundled setup.
[working for offline installations]. it also allows to keep version
control.


martin  

David Brown wrote:
 
 I always thought that if you did a CPAN installation of mod_perl, it
 automatically downloaded the modules that it needed.  Am I wrong ?



[OT] Var Scope question (under mod_perl, of course!)

2000-06-30 Thread Martin Langhoff

hi,

sorry for the off-topic-ness, but I'm being bitten by a
variable-scope problem, and maybe if someone is kind enough can help me
out. Off-list, of course.

I'm writing a module that is called under from embperl and registry
scripts, and I'm finding that the following structure doesn't work:

- - pseudo code/ sample code 
use Tie::DBI
my %hash;
sub connect {
# tie  %hash to a mysql DB here !
}
sub get_data {
connect();
return $hash{elementA}
}


the connect works, and within connect, the tied hash works. now
inside get_data 's scope, the hash is empty. ¿? If I explicitly
'return' a hashref after tying it (and grab it in get_data), that
hashref works allright, so it's not related to scopes breaking the
workings of Tie::DBI.

I've got this example, from perlmod, that is supposed to work
my $x = 10;
sub bumpx {  $x++ }

and it certainly does. Now why doesn't my code work?

By the way: I know it's not good to rely in such poor coding
practices as using module globals, but I've got a small module to
program, 2 such 'global tied hashes', and I'm carefully exporting only
what's needed. So I guess I might get away with it ;)


martin



[OT] Var Scope question (under mod_perl, of course!)

2000-06-30 Thread Martin Langhoff

hi,

sorry for the off-topic-ness, but I'm being bitten by a
variable-scope problem, and maybe if someone is kind enough can help me
out. Off-list, of course.

I'm writing a module that is called under from embperl and registry
scripts, and I'm finding that the following structure doesn't work:

- - pseudo code/ sample code 
use Tie::DBI
my %hash;
sub connect {
# tie  %hash to a mysql DB here !
}
sub get_data {
connect();
return $hash{elementA}
}


the connect works, and within connect, the tied hash works. now
inside get_data 's scope, the hash is empty. ¿? If I explicitly
'return' a hashref after tying it (and grab it in get_data), that
hashref works allright, so it's not related to scopes breaking the
workings of Tie::DBI.

I've got this example, from perlmod, that is supposed to work
my $x = 10;
sub bumpx {  $x++ }

and it certainly does. Now why doesn't my code work?

By the way: I know it's not good to rely in such poor coding
practices as using module globals, but I've got a small module to
program, 2 such 'global tied hashes', and I'm carefully exporting only
what's needed. So I guess I might get away with it ;)


martin