Subject: | AnyEvent::Socket DNS does not use nsswitch.conf |
Date: | Fri, 24 May 2013 14:36:32 +1000 |
To: | <bug-AnyEvent [...] rt.cpan.org> |
From: | Ricky Cook <ricky [...] infoxchange.net.au> |
This bug could be deeper than just not using nsswitch.conf ("No such
device or address" seems a bit weird, given that DNS would fail, then
hosts file /should/ be used right away), however that is certainly
something that I have identified as being an issue. At the very least,
the hosts file should be parsed /before/ DNS, is this seems to be the
way most (if not all; I have yet to find one) distros handle DNS resolution.
*
Version*: AnyEvent-7.04
*Perl Version*: v5.14.2 built for x86_64-linux-gnu-thread-multi
*OS Info*: Linux jenkins-S2S-Trigger-Incremental-186 3.2.0-4-amd64 #1
SMP Debian 3.2.41-2+deb7u2 x86_64 GNU/Linux
*Incorrect HTTP::Response*:
$VAR1 = bless( {
'_content' => 'No such device or address',
'_rc' => 595,
'_headers' => bless( {}, 'HTTP::Headers' ),
'_msg' => 'No such device or address',
'_request' => bless( {
'_content' => '',
'_uri' => bless( do{\(my $o =
'http://selenium.jenkins-s2s-trigger-incremental-186.serv.abb.ixa.net.au:3000/')},
'URI::http' ),
'_headers' => bless( {},
'HTTP::Headers' ),
'_method' => 'GET'
}, 'HTTP::Request' )
}, 'HTTP::Response' );
*/etc/hosts*:
# HEADER: This file was autogenerated at Fri Apr 19 05:09:30 +0000 2013
# HEADER: by puppet. While it can still be managed manually, it
# HEADER: is definitely not recommended.
127.0.0.1 localhost
127.0.1.0 int-build-lxc-s2s.serv.abb.infoxchange.net.au
int-build-lxc-s2s
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
/(... snipped ip ...)/ puppet
127.0.0.1 demo.s2s.int-build.serv.abb.ixa.net.au
127.0.0.1 www.s2s.int-build.serv.abb.ixa.net.au
127.0.0.1 selenium
127.0.0.1 selenium.jenkins-s2s-trigger-incremental-186.serv.abb.ixa.net.au
*/etc/nsswitch.conf*:
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
passwd: compat
group: compat
shadow: compat
hosts: files dns
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis
*netstat -lntp*:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address
State PID/Program name
/(... snipped ...)/
tcp 0 0 127.0.0.1:3000 0.0.0.0:*
LISTEN -
/(... snipped ...)/
*To reproduce*:
perl -MAnyEvent::HTTP::LWP::UserAgent -MHTTP::Request -MData::Dumper -e
"print
Dumper(AnyEvent::HTTP::LWP::UserAgent->new->request(HTTP::Request->new(GET
=>
'http://selenium.jenkins-s2s-trigger-incremental-186.serv.abb.ixa.net.au/')))"
OR
perl -MAnyEvent::HTTP::LWP::UserAgent -MHTTP::Request -MData::Dumper -e
"print
Dumper(AnyEvent::HTTP::LWP::UserAgent->new->request(HTTP::Request->new(GET
=>
'http://selenium.jenkins-s2s-trigger-incremental-186.serv.abb.ixa.net.au:3000/')))"
*My work around so far is*:
use HTTP::Request::Common;
use Socket;
use URI;
my $uri_string =
'http://selenium.jenkins-s2s-trigger-incremental-186.serv.abb.ixa.net.au:3000/';
my $uri = URI->new($url_string) or die("Invalid URI: '$uri_string'");
my $host = $uri->host or die("No host in URI: '$uri_string'");
my $packed_host_ip = gethostbyname($host) or die("Could not get IP for
host: '$host'");
my $host_ip = inet_ntoa($packed_host_ip);
$uri->host($host_ip);
HTTP::Request::Common::GET($uri->as_string, 'Host' => $host);