Urb LeJeune on Wed, 30 Oct 2002 10:17:40 -0500


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

nslookup question


	I'm trying to fix the security problem in formmail.pl to automatically
configure itself. The fix that is out there checks the passed recipient field
against an array of acceptable recipients. The problem on an active
server is the script has to be updated every time a new recipient is added.

	The following subroutine is designed to take the recipient email
address and test to see if the domain name resolves to the IP address
of the server.

  my ($Email) = @_;
  return 0 unless $Email; # Invalid if no passed eamil address
  ($UserID,$Domain) = split("\@",$Email);
  $Text = `nslookup $Domain`; # Get the output from nslookup
  ($Junk,$Junk,$IPaddress) = split("Address: *",$Text);
  $IPaddress =~ s/\s+$//; # Remove trailing whitespace
  ($IPaddress eq $ENV{SERVER_ADDR}) ? return 1 : return 0;

	It works fine if the domain name is a valid domain name. If
it isn't the following line of text is displayed.

*** ns1.request.net can't find usats.abc: Non-existent host/domain

	What seems to be happening is that nslookup prints once
if there is a valid domain name and the output is captured in $Text.
However, it appears to be printing twice for an invalid domain name
and the second print is not captured. Is there a work around to this
problem?

	Thanks

Urb


**Majordomo list services provided by PANIX <URL:http://www.panix.com>** **To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**