Hi all,
The tests for mod_access fail if 127.0.0.1 does not resolve as "localhost"
(mine resolves as "localhost.localdomain"). This patch fixes it.
I changed the regexp matches to explicit equals where possible, since
changing /^from localhost$/ to /^from $localhost_name$/ could hide all
kinds of problems when there are dots in the hostnames.
Oh, and it needs the Socket package to access the constant AF_INET...
Gary
[ Gary Benson, Red Hat Europe ][ [EMAIL PROTECTED] ][ GnuPG 60E8793A ]
Index: t/modules/access.t
===================================================================
RCS file: /home/cvspublic/httpd-test/perl-framework/t/modules/access.t,v
retrieving revision 1.2
diff -u -r1.2 access.t
--- t/modules/access.t 2001/08/08 17:53:10 1.2
+++ t/modules/access.t 2001/08/28 09:56:40
@@ -4,14 +4,18 @@
use Apache::Test;
use Apache::TestRequest;
use Apache::TestConfig;
+use Socket;
##
## mod_access test
##
+my $localhost_addr = pack('C4', 127, 0, 0, 1);
+my $localhost_name = gethostbyaddr($localhost_addr, AF_INET);
+
my @localhost = (
'from all',
- 'from localhost',
+ "from $localhost_name",
'from 127.0.0.1',
'from 127.0',
'from 127.0.0.1/255.255.0.0',
@@ -47,8 +51,8 @@
## denying by default
if ($allow =~ /^from 127/
- || $allow =~ /^from localhost$/
- || $allow =~ /^from all$/) {
+ || $allow eq "from $localhost_name"
+ || $allow eq 'from all') {
## if we are explicitly allowed, its ok
ok GET_OK "/modules/access/htaccess/index.html";
@@ -71,8 +75,8 @@
## allowing by default
if ($deny =~ /^from 127/
- || $deny =~ /^from localhost$/
- || $deny =~ /^from all$/) {
+ || $deny eq "from $localhost_name"
+ || $deny eq 'from all') {
## if we are denied explicitly
## its not ok
@@ -102,16 +106,16 @@
## allowing by default
if ($allow =~ /^from 127/
- || $allow =~ /^from localhost$/
- || $allow =~ /^from all$/) {
+ || $allow eq "from $localhost_name"
+ || $allow eq 'from all') {
## we are explicitly allowed
## so it is ok.
ok GET_OK "/modules/access/htaccess/index.html";
} elsif ($deny =~ /^from 127/
- || $deny =~ /^from localhost$/
- || $deny =~ /^from all$/) {
+ || $deny eq "from $localhost_name"
+ || $deny eq 'from all') {
## if we are not explicitly allowed
## and are explicitly denied,
@@ -131,16 +135,16 @@
## denying by default
if ($deny =~ /^from 127/
- || $deny =~ /^from localhost$/
- || $deny =~ /^from all$/) {
+ || $deny eq "from $localhost_name"
+ || $deny eq 'from all') {
## if we are explicitly denied,
## we get no access.
ok !GET_OK "/modules/access/htaccess/index.html";
} elsif ($allow =~ /^from 127/
- || $allow =~ /^from localhost$/
- || $allow =~ /^from all$/) {
+ || $allow eq "from $localhost_name"
+ || $allow eq 'from all') {
## if we are not explicitly denied
## and are explicitly allowed,