tag 470564 patch thanks On Tue, Mar 11, 2008 at 10:14:55PM +0000, Adrian Bridgett wrote:
> We just had cron die on our production boxes as someone was moving > /var/spool around. Whilst I certainly don't mind it warning that > /var/spool/crontabs didn't exist, it would be really nice if it didn't > die - but just skipped it. I think a change like the following will have the requested effect (for /v/s/cron/crontabs as well as /etc/cron.d). cron can also die for some other reasons, but it's not immediately clear to me which cases shouldn't be fatal. Note also the unrelated change to make valid_name a "static" function (Actually, that function can cause cron to exit if the regex compilation fails, but that typically happens only during the first cron run). diff -u cron-3.0pl1/database.c cron-3.0pl1/database.c --- cron-3.0pl1/database.c +++ cron-3.0pl1/database.c @@ -78,7 +78,7 @@ */ if (stat(SPOOL_DIR, &statbuf) < OK) { log_it("CRON", getpid(), "STAT FAILED", SPOOL_DIR); - (void) exit(ERROR_EXIT); + statbuf.st_mtime = 0; } /* track system crontab file @@ -93,7 +93,7 @@ */ if (stat(SYSCRONDIR, &syscrond_stat) < OK) { log_it("CRON", getpid(), "STAT FAILED", SYSCRONDIR); - (void) exit(ERROR_EXIT); + syscrond_stat.st_mtime = 0; } /* If SYSCRONDIR was modified, we know that something is changed and @@ -175,10 +175,9 @@ /* Read all the package crontabs. */ if (!(dir = opendir(SYSCRONDIR))) { log_it("CRON", getpid(), "OPENDIR FAILED", SYSCRONDIR); - (void) exit(ERROR_EXIT); } - while (NULL != (dp = readdir(dir))) { + while (dir!=NULL && NULL != (dp = readdir(dir))) { char fname[MAXNAMLEN+1], tabname[PATH_MAX+1]; @@ -208,7 +207,7 @@ &statbuf, &new_db, old_db); } - closedir(dir); + if (dir) closedir(dir); #endif /* we used to keep this dir open all the time, for the sake of @@ -217,10 +216,9 @@ */ if (!(dir = opendir(SPOOL_DIR))) { log_it("CRON", getpid(), "OPENDIR FAILED", SPOOL_DIR); - (void) exit(ERROR_EXIT); } - while (NULL != (dp = readdir(dir))) { + while (dir!=NULL && NULL != (dp = readdir(dir))) { char fname[MAXNAMLEN+1], tabname[PATH_MAX+1]; @@ -238,7 +236,7 @@ process_crontab(fname, fname, tabname, &statbuf, &new_db, old_db); } - closedir(dir); + if (dir!=NULL) closedir(dir); /* if we don't do this, then when our children eventually call * getpwnam() in do_command.c's child_process to verify MAILTO=, @@ -448,7 +446,7 @@ names, originally GPL, but relicensed to cron license per e-mail of 27 September 2003. I've changed it to do regcomp() only once. */ -int valid_name(char *filename) +static int valid_name(char *filename) { static regex_t hierre, tradre, excsre, classicalre; static int donere = 0; -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]