Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Sep 2019 00:12:44 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org
Subject:   svn commit: r352588 - releng/12.1/usr.sbin/periodic
Message-ID:  <201909220012.x8M0Ciu1068597@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Sun Sep 22 00:12:43 2019
New Revision: 352588
URL: https://svnweb.freebsd.org/changeset/base/352588

Log:
  MF stable/12 r352489
  
  Approved by:	re (kib)
  
  r351192:
  periodic: fix anticongestion for scripts run after security
  
  Revision 316342, which introduced the anticongestion feature, failed to
  consider that the periodic scripts are executed by a recursive invocation of
  periodic.  The recursive invocation wrongly cleaned up a temporary file that
  should've been cleaned up only by the original invocation.  The result is
  that if the first script that requests an anticongestion sleep runs after
  the security scripts, the sleep won't happen.
  
  Fix this bug by delaying cleanup until the end of the original invocation.
  
  PR:             236564
  Submitted by:   Yasuhiro KIMURA <yasu@utahime.org>
  Reviewed by:    imp
  
  r351203:
  periodic: replace "tty" with "test -t 0"
  
  Apparently using tty for this purpose has been deprecated since 4.4 Lite.
  
  Reviewed by:    cy
  Differential Revision:  https://reviews.freebsd.org/D21318

Modified:
  releng/12.1/usr.sbin/periodic/periodic.sh
Directory Properties:
  releng/12.1/   (props changed)

Modified: releng/12.1/usr.sbin/periodic/periodic.sh
==============================================================================
--- releng/12.1/usr.sbin/periodic/periodic.sh	Sat Sep 21 21:02:57 2019	(r352587)
+++ releng/12.1/usr.sbin/periodic/periodic.sh	Sun Sep 22 00:12:43 2019	(r352588)
@@ -78,8 +78,13 @@ arg=$1
 
 if [ -z "$PERIODIC_ANTICONGESTION_FILE" ] ; then
 	export PERIODIC_ANTICONGESTION_FILE=`mktemp ${TMPDIR:-/tmp}/periodic.anticongestion.XXXXXXXXXX`
+	remove_periodic_anticongestion_file=yes
+else
+	# We might be in a recursive invocation; let the top-level invocation
+	# remove the file.
+	remove_periodic_anticongestion_file=no
 fi
-if tty > /dev/null 2>&1; then
+if [ -t 0 ]; then
 	export PERIODIC_IS_INTERACTIVE=1
 fi
 tmp_output=`mktemp ${TMPDIR:-/tmp}/periodic.XXXXXXXXXX`
@@ -147,4 +152,6 @@ esac
 } | output_pipe $arg "$context"
 
 rm -f $tmp_output
-rm -f $PERIODIC_ANTICONGESTION_FILE
+if [ $remove_periodic_anticongestion_file = "yes" ] ; then
+	rm -f $PERIODIC_ANTICONGESTION_FILE
+fi



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