apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <wr...@rowe-clan.net>
Subject Outch - what a tangled web.
Date Thu, 03 Jan 2002 00:59:43 GMT
I've been diagnosing our failures of httpd.

My Win32 machine has the usual, bogus computer name (v505, in my case.)
There is no 'magic' DNS going on, Win32 is usually clueless.  And since
I cannot convice my machine to look in any DNS other than the 'blessed
Windows Domain Server' [I have none], I'd created a few entries in the
local HOSTS file that map my www#.rowe-clan.net addresses to their true
IP addresses.  Now Win32 and the rest of the world can agree on names.


A typical machine with a BSD-derrived stack should do the following;

use Socket ();

my $lip = Socket::inet_aton('localhost');
my $slip = join('.', unpack("C4",$lip));
print "localhost is at $slip\n";

my $lname = gethostbyaddr($lip, Socket::AF_INET());
print "$slip is named $lname\n";

my $rip = Socket::inet_aton($lname);
my $srip = join('.', unpack("C4",$rip));
print "$lname is at $srip\n";

my $rname = gethostbyaddr($rip, Socket::AF_INET());
print "$srip is named $rname\n";


The results?

localhost is at 127.0.0.1
127.0.0.1 is named localhost
localhost is at 127.0.0.1
127.0.0.1 is named localhost


But Windows is a different beast;

localhost is at 127.0.0.1
127.0.0.1 is named v505
v505 is at 208.176.192.147
208.176.192.147 is named www2.rowe-clan.net

That's a leap, wouldn't you say?

This is what is causing the httpd-tests for t/modules/access.t to fail,
since the machine isn't sure which stack its on.

This has some pretty big ramifications, I think, when we start to look
at a big picture.  The following little patch solves the problems.

Index: Apache-Test/lib/Apache/TestConfig.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfig.pm,v
retrieving revision 1.118
diff -u -r1.118 TestConfig.pm
--- Apache-Test/lib/Apache/TestConfig.pm 31 Dec 2001 06:39:30 -0000 1.118
+++ Apache-Test/lib/Apache/TestConfig.pm 3 Jan 2002 00:29:49 -0000
@@ -478,6 +478,13 @@
 sub default_servername {
     my $self = shift;
     $localhost ||= $self->default_localhost;
+    if (WIN32) {
+        my $ip = Socket::inet_aton($localhost);
+        if ($ip ne pack('C4', 127, 0, 0, 1)) {
+            $localhost = gethostbyaddr($ip, 'localhost');
+        }
+    }
+    $localhost;
 }
 
 #XXX: could check if the port is in use and select another if so

And all tests begin to fly :)  So I took this a step further, and thought, 
heck, why not the remote name?

Index: Apache-Test/lib/Apache/TestConfig.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfig.pm,v
retrieving revision 1.118
diff -u -r1.118 TestConfig.pm
--- Apache-Test/lib/Apache/TestConfig.pm 31 Dec 2001 06:39:30 -0000 1.118
+++ Apache-Test/lib/Apache/TestConfig.pm 3 Jan 2002 00:31:02 -0000
@@ -478,6 +478,13 @@
 sub default_servername {
     my $self = shift;
     $localhost ||= $self->default_localhost;
+    if (WIN32) {
+        my $ip = Socket::inet_aton($localhost);
+        if ($ip ne pack('C4', 127, 0, 0, 1)) {
+            $localhost = gethostbyaddr($ip, Socket::AF_INET());
+        }
+    }
+    $localhost;
 }
 
 #XXX: could check if the port is in use and select another if so

Which should do pretty much the same bit, and uses my www2.rowe-clan.net name.

Unfortuantely, that bites.  Fails vhost_alias and all SSL tests.  So now we know
this affecting the perl tests, and vhosts through APR. 

I don't have any quick solutions, but I figured I better draw this out before it
begins to bite others.

So

Bill



Mime
View raw message