Re: [Mutt] #3261: mutt should open attachment as read-only file for external viewer
#3261: mutt should open attachment as read-only file for external viewer
------------------------------+---------------------------------------------
Reporter: antonio@â | Owner: mutt-dev
Type: enhancement | Status: new
Priority: minor | Milestone:
Component: mutt | Version:
Keywords: |
------------------------------+---------------------------------------------
Comment(by pweis):
Turns out that mutt needs write permissions to unlink a file, see
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=569500). The following
patch from James Vega fixes this problem by restoring write permissions
just before the unlink.
{{{
Open received attachments as read-only so the editor won't be able to
modify
it; otherwise the user can believe that he/she can edit it and risk to
lose
his/her work (see upstream bug http://bugs.mutt.org/3261)
--- a/attach.c
+++ b/attach.c
@@ -492,6 +492,7 @@
FREE (&fname);
if (mutt_save_attachment (fp, a, tempfile, 0, NULL) == -1)
goto return_error;
+ chmod (tempfile, 0400);
}
use_pipe = rfc1524_expand_command (a, tempfile, type,
@@ -633,7 +634,11 @@
if (entry)
rfc1524_free_entry (&entry);
if (fp && tempfile[0])
+ {
+ /* Restore write permission so mutt_unlink can open the file for
writing */
+ chmod(tempfile, 0600);
mutt_unlink (tempfile);
+ }
else if (unlink_tempfile)
unlink(tempfile);
}}}
--
Ticket URL: <http://dev.mutt.org/trac/ticket/3261#comment:2>
Mutt <http://www.mutt.org/>
The Mutt mail user agent