Package: mutt
Version: 1.5.18-6+b1
Severity: important
Tags: upstream patch

By default, mutt stores drafts in
/tmp/mutt-$HOSTNAME-$UID-$PID-$REV. /tmp is designed to hold data
that isn't guaranteed to be preserved between different invocations
of programmes. For practical purposes, and on Debian at least, this
translates to files being deleted on every boot, unless TMPTIME is
amended in /etc/default/rcS and /tmp is not a tmpfs.

This behaviour can cause loss of data, e.g. when the laptop dies or
turns itself off due to low power; the user might not have a chance
to commit the temporary mail draft s/he was working on to
non-volatile storage.

I suggest that mutt should use /var/tmp by default for its mail
drafts, as that directory is also temporary in nature, but cleaned
less frequently than /tmp. More specifically, the FHS dictates that
"files and directories located in /var/tmp must not be deleted when
the system is booted."

Attached are two patches, one for the code and what looks like the
source of the documentation (init.h), and another patching the docs,
which look like auto-generated content.

Thanks for your consideration,

-- 
 .''`.   martin f. krafft <madd...@d.o>      Related projects:
: :'  :  proud Debian developer               http://debiansystem.info
`. `'`   http://people.debian.org/~madduck    http://vcs-pkg.org
  `-  Debian - when you have better things to do than fixing systems
From b0da9a700c4dd50d12af5ec8b3fbdaae0f295137 Mon Sep 17 00:00:00 2001
From: martin f. krafft <madd...@madduck.net>
Date: Tue, 26 May 2009 08:20:03 +0200
Subject: [PATCH 1/2] Changed tmpdir default to /var/tmp

By default, mutt stores drafts in
/tmp/mutt-$HOSTNAME-$UID-$PID-$REV. /tmp is designed to hold data
that isn't guaranteed to be preserved between different invocations
of programmes. For practical purposes, and on Debian at least, this
translates to files being deleted on every boot, unless TMPTIME is
amended in /etc/default/rcS and /tmp is not a tmpfs.

This behaviour can cause loss of data, e.g. when the laptop dies or
turns itself off due to low power; the user might not have a chance
to commit the temporary mail draft s/he was working on to
non-volatile storage.

I suggest that mutt should use /var/tmp by default for its mail
drafts, as that directory is also temporary in nature, but cleaned
less frequently than /tmp. More specifically, the FHS dictates that
"files and directories located in /var/tmp must not be deleted when
the system is booted."

This patch modifies all occurrences of $tmpdir, $TMPDIR and Tempdir, but
not the documentation, which looks like it's generated from init.h.

Signed-off-by: martin f. krafft <madd...@madduck.net>
---
 init.c        |    2 +-
 init.h        |    2 +-
 install-sh    |    2 +-
 muttbug.sh.in |    2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/init.c b/init.c
index 9b98d77..8fbca4f 100644
--- a/init.c
+++ b/init.c
@@ -2987,7 +2987,7 @@ void mutt_init (int skip_sys_rc, LIST *commands)
     MailcapPath = safe_strdup ("~/.mailcap:" PKGDATADIR "/mailcap:" SYSCONFDIR "/mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap");
   }
 
-  Tempdir = safe_strdup ((p = getenv ("TMPDIR")) ? p : "/tmp");
+  Tempdir = safe_strdup ((p = getenv ("TMPDIR")) ? p : "/var/tmp");
 
   p = getenv ("VISUAL");
   if (!p)
diff --git a/init.h b/init.h
index f9c5bba..7839c4d 100644
--- a/init.h
+++ b/init.h
@@ -3112,7 +3112,7 @@ struct option_t MuttVars[] = {
   ** This variable allows you to specify where Mutt will place its
   ** temporary files needed for displaying and composing messages.  If
   ** this variable is not set, the environment variable \fC$$$TMPDIR\fP is
-  ** used.  If \fC$$$TMPDIR\fP is not set then ``\fC/tmp\fP'' is used.
+  ** used.  If \fC$$$TMPDIR\fP is not set then ``\fC/var/tmp\fP'' is used.
   */
   { "to_chars",		DT_STR,	 R_BOTH, UL &Tochars, UL " +TCFL" },
   /*
diff --git a/install-sh b/install-sh
index 4fbbae7..66ebf87 100755
--- a/install-sh
+++ b/install-sh
@@ -332,7 +332,7 @@ do
 	    # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
 	    ;;
 	  *)
-	    tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+	    tmpdir=${TMPDIR-/var/tmp}/ins$RANDOM-$$
 	    trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
 
 	    if (umask $mkdir_umask &&
diff --git a/muttbug.sh.in b/muttbug.sh.in
index 9bcb955..f62fa06 100644
--- a/muttbug.sh.in
+++ b/muttbug.sh.in
@@ -85,7 +85,7 @@ esac
 exec > /dev/tty
 exec < /dev/tty
 
-SCRATCH=${TMPDIR-/tmp}/`basename $0`.`hostname`.$$
+SCRATCH=${TMPDIR-/var/tmp}/`basename $0`.`hostname`.$$
 
 mkdir ${SCRATCH} || \
 { 
-- 
1.6.3.1

From 2da4326842179839ef186c9b669c20470eb2ceea Mon Sep 17 00:00:00 2001
From: martin f. krafft <madd...@madduck.net>
Date: Tue, 26 May 2009 08:23:03 +0200
Subject: [PATCH 2/2] Amend documentation to reflect tmpdir change to /var/tmp

Commit b0da9a7 changes the tempdir default value to /var/tmp, but does
not touch documentation which looks like it's auto-generated from
init.h. This commit thus patches the documentation separately.

Signed-off-by: martin f. krafft <madd...@madduck.net>
---
 doc/Muttrc         |    2 +-
 doc/manual.html    |    4 ++--
 doc/manual.txt     |    4 ++--
 doc/reference.html |    2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/doc/Muttrc b/doc/Muttrc
index d5606a8..dbff7fe 100644
--- a/doc/Muttrc
+++ b/doc/Muttrc
@@ -4440,7 +4440,7 @@ attachments   -I message/external-body
 # This variable allows you to specify where Mutt will place its
 # temporary files needed for displaying and composing messages.  If
 # this variable is not set, the environment variable $TMPDIR is
-# used.  If $TMPDIR is not set then ``/tmp'' is used.
+# used.  If $TMPDIR is not set then ``/var/tmp'' is used.
 # 
 # 
 # set to_chars=" +TCFL"
diff --git a/doc/manual.html b/doc/manual.html
index 07afabc..7fbe894 100644
--- a/doc/manual.html
+++ b/doc/manual.html
@@ -2530,7 +2530,7 @@ information, notably the type, encoding and description.
 </p><p>
 Attachments appear as follows:
 </p><pre class="screen">
-- 1 [text/plain, 7bit, 1K]           /tmp/mutt-euler-8082-0 &lt;no description&gt;
+- 1 [text/plain, 7bit, 1K]           /var/tmp/mutt-euler-8082-0 &lt;no description&gt;
   2 [applica/x-gunzip, base64, 422K] ~/src/mutt-0.85.tar.gz &lt;no description&gt;
 </pre><p>
 The '-' denotes that Mutt will delete the file after sending (or
@@ -6104,7 +6104,7 @@ Default: (empty)</p></div><p>
 This variable allows you to specify where Mutt will place its
 temporary files needed for displaying and composing messages.  If
 this variable is not set, the environment variable <code class="literal">$TMPDIR</code> is
-used.  If <code class="literal">$TMPDIR</code> is not set then “<span class="quote"><code class="literal">/tmp</code></span>” is used.
+used.  If <code class="literal">$TMPDIR</code> is not set then “<span class="quote"><code class="literal">/var/tmp</code></span>” is used.
 </p></div><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="to-chars"></a>3.290. to_chars</h3></div></div></div><div class="literallayout"><p>Type: string<br />
 Default: “<span class="quote"><code class="literal"> +TCFL</code></span>”</p></div><p>
 Controls the character used to indicate mail addressed to you.  The
diff --git a/doc/manual.txt b/doc/manual.txt
index 1a01e39..ce916f9 100644
--- a/doc/manual.txt
+++ b/doc/manual.txt
@@ -3928,7 +3928,7 @@ description.
 
 Attachments appear as follows:
 
-- 1 [text/plain, 7bit, 1K]           /tmp/mutt-euler-8082-0 <no description>
+- 1 [text/plain, 7bit, 1K]           /var/tmp/mutt-euler-8082-0 <no description>
   2 [applica/x-gunzip, base64, 422K] ~/src/mutt-0.85.tar.gz <no description>
 
 The '-' denotes that Mutt will delete the file after sending (or postponing, or
@@ -9140,7 +9140,7 @@ Default: (empty)
 
 This variable allows you to specify where Mutt will place its temporary files
 needed for displaying and composing messages. If this variable is not set, the
-environment variable $TMPDIR is used. If $TMPDIR is not set then ?/tmp? is
+environment variable $TMPDIR is used. If $TMPDIR is not set then ?/var/tmp? is
 used.
 
 3.290. to_chars
diff --git a/doc/reference.html b/doc/reference.html
index 4bdd6ba..3eea0c8 100644
--- a/doc/reference.html
+++ b/doc/reference.html
@@ -2742,7 +2742,7 @@ Default: (empty)</p></div><p>
 This variable allows you to specify where Mutt will place its
 temporary files needed for displaying and composing messages.  If
 this variable is not set, the environment variable <code class="literal">$TMPDIR</code> is
-used.  If <code class="literal">$TMPDIR</code> is not set then “<span class="quote"><code class="literal">/tmp</code></span>” is used.
+used.  If <code class="literal">$TMPDIR</code> is not set then “<span class="quote"><code class="literal">/var/tmp</code></span>” is used.
 </p></div><div class="sect2" lang="en" xml:lang="en"><div class="titlepage"><div><div><h3 class="title"><a id="to-chars"></a>3.290. to_chars</h3></div></div></div><div class="literallayout"><p>Type: string<br />
 Default: “<span class="quote"><code class="literal"> +TCFL</code></span>”</p></div><p>
 Controls the character used to indicate mail addressed to you.  The
-- 
1.6.3.1

Attachment: digital_signature_gpg.asc
Description: Digital signature (see http://martin-krafft.net/gpg/)

Reply via email to