903f6e
Subject: Changed tmpdir default to /var/tmp
903f6e
903f6e
By default, mutt stores drafts in
903f6e
/tmp/mutt-$HOSTNAME-$UID-$PID-$REV. /tmp is designed to hold data
903f6e
that isn't guaranteed to be preserved between different invocations
903f6e
of programmes. For practical purposes, and on Debian at least, this
903f6e
translates to files being deleted on every boot, unless TMPTIME is
903f6e
amended in /etc/default/rcS and /tmp is not a tmpfs.
903f6e
903f6e
This behaviour can cause loss of data, e.g. when the laptop dies or
903f6e
turns itself off due to low power; the user might not have a chance
903f6e
to commit the temporary mail draft s/he was working on to
903f6e
non-volatile storage.
903f6e
903f6e
I suggest that mutt should use /var/tmp by default for its mail
903f6e
drafts, as that directory is also temporary in nature, but cleaned
903f6e
less frequently than /tmp. More specifically, the FHS dictates that
903f6e
"files and directories located in /var/tmp must not be deleted when
903f6e
the system is booted."
903f6e
903f6e
This patch modifies all occurrences of $tmpdir, $TMPDIR and Tempdir, but
903f6e
not the documentation, which looks like it's generated from init.h.
903f6e
903f6e
Patch created by: martin f. krafft <madduck@madduck.net>, submitted to
903f6e
http://dev.mutt.org/trac/ticket/3236
903f6e
and repaired to be able to apply.
903f6e
903f6e
Fedora related: Upstream is not willing to change defualt tmpdir,
903f6e
because they don't believe /var/tmp is on all supported platforms.
903f6e
However, they agree with changing it in distrubution packages. 
903f6e
More info at http://dev.mutt.org/trac/ticket/3236
903f6e
903f6e
diff -up mutt-1.5.21/doc/manual.html.tmpdir mutt-1.5.21/doc/manual.html
903f6e
--- mutt-1.5.21/doc/manual.html.tmpdir	2012-09-27 15:02:53.455915783 +0200
903f6e
+++ mutt-1.5.21/doc/manual.html	2012-09-27 15:04:07.439427603 +0200
903f6e
@@ -3090,7 +3090,7 @@ information, notably the type, encoding
903f6e
 

903f6e
 Attachments appear as follows by default:
903f6e
 

903f6e
-- 1 [text/plain, 7bit, 1K]           /tmp/mutt-euler-8082-0 <no description>
903f6e
+- 1 [text/plain, 7bit, 1K]           /var/tmp/mutt-euler-8082-0 <no description>
903f6e
   2 [applica/x-gunzip, base64, 422K] ~/src/mutt-0.85.tar.gz <no description>
903f6e
 

903f6e
 The - denotes that Mutt will delete the file after
903f6e
@@ -6944,7 +6944,7 @@ Default: (empty)

903f6e
 This variable allows you to specify where Mutt will place its
903f6e
 temporary files needed for displaying and composing messages.  If
903f6e
 this variable is not set, the environment variable $TMPDIR is
903f6e
-used.  If $TMPDIR is not set then /tmp is used.
903f6e
+used.  If $TMPDIR is not set then /var/tmp is used.
903f6e
 

3.294. to_chars

Type: string

903f6e
 Default:  +TCFL

903f6e
 Controls the character used to indicate mail addressed to you.  The
903f6e
diff -up mutt-1.5.21/doc/manual.txt.tmpdir mutt-1.5.21/doc/manual.txt
903f6e
--- mutt-1.5.21/doc/manual.txt.tmpdir	2012-09-27 15:04:20.601518838 +0200
903f6e
+++ mutt-1.5.21/doc/manual.txt	2012-09-27 15:04:50.154724683 +0200
903f6e
@@ -4524,7 +4524,7 @@ description.
903f6e
 
903f6e
 Attachments appear as follows by default:
903f6e
 
903f6e
-- 1 [text/plain, 7bit, 1K]           /tmp/mutt-euler-8082-0 <no description>
903f6e
+- 1 [text/plain, 7bit, 1K]           /var/tmp/mutt-euler-8082-0 <no description>
903f6e
   2 [applica/x-gunzip, base64, 422K] ~/src/mutt-0.85.tar.gz <no description>
903f6e
 
903f6e
 The ?-? denotes that Mutt will delete the file after sending (or postponing, or
903f6e
@@ -9746,7 +9746,7 @@ Default: (empty)
903f6e
 
903f6e
 This variable allows you to specify where Mutt will place its temporary files
903f6e
 needed for displaying and composing messages. If this variable is not set, the
903f6e
-environment variable $TMPDIR is used. If $TMPDIR is not set then ?/tmp? is
903f6e
+environment variable $TMPDIR is used. If $TMPDIR is not set then ?/var/tmp? is
903f6e
 used.
903f6e
 
903f6e
 3.294. to_chars
903f6e
diff -up mutt-1.5.21/doc/Muttrc.tmpdir mutt-1.5.21/doc/Muttrc
903f6e
--- mutt-1.5.21/doc/Muttrc.tmpdir	2012-09-27 15:02:16.391661482 +0200
903f6e
+++ mutt-1.5.21/doc/Muttrc	2012-09-27 15:02:33.822780695 +0200
903f6e
@@ -4515,7 +4515,7 @@ attachments   -I message/external-body
903f6e
 # This variable allows you to specify where Mutt will place its
903f6e
 # temporary files needed for displaying and composing messages.  If
903f6e
 # this variable is not set, the environment variable $TMPDIR is
903f6e
-# used.  If $TMPDIR is not set then ``/tmp'' is used.
903f6e
+# used.  If $TMPDIR is not set then ``/var/tmp'' is used.
903f6e
 # 
903f6e
 # 
903f6e
 # set to_chars=" +TCFL"
903f6e
diff -up mutt-1.5.21/doc/reference.html.tmpdir mutt-1.5.21/doc/reference.html
903f6e
--- mutt-1.5.21/doc/reference.html.tmpdir	2012-09-27 15:05:12.288879110 +0200
903f6e
+++ mutt-1.5.21/doc/reference.html	2012-09-27 15:05:51.130151344 +0200
903f6e
@@ -2804,7 +2804,7 @@ Default: (empty)

903f6e
 This variable allows you to specify where Mutt will place its
903f6e
 temporary files needed for displaying and composing messages.  If
903f6e
 this variable is not set, the environment variable $TMPDIR is
903f6e
-used.  If $TMPDIR is not set then /tmp is used.
903f6e
+used.  If $TMPDIR is not set then /var/tmp is used.
903f6e
 

3.294. to_chars

Type: string

903f6e
 Default:  +TCFL

903f6e
 Controls the character used to indicate mail addressed to you.  The
903f6e
diff -up mutt-1.5.21/init.c.tmpdir mutt-1.5.21/init.c
903f6e
--- mutt-1.5.21/init.c.tmpdir	2012-09-27 14:59:10.099395476 +0200
903f6e
+++ mutt-1.5.21/init.c	2012-09-27 14:59:23.292484023 +0200
903f6e
@@ -2992,7 +2992,7 @@ void mutt_init (int skip_sys_rc, LIST *c
903f6e
     MailcapPath = safe_strdup ("~/.mailcap:" PKGDATADIR "/mailcap:" SYSCONFDIR "/mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap");
903f6e
   }
903f6e
 
903f6e
-  Tempdir = safe_strdup ((p = getenv ("TMPDIR")) ? p : "/tmp");
903f6e
+  Tempdir = safe_strdup ((p = getenv ("TMPDIR")) ? p : "/var/tmp");
903f6e
 
903f6e
   p = getenv ("VISUAL");
903f6e
   if (!p)
903f6e
diff -up mutt-1.5.21/init.h.tmpdir mutt-1.5.21/init.h
903f6e
--- mutt-1.5.21/init.h.tmpdir	2012-09-27 14:59:46.214638908 +0200
903f6e
+++ mutt-1.5.21/init.h	2012-09-27 15:00:21.541877784 +0200
903f6e
@@ -3178,7 +3178,7 @@ struct option_t MuttVars[] = {
903f6e
   ** This variable allows you to specify where Mutt will place its
903f6e
   ** temporary files needed for displaying and composing messages.  If
903f6e
   ** this variable is not set, the environment variable \fC$$$TMPDIR\fP is
903f6e
-  ** used.  If \fC$$$TMPDIR\fP is not set then ``\fC/tmp\fP'' is used.
903f6e
+  ** used.  If \fC$$$TMPDIR\fP is not set then ``\fC/var/tmp\fP'' is used.
903f6e
   */
903f6e
   { "to_chars",		DT_STR,	 R_BOTH, UL &Tochars, UL " +TCFL" },
903f6e
   /*
903f6e
diff -up mutt-1.5.21/install-sh.tmpdir mutt-1.5.21/install-sh
903f6e
--- mutt-1.5.21/install-sh.tmpdir	2012-09-27 15:00:32.246950740 +0200
903f6e
+++ mutt-1.5.21/install-sh	2012-09-27 15:01:15.957247967 +0200
903f6e
@@ -332,7 +332,7 @@ do
903f6e
 	    # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
903f6e
 	    ;;
903f6e
 	  *)
903f6e
-	    tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
903f6e
+	    tmpdir=${TMPDIR-/var/tmp}/ins$RANDOM-$$
903f6e
 	    trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
903f6e
 
903f6e
 	    if (umask $mkdir_umask &&
903f6e
diff -up mutt-1.5.21/muttbug.sh.in.tmpdir mutt-1.5.21/muttbug.sh.in
903f6e
--- mutt-1.5.21/muttbug.sh.in.tmpdir	2012-09-27 15:01:37.097392500 +0200
903f6e
+++ mutt-1.5.21/muttbug.sh.in	2012-09-27 15:01:52.061494226 +0200
903f6e
@@ -85,7 +85,7 @@ esac
903f6e
 exec > /dev/tty
903f6e
 exec < /dev/tty
903f6e
 
903f6e
-SCRATCH=${TMPDIR-/tmp}/`basename $0`.`hostname`.$$
903f6e
+SCRATCH=${TMPDIR-/var/tmp}/`basename $0`.`hostname`.$$
903f6e
 
903f6e
 mkdir ${SCRATCH} || \
903f6e
 {