| Summary: | sys-process/vixie-cron-4.1-r10: runs deleted files from /etc/cron.d | ||
|---|---|---|---|
| Product: | Gentoo Linux | Reporter: | gilhad <gilhad> |
| Component: | [OLD] Core system | Assignee: | No maintainer - Look at https://wiki.gentoo.org/wiki/Project:Proxy_Maintainers if you want to take care of it <maintainer-needed> |
| Status: | RESOLVED OBSOLETE | ||
| Severity: | minor | CC: | christoph.gysin, cron-bugs+disabled, kfm, treecleaner |
| Priority: | High | Keywords: | PMASKED |
| Version: | unspecified | ||
| Hardware: | x86 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Package list: | Runtime testing required: | --- | |
| Deadline: | 2019-10-11 | ||
| Attachments: | fix reloading of changed files in /etc/cron.d | ||
|
Description
gilhad
2009-07-05 02:30:42 UTC
I can confirm this. There are multiple problems with the /etc/cron.d patch, vixie-cron-4.1-gentoo-r4.patch.bz2:
@@ -53,6 +53,11 @@
(void) exit(ERROR_EXIT);
}
+ if (stat("/etc/cron.d", &crond_stat) < OK) {
+ log_it("CRON", getpid(), "STAT FAILED", SPOOL_DIR);
Wrong log entry, SPOOL_DIR is supposed to be "/etc/cron.d".
@@ -76,13 +82,43 @@
* actually changed. Whatever is left in the old database when
* we're done is chaff -- crontabs that disappeared.
*/
- new_db.mtime = TMAX(statbuf.st_mtime, syscron_stat.st_mtime);
+ new_db.mtime = TMAX(crond_stat.st_mtime,
+ TMAX(statbuf.st_mtime, syscron_stat.st_mtime));
This only takes mtime from /etc/cron.d dir, ignoring changed files within.
new_db.head = new_db.tail = NULL;
if (syscron_stat.st_mtime)
process_crontab("root", NULL, SYSCRONTAB, &syscron_stat,
&new_db, old_db);
+ if (!(dir = opendir("/etc/cron.d"))) {
+ log_it("CRON", getpid(), "OPENDIR FAILED", "/etc/cron.d");
+ (void) exit(ERROR_EXIT);
+ }
+
+ while (NULL != (dp = readdir(dir))) {
+ char fname[MAXNAMLEN+1],
+ tabname[MAXNAMLEN+1];
+
+ /* avoid file names beginning with ".". this is good
+ * because we would otherwise waste two guaranteed calls
+ * to getpwnam() for . and .., and there shouldn't be
+ * hidden files in here anyway. Also ignore files beginning
+ * with '#' and ending with '~'.
+ */
+ if (dp->d_name[0] == '.' ||
+ dp->d_name[0] == '#' ||
+ dp->d_name[strlen(dp->d_name) - 1] == '~')
+ continue;
+
+ (void) strncpy(fname, dp->d_name, MAXNAMLEN);
+ snprintf(tabname, MAXNAMLEN+1, "/etc/cron.d/%s", fname);
+
+ process_crontab("root", NULL, tabname,
+ &crond_stat, &new_db, old_db);
The NULL here will make process_crontab() use "*system*" as user, and also as key to store in the database. We need unique identifiers though, so I suggest using the full path of the file as key.
Patch follows.
Created attachment 201206 [details, diff]
fix reloading of changed files in /etc/cron.d
This fixes reloading of files within /etc/cron.d/ based on mtime.
It *still* only checks for changed files within /etc/cron.d if /etc/cron.d's mtime has changed! If you edit the file in place (open/truncate/write/close) the directory won't get changed and cron will not reread the file.
This is actually the same behavior as in /var/spool/cron/crontabs, but there you would usually use "crontab -e" anyways, which will update the directory's mtime.
gilhad, I hope you're still on to this. Would you please test if this works for you? Package removed. |