From e1f7fa65675d0c580f3671bda4d0390218e128e0 Mon Sep 17 00:00:00 2001 From: Kana Steimle Date: Mon, 20 Jan 2025 20:59:43 +0000 Subject: [PATCH] crontab: Make sure crond detects crontab modifications Currently crond uses the modification time of the crontabs directory to detect changes to the crontab files to decide whether to reload them. This works fine when crontab creates or removes crontab files, but when an existing crontab file is modified or replaced, it doesn't change the modification time of the directory, so crond doesn't know it should reload the crontab files. This patch fixes this by making crontab remove the old crontab file (if it exists) before recreating it, so the directory's modification time always changes when a crontab is modified. --- toys/pending/crontab.c | 1 + 1 file changed, 1 insertion(+) diff --git a/toys/pending/crontab.c b/toys/pending/crontab.c index 575398f2..ced5755e 100644 --- a/toys/pending/crontab.c +++ b/toys/pending/crontab.c @@ -234,6 +234,7 @@ static void update_crontab(char *src, char *dest) int fdin, fdout; snprintf(toybuf, sizeof(toybuf), "%s%s", TT.cdir, dest); + unlink(toybuf); fdout = xcreate(toybuf, O_WRONLY|O_CREAT|O_TRUNC, 0600); fdin = xopenro(src); xsendfile(fdin, fdout); -- 2.39.5