Re: [OT]: In my Farthers House there are many mansions
-- Tony Bowden [EMAIL PROTECTED] On Sat, Nov 02, 2002 at 12:13:19PM -, Jeff wrote: It sounds like you're saying that you should only use a subset of Perl as some programmers may not understand the other parts of it? That is what I'm saying. I'm aware that this is a controversial opinion in the Perl world. However, I think it's reasonable to know your audience and write for them. Have to agree 100% with Perrin - in my experience, refactoring for performance is often used as an excuse for 'rewrite in my style', I'm not sure anyone has actually posited using map for performance, but in most cases that would indeed be a pretty stupid reason to use it. See the Schwartzian Transform for an excellent example of where you would use map for performance. Main advantage is getting perl to manage the list space. If I find myself writing for(blah){ push @foo, something } it can usually be done more simply via @foo = map { something } ( blah ). If you end up making large lists, especially in loops, then map can be a speedup. It is also faster if you have to flatten out strucures frequently (vs iterating over keys %foo and assigning things one at a time). map can also be convienent in allowing for lexicals that are assigned when they are built, similarly grep: if( my @process_this = grep {-s $cutoff} @filz ) { deal with @process_this here, know it won't outlive the braces. } Defining the lexicals in a scope where the don't outlive their purose can be a big help in maintainability. -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582
Re: CGI parameters appear to be doubled on 8 bit chars...
$VAR1 = { 'LastScreen' = [ '/MR-@0,324,', '/MR-@0,324,' ], 'Subject' = [ 'Blah blah blah', 'Blah blah blah' ], 'Message' = [ '#8216;blah blah#8217; blah blah #8216;blah blah#8217; blah.', '91blah blah92 blah blah 91blah blah92blah.' ] } If you know the fields that are supposed to have select lists on them (e.g., select_list{qw(field field field)} = 1) then you can walk down the list and compare ref $contents with $select_list{$name}. If both are true then it's a list, else it's 8 bit junk in two fields; both false gives you a normal field. -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582
Re: serving large files with access controls
Is there a way to do this so that access to the file would be _impossible_ unless the user is authenticated by the mod-perl server? I am looking for a solution that can guarantee that there is no way to circumvent the authentication process. I can think of solutions where the probability that users can access the file without authenticating can be made very small, but I am looking for an absolute guarantee. Impossible, no. If the proxy server can handle FTP then one way is to have the source directory mods at 0711. That requires knowing the file name to get it; no listings w/o read access. After that you can have the web server, say, symlink a file with some temp name and redirect the user to the ftp server. Net result is that the proxy handles an ftp request for a name that is temporary to the download and hard to guess. -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582
Re: Archive::Tar
-- Anthony E. [EMAIL PROTECTED] How can I get this to tar the entire backup directory? And if I wanted to say pic out all file based on extensions later on like .pl *.pl how to do that as well with this? gnu cpio will write tar: find $dir | cpio -ov -Htar | gzip --best /blah/$dir.tar.gz; or find $dir -name '*.pl' | cpio -ov -Htar | gzip ... the -Hcrc puts a 32-bit crc on the files for better error checking, etc: find $dir -name '*.pl' | cpio -ov -Hcrc | gzip ... Nice thing about cpio vs. tar for this is that if tar fails to write it can exit zero after successfully telling you that it failed; cpio croaks and exits non-zero immediatly if it detects an error on writing or extract. -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582
Re: Modperl! Your private *UNDERAGE* lolitas and boys!
-- Michael Poole [EMAIL PROTECTED] Oden Eriksson [EMAIL PROTECTED] writes: On Thursdayen den 1 January 1970 00.59, [EMAIL PROTECTED] wrote: P.S. This is not spam! He he..., yeah right... How do one keep this kind of shit out of here? I'd like to know, too. The answer, of course, is Perl. The spamassassin module to be precise, see http://www.spamassassin.org for details. -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582
Re: Best compile options for perl 5.8 for mod_perl 1.x and 2.x
./Configure -des -Dprefix=/home/stas/perl/ithread \ -Dusethreads -Duseshrplib Also worth using large file support if you habitually munge 2GB files. -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582
Re: Can mod_perl help me use ENV variables in httpd.conf?
Yup. See the perl directive. Good description of how it works in the Eagle Book. -- Fran Fabrizio [EMAIL PROTECTED] I am trying to make a portable mod_perl.conf. I have things like: Alias /cgi-bin/chimpkit/ /usr/local/apache/cgi-bin/chimpkit/ Location /cgi-bin/chimpkit/ SetHandler perl-script PerlHandler Apache::Registry Options +ExecCGI PerlSendHeader On /Location which really needs to become something like: Alias /cgi-bin/chimpkit/ $SERVER_ROOT/cgi-bin/chimpkit/ etc... I don't think I can do this directly with Apache but I found a random newsgroup thread that suggested something like the following might work: Perl push @PerlConfig, EOF Alias /cgi-bin/chimpkit/ $ENV{'SERVER_ROOT'}/cgi-bin/chimpkit/ Location /cgi-bin/chimpkit/ SetHandler perl-script PerlHandler Apache::Registry Options +ExecCGI PerlSendHeader On /Location EOF /Perl Is this a good way to solve this problem, is there an easier way, and does this even work? :-) Thanks, Fran -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582
Re: Kind-of PerlSections, and location question
Have a databae table that stores the information for each setting, then load it dynamically as a request comes in... mailer dream code: $ENV{REQUEST_URI} =~ /^\/(.*?)\//; $base_path = $1; if (!exists($Location{$base_path})) { ... do database calls to load necessairy information ... and set as if this was a perl section in an ... httpd.conf file. } ... then execute as if that location section was always there If there's a better solution then this, I'm also eager to hear it :) Depending on the rate of server additions you might be better off loading these at startup time or on a user signal (e.g., $SIG{USR1} = \reload_stuff_from_db). Timestamping the database entry for the site might also help, since you wouldn't have to re-load the entire thing every time the site was hit. -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582
Re: mod_perl training companies?
http://www.stonehenge.com/ http://www.stonehenge.com/perltraining/ -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582
Re: kylix: rad!
-- brian moseley [EMAIL PROTECTED] many of us on this list have well-developed preferences for editing and debugging our code, configuring and testing our applications that are based on executing shell commands in a terminal. don't you think there are lots of well developed advocacy reasons for offering an alternative paradigm? Good example would be W32 developers who want to migrate and simply don't know their way around *NIX yet. Even if they've taken the time to learn how the HTTP/HTML/etc end of things function, working on NT doesn't give them very good reflexes for dealing with *NIX. This does seem like a good way to show people that gaining add'l control with mod_perl doesn't have to be painful. -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582
Anyone know of specific problems with the malloc in Sun's libc?
W/ current apache and mod_perl, perl-5.6.1, Solaris-2.8. Been having problems with DBI dropping connections. One suggestion was to override the default of no and use the malloc that comes with perl-5.6.1. Anyone know of problems or any obvious symptoms? thanx. -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582
Success story.
The URL is on an internal LAN for a company whose name I cannot use. The site gets up to a few hundred hits per second supporting a telephone call center database. My company was asked to develop a web front end onto a TB data warehouse. The existing system (carefully crafted in C) was so slow people couldn't get their work done (e.g., 45-minute query times). We re-did the back end and slapped an interface on it using mod_perl. The first time the users saw it they asked for a Stop button like the existing system had so they could abort long-running queries. Then we went over where to put it with me running queries. They gave up on the idea because the data was returned too fast for them to hit a button. Through 4+ weeks of User Acceptance Testing (UAT) they asked for a few dozen changes in the reports. Few of them took loger than 20 minutes to implement. In several cases they got annoyed that the company email took longer to deliver the fix notice than make the change. Using Perl we were also able to handle the database manglement software for tablespace and table creation, web site auth. and reporting code and most of the ETL process management code in one language. That also saved us quite a bit of work. -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582
Re: load balancing on apache
-- Hemant Singh [EMAIL PROTECTED] Hi All I am planning to host an application and its size is going to be big one , so expect the concurrent number of connection s to be around 2200.To combat the same , want to perform load sharing on 3-4 servers.So the ide is to put one machine on external IP and this machine , after receiving the requests would forward them to any of the other three machines having the application deployed and running on the same environment.Pls suggest how can i achieve this on apache. Randal Schwartz had a good article on this about a year ago. You can use the re-write phase to balance the load w/in Apache if you want to. Alternatives include round- robin DNS and separate load balancing software. -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582
Re:[Rewrite article] Randal Schwartz article on load balancing inEpache
-- Anand R [EMAIL PROTECTED] I would like to see the article of Randal Schwartz ,.. Will some one help me out with this Check out his website at stonehenge.com. Look for something like poor man's load balancer. Trick was to use the URI [post read?] to re-write the URI and post it to another system based on the estimated load any other balancing criteria. You might be able to find it via google also. -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582
Oddity with redirects
Getting Apache::AuthCookie working. The AuthCookie portion is proving simpler than Apache... Problem is that accessing the /loginform location works perfectly: I get the form, get the cookie back and get sent to the proper place. Accessing the protected site blows up because the Apache object referent is undef (see below for examples). No doubt I've screwed up some part of the httpd.conf but cannot figure out what at this point... Wandering through the Apache doc's hasn't helped, nor can I find anything particularly descriptive in the Eagle book -- p. 123+ don't indicate that the $r is any different for a request and p. 554+ are in C. None of them seem to indicate that a redirected request produces an invalid request object in the perl API. Any suggestions as to what I've done wrong or specific working examples would be appreciated. /sl Aside: this is rather obviusly hack code at this point. I know that, the only purpose is to get a working referent when accessing the /foo site. sub login_form($$) { my( $class, $request ) = @_; print STDERR \n$$: login_form: $class, , Dumper $request; print STDERR \n$$: login_form: $class\nrequest:\n, $request-as_string; print STDERR Environment:\n, Dumper \%ENV; # this eventually needs to be updated for the user's # real dest uri. ( my $form = $loginform ) =~ s{DEST}{/foo}; print STDOUT $form; } # Authorization cookie handler. PerlModule Cdr::AuthCookie; PerlSetVar CDRPath /foo PerlSetVar CDRLoginScript /cdrloginform PerlSetVar CDRLoginHandler /cdrlogin #PerlSetVar CDRExpires +8h PerlSetVar AuthCookieDebug 3 # this shows the login form. Location /cdrloginform SetHandler perl-script PerlHandler Cdr::AuthCookie-login_form /Location # handle posted data from the login form. location /cdrlogin AuthType Cdr::AuthCookie AuthName CDR SetHandler perl-script PerlHandler Cdr::AuthCookie-login /Location Location /foo SetHandler perl-script AuthTypeCdr::AuthCookie AuthNameCDR PerlAuthenHandler Cdr::AuthCookie-authenticate PerlAuthzHandlerCdr::AuthCookie-authorize PerlHandler Cdr::Hello # just print the famous message require valid-user /Location Result of accessing /cdrloginform: 32309: login_form: Cdr::AuthCookie, bless( do{\(my $o = 144324132)}, 'Apache' ) 32309: login_form: Cdr::AuthCookie request: GET /cdrloginform HTTP/1.1 Accept: text/html, image/png, image/jpeg, image/gif, image/x-xbitmap, */* Accept-Encoding: deflate, gzip, x-gzip, identity, *;q=0 Cache-Control: no-cache Connection: Keep-Alive, TE Host: cdr_dev.lit.alltel.com:8081 TE: deflate, gzip, chunked, identity, trailers User-Agent: Opera/5.0 (Linux 2.2.18.ae i686; U) [en] HTTP/1.1 (null) Environment [cruft removed]: { QUERY_STRING = '', REMOTE_PORT = '3767', HTTP_USER_AGENT = 'Opera/5.0 (Linux 2.2.18.ae i686; U) [en]', HTTP_ACCEPT = 'text/html, image/png, image/jpeg, image/gif, image/x-xbitmap, */*', HTTP_HOST = 'cdr_dev.lit.alltel.com:8081', GATEWAY_INTERFACE = 'CGI-Perl/1.1', HTTP_TE = 'deflate, gzip, chunked, identity, trailers', SCRIPT_NAME = '/cdrloginform', SERVER_NAME = 'AlltelViewer', HTTP_ACCEPT_ENCODING = 'deflate, gzip, x-gzip, identity, *;q=0', MOD_PERL = 'mod_perl/1.26', SCRIPT_FILENAME = '/home/lembark/sandbox/cdr//code/app/website/htdocs/cdrloginform', APACHE_PORT = '8081', SERVER_PROTOCOL = 'HTTP/1.1', HTTP_CONNECTION = 'Keep-Alive, TE', SERVER_SIGNATURE = 'ADDRESSApache/1.3.20 Server at AlltelViewer Port 8081/ADDRESS ', SERVER_SOFTWARE = 'Apache/1.3.20 (Unix) mod_perl/1.26', : HTTP_CACHE_CONTROL = 'no-cache' } Result of accessing /foo: 32309: login_form: Cdr::AuthCookie, undef [Thu Dec 6 11:11:20 2001] [error] Can't call method as_string on an undefined value at Cdr/AuthCookie.pm line 360, DATA line 1.
Problem with Apache::AuthCookie
Getting multiple header entries from AuthCookie returned to the client. This happens even if I stub out the authen_cred and authen_ses_key to return foo. Other thing I notice after adding logging to the authentication and authorization sub's is that the $r-connection-user set by authentication isn't available in $r-connection-user in authorization. As a result of the undef $r-connection-user in authorization it's sending back a FORBIDDEN which [I think?] causes the problems. The examples I've seen of login_form code use a simple print to get things on the screen (e.g., Apache::AuthTicket). I've tried this and various combinations of sending the headers and form with no luck. Ideally Apache::AuthCookie should only require the login_form, authen_cred and authen_ses_key sub's to function with the addition of login_screen to use a location rather rather than #!-ed code for the login form. Does anyone know of a simple, working example of deriving a class from Apache::AuthTicket or some specific documentation for a complete class? The code that comes with it is only useful for testing Below are the relavant error_log items (showing the user available in authenticate and undef in authorize). thanx. sl # Authorization cookie handler. PerlModule Cdr::AuthCookie; PerlSetVar CDRPath /foo PerlSetVar CDRLoginScript /cdrloginform PerlSetVar CDRLoginHandler /cdrlogin #PerlSetVar CDRExpires +8h PerlSetVar AuthCookieDebug 9 # this shows the login form. Location /cdrloginform SetHandler perl-script PerlHandler Cdr::AuthCookie-login_form /Location # handle posted data from the login form. location /cdrlogin SetHandler perl-script AuthTypeCdr::AuthCookie AuthNameCDR PerlHandler Cdr::AuthCookie-login /Location Location /foo SetHandler perl-script AuthTypeCdr::AuthCookie AuthNameCDR PerlAuthenHandler Cdr::AuthCookie-authenticate PerlAuthzHandlerCdr::AuthCookie-authorize PerlHandler Cdr::Hello require valid-user /Location Location /foo/bar SetHandler perl-script AuthTypeCdr::AuthCookie AuthNameCDR PerlAuthenHandler Cdr::AuthCookie-authenticate PerlAuthzHandlerCdr::AuthCookie-authorize PerlHandler Cdr::Hello require valid-user /Location ### # Cdr::AuthCookie.pm ### package Cdr::AuthCookie; use strict; use base qw( Apache::AuthCookie ); local $\ = \n; local $, = \n; # CPAN modules use Carp; use Apache::Constants qw(:common M_GET M_POST FORBIDDEN REDIRECT); use Apache::Log; use Digest::MD5 qw( md5_hex ); # used for sharing and generating the shared secret # used in the authrization process. use IPC::SysV; use IPC::Shareable; use Digest::MD5 qw( md5_hex ); use Data::Dumper; $Data::Dumper::Purity = 1; $Data::Dumper::Terse= 1; $Data::Dumper::Indent = 1; $Data::Dumper::Deepcopy = 0; $Data::Dumper::Quotekeys= 0; # homegrown modules use Cdr::Reportz; use Cdr::Shared qw( logrequest sendreply ); # package variables # initialize the untied variable to false, use $key to check the status. our $secret = ''; our $key = ''; # amount of time before a cookie times out. # currently set to 8 hours (28 800 sec). # # 10 sec for testing only, probably useful in production. my $timeout = 30; #28800; # login screen returns this to the caller. my $loginform = 'END'; html head !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 3.2 Final//EN base href=$ENV{BASEURL} /head body form method=get action=/cdrlogin !-- Login form for an Cdr::AuthCookie -- input type=hidden name=destination value=DEST table tr th align=center colspan=2 Please Enter Your Username and Password to log in: tr th align=right Username: td align=left input type=text name=credential_0 size=12 maxlenth=12 tr th align=right Password: td align=left input type=password name=credential_1 size=12 maxlenth=12 tr
Problem with Apache::AuthCookie-3.00
Getting multiple HTTP replies returned to the client. They get a form and followig it an 'access denied' message from Apache. The examples I've seen of login_form code use a simple print to get things on the screen (e.g., Apache::AuthTicket). I've tried this and various combinations of sending the headers and form with no luck. Ideally Apache::AuthCookie should only require the login_form, authen_cred and authen_ses_key sub's to function with the addition of login_screen to use a location rather rather than #!-ed code for the login form. Does anyone know of a simple, working example of deriving a class from Apache::AuthTicket or some specific documentation for a complete class? The code that comes with it is only useful for testing; the other modules include quit a bit of non-AuthCookie sub's that may have a bearing on how the form is handled. The login_form is taken from Apache::AuthTicket (basically just a header and static body). My sub-class also overloads authentication to call login_form($r) rather than without arguments. sub authen_cred( $$\@ ) { foo } sub authen_ses_key( $$$ ) { foo } sub login_form { my( $class, $request ) = @_; $request-no_cache( 1 ); $request-send_http_header( 'text/html' ); $request-print( $form ); OK } -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582
Re: Are global variables truly global?
-- Chui G. Tey [EMAIL PROTECTED] I have some state data that I need to persist between requests. At the moment these are COM objects, but they'll be ported to Perl Classes. It is quite important that only one of these instances exist per web server. These instances are too large to write and read to file on every request. So I have defined the variable as a package level variable. I have been instantiating the variable in my handler() routine if it has not already been instantiated. ie. Global variables are exactly that: global. If you use something like: our $foo ||= somefunc; or our $foo = Someclass-constructor( @blah ); then you'll get a value that goes into the symbol table and is unique w/in the executing process. Thing you'll need to read up on are global variables, packages/namespaces and how use strict effects things (all of which are in the Camel or Llama books). -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582
Re: Exporting C++ class to Perl?
-- Vlad Safronov [EMAIL PROTECTED] Hi, How can I export C++ class and its interface to Perl? Is it just like exporting simple C function to Perl (in perlxs doc. example)? Is there good (not big) CPAN examples for this problem? perl -MCPAN -e shell; get Inline -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582
Re: Excellent article on Apache/mod_perl at eToys
Exactly- the statically typed languages I am familiar with have a casting mechanism to utterly subvert compile-time type checks. While static typing allows better compile-time optimization, it's value as a debugging mechanism is near the bottom of the list of advantages for engineering a large project. If interface guarantees are important between Perl objects, I'd have a look at Class::Contract. One nice thing about which is that the contract portion can be essentially turned off in production. Gives you the best of both worlds: strong checking during development w/ good speed in productin. Compile time checking can definitely be a friend of yours especially when dealing with large systems. But it's also a friend that's judgemental (strongly typed) so he's a pain to drag along to a party To me, strongly vs weakly typed is less descriptive than statically vs dynamically typed. To me, it is utterly nondescriptive in a PHB buzzwordy way, whereas static vs. dynamic typing is meaningful (and what I think most people really mean by the former). Comparing Perl to other OO languages runs into the fact that only Perl uses a fairly high-level object as its basic storage unit (scalar). The first thing most people write/buy for the strongly typed languages is a library of contaner classes: things that subvert the strong checking of low-level types. The second thing that usually happens is that the low-level types get their base operations overloaded via container objects. Net result is minimal -- at best -- type checking. The problem isn't really that scalars are weakly typed, since all you can deal with are scalars. If programmers bothered to write checks in their code (e.g., $foo =~ /^\d$/ or croak NAN) then Perl will do as well or better than most languages. Coders are too used to having the low-level type checking around as a crutch, so they don't. Implementing code that uses Class::Contract forces you to declare [perhaps even analyze?] not only data types but expectations, and ends up causing people to do a much better job of checking then most other languages even allow. -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582
Re: PerlSetVar string value - no \n translation?
-- Louis LeBlanc [EMAIL PROTECTED] Hey all. I don't know how many people are lurking here, since the list seems to be very light traffic (the lightest of 8 I sub to), but I have a question regarding PerlSetVar and strings. Here is what I'm trying to do: In httpd.conf: Location /MyHandler . . . PerlSetVar MailMsg Access Report \ This is a mail message spanning several \ lines that I would like to mail to a \ particular address when the handler is \ invoked. \ Unfortunately, it all winds up on one line and \ any \n included do not get translated. /Location And in my module, I am successfully sending this message to the email address, but it arrives looking like this: Access Report This is a mail message spanning several lines that I would like to mail to a particular address when the handler is invoked. Unfortunately, it all winds up on one line and any \n included do not get translated. And the darn thing is all on one line. '\n' is not translated, etc. It looks like the string is proveded as if enclosed in single quotes. Which is bad. Quick hack for the moment: PerlSetVar Blah A long line withbrHTMLbrBreaks In It; that or set the thing and use: s/br/\n/gs; somewhere in the code. -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582
Bit of an oddity configuring perl (fwd) (fwd)
Should be fairly simple: Configure a few locations w/in the perl section of httpd.conf. The code seems to run, exept that naming the first section /cdr/Data gives me the output from Cdr::Welcome, rather than the Cdr::Data module. Changing the name from cdr/Data to cdr/Foo in the config file fixes the problem; changing it to cdr/Bar breaks things again. Aside from server-status and server-info these are the only locations in the config file; the only dir's in the file are serverroot and htdocs -- which don't seem to cause any problem. The really annoying thing is that all I get back is a lack of error messages and the contents of the /cdr location when accessing the /cdr/Data (/cdr/Menu and /cdr work fine). Aside from gremlins or an easter egg for URI's named Foo, anyone know of a decent reference for this? thanx, sl $Location{'/cdr/Data'} = { SetHandler = 'perl-script', SetEnvIf= [ [ 'Cookie', 'Eastern', 'TZ=US/Eastern' ], [ 'Cookie', 'Central', 'TZ=US/Central' ], [ 'Cookie', 'Mountain', 'TZ=US/Mountain' ], [ 'Cookie', 'Pacific', 'TZ=US/Pacific' ], [ 'Referer', 'Central', 'TZ=US/Central' ], [ 'Referer', 'Eastern', 'TZ=US/Eastern' ], [ 'Referer', 'Mountain', 'TZ=US/Mountain' ], [ 'Referer', 'Pacific', 'TZ=US/Pacific' ], ], PerlHandler = 'Cdr::Data', }; # welcome screen, authentication is handled # here also via Apache::AuthNetLDAP which # is configured here. $Location{'/cdr'} = { SetHandler = 'perl-script', PerlSetEnv = BASEURL http://$host:$Port/cdr;, PerlHandler = 'Cdr::Welcome', }; $Location{'/cdr/Top'} = { SetHandler = 'perl-script', PerlHandler = 'Cdr::Top', }; $Location{'/cdr/Menu'} = { SetHandler = 'perl-script', PerlHandler = 'Cdr::Menu', }; -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582
Re: Off-topic - Apache Config - Load crises
-- Rafiq Ismail [EMAIL PROTECTED] There are some really graphic intensive pages here, however I'm not sure if Keep alive is good when there's lots of contention for pages. Should I: i) disable keep alive? ii) reduce the keep alive time out ? iii) up my number for max spare servers? Since i've not maxed out on load or memory, perhaps more idle servers will reduce the contention for apache children? My intutition is that since the server is obviously in trouble, resource wise, perhaps increasing the number of daemons will relieve the load. Not sure. It's a big box. Any ideas? iv) Something else? Unless you are running out of proc's -- hitting MaxServers -- then the number of keepalives shouldn't matter that much. The [lack of] bandwidth seems to be causing you pain. If you can spread the load over multiple machines further up the network (i.e., with fewer routers between them and the cloud) it might help. Randal wrote an article last year about using rewrite rules as a poor-man's load balancer. That might help. -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582
Re: Knowing if a apache server is compiled with mod_perl
-- Mat [EMAIL PROTECTED] Hi everyone, I'd like to know if there is a simple way to find if an apache server is compiled with mod_perl and with which version. My aim is to write a script which compile mod_perl if it is not installed.For the moment I've found only two ways, launch the actual server and telnet it to parse the server signature. But it has the disadvantages of having the Apache server running and the server signature on.The other way would be to get the return of httpd -v, but I won't have the version and I think this won't work if the module is compiled in dso. So is it possible from the Apache binary to check mod_perl ? If the server is compiled w/ mod_info check that for mod_perl. -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582
Re: Cloning the request object
-- Alin Simionoiu [EMAIL PROTECTED] Hi there, Those anybody know if is possible to clone the apache request object?. I'm trying to write a Apache module that do some basic validation against the request parameters. But as soon as a touching the request is gone. any other posibilities? I've never had problems with: sub handler { my $request = shift; foo $request or croak foo doesn't like you!; ... } sub foo { my $request = shift; ... } -- Steven Lembark 2930 W. Palmer Workhorse Computing Chicago, IL 60647 +1 800 762 1582
Re: BOF?
- brian moseley [EMAIL PROTECTED] on 07/14/01 10:43:42 -0700: On Sat, 14 Jul 2001, Ken Williams wrote: I just noticed that there's no mod_perl BOF listed at http://conferences.oreillynet.com/cs/os2001/pub/10/bofs.html . Is one scheduled? If not, let's get one together. speaking of which. there should be an opening night piss-up, eh? somebody that knows the area should propose a place. I have family in San Diego. Should be getting names of places today. sl
Re: API Design Question
memory used by the various .pm files that will be loaded numerous times. I can see that grouping functions based on functionality would reduce the number of .pm files in memory. However, if I go that route, use only loads the .pm once. Multiple uses don't eat up any more resource than having it done once. The minimal-module approach can be managed nicely via Autosplit, which puts eash sub in its own module with a stub AUTOLOAD that snags things into core only when they are called (the ultimate in lazyness, no?). This is particularly nice for rarely called modules . One example is speicial exceptions in database app's. You can put the exception handler into a sub, have autosplit stuff it into a module and only load it into memory if the error does show up. This helps with code release issues because the related code lives in a single moule for editing and testing purposes but only sucks up core when needed. sl
Re: API Design Question
Note that if they do get called this will end up using more memory than if you had just loaded them during startup, since they won't be shared between child processes. Original assumption is that they are called infrequently. You'll also find that the amount of memory sucked up by a single subroutine isn't much, less than pre-loading possibly 10' s of sub's that never get called. sl
Re: which perl?
I am running Apache/1.3.14 (Unix) mod_perl/1.25 on a redhat 7 system. Since the perl binary that came with the redhat distribution was version 5.6.0, I assumed that is the version that got built into mod perl (statically linked). But I just discovered using perl's $] variable, that it's actually using 5.006! So far as I can tell, I don't even have a copy of perl 5.006 on my system... Is mod_perl actulaly distributed with a version of perl interpreter intact? If so, How do I upgrade it? For the amount of time it takes, I'd suggest just building a local copy of mod_perl. If you use a .makepl_args.mod_perl file it can be done with a single perl Makefile.PL; make test install.
Unable to build apache + mod_perl on AIX
apache_1.3.20 mod_perl-1.25 AIX kbs80 3 4 000C30CD4C00 unknown Problem: regardless of what arg's I've tried or all-in-one, one-step I keep getting xlC as the compier and CFLAGS which include -qlonglong -q32 -maxmem'. xlC then fails to compile apache. Running ./configure --blah in the apache directory w/ CC=/path/to/gcc and CFLAGS='-O2 -I/blah -L/blah' gives me a working copy of apache -- sans mod_perl. Running find . -type f | xargs grep -il qlonglong and '... grep -il xlC' in the mod_perl and apache directories gets me NADA. This includes the documentation, source, Makefiles, inputs, you-name-it. Question: What is a way to run some combination of perl Makefile.PL with or without ./configure for apache that will cause the result to use $CC and $CFLAGS in my envoronment -- or which piece of code can I hack that is finding xlC in hte first place (sorry, I don't have time to perl -d Makefile.pl at this point). thanx.
Re: handler for error log
Is it possible to put a handler on the error log so that certain elements could be filtered? Ideally, I'd like to keep track of how many times a certain error appears and with a handler that would be a cake walk. So the handler would 'live' between the main httpd process and the file, doing it's magic there. I've done some searching and found nothing [other than people complaining about their CGI scripts]. Any pointers or suggestions are welcome. There are several log watchers avaialble, including ones written in perl. One simple trick is to essentially tail -f the thing into a regex. Quick way is to seek to the end, store -M $logfile and set $\ = undef. After that: open my $logfile, $logpath or croak $logpath: $!; undef $\; # or leave it alone if reading into an array. for( my $lastmod = -M $logfile ;;) { sleep 10 while( $lastmod == -M $logfile ); my $newstuff = $logfile; # regex $newsuff to your heart's delight. # that or read it as @newstuff and process it # line by line } -- Steven Lembark 2930 W. Palmer chicago, IL 60647 [EMAIL PROTECTED] +1 800 762 1582
Re: Make Test problems...
snip file called makpl_args.mod_perl in the mod_perl directory. The best arrangement for the directories seems to be something like: snip Even easier, put .makepl_args.mod_perl into your home directory and you won't have to re-create it every time you go to re-build Apache.
Re: Memory leak
script offers database search facilities on the web. If a search is performed which results in many (namely 400) rows being returned, then the httpd child that serves the request grows by 2 MB. Have a child serve that request ten times, and its size will grow from an initial 8 MB to 28 MB. Another ten times and it will go to around 50 MB. Depending on how the return is processed this looks more like an unused reference left behind. You might want to try, e.g., calling the handler from a harness and see where the memory is going in the debugger. It also depends on how the rows are being retrieved. If you are in a while( nextrow ) loop vs. a for( fetchall_arrayref ) type the memory use gets pretty large. Depending on the size of your queries this could also just be perl's buffering the input. Remember that perl doesn't free the space it uses but keeps it internally for later use. If you are running large enough queries over time the memory use will track the high-water mark of the rows returned (which obviuosly pertaint to fetchall-type returns). If the queries get large enough you can suck up lotsaMB. -- Steven Lembark 2930 W. Palmer St. Chicago, IL 60647 [EMAIL PROTECTED] 800-762-1582
Trying to find correct format for PerlSetVar's -- or get Apache::AuthNetLDAP working.
Eagle gives number of examples, none of which is a PerlSetVar. guessing it would be a hash of var's to set with values. Not having much luck -- Apache::AuthNetLDAP fails with: [Wed May 30 23:33:21 2001] [notice] Apache/1.3.19 (Unix) mod_perl/1.25 configured -- resuming normal operations [Wed May 30 23:33:21 2001] [info] Server built: May 4 2001 18:38:57 [Wed May 30 23:33:31 2001] [error] Can't call method bind on an undefined value at /usr/local/perl5/lib/site_perl/5.6.1/Apache/AuthNetLDAP.pm line 57. which is running: 47 my $ldap = new Net::LDAP($ldapserver, port = $ldapport); 48 49 my $mesg; 50 #initial bind as user in Apache config 51 if ($bindpwd ne ) 52 { 53 $mesg = $ldap-bind($binddn, password=$bindpwd); 54 } 55 else 56 { 57 $mesg = $ldap-bind(); 58 } 59 60 #each error message has an LDAP error code 61 if (my $error = $mesg-code()) 62 { 63 $r-note_basic_auth_failure; 64 $r-log_reason(user $username: LDAP Connection Failed: $error,$r-uri); 65 return AUTH_REQUIRED; 66 } problem seems to be that i'm not getting the PerlSetVar's across to it via perly config: 164 $Location{'/blah'} = 163 { 164 SetHandler = 'perl-script', 165 166 PerlAuthenHandler = 'Apache::AuthNetLDAP', 167 168 PerlSetVar = 169 { 170 BindDN = 'employeenumber=123456 ou=people o=foo.bar', 171 BindPWD = 'password', 172 BaseDN = 'ou=people o=foo.bar', 173 LDAPServer = 'ldap.alltel.com', 174 LDAPPort= '389', 175 UIDAttr = 'sn', 176 }, 177 178 AuthName= '/tdrdw', 179 AuthType= 'Basic', 180 181 require = 'valid-user', 182 183 PerlSetEnv = BASEURL http://$host:$Port/tdrdw;, 184 PerlHandler = 'Tdrdw::Welcome', 185 }, is there any better doc for this than the eagle book? -- Steven Lembark 2930 W. Palmer St. Chicago, IL 60647 [EMAIL PROTECTED] 800-762-1582
looking for help finishing a module
something like Apache::Digest::FixMSHak. MS decided that their version of digest security was better than the RFC. i should be doable to add a re-write module that hacks the MS hak back to stock values so that mod_digest works again. people i've spoken to so far don't know if there is anything other than simply truncating the uri to its path (leaving off the arguments) that's done by MS. if anyone knows how their process works, or is willing to help check it, please warn me. it'll be a big help in this thing done sooner. thanx. -- Steven Lembark 2930 W. Palmer St. Chicago, IL 60647 [EMAIL PROTECTED] 800-762-1582
bug in exploder blows up Digest security
anyone know of a way around this? i have a site that depends heavily on anchors for delivering reports. exploder chops off the uri at the arguments, which is not what mod_auth_digest (nor RFC 2617) expect. anyone know of a way to force exploder to use the full uri for the digest authorization header? rewrite doesn't seem likely to help since the hash was generated with the wrong value of the uri to begin with. thanx. GET /tdrdw/Data?menuform=1report=lookup=report=sar_min_esnlookup=99all=0 HTTP/1.1 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, application/pdf, */* Accept-Encoding: gzip, deflate Accept-Language: en-us Authorization: Digest username="paul", realm="TDRDW", qop="auth", algorithm="MD5", uri="/tdrdw/Data", nonce="OsOuHA==3be36661a184a9851d9263409b407031c9fc8 928", nc=0007, cnonce="456ac2f6e01485024bbb49b3652923dc", response="3f9fe67dfe9188da6a358520d41e1dbe" Connection: Keep-Alive Host: alpha:8082 Referer: http://alpha:8082/tdrdw/Menu User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 98) HTTP/1.1 (null) [Thu Mar 29 15:54:58 2001] [error] [client 10.35.2.5] Digest: uri mismatch - /tdrdw/Data does not match request-uri /tdrdw/Data?menuform=1report=lo -- Steven Lembark 2930 W. Palmer St. Chicago, IL 60647 [EMAIL PROTECTED] 800-762-1582
looking for docs
anyone know where doc's for handling digest authentiction w/ m_p 1.25 live? having little luck finding any working examples and i'm running out of time... thanx. -- Steven Lembark 2930 W. Palmer St. Chicago, IL 60647 [EMAIL PROTECTED] 800-762-1582
Re: Dynamic loading of development libraries
I'm currently a developer for an on-line publication using Apache / mod_perl / Mason. We currently have about six developers working on the project and I have been running into problems with concurrent work on the Perl libraries that power our site. We use CVS to manage revisions, but the only way for a developer to see if their code is working is to run it on our webserver. However, mod_perl's very purpose is to keep one copy of your modules loaded from the start. StatINC addresses this problem to a certain extent, but it fails when you have multiple versions of a Perl module that you want to load depending on which user is requesting. I sort of got around this by modifying my Mason handler to examine the requested URI ( ex. /dev/user_name/blah.html ) and loading the appropriate module for that user. Basically, this involved modifying the @INC paths in the handler, requiring the modules, and then calling the StatINC handler sub to reload any modified modules. This sort of screams hack and it never worked that well. Processes would load the proper module for one user, and then use that same module to serve another user who was looking for his own modules. Chaos ensued... I have a few ideas as to what I should try next. Perhaps limiting RequestsPerChild to 1, such that libraries don't get reused? I don't know what the ramifications of this are. Short of running a webserver for each user (a bad solution in my opinion) does anyone have ideas? you can update your httpd.conf to vary the port number based on who is starting the thing. this gives you something like: perl ... %portlist = qw( jow 8081 bloe 8082 john 8083 doe 8084 ); $Port = $portlist{$ENV{LOGNAME}} or die "no port for $ENV{$LOGNAME}"; to check out a new version just bounce your copy of the server and keep going. normal cycle looks something like cvs -q update -d; bounce; try it, edit thing, keep going. if you reach a point where something works use cvs commit. -- Steven Lembark 2930 W. Palmer St. Chicago, IL 60647 [EMAIL PROTECTED] 800-762-1582
alarm w/in mod_perl?
does apache swallow SIGALRM during its normal operation? can't find any reference to alarm or ALRM in eagle; doesn't mean i havn't missed something... using: sub blah { recalculate time-based items that change hourly; alarm $next_time_to_run - time; $next_time_to_run; } sig{ALRM} = \blah; gets me nowhere, so far as i can tell. messages printed to STDERR get output then the sub is first run; reducing the time to 10 seconds doesn't generate 6 records / minute. i can imaging apache using ALRM for its own purposes, leaving me stuck with $cutoff = blah if( time $cutoff ) every time i pass through the routine (blech). -- Steven Lembark 2930 W. Palmer St. Chicago, IL 60647 [EMAIL PROTECTED] 800-762-1582
development question
apache 1.3.14. havemultiple developers hacking html, mod_perl w/ own sandboxes. need them to start up their own servers on various ports (e.g., 8081, 8082...). we are using CVS and need to share access to a valid httpd.conf file. hmmm... we all use the same httpd.conf and we all step on one another w/ ports and dir's. not good. no way i know of use specify htdocs as a relative path or use $HOME or $SANDBOX to set it. virtual hosts don't work well since everyone collides on the main server's PORT setting and none of has have SU access to suck up port 80 (which still wouldn't help if we collide on 80). trying to avoid people using -d for now -- still doesn't help since DocumentRoot wants an absolute path. include doesn't work since we are sharing the same CVS tree and would end up with the same includes -- unless there is something like Include "$ENV{LOGNAME}-conf" to allow per-user portions of the config. never learned how to configure apache w/ the perl format, which might solve the entire thing via $ENV{HOME}. might not... so... anyone have an example httpd.conf (stock or perly) that would allow multiple people on the same machine to check out the same httpd.conf, start up httpd w/ -f ./httpd.conf and not collide on the ports, dir's? the only thing i can come up with so far is rather messy, using, with IfDefine blah Include blah-config /IfDefine we can edit the common httpd.conf file for each of ourselves. seems like performing the replacement in-place (e.g., via $LOGNAME) would be a cleaner way. thanx -- Steven Lembark 2930 W. Palmer St. Chicago, IL 60647 [EMAIL PROTECTED] 800-762-1582
anyone had luck compiling apache-1.3.14 w/ mod_perl-1.24_01on aix 4.3.3?
the Makefile.PL doesn't even work... can't find any references to specific problems, figured i'd check before getting into the gory details... -- Steven Lembark 2930 W. Palmer St. Chicago, IL 60647 [EMAIL PROTECTED] 800-762-1582
infamous mod_perl mod_ssl together not making...
found snippet (below) on archive, obviously i'm missing something... after following the notes in ./mod_perl-1.3.1/INSTALL.simple.ssl, ./mod_ssl-2.4.10-1.3.9 and previous suggestions from the mailing list: make[1]: Entering directory `/var/CPAN/build/apache_1.3.9' === src make[2]: Entering directory `/var/CPAN/build/apache_1.3.9' make[3]: Entering directory `/var/CPAN/build/apache_1.3.9/src' make[3]: *** No rule to make target `all'. make[3]: Leaving directory `/var/CPAN/build/apache_1.3.9/src' make[2]: *** [build-std] Error 2 if i leave out mod_perl the whole thing makes, including mod_perl seems to break it every time. basic steps: extract, make, make test make install of openssl-0.9.4, mm-1.0.12, rsaref2. all of those worked. blew off ./apache-1.3.9, re-extracted it. extracted mod_ssl-2.4.10-1.3.9. went through the "flexible APACI-only way" just for grins, ran make in apache. this much worked. went through the key generation, got snakeoil, etc. cd ../mod_perl-1.2.1; made the ~/.makepl_args.mod_perl with: EVERYTHING=1 USE_APACI=1 APACI_ARGS=--enable-module=rewrite APACI_ARGS=--enable-module=ssl APACI_ARGS=--enable-module=proxy export SSL_BASE=/opt/ssl; export APACHE_PREFIX=/opt/apache/1.3.9; ls $SSL_BASE/lib shows me libcrypto.a libssl.a [could be first scewup, SSL_BASE == install dir w/ lib include or ./lib itself?] perl Makefile.PL; make -wk 21 | tee Make.log; which then finally gives me: make[3]: Entering directory `/var/CPAN/build/apache_1.3.9/src' make[3]: *** No rule to make target `all'. wunnerful. as a variation i blew off apache-1.3.9, ran all the steps as above without the make after configuring mod_ssl, went directly to the perl Makefile.PL. same result. blowing off apache-1.3.9 one more time and running the usual apaci config make w/ mod_perl only works fine. something i'm screwing up w/ the two of them... system is heavily hacked RH-6.0 w/ current perl: Linux dizzy.wrkhors.com 2.2.14 #19 SMP Sat Jan 8 00:59:20 CST 2000 i686 unknown Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration: Platform: osname=linux, osvers=2.2.13, archname=i686-linux uname='linux dizzy.wrkhors.com 2.2.13 #9 smp sat nov 13 22:03:19 cst 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' ccflags ='-Dbool=char -DHAS_BOOL' 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 -lndbm -lgdbm -ldb -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 Nov 16 1999 19:32:59 @INC: /opt/perl5/lib/5.00503/i686-linux /opt/perl5/lib/5.00503 /opt/perl5/lib/site_perl/5.005/i686-linux /opt/perl5/lib/site_perl/5.005 . from email archive: snip Installing mod_ssl was a breeze for me. I followed mod_ssl's instructions for "b) The flexible APACI-only way": ./configure --with-apache=../apache_1.3.x Then: mod_perl-x.xx % SSL_BASE=... perl Makefile.PL ... make test make install For your configure options, just create a $HOME/.makepl_args.mod_perl that looks like so: APACHE_PREFIX=/weblab/software/packages/apache-1.3.2 APACI_ARGS=--enable-module=rewrite APACI_ARGS=--enable-module=ssl When Makefile.PL is run, it'll read in those options and pass then to Apache's configure script. -- Steven Lembark 2930 W. Palmer St. Chicago, IL 60647 [EMAIL PROTECTED] 800-762-1582