File: Dont-die-on-missing-spool-dir.patch

package info (click to toggle)
cron 3.0pl1-197
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 3,816 kB
  • sloc: ansic: 54,879; xml: 1,600; perl: 733; sh: 463; makefile: 446; python: 43
file content (51 lines) | stat: -rw-r--r-- 1,445 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
From: Christian Kastner <ckk@kvr.at>
Date: Fri, 25 Dec 2015 23:57:47 +0100
Subject: Don't die on missing spool dir

The daemon shouldn't just die when spool dir is missing, for example when
/var/spool is being moved around. This a recoverable situation.

Fix provided by Justin Pryzby <justinpryzby@users.sourceforge.net>.

Bug-Debian: https://bugs.debian.org/470564
Forwarded: no
Last-Update: 2015-12-25
---
 database.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/database.c b/database.c
index 8e49159..09f44a4 100644
--- a/database.c
+++ b/database.c
@@ -68,7 +68,7 @@ load_database(old_db)
 	 */
 	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
@@ -109,10 +109,9 @@ load_database(old_db)
 	 */
 	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];
 
@@ -130,7 +129,8 @@ load_database(old_db)
 		process_crontab(fname, fname, tabname,
 				&statbuf, &new_db, old_db);
 	}
-	closedir(dir);
+	if (dir)
+		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=,