[25997] in Perl-Users-Digest
Perl-Users Digest, Issue: 8216 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 30 11:05:31 2005
Date: Thu, 30 Jun 2005 08:05:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 30 Jun 2005 Volume: 10 Number: 8216
Today's topics:
Re: Checking IP addresses against lists of IPs, partial axel@white-eagle.invalid.uk
Re: FAQ 6.9 What is "/o" really for? <bart.lateur@pandora.be>
Re: SOAP::Lite proxied <scobloke2@infotop.co.uk>
Re: SOAP::Lite proxied <scobloke2@infotop.co.uk>
Re: SOAP::Lite proxied <1usa@llenroc.ude.invalid>
weird behavior with open and pipe <moritz.karbach@desy.de>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 30 Jun 2005 10:06:35 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: Checking IP addresses against lists of IPs, partial IPs, and netmasks.
Message-Id: <LuPwe.39751$Vo6.5883@fe3.news.blueyonder.co.uk>
Joe Smith <joe@inwap.com> wrote:
> axel@white-eagle.invalid.uk wrote:
>>>192.168.2.3
>>>192.168.
>>>192.168.2.0/255.255.255.0
>>>192.168.2.0/24
>> However I suspect you are wanting to do more than that and check
>> if the IP address is within a certain range... but then you would
>> need to supply more information about the address to be checked
>> (i.e. what class of address).
> I've seen that syntax before. The class of address _is_ being provided.
> 192.168. = 192.168.*.* = 192.168.0.0:255.255.0.0 = 192.168/16
> 192.168.2 = 192.168.2.* = 192.168.2.0:255.255.255.0 = 192.168.2/24
> 192.168.2.0/24 = 192.168.2/24
> 192.168.2.3 = 192.168.2.3:255.255.255.255 = 192.168.2.3/32
No it was not provided. Only an IP number was provided to be matched.
The class of which is unknown... except in the era of pre-classless
addresses.
We know what a 192.168 number is by simply looking at it... a
private number... but if the number had been 194... it would be a
different story.
Axel
------------------------------
Date: Thu, 30 Jun 2005 09:52:16 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: FAQ 6.9 What is "/o" really for?
Message-Id: <71g7c1tod9eah03udnntkasva4pic2dtgk@4ax.com>
PerlFAQ Server wrote:
> Using a variable in a regular expression match forces a re-evaluation
> (and perhaps recompilation) each time the regular expression is
> encountered.
Hmm, isn't this info outdated? At least the latest versions of Perl (and
already since 5.6.x at least, IIRC), do cache the string value and don't
recompile the regex is it hasn't changed. In many of my tests, /$pat/o
was *not* faster than just /$pat/, with an unchanged variable.
Anyway, I'd like to see the things I mention here off the top of my
head, incorporated into this FAQ entry.
--
Bart.
------------------------------
Date: Thu, 30 Jun 2005 08:51:46 +0000 (UTC)
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Re: SOAP::Lite proxied
Message-Id: <da0bqv$4ih$1@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com>
A. Sinan Unur wrote:
> Ian Wilson <scobloke2@infotop.co.uk> wrote in
> news:d9tq3u$k3n$1@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com:
>
>
>> With LWP::UserAgent, you can also do things like
>> $ua->proxy('http'=>'http://proxy.server:8080');
>> $request->proxy_authorization_basic('fred', 'secret'); Is there any
>> way to do something equivalent using SOAP::Lite?
>
>
> Are you asking us to look up documentation for you?
Certainly not! My apologies for not stating that I had already read that
document.
> http://search.cpan.org/~byrne/SOAP-Lite-0.60a/lib/SOAP/Lite.pm
>
> <blockquote> In addition to endpoint parameter, proxy() can accept
> any transport specific parameters that could be passed as name =>
> value pairs. For example, to specify proxy settings for HTTP protocol
> you may do:
>
> $soap->proxy('http://endpoint.server/', proxy => ['http' =>
> 'http://my.proxy.server/']); </blockquote>
I hadn't found anywhere in that document where it explains how to set
the credentials required by the proxy for authorization - i.e. a user-ID
and password (for the HTTP proxy, not the endpoint).
There are however some clues in the soaplite cookbook, I have tried all
of these. I will follow-up with some sanitized code later.
I have tried, for example:
$soap->proxy('http://user:pass@endpoint.server/',
proxy => ['http' => 'http://my.proxy.server/']);
and
$soap->proxy('http://endpoint.server/',
proxy => ['http' => 'http://user:pass@my.proxy.server/']);
The former is suggested in the cookbook. It seems like it should
authenticate to the endpoint not to the HTTP proxy so I tried the latter
variant as well.
> Now, I have never tried this, and I don't know if it works, but I
> would have expected you to at least attempt it yourself,
You are right to expect this and I have indeed tried a half dozen
variants of this, I should have said so (I worry that long posts tend to
make people's eyes glaze over)
I also checked what is happening with "use SOAP::Lite +trace;"
concurrently with a "tail -f /var/log/squid/access.log" at the HTTP
proxy server. I have used wget and a perl script using LWP::Useragent to
check the proxy and endpoint logging, use of environment variables,
explicit setting of credentials, etc. This would be a lot to post so
instead I'll construct a minimal example that readers could run.
> and provide a minimal but complete script that still exhibits the
> problem.
Will do, once I have found (or created) a public SOAP endpoint that I
can use for this purpose.
------------------------------
Date: Thu, 30 Jun 2005 11:29:36 +0000 (UTC)
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Re: SOAP::Lite proxied
Message-Id: <da0l2t$kp7$1@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com>
A. Sinan Unur wrote:
> Ian Wilson <scobloke2@infotop.co.uk> wrote in
> news:d9tq3u$k3n$1@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com:
>
>
>> With LWP::UserAgent, you can also do things like
>> $ua->proxy('http'=>'http://proxy.server:8080');
>> $request->proxy_authorization_basic('fred', 'secret'); Is there any
>> way to do something equivalent using SOAP::Lite?
>
>
> I would have expected you to ... provide a minimal but complete
> script that still exhibits the problem.
>
As should have been evident from my original post. I have code that
retrieves the correct result on one computer but not when run on another
computer (both same flavour of Unix) - so I'd not expect to find a fatal
error in the Perl scripts below.
On computer-A, with proxy-A, the clients return
...
"37.5 C = 99.5 F"
On computer-B, with proxy-B, the clients fail:
...
"407 Proxy Authentication Required"
client1 - relies on (undocumented?) environment variables
Korn shell:
export HTTP_proxy=http://proxy.example.com \
HTTP_proxy_user=Dirk \
HTTP_proxy_pass=foo
./soaptempclient1.pl
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
#!/usr/bin/perl -w
use strict;
use warnings;
use SOAP::Lite;
my $c = shift @ARGV;
$c = 37.5 unless $c;
foreach (qw(HTTP_proxy HTTP_proxy_user HTTP_proxy_pass)) {
print "$_='$ENV{$_}'\n" unless not defined $ENV{$_};
}
print
"$c C = ",
SOAP::Lite
-> uri('http://www.example.org/Temperatures')
-> proxy ('http://www.example.org/cgi-bin/soaptemp.pl')
-> c2f($c)
-> result,
" F\n";
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
client2 explicitly sets credentials using an approach that is not
explicitly documented anywhere I have found so far. Note that the user
and password for the HTTP proxy are "Dirk" and "foo" respectively. The
SOAP endpoint does not require authentication.
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
#!/usr/bin/perl -w
use strict;
use warnings;
use SOAP::Lite;
my $c = shift @ARGV;
$c = 37.5 unless $c;
foreach (qw(HTTP_proxy HTTP_proxy_user HTTP_proxy_pass)) {
print "$_='$ENV{$_}'\n" unless not defined $ENV{$_};
}
print
"$c C = ",
SOAP::Lite
-> uri('http://www.example.org/Temperatures')
-> proxy ('http://www.example.org/cgi-bin/soaptemp.pl',
proxy => ['http' => 'http://Dirk:foo@12.34.56.78:8080'])
-> c2f($c)
-> result,
" F\n";
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
server script soaptemp.pl
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
#!/usr/bin/perl -w
use SOAP::Transport::HTTP;
SOAP::Transport::HTTP::CGI
-> dispatch_to('Temperatures')
-> handle;
package Temperatures;
sub f2c {
my ($class, $f) = @_;
return 5/9*($f-32);
}
sub c2f {
my ($class, $c) = @_;
return 32+$c*9/5;
}
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
For proxy-A, I use Squid. In squid.conf I added
authenticate_program /usr/local/bin/squidauth.pl
acl authentic proxy_auth REQUIRED
http_access allow authentic
http_access deny all
proxy_auth_realm Ians Proxy
squidauth.pl (verbatim from squid docs) is
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
#!/usr/bin/perl -w
$|=1; # no buffering, important!
while (<>) {
chop;
($u,$p) = split;
$ans = &check($u,$p);
print "$ans\n";
}
sub check {
local($u,$p) = @_;
return 'ERR' unless (defined $p && defined $u);
return 'OK' if ('Dirk' eq $u);
return 'OK' if ('Sekrit' eq $p);
return 'ERR';
}
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
I'll have to get the proxy-B administrator to check that it accepts
basic authentication (as opposed to NTLM, Digest or others only)
In my view, HTTP-proxy authentication *could* be better documented in
the SOAP::Lite docs. YMMV.
------------------------------
Date: Thu, 30 Jun 2005 14:28:13 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: SOAP::Lite proxied
Message-Id: <Xns96856A81CBF12asu1cornelledu@127.0.0.1>
Ian Wilson <scobloke2@infotop.co.uk> wrote in
news:da0bqv$4ih$1@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com:
> A. Sinan Unur wrote:
>> Ian Wilson <scobloke2@infotop.co.uk> wrote in
>> news:d9tq3u$k3n$1@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com:
>>
>>
>>> With LWP::UserAgent, you can also do things like
>>> $ua->proxy('http'=>'http://proxy.server:8080');
>>> $request->proxy_authorization_basic('fred', 'secret'); Is there any
>>> way to do something equivalent using SOAP::Lite?
>>
>>
>> Are you asking us to look up documentation for you?
>
> Certainly not! My apologies for not stating that I had already read
> that document.
OK, sorry about that. So many people do post without looking that if it
is not explicitly stated, I tend to assume they haven't/
>> http://search.cpan.org/~byrne/SOAP-Lite-0.60a/lib/SOAP/Lite.pm
>>
>> <blockquote> In addition to endpoint parameter, proxy() can accept
>> any transport specific parameters that could be passed as name =>
>> value pairs. For example, to specify proxy settings for HTTP protocol
>> you may do:
>>
>> $soap->proxy('http://endpoint.server/', proxy => ['http' =>
>> 'http://my.proxy.server/']); </blockquote>
>
> I hadn't found anywhere in that document where it explains how to set
> the credentials required by the proxy for authorization - i.e. a
> user-ID and password (for the HTTP proxy, not the endpoint).
Hmmm ... I can't either. On the other hand,
http://search.cpan.org/~byrne/SOAP-Lite-
0.60a/lib/SOAP/Transport/HTTP.pm#PROXY_SETTINGS
does have a section on it. The key phrase seems to be:
<quote>
You can use any proxy setting you use with LWP::UserAgent modules:
</quote>
Unfortunately, LWP::UserAgent docs do not give much information either.
However, here is the relevant snippet from SOAP::Transport::HTTP:
my $req = HTTP::Request->new($method => $endpoint,
(defined $headers ? $headers : HTTP::Headers->new),
$req->protocol('HTTP/1.1');
$req->proxy_authorization_basic(
$ENV{'HTTP_proxy_user'},
$ENV{'HTTP_proxy_pass'}
) if ($ENV{'HTTP_proxy_user'}
&& $ENV{'HTTP_proxy_pass'}
);
(source reformatted to fit).
This leads me to believe the environment variable method should work.
> $soap->proxy('http://endpoint.server/',
> proxy => ['http' => 'http://user:pass@my.proxy.server/']);
And, this should work as well:
<URL:http://search.cpan.org/~byrne/SOAP-Lite-
0.60a/lib/SOAP/Transport/HTTP.pm#SYNOPSIS>
So, I am not sure how I could help you with the problem (it seems like
this is an issue caused by something other than SOAP::Lite), especially
since I do not have a setup where I can try things.
I would focus on the differences rather than the similarities between
the two systems. Are two systems going through the same proxy?
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Thu, 30 Jun 2005 16:03:44 +0200
From: Moritz Karbach <moritz.karbach@desy.de>
Subject: weird behavior with open and pipe
Message-Id: <da0u40$gihn$1@claire.desy.de>
Hi,
I'm still tuning the run()-function of my Command class (see some older
postings of mine, if you like).
I'm using
open($fh_child,"-|");
to fork and to open a pipe to the child, which then exec's a system command.
The parent uses
my @output = <$fh_child>;
close($fh_child);
to receive the output. Here is the problem:
If the childs executes a certain system command and the system command gets
killed externally (by a watchdog), sometimes the parent doesn't receive any
output! Yes, I'm sure, that the system command has written something to std
out before it got killed.
The weird thing is, that if I execute something like
<test.sh>
#!/bin/bash
echo "this is a test"
sleep 10
</test.sh>
and if I kill the process after say 5 seconds, the parent indeed receives
the line "this is a test"!
Obviously it must be some difference in the binaries/system commands. Any
idea, what could be the reason for this difference? Is there a possible
workaround?
I already tried
while ( my $line = <$fh_child> )
{
push ( @{$this->{output}}, $line );
#print "X " . $line;
}
without success...
Cheers,
- Moritz
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 8216
***************************************