Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Aug 2012 19:17:36 +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-8@freebsd.org
Subject:   svn commit: r239877 - stable/8/usr.sbin/cron/crontab
Message-ID:  <201208291917.q7TJHaMn099745@svn.freebsd.org>

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

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/8/usr.sbin/cron/crontab/crontab.c
Directory Properties:
  stable/8/usr.sbin/cron/crontab/   (props changed)

Modified: stable/8/usr.sbin/cron/crontab/crontab.c
==============================================================================
--- stable/8/usr.sbin/cron/crontab/crontab.c	Wed Aug 29 19:17:29 2012	(r239876)
+++ stable/8/usr.sbin/cron/crontab/crontab.c	Wed Aug 29 19:17:35 2012	(r239877)
@@ -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.q7TJHaMn099745>