Subject: 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.
Patch created by: martin f. krafft
Attachments appear as follows by default:
-- 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 @@ -6944,7 +6944,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 used.
+used. If $TMPDIR
is not set then “/var/tmp
” is used.
Type: string
Default: “ +TCFL
”
Controls the character used to indicate mail addressed to you. The
diff -up mutt-1.5.21/doc/manual.txt.tmpdir mutt-1.5.21/doc/manual.txt
--- mutt-1.5.21/doc/manual.txt.tmpdir 2012-09-27 15:04:20.601518838 +0200
+++ mutt-1.5.21/doc/manual.txt 2012-09-27 15:04:50.154724683 +0200
@@ -4524,7 +4524,7 @@ description.
Attachments appear as follows by default:
-- 1 [text/plain, 7bit, 1K] /tmp/mutt-euler-8082-0
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.
Type: string
Default: “ +TCFL
”
Controls the character used to indicate mail addressed to you. The diff -up mutt-1.5.21/init.c.tmpdir mutt-1.5.21/init.c --- mutt-1.5.21/init.c.tmpdir 2012-09-27 14:59:10.099395476 +0200 +++ mutt-1.5.21/init.c 2012-09-27 14:59:23.292484023 +0200 @@ -2992,7 +2992,7 @@ void mutt_init (int skip_sys_rc, LIST *c 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 -up mutt-1.5.21/init.h.tmpdir mutt-1.5.21/init.h --- mutt-1.5.21/init.h.tmpdir 2012-09-27 14:59:46.214638908 +0200 +++ mutt-1.5.21/init.h 2012-09-27 15:00:21.541877784 +0200 @@ -3178,7 +3178,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 -up mutt-1.5.21/install-sh.tmpdir mutt-1.5.21/install-sh --- mutt-1.5.21/install-sh.tmpdir 2012-09-27 15:00:32.246950740 +0200 +++ mutt-1.5.21/install-sh 2012-09-27 15:01:15.957247967 +0200 @@ -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 -up mutt-1.5.21/muttbug.sh.in.tmpdir mutt-1.5.21/muttbug.sh.in --- mutt-1.5.21/muttbug.sh.in.tmpdir 2012-09-27 15:01:37.097392500 +0200 +++ mutt-1.5.21/muttbug.sh.in 2012-09-27 15:01:52.061494226 +0200 @@ -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} || \ {