OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef SANDBOX_LINUX_SERVICES_NAMESPACE_UTILS_H_ | 5 #ifndef SANDBOX_LINUX_SERVICES_NAMESPACE_UTILS_H_ |
6 #define SANDBOX_LINUX_SERVICES_NAMESPACE_UTILS_H_ | 6 #define SANDBOX_LINUX_SERVICES_NAMESPACE_UTILS_H_ |
7 | 7 |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 | 9 |
| 10 #include <type_traits> |
| 11 |
10 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
11 #include "base/macros.h" | 13 #include "base/macros.h" |
12 #include "base/template_util.h" | |
13 #include "sandbox/sandbox_export.h" | 14 #include "sandbox/sandbox_export.h" |
14 | 15 |
15 namespace sandbox { | 16 namespace sandbox { |
16 | 17 |
17 // Utility functions for using Linux namepaces. | 18 // Utility functions for using Linux namepaces. |
18 class SANDBOX_EXPORT NamespaceUtils { | 19 class SANDBOX_EXPORT NamespaceUtils { |
19 public: | 20 public: |
20 static_assert((base::is_same<uid_t, gid_t>::value), | 21 static_assert(std::is_same<uid_t, gid_t>::value, |
21 "uid_t and gid_t must be the same type"); | 22 "uid_t and gid_t must be the same type"); |
22 // generic_id_t can be used for either uid_t or gid_t. | 23 // generic_id_t can be used for either uid_t or gid_t. |
23 typedef uid_t generic_id_t; | 24 typedef uid_t generic_id_t; |
24 | 25 |
25 // Write a uid or gid mapping from |id| to |id| in |map_file|. This function | 26 // Write a uid or gid mapping from |id| to |id| in |map_file|. This function |
26 // is async-signal-safe. | 27 // is async-signal-safe. |
27 static bool WriteToIdMapFile(const char* map_file, | 28 static bool WriteToIdMapFile(const char* map_file, |
28 generic_id_t id) WARN_UNUSED_RESULT; | 29 generic_id_t id) WARN_UNUSED_RESULT; |
29 | 30 |
30 // Returns true if unprivileged namespaces of type |type| is supported | 31 // Returns true if unprivileged namespaces of type |type| is supported |
(...skipping 14 matching lines...) Expand all Loading... |
45 // KernelSupportsDenySetgroups. This function is async-signal-safe. | 46 // KernelSupportsDenySetgroups. This function is async-signal-safe. |
46 static bool DenySetgroups() WARN_UNUSED_RESULT; | 47 static bool DenySetgroups() WARN_UNUSED_RESULT; |
47 | 48 |
48 private: | 49 private: |
49 DISALLOW_IMPLICIT_CONSTRUCTORS(NamespaceUtils); | 50 DISALLOW_IMPLICIT_CONSTRUCTORS(NamespaceUtils); |
50 }; | 51 }; |
51 | 52 |
52 } // namespace sandbox | 53 } // namespace sandbox |
53 | 54 |
54 #endif // SANDBOX_LINUX_SERVICES_NAMESPACE_UTILS_H_ | 55 #endif // SANDBOX_LINUX_SERVICES_NAMESPACE_UTILS_H_ |
OLD | NEW |