Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1063)

Unified Diff: chrome/browser/chromeos/gdata/gdata_file_system.cc

Issue 10072003: gdata: Change permissions of cache persistent directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/gdata/gdata_file_system.cc
diff --git a/chrome/browser/chromeos/gdata/gdata_file_system.cc b/chrome/browser/chromeos/gdata/gdata_file_system.cc
index dd2ed256ae88be849e6c3baca1d3dc83fc6ca550..a8c7dc21ebe9f21879bc51324b1f04e10422f771 100644
--- a/chrome/browser/chromeos/gdata/gdata_file_system.cc
+++ b/chrome/browser/chromeos/gdata/gdata_file_system.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/chromeos/gdata/gdata_file_system.h"
#include <errno.h>
+#include <sys/stat.h>
#include <utility>
@@ -204,6 +205,22 @@ base::PlatformFileError CreateCacheDirectories(
return error;
}
+// Changes the permissions of |file_path| to |permissions|.
+// Returns the platform error code of the operation.
+base::PlatformFileError ChangeFilePermissions(const FilePath& file_path,
+ mode_t permissions) {
+ base::PlatformFileError error = base::PLATFORM_FILE_OK;
+
+ if (HANDLE_EINTR(chmod(file_path.value().c_str(), permissions)) != 0) {
+ error = SystemToPlatformError(errno);
+ PLOG(ERROR) << "Error changing permissions of " << file_path.value();
+ } else {
+ DVLOG(1) << "Changed permissions of " << file_path.value();
+ }
+
+ return error;
+}
+
// Modifies cache state of file on IO thread pool, which involves:
// - moving or copying file (per |file_operation_type|) from |source_path| to
// |dest_path| if they're different
@@ -3249,7 +3266,14 @@ void GDataFileSystem::InitializeCacheIfNecessary() {
void GDataFileSystem::InitializeCacheOnIOThreadPool() {
base::PlatformFileError error = CreateCacheDirectories(cache_paths_);
+ if (error != base::PLATFORM_FILE_OK)
+ return;
+ // Change permissions of cache persistent directory to u+rwx,og+x in order to
+ // allow archive files in that directory to be mounted by cros-disks.
+ error = ChangeFilePermissions(
+ cache_paths_[GDataRootDirectory::CACHE_TYPE_PERSISTENT],
+ S_IRWXU | S_IXGRP | S_IXOTH);
if (error != base::PLATFORM_FILE_OK)
return;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698