summaryrefslogtreecommitdiffstats
path: root/usr.sbin/cron
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2012-07-02 20:27:37 +0000
committerjhb <jhb@FreeBSD.org>2012-07-02 20:27:37 +0000
commit49f8db31d37357f4ad6c8e575f34cc38d7306815 (patch)
tree5d23f37a26f701438d473800320cd18fdd4c329e /usr.sbin/cron
parent71a3fb9c455c624581c902fae8be7ebc45e72fa4 (diff)
downloadFreeBSD-src-49f8db31d37357f4ad6c8e575f34cc38d7306815.zip
FreeBSD-src-49f8db31d37357f4ad6c8e575f34cc38d7306815.tar.gz
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
Diffstat (limited to 'usr.sbin/cron')
-rw-r--r--usr.sbin/cron/crontab/crontab.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/usr.sbin/cron/crontab/crontab.c b/usr.sbin/cron/crontab/crontab.c
index 3bb54a5..69c4606 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);
OpenPOWER on IntegriCloud