mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Add DisableNamespaces to PolicyBuilder
Currently mostly no-op, but this is the first step to turn namespaces on by default. PiperOrigin-RevId: 249439158 Change-Id: I5eeb1216dc868c660f62ad50c34f626afbf7db61
This commit is contained in:
parent
71a317e65f
commit
85059ef40d
|
@ -31,7 +31,6 @@
|
|||
#include <cstdint>
|
||||
#include <utility>
|
||||
|
||||
#include <glog/logging.h>
|
||||
#include "absl/strings/escaping.h"
|
||||
#include "absl/strings/match.h"
|
||||
#include "sandboxed_api/sandbox2/namespace.h"
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
#include <glog/logging.h>
|
||||
#include "absl/base/macros.h"
|
||||
#include "absl/memory/memory.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
|
@ -444,10 +445,27 @@ class PolicyBuilder final {
|
|||
// (e.g. AddFile), therefore it is only necessary to explicitly enable
|
||||
// namespaces when not using any other namespace helper feature.
|
||||
PolicyBuilder& EnableNamespaces() {
|
||||
CHECK(!disable_namespaces_)
|
||||
<< "Namespaces cannot be both disabled and enabled";
|
||||
use_namespaces_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Disables the use of namespaces.
|
||||
//
|
||||
// Sandbox2 with namespaces enabled is the recommended mode and will be the
|
||||
// default in future, then calling this function will be necessary in order
|
||||
// to use Sandbox2 without namespaces.
|
||||
PolicyBuilder& DisableNamespaces() {
|
||||
CHECK(!use_namespaces_)
|
||||
<< "Namespaces cannot be both disabled and enabled. You're probably "
|
||||
"using features that implicitly enable namespaces (SetHostname, "
|
||||
"AddFile, AddDirectory, AddDataDependency, AddLibrariesForBinary or "
|
||||
"similar)";
|
||||
disable_namespaces_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Set hostname in the network namespace instead of default "sandbox2".
|
||||
//
|
||||
// Calling this function will enable use of namespaces.
|
||||
|
@ -495,6 +513,7 @@ class PolicyBuilder final {
|
|||
|
||||
Mounts mounts_;
|
||||
bool use_namespaces_ = false;
|
||||
bool disable_namespaces_ = false;
|
||||
bool allow_unrestricted_networking_ = false;
|
||||
std::string hostname_ = kDefaultHostname;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user