From 5cdfc55cabc0321285ac6446db9f30a3e22bb1e5 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Mon, 2 Jul 2012 20:27:37 +0000 Subject: [PATCH] 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 --- usr.sbin/cron/crontab/crontab.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/usr.sbin/cron/crontab/crontab.c b/usr.sbin/cron/crontab/crontab.c index 3bb54a507af..69c46063344 100644 --- a/usr.sbin/cron/crontab/crontab.c +++ b/usr.sbin/cron/crontab/crontab.c @@ -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);