Date: Wed, 2 Oct 2002 22:53:19 +0100 From: Ceri Davies <ceri@FreeBSD.org> To: www@FreeBSD.org Subject: Re: Patch to dosendpr.cgi for review Message-ID: <20021002215319.GB14511@submonkey.net> In-Reply-To: <20021002215129.GA14511@submonkey.net> References: <20021002215129.GA14511@submonkey.net>
next in thread | previous in thread | raw e-mail | index | archive | help
--8t9RHnE3ZwKMSgU+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Oct 02, 2002 at 10:51:29PM +0100, Ceri Davies wrote: > > As promised recently on developers, here's my patch to dosendpr.cgi for > review. > It's also available at http://www.submonkey.net/patches/dosendpr_cgi.diff "Also". Yeah, right.. Patch attached this time. Ceri -- you can't see when light's so strong you can't see when light is gone --8t9RHnE3ZwKMSgU+ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="dosendpr.cgi.diff" Index: dosendpr.cgi =================================================================== RCS file: /home/ncvs/www/en/cgi/dosendpr.cgi,v retrieving revision 1.8 diff -u -r1.8 dosendpr.cgi --- dosendpr.cgi 20 May 2002 07:14:41 -0000 1.8 +++ dosendpr.cgi 2 Oct 2002 21:16:37 -0000 @@ -12,6 +12,35 @@ require "html.pl"; +use Socket; + +my $blackhole = "relays.osirusoft.com"; +my $openproxyip = "127.0.0.9"; +my $blackhole_err = 0; +my $openproxy; + +# isopenproxy ($ip, $blackhole_zone, $positive_ip) +# Returns undef on error, 0 if DNS lookup fails, $positive_ip if verified +# proxy. A DNS lookup failing can either means that there was a network +# problem, or that the IP is not listed in the blackhole zone. +sub isopenproxy ($$$) { + # If $? is already set, then a successful gethostbyname() leaves it set + local $?; + my ($ip, $zone, $proxyip) = @_; + my ($reversed_ip, $packed); + if (!defined $proxyip) { return undef }; + + $reversed_ip = join('.', reverse split(/\./, $ip)); + $packed = gethostbyname("${reversed_ip}.${blackhole}"); + return undef if $?; + + if ($packed && (inet_ntoa($packed) eq $proxyip)) { + return $proxyip; + } else { + return 0; + } +} + sub prerror { &html_title ("Problem Report Error"); &html_body(); @@ -67,12 +96,24 @@ exit(1); } +$openproxy = isopenproxy($ENV{'REMOTE_ADDR'}, $blackhole, $openproxyip); +if (defined $openproxy) { + if ($openproxy) { + &prerror("$ENV{'REMOTE_ADDR'} is an open proxy server"); + } +} else { + $blackhole_err++; +} + # Build the PR. $pr = "To: $gnemail\n" . "From: $cgi_data{'originator'} <$cgi_data{'email'}>\n" . "Subject: $cgi_data{'synopsis'}\n" . - "X-Originating-IP: $ENV{'REMOTE_ADDR'}\n" . - "X-Send-Pr-Version: www-1.0\n\n" . + "X-Originating-IP: $ENV{'REMOTE_ADDR'}\n"; +if ($blackhole_err) { + $pr .= "X-Originating-IP-Is-Open-Proxy: Maybe\n"; +} +$pr .= "X-Send-Pr-Version: www-1.0\n\n" . ">Submitter-Id:\t$cgi_data{'submitterid'}\n" . ">Originator:\t$cgi_data{'originator'}\n" . ">Organization:\t$cgi_data{'organization'}\n" . --8t9RHnE3ZwKMSgU+-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-www" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021002215319.GB14511>