svn commit: r239876 - stable/9/usr.sbin/cron/crontab

John Baldwin jhb at FreeBSD.org
Wed Aug 29 19:17:30 UTC 2012


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);


More information about the svn-src-all mailing list