Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Jul 2012 20:27:38 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r238024 - head/usr.sbin/cron/crontab
Message-ID:  <201207022027.q62KRc7Z097153@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Mon Jul  2 20:27:37 2012
New Revision: 238024
URL: http://svn.freebsd.org/changeset/base/238024

Log:
  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.
  
  MFC after:	1 month

Modified:
  head/usr.sbin/cron/crontab/crontab.c

Modified: head/usr.sbin/cron/crontab/crontab.c
==============================================================================
--- head/usr.sbin/cron/crontab/crontab.c	Mon Jul  2 20:26:11 2012	(r238023)
+++ head/usr.sbin/cron/crontab/crontab.c	Mon Jul  2 20:27:37 2012	(r238024)
@@ -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?201207022027.q62KRc7Z097153>