diff options
author | benchan@chromium.org <benchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-09 06:32:05 +0000 |
---|---|---|
committer | benchan@chromium.org <benchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-09 06:32:05 +0000 |
commit | b75cf235a0b3830b03649dc492a93dc4365b8bd9 (patch) | |
tree | 530e3538012e69a7241b9c63cb5cb1b1d204335e /webkit/fileapi/native_file_util.cc | |
parent | 3293960bdf505b7d8249fe17a7ecbf5c81984614 (diff) | |
download | chromium_src-b75cf235a0b3830b03649dc492a93dc4365b8bd9.zip chromium_src-b75cf235a0b3830b03649dc492a93dc4365b8bd9.tar.gz chromium_src-b75cf235a0b3830b03649dc492a93dc4365b8bd9.tar.bz2 |
Give group/other users access to directories created by File API on Chrome OS.
This CL complements a previous CL committed to revision 110740. The
previous CL makes files created by Chrome (via File API) readable by
group and other users on Chrome OS. However, that does not address the
permission issue on directories created by Chrome. Files under
directories created by Chrome are not readable by group and other users
without making the directories accessible by group and other users as
well.
BUG=126401
TEST=Check permissions (i.e. 0711) on directories created by File API.
Review URL: https://chromiumcodereview.appspot.com/10379027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135994 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi/native_file_util.cc')
-rw-r--r-- | webkit/fileapi/native_file_util.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/webkit/fileapi/native_file_util.cc b/webkit/fileapi/native_file_util.cc index a0d2b35..f73c74a 100644 --- a/webkit/fileapi/native_file_util.cc +++ b/webkit/fileapi/native_file_util.cc @@ -12,6 +12,29 @@ namespace fileapi { +namespace { + +// Sets permissions on directory at |dir_path| based on the target platform. +// Returns true on success, or false otherwise. +// +// TODO(benchan): Find a better place outside webkit to host this function. +bool SetPlatformSpecificDirectoryPermissions(const FilePath& dir_path) { +#if defined(OS_CHROMEOS) + // System daemons on Chrome OS may run as a user different than the Chrome + // process but need to access files under the directories created here. + // Because of that, grant the execute permission on the created directory + // to group and other users. + if (HANDLE_EINTR(chmod(dir_path.value().c_str(), + S_IRWXU | S_IXGRP | S_IXOTH)) != 0) { + return false; + } +#endif + // Keep the directory permissions unchanged on non-Chrome OS platforms. + return true; +} + +} // namespace + class NativeFileEnumerator : public FileSystemFileUtil::AbstractFileEnumerator { public: NativeFileEnumerator(const FilePath& root_path, @@ -125,6 +148,10 @@ PlatformFileError NativeFileUtil::CreateDirectory( if (!file_util::CreateDirectory(path.internal_path())) return base::PLATFORM_FILE_ERROR_FAILED; + + if (!SetPlatformSpecificDirectoryPermissions(path.internal_path())) + return base::PLATFORM_FILE_ERROR_FAILED; + return base::PLATFORM_FILE_OK; } |