Commit 2db07c1a authored by bartfab@chromium.org's avatar bartfab@chromium.org

Revert 289526 "Fix Mac sandbox meta data access"

Speculative revert as a lot of Mac bots broke when this landed:

http://build.chromium.org/p/chromium.mac/builders/Mac%2010.6%20Tests%20%28dbg%29%282%29/builds/54365
http://build.chromium.org/p/chromium.mac/builders/Mac%2010.6%20Tests%20%28dbg%29%284%29/builds/43947
http://build.chromium.org/p/chromium.mac/builders/Mac%2010.6%20Tests%20%28dbg%29%283%29/builds/52314

> Fix Mac sandbox meta data access
> 
> Sandbox::AllowMetadataForPath() currently allow all metadata access due to
> https://codereview.chromium.org/10539009/ made the for loop comparison
> in Sandbox::AllowMetadataForPath() always false, when we actually only
> want to allow access to the path and all its parent path until root.
> 
> Turn the for loop to a do/while loop instead as it's a better fit, also
> add a test case for Sandbox::AllowMetadataForPath().
> 
> It should only affect component builds on OS X 10.6 and utility process
> as no other process is using this mechanism.
> 
> Review URL: https://codereview.chromium.org/472513002

TBR=jiangj@opera.com

Review URL: https://codereview.chromium.org/469293002

Cr-Commit-Position: refs/heads/master@{#289541}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289541 0039d316-1c4b-4281-b951-d872f2087c98
parent 23005b6b
......@@ -160,7 +160,6 @@ class CONTENT_EXPORT Sandbox {
FRIEND_TEST_ALL_PREFIXES(MacDirAccessSandboxTest, StringEscape);
FRIEND_TEST_ALL_PREFIXES(MacDirAccessSandboxTest, RegexEscape);
FRIEND_TEST_ALL_PREFIXES(MacDirAccessSandboxTest, SandboxAccess);
FRIEND_TEST_ALL_PREFIXES(MacDirAccessSandboxTest, AllowMetadataForPath);
DISALLOW_IMPLICIT_CONSTRUCTORS(Sandbox);
};
......
......@@ -114,14 +114,12 @@ NSString* Sandbox::AllowMetadataForPath(const base::FilePath& allowed_path) {
// Collect a list of all parent directories.
base::FilePath last_path = allowed_path;
std::vector<base::FilePath> subpaths;
base::FilePath path = allowed_path;
do {
for (base::FilePath path = allowed_path;
path.value() != last_path.value();
path = path.DirName()) {
subpaths.push_back(path);
last_path = path;
path = path.DirName();
} while (path.value() != last_path.value());
}
// Iterate through all parents and allow stat() on them explicitly.
NSString* sandbox_command = @"(allow file-read-metadata ";
......
......@@ -127,6 +127,7 @@ TEST_F(MacDirAccessSandboxTest, RegexEscape) {
std::string out;
EXPECT_TRUE(Sandbox::QuoteStringForRegex(in_utf8, &out));
EXPECT_EQ(expected, out);
}
}
......@@ -177,18 +178,6 @@ TEST_F(MacDirAccessSandboxTest, SandboxAccess) {
}
}
TEST_F(MacDirAccessSandboxTest, AllowMetadataForPath) {
{
std::string expected(
"(allow file-read-metadata (literal \"/\")(literal \"/System\")"
"(literal \"/System/Library\")"
"(literal \"/System/Library/Frameworks\"))");
NSString* sandbox_command = Sandbox::AllowMetadataForPath(
base::FilePath("/System/Library/Frameworks"));
EXPECT_EQ(base::SysNSStringToUTF8(sandbox_command), expected);
}
}
MULTIPROCESS_TEST_MAIN(mac_sandbox_path_access) {
char *sandbox_allowed_dir = getenv(kSandboxAccessPathKey);
if (!sandbox_allowed_dir)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment