Support passing stderrthreshold to sandboxee

PiperOrigin-RevId: 559769140
Change-Id: I57ad45e1155355e51a821d7903b2eb73dd1303ee
This commit is contained in:
Christian Blichmann 2023-08-24 08:57:49 -07:00 committed by Copybara-Service
parent 3adc232a07
commit d5ff466c59
4 changed files with 17 additions and 9 deletions

View File

@ -117,6 +117,8 @@ function(add_sapi_library)
target_link_libraries("${_sapi_bin}" PRIVATE target_link_libraries("${_sapi_bin}" PRIVATE
-fuse-ld=gold -fuse-ld=gold
-Wl,--whole-archive "${_sapi_LIBRARY}" -Wl,--no-whole-archive -Wl,--whole-archive "${_sapi_LIBRARY}" -Wl,--no-whole-archive
# Needs to be whole-archive due to how it Abseil registers flags
-Wl,--whole-archive absl::log_flags -Wl,--no-whole-archive
sapi::client sapi::client
${CMAKE_DL_LIBS} ${CMAKE_DL_LIBS}
) )

View File

@ -83,11 +83,14 @@ cc_library(
"//sandboxed_api/util:raw_logging", "//sandboxed_api/util:raw_logging",
"//sandboxed_api/util:runfiles", "//sandboxed_api/util:runfiles",
"//sandboxed_api/util:status", "//sandboxed_api/util:status",
"@com_google_absl//absl/base",
"@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/base:dynamic_annotations", "@com_google_absl//absl/base:dynamic_annotations",
"@com_google_absl//absl/base:log_severity",
"@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/log", "@com_google_absl//absl/log",
"@com_google_absl//absl/log:check", "@com_google_absl//absl/log:check",
"@com_google_absl//absl/log:globals",
"@com_google_absl//absl/status", "@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor", "@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings", "@com_google_absl//absl/strings",
@ -185,6 +188,7 @@ cc_library(
"@com_google_absl//absl/flags:parse", "@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/log", "@com_google_absl//absl/log",
"@com_google_absl//absl/log:check", "@com_google_absl//absl/log:check",
"@com_google_absl//absl/log:flags",
"@com_google_absl//absl/log:initialize", "@com_google_absl//absl/log:initialize",
"@com_google_absl//absl/status:statusor", "@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings", "@com_google_absl//absl/strings",

View File

@ -52,8 +52,7 @@ add_library(sapi_embed_file ${SAPI_LIB_TYPE}
) )
add_library(sapi::embed_file ALIAS sapi_embed_file) add_library(sapi::embed_file ALIAS sapi_embed_file)
target_link_libraries(sapi_embed_file target_link_libraries(sapi_embed_file
PRIVATE absl::core_headers PRIVATE absl::strings
absl::strings
sandbox2::util sandbox2::util
sapi::base sapi::base
sapi::fileops sapi::fileops
@ -71,8 +70,11 @@ add_library(sapi_sapi ${SAPI_LIB_TYPE}
) )
add_library(sapi::sapi ALIAS sapi_sapi) add_library(sapi::sapi ALIAS sapi_sapi)
target_link_libraries(sapi_sapi target_link_libraries(sapi_sapi
PRIVATE absl::dynamic_annotations PRIVATE absl::base
absl::dynamic_annotations
absl::flat_hash_map absl::flat_hash_map
absl::log
absl::log_globals
absl::status absl::status
absl::statusor absl::statusor
absl::str_format absl::str_format
@ -100,6 +102,7 @@ add_library(sapi_call ${SAPI_LIB_TYPE}
) )
add_library(sapi::call ALIAS sapi_call) add_library(sapi::call ALIAS sapi_call)
target_link_libraries(sapi_call PRIVATE target_link_libraries(sapi_call PRIVATE
absl::core_headers
sapi::var_type sapi::var_type
sapi::base sapi::base
) )
@ -172,8 +175,8 @@ target_link_libraries(sapi_client
absl::dynamic_annotations absl::dynamic_annotations
absl::flags_parse absl::flags_parse
absl::log absl::log
absl::log_flags
absl::log_initialize absl::log_initialize
absl::statusor
absl::strings absl::strings
libffi::libffi libffi::libffi
sandbox2::comms sandbox2::comms
@ -210,7 +213,6 @@ if(BUILD_TESTING AND SAPI_BUILD_TESTING AND NOT CMAKE_CROSSCOMPILING)
target_link_libraries(sapi_test PRIVATE target_link_libraries(sapi_test PRIVATE
absl::status absl::status
absl::statusor absl::statusor
absl::time
benchmark benchmark
sandbox2::result sandbox2::result
sapi::proto_arg_proto sapi::proto_arg_proto

View File

@ -19,12 +19,11 @@
#include <initializer_list> #include <initializer_list>
#include <memory> #include <memory>
#include <string> #include <string>
#include <utility>
#include <vector> #include <vector>
#include "sandboxed_api/file_toc.h" #include "sandboxed_api/file_toc.h"
#include "absl/base/attributes.h"
#include "absl/base/macros.h" #include "absl/base/macros.h"
#include "absl/log/globals.h"
#include "absl/log/log.h" #include "absl/log/log.h"
#include "absl/status/status.h" #include "absl/status/status.h"
#include "absl/status/statusor.h" #include "absl/status/statusor.h"
@ -119,13 +118,14 @@ class Sandbox {
// Gets extra arguments to be passed to the sandboxee. // Gets extra arguments to be passed to the sandboxee.
virtual void GetArgs(std::vector<std::string>* args) const { virtual void GetArgs(std::vector<std::string>* args) const {
// Do nothing by default. args->push_back(absl::StrCat("--stderrthreshold=",
static_cast<int>(absl::StderrThreshold())));
} }
private: private:
// Gets the environment variables passed to the sandboxee. // Gets the environment variables passed to the sandboxee.
virtual void GetEnvs(std::vector<std::string>* envs) const { virtual void GetEnvs(std::vector<std::string>* envs) const {
envs->push_back("GOOGLE_STDERRTHRESHOLD=INFO"); // Do nothing by default.
} }
// Returns the sandbox policy. Subclasses can modify the default policy // Returns the sandbox policy. Subclasses can modify the default policy