OLD | NEW |
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 if (!ValidateSignature()) | 57 if (!ValidateSignature()) |
58 return; // ValidateSignature() already reported the error. | 58 return; // ValidateSignature() already reported the error. |
59 | 59 |
60 // Copy the crx file into our working directory. | 60 // Copy the crx file into our working directory. |
61 FilePath temp_crx_path = temp_dir_.path().Append(crx_path_.BaseName()); | 61 FilePath temp_crx_path = temp_dir_.path().Append(crx_path_.BaseName()); |
62 if (!file_util::CopyFile(crx_path_, temp_crx_path)) { | 62 if (!file_util::CopyFile(crx_path_, temp_crx_path)) { |
63 ReportFailure("Failed to copy extension file to temporary directory."); | 63 ReportFailure("Failed to copy extension file to temporary directory."); |
64 return; | 64 return; |
65 } | 65 } |
66 | 66 |
67 // If we are supposed to use a subprocess, copy the crx to the temp directory | 67 // The utility process will have access to the directory passed to |
68 // and kick off the subprocess. | 68 // SandboxedExtensionUnpacker. That directory should not contain a |
| 69 // symlink or NTFS junction, because when the path is used, following |
| 70 // the link will cause file system access outside the sandbox path. |
| 71 FilePath normalized_crx_path; |
| 72 if (!file_util::NormalizeFilePath(temp_crx_path, &normalized_crx_path)) { |
| 73 // TODO(skerner): Remove this logging once crbug/13044 is fixed. |
| 74 // This bug is starred by many users who have some kind of link. |
| 75 // If NormalizeFilePath() fails we want to see it in the logs they send. |
| 76 LOG(ERROR) << "Could not get the normalized path of " |
| 77 << temp_crx_path.value(); |
| 78 normalized_crx_path = temp_crx_path; |
| 79 } else { |
| 80 LOG(INFO) << "RealFilePath: from " << temp_crx_path.value() |
| 81 << " to " << normalized_crx_path.value(); |
| 82 } |
| 83 |
| 84 // If we are supposed to use a subprocess, kick off the subprocess. |
69 // | 85 // |
70 // TODO(asargent) we shouldn't need to do this branch here - instead | 86 // TODO(asargent) we shouldn't need to do this branch here - instead |
71 // UtilityProcessHost should handle it for us. (http://crbug.com/19192) | 87 // UtilityProcessHost should handle it for us. (http://crbug.com/19192) |
72 bool use_utility_process = rdh_ && | 88 bool use_utility_process = rdh_ && |
73 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess); | 89 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess); |
74 if (use_utility_process) { | 90 if (use_utility_process) { |
75 ChromeThread::PostTask( | 91 ChromeThread::PostTask( |
76 ChromeThread::IO, FROM_HERE, | 92 ChromeThread::IO, FROM_HERE, |
77 NewRunnableMethod( | 93 NewRunnableMethod( |
78 this, | 94 this, |
79 &SandboxedExtensionUnpacker::StartProcessOnIOThread, | 95 &SandboxedExtensionUnpacker::StartProcessOnIOThread, |
80 temp_crx_path)); | 96 normalized_crx_path)); |
81 } else { | 97 } else { |
82 // Otherwise, unpack the extension in this process. | 98 // Otherwise, unpack the extension in this process. |
83 ExtensionUnpacker unpacker(temp_crx_path); | 99 ExtensionUnpacker unpacker(normalized_crx_path); |
84 if (unpacker.Run() && unpacker.DumpImagesToFile() && | 100 if (unpacker.Run() && unpacker.DumpImagesToFile() && |
85 unpacker.DumpMessageCatalogsToFile()) { | 101 unpacker.DumpMessageCatalogsToFile()) { |
86 OnUnpackExtensionSucceeded(*unpacker.parsed_manifest()); | 102 OnUnpackExtensionSucceeded(*unpacker.parsed_manifest()); |
87 } else { | 103 } else { |
88 OnUnpackExtensionFailed(unpacker.error_message()); | 104 OnUnpackExtensionFailed(unpacker.error_message()); |
89 } | 105 } |
90 } | 106 } |
91 } | 107 } |
92 | 108 |
93 void SandboxedExtensionUnpacker::StartProcessOnIOThread( | 109 void SandboxedExtensionUnpacker::StartProcessOnIOThread( |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 if (!file_util::WriteFile(path, | 419 if (!file_util::WriteFile(path, |
404 catalog_json.c_str(), | 420 catalog_json.c_str(), |
405 catalog_json.size())) { | 421 catalog_json.size())) { |
406 ReportFailure("Error saving catalog."); | 422 ReportFailure("Error saving catalog."); |
407 return false; | 423 return false; |
408 } | 424 } |
409 } | 425 } |
410 | 426 |
411 return true; | 427 return true; |
412 } | 428 } |
OLD | NEW |