Package: bsd-mailx / 8.1.2-0.20141216cvs-2

14-Truncate-mailbox-instead-of-deleting-it.patch Patch series | 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
36
37
38
39
40
41
42
43
44
45
46
47
48
From: Robert Luberda <robert@debian.org>
Date: Wed, 27 Mar 2002 00:20:00 +0100
Subject: 14 Truncate mailbox instead of deleting it.

fio.c: Don't delete mailbox file, always truncate it,
because liblockfile fails to remove the lock file if mailbox doesn't exist (closes: #111537).

quit.c: change message saing that mailbox was "removed" to "truncated" (closes: #196682);
---
 fio.c  | 8 ++++++++
 quit.c | 4 ++++
 2 files changed, 12 insertions(+)

diff --git a/fio.c b/fio.c
index fef4787..3aff894 100644
--- a/fio.c
+++ b/fio.c
@@ -322,6 +322,14 @@ rm(char *name)
 		errno = EISDIR;
 		return(-1);
 	}
+#ifdef DEBIAN
+	/*
+	 * lockfile_remove can't remove a lockfile if a mailbox file
+	 * doesn't exist, so we must not delete it (see Bug#111537).
+	 */
+	if (!strcmp (name, mailname))
+		return(truncate(name, 0));
+#endif
 	if (unlink(name) == -1) {
 		if (errno == EPERM)
 			return(truncate(name, (off_t)0));
diff --git a/quit.c b/quit.c
index c69f64a..c83273f 100644
--- a/quit.c
+++ b/quit.c
@@ -472,7 +472,11 @@ edstop(void)
 	(void)Fclose(obuf);
 	if (gotcha) {
 		(void)rm(mailname);
+#ifdef DEBIAN
+		puts("truncated");
+#else
 		puts("removed");
+#endif
 	} else
 		puts("complete");
 	fflush(stdout);