From reho@rx.cz  Fri Feb 17 11:05:35 2006
Return-Path: <reho@rx.cz>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 9193116A420;
	Fri, 17 Feb 2006 11:05:35 +0000 (GMT)
	(envelope-from reho@rx.cz)
Received: from charon.rx.cz (199.106.broadband4.iol.cz [85.71.106.199])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 3746643D46;
	Fri, 17 Feb 2006 11:05:33 +0000 (GMT)
	(envelope-from reho@rx.cz)
Received: from charon.rx.cz (localhost [127.0.0.1])
	by charon.rx.cz (8.13.4/8.13.4) with ESMTP id k1HB5V6G036250;
	Fri, 17 Feb 2006 12:05:31 +0100 (CET)
	(envelope-from reho@199.106.broadband4.iol.cz)
Received: (from root@localhost)
	by charon.rx.cz (8.13.4/8.13.4/Submit) id k1HB5VHc036249;
	Fri, 17 Feb 2006 12:05:31 +0100 (CET)
	(envelope-from reho)
Message-Id: <200602171105.k1HB5VHc036249@charon.rx.cz>
Date: Fri, 17 Feb 2006 12:05:31 +0100 (CET)
From: Petr Rehor <prehor@gmail.com>
Reply-To: Petr Rehor <prehor@gmail.com>
To: FreeBSD-gnats-submit@FreeBSD.org
Cc: matteo@FreeBSD.org
Subject: [patch] /etc/periodic/daily/440.status-mailq exits with bad value when daily_status_mailq_shorten is set to YES
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         93472
>Category:       conf
>Synopsis:       [patch] /etc/periodic/daily/440.status-mailq exits with bad value when daily_status_mailq_shorten is set to YES
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    matteo
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Feb 17 11:10:10 GMT 2006
>Closed-Date:    Sun Mar 12 18:45:29 GMT 2006
>Last-Modified:  Sun Mar 12 18:45:29 GMT 2006
>Originator:     Petr Rehor
>Release:        FreeBSD 6.0-RELEASE-c3 i386
>Organization:
>Environment:
System: FreeBSD charon.rx.cz 6.0-RELEASE-c3 FreeBSD 6.0-RELEASE-c3 #0: Tue Nov 8 20:44:39 UTC 2005 root@marvin.rx.cz:/usr/obj/usr/src/sys/GENERIC i386
>Description:
/etc/periodic/daily/440.status-mailq exits wits 0 when
daily_status_mailq_shorten is set to YES and you have two
mails with same recipient in mail queue.
>How-To-Repeat:
Put exactly two mails with same recipient to mail queue, set

	daily_status_mailq_shorten="YES"

in your /etc/periodic.conf and run

	/etc/periodic/daily/440.status-mailq; echo $?

It prints one about items in mail queue line to terminal but exits with 0.
>Fix:

--- 440.status-mailq.diff begins here ---
Index: 440.status-mailq
===================================================================
RCS file: /home/ncvs/src/etc/periodic/daily/440.status-mailq,v
retrieving revision 1.10
diff -u -r1.10 440.status-mailq
--- 440.status-mailq	7 Feb 2006 08:21:06 -0000	1.10
+++ 440.status-mailq	17 Feb 2006 10:54:13 -0000
@@ -32,8 +32,9 @@
 			awk '$1 > 1 {print $1, $2}';;
 		*)
 		    mailq;;
-	    esac | tee /dev/stderr | fgrep -v 'mqueue is empty' | wc -l)
-	    [ $rc -gt 1 ] && rc=1 || rc=0
+	    esac | tee /dev/stderr |
+	    egrep -v '(mqueue is empty|Total requests)' | wc -l)
+	    [ $rc -gt 0 ] && rc=1 || rc=0
 
 	    case "$daily_status_include_submit_mailq" in
 	    [Yy][Ee][Ss])
@@ -52,8 +53,9 @@
 				awk '$1 > 1 {print $1, $2}';;
 			*)
 			    mailq -Ac;;
-		    esac | tee /dev/stderr | fgrep -v 'mqueue is empty' | wc -l)
-		    [ $rc_submit -gt 1 ] && rc=1
+		    esac | tee /dev/stderr |
+		    egrep -v '(mqueue is empty|Total requests)' | wc -l)
+		    [ $rc_submit -gt 0 ] && rc=1
 		fi;;
 	    esac
 	fi;;
--- 440.status-mailq.diff ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->matteo 
Responsible-Changed-By: matteo 
Responsible-Changed-When: Sun Mar 5 21:18:40 UTC 2006 
Responsible-Changed-Why:  
Grab this 

http://www.freebsd.org/cgi/query-pr.cgi?pr=93472 
State-Changed-From-To: open->patched 
State-Changed-By: matteo 
State-Changed-When: Wed Mar 8 17:27:04 UTC 2006 
State-Changed-Why:  
Fixed in HEAD 

http://www.freebsd.org/cgi/query-pr.cgi?pr=93472 
State-Changed-From-To: patched->closed 
State-Changed-By: matteo 
State-Changed-When: Sun Mar 12 18:45:11 UTC 2006 
State-Changed-Why:  
Fixed, thanks 

http://www.freebsd.org/cgi/query-pr.cgi?pr=93472 
>Unformatted:
