Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Sep 2000 13:08:19 -0700 (PDT)
From:      dhw@whistle.com
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/21600: Case-insensitive sort/summary for mail rejects
Message-ID:  <200009272008.e8RK8J815962@pau-amma.whistle.com>

next in thread | raw e-mail | index | archive | help

>Number:         21600
>Category:       bin
>Synopsis:       /etc/periodic/daily/460.status-mail-rejects is case-sensitive
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Sep 27 13:10:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     David Wolfskill
>Release:        FreeBSD 4.1-STABLE i386
>Organization:
Whistle Communications
>Environment:

	/etc/periodic/daily/460.status-mail-rejects is at 1.8.2.2.

>Description:

	Host names are case-insensitive (as far as DNS is concerned,
	at least).  It is thus a bit counter-intuitive to have the
	output (under "Checking for rejected mail hosts:") in the "daily
	run output" show such things as:

	Checking for rejected mail hosts:
	 156 interjetnet.net
	  63 whistle.com
	  13 INTERJETNET.NET
	   7 interjetnet.com
	   3 [203.69.38.37]
	   3 WHISTLE.COM
	   2 INTERJETNET.COM
	   1 mail.com
	   1 InterJetNet.net
	   1 <dts1.domedia.com.tw

	when the "interjetnet.net" and "INTERJETNET.NET" entries refer
	to effectively the same (broken) destination.

>How-To-Repeat:

	Be the recipient of messages from spammers who use inconsistent
	capitalization in host names....  :-}

>Fix:

	Well, I'd suggest the following, which takes care of the
	immediate problem:

===================================================================
RCS file: RCS/460.status-mail-rejects,v
retrieving revision 1.1
diff -u -r1.1 460.status-mail-rejects
--- 460.status-mail-rejects	2000/09/27 19:17:41	1.1
+++ 460.status-mail-rejects	2000/09/27 19:18:58
@@ -37,6 +37,6 @@
 	    } |
 		perl -ne "print \"\$2\n\"
 		    if (/reject=/ and /^$start.*ruleset=check_\S+,\s+arg1=(<[^@]+@)?([^>,]+).*reject=/o);" |
-		sort | uniq -c | sort -nr
+		sort -f | uniq -ic | sort -fnr
 	fi;;
 esac


	It does not nesessarily ensure any sort of consistency in the
	output, though -- before:

	Checking for rejected mail hosts:
	 156 interjetnet.net
	  63 whistle.com
	  13 INTERJETNET.NET
	   7 interjetnet.com
	   3 [203.69.38.37]
	   3 WHISTLE.COM
	   2 INTERJETNET.COM
	   1 mail.com
	   1 InterJetNet.net
	   1 <dts1.domedia.com.tw

	and after:

	Checking for rejected mail hosts:
	 170 INTERJETNET.NET
	  66 WHISTLE.COM
	   9 INTERJETNET.COM
	   3 [203.69.38.37]
	   1 mail.com
	   1 <dts1.domedia.com.tw

	
	So it's a bit of a hack, but it makes life a little easier on a
	postmaster....  :-}  Another alternative would be to hack the Perl
	part to lowercase the hostnames that are emitted:

===================================================================
RCS file: RCS/460.status-mail-rejects,v
retrieving revision 1.1
diff -u -r1.1 460.status-mail-rejects
--- 460.status-mail-rejects     2000/09/27 19:17:41     1.1
+++ 460.status-mail-rejects     2000/09/27 19:55:02
@@ -35,8 +35,8 @@
                done
                cat /var/log/maillog
            } |
- 		perl -ne "print \"\$2\n\"
- 		    if (/reject=/ and /^$start.*ruleset=check_\S+,\s+arg1=(<[^@]+@)?([^>,]+).*reject=/o);" |
+ 		perl -ne 'print lc($2) . "\n"
+ 		    if (/reject=/ and /^$start.*ruleset=check_\S+,\s+arg1=(<[^@]+@)?([^>,]+).*reject=/o);' |
                sort | uniq -c | sort -nr
        fi;;
 esac

	(So, a bit of time elapsed while I got the quoting right, which
	is why the numbers differ.)  Here's a result from this version:

	Checking for rejected mail hosts:
	 268 interjetnet.net
	 111 whistle.com
	  16 interjetnet.com
	   8 sginet.com
	   6 www.bhes.wash.k12.ut.us.
	   6 www.bhes.wash.k12.ut.us
	   5 [203.69.38.37]
	   1 www.bhes.wash.k12.ut.us.com
	   1 whispersintimates.cominfo@whistle.com
	   1 mail.com
	   1 <dts1.domedia.com.tw

	(That trailing dot is a bit annoying... but I'm running low on
	time to fix it....)

>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200009272008.e8RK8J815962>