OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "sandbox/linux/services/credentials.h" | 5 #include "sandbox/linux/services/credentials.h" |
6 | 6 |
7 #include <dirent.h> | 7 #include <dirent.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <fcntl.h> | 9 #include <fcntl.h> |
10 #include <signal.h> | 10 #include <signal.h> |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 // Wrapper to manage the result from libcap2's cap_from_text(). | 49 // Wrapper to manage the result from libcap2's cap_from_text(). |
50 typedef scoped_ptr<char, CapTextFreeDeleter> ScopedCapText; | 50 typedef scoped_ptr<char, CapTextFreeDeleter> ScopedCapText; |
51 | 51 |
52 struct FILECloser { | 52 struct FILECloser { |
53 inline void operator()(FILE* f) const { | 53 inline void operator()(FILE* f) const { |
54 DCHECK(f); | 54 DCHECK(f); |
55 PCHECK(0 == fclose(f)); | 55 PCHECK(0 == fclose(f)); |
56 } | 56 } |
57 }; | 57 }; |
58 | 58 |
59 // Don't use ScopedFILE in base/file_util.h since it doesn't check fclose(). | 59 // Don't use ScopedFILE in base since it doesn't check fclose(). |
60 // TODO(jln): fix base/. | 60 // TODO(jln): fix base/. |
61 typedef scoped_ptr<FILE, FILECloser> ScopedFILE; | 61 typedef scoped_ptr<FILE, FILECloser> ScopedFILE; |
62 | 62 |
63 struct DIRCloser { | 63 struct DIRCloser { |
64 void operator()(DIR* d) const { | 64 void operator()(DIR* d) const { |
65 DCHECK(d); | 65 DCHECK(d); |
66 PCHECK(0 == closedir(d)); | 66 PCHECK(0 == closedir(d)); |
67 } | 67 } |
68 }; | 68 }; |
69 | 69 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 } | 309 } |
310 | 310 |
311 bool Credentials::DropFileSystemAccess() { | 311 bool Credentials::DropFileSystemAccess() { |
312 // Chrooting to a safe empty dir will only be safe if no directory file | 312 // Chrooting to a safe empty dir will only be safe if no directory file |
313 // descriptor is available to the process. | 313 // descriptor is available to the process. |
314 DCHECK(!HasOpenDirectory(-1)); | 314 DCHECK(!HasOpenDirectory(-1)); |
315 return ChrootToSafeEmptyDir(); | 315 return ChrootToSafeEmptyDir(); |
316 } | 316 } |
317 | 317 |
318 } // namespace sandbox. | 318 } // namespace sandbox. |
OLD | NEW |