Bug 20514

Summary: daily periodic: [: /var/log/maillog.10.gz: unexpected operator
Product: Base System Reporter: Andre Albsmeier <Andre.Albsmeier>
Component: confAssignee: Brian Somers <brian>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.1-STABLE   
Hardware: Any   
OS: Any   

Description Andre Albsmeier 2000-08-10 05:50:01 UTC
If you have more than 9 /var/log/maillog.*.gz files, 460.status-mail-rejects
complains:

Checking for rejected mail hosts:
[: /var/log/maillog.10.gz: unexpected operator

Fix: 

Somwhere near

[ -f /var/log/maillog.$n* ] && zcat -fc /var/log/maillog.$n*

because [ -f /var/log/maillog.$n* ] evaluates to 

[ -f /var/log/maillog.1.gz /var/log/maillog.10.gz ] and /bin/test
doesn't like this.
How-To-Repeat: 
Make sure you have /var/log/maillog.1.gz and /var/log/maillog.10.gz
and run 460.status-mail-rejects
Comment 1 Sheldon Hearn 2000-08-10 11:29:58 UTC
On Thu, 10 Aug 2000 06:49:28 +0200, Andre Albsmeier wrote:

> If you have more than 9 /var/log/maillog.*.gz files, 460.status-mail-rejects
> complains:
> 
> Checking for rejected mail hosts:
> [: /var/log/maillog.10.gz: unexpected operator

That's because this test is broken:

	[ -f /var/log/maillog.$n* ]

One possible solution is as follows:

Index: 460.status-mail-rejects
===================================================================
RCS file: /home/ncvs/src/etc/periodic/daily/460.status-mail-rejects,v
retrieving revision 1.10
diff -u -d -r1.10 460.status-mail-rejects
--- 460.status-mail-rejects	2000/06/30 09:41:15	1.10
+++ 460.status-mail-rejects	2000/08/10 10:27:40
@@ -24,7 +24,13 @@
 	    {
 		while [ $n -ge 0 ]
 		do
-		    [ -f /var/log/maillog.$n* ] && zcat -fc /var/log/maillog.$n*
+		    if [ -f /var/log/maillog.$n ]
+		    then
+			cat -c /var/log/maillog.$n
+		    elif [ -f /var/log/maillog.$n.gz ]
+		    then
+			zcat -c /var/log/maillog.$n.gz
+		    fi
 		    n=$(($n - 1))
 		done
 		cat /var/log/maillog

This'll work fine until periodic(8) supports alternative compression
mechanisms.

Ciao,
Sheldon.
Comment 2 Sheldon Hearn freebsd_committer freebsd_triage 2000-08-10 11:30:20 UTC
Responsible Changed
From-To: freebsd-bugs->brian

I've proposed a patch.  Over to the maintainer.
Comment 3 Brian Somers freebsd_committer freebsd_triage 2000-08-10 12:00:14 UTC
State Changed
From-To: open->closed

A fix has been committed to -current and (rather prematurely) to -stable.