From nobody@FreeBSD.org  Wed Mar  7 14:18:28 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 8ED3E106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Wed,  7 Mar 2012 14:18:28 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 6F6D98FC16
	for <freebsd-gnats-submit@FreeBSD.org>; Wed,  7 Mar 2012 14:18:28 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q27EISRh085564
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 7 Mar 2012 14:18:28 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q27EISnj085563;
	Wed, 7 Mar 2012 14:18:28 GMT
	(envelope-from nobody)
Message-Id: <201203071418.q27EISnj085563@red.freebsd.org>
Date: Wed, 7 Mar 2012 14:18:28 GMT
From: Volodymyr Kostyrko <c.kworr@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: /etc/periodic reports misconfiguration when it shouldn't
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         165817
>Category:       conf
>Synopsis:       [periodic] [patch] /etc/periodic reports misconfiguration when it shouldn't
>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 Mar 07 14:20:14 UTC 2012
>Closed-Date:    
>Last-Modified:  Tue May  8 15:00:21 UTC 2012
>Originator:     Volodymyr Kostyrko
>Release:        RELENG_9
>Organization:
None
>Environment:
FreeBSD green.tandem.local 9.0-STABLE FreeBSD 9.0-STABLE #0 r232540: Mon Mar  5 13:52:59 EET 2012     arcade@green.tandem.local:/usr/obj/usr/src/sys/MINIMAL_4BSD  amd64
>Description:
Periodic 999.local scripts reports misconfiguration if they fail to find /etc/*.local file. However the absence of this file is not misconfiguration but is rather an option to specify local configuration additions in netboot environment.

After that if anyone sets:

 *_show_badconfig=yes
 *_show_success=no

The minimal mail would be emailed anyway regardless of other tasks:

/etc/*.local: No such file

-- End of * output --

Attached patch fixes this by not modifying `rc` when `*.local` file is not found. Generated output remains the same and the only change would be not generating mail when `*.local` file is not found locally.
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

diff -urN /etc/periodic/daily/999.local ./daily/999.local
--- /etc/periodic/daily/999.local	2011-12-28 11:17:21.420664000 +0200
+++ ./daily/999.local	2012-03-07 16:04:19.722599521 +0200
@@ -27,7 +27,6 @@
 		sh $script || rc=3
 	    else
 		echo "$script: No such file"
-		[ $rc -lt 2 ] && rc=2
 	    fi;;
 	*)
 	    echo "$script: Not an absolute path"
diff -urN /etc/periodic/monthly/999.local ./monthly/999.local
--- /etc/periodic/monthly/999.local	2011-12-28 11:17:21.467664000 +0200
+++ ./monthly/999.local	2012-03-07 16:04:26.617599427 +0200
@@ -24,7 +24,6 @@
 		sh $script || rc=3
 	    else
 		echo "$script: No such file"
-		[ $rc -lt 2 ] && rc=2
 	    fi;;
 	*)
 	    echo "$script: Not an absolute path"
diff -urN /etc/periodic/periodic.silence.patch ./periodic.silence.patch
--- /etc/periodic/periodic.silence.patch	1970-01-01 03:00:00.000000000 +0300
+++ ./periodic.silence.patch	2012-03-07 16:09:23.287599845 +0200
@@ -0,0 +1,22 @@
+diff -urN /etc/periodic/daily/999.local ./daily/999.local
+--- /etc/periodic/daily/999.local	2011-12-28 11:17:21.420664000 +0200
++++ ./daily/999.local	2012-03-07 16:04:19.722599521 +0200
+@@ -27,7 +27,6 @@
+ 		sh $script || rc=3
+ 	    else
+ 		echo "$script: No such file"
+-		[ $rc -lt 2 ] && rc=2
+ 	    fi;;
+ 	*)
+ 	    echo "$script: Not an absolute path"
+diff -urN /etc/periodic/monthly/999.local ./monthly/999.local
+--- /etc/periodic/monthly/999.local	2011-12-28 11:17:21.467664000 +0200
++++ ./monthly/999.local	2012-03-07 16:04:26.617599427 +0200
+@@ -24,7 +24,6 @@
+ 		sh $script || rc=3
+ 	    else
+ 		echo "$script: No such file"
+-		[ $rc -lt 2 ] && rc=2
+ 	    fi;;
+ 	*)
+ 	    echo "$script: Not an absolute path"
diff -urN /etc/periodic/weekly/999.local ./weekly/999.local
--- /etc/periodic/weekly/999.local	2011-12-28 11:17:21.452664000 +0200
+++ ./weekly/999.local	2012-03-07 16:04:44.751599176 +0200
@@ -24,7 +24,6 @@
 		sh $script || rc=3
 	    else
 		echo "$script: No such file"
-		[ $rc -lt 2 ] && rc=2
 	    fi;;
 	*)
 	    echo "$script: Not an absolute path"


>Release-Note:
>Audit-Trail:

From: John Baldwin <jhb@freebsd.org>
To: bug-followup@freebsd.org,
 c.kworr@gmail.com
Cc:  
Subject: Re: conf/165817: [periodic] [patch] /etc/periodic reports misconfiguration when it shouldn&#39;t
Date: Mon, 7 May 2012 11:15:28 -0400

 This doesn't make sense.  The various variables don't have a default value in 
 /etc/defaults/rc.conf (e.g. daily_local), so they should just be empty, and 
 the for loop should not do anything if the variable is empty.  For example, if 
 you run this in /bin/sh:
 
 $ for script in $notexists
 > do
 > echo foo
 > done
 $ 
 
 You don't get any output at all.  Thus, having the default configuration of 
 not having these variables set should never get into the loop to execute the 
 line you are modifying.
 
 In your case you must have daily_local, etc. set to some absolute path that 
 doesn't exist (e.g. daily_local="/nonexistent") in which case that is a 
 misconfiguration that the scripts should warn you about.
 
 Or is the problem that you have daily_local set to "/etc/*.local" (the glob)
 and that isn't matching, so the shell runs the loop with the value 
 "/etc/*.local"?  That is a bit harder to fix.
 
 Your patch would not be correct if someone set "daily_local" to 
 "/nonexistent".  That is a case that _should_ be warned about.
 
 -- 
 John Baldwin

From: Volodymyr Kostyrko <c.kworr@gmail.com>
To: John Baldwin <jhb@freebsd.org>
Cc: bug-followup@freebsd.org
Subject: Re: conf/165817: [periodic] [patch] /etc/periodic reports misconfiguration
 when it shouldn&#39;t
Date: Tue, 08 May 2012 10:57:58 +0300

 John Baldwin wrote:
 > This doesn't make sense.  The various variables don't have a default value in
 > /etc/defaults/rc.conf (e.g. daily_local), so they should just be empty, and
 > the for loop should not do anything if the variable is empty.  For example, if
 > you run this in /bin/sh:
 >
 > $ for script in $notexists
 >> do
 >> echo foo
 >> done
 > $
 >
 > You don't get any output at all.  Thus, having the default configuration of
 > not having these variables set should never get into the loop to execute the
 > line you are modifying.
 >
 > In your case you must have daily_local, etc. set to some absolute path that
 > doesn't exist (e.g. daily_local="/nonexistent") in which case that is a
 > misconfiguration that the scripts should warn you about.
 >
 > Or is the problem that you have daily_local set to "/etc/*.local" (the glob)
 > and that isn't matching, so the shell runs the loop with the value
 > "/etc/*.local"?  That is a bit harder to fix.
 >
 > Your patch would not be correct if someone set "daily_local" to
 > "/nonexistent".  That is a case that _should_ be warned about.
 
 Yes, I should probably rethink the patch. It definitely should warn 
 about /nonexistent.
 
 That makes me somehow stuck. periodic scripts source 
 /etc/defaults/periodic.conf which defines this variables as 
 "/etc/*.local". So when it comes to checking whether this file is 
 available the variable is already set. The possible solution is to check 
 whether variable is set to the default path and skip warning if default 
 path is unexistent or adding empty placeholders for required files. I 
 personally prefer the latter to keep scripts as simple as possible and 
 strip all signs of artificial intelligence aka weird logic.
 
 -- 
 Sphinx of black quartz judge my vow.

From: John Baldwin <jhb@FreeBSD.org>
To: Volodymyr Kostyrko <c.kworr@gmail.com>
Cc: bug-followup@freebsd.org
Subject: Re: conf/165817: [periodic] [patch] /etc/periodic reports misconfiguration
 when it shouldn&#39;t
Date: Tue, 08 May 2012 10:52:37 -0400

 On 5/8/12 3:57 AM, Volodymyr Kostyrko wrote:
 > John Baldwin wrote:
 >> This doesn't make sense.  The various variables don't have a default
 >> value in
 >> /etc/defaults/rc.conf (e.g. daily_local), so they should just be
 >> empty, and
 >> the for loop should not do anything if the variable is empty.  For
 >> example, if
 >> you run this in /bin/sh:
 >>
 >> $ for script in $notexists
 >>> do
 >>> echo foo
 >>> done
 >> $
 >>
 >> You don't get any output at all.  Thus, having the default
 >> configuration of
 >> not having these variables set should never get into the loop to
 >> execute the
 >> line you are modifying.
 >>
 >> In your case you must have daily_local, etc. set to some absolute path
 >> that
 >> doesn't exist (e.g. daily_local="/nonexistent") in which case that is a
 >> misconfiguration that the scripts should warn you about.
 >>
 >> Or is the problem that you have daily_local set to "/etc/*.local" (the
 >> glob)
 >> and that isn't matching, so the shell runs the loop with the value
 >> "/etc/*.local"?  That is a bit harder to fix.
 >>
 >> Your patch would not be correct if someone set "daily_local" to
 >> "/nonexistent".  That is a case that _should_ be warned about.
 > 
 > Yes, I should probably rethink the patch. It definitely should warn
 > about /nonexistent.
 > 
 > That makes me somehow stuck. periodic scripts source
 > /etc/defaults/periodic.conf which defines this variables as
 > "/etc/*.local". So when it comes to checking whether this file is
 > available the variable is already set. The possible solution is to check
 > whether variable is set to the default path and skip warning if default
 > path is unexistent or adding empty placeholders for required files. I
 > personally prefer the latter to keep scripts as simple as possible and
 > strip all signs of artificial intelligence aka weird logic.
 
 Oof, now I see.  I was looking at /etc/defaults/rc.conf rather than
 /etc/defaults/periodic.conf for some reason.  We certainly should not
 warn in the default install.  I'll think about this some more.
 
 -- 
 John Baldwin
>Unformatted:
