File: fsync-to-check-for-full-disk.patch

package info (click to toggle)
cron 3.0pl1-162
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,204 kB
  • sloc: ansic: 47,007; perl: 733; makefile: 429; sh: 425; python: 36
file content (35 lines) | stat: -rw-r--r-- 1,048 bytes parent folder | download
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
From: Christian Kastner <ckk@kvr.at>
Date: Tue, 22 Dec 2015 23:47:34 +0100
Subject: fsync to check for full disk

Make sure that writing the crontab actually succeeded.

Based on an initial fix by Steve Greenland <stevegr@debian.org>.

Bug-Debian: https://bugs.debian.org/110612
Forwarded: no
Last-Update: 2015-12-22
Index: cron/crontab.c
===================================================================
--- cron.orig/crontab.c
+++ cron/crontab.c
@@ -541,9 +541,8 @@ replace_cmd() {
 	Set_LineNum(1)
 	while (EOF != (ch = get_char(NewCrontab)))
 		putc(ch, tmp);
-	fflush(tmp);  rewind(tmp);
 
-	if (ferror(tmp)) {
+	if (ferror(tmp) || fflush(tmp) || fsync(fileno(tmp))) {
 		fprintf(stderr, "%s: %s: %s\n",
 			ProgramName, tn, strerror(errno));
 		fclose(tmp);  unlink(tn);
@@ -552,7 +551,7 @@ replace_cmd() {
 
 	/* check the syntax of the file being installed.
 	 */
-
+	rewind(tmp);
 	/* BUG: was reporting errors after the EOF if there were any errors
 	 * in the file proper -- kludged it by stopping after first error.
 	 *		vix 31mar87