#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "sandbox/linux/services/namespace_sandbox.h"
#include <sched.h>
#include <signal.h>
#include <stddef.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <string>
#include <utility>
#include <vector>
#include "base/check_op.h"
#include "base/command_line.h"
#include "base/environment.h"
#include "base/files/scoped_file.h"
#include "base/posix/eintr_wrapper.h"
#include "base/process/launch.h"
#include "base/process/process.h"
#include "build/build_config.h"
#include "sandbox/linux/services/credentials.h"
#include "sandbox/linux/services/namespace_utils.h"
#include "sandbox/linux/services/syscall_wrappers.h"
#include "sandbox/linux/system_headers/linux_signal.h"
namespace sandbox {
namespace {
const char kSandboxUSERNSEnvironmentVarName[] = …;
const char kSandboxPIDNSEnvironmentVarName[] = …;
const char kSandboxNETNSEnvironmentVarName[] = …;
class WriteUidGidMapDelegate : public base::LaunchOptions::PreExecDelegate { … };
void SetEnvironForNamespaceType(base::EnvironmentMap* environ,
base::NativeEnvironmentString env_var,
bool value) { … }
int g_signal_exit_codes[64];
void TerminationSignalHandler(int sig) { … }
#if defined(LIBC_GLIBC)
struct glibc_pthread { … };
pid_t GetGlibcCachedTid() { … }
void MaybeUpdateGlibcTidCache() { … }
#endif
}
NamespaceSandbox::Options::Options()
: … { … }
NamespaceSandbox::Options::~Options() { … }
base::Process NamespaceSandbox::LaunchProcess(
const base::CommandLine& cmdline,
const base::LaunchOptions& launch_options) { … }
base::Process NamespaceSandbox::LaunchProcess(
const std::vector<std::string>& argv,
const base::LaunchOptions& launch_options) { … }
base::Process NamespaceSandbox::LaunchProcessWithOptions(
const base::CommandLine& cmdline,
const base::LaunchOptions& launch_options,
const Options& ns_sandbox_options) { … }
base::Process NamespaceSandbox::LaunchProcessWithOptions(
const std::vector<std::string>& argv,
const base::LaunchOptions& launch_options,
const Options& ns_sandbox_options) { … }
pid_t NamespaceSandbox::ForkInNewPidNamespace(bool drop_capabilities_in_child) { … }
void NamespaceSandbox::InstallDefaultTerminationSignalHandlers() { … }
bool NamespaceSandbox::InstallTerminationSignalHandler(
int sig,
int exit_code) { … }
bool NamespaceSandbox::InNewUserNamespace() { … }
bool NamespaceSandbox::InNewPidNamespace() { … }
bool NamespaceSandbox::InNewNetNamespace() { … }
}