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

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

Issue 472513002: Fix Mac sandbox meta data access (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
« no previous file with comments | « content/common/sandbox_mac.h ('k') | content/common/sandbox_mac_diraccess_unittest.mm » ('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) 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 for (base::FilePath path = allowed_path; 117
118 path.value() != last_path.value(); 118 base::FilePath path = allowed_path;
119 path = path.DirName()) { 119 do {
120 subpaths.push_back(path); 120 subpaths.push_back(path);
121
121 last_path = path; 122 last_path = path;
122 } 123 path = path.DirName();
124 } while (path.value() != last_path.value());
123 125
124 // Iterate through all parents and allow stat() on them explicitly. 126 // Iterate through all parents and allow stat() on them explicitly.
125 NSString* sandbox_command = @"(allow file-read-metadata "; 127 NSString* sandbox_command = @"(allow file-read-metadata ";
126 for (std::vector<base::FilePath>::reverse_iterator i = subpaths.rbegin(); 128 for (std::vector<base::FilePath>::reverse_iterator i = subpaths.rbegin();
127 i != subpaths.rend(); 129 i != subpaths.rend();
128 ++i) { 130 ++i) {
129 std::string subdir_escaped; 131 std::string subdir_escaped;
130 if (!QuotePlainString(i->value(), &subdir_escaped)) { 132 if (!QuotePlainString(i->value(), &subdir_escaped)) {
131 FatalStringQuoteException(i->value()); 133 FatalStringQuoteException(i->value());
132 return nil; 134 return nil;
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 if (HANDLE_EINTR(fcntl(fd.get(), F_GETPATH, canonical_path)) != 0) { 616 if (HANDLE_EINTR(fcntl(fd.get(), F_GETPATH, canonical_path)) != 0) {
615 DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: " 617 DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: "
616 << path.value(); 618 << path.value();
617 return path; 619 return path;
618 } 620 }
619 621
620 return base::FilePath(canonical_path); 622 return base::FilePath(canonical_path);
621 } 623 }
622 624
623 } // namespace content 625 } // namespace content
OLDNEW
« no previous file with comments | « content/common/sandbox_mac.h ('k') | content/common/sandbox_mac_diraccess_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698