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

Side by Side Diff: sandbox/linux/services/namespace_utils.h

Issue 881733002: Add namespace sandbox class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Last round of comments. Created 5 years, 10 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
OLDNEW
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 "base/compiler_specific.h"
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/template_util.h" 12 #include "base/template_util.h"
12 #include "sandbox/sandbox_export.h" 13 #include "sandbox/sandbox_export.h"
13 14
14 namespace sandbox { 15 namespace sandbox {
15 16
16 // Utility functions for using Linux namepaces. 17 // Utility functions for using Linux namepaces.
17 class SANDBOX_EXPORT NamespaceUtils { 18 class SANDBOX_EXPORT NamespaceUtils {
18 public: 19 public:
19 COMPILE_ASSERT((base::is_same<uid_t, gid_t>::value), UidAndGidAreSameType); 20 COMPILE_ASSERT((base::is_same<uid_t, gid_t>::value), UidAndGidAreSameType);
20 // generic_id_t can be used for either uid_t or gid_t. 21 // generic_id_t can be used for either uid_t or gid_t.
21 typedef uid_t generic_id_t; 22 typedef uid_t generic_id_t;
22 23
23 // Write a uid or gid mapping from |id| to |id| in |map_file|. 24 // Write a uid or gid mapping from |id| to |id| in |map_file|. This function
24 static bool WriteToIdMapFile(const char* map_file, generic_id_t id); 25 // is async-signal-safe.
26 static bool WriteToIdMapFile(const char* map_file,
27 generic_id_t id) WARN_UNUSED_RESULT;
25 28
26 // Returns true if unprivileged namespaces of type |type| is supported 29 // Returns true if unprivileged namespaces of type |type| is supported
27 // (meaning that both CLONE_NEWUSER and type are are supported). |type| must 30 // (meaning that both CLONE_NEWUSER and type are are supported). |type| must
28 // be one of CLONE_NEWIPC, CLONE_NEWNET, CLONE_NEWNS, CLONE_NEWPID, 31 // be one of CLONE_NEWIPC, CLONE_NEWNET, CLONE_NEWNS, CLONE_NEWPID,
29 // CLONE_NEWUSER, or CLONE_NEWUTS. This relies on access to /proc, so it will 32 // CLONE_NEWUSER, or CLONE_NEWUTS. This relies on access to /proc, so it will
30 // not work from within a sandbox. 33 // not work from within a sandbox.
31 static bool KernelSupportsUnprivilegedNamespace(int type); 34 static bool KernelSupportsUnprivilegedNamespace(int type);
32 35
33 private: 36 private:
34 DISALLOW_IMPLICIT_CONSTRUCTORS(NamespaceUtils); 37 DISALLOW_IMPLICIT_CONSTRUCTORS(NamespaceUtils);
35 }; 38 };
36 39
37 } // namespace sandbox 40 } // namespace sandbox
38 41
39 #endif // SANDBOX_LINUX_SERVICES_NAMESPACE_UTILS_H_ 42 #endif // SANDBOX_LINUX_SERVICES_NAMESPACE_UTILS_H_
OLDNEW
« no previous file with comments | « sandbox/linux/services/namespace_sandbox_unittest.cc ('k') | sandbox/linux/services/namespace_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698