OT: Help with SQL SELECT on Varchar from character 0..n
Hi, I'm using postgres and remember having done something ages ago with some operator in mysql, although it makes zero sense to me now as to how I did it the first time. What I want to do is have a select return a partial string from the ith character of a string to the jth character of a string. I'd like postgres to filter this partial string and return it to me. Any ideas how I can go about doing this without using postgres regular expressions? Am I simply imagining that I managed to do this the first time around? Or should I be ashamed that I don't remember how to do it this time around? Cheers, Rafiq
Re: OT: Help with SQL SELECT on Varchar from character 0..n
Doh! SUBSTR - I forgot to wear my brain this morning. On Tue, 17 Sep 2002, Rafiq Ismail (ADMIN) wrote: Hi, I'm using postgres and remember having done something ages ago with some operator in mysql, although it makes zero sense to me now as to how I did it the first time. What I want to do is have a select return a partial string from the ith character of a string to the jth character of a string. I'd like postgres to filter this partial string and return it to me. Any ideas how I can go about doing this without using postgres regular expressions? Am I simply imagining that I managed to do this the first time around? Or should I be ashamed that I don't remember how to do it this time around? Cheers, Rafiq
Re: Error messages in Apache::Registry
On 16 Sep 2002 at 18:10, Perrin Harkins wrote: The way that most people would recommend in A::R or anything else is to trap errors with eval blocks and then handle them appropriately. I thought I was doing that at a global level by throwing an error with die() that was caught by CGI::Carp. I'm realizing that it isn't so simple. Unfortunately, CGI::Carp is still not displaying my custom error message which I set in a BEGIN block using the set_message() function. I don't know a lot about CGI::Carp specifically, but I'm guessing it tries to avoid catching any dies inside of evals, so you will probably have to modify it or roll your own if you want that behavior. Ahhh, that makes sense. Of course, my application still stops executing, but I guess that is because the error percolated up to mod_perl then back down to CGI::Carp which had set the %SIG hash. I guess this system wouldn't work if I try to redefine the set_message function in other Registry scripts since CGI::Carp is not being instantiated individually in each script (or is it??). If it uses globals (as opposed to an OO interface) then it's the same globals for every Registry script. That would be a problem if you only set it in the BEGIN block, but you could easilly set it on every execution of the script. Ohh, well isn't that a good idea ;-p. I feel like a beginner all over again in this environment. If you leave $ set, it will cause A::R to return a SERVER_ERROR status and apache will send a generic error page after your message. Oh, so if I handle the error myself, I should unset $@? I didn't see this in the example mydie function in the Guide. However, exit 1 is called at the end of the subroutine which may be sufficient for bypassing the A::R check. You can override die, or install a signal handler for the DIE hook, or wrap your code in an eval block. One of the the members of the CGI::Application mailing list suggested using Graham Barr's Error module and a wrap around the instantiation script. It's an interesting approach which I'm going to take a look at today. Indeed, it appears that the suggestion in the Code Snippets section of the mod_perl guide http://perl.apache.org/docs/1.0/guide/snippets.html#Redirecting_Errors_t o_ the_Client_Instead_of_error_log will not work as given for Apache::Registry scripts. It should work. The signal handler is called even inside an eval. Hmm, I'll try again. I still am having no luck. I've walked through the execution with the debugger and am finding that Carp::longmess_heavy is catching my die() calls despite the fact that I have set `local $SIG{__DIE__} = \mydie;`. I was using the diagnostics and warnings pragmas but turned them off (diagnostics was catching the die before Carp). However, I'm not using Carp... except in my startup.pl that I copied from somewhere on the net: `$SIG{__WARN__} = \Carp::cluck;` I removed that code but am still getting Carp being called before my custom handler. It must be some library I'm using but why wouldn't my localized %SIG override this value? Very confused, William -- Lead Developer Knowmad Services Inc. || Internet Applications Database Integration http://www.knowmad.com
Re: Error messages in Apache::Registry
William McKee wrote: The way that most people would recommend in A::R or anything else is to trap errors with eval blocks and then handle them appropriately. I thought I was doing that at a global level by throwing an error with die() that was caught by CGI::Carp. I'm realizing that it isn't so simple. Matt wrote some stuff for the guide explaining why the die handler is not the best approach. Basically, it means all errors will be treated the same. Oh, so if I handle the error myself, I should unset $@? No, I think I was wrong about that. You shouldn't need to unset it yourself. One of the the members of the CGI::Application mailing list suggested using Graham Barr's Error module and a wrap around the instantiation script. It's an interesting approach which I'm going to take a look at today. I don't recommend that. There's no reason to use Error instead of just an eval block. It can be this simple: eval { ... your code here ... }; if ($) { ... print nice error page with $ message ... } This will only work if you turn off all the DIE handlers. I still am having no luck. I've walked through the execution with the debugger and am finding that Carp::longmess_heavy is catching my die() calls despite the fact that I have set `local $SIG{__DIE__} = \mydie;`. As you discovered, this seems to be interference from the debugger. I'm not sure how to turn that off, although you could probably look at perl5db.pl and edit it. - Perrin
Re: Error messages in Apache::Registry
On 17 Sep 2002 at 13:27, Perrin Harkins wrote: Matt wrote some stuff for the guide explaining why the die handler is not the best approach. Basically, it means all errors will be treated the same. Ahh, right. Is this what you're referring to? http://perl.apache.org/docs/general/perl_reference/perl_reference.html#Alt ernative_Exception_Handling_Techniques Thanks for your persistence in helping me overcome my ignorance. William -- Lead Developer Knowmad Services Inc. || Internet Applications Database Integration http://www.knowmad.com
Linux + Apache Worm exploiting pre 0.9.6g OpenSSL vulnerabilitieson the loose
Hey, There seems to be a worm spreading for Apache + Linux + OpenSSL servers that I saw a discussion on at http://apache.slashdot.org/apache/02/09/13/2315246.shtml?tid=172 Seems like we need to upgrade our apache servers to OpenSSL 0.9.6g if we haven't already. I didn't see this posted to mod_perl yet, forgive me if this has been sent out already. Based on discussion at: http://online.securityfocus.com/bid/5363/discussion/ it seems that we might need to upgrade modssl as well, but I have not seen a release of modssl since June ( see http://www.modssl.org/news/ ), so this seems to not be necessary, but do not take my word for it, upgrade if you think its a good idea ( probably is anyway ). Regards, Josh Josh Chamas, Founder phone:925-552-0128 Chamas Enterprises Inc.http://www.chamas.com NodeWorks Link Checkinghttp://www.nodeworks.com
apche + mod_perl
Hi Guys, Having decided to give Linux a go I installed Linux and Apache on a spare machine at work with the intention of using it to run an intranet. I managed to run Apache succesfully to serve up simple HTML files, but I wanted some dynamic content so I installed Mod_perl as well. However I have run into a few difficulties regarding its configuration. The install process of mod_perl didn't throw up any errors and no lines were added to httpd.conf. I added a few lines that I found on a website to run mod_perl when Apache starts. Unfortunatley Apache generates errors with this config so I modified it so Apache starts. Could anyway tell me the lines I need to add to httpd.conf? Also, seeing as I've never used mod_perl (or Perl for that matter) I don't have any scripts, nor do I know how to add a script to a HTML page, so would it be possible for someone to tell me a very basic script that will merely let me know that it is running? System specs: RedHat Linux 7.1 (2.4.2-2) on i386 Apache installed in '/web/apache' Perl 5.6.0 Mod_perl 1.99_5 I realize that this is a very menial problem, but I scoured the Perl section of apache.org and couldn't find the information I required. Thankyou very much for any help you can offer. Testic
LibXML and PerlRun
I am having troubles using XML::LibXML with PerlRun. The script I am running runs just fine under CGI, but when using PerlRun, I get the following message: PerlRun: `Can't locate object method SendFault via package Entity: line 19: error: AttValue: ' expected SupplierRQ ID=7 TSID=thermeon.eds StartLoc=345 TSStartLoc= ^ Entity: line 19: error: attributes construct error SupplierRQ ID=7 TSID=thermeon.eds StartLoc=345 TSStartLoc= ^ Entity: line 19: error: Couldn't find end of Start Tag TravelSupplierRQ SupplierRQ ID=7 TSID=thermeon.eds StartLoc=345 TSStartLoc= ^ Entity: line 19: error: Extra content at the end of the document SupplierRQ ID=7 TSID=thermeon.eds StartLoc=345 TSStartLoc= ^ at /usr/local/link/PerlRun/link line 26 at /usr/local/link/PerlRun/link line 18, S chunk 21019. ' The same script input was used -- just the copy of the script in the cgi-bin directory works, and the copy in PerlRun doesn't. Here are excepts from /usr/local/link/PerlRun/link: #! /usr/bin/perl use strict; use XML::LibXML; my $parser = XML::LibXML-new(); eval { Main }; ##This is the line 18## if ($) { SendFault $; exit(500); } sub Main { #--- my $doc = $parser-parse_fh(\*STDIN); ## this is the line 26 ## my $message = $doc-documentElement(); ### things cut here -- read message and process it ### } sub SendFault { ### things cut here -- build an error message and print it to STDOUT ### }
Re: problem with $r-push_handlers()
I have traced my problem to the following subroutine which populates the Hash I use to keep track of mappings of URL's to Modules (handlers)to use. As you will see, at the very end of my parse_file subroutine I have two lines commented out. IF I uncomment these lines out, I end up overwriting the data in my hash with the clean data I supply. When I do this my Apache Multiplexer (the thing which does the $r-push_handlers($handler_bf)) works fine and all is fine. However if I leave the line commented out - as is here - I get the following error:- [Tue Sep 17 22:41:35 2002] [error] Undefined subroutine MyMod::Apache::Test1 called, GEN2 line 2. So I'm at a loss, any further help you could give would be useful, Marty Here is a sample file:- /test1/ = MyMod::Apache::Test1/test2/ = MyMod::Apache::Test2 Here is a file parsing subroutine I use to read the above file and populate a hash, which I export to another routine.:- our (%HANDLERS); sub _is_tainted{ not eval { join("",@_), kill 0; 1; };} sub parse_file{ my $file=shift; print STDERR "Parsing file $file\n"; open (FILE,"$file") or die "Cannot open file for reading $file"; while (my $line=FILE) { chomp $line; if ($line=~/^\#/) { next; } else { my ($keyname,$varname)=split/\=/,$line; print STDERR "Initial $keyname = $varname\n"; $keyname=~s/^\s*//; $varname=~s/^\s*//; $keyname=~s/\s*$//; $varname=~s/\s*$//; $keyname=~s/'//g; $varname=~s/'//g; $keyname=~s/"//g; $varname=~s/"//g; $keyname=~s/^\///; $keyname=~s/\/$//; my @tmp=split /\//, $keyname; my $untainted_keyname; while (@tmp) { my $tainted_var=shift @tmp; if ($tainted_var =~/^([\w-]+)$/) { $tainted_var=$1; die "$tainted_var is Tainted" if (_is_tainted($tainted_var)); $untainted_keyname.='/'.$tainted_var; die "$untainted_keyname is Tainted" if (_is_tainted($untainted_keyname)); } else { die "Taint Check failed for $tainted_var\n"; } } $untainted_keyname.='/'; if ($varname=~/^([-:\w]+)$/) { $varname=$1; die "$varname is Tainted" if (_is_tainted($varname)); } else { die "Taint Check failed for $varname\n"; } $HANDLERS{$untainted_keyname}=$varname; print STDERR "Added $keyname = $varname\n"; } } #$HANDLERS{'/test1/'}='MyMod::Apache::Test1'; #$HANDLERS{'/test2/'} = 'MyMod::Apache::Test2'; close (FILE);} - Original Message - From: Martin Moss To: [EMAIL PROTECTED] Sent: Tuesday, September 17, 2002 2:13 AM Subject: problem with $r-push_handlers() All, can anybody provide any help with this problem - and maybe explain why I get the following anomoly? I've been trying to find the cause of the issue but to no avail:-( I have MyMod::Apache::Test pre-loaded in my httpd.conf file. Here is an extract of code:- ($handler is defined from a Hash defined within this Code) ($handler_bf is defined from a hash exported by a module used in this code. to get to the stage in the code where the following lines commence, I already have read the value from the exported hash and it is held in the variable $handler_bf) #$r-push_handlers(PerlHandler = $handler);$r-push_handlers(PerlHandler = $handler_bf); print STDERR "They match\n ($handler) = ($handler_bf)\n" if ($handler eq $handler_bf); When I run the code I get the following error:- MyMod::Apache::Multiplex Matched /test/ to MyMod::Apache::Test (MyMod::Apache::Test) for /mod_perl_push_handlers: Not a subroutine name or CODE reference! at /usr/local/lib/perl//MyMod/Apache/Multiplex.pm line 101.They match(MyMod::Apache::Test) = (MyMod::Apache::Test) WHEREAS if I use the following code:- #$r-push_handlers(PerlHandler = $handler);$r-push_handlers(PerlHandler = $handler_bf); print STDERR "They match\n ($handler) = ($handler_bf)\n" if ($handler eq $handler_bf); It works and I get this output :- MyMod::Apache::Multiplex Matched /reconciler/test/ to MyMod::Apache::Test (MyMod::Apache::Test) for /They match(MyMod::Apache::Test) = (MyMod::Apache::Test) So I'm still at a loss. I've tried checking for tainted variables as the handler hash which fails is populated by reading the contents of files, whereas the other is simply defined in the script. I'm guessing this is something more subtle like a configuration problem. I've tried stopping a starting apache after making each change to the script. so each test is run on a fresh server. Anyway, Answers on a Postcard please:-) Regards Marty
RE: apche + mod_perl
Testic, Listed below are a few links that should get you on your way: First start with "The Guide" http://perl.apache.org/docs/1.0/guide/index.html. It has been very helpful to me when I have questions. Second go to http://www.modperlcookbook.org/(buy their book) It has some sample code and such which should help out immensely Finally visit http://modperl.com:9000/(buy this book also) It is a little hard to follow in the beginning, but it is worth while in the long run. I hope these help and good luck with you mod_perl adventure. Joe -Original Message-From: testic [mailto:[EMAIL PROTECTED]]Sent: Tuesday, September 17, 2002 3:22 PMTo: [EMAIL PROTECTED]Subject: apche + mod_perl Hi Guys, Having decided to give Linux a go I installed Linux and Apache on a spare machine at work with the intention of using it to run an intranet. I managed to run Apache succesfully to serve up simple HTML files, but I wanted some dynamic content so I installed Mod_perl as well. However I have run into a few difficulties regarding its configuration. The install process of mod_perl didn't throw up any errors and no lines were added to httpd.conf. I added a few lines that I found on a website to run mod_perl when Apache starts. Unfortunatley Apache generates errors with this config so I modified it so Apache starts. Could anyway tell me the lines I need to add to httpd.conf? Also, seeing as I've never used mod_perl (or Perl for that matter) I don't have any scripts, nor do I know how to add a script to a HTML page, so would it be possible for someone to tell me a very basic script that will merely let me know that it is running? System specs: RedHat Linux 7.1 (2.4.2-2) on i386 Apache installed in '/web/apache' Perl 5.6.0 Mod_perl 1.99_5 I realize that this is a very menial problem, but I scoured the Perl section of apache.org and couldn't find the information I required. Thankyou very much for any help you can offer. Testic
Re: LibXML and PerlRun
Hi Scott, I had lots of problems using XML under Apache until I recompiled Apache with the --disable-rule=EXPAT rule as partially described in the AxKit FAQ http://axkit.org/faq.xml. I'm new to the world of XML so don't know whether this will help you or not. You didn't mention a segfault but this is just the kind of thing I was experiencing when trying to use an XML library under mod_perl. Perhaps if someone from the AxKit project is reading this message, they can modify that FAQ to save others the trouble of figuring out how To compile Apache without expat, simply supply the option: RULE_EXPAT=NO. That is not a simple thing for new users g. Good luck, William -- Lead Developer Knowmad Services Inc. || Internet Applications Database Integration http://www.knowmad.com
RE: Linux + Apache Worm exploiting pre 0.9.6g OpenSSL vulnerabilities on the loose
Josh, I believe the virus only affects systems pre-0.9.6e: http://www.openssl.org/news/secadv_20020730.txt. Thanks, Christian - Christian Gilmore Technology Leader GeT WW Global Applications Development IBM Software Group -Original Message- From: Josh Chamas [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 17, 2002 2:43 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Linux + Apache Worm exploiting pre 0.9.6g OpenSSL vulnerabilities on the loose Hey, There seems to be a worm spreading for Apache + Linux + OpenSSL servers that I saw a discussion on at http://apache.slashdot.org/apache/02/09/13/2315246.shtml?tid=172 Seems like we need to upgrade our apache servers to OpenSSL 0.9.6g if we haven't already. I didn't see this posted to mod_perl yet, forgive me if this has been sent out already. Based on discussion at: http://online.securityfocus.com/bid/5363/discussion/ it seems that we might need to upgrade modssl as well, but I have not seen a release of modssl since June ( see http://www.modssl.org/news/ ), so this seems to not be necessary, but do not take my word for it, upgrade if you think its a good idea ( probably is anyway ). Regards, Josh Josh Chamas, Founder phone:925-552-0128 Chamas Enterprises Inc.http://www.chamas.com NodeWorks Link Checkinghttp://www.nodeworks.com
Re: problem with $r-push_handlers()
You are a star!!! I ammended your syntax slightly and did this:- my $sub_string='sub { '.$handler_bf.'($r) };'; $r-push_handlers(PerlHandler = eval $sub_string); Otherwise The handler routine of my handler module doesn't get passed the Apache object as it's first argument. It seems to work fine. Thank you. One point to ask, Is this less efficient, as I'm passing an anonynmous subroutine around rather than a code reference? I can finally go to bed :-) Kind regards Marty - Original Message - From: Marcin Kasperski [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, September 18, 2002 12:55 AM Subject: Re: problem with $r-push_handlers() MyMod::Apache::Multiplex Matched /test/ to MyMod::Apache::Test (MyMod::Apache::Test) for / mod_perl_push_handlers: Not a subroutine name or CODE reference! at /usr/local/lib/perl//MyMod/Apache/Multiplex.pm line 101. They match (MyMod::Apache::Test) = (MyMod::Apache::Test) I have observed similar problem myself. I got the same error when I wrote in my startup.pl Apache-push_handlers(PerlChildInitHandler, \MyApp::Main::on_child_init); when I replaced it with Apache-push_handlers(PerlChildInitHandler, sub { MyApp::Main::on_child_init(); }); it works as expected. -- ( Marcin Kasperski | You have the right to peace, fun, and ctive ) ( http://www.mk.w.pl |and enjoyable work. ) (--- -) ( Nie gub zgosze bdw: p://www.mk.w.pl/narzedzia/narzedzia_bugewid)
RE: Linux + Apache Worm exploiting pre 0.9.6g OpenSSL vulnerabilities on the loose
Christian Gilmore writes: I believe the virus only affects systems pre-0.9.6e: http://www.openssl.org/news/secadv_20020730. Also note that vendors may have retrofited older versions with the patch. For example, Red Hat still is at 0.9.5a 0.9.6b (see http://rhn.redhat.com/errata/RHSA-2002-160.html for more info) Rob
[OT] document management
I do work for a Land Use legal center from time to time. They have a project that eventually needs to find it's way onto the web in order to maximize information sharing. What I need to find is a system that would allow users to upload word and/or pdf and/or html files into a library system that would automatically extract keywords and then file the documents into a database. The goal of all this is to avoid having users doing double work, e.g. creating word docs only to convert, etc., while having a system that is as user friendly as possible because most of these users aren't technically savy. I've been doing searches for mod_perl non-mod_perl based solutions but haven't found anything (lot's of content management but no document management). TIA
Re: [OT] document management
On that note, lets go off into word matching - On Tuesday, September 17, 2002, at 10:15 PM, Erich Markert wrote: I've been doing searches for mod_perl non-mod_perl based solutions but haven't found anything (lot's of content management but no document management). Here is an example of word matching: #!C:\perl\bin\perl.exe #!/usr/bin/perl # A Perl filter that will take the selected text, sort the # words, put into a column, remove duplicates, then output a # word count by each. use strict; my %count; while (DATA) { for my $word (split) { next unless $word =~ /\w/; $word =~ s/^\W+//; $word =~ s/\W+$//; $count{lc $word}++; } } for my $word (sort keys %count) { print $word $count{$word}\n; } sleep 30; __END__ Dr. Seuss's Guide to the Internet (with apologies to Dr. Seuss and you sheep) Here's an easy game to play. Here's an easy thing to say. If a packet hits a pocket on a socket on a port, And the bus is interrupted as a very last resort, And the address of the memory makes your floppy disk abort, Then the socket packet pocket has an error to report! If your cursor finds a menu item followed by a dash, And the double-clicking icon puts your window in the trash, And your data is corrupted 'cause the index doesn't hash, Then your situation's hopeless, and your system's gonna crash! You can't say this? What a shame, sir! We'll find you Another game, sir. If the label on the cable on the table at your house, Says the network is connected to the button on your mouse, But your packets want to tunnel on another protocol That's repeatedly rejected by your printer down the hall, And your screen is all distorted by the side effects of Gauss, So your icons in the window are as wavy as a souse, Then you may as well reboot and go out with a bang, 'Cause as sure as I'm a poet, the sucker's gonna hang! When the copy of your floppy's getting sloppy on the disk, And the microcode instructions cause unnecessary RISC, Then you have to flash your memory and you'll want to RAM your ROM. Quickly turn off the computer and be sure to tell your mom! No, I didn't start this code, but I changed the data to protect the innocent... Cheers! -Bill- :] WC -Sx- Jones * Lead e-Systems Developer * http://insecurity.org/ FCCJ * 501 W State St * Jacksonville, FL 32202 * 1 (904) 632-3089 __ __ __ __ __ / // /__ ___ __ __ / // /__ _/ /_ / _ / _ `/ _ \/ _ \/ // / / _ / _ `/ __/ '_/ -_) __/ /_//_/\_,_/ .__/ .__/\_, / /_//_/\_,_/\__/_/\_\\__/_/ /_/ /_/ /___/ Running LinuxPPC UltraPenguin SuSE 7.3 (-Sx-) __ _ http://jacksonville.pm.org/ / /(_)_ __ _ ___ __ http://cis4dl.sf.net/ / / | | '_ \| | | \ \/ / http://www.suse.com/ / /__| | | | | |_| | http://www.perl.com/ \/_|_| |_|\__,_/_/\_\ http://www.fccj.edu/