Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Aug 2012 19:17:29 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r239876 - stable/9/usr.sbin/cron/crontab
Message-ID:  <201208291917.q7TJHTZR099697@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Wed Aug 29 19:17:29 2012
New Revision: 239876
URL: http://svn.freebsd.org/changeset/base/239876

Log:
  MFC 238024:
  Add a one second sleep before touching the spool directory.  If the touch
  occurs in the same second as the earlier operations to create the temporary
  file and the cron(8) daemon is rescans the spool directory during that
  second, then the daemon may miss a cron edit and not properly update its
  internal database.

Modified:
  stable/9/usr.sbin/cron/crontab/crontab.c
Directory Properties:
  stable/9/usr.sbin/cron/crontab/   (props changed)

Modified: stable/9/usr.sbin/cron/crontab/crontab.c
==============================================================================
--- stable/9/usr.sbin/cron/crontab/crontab.c	Wed Aug 29 19:12:53 2012	(r239875)
+++ stable/9/usr.sbin/cron/crontab/crontab.c	Wed Aug 29 19:17:29 2012	(r239876)
@@ -608,6 +608,15 @@ replace_cmd() {
 
 	log_it(RealUser, Pid, "REPLACE", User);
 
+	/*
+	 * Creating the 'tn' temp file has already updated the
+	 * modification time of the spool directory.  Sleep for a
+	 * second to ensure that poke_daemon() sets a later
+	 * modification time.  Otherwise, this can race with the cron
+	 * daemon scanning for updated crontabs.
+	 */
+	sleep(1);
+
 	poke_daemon();
 
 	return (0);



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