git: 004bba2b6b0e - main - periodic: Fix empty output check

From: Dag-Erling Smørgrav <des_at_FreeBSD.org>
Date: Wed, 11 Nov 2026 18:08:35 UTC
The branch main has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=004bba2b6b0ea5313480be65bc9506c5628e5a78

commit 004bba2b6b0ea5313480be65bc9506c5628e5a78
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-11-11 18:07:57 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-11-11 18:07:57 +0000

    periodic: Fix empty output check
    
    The empty_output variable is normalized to YES or NO, but we were
    comparing it to TRUE, so the comparison always failed no matter what it
    was set to.  Compare it to YES instead.
    
    This feature has been disabled since 2007, so flip the default to NO to
    preserve the current behavior.  Adjust the documentation accordingly.
    
    Relnotes:       yes
    PR:             300676
    MFC after:      1 week
    Fixes:          68c35072f914 ("Add an option to make periodic(8) quiet when no output was generated.")
    Reviewed by:    ivy, emaste
    Differential Revision:  https://reviews.freebsd.org/D61435
---
 share/man/man5/periodic.conf.5  | 9 ++++++++-
 usr.sbin/periodic/periodic.8    | 7 +++----
 usr.sbin/periodic/periodic.conf | 4 ++++
 usr.sbin/periodic/periodic.sh   | 4 ++--
 4 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/share/man/man5/periodic.conf.5 b/share/man/man5/periodic.conf.5
index 568493154558..5bb8285d7579 100644
--- a/share/man/man5/periodic.conf.5
+++ b/share/man/man5/periodic.conf.5
@@ -23,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd June 19, 2026
+.Dd November 11, 2026
 .Dt PERIODIC.CONF 5
 .Os
 .Sh NAME
@@ -131,6 +131,13 @@ respectively.
 Refer to the
 .Xr periodic 8
 manual page for how script return codes are interpreted.
+.It Ao Ar dir Ac Ns Va _show_empty_output
+.Pq Vt bool
+Set to
+.Dq Li YES
+to still send an email even if no output was produced for the scripts
+found in
+.Ar dir .
 .It Va anticongestion_sleeptime
 .Pq Vt int
 The maximum number of seconds to randomly sleep in order to smooth bursty loads
diff --git a/usr.sbin/periodic/periodic.8 b/usr.sbin/periodic/periodic.8
index 0cd57bab27e2..ed5717db7ba6 100644
--- a/usr.sbin/periodic/periodic.8
+++ b/usr.sbin/periodic/periodic.8
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd June 18, 2020
+.Dd November 11, 2026
 .Dt PERIODIC 8
 .Os
 .Sh NAME
@@ -136,11 +136,10 @@ value does not begin with a
 .Ql /
 and is not empty, it is assumed to contain a list of email addresses, and
 the output is mailed to them.
-If
+If the script did not produce any output, no email is sent, unless
 .Ao Ar basedir Ac Ns Va _show_empty_output
 is set to
-.Dq Li NO ,
-then no mail will be sent if the output was empty.
+.Dq Li YES .
 .Pp
 If
 .Ao Ar basedir Ac Ns Va _output
diff --git a/usr.sbin/periodic/periodic.conf b/usr.sbin/periodic/periodic.conf
index 7066c7b49fd1..c113d60e42c9 100644
--- a/usr.sbin/periodic/periodic.conf
+++ b/usr.sbin/periodic/periodic.conf
@@ -45,6 +45,7 @@ daily_output="root"					# user or /file
 daily_show_success="YES"				# scripts returning 0
 daily_show_info="YES"					# scripts returning 1
 daily_show_badconfig="NO"				# scripts returning 2
+daily_show_empty_output="NO"				# Don't notify of empty output
 
 # 100.clean-disks
 daily_clean_disks_enable="NO"				# Delete files daily
@@ -208,6 +209,7 @@ weekly_output="root"					# user or /file
 weekly_show_success="YES"				# scripts returning 0
 weekly_show_info="YES"					# scripts returning 1
 weekly_show_badconfig="NO"				# scripts returning 2
+weekly_show_empty_output="NO"				# Don't notify of empty output
 
 # 310.locate
 weekly_locate_enable="YES"				# Update locate weekly
@@ -240,6 +242,7 @@ monthly_output="root"					# user or /file
 monthly_show_success="YES"				# scripts returning 0
 monthly_show_info="YES"					# scripts returning 1
 monthly_show_badconfig="NO"				# scripts returning 2
+monthly_show_empty_output="NO"				# Don't notify of empty output
 
 # 200.accounting
 monthly_accounting_enable="YES"				# Login accounting
@@ -259,6 +262,7 @@ monthly_local="/etc/monthly.local"			# Local scripts
 security_show_success="YES"				# scripts returning 0
 security_show_info="YES"				# scripts returning 1
 security_show_badconfig="NO"				# scripts returning 2
+security_show_empty_output="NO"				# Don't notify of empty output
 
 # These options are used by the security periodic(8) scripts spawned in
 # daily and weekly 450.status-security.
diff --git a/usr.sbin/periodic/periodic.sh b/usr.sbin/periodic/periodic.sh
index a310f04864da..a34e28e41654 100644
--- a/usr.sbin/periodic/periodic.sh
+++ b/usr.sbin/periodic/periodic.sh
@@ -98,7 +98,7 @@ export PERIODIC="$arg${PERIODIC:+ }${PERIODIC}"
 # set, assume the user didn't really want us to muck with it (it's a
 # README file or has been disabled).
 
-success=YES info=YES badconfig=NO empty_output=YES	# Defaults when ${run}_* aren't YES/NO
+success=YES info=YES badconfig=NO empty_output=NO	# Defaults when ${run}_* aren't YES/NO
 for var in success info badconfig empty_output; do
     case $(eval echo "\$${arg##*/}_show_$var") in
     [Yy][Ee][Ss]) eval $var=YES;;
@@ -144,7 +144,7 @@ esac
         done
     done
     if [ $empty = TRUE ]; then
-        if [ $empty_output = TRUE ]; then
+        if [ $empty_output = YES ]; then
             [ $processed = 1 ] && plural= || plural=s
             echo "No output from the $processed file$plural processed"
         fi