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

Side by Side Diff: trunk/src/content/common/sandbox_mac.mm

Issue 469293002: Revert 289526 "Fix Mac sandbox meta data access" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/common/sandbox_mac.h" 5 #include "content/common/sandbox_mac.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include <CoreFoundation/CFTimeZone.h> 9 #include <CoreFoundation/CFTimeZone.h>
10 extern "C" { 10 extern "C" {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 DLOG(FATAL) << "String quoting failed " << bad_string; 107 DLOG(FATAL) << "String quoting failed " << bad_string;
108 } 108 }
109 109
110 } // namespace 110 } // namespace
111 111
112 // static 112 // static
113 NSString* Sandbox::AllowMetadataForPath(const base::FilePath& allowed_path) { 113 NSString* Sandbox::AllowMetadataForPath(const base::FilePath& allowed_path) {
114 // Collect a list of all parent directories. 114 // Collect a list of all parent directories.
115 base::FilePath last_path = allowed_path; 115 base::FilePath last_path = allowed_path;
116 std::vector<base::FilePath> subpaths; 116 std::vector<base::FilePath> subpaths;
117 117 for (base::FilePath path = allowed_path;
118 base::FilePath path = allowed_path; 118 path.value() != last_path.value();
119 do { 119 path = path.DirName()) {
120 subpaths.push_back(path); 120 subpaths.push_back(path);
121
122 last_path = path; 121 last_path = path;
123 path = path.DirName(); 122 }
124 } while (path.value() != last_path.value());
125 123
126 // Iterate through all parents and allow stat() on them explicitly. 124 // Iterate through all parents and allow stat() on them explicitly.
127 NSString* sandbox_command = @"(allow file-read-metadata "; 125 NSString* sandbox_command = @"(allow file-read-metadata ";
128 for (std::vector<base::FilePath>::reverse_iterator i = subpaths.rbegin(); 126 for (std::vector<base::FilePath>::reverse_iterator i = subpaths.rbegin();
129 i != subpaths.rend(); 127 i != subpaths.rend();
130 ++i) { 128 ++i) {
131 std::string subdir_escaped; 129 std::string subdir_escaped;
132 if (!QuotePlainString(i->value(), &subdir_escaped)) { 130 if (!QuotePlainString(i->value(), &subdir_escaped)) {
133 FatalStringQuoteException(i->value()); 131 FatalStringQuoteException(i->value());
134 return nil; 132 return nil;
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 if (HANDLE_EINTR(fcntl(fd.get(), F_GETPATH, canonical_path)) != 0) { 614 if (HANDLE_EINTR(fcntl(fd.get(), F_GETPATH, canonical_path)) != 0) {
617 DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: " 615 DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: "
618 << path.value(); 616 << path.value();
619 return path; 617 return path;
620 } 618 }
621 619
622 return base::FilePath(canonical_path); 620 return base::FilePath(canonical_path);
623 } 621 }
624 622
625 } // namespace content 623 } // namespace content
OLDNEW
« no previous file with comments | « trunk/src/content/common/sandbox_mac.h ('k') | trunk/src/content/common/sandbox_mac_diraccess_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698