fix(scheduled-jobs): write a linked crontab through its link, with the target's mode
driver / standard (pull_request) Successful in 16s
driver / lint (pull_request) Successful in 20s
driver / types (pull_request) Successful in 1m11s
driver / test (3.12) (pull_request) Successful in 1m25s
driver / test (3.13) (pull_request) Successful in 1m18s
driver / lowest (pull_request) Successful in 40s
driver / build (pull_request) Successful in 36s
driver / security (pull_request) Successful in 1m8s
CI / driver (pull_request) Successful in 2m54s
driver / publish (pull_request) Skipped

stat without -L gave the link's own mode, 777, and install replaced the
link with a plain file of that mode: cron ignores a file anyone may write,
so every job in it stopped (/etc/cron.d/vzdump on older PVE links to
/etc/pve/vzdump.cron). The file the link names is written instead.

Refs #86
This commit is contained in:
christianmanivong committed 2026-11-03 05:39:57 +01:00
1 parent df476a12f2
commit edef6cf07c
2 files changed
+18 -2

No files matched your search

+5 -2
View File
@@ -244,8 +244,11 @@ class PosixScheduledJobsMixin(ScheduledJobsMixin):
if user is not None:
self._sj_write_crontab(user, text)
return
mode, owner, group = self._sj_checked([*self.STAT_ARGV, path]).stdout.split()[:3]
self._sj_install(text, path, mode, owner, group)
# Through a symbolic link to the file it names, with that file's mode: the
# link's own mode is 777, and cron ignores a file anyone may write.
real = self._sj_checked(["readlink", "-f", "--", path]).stdout.strip() or path
mode, owner, group = self._sj_checked([*self.STAT_ARGV, real]).stdout.split()[:3]
self._sj_install(text, real, mode, owner, group)
def _sj_line(self, job: dict[str, object], text: str) -> CronLine:
"""The job's line in *text* as it is now, read again for the write."""