From a420682099cdbad245c155daea328a7c2658bc18 Mon Sep 17 00:00:00 2001 From: Christian Blichmann Date: Wed, 27 Apr 2022 06:00:05 -0700 Subject: [PATCH] Use an env var instead of `-logtostderr` This should make it easier to migrate away from gflags. PiperOrigin-RevId: 444834240 Change-Id: If9717131b7a803a8459992b68933491a0945182e --- sandboxed_api/sandbox.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sandboxed_api/sandbox.h b/sandboxed_api/sandbox.h index 7c3b8fc..61b5a4b 100644 --- a/sandboxed_api/sandbox.h +++ b/sandboxed_api/sandbox.h @@ -114,12 +114,17 @@ class Sandbox { protected: - // Gets the arguments passed to the sandboxee. + // Gets extra arguments to be passed to the sandboxee. virtual void GetArgs(std::vector* args) const { - args->push_back("--logtostderr=true"); + // Do nothing by default. } private: + // Gets the environment variables passed to the sandboxee. + virtual void GetEnvs(std::vector* envs) const { + envs->push_back("GOOGLE_LOGTOSTDERR=1"); + } + // Returns the sandbox policy. Subclasses can modify the default policy // builder, or return a completely new policy. virtual std::unique_ptr ModifyPolicy( @@ -131,11 +136,10 @@ class Sandbox { // - absolute: will be used as is. virtual std::string GetLibPath() const { return ""; } - // Gets the environment variables passed to the sandboxee. - virtual void GetEnvs(std::vector* envs) const {} - // Modifies the Executor object if needed. - virtual void ModifyExecutor(sandbox2::Executor* executor) {} + virtual void ModifyExecutor(sandbox2::Executor* executor) { + // Do nothing by default. + } // Provides a custom notifier for sandboxee events. May return nullptr. virtual std::unique_ptr CreateNotifier() { return nullptr; }