summaryrefslogtreecommitdiffstats
path: root/base/path_service.cc
diff options
context:
space:
mode:
authorpastarmovj@chromium.org <pastarmovj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-04 13:04:11 +0000
committerpastarmovj@chromium.org <pastarmovj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-04 13:04:11 +0000
commit4b15160fbc0cdaea88842bb6ea36b40f8ef88c71 (patch)
tree2b328ceacaa081cf006d09d4fa001626256e8cf0 /base/path_service.cc
parent65e1332ddde91ec93011b84fa41f952d12807a62 (diff)
downloadchromium_src-4b15160fbc0cdaea88842bb6ea36b40f8ef88c71.zip
chromium_src-4b15160fbc0cdaea88842bb6ea36b40f8ef88c71.tar.gz
chromium_src-4b15160fbc0cdaea88842bb6ea36b40f8ef88c71.tar.bz2
Make sure only the main browser process and service proceses are allowed to create the profile directory.
This patch lets Chrome start with profile located on a network share on Windows Vista and newer. BUG=120388 TEST=Start Chrome with --user-data-dir pointing to a network share location and try to navigate to a web page. This should not lead to a hang of the renderer. Review URL: http://codereview.chromium.org/10306009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135321 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/path_service.cc')
-rw-r--r--base/path_service.cc25
1 files changed, 18 insertions, 7 deletions
diff --git a/base/path_service.cc b/base/path_service.cc
index 46f394c..a3b882c 100644
--- a/base/path_service.cc
+++ b/base/path_service.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -222,18 +222,29 @@ bool PathService::Get(int key, FilePath* result) {
}
bool PathService::Override(int key, const FilePath& path) {
+ // Just call the full function with true for the value of |create|.
+ return OverrideAndCreateIfNeeded(key, path, true);
+}
+
+bool PathService::OverrideAndCreateIfNeeded(int key,
+ const FilePath& path,
+ bool create) {
PathData* path_data = GetPathData();
DCHECK(path_data);
DCHECK_GT(key, base::DIR_CURRENT) << "invalid path key";
FilePath file_path = path;
- // Make sure the directory exists. We need to do this before we translate
- // this to the absolute path because on POSIX, AbsolutePath fails if called
- // on a non-existent path.
- if (!file_util::PathExists(file_path) &&
- !file_util::CreateDirectory(file_path))
- return false;
+ // For some locations this will fail if called from inside the sandbox there-
+ // fore we protect this call with a flag.
+ if (create) {
+ // Make sure the directory exists. We need to do this before we translate
+ // this to the absolute path because on POSIX, AbsolutePath fails if called
+ // on a non-existent path.
+ if (!file_util::PathExists(file_path) &&
+ !file_util::CreateDirectory(file_path))
+ return false;
+ }
// We need to have an absolute path, as extensions and plugins don't like
// relative paths, and will gladly crash the browser in CHECK()s if they get a