From f6d07f6cc622da5409a4f09db2b34d9c44f71011 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 18 Jan 2010 13:50:33 -0500 Subject: =?UTF-8?q?Bug=C2=A0607234=20-=20Open=20received=20attachments=20a?= =?UTF-8?q?s=20read-only?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- widgets/misc/e-attachment.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/widgets/misc/e-attachment.c b/widgets/misc/e-attachment.c index a8cef68835..5385ab001c 100644 --- a/widgets/misc/e-attachment.c +++ b/widgets/misc/e-attachment.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -2045,6 +2046,7 @@ attachment_open_save_finished_cb (EAttachment *attachment, OpenContext *open_context) { GFile *file; + gchar *path; GError *error = NULL; file = e_attachment_save_finish (attachment, result, &error); @@ -2052,6 +2054,22 @@ attachment_open_save_finished_cb (EAttachment *attachment, if (attachment_open_check_for_error (open_context, error)) return; + /* Make the temporary file read-only. + * + * This step is non-critical, so if an error occurs just + * emit a warning and move on. + * + * XXX I haven't figured out how to do this through GIO. + * Attempting to set the "access::can-write" attribute via + * g_file_set_attribute() returned G_IO_ERROR_NOT_SUPPORTED + * and the only other possibility I see is "unix::mode", + * which is obviously not portable. + */ + path = g_file_get_path (file); + if (g_chmod (path, S_IRUSR | S_IRGRP | S_IROTH) < 0) + g_warning ("%s", g_strerror (errno)); + g_free (path); + attachment_open_file (file, open_context); g_object_unref (file); } -- cgit v1.2.3