diff options
author | borisv <borisv@chromium.org> | 2015-11-13 15:56:43 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-13 23:57:29 +0000 |
commit | c033ac1acfbe6226b10239a53d3d4b60f7cf9577 (patch) | |
tree | 8be8f28b5f08661dc8c0f8447bb292a29fc05261 | |
parent | 066f3cc5c5658a5a0b95c2eda0399cf1c85b726a (diff) | |
download | chromium_src-c033ac1acfbe6226b10239a53d3d4b60f7cf9577.zip chromium_src-c033ac1acfbe6226b10239a53d3d4b60f7cf9577.tar.gz chromium_src-c033ac1acfbe6226b10239a53d3d4b60f7cf9577.tar.bz2 |
Make the Chrome recovery component work for Mac
R=rsesek@chromium.org,sorin@chromium.org,mark@chromium.org
BUG=554979
Review URL: https://codereview.chromium.org/1440893002
Cr-Commit-Position: refs/heads/master@{#359695}
-rw-r--r-- | chrome/browser/component_updater/recovery_component_installer.cc | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/chrome/browser/component_updater/recovery_component_installer.cc b/chrome/browser/component_updater/recovery_component_installer.cc index 8943ab4..ea9b72e 100644 --- a/chrome/browser/component_updater/recovery_component_installer.cc +++ b/chrome/browser/component_updater/recovery_component_installer.cc @@ -315,6 +315,21 @@ bool RecoveryComponentInstaller::RunInstallCommand( } #endif // defined(OS_WIN) +#if defined(OS_POSIX) +// Sets the POSIX executable permissions on a file +bool SetPosixExecutablePermission(const base::FilePath& path) { + int permissions = 0; + if (!base::GetPosixFilePermissions(path, &permissions)) + return false; + const int kExecutableMask = base::FILE_PERMISSION_EXECUTE_BY_USER | + base::FILE_PERMISSION_EXECUTE_BY_GROUP | + base::FILE_PERMISSION_EXECUTE_BY_OTHERS; + if ((permissions & kExecutableMask) == kExecutableMask) + return true; // No need to update + return base::SetPosixFilePermissions(path, permissions | kExecutableMask); +} +#endif // defined(OS_POSIX) + bool RecoveryComponentInstaller::Install(const base::DictionaryValue& manifest, const base::FilePath& unpack_path) { std::string name; @@ -334,7 +349,7 @@ bool RecoveryComponentInstaller::Install(const base::DictionaryValue& manifest, if (!PathService::Get(DIR_RECOVERY_BASE, &path)) return false; if (!base::PathExists(path) && !base::CreateDirectory(path)) - return false; + return false; path = path.AppendASCII(version.GetString()); if (base::PathExists(path) && !base::DeleteFile(path, true)) return false; @@ -347,6 +362,17 @@ bool RecoveryComponentInstaller::Install(const base::DictionaryValue& manifest, if (!base::PathExists(main_file)) return false; +#if defined(OS_POSIX) + // The current version of the CRX unzipping does not restore + // correctly the executable flags/permissions. See https://crbug.com/555011 + if (!SetPosixExecutablePermission(main_file)) { + DVLOG(1) << "Recovery component failed to set the executable " + "permission on the file: " + << main_file.value(); + return false; + } +#endif + // Run the recovery component. const bool is_deferred_run = false; const auto cmdline = GetRecoveryInstallCommandLine( |