You are viewing a plain text version of this content. The canonical link for it is here.
Posted to test-dev@httpd.apache.org by "William A. Rowe, Jr." <wr...@rowe-clan.net> on 2002/01/03 01:59:43 UTC

Outch - what a tangled web.

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



Re: Outch - what a tangled web.

Posted by Doug MacEachern <do...@covalent.net>.
On Sun, 6 Jan 2002, William A. Rowe, Jr. wrote:
 
> Which flavor OS, doug?

win2k (5.00.2195)
 
> Is there an option to t/TEST to pass the local machine name?

t/TEST -servername foo


Re: Outch - what a tangled web.

Posted by "William A. Rowe, Jr." <wr...@covalent.net>.
From: "Randy Kobes" <ra...@theoryx5.uwinnipeg.ca>
Sent: Sunday, January 06, 2002 5:13 PM


> From: "Doug MacEachern" <do...@covalent.net>
> Sent: Saturday, January 05, 2002 6:38 PM
> 
> > i wouldn't object to special casing to make win32 happy.  though i find it
> > odd that things are working ok as-is on my win32 box and on others.  is
> > there any info i can give you about my win32 setup that would help?  fwiw
> > your script outputs the following on my box:
> >
> > localhost is at 127.0.0.1
> > 127.0.0.1 is named bramble
> > bramble is at 10.0.1.2
> > 10.0.1.2 is named bramble

Ok... so your machine gets to identity in 3 reversions (lh->ip->lh->ip)

Which flavor OS, doug?

> For one more data point, on my Win98 machine, which is on a
> dial-up network without a permanent ip address, the script gives
> 
> 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
> 
> and the modules/access.t tests all pass.

Useful to know, Randy, thanks!  Windows NT and prior can be trivially
configured for the right name stuff; it's 2000 that gets prickly.

I need to iterate through the local name, the flipflop (that middle case
on my system example, 'v505') and the absolute name.

Is there an option to t/TEST to pass the local machine name?

Bill



Re: Outch - what a tangled web.

Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
----- Original Message -----
From: "Doug MacEachern" <do...@covalent.net>
To: "William A. Rowe, Jr." <wr...@rowe-clan.net>
Cc: <te...@httpd.apache.org>; <de...@apr.apache.org>
Sent: Saturday, January 05, 2002 6:38 PM
Subject: Re: Outch - what a tangled web.


> i wouldn't object to special casing to make win32 happy.  though i find it
> odd that things are working ok as-is on my win32 box and on others.  is
> there any info i can give you about my win32 setup that would help?  fwiw
> your script outputs the following on my box:
>
> localhost is at 127.0.0.1
> 127.0.0.1 is named bramble
> bramble is at 10.0.1.2
> 10.0.1.2 is named bramble

For one more data point, on my Win98 machine, which is on a
dial-up network without a permanent ip address, the script gives

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

and the modules/access.t tests all pass.

best regards,
randy kobes



Re: Outch - what a tangled web.

Posted by Doug MacEachern <do...@covalent.net>.
i wouldn't object to special casing to make win32 happy.  though i find it
odd that things are working ok as-is on my win32 box and on others.  is
there any info i can give you about my win32 setup that would help?  fwiw
your script outputs the following on my box:

localhost is at 127.0.0.1
127.0.0.1 is named bramble
bramble is at 10.0.1.2
10.0.1.2 is named bramble








Re: Outch - what a tangled web.

Posted by Doug MacEachern <do...@covalent.net>.
i wouldn't object to special casing to make win32 happy.  though i find it
odd that things are working ok as-is on my win32 box and on others.  is
there any info i can give you about my win32 setup that would help?  fwiw
your script outputs the following on my box:

localhost is at 127.0.0.1
127.0.0.1 is named bramble
bramble is at 10.0.1.2
10.0.1.2 is named bramble