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

Side by Side Diff: chrome/browser/extensions/sandboxed_extension_unpacker.cc

Issue 2802018: Loosen permission on extension temp dir when a flag is used. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: Rebase for commit. Created 10 years, 5 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 unified diff | Download patch
« no previous file with comments | « base/scoped_temp_dir_unittest.cc ('k') | chrome/browser/utility_process_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/sandboxed_extension_unpacker.h" 5 #include "chrome/browser/extensions/sandboxed_extension_unpacker.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/crypto/signature_verifier.h" 10 #include "base/crypto/signature_verifier.h"
(...skipping 24 matching lines...) Expand all
35 : crx_path_(crx_path), temp_path_(temp_path), 35 : crx_path_(crx_path), temp_path_(temp_path),
36 thread_identifier_(ChromeThread::ID_COUNT), 36 thread_identifier_(ChromeThread::ID_COUNT),
37 rdh_(rdh), client_(client), got_response_(false) { 37 rdh_(rdh), client_(client), got_response_(false) {
38 } 38 }
39 39
40 void SandboxedExtensionUnpacker::Start() { 40 void SandboxedExtensionUnpacker::Start() {
41 // We assume that we are started on the thread that the client wants us to do 41 // We assume that we are started on the thread that the client wants us to do
42 // file IO on. 42 // file IO on.
43 CHECK(ChromeThread::GetCurrentThreadIdentifier(&thread_identifier_)); 43 CHECK(ChromeThread::GetCurrentThreadIdentifier(&thread_identifier_));
44 44
45 // To understand crbug/35198, allow users who can reproduce the bug
46 // to loosen permissions on the scoped directory.
47 bool loosen_permissions = false;
48 #if defined (OS_WIN)
49 loosen_permissions = CommandLine::ForCurrentProcess()->HasSwitch(
50 switches::kIssue35198Permission);
51 LOG(INFO) << "loosen_permissions = " << loosen_permissions;
52 #endif
53
45 // Create a temporary directory to work in. 54 // Create a temporary directory to work in.
46 if (!temp_dir_.CreateUniqueTempDirUnderPath(temp_path_)) { 55 if (!temp_dir_.CreateUniqueTempDirUnderPath(temp_path_,
56 loosen_permissions)) {
47 ReportFailure("Could not create temporary directory."); 57 ReportFailure("Could not create temporary directory.");
48 return; 58 return;
49 } 59 }
50 60
51 // Initialize the path that will eventually contain the unpacked extension. 61 // Initialize the path that will eventually contain the unpacked extension.
52 extension_root_ = temp_dir_.path().AppendASCII( 62 extension_root_ = temp_dir_.path().AppendASCII(
53 extension_filenames::kTempExtensionName); 63 extension_filenames::kTempExtensionName);
54 64
65 // To understand crbug/35198, allow users who can reproduce the bug to
66 // create the unpack directory in the browser process.
67 bool crxdir_in_browser = CommandLine::ForCurrentProcess()->HasSwitch(
68 switches::kIssue35198CrxDirBrowser);
69 LOG(INFO) << "crxdir_in_browser = " << crxdir_in_browser;
70 if (crxdir_in_browser && !file_util::CreateDirectory(extension_root_)) {
71 LOG(ERROR) << "Failed to create directory " << extension_root_.value();
72 }
73
55 // Extract the public key and validate the package. 74 // Extract the public key and validate the package.
56 if (!ValidateSignature()) 75 if (!ValidateSignature())
57 return; // ValidateSignature() already reported the error. 76 return; // ValidateSignature() already reported the error.
58 77
59 // Copy the crx file into our working directory. 78 // Copy the crx file into our working directory.
60 FilePath temp_crx_path = temp_dir_.path().Append(crx_path_.BaseName()); 79 FilePath temp_crx_path = temp_dir_.path().Append(crx_path_.BaseName());
61 if (!file_util::CopyFile(crx_path_, temp_crx_path)) { 80 if (!file_util::CopyFile(crx_path_, temp_crx_path)) {
62 ReportFailure("Failed to copy extension file to temporary directory."); 81 ReportFailure("Failed to copy extension file to temporary directory.");
63 return; 82 return;
64 } 83 }
65 84
66 // The utility process will have access to the directory passed to 85 // The utility process will have access to the directory passed to
67 // SandboxedExtensionUnpacker. That directory should not contain a 86 // SandboxedExtensionUnpacker. That directory should not contain a
68 // symlink or NTFS junction, because when the path is used, following 87 // symlink or NTFS junction, because when the path is used, following
69 // the link will cause file system access outside the sandbox path. 88 // the link will cause file system access outside the sandbox path.
70 FilePath normalized_crx_path; 89 FilePath normalized_crx_path;
71 if (!file_util::NormalizeFilePath(temp_crx_path, &normalized_crx_path)) { 90 if (!file_util::NormalizeFilePath(temp_crx_path, &normalized_crx_path)) {
72 // TODO(skerner): Remove this logging once crbug/13044 is fixed.
73 // This bug is starred by many users who have some kind of link.
74 // If NormalizeFilePath() fails we want to see it in the logs they send.
75 LOG(ERROR) << "Could not get the normalized path of " 91 LOG(ERROR) << "Could not get the normalized path of "
76 << temp_crx_path.value(); 92 << temp_crx_path.value();
77 normalized_crx_path = temp_crx_path; 93 normalized_crx_path = temp_crx_path;
78 } else { 94 } else {
79 LOG(INFO) << "RealFilePath: from " << temp_crx_path.value() 95 LOG(INFO) << "RealFilePath: from " << temp_crx_path.value()
80 << " to " << normalized_crx_path.value(); 96 << " to " << normalized_crx_path.value();
81 } 97 }
82 98
83 // If we are supposed to use a subprocess, kick off the subprocess. 99 // If we are supposed to use a subprocess, kick off the subprocess.
84 // 100 //
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 if (!file_util::WriteFile(path, 408 if (!file_util::WriteFile(path,
393 catalog_json.c_str(), 409 catalog_json.c_str(),
394 catalog_json.size())) { 410 catalog_json.size())) {
395 ReportFailure("Error saving catalog."); 411 ReportFailure("Error saving catalog.");
396 return false; 412 return false;
397 } 413 }
398 } 414 }
399 415
400 return true; 416 return true;
401 } 417 }
OLDNEW
« no previous file with comments | « base/scoped_temp_dir_unittest.cc ('k') | chrome/browser/utility_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698