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

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

Issue 197873014: Revert of Implement ScopedFD in terms of ScopedGeneric. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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" {
11 #include <sandbox.h> 11 #include <sandbox.h>
12 } 12 }
13 #include <signal.h> 13 #include <signal.h>
14 #include <sys/param.h> 14 #include <sys/param.h>
15 15
16 #include "base/basictypes.h" 16 #include "base/basictypes.h"
17 #include "base/command_line.h" 17 #include "base/command_line.h"
18 #include "base/compiler_specific.h" 18 #include "base/compiler_specific.h"
19 #include "base/file_util.h" 19 #include "base/file_util.h"
20 #include "base/files/scoped_file.h"
21 #include "base/mac/bundle_locations.h" 20 #include "base/mac/bundle_locations.h"
22 #include "base/mac/mac_util.h" 21 #include "base/mac/mac_util.h"
23 #include "base/mac/scoped_cftyperef.h" 22 #include "base/mac/scoped_cftyperef.h"
24 #include "base/mac/scoped_nsautorelease_pool.h" 23 #include "base/mac/scoped_nsautorelease_pool.h"
25 #include "base/mac/scoped_nsobject.h" 24 #include "base/mac/scoped_nsobject.h"
26 #include "base/rand_util.h" 25 #include "base/rand_util.h"
27 #include "base/strings/string16.h" 26 #include "base/strings/string16.h"
28 #include "base/strings/string_piece.h" 27 #include "base/strings/string_piece.h"
29 #include "base/strings/string_util.h" 28 #include "base/strings/string_util.h"
30 #include "base/strings/stringprintf.h" 29 #include "base/strings/stringprintf.h"
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 return success; 600 return success;
602 } 601 }
603 602
604 // static 603 // static
605 bool Sandbox::SandboxIsCurrentlyActive() { 604 bool Sandbox::SandboxIsCurrentlyActive() {
606 return gSandboxIsActive; 605 return gSandboxIsActive;
607 } 606 }
608 607
609 // static 608 // static
610 base::FilePath Sandbox::GetCanonicalSandboxPath(const base::FilePath& path) { 609 base::FilePath Sandbox::GetCanonicalSandboxPath(const base::FilePath& path) {
611 base::ScopedFD fd(HANDLE_EINTR(open(path.value().c_str(), O_RDONLY))); 610 int fd = HANDLE_EINTR(open(path.value().c_str(), O_RDONLY));
612 if (!fd.is_valid()) { 611 if (fd < 0) {
613 DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: " 612 DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: "
614 << path.value(); 613 << path.value();
615 return path; 614 return path;
616 } 615 }
616 file_util::ScopedFD file_closer(&fd);
617 617
618 base::FilePath::CharType canonical_path[MAXPATHLEN]; 618 base::FilePath::CharType canonical_path[MAXPATHLEN];
619 if (HANDLE_EINTR(fcntl(fd.get(), F_GETPATH, canonical_path)) != 0) { 619 if (HANDLE_EINTR(fcntl(fd, F_GETPATH, canonical_path)) != 0) {
620 DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: " 620 DPLOG(FATAL) << "GetCanonicalSandboxPath() failed for: "
621 << path.value(); 621 << path.value();
622 return path; 622 return path;
623 } 623 }
624 624
625 return base::FilePath(canonical_path); 625 return base::FilePath(canonical_path);
626 } 626 }
627 627
628 } // namespace content 628 } // namespace content
OLDNEW
« no previous file with comments | « content/common/sandbox_linux/sandbox_linux.cc ('k') | content/common/sandbox_mac_system_access_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698