Ensure g_file_copy() does not temporarily expose private files
authorColin Walters <walters@verbum.org>
Sun, 12 May 2013 06:28:01 +0000 (07:28 +0100)
committerColin Walters <walters@verbum.org>
Wed, 5 Jun 2013 18:00:20 +0000 (19:00 +0100)
commit9f1a0b57cdca9eb2f9d8a8ecd414369df739fb8d
treec31cdd02c402cc856eb80fd4c41c56df5f66c6d3
parent02aaef5a4dd92fe3a3f3a7c4ccebf22ca1ba2644
Ensure g_file_copy() does not temporarily expose private files

Previously, g_file_copy() would (on Unix) create files with the
default mode of 644.  For applications which might at user request
copy arbitrary private files such as ~/.ssh or /etc/shadow, a
world-readable copy would be temporarily exposed.

This patch is suboptimal in that it *only* fixes g_file_copy()
for the case where both source and destination are instances of
GLocalFile on Unix.

The reason for this is that the public GFile APIs for creating files
allow very limited control over the access permissions for the created
file; one can either say a file is "private" or not.  Fixing
this by adding e.g. g_file_create_with_attributes() would make sense,
except this would entail 8 new API calls for all the variants of
_create(), _create_async(), _replace(), _replace_async(),
_create_readwrite(), _create_readwrite_async(), _replace_readwrite(),
_replace_readwrite_async().  That can be done as a separate patch
later.

https://bugzilla.gnome.org/show_bug.cgi?id=699959
gio/gfile.c
gio/glocalfile.c
gio/glocalfile.h
gio/glocalfileoutputstream.c
gio/glocalfileoutputstream.h