summaryrefslogtreecommitdiffstats
path: root/chrome/browser/download
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-24 23:55:55 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-24 23:55:55 +0000
commitf84233c60d5c6d64abd253cc5c9fd61b6381d3cc (patch)
tree6228b3b597cc15e72877e7372313fa2ae47c2c69 /chrome/browser/download
parentf11030094e99bcb61555dc3bb4c157703dc1d7ea (diff)
downloadchromium_src-f84233c60d5c6d64abd253cc5c9fd61b6381d3cc.zip
chromium_src-f84233c60d5c6d64abd253cc5c9fd61b6381d3cc.tar.gz
chromium_src-f84233c60d5c6d64abd253cc5c9fd61b6381d3cc.tar.bz2
Posix: Set download file's permissions correctly.
BUG=36107 TEST=see bug. Review URL: http://codereview.chromium.org/661025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39953 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download')
-rw-r--r--chrome/browser/download/download_file.cc17
1 files changed, 14 insertions, 3 deletions
diff --git a/chrome/browser/download/download_file.cc b/chrome/browser/download/download_file.cc
index 09d5e1d..a619647 100644
--- a/chrome/browser/download/download_file.cc
+++ b/chrome/browser/download/download_file.cc
@@ -121,10 +121,21 @@ bool DownloadFile::Rename(const FilePath& new_path) {
if (!file_util::RenameFileAndResetSecurityDescriptor(full_path_, new_path))
return false;
#elif defined(OS_POSIX)
- // TODO(estade): Move() falls back to copying and deleting when a simple
- // rename fails. Copying sucks for large downloads. crbug.com/8737
- if (!file_util::Move(full_path_, new_path))
+ {
+ // Similarly, on Unix, we're moving a temp file created with permissions
+ // 600 to |new_path|. Here, we try to fix up the destination file with
+ // appropriate permissions.
+ struct stat st;
+ bool stat_succeeded = (stat(new_path.value().c_str(), &st) == 0);
+
+ // TODO(estade): Move() falls back to copying and deleting when a simple
+ // rename fails. Copying sucks for large downloads. crbug.com/8737
+ if (!file_util::Move(full_path_, new_path))
return false;
+
+ if (stat_succeeded)
+ chmod(new_path.value().c_str(), st.st_mode);
+ }
#endif
full_path_ = new_path;