Use Abseil's log/flags instead of glog/gflags

Follow-up changes might be required to fully fix up the contrib sandboxes.

PiperOrigin-RevId: 482475998
Change-Id: Iff631eb838a024b2f047a1be61bb27e35a8ff2f4
This commit is contained in:
Christian Blichmann 2022-10-20 06:48:06 -07:00 committed by Copybara-Service
parent 7dca070083
commit 4c87556901
152 changed files with 725 additions and 765 deletions

View File

@ -79,21 +79,6 @@ if(SAPI_DOWNLOAD_LIBUNWIND)
endif()
sapi_check_target(unwind_ptrace_wrapped)
if(SAPI_DOWNLOAD_GFLAGS)
include(cmake/gflags.cmake)
sapi_check_target(gflags)
else()
find_package(gflags REQUIRED)
endif()
if(SAPI_DOWNLOAD_GLOG)
include(cmake/glog.cmake)
endif()
sapi_check_target(glog::glog)
# TODO(cblichmann): Check if this is needed/works with system lib
add_dependencies(glog gflags::gflags)
if(SAPI_DOWNLOAD_PROTOBUF)
include(cmake/protobuf.cmake)
endif()

View File

@ -30,8 +30,6 @@ endif()
option(SAPI_DOWNLOAD_ABSL "Download Abseil at config time" ON)
option(SAPI_DOWNLOAD_GOOGLETEST "Download googletest at config time" ON)
option(SAPI_DOWNLOAD_BENCHMARK "Download benchmark at config time" ON)
option(SAPI_DOWNLOAD_GFLAGS "Download gflags at config time" ON)
option(SAPI_DOWNLOAD_GLOG "Download glog at config time" ON)
option(SAPI_DOWNLOAD_PROTOBUF "Download protobuf at config time" ON)
option(SAPI_DOWNLOAD_LIBUNWIND "Download libunwind at config time" ON)
option(SAPI_DOWNLOAD_LIBCAP "Download libcap at config time" ON)

View File

@ -1,25 +0,0 @@
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FetchContent_Declare(gflags
GIT_REPOSITORY https://github.com/gflags/gflags.git
GIT_TAG addd749114fab4f24b7ea1e0f2f837584389e52c # 2020-03-18
)
set(GFLAGS_IS_SUBPROJECT TRUE)
set(GFLAGS_BUILD_SHARED_LIBS ${SAPI_ENABLE_SHARED_LIBS})
set(GFLAGS_INSTALL_SHARED_LIBS ${SAPI_ENABLE_SHARED_LIBS})
set(GFLAGS_INSTALL_HEADERS OFF)
set(GFLAGS_BUILD_TESTING FALSE)
FetchContent_MakeAvailable(gflags)

View File

@ -1,43 +0,0 @@
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FetchContent_Declare(glog
GIT_REPOSITORY https://github.com/google/glog.git
GIT_TAG 3ba8976592274bc1f907c402ce22558011d6fc5e # 2020-02-16
)
# Force gflags from subdirectory
set(WITH_GFLAGS FALSE CACHE BOOL "" FORCE)
set(HAVE_LIB_GFLAGS TRUE CACHE STRING "" FORCE)
set(WITH_UNWIND FALSE CACHE BOOL "" FORCE)
set(UNWIND_LIBRARY FALSE)
set(HAVE_PWD_H FALSE)
set(WITH_PKGCONFIG TRUE CACHE BOOL "" FORCE)
set(BUILD_SHARED_LIBS ${SAPI_ENABLE_SHARED_LIBS})
FetchContent_MakeAvailable(glog)
target_include_directories(glog PUBLIC
$<BUILD_INTERFACE:${gflags_BINARY_DIR}/include>
$<BUILD_INTERFACE:${gflags_BINARY_DIR}>
)
add_library(gflags_nothreads STATIC IMPORTED)
set_target_properties(gflags_nothreads PROPERTIES
IMPORTED_LOCATION "${gflags_BINARY_DIR}/libgflags_nothreads.a"
)
target_link_libraries(glog PRIVATE
#-Wl,--whole-archive gflags_nothreads -Wl,--no-whole-archive
gflags_nothreads
)

View File

@ -18,9 +18,11 @@ add_executable(sapi_minibrotli
../utils/utils_brotli_enc.cc
../utils/utils_brotli_dec.cc
)
target_link_libraries(sapi_minibrotli
PRIVATE absl::flags_parse
sapi_contrib::brotli
sapi::logging
sapi::sapi
target_link_libraries(sapi_minibrotli PRIVATE
absl::flags
absl::flags_parse
absl::log_globals
absl::log_initialize
sapi_contrib::brotli
sapi::sapi
)

View File

@ -17,11 +17,12 @@
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "contrib/brotli/sandboxed.h"
#include "contrib/brotli/utils/utils_brotli.h"
#include "contrib/brotli/utils/utils_brotli_dec.h"
#include "contrib/brotli/utils/utils_brotli_enc.h"
#include "sandboxed_api/util/logging.h"
ABSL_FLAG(bool, decompress, false, "decompress");
@ -62,8 +63,9 @@ absl::Status DecompressInMemory(BrotliSandbox& sandbox,
int main(int argc, char* argv[]) {
std::string prog_name(argv[0]);
sapi::InitLogging(argv[0]);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
absl::InitializeLog();
if (args.size() != 3) {
std::cerr << "Usage:\n " << prog_name << " INPUT OUTPUT\n";

View File

@ -21,9 +21,11 @@ target_include_directories(sapi_miniblosc INTERFACE
"${SAPI_SOURCE_DIR}"
)
target_link_libraries(sapi_miniblosc
PRIVATE sapi_contrib::blosc
absl::flags_parse
sapi::logging
sapi::sapi
target_link_libraries(sapi_miniblosc PRIVATE
absl::flags
absl::flags_parse
absl::log_globals
absl::log_initialize
sapi_contrib::blosc
sapi::sapi
)

View File

@ -12,17 +12,18 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <absl/flags/flag.h>
#include <absl/flags/parse.h>
#include <unistd.h>
#include <fstream>
#include <iostream>
#include <string>
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "contrib/c-blosc/sandboxed.h"
#include "contrib/c-blosc/utils/utils_blosc.h"
#include "sandboxed_api/util/logging.h"
ABSL_FLAG(bool, decompress, false, "decompress");
ABSL_FLAG(int, clevel, 5, "compression level");
@ -53,8 +54,9 @@ absl::Status Stream(CbloscApi& api, std::string& infile_s,
int main(int argc, char* argv[]) {
std::string prog_name(argv[0]);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
sapi::InitLogging(argv[0]);
absl::InitializeLog();
if (args.size() != 3) {
std::cerr << "Usage:\n " << prog_name << " INPUT OUTPUT\n";

View File

@ -16,8 +16,11 @@ add_executable(sapi_minihunspell
main.cc
)
target_link_libraries(sapi_minihunspell
PRIVATE sapi_contrib::hunspell
sapi::logging
sapi::sapi
target_link_libraries(sapi_minihunspell PRIVATE
absl::flags
absl::flags_parse
absl::log_globals
absl::log_initialize
sapi_contrib::hunspell
sapi::sapi
)

View File

@ -18,8 +18,10 @@
#include <iostream>
#include <string>
#include "absl/flags/parse.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "contrib/hunspell/sandboxed.h"
#include "sandboxed_api/util/logging.h"
absl::Status PrintSuggest(HunspellApi& api, sapi::v::RemotePtr& hunspellrp,
sapi::v::ConstCStr& word) {
@ -53,7 +55,9 @@ absl::Status PrintSuggest(HunspellApi& api, sapi::v::RemotePtr& hunspellrp,
}
int main(int argc, char* argv[]) {
sapi::InitLogging(argv[0]);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
absl::ParseCommandLine(argc, argv);
absl::InitializeLog();
if (argc != 4) {
std::cerr << "Usage:\n " << argv[0];

View File

@ -17,12 +17,17 @@ foreach(target IN ITEMS base multiple_files yaml_stream formatter)
jsonnet_${target}_example.cc
)
target_link_libraries(jsonnet_${target}_sandboxed PRIVATE
absl::check
absl::flags
absl::flags_parse
absl::log
absl::log_globals
absl::log_initialize
libjsonnet
sapi_contrib::jsonnet_helper
sapi_contrib::jsonnet
sapi::file_base
sapi::fileops
sapi::logging
sapi::sapi
)
endforeach()
@ -30,11 +35,15 @@ endforeach()
add_executable(jsonnet_base_transacted
jsonnet_base_transaction.cc
)
target_link_libraries(jsonnet_base_transacted PRIVATE
absl::check
absl::flags
absl::flags_parse
absl::log
absl::log_globals
absl::log_initialize
libjsonnet
sapi_contrib::jsonnet_helper
sapi_contrib::jsonnet
sapi::logging
sapi::sapi
)

View File

@ -15,9 +15,12 @@
#include <cstdlib>
#include <iostream>
#include "absl/flags/parse.h"
#include "absl/log/check.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "contrib/jsonnet/jsonnet_base_sandbox.h"
#include "sandboxed_api/util/fileops.h"
#include "sandboxed_api/util/logging.h"
#include "sandboxed_api/util/path.h"
absl::Status JsonnetMain(std::string in_file, std::string out_file) {
@ -73,10 +76,11 @@ absl::Status JsonnetMain(std::string in_file, std::string out_file) {
int main(int argc, char* argv[]) {
using sapi::file_util::fileops::Basename;
sapi::InitLogging(argv[0]);
gflags::ParseCommandLineFlags(&argc, &argv, true);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
absl::ParseCommandLine(argc, argv);
absl::InitializeLog();
if (!(argc == 3)) {
if (argc != 3) {
std::cerr << "Usage:\n"
<< Basename(argv[0])
<< " /absolute/path/to/INPUT.jsonnet /absolute/path/to/OUTPUT\n";

View File

@ -14,8 +14,11 @@
#include "contrib/jsonnet/jsonnet_base_transaction.h"
#include "absl/flags/parse.h"
#include "absl/log/check.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "sandboxed_api/util/fileops.h"
#include "sandboxed_api/util/logging.h"
#include "sandboxed_api/util/path.h"
absl::Status JsonnetTransaction::Main() {
@ -65,10 +68,11 @@ absl::Status JsonnetTransaction::Main() {
int main(int argc, char* argv[]) {
using sapi::file_util::fileops::Basename;
sapi::InitLogging(argv[0]);
gflags::ParseCommandLineFlags(&argc, &argv, true);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
absl::ParseCommandLine(argc, argv);
absl::InitializeLog();
if (!(argc == 3)) {
if (argc != 3) {
std::cerr << "Usage:\n"
<< Basename(argv[0])
<< " /absolute/path/to/INPUT.jsonnet /absolute/path/to/OUTPUT\n";

View File

@ -19,8 +19,11 @@
#include <iostream>
#include "jsonnet_sapi.sapi.h" // NOLINT(build/include)
#include "absl/flags/parse.h"
#include "absl/log/check.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "sandboxed_api/util/fileops.h"
#include "sandboxed_api/util/logging.h"
#include "sandboxed_api/util/path.h"
class JsonnetSapiSandbox : public JsonnetSandbox {
@ -105,10 +108,11 @@ absl::Status JsonnetMain(std::string in_file, std::string out_file) {
int main(int argc, char* argv[]) {
using sapi::file_util::fileops::Basename;
sapi::InitLogging(argv[0]);
gflags::ParseCommandLineFlags(&argc, &argv, true);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
absl::ParseCommandLine(argc, argv);
absl::InitializeLog();
if (!(argc == 3)) {
if (argc != 3) {
std::cerr << "Usage:\n"
<< Basename(argv[0])
<< " /absolute/path/to/INPUT.jsonnet /absolute/path/to/OUTPUT\n";

View File

@ -19,8 +19,11 @@
#include <iostream>
#include "jsonnet_sapi.sapi.h" // NOLINT(build/include)
#include "absl/flags/parse.h"
#include "absl/log/check.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "sandboxed_api/util/fileops.h"
#include "sandboxed_api/util/logging.h"
#include "sandboxed_api/util/path.h"
class JsonnetSapiSandbox : public JsonnetSandbox {
@ -108,10 +111,11 @@ absl::Status JsonnetMain(std::string in_file, std::string out_file) {
int main(int argc, char* argv[]) {
using sapi::file_util::fileops::Basename;
sapi::InitLogging(argv[0]);
gflags::ParseCommandLineFlags(&argc, &argv, true);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
absl::ParseCommandLine(argc, argv);
absl::InitializeLog();
if (!(argc == 3)) {
if (argc != 3) {
std::cerr << "Usage:\n"
<< Basename(argv[0])
<< " /absolute/path/to/INPUT.jsonnet /absolute/path/to/OUTPUT\n";

View File

@ -15,9 +15,12 @@
#include <cstdlib>
#include <iostream>
#include "absl/flags/parse.h"
#include "absl/log/check.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "contrib/jsonnet/jsonnet_base_sandbox.h"
#include "sandboxed_api/util/fileops.h"
#include "sandboxed_api/util/logging.h"
#include "sandboxed_api/util/path.h"
absl::Status JsonnetMain(std::string in_file, std::string out_file) {
@ -73,10 +76,11 @@ absl::Status JsonnetMain(std::string in_file, std::string out_file) {
int main(int argc, char* argv[]) {
using sapi::file_util::fileops::Basename;
sapi::InitLogging(argv[0]);
gflags::ParseCommandLineFlags(&argc, &argv, true);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
absl::ParseCommandLine(argc, argv);
absl::InitializeLog();
if (!(argc == 3)) {
if (argc == 3) {
std::cerr << "Usage:\n"
<< Basename(argv[0])
<< " /absolute/path/to/INPUT.jsonnet /absolute/path/to/OUTPUT\n";

View File

@ -20,7 +20,7 @@
#include <fstream>
#include <iostream>
#include <glog/logging.h>
#include "absl/log/log.h"
#include "sandboxed_api/util/fileops.h"
static constexpr std::size_t kMaxDomainNameLength = 256;

View File

@ -16,9 +16,12 @@ add_executable(sapi_minilibraw
main.cc
../utils/utils_libraw.cc
)
target_link_libraries(sapi_minilibraw
PRIVATE absl::strings
sapi_contrib::libraw
sapi::logging
sapi::sapi
target_link_libraries(sapi_minilibraw PRIVATE
absl::flags
absl::flags_parse
absl::log_globals
absl::log_initialize
absl::strings
sapi_contrib::libraw
sapi::sapi
)

View File

@ -17,10 +17,12 @@
#include <iostream>
#include <vector>
#include "absl/flags/parse.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "absl/status/statusor.h"
#include "contrib/libraw/sandboxed.h"
#include "contrib/libraw/utils/utils_libraw.h"
#include "sandboxed_api/util/logging.h"
void PrintUsage(const char* name) {
std::cout << "Dump (small) selecton of RAW file as tab-separated text file\n"
@ -38,7 +40,10 @@ uint16_t SubtractBlack(uint16_t val, unsigned int bl) {
}
int main(int argc, char* argv[]) {
sapi::InitLogging(argv[0]);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
absl::ParseCommandLine(argc, argv);
absl::InitializeLog();
if (argc < 4) {
PrintUsage(argv[0]);
return EXIT_FAILURE;

View File

@ -18,7 +18,11 @@ add_executable(sandboxed
)
target_link_libraries(sandboxed PRIVATE
tiff_sapi
absl::flags
absl::flags_parse
absl::log_globals
absl::log_initialize
sapi::sapi
sapi_contrib::libtiff
sapi::temp_file
)

View File

@ -19,6 +19,9 @@
#include <vector>
#include "../sandboxed.h" // NOLINT(build/include)
#include "absl/flags/parse.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "sandboxed_api/util/fileops.h"
#include "sandboxed_api/util/path.h"
#include "sandboxed_api/vars.h"
@ -135,7 +138,9 @@ std::string GetFilePath(const std::string filename) {
} // namespace
int main(int argc, char* argv[]) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
absl::ParseCommandLine(argc, argv);
absl::InitializeLog();
std::string srcfile;
// "test/images/quad-tile.jpg.tiff"

View File

@ -17,9 +17,11 @@ add_executable(sapi_minixls
../utils/utils_libxls.cc
)
target_link_libraries(sapi_minixls
PRIVATE sapi_libxls
absl::flags_parse
sapi::logging
sapi::sapi
target_link_libraries(sapi_minixls PRIVATE
absl::flags
absl::flags_parse
absl::log_globals
absl::log_initialize
sapi_contrib::libxls
sapi::sapi
)

View File

@ -23,16 +23,18 @@
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "contrib/libxls/sandboxed.h"
#include "contrib/libxls/utils/utils_libxls.h"
#include "sandboxed_api/util/logging.h"
ABSL_FLAG(uint32_t, sheet, 0, "sheet number");
int main(int argc, char* argv[]) {
std::string prog_name(argv[0]);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
sapi::InitLogging(argv[0]);
absl::InitializeLog();
if (args.size() != 2) {
std::cerr << "Usage:\n " << prog_name << " INPUT\n";

View File

@ -16,8 +16,10 @@ add_executable(sapi_minizip
main.cc
)
target_link_libraries(sapi_minizip PRIVATE
sapi_contrib::libzip
sapi::logging
sapi::sapi
absl::flags
absl::flags_parse
absl::log_globals
absl::log_initialize
sapi_contrib::libzip
sapi::sapi
)

View File

@ -23,9 +23,10 @@
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "contrib/libzip/sandboxed.h"
#include "contrib/libzip/utils/utils_zip.h"
#include "sandboxed_api/util/logging.h"
ABSL_FLAG(bool, list, false, "list files");
ABSL_FLAG(std::string, unzip, "", "unzip");
@ -84,8 +85,9 @@ absl::Status DeleteFile(LibZip& zip, const std::string& filename) {
int main(int argc, char* argv[]) {
std::string prog_name(argv[0]);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
sapi::InitLogging(argv[0]);
absl::InitializeLog();
if (args.size() < 2 || args.size() > 3) {
std::cerr << "Usage:\n " << prog_name << " ZIPFILE [OUTFILE]\n";

View File

@ -20,7 +20,6 @@ if(SAPI_BUILD_EXAMPLES)
)
target_link_libraries(lodepng_unsandboxed PRIVATE
lodepng
sapi::logging
sapi::sapi
sapi::temp_file
sapi::file_base
@ -35,7 +34,6 @@ if(SAPI_BUILD_EXAMPLES)
)
target_link_libraries(lodepng_sandboxed PRIVATE
sapi_contrib::lodepng
sapi::logging
sapi::sapi
sapi::temp_file
sapi::fileops
@ -53,8 +51,6 @@ if(BUILD_TESTING AND SAPI_BUILD_TESTING)
sapi_contrib::lodepng
absl::strings
absl::time
sapi::flags
sapi::logging
sapi::sapi
sapi::temp_file
sapi::fileops

View File

@ -18,7 +18,7 @@
#include <cstddef>
#include <cstdint>
#include <glog/logging.h>
#include "absl/log/log.h"
#include "sandboxed_api/util/fileops.h"
#include "sandboxed_api/util/temp_file.h"

View File

@ -12,12 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <cstdint>
#include <iostream>
#include <vector>
#include "helpers.h" // NOLINT(build/include)
#include "sandbox.h" // NOLINT(build/include)
#include "absl/flags/parse.h"
#include "absl/log/check.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "absl/status/statusor.h"
#include "sandboxed_api/util/logging.h"
void EncodeDecodeOneStep(SapiLodepngSandbox& sandbox, LodepngApi& api) {
// Generate the values.
@ -172,7 +177,9 @@ void EncodeDecodeTwoSteps(SapiLodepngSandbox& sandbox, LodepngApi& api) {
}
int main(int argc, char* argv[]) {
sapi::InitLogging(argv[0]);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
absl::ParseCommandLine(argc, argv);
absl::InitializeLog();
const std::string images_path = CreateTempDirAtCWD();
CHECK(sapi::file_util::fileops::Exists(images_path, false))

View File

@ -12,12 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <cstdint>
#include <iostream>
#include <vector>
#include "helpers.h" // NOLINT(build/include)
#include "lodepng.gen.h" // NOLINT(build/include)
#include "absl/flags/parse.h"
#include "absl/log/check.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "sandboxed_api/util/fileops.h"
#include "sandboxed_api/util/logging.h"
#include "sandboxed_api/util/path.h"
void EncodeDecodeOneStep(const std::string& images_path) {
@ -99,7 +104,9 @@ void EncodeDecodeTwoSteps(const std::string& images_path) {
}
int main(int argc, char* argv[]) {
sapi::InitLogging(argv[0]);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
absl::ParseCommandLine(argc, argv);
absl::InitializeLog();
const std::string images_path = CreateTempDirAtCWD();
CHECK(sapi::file_util::fileops::Exists(images_path, false))

View File

@ -99,10 +99,12 @@ target_include_directories(pffft_sapi INTERFACE
add_executable(pffft_sandboxed
main_pffft_sandboxed.cc
)
target_link_libraries(pffft_sandboxed
PRIVATE sapi_contrib::pffft
absl::flags
absl::flags_parse
sapi::logging
sapi::sapi
target_link_libraries(pffft_sandboxed PRIVATE
absl::flags
absl::flags_parse
absl::log
absl::log_globals
absl::log_initialize
sapi_contrib::pffft
sapi::sapi
)

View File

@ -23,7 +23,8 @@
#include "pffft_sapi.sapi.h" // NOLINT(build/include)
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "sandboxed_api/util/logging.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "sandboxed_api/vars.h"
class PffftSapiSandbox : public PffftSandbox {
@ -178,8 +179,9 @@ absl::Status PffftMain() {
}
int main(int argc, char* argv[]) {
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
absl::ParseCommandLine(argc, argv);
sapi::InitLogging(argv[0]);
absl::InitializeLog();
if (absl::Status status = PffftMain(); !status.ok()) {
LOG(ERROR) << "Initialization failed: " << status.ToString();

View File

@ -14,14 +14,15 @@
include(GoogleTest)
add_executable(turbojpeg_sapi_test turbojpeg_sapi_test.cc)
target_link_libraries(turbojpeg_sapi_test PRIVATE
turbojpeg_sapi
sapi::logging
sapi::base
gtest
gmock
add_executable(turbojpeg_sapi_test
turbojpeg_sapi_test.cc
)
gtest_discover_tests(turbojpeg_sapi_test PROPERTIES ENVIRONMENT "TEST_FILES_DIR=${PROJECT_SOURCE_DIR}/tests")
target_link_libraries(turbojpeg_sapi_test PRIVATE
sapi_contrib::turbojpeg
sapi::test_main
)
gtest_discover_tests(turbojpeg_sapi_test PROPERTIES
ENVIRONMENT "TEST_FILES_DIR=${PROJECT_SOURCE_DIR}/tests"
)

View File

@ -22,12 +22,10 @@
#include <fstream>
#include <iostream>
#include "gflags/gflags.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "sandboxed_api/testing.h"
#include "sandboxed_api/util/fileops.h"
#include "sandboxed_api/util/logging.h"
#include "sandboxed_api/util/path.h"
#include "sandboxed_api/util/status_matchers.h"
#include "turbojpeg_sapi.sapi.h" // NOLINT(build/include)
@ -173,9 +171,3 @@ TEST_F(TurboJpegSapiSandboxTest, Decompressor) {
ASSERT_THAT(decompress_result.value(), Eq(0));
}
} // namespace
int main(int argc, char* argv[]) {
::sapi::InitLogging(program_invocation_short_name);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@ -17,9 +17,11 @@ add_executable(sapi_miniuriparser
../utils/utils_uriparser.cc
)
target_link_libraries(sapi_miniuriparser
PRIVATE sapi_contrib::uriparser
sapi::logging
sapi::sapi
absl::flags_parse
target_link_libraries(sapi_miniuriparser PRIVATE
absl::flags
absl::flags_parse
absl::log_globals
absl::log_initialize
sapi_contrib::uriparser
sapi::sapi
)

View File

@ -18,9 +18,10 @@
#include <vector>
#include "absl/flags/parse.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "contrib/uriparser/sandboxed.h"
#include "contrib/uriparser/utils/utils_uriparser.h"
#include "sandboxed_api/util/logging.h"
void Print(const char* name, const absl::StatusOr<std::string>& r) {
if (!r.ok()) {
@ -38,8 +39,9 @@ void Print(const char* name, const absl::StatusOr<std::string>& r) {
int main(int argc, char* argv[]) {
std::string prog_name(argv[0]);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
sapi::InitLogging(argv[0]);
absl::InitializeLog();
if (args.size() < 2) {
std::cerr << "Usage:\n " << prog_name << " URI ...\n";

View File

@ -67,11 +67,10 @@ if(BUILD_TESTING AND SAPI_BUILD_TESTING)
woff2_sapi_test.cc
)
target_link_libraries(woff2_sapi_test PRIVATE
absl::flags
absl::flags_parse
sapi_contrib::woff2
sapi::logging
sapi::base
gtest
gmock
sapi::test_main
)
gtest_discover_tests(woff2_sapi_test PROPERTIES
ENVIRONMENT "TEST_DATA_DIR=${PROJECT_SOURCE_DIR}/testdata")

View File

@ -22,13 +22,11 @@
#include <iostream>
#include <optional>
#include "gflags/gflags.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "contrib/woff2/woff2_wrapper.h"
#include "sandboxed_api/testing.h"
#include "sandboxed_api/util/fileops.h"
#include "sandboxed_api/util/logging.h"
#include "sandboxed_api/util/path.h"
#include "sandboxed_api/util/status_matchers.h"
#include "woff2_sapi.sapi.h" // NOLINT(build/include)
@ -127,11 +125,5 @@ TEST_F(Woff2SapiSandboxTest, Decompress) {
auto ptr = sapi::v::RemotePtr{reinterpret_cast<void*>(p.GetValue())};
ASSERT_THAT(api_->WOFF2_Free(&ptr), IsOk());
}
} // namespace
int main(int argc, char* argv[]) {
if (argc < 1) return 255;
::sapi::InitLogging(argv[0]);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
} // namespace

View File

@ -16,9 +16,11 @@ add_executable(sapi_minizopfli
main.cc
../utils/utils_zopfli.cc
)
target_link_libraries(sapi_minizopfli
PRIVATE sapi_contrib::zopfli
sapi::logging
sapi::sapi
absl::flags_parse
target_link_libraries(sapi_minizopfli PRIVATE
absl::flags
absl::flags_parse
absl::log_globals
absl::log_initialize
sapi_contrib::zopfli
sapi::sapi
)

View File

@ -21,9 +21,10 @@
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "contrib/zopfli/sandboxed.h"
#include "contrib/zopfli/utils/utils_zopfli.h"
#include "sandboxed_api/util/logging.h"
ABSL_FLAG(bool, stream, false, "stream memory to sandbox");
ABSL_FLAG(bool, zlib, false, "zlib compression");
@ -60,8 +61,9 @@ absl::Status CompressMainFD(ZopfliApi& api, std::string& infile_s,
int main(int argc, char* argv[]) {
std::string prog_name(argv[0]);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
sapi::InitLogging(argv[0]);
absl::InitializeLog();
if (args.size() != 3) {
std::cerr << "Usage:\n " << prog_name << " INPUT OUTPUT\n";

View File

@ -17,9 +17,11 @@ add_executable(sapi_minizstd
../utils/utils_zstd.cc
)
target_link_libraries(sapi_minizstd
PRIVATE sapi_contrib::zstd
sapi::logging
sapi::sapi
absl::flags_parse
target_link_libraries(sapi_minizstd PRIVATE
absl::flags
absl::flags_parse
absl::log_globals
absl::log_initialize
sapi_contrib::zstd
sapi::sapi
)

View File

@ -23,9 +23,10 @@
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "contrib/zstd/sandboxed.h"
#include "contrib/zstd/utils/utils_zstd.h"
#include "sandboxed_api/util/logging.h"
ABSL_FLAG(bool, stream, false, "stream data to sandbox");
ABSL_FLAG(bool, decompress, false, "decompress");
@ -79,8 +80,9 @@ absl::Status FileDescriptor(ZstdApi& api, std::string infile_s,
int main(int argc, char* argv[]) {
std::string prog_name(argv[0]);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
std::vector<char*> args = absl::ParseCommandLine(argc, argv);
sapi::InitLogging(argv[0]);
absl::InitializeLog();
if (args.size() != 3) {
std::cerr << "Usage:\n " << prog_name << " INPUT OUTPUT\n";

View File

@ -18,7 +18,7 @@
#include "../sandbox.h" // NOLINT(build/include)
#include "curl_sapi.sapi.h" // NOLINT(build/include)
#include "gtest/gtest.h"
#include "sandboxed_api/util/flag.h"
#include "absl/flags/flag.h"
#include "absl/status/statusor.h"
#include "sandboxed_api/util/status_matchers.h"

View File

@ -18,8 +18,8 @@
#include <fstream>
#include <iostream>
#include <glog/logging.h>
#include "gdal_sapi.sapi.h" // NOLINT(build/include)
#include "absl/log/log.h"
#include "sandboxed_api/util/fileops.h"
class GdalSapiSandbox : public GDALSandbox {

View File

@ -19,7 +19,7 @@ add_library(sapi_minitar_lib STATIC
)
target_link_libraries(sapi_minitar_lib PUBLIC
glog::glog
absl::log
libarchive_sapi
sandbox2::executor
sapi::fileops

View File

@ -36,7 +36,7 @@ add_library(sapi_minitar_lib_shared SHARED
)
target_link_libraries(sapi_minitar_lib_shared PUBLIC
glog::glog
absl::log
libarchive_sapi
sandbox2::executor
sapi::fileops

View File

@ -18,7 +18,6 @@ add_executable(helloworld
target_link_libraries(helloworld
uv_a
uv_sapi
sapi::flags
sapi::sapi
)

View File

@ -18,7 +18,7 @@
#include <iostream>
#include "sandboxed_api/util/flag.h"
#include "absl/flags/flag.h"
#include "uv_sapi.sapi.h" // NOLINT(build/include)
namespace {

View File

@ -18,7 +18,8 @@
#include <iostream>
#include "sandboxed_api/util/flag.h"
#include "absl/flags/flag.h"
#include "absl/log/initialize.h"
#include "uv_sapi.sapi.h" // NOLINT(build/include)
namespace {
@ -102,8 +103,8 @@ absl::Status IdleBasic() {
} // namespace
int main(int argc, char* argv[]) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
sapi::InitLogging(argv[0]);
absl::ParseCommandLine(argc, argv);
absl::InitializeLog();
if (absl::Status status = IdleBasic(); !status.ok()) {
LOG(ERROR) << "IdleBasic failed: " << status.ToString();

View File

@ -18,7 +18,7 @@
#include <iostream>
#include "sandboxed_api/util/flag.h"
#include "absl/flags/flag.h"
#include "uv_sapi.sapi.h" // NOLINT(build/include)
namespace {

View File

@ -17,7 +17,7 @@
#include <uv.h>
#include "gtest/gtest.h"
#include "sandboxed_api/util/flag.h"
#include "absl/flags/flag.h"
#include "sandboxed_api/util/status_matchers.h"
#include "uv_sapi.sapi.h" // NOLINT(build/include)

View File

@ -17,7 +17,7 @@
#include <uv.h>
#include "gtest/gtest.h"
#include "sandboxed_api/util/flag.h"
#include "absl/flags/flag.h"
#include "sandboxed_api/util/status_matchers.h"
#include "uv_sapi.sapi.h" // NOLINT(build/include)

View File

@ -16,7 +16,7 @@
#include <uv.h>
#include "gtest/gtest.h"
#include "sandboxed_api/util/flag.h"
#include "absl/flags/flag.h"
#include "sandboxed_api/util/status_matchers.h"
#include "uv_sapi.sapi.h" // NOLINT(build/include)

View File

@ -17,7 +17,7 @@
#include <uv.h>
#include "gtest/gtest.h"
#include "sandboxed_api/util/flag.h"
#include "absl/flags/flag.h"
#include "sandboxed_api/util/status_matchers.h"
#include "uv_sapi.sapi.h" // NOLINT(build/include)

View File

@ -17,7 +17,7 @@
#include <uv.h>
#include "gtest/gtest.h"
#include "sandboxed_api/util/flag.h"
#include "absl/flags/flag.h"
#include "sandboxed_api/util/status_matchers.h"
#include "uv_sapi.sapi.h" // NOLINT(build/include)

View File

@ -49,10 +49,8 @@ cc_library(
"//sandboxed_api/util:raw_logging",
"//sandboxed_api/util:strerror",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/status",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/synchronization",
"@com_google_glog//:glog",
],
)
@ -82,19 +80,20 @@ cc_library(
"//sandboxed_api/sandbox2/util:bpf_helper",
"//sandboxed_api/util:file_base",
"//sandboxed_api/util:fileops",
"//sandboxed_api/util:raw_logging",
"//sandboxed_api/util:runfiles",
"//sandboxed_api/util:status",
"@com_google_absl//absl/base",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/base:dynamic_annotations",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/log",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/synchronization",
"@com_google_absl//absl/time",
"@com_google_glog//:glog",
],
)
@ -154,15 +153,17 @@ cc_library(
":proto_arg_cc_proto",
":var_type",
"//sandboxed_api/sandbox2:comms",
"//sandboxed_api/util:raw_logging",
"//sandboxed_api/util:status",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/synchronization",
"@com_google_absl//absl/utility",
"@com_google_glog//:glog",
],
)
@ -174,7 +175,6 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
":call",
":config",
":lenval_core",
":proto_arg_cc_proto",
":vars",
@ -182,11 +182,13 @@ cc_library(
"//sandboxed_api/sandbox2:comms",
"//sandboxed_api/sandbox2:forkingclient",
"//sandboxed_api/sandbox2:logsink",
"//sandboxed_api/util:flags",
"//sandboxed_api/util:logging",
"//sandboxed_api/util:raw_logging",
"@com_google_absl//absl/base:dynamic_annotations",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/log:initialize",
"@com_google_absl//absl/strings",
"@com_google_glog//:glog",
"@com_google_protobuf//:protobuf",
"@org_sourceware_libffi//:libffi",
],

View File

@ -63,7 +63,7 @@ target_link_libraries(sapi_embed_file
sapi::base
sapi::raw_logging
sapi::status
PUBLIC glog::glog
PUBLIC absl::log
)
# sandboxed_api:sapi
@ -162,7 +162,7 @@ target_link_libraries(sapi_vars
sapi::proto_arg_proto
sapi::status
sapi::var_type
PUBLIC glog::glog
PUBLIC absl::log
)
# sandboxed_api:client
@ -173,6 +173,8 @@ add_library(sapi::client ALIAS sapi_client)
target_link_libraries(sapi_client
PRIVATE absl::core_headers
absl::dynamic_annotations
absl::flags_parse
absl::log_initialize
absl::strings
libffi::libffi
sandbox2::client
@ -181,13 +183,12 @@ target_link_libraries(sapi_client
sandbox2::logsink
sapi::base
sapi::call
sapi::flags
sapi::lenval_core
sapi::logging
sapi::proto_arg_proto
sapi::vars
${CMAKE_DL_LIBS}
PUBLIC glog::glog
PUBLIC absl::check
absl::log
)
if(BUILD_TESTING AND SAPI_BUILD_TESTING AND NOT CMAKE_CROSSCOMPILING)

View File

@ -22,24 +22,24 @@
#include <list>
#include <vector>
#include <glog/logging.h>
#include "google/protobuf/descriptor.h"
#include "google/protobuf/message.h"
#include "absl/base/dynamic_annotations.h"
#include "sandboxed_api/util/flag.h"
#include "absl/flags/parse.h"
#include "absl/log/check.h"
#include "absl/log/initialize.h"
#include "absl/log/log.h"
#include "absl/strings/str_cat.h"
#include "sandboxed_api/call.h"
#include "sandboxed_api/config.h"
#include "sandboxed_api/lenval_core.h"
#include "sandboxed_api/proto_arg.pb.h"
#include "sandboxed_api/proto_helper.h"
#include "sandboxed_api/sandbox2/comms.h"
#include "sandboxed_api/sandbox2/forkingclient.h"
#include "sandboxed_api/sandbox2/logsink.h"
#include "sandboxed_api/util/logging.h"
#include "sandboxed_api/vars.h"
#include "sandboxed_api/util/raw_logging.h"
#include <ffi.h>
#include <ffitarget.h>
namespace sapi {
namespace {
@ -56,13 +56,14 @@ ffi_type* GetFFIType(size_t size, v::Type type) {
case v::Type::kFloat:
if (size == sizeof(float)) {
return &ffi_type_float;
} else if (size == sizeof(double)) {
return &ffi_type_double;
} else if (size == sizeof(long double)) {
return &ffi_type_longdouble;
} else {
LOG(FATAL) << "Unknown floating-point size: " << size;
}
if (size == sizeof(double)) {
return &ffi_type_double;
}
if (size == sizeof(long double)) {
return &ffi_type_longdouble;
}
LOG(FATAL) << "Unsupported floating-point size: " << size;
case v::Type::kInt:
switch (size) {
case 1:
@ -74,7 +75,7 @@ ffi_type* GetFFIType(size_t size, v::Type type) {
case 8:
return &ffi_type_uint64;
default:
LOG(FATAL) << "Unknown integral size: " << size;
LOG(FATAL) << "Unsupported integral size: " << size;
}
case v::Type::kStruct:
LOG(FATAL) << "Structs are not supported as function arguments";
@ -416,15 +417,15 @@ void ServeRequest(sandbox2::Comms* comms) {
} // namespace sapi
ABSL_ATTRIBUTE_WEAK int main(int argc, char* argv[]) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
sapi::InitLogging(argv[0]);
absl::ParseCommandLine(argc, argv);
absl::InitializeLog();
// Note regarding the FD usage here: Parent and child seem to make use of the
// same FD, although this is not true. During process setup `dup2()` will be
// called to replace the FD `kSandbox2ClientCommsFD`.
// We do not use a new comms object here as the destructor would close our FD.
sandbox2::Comms comms{sandbox2::Comms::kDefaultConnection};
sandbox2::ForkingClient s2client{&comms};
sandbox2::Comms comms(sandbox2::Comms::kDefaultConnection);
sandbox2::ForkingClient s2client(&comms);
// Forkserver loop.
while (true) {

View File

@ -20,9 +20,6 @@
#include <sys/types.h>
#include <unistd.h>
#include <glog/logging.h>
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
#include "sandboxed_api/sandbox2/util.h"
#include "sandboxed_api/util/fileops.h"

View File

@ -74,9 +74,9 @@ cc_test(
":stringop_params_cc_proto",
"//sandboxed_api:sapi",
"//sandboxed_api:vars",
"//sandboxed_api/util:flags",
"//sandboxed_api/util:status",
"//sandboxed_api/util:status_matchers",
"@com_google_absl//absl/log",
"@com_google_absl//absl/status",
"@com_google_absl//absl/time",
"@com_google_googletest//:gtest_main",

View File

@ -74,8 +74,7 @@ if(SAPI_BUILD_TESTING)
target_link_libraries(sapi_main_stringop PRIVATE
absl::strings
absl::time
glog::glog
sapi::flags
absl::log
sapi::sapi
sapi::status
sapi::stringop_sapi

View File

@ -18,10 +18,9 @@
#include <memory>
#include <glog/logging.h>
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "sandboxed_api/util/flag.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/time/time.h"
#include "sandboxed_api/examples/stringop/sandbox.h"
@ -41,7 +40,7 @@ using ::testing::StrEq;
// Tests using a simple transaction (and function pointers):
TEST(StringopTest, ProtobufStringDuplication) {
sapi::BasicTransaction st(std::make_unique<StringopSapiSandbox>());
sapi::BasicTransaction st(absl::make_unique<StringopSapiSandbox>());
EXPECT_THAT(st.Run([](sapi::Sandbox* sandbox) -> absl::Status {
StringopApi api(sandbox);
stringop::StringDuplication proto;

View File

@ -35,7 +35,7 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
":sum_params_cc_proto",
"@com_google_glog//:glog",
"@com_google_absl//absl/log",
],
alwayslink = 1, # All functions are linked into depending binaries
)
@ -82,8 +82,13 @@ cc_binary(
":sum_params_cc_proto",
"//sandboxed_api:sapi",
"//sandboxed_api:vars",
"//sandboxed_api/util:flags",
"//sandboxed_api/util:logging",
"@com_google_absl//absl/base:log_severity",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/log:globals",
"@com_google_absl//absl/log:initialize",
"@com_google_absl//absl/status",
"@com_google_absl//absl/strings",
],

View File

@ -38,7 +38,7 @@ add_dependencies(sapi_sum
)
target_link_libraries(sapi_sum
PRIVATE $<TARGET_OBJECTS:sapi_sum_params_proto>
glog::glog
absl::log
sapi::base
PUBLIC protobuf::libprotobuf
)
@ -79,11 +79,12 @@ add_executable(sapi_main_sum
set_target_properties(sapi_main_sum PROPERTIES OUTPUT_NAME main_sum)
add_executable(sapi::main_sum ALIAS sapi_main_sum)
target_link_libraries(sapi_main_sum PRIVATE
absl::log
absl::log_initialize
absl::flags
absl::flags_parse
absl::strings
glog::glog
sapi::base
sapi::flags
sapi::logging
sapi::sapi
sapi::status
sapi::sum_sapi

View File

@ -18,15 +18,19 @@
#include <memory>
#include <glog/logging.h>
#include "sandboxed_api/util/flag.h"
#include "absl/base/log_severity.h"
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/log/check.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/strings/str_cat.h"
#include "sandboxed_api/examples/sum/sandbox.h"
#include "sandboxed_api/examples/sum/sum-sapi.sapi.h"
#include "sandboxed_api/examples/sum/sum_params.pb.h"
#include "sandboxed_api/transaction.h"
#include "sandboxed_api/util/logging.h"
#include "sandboxed_api/vars.h"
namespace {
@ -208,12 +212,13 @@ absl::Status test_addition(sapi::Sandbox* sandbox, int a, int b, int c) {
} // namespace
int main(int argc, char* argv[]) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
sapi::InitLogging(argv[0]);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
absl::ParseCommandLine(argc, argv);
absl::InitializeLog();
absl::Status status;
sapi::BasicTransaction st{std::make_unique<SumSapiSandbox>()};
sapi::BasicTransaction st(std::make_unique<SumSapiSandbox>());
// Using the simple transaction (and function pointers):
CHECK(st.Run(test_addition, 1, 1, 2).ok());
CHECK(st.Run(test_addition, 1336, 1, 1337).ok());
@ -273,10 +278,10 @@ int main(int argc, char* argv[]) {
LOG(INFO) << "Final run result for violate: " << status;
CHECK(status.code() == absl::StatusCode::kUnavailable);
SumTransaction sapi_timeout{std::make_unique<SumSapiSandbox>(),
SumTransaction sapi_timeout(std::make_unique<SumSapiSandbox>(),
/*crash=*/false,
/*violate=*/false,
/*time_out=*/true};
/*time_out=*/true);
status = sapi_timeout.Run();
LOG(INFO) << "Final run result for timeout: " << status;
CHECK(status.code() == absl::StatusCode::kUnavailable);

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <glog/logging.h>
#include "absl/log/log.h"
#include "sandboxed_api/examples/sum/sum_params.pb.h"
extern "C" int sumproto(const sumsapi::SumParamsProto* params) {

View File

@ -40,11 +40,13 @@ cc_binary(
copts = sapi_platform_copts(),
deps = [
":zlib-sapi",
":zlib-sapi_embed",
"//sandboxed_api:vars",
"//sandboxed_api/util:flags",
"//sandboxed_api/util:logging",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:globals",
"@com_google_absl//absl/log:initialize",
"@com_google_absl//absl/status:statusor",
],
)

View File

@ -33,11 +33,12 @@ add_executable(sapi_main_zlib
)
set_target_properties(sapi_main_zlib PROPERTIES OUTPUT_NAME main_zlib)
target_link_libraries(sapi_main_zlib PRIVATE
absl::status
sapi::base
glog::glog
sapi::flags
sapi::logging
absl::flags
absl::flags_parse
absl::log
absl::log_initialize
absl::status
sapi::sapi
sapi::status
sapi::zlib_sapi

View File

@ -17,12 +17,14 @@
#include <cstdlib>
#include <glog/logging.h>
#include "absl/base/macros.h"
#include "sandboxed_api/util/flag.h"
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "absl/log/log.h"
#include "absl/status/statusor.h"
#include "sandboxed_api/examples/zlib/zlib-sapi.sapi.h"
#include "sandboxed_api/util/logging.h"
#include "sandboxed_api/vars.h"
// Need to define these manually, as zlib.h cannot be directly included. The
@ -38,8 +40,9 @@
#define Z_STREAM_END 1
int main(int argc, char* argv[]) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
sapi::InitLogging(argv[0]);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
absl::ParseCommandLine(argc, argv);
absl::InitializeLog();
sapi::Sandbox sandbox(sapi::zlib::zlib_sapi_embed_create());
sapi::zlib::ZlibApi api(&sandbox);

View File

@ -14,12 +14,13 @@
#include "sandboxed_api/rpcchannel.h"
#include <glog/logging.h>
#include "absl/log/log.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
#include "absl/synchronization/mutex.h"
#include "sandboxed_api/call.h"
#include "sandboxed_api/sandbox2/comms.h"
#include "sandboxed_api/util/raw_logging.h"
#include "sandboxed_api/util/status_macros.h"
namespace sapi {

View File

@ -23,10 +23,10 @@
#include <cstdio>
#include <memory>
#include <glog/logging.h>
#include "absl/base/casts.h"
#include "absl/base/dynamic_annotations.h"
#include "absl/base/macros.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
@ -42,6 +42,7 @@
#include "sandboxed_api/sandbox2/util/bpf_helper.h"
#include "sandboxed_api/util/fileops.h"
#include "sandboxed_api/util/path.h"
#include "sandboxed_api/util/raw_logging.h"
#include "sandboxed_api/util/runfiles.h"
#include "sandboxed_api/util/status_macros.h"
@ -239,6 +240,7 @@ absl::Status Sandbox::SynchronizePtrBefore(v::Callable* ptr) {
}
// Cast is safe, since type is v::Type::kPointer
auto* p = static_cast<v::Ptr*>(ptr);
// NOLINTNEXTLINE(clang-diagnostic-deprecated-declarations)
if (p->GetSyncType() == v::Pointable::kSyncNone) {
return absl::OkStatus();
}
@ -252,6 +254,7 @@ absl::Status Sandbox::SynchronizePtrBefore(v::Callable* ptr) {
// Allocation occurs during both before/after synchronization modes. But the
// memory is transferred to the sandboxee only if v::Pointable::kSyncBefore
// was requested.
// NOLINTNEXTLINE(clang-diagnostic-deprecated-declarations)
if ((p->GetSyncType() & v::Pointable::kSyncBefore) == 0) {
return absl::OkStatus();
}
@ -270,6 +273,7 @@ absl::Status Sandbox::SynchronizePtrAfter(v::Callable* ptr) const {
return absl::OkStatus();
}
v::Ptr* p = reinterpret_cast<v::Ptr*>(ptr);
// NOLINTNEXTLINE(clang-diagnostic-deprecated-declarations)
if ((p->GetSyncType() & v::Pointable::kSyncAfter) == 0) {
return absl::OkStatus();
}

View File

@ -61,7 +61,7 @@ cc_test(
":util",
"//sandboxed_api/sandbox2/util:bpf_helper",
"//sandboxed_api/util:status_matchers",
"@com_google_glog//:glog",
"@com_google_absl//absl/log:check",
"@com_google_googletest//:gtest_main",
],
)
@ -80,10 +80,10 @@ cc_library(
":util",
"//sandboxed_api:config",
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/log",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/types:span",
"@com_google_glog//:glog",
],
)
@ -129,7 +129,8 @@ cc_library(
deps = [
":comms",
":logserver_cc_proto",
"@com_google_glog//:glog",
"@com_google_absl//absl/base:log_severity",
"@com_google_absl//absl/log",
],
)
@ -142,9 +143,12 @@ cc_library(
deps = [
":comms",
":logserver_cc_proto",
"@com_google_absl//absl/log:log_entry",
"@com_google_absl//absl/log:log_sink",
"@com_google_absl//absl/log:log_sink_registry",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/synchronization",
"@com_google_glog//:glog",
],
)
@ -157,7 +161,8 @@ cc_library(
":comms",
":logserver",
":logsink",
"@com_google_absl//absl/base:core_headers",
"//sandboxed_api/util:raw_logging",
"@com_google_absl//absl/log",
"@com_google_absl//absl/strings",
],
)
@ -171,14 +176,15 @@ cc_library(
":bpfdisassembler",
":comms",
":namespace",
":regs",
":syscall",
":violation_cc_proto",
"//sandboxed_api:config",
"//sandboxed_api/sandbox2/network_proxy:filtering",
"//sandboxed_api/sandbox2/util:bpf_helper",
"//sandboxed_api/util:flags",
"//sandboxed_api/util:raw_logging",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/log",
"@com_google_absl//absl/types:optional",
],
)
@ -195,7 +201,7 @@ cc_library(
":util",
"//sandboxed_api:config",
"@com_google_absl//absl/base:core_headers",
"@com_google_glog//:glog",
"@com_google_absl//absl/log",
],
)
@ -220,8 +226,7 @@ cc_binary(
":sanitizer",
"//sandboxed_api/util:raw_logging",
"//sandboxed_api/util:strerror",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/log:globals",
],
)
@ -245,15 +250,15 @@ cc_library(
"//sandboxed_api:config",
"//sandboxed_api:embed_file",
"//sandboxed_api/util:fileops",
"//sandboxed_api/util:flags",
"//sandboxed_api/util:raw_logging",
"//sandboxed_api/util:status",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/log",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/synchronization",
"@com_google_glog//:glog",
],
)
@ -286,8 +291,10 @@ cc_library(
":util",
"//sandboxed_api:config",
"//sandboxed_api/util:fileops",
"//sandboxed_api/util:status",
"//sandboxed_api/util:raw_logging",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/status",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:span",
@ -351,7 +358,7 @@ cc_library(
"//sandboxed_api/util:file_base",
"//sandboxed_api/util:file_helpers",
"//sandboxed_api/util:fileops",
"//sandboxed_api/util:flags",
"//sandboxed_api/util:raw_logging",
"//sandboxed_api/util:status",
"//sandboxed_api/util:strerror",
"//sandboxed_api/util:temp_file",
@ -359,6 +366,9 @@ cc_library(
"@com_google_absl//absl/cleanup",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
@ -431,13 +441,12 @@ cc_library(
":util",
"//sandboxed_api/sandbox2/unwind",
"//sandboxed_api/sandbox2/util:bpf_helper",
"//sandboxed_api/util:file_helpers",
"//sandboxed_api/util:fileops",
"//sandboxed_api/util:raw_logging",
"//sandboxed_api/util:status",
"//sandboxed_api/util:strerror",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/log",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
@ -456,8 +465,9 @@ cc_library(
":comms",
":forkserver_cc_proto",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/synchronization",
"@com_google_glog//:glog",
],
)
@ -539,6 +549,7 @@ cc_test(
"//sandboxed_api/util:fileops",
"//sandboxed_api/util:status_matchers",
"//sandboxed_api/util:temp_file",
"@com_google_absl//absl/log",
"@com_google_absl//absl/strings",
"@com_google_googletest//:gtest_main",
],
@ -555,6 +566,7 @@ cc_library(
":comms",
":forkserver",
":sanitizer",
"@com_google_absl//absl/log:check",
],
)
@ -612,6 +624,7 @@ cc_test(
"//sandboxed_api:config",
"//sandboxed_api:testing",
"//sandboxed_api/util:status_matchers",
"@com_google_absl//absl/log",
"@com_google_googletest//:gtest_main",
],
)
@ -666,8 +679,9 @@ cc_test(
":comms_test_cc_proto",
"//sandboxed_api/util:status_matchers",
"@com_google_absl//absl/container:fixed_array",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/strings",
"@com_google_glog//:glog",
"@com_google_googletest//:gtest_main",
"@com_google_protobuf//:protobuf",
],
@ -686,8 +700,9 @@ cc_test(
":global_forkserver",
":sandbox2",
"//sandboxed_api:testing",
"//sandboxed_api/util:raw_logging",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/strings",
"@com_google_glog//:glog",
"@com_google_googletest//:gtest_main",
],
)
@ -719,10 +734,10 @@ cc_test(
tags = ["no_qemu_user_mode"],
deps = [
":comms",
":regs",
":sandbox2",
"//sandboxed_api:testing",
"//sandboxed_api/sandbox2/util:bpf_helper",
"@com_google_absl//absl/log",
"@com_google_absl//absl/strings",
"@com_google_googletest//:gtest_main",
],
@ -771,7 +786,6 @@ cc_test(
":sandbox2",
"//sandboxed_api:config",
"//sandboxed_api:testing",
"//sandboxed_api/sandbox2/util:bpf_helper",
"//sandboxed_api/util:status_matchers",
"@com_google_absl//absl/strings",
"@com_google_googletest//:gtest_main",
@ -796,6 +810,7 @@ cc_test(
"//sandboxed_api/sandbox2/util:bpf_helper",
"//sandboxed_api/util:status_matchers",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/log",
"@com_google_absl//absl/strings",
"@com_google_googletest//:gtest_main",
],
@ -830,10 +845,11 @@ cc_test(
"//sandboxed_api:testing",
"//sandboxed_api/sandbox2/util:bpf_helper",
"//sandboxed_api/util:fileops",
"//sandboxed_api/util:flags",
"//sandboxed_api/util:status_matchers",
"//sandboxed_api/util:temp_file",
"@com_google_absl//absl/cleanup",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:reflection",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_googletest//:gtest_main",
@ -887,10 +903,10 @@ cc_test(
"//sandboxed_api:testing",
"//sandboxed_api/sandbox2/util:bpf_helper",
"//sandboxed_api/util:status_matchers",
"@com_google_absl//absl/log",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_glog//:glog",
"@com_google_googletest//:gtest_main",
],
)

View File

@ -62,7 +62,7 @@ target_link_libraries(sandbox2_syscall
absl::strings
sandbox2::util
sapi::base
PUBLIC glog::glog
PUBLIC absl::log
)
# sandboxed_api/sandbox2:result
@ -106,7 +106,7 @@ target_link_libraries(sandbox2_logserver
PRIVATE sandbox2::comms
sandbox2::logserver_proto
sapi::base
PUBLIC glog::glog
PUBLIC absl::log
)
# sandboxed_api/sandbox2:logsink
@ -121,7 +121,7 @@ target_link_libraries(sandbox2_logsink
sandbox2::logserver_proto
sapi::base
PUBLIC absl::synchronization
glog::glog
absl::log
)
# sandboxed_api/sandbox2:ipc
@ -159,7 +159,6 @@ target_link_libraries(sandbox2_policy PRIVATE
sandbox2::violation_proto
sapi::base
sapi::config
sapi::flags
)
# sandboxed_api/sandbox2:notify
@ -169,7 +168,7 @@ add_library(sandbox2_notify ${SAPI_LIB_TYPE}
add_library(sandbox2::notify ALIAS sandbox2_notify)
target_link_libraries(sandbox2_notify
PUBLIC absl::core_headers
glog::glog
absl::log
sandbox2::comms
sandbox2::result
sandbox2::syscall
@ -197,16 +196,13 @@ set_target_properties(sandbox2_forkserver_bin PROPERTIES
OUTPUT_NAME forkserver_bin)
add_executable(sandbox2::forkserver_bin ALIAS sandbox2_forkserver_bin)
target_link_libraries(sandbox2_forkserver_bin PRIVATE
absl::core_headers
absl::strings
absl::log_globals
sandbox2::client
sandbox2::comms
sandbox2::forkserver
sandbox2::sanitizer
sapi::strerror
sapi::base
sapi::raw_logging
PUBLIC glog::glog
)
# sandboxed_api/sandbox2:forkserver_bin_embed
@ -227,7 +223,7 @@ target_link_libraries(sandbox2_global_forkserver
PRIVATE absl::strings
absl::status
absl::statusor
glog::glog
absl::log
sandbox2::client
sandbox2::forkserver_bin_embed
sapi::strerror
@ -239,11 +235,11 @@ target_link_libraries(sandbox2_global_forkserver
sapi::raw_logging
sapi::status
PUBLIC absl::core_headers
absl::flags
absl::synchronization
sandbox2::comms
sandbox2::fork_client
sandbox2::forkserver_proto
sapi::flags
)
# sandboxed_api/sandbox2:start_global_forkserver_lib_constructor
@ -276,10 +272,10 @@ target_link_libraries(sandbox2_executor
sandbox2::util
sapi::base
sapi::status_proto
PUBLIC absl::span
PUBLIC absl::log
absl::span
absl::status
absl::strings
glog::glog
sapi::config
sapi::fileops
sapi::status
@ -317,7 +313,6 @@ target_link_libraries(sandbox2_sandbox2
sapi::config
sapi::file_base
sapi::fileops
sapi::flags
sapi::status
sapi::temp_file
sandbox2::bpf_helper
@ -426,7 +421,6 @@ add_library(sandbox2::fork_client ALIAS sandbox2_fork_client)
target_link_libraries(sandbox2_fork_client PRIVATE
absl::core_headers
absl::synchronization
glog::glog
sandbox2::comms
sandbox2::forkserver_proto
sapi::base
@ -486,7 +480,8 @@ add_library(sandbox2_forkingclient ${SAPI_LIB_TYPE}
)
add_library(sandbox2::forkingclient ALIAS sandbox2_forkingclient)
target_link_libraries(sandbox2_forkingclient
PRIVATE glog::glog
PRIVATE absl::memory
absl::log
sandbox2::sanitizer
sapi::base
PUBLIC sandbox2::client
@ -617,7 +612,7 @@ if(BUILD_TESTING AND SAPI_BUILD_TESTING)
OUTPUT_NAME regs_test
)
target_link_libraries(sandbox2_regs_test PRIVATE
glog::glog
absl::check
sapi::config
sapi::status_matchers
sandbox2::bpf_helper
@ -739,14 +734,15 @@ if(BUILD_TESTING AND SAPI_BUILD_TESTING)
add_executable(sandbox2_comms_test
comms_test.cc
)
target_link_libraries(sandbox2_comms_test
PRIVATE absl::fixed_array
absl::strings
sandbox2::comms
sandbox2::comms_test_proto
sapi::status_matchers
sapi::test_main
PUBLIC glog::glog
target_link_libraries(sandbox2_comms_test PRIVATE
absl::check
absl::fixed_array
absl::log
absl::strings
sandbox2::comms
sandbox2::comms_test_proto
sapi::status_matchers
sapi::test_main
)
gtest_discover_tests_xcompile(sandbox2_comms_test)
@ -762,11 +758,13 @@ if(BUILD_TESTING AND SAPI_BUILD_TESTING)
sandbox2::testcase_minimal
)
target_link_libraries(sandbox2_forkserver_test PRIVATE
absl::check
absl::strings
sandbox2::comms
sandbox2::forkserver
sandbox2::forkserver_proto
sandbox2::sandbox2
sapi::raw_logging
sapi::testing
sapi::test_main
)
@ -936,16 +934,16 @@ if(BUILD_TESTING AND SAPI_BUILD_TESTING)
)
target_link_libraries(sandbox2_stack_trace_test PRIVATE
absl::cleanup
absl::flags
absl::status
absl::strings
sandbox2::bpf_helper
sapi::fileops
sandbox2::global_forkserver
sandbox2::sandbox2
sandbox2::util
sapi::fileops
sapi::temp_file
sapi::testing
sandbox2::util
sapi::flags
sapi::status_matchers
sapi::test_main
)
@ -970,7 +968,6 @@ if(BUILD_TESTING AND SAPI_BUILD_TESTING)
sandbox2::ipc
sandbox2::sandbox2
sapi::testing
sapi::flags
sapi::status_matchers
sapi::test_main
)
@ -994,7 +991,6 @@ if(BUILD_TESTING AND SAPI_BUILD_TESTING)
sandbox2::bpf_helper
sandbox2::comms
sapi::testing
sapi::flags
sapi::status_matchers
sapi::test_main
PUBLIC sandbox2::sandbox2

View File

@ -24,9 +24,9 @@
#include <utility>
#include <vector>
#include <glog/logging.h>
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/log/log.h"
#include "sandboxed_api/config.h"
#include "sandboxed_api/sandbox2/comms.h"
#include "sandboxed_api/sandbox2/executor.h"

View File

@ -1,4 +1,3 @@
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -26,11 +25,12 @@
#include <thread> // NOLINT(build/c++11)
#include <utility>
#include <glog/logging.h>
#include "google/protobuf/text_format.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/container/fixed_array.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/strings/string_view.h"
#include "sandboxed_api/sandbox2/comms_test.pb.h"
#include "sandboxed_api/util/status_matchers.h"

View File

@ -34,10 +34,13 @@ cc_binary(
"//sandboxed_api/sandbox2",
"//sandboxed_api/sandbox2:comms",
"//sandboxed_api/sandbox2/util:bpf_helper",
"//sandboxed_api/util:flags",
"//sandboxed_api/util:logging",
"//sandboxed_api/util:runfiles",
"@com_google_glog//:glog",
"@com_google_absl//absl/base:log_severity",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:globals",
"@com_google_absl//absl/log:initialize",
],
)
@ -50,8 +53,8 @@ cc_binary(
"//sandboxed_api/sandbox2:client",
"//sandboxed_api/sandbox2:comms",
"//sandboxed_api/sandbox2:util",
"//sandboxed_api/util:flags",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
],
)
@ -68,7 +71,7 @@ cc_test(
"//sandboxed_api:testing",
"//sandboxed_api/sandbox2:util",
"//sandboxed_api/util:status_matchers",
"@com_google_glog//:glog",
"@com_google_absl//absl/log",
"@com_google_googletest//:gtest_main",
],
)

View File

@ -21,13 +21,15 @@ add_dependencies(sandbox2_crc4sandbox
sandbox2::crc4bin
)
target_link_libraries(sandbox2_crc4sandbox PRIVATE
absl::flags
absl::flags_parse
absl::log
absl::log_initialize
sandbox2::bpf_helper
sandbox2::comms
sapi::runfiles
sandbox2::sandbox2
sapi::base
sapi::flags
sapi::logging
)
# sandboxed_api/sandbox2/examples/crc4:crc4bin
@ -38,9 +40,10 @@ set_target_properties(sandbox2_crc4bin PROPERTIES OUTPUT_NAME crc4bin)
add_executable(sandbox2::crc4bin ALIAS sandbox2_crc4bin)
target_link_libraries(sandbox2_crc4bin PRIVATE
absl::core_headers
absl::flags
absl::flags_parse
sandbox2::client
sandbox2::comms
sandbox2::util
sapi::base
sapi::flags
)

View File

@ -20,7 +20,8 @@
#include <cstdint>
#include <cstring>
#include "sandboxed_api/util/flag.h"
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "sandboxed_api/sandbox2/client.h"
#include "sandboxed_api/sandbox2/comms.h"
#include "sandboxed_api/sandbox2/util.h"
@ -45,7 +46,7 @@ static uint32_t ComputeCRC4Impl(const uint8_t* ptr, uint64_t len) {
}
int main(int argc, char* argv[]) {
gflags::ParseCommandLineFlags(&argc, &argv, false);
absl::ParseCommandLine(argc, argv);
// Set-up the sandbox2::Client object, using a file descriptor (1023).
sandbox2::Comms comms(sandbox2::Comms::kDefaultConnection);

View File

@ -27,8 +27,12 @@
#include <utility>
#include <vector>
#include <glog/logging.h>
#include "sandboxed_api/util/flag.h"
#include "absl/base/log_severity.h"
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "absl/log/log.h"
#include "sandboxed_api/config.h"
#include "sandboxed_api/sandbox2/comms.h"
#include "sandboxed_api/sandbox2/executor.h"
@ -38,12 +42,9 @@
#include "sandboxed_api/sandbox2/result.h"
#include "sandboxed_api/sandbox2/sandbox2.h"
#include "sandboxed_api/sandbox2/util/bpf_helper.h"
#include "sandboxed_api/util/logging.h"
#include "sandboxed_api/util/runfiles.h"
using std::string; // gflags <-> Abseil Flags
ABSL_FLAG(string, input, "", "Input to calculate CRC4 of.");
ABSL_FLAG(std::string, input, "", "Input to calculate CRC4 of.");
ABSL_FLAG(bool, call_syscall_not_allowed, false,
"Have sandboxee call clone (violation).");
@ -88,8 +89,9 @@ bool SandboxedCRC4(sandbox2::Comms* comms, uint32_t* crc4) {
} // namespace
int main(int argc, char* argv[]) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
sapi::InitLogging(argv[0]);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
absl::ParseCommandLine(argc, argv);
absl::InitializeLog();
if (absl::GetFlag(FLAGS_input).empty()) {
LOG(ERROR) << "Parameter --input required.";

View File

@ -18,9 +18,9 @@
#include <string>
#include <glog/logging.h>
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "absl/log/log.h"
#include "sandboxed_api/sandbox2/util.h"
#include "sandboxed_api/testing.h"
#include "sandboxed_api/util/status_matchers.h"

View File

@ -31,9 +31,13 @@ cc_binary(
"//sandboxed_api/sandbox2",
"//sandboxed_api/sandbox2:comms",
"//sandboxed_api/sandbox2:forkserver",
"//sandboxed_api/util:flags",
"//sandboxed_api/util:logging",
"//sandboxed_api/util:runfiles",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/log:globals",
"@com_google_absl//absl/log:initialize",
],
)
@ -45,8 +49,11 @@ cc_binary(
deps = [
"//sandboxed_api/sandbox2:comms",
"//sandboxed_api/sandbox2:forkingclient",
"//sandboxed_api/util:flags",
"//sandboxed_api/util:raw_logging",
"@com_google_absl//absl/base:log_severity",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/log:globals",
"@com_google_absl//absl/log:initialize",
],
)

View File

@ -22,13 +22,16 @@ add_dependencies(sandbox2_custom_fork_sandbox
)
target_link_libraries(sandbox2_custom_fork_sandbox PRIVATE
absl::core_headers
absl::flags
absl::flags_parse
absl::log
absl::log_globals
absl::log_initialize
sandbox2::comms
sandbox2::forkserver
sapi::runfiles
sandbox2::sandbox2
sapi::base
sapi::flags
sapi::logging
sapi::raw_logging
)
@ -41,10 +44,11 @@ set_target_properties(sandbox2_custom_fork_bin PROPERTIES
)
add_executable(sandbox2::custom_fork_bin ALIAS sandbox2_custom_fork_bin)
target_link_libraries(sandbox2_custom_fork_bin PRIVATE
absl::log_initialize
absl::flags_parse
sandbox2::comms
sandbox2::forkingclient
sandbox2::util
sapi::base
sapi::flags
sapi::raw_logging
)

View File

@ -20,7 +20,10 @@
#include <cstdint>
#include "sandboxed_api/util/flag.h"
#include "absl/base/log_severity.h"
#include "absl/flags/parse.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "sandboxed_api/sandbox2/comms.h"
#include "sandboxed_api/sandbox2/forkingclient.h"
#include "sandboxed_api/util/raw_logging.h"
@ -38,10 +41,11 @@ static int SandboxeeFunction(sandbox2::Comms* comms) {
}
int main(int argc, char* argv[]) {
absl::ParseCommandLine(argc, argv);
// Writing to stderr limits the number of invoked syscalls.
gflags::SetCommandLineOptionWithMode("logtostderr", "true",
gflags::SET_FLAG_IF_DEFAULT);
gflags::ParseCommandLineFlags(&argc, &argv, false);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
absl::InitializeLog();
// Instantiate Comms channel with the parent Executor
sandbox2::Comms comms(sandbox2::Comms::kDefaultConnection);

View File

@ -23,8 +23,12 @@
#include <utility>
#include <vector>
#include <glog/logging.h>
#include "sandboxed_api/util/flag.h"
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/log/check.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "absl/log/log.h"
#include "sandboxed_api/config.h"
#include "sandboxed_api/sandbox2/comms.h"
#include "sandboxed_api/sandbox2/executor.h"
@ -34,7 +38,6 @@
#include "sandboxed_api/sandbox2/policybuilder.h"
#include "sandboxed_api/sandbox2/result.h"
#include "sandboxed_api/sandbox2/sandbox2.h"
#include "sandboxed_api/util/logging.h"
#include "sandboxed_api/util/runfiles.h"
std::unique_ptr<sandbox2::Policy> GetPolicy() {
@ -93,8 +96,9 @@ static int SandboxIteration(sandbox2::ForkClient* fork_client, int32_t i) {
}
int main(int argc, char* argv[]) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
sapi::InitLogging(argv[0]);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
absl::ParseCommandLine(argc, argv);
absl::InitializeLog();
// This test is incompatible with sanitizers.
// The `SKIP_SANITIZERS_AND_COVERAGE` macro won't work for us here since we

View File

@ -34,10 +34,13 @@ cc_binary(
"//sandboxed_api/sandbox2:comms",
"//sandboxed_api/sandbox2/util:bpf_helper",
"//sandboxed_api/util:fileops",
"//sandboxed_api/util:flags",
"//sandboxed_api/util:logging",
"//sandboxed_api/util:runfiles",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:globals",
"@com_google_absl//absl/log:initialize",
],
)
@ -49,7 +52,7 @@ cc_binary(
deps = [
"//sandboxed_api/sandbox2:client",
"//sandboxed_api/sandbox2:comms",
"//sandboxed_api/sandbox2:util",
"@com_google_absl//absl/log",
"@com_google_absl//absl/strings:str_format",
],
)

View File

@ -21,14 +21,17 @@ add_dependencies(sandbox2_network_sandbox
sandbox2::network_bin
)
target_link_libraries(sandbox2_network_sandbox PRIVATE
absl::flags
absl::flags_parse
absl::log
absl::log_globals
absl::log_initialize
sandbox2::bpf_helper
sandbox2::comms
sapi::fileops
sapi::runfiles
sandbox2::sandbox2
sapi::base
sapi::flags
sapi::logging
)
# sandboxed_api/sandbox2/examples/network_bin:network_bin

View File

@ -22,10 +22,10 @@
#include <cstring>
#include <string>
#include "absl/log/log.h"
#include "absl/strings/str_format.h"
#include "sandboxed_api/sandbox2/client.h"
#include "sandboxed_api/sandbox2/comms.h"
#include "sandboxed_api/sandbox2/util.h"
static ssize_t ReadFromFd(int fd, uint8_t* buf, size_t size) {
ssize_t received = 0;
@ -73,6 +73,8 @@ int main(int argc, char* argv[]) {
return 1;
}
if (!CommunicationTest(client)) return 2;
if (!CommunicationTest(client)) {
return 2;
}
return 0;
}

View File

@ -27,9 +27,12 @@
#include <cstdlib>
#include <string>
#include <glog/logging.h>
#include "absl/base/macros.h"
#include "sandboxed_api/util/flag.h"
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "absl/log/log.h"
#include "sandboxed_api/config.h"
#include "sandboxed_api/sandbox2/comms.h"
#include "sandboxed_api/sandbox2/executor.h"
@ -38,7 +41,6 @@
#include "sandboxed_api/sandbox2/sandbox2.h"
#include "sandboxed_api/sandbox2/util/bpf_helper.h"
#include "sandboxed_api/util/fileops.h"
#include "sandboxed_api/util/logging.h"
#include "sandboxed_api/util/runfiles.h"
namespace {
@ -174,8 +176,9 @@ int main(int argc, char* argv[]) {
return EXIT_SUCCESS;
}
gflags::ParseCommandLineFlags(&argc, &argv, true);
sapi::InitLogging(argv[0]);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
absl::ParseCommandLine(argc, argv);
absl::InitializeLog();
int port = 8085;
std::thread server_thread{Server,port};
server_thread.detach();

View File

@ -30,10 +30,13 @@ cc_binary(
"//sandboxed_api/sandbox2:comms",
"//sandboxed_api/sandbox2/util:bpf_helper",
"//sandboxed_api/util:fileops",
"//sandboxed_api/util:flags",
"//sandboxed_api/util:logging",
"//sandboxed_api/util:runfiles",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:globals",
"@com_google_absl//absl/log:initialize",
],
)
@ -47,12 +50,15 @@ cc_binary(
"//sandboxed_api/sandbox2:comms",
"//sandboxed_api/sandbox2/network_proxy:client",
"//sandboxed_api/util:fileops",
"//sandboxed_api/util:flags",
"//sandboxed_api/util:status",
"//sandboxed_api/util:strerror",
"@com_google_absl//absl/base:log_severity",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:globals",
"@com_google_absl//absl/log:initialize",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
],
)

View File

@ -21,14 +21,17 @@ add_dependencies(sandbox2_networkproxy_sandbox
sandbox2::networkproxy_bin
)
target_link_libraries(sandbox2_networkproxy_sandbox PRIVATE
absl::flags
absl::flags_parse
absl::log
absl::log_globals
absl::log_initialize
sandbox2::bpf_helper
sandbox2::comms
sapi::fileops
sapi::runfiles
sandbox2::sandbox2
sapi::base
sapi::flags
sapi::logging
)
# sandboxed_api/sandbox2/examples/networkproxy:networkproxy_bin
@ -40,6 +43,11 @@ set_target_properties(sandbox2_networkproxy_bin PROPERTIES
)
add_executable(sandbox2::networkproxy_bin ALIAS sandbox2_networkproxy_bin)
target_link_libraries(sandbox2_networkproxy_bin PRIVATE absl::status
absl::flags
absl::flags_parse
absl::log
absl::log_globals
absl::log_initialize
absl::statusor
absl::str_format
sandbox2::client
@ -47,7 +55,6 @@ target_link_libraries(sandbox2_networkproxy_bin PRIVATE absl::status
sapi::fileops
sandbox2::network_proxy_client
sapi::base
sapi::flags
sapi::status
sapi::strerror
)

View File

@ -11,10 +11,14 @@
#include <cstring>
#include "sandboxed_api/util/flag.h"
#include "absl/base/log_severity.h"
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "sandboxed_api/sandbox2/client.h"
#include "sandboxed_api/sandbox2/comms.h"
@ -105,7 +109,9 @@ absl::StatusOr<int> ConnectToServer(int port) {
} // namespace
int main(int argc, char* argv[]) {
gflags::ParseCommandLineFlags(&argc, &argv, false);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
absl::ParseCommandLine(argc, argv);
absl::InitializeLog();
// Set-up the sandbox2::Client object, using a file descriptor (1023).
sandbox2::Comms comms(sandbox2::Comms::kDefaultConnection);

View File

@ -15,9 +15,12 @@
#include <string>
#include <vector>
#include <glog/logging.h>
#include "absl/base/macros.h"
#include "sandboxed_api/util/flag.h"
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "absl/log/log.h"
#include "sandboxed_api/config.h"
#include "sandboxed_api/sandbox2/comms.h"
#include "sandboxed_api/sandbox2/executor.h"
@ -26,7 +29,6 @@
#include "sandboxed_api/sandbox2/sandbox2.h"
#include "sandboxed_api/sandbox2/util/bpf_helper.h"
#include "sandboxed_api/util/fileops.h"
#include "sandboxed_api/util/logging.h"
#include "sandboxed_api/util/runfiles.h"
ABSL_FLAG(bool, connect_with_handler, true, "Connect using automatic mode.");
@ -124,10 +126,11 @@ int main(int argc, char* argv[]) {
return EXIT_SUCCESS;
}
gflags::ParseCommandLineFlags(&argc, &argv, true);
sapi::InitLogging(argv[0]);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
absl::ParseCommandLine(argc, argv);
absl::InitializeLog();
int port = 8085;
std::thread server_thread{Server,port};
std::thread server_thread{Server, port};
server_thread.detach();
// Note: In your own code, use sapi::GetDataDependencyFilePath() instead.

View File

@ -34,9 +34,12 @@ cc_binary(
"//sandboxed_api:config",
"//sandboxed_api/sandbox2",
"//sandboxed_api/sandbox2/util:bpf_helper",
"//sandboxed_api/util:flags",
"//sandboxed_api/util:logging",
"//sandboxed_api/util:runfiles",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:globals",
"@com_google_absl//absl/log:initialize",
],
)

View File

@ -21,12 +21,14 @@ add_dependencies(sandbox2_static_sandbox
sandbox2::static_bin
)
target_link_libraries(sandbox2_static_sandbox PRIVATE
absl::flags
absl::flags_parse
absl::log
absl::log_initialize
sandbox2::bpf_helper
sapi::runfiles
sandbox2::sandbox2
sapi::base
sapi::flags
sapi::logging
)
# sandboxed_api/sandbox2/examples/static:static_bin

View File

@ -28,8 +28,11 @@
#include <utility>
#include <vector>
#include <glog/logging.h>
#include "sandboxed_api/util/flag.h"
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "absl/log/log.h"
#include "sandboxed_api/config.h"
#include "sandboxed_api/sandbox2/executor.h"
#include "sandboxed_api/sandbox2/limits.h"
@ -38,7 +41,6 @@
#include "sandboxed_api/sandbox2/result.h"
#include "sandboxed_api/sandbox2/sandbox2.h"
#include "sandboxed_api/sandbox2/util/bpf_helper.h"
#include "sandboxed_api/util/logging.h"
#include "sandboxed_api/util/runfiles.h"
std::unique_ptr<sandbox2::Policy> GetPolicy() {
@ -126,8 +128,9 @@ int main(int argc, char* argv[]) {
if constexpr (sapi::sanitizers::IsAny()) {
return EXIT_SUCCESS;
}
gflags::ParseCommandLineFlags(&argc, &argv, true);
sapi::InitLogging(argv[0]);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
absl::ParseCommandLine(argc, argv);
absl::InitializeLog();
// Note: In your own code, use sapi::GetDataDependencyFilePath() instead.
const std::string path = sapi::internal::GetSapiDataDependencyFilePath(

View File

@ -34,8 +34,11 @@ cc_binary(
"//sandboxed_api/sandbox2:util",
"//sandboxed_api/sandbox2/util:bpf_helper",
"//sandboxed_api/util:fileops",
"//sandboxed_api/util:flags",
"//sandboxed_api/util:logging",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:globals",
"@com_google_absl//absl/log:initialize",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/time",

View File

@ -19,12 +19,15 @@ add_executable(sandbox2_sandbox2tool
set_target_properties(sandbox2_sandbox2tool PROPERTIES OUTPUT_NAME sandbox2tool)
add_executable(sandbox2::sandbox2tool ALIAS sandbox2_sandbox2tool)
target_link_libraries(sandbox2_sandbox2tool PRIVATE
absl::flags
absl::flags_parse
absl::log
absl::log_globals
absl::log_initialize
absl::strings
absl::time
sandbox2::bpf_helper
sandbox2::sandbox2
sandbox2::util
sapi::base
sapi::flags
sapi::logging
)

View File

@ -34,8 +34,11 @@
#include <utility>
#include <vector>
#include <glog/logging.h>
#include "sandboxed_api/util/flag.h"
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "absl/log/log.h"
#include "absl/strings/str_format.h"
#include "absl/strings/str_split.h"
#include "absl/time/time.h"
@ -49,9 +52,6 @@
#include "sandboxed_api/sandbox2/util.h"
#include "sandboxed_api/sandbox2/util/bpf_helper.h"
#include "sandboxed_api/util/fileops.h"
#include "sandboxed_api/util/logging.h"
using std::string;
ABSL_FLAG(bool, sandbox2tool_keep_env, false,
"Keep current environment variables");
@ -78,9 +78,9 @@ ABSL_FLAG(uint64_t, sandbox2tool_walltime_timeout, 60U,
"Wall-time timeout in seconds (if >0)");
ABSL_FLAG(uint64_t, sandbox2tool_file_size_creation_limit, 1024U,
"Maximum size of created files");
ABSL_FLAG(string, sandbox2tool_cwd, "/",
ABSL_FLAG(std::string, sandbox2tool_cwd, "/",
"If not empty, chdir to the directory before sandboxed");
ABSL_FLAG(string, sandbox2tool_additional_bind_mounts, "",
ABSL_FLAG(std::string, sandbox2tool_additional_bind_mounts, "",
"If user namespaces are enabled, this option will add additional "
"bind mounts. Mounts are separated by comma and can optionally "
"specify a target using \"=>\" "
@ -105,8 +105,9 @@ void OutputFD(int fd) {
} // namespace
int main(int argc, char* argv[]) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
sapi::InitLogging(argv[0]);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
absl::ParseCommandLine(argc, argv);
absl::InitializeLog();
if (argc < 2) {
absl::FPrintF(stderr, "Usage: %s [flags] -- cmd args...", argv[0]);

View File

@ -26,9 +26,12 @@ cc_binary(
"//sandboxed_api/sandbox2",
"//sandboxed_api/sandbox2:comms",
"//sandboxed_api/sandbox2/util:bpf_helper",
"//sandboxed_api/util:flags",
"//sandboxed_api/util:logging",
"//sandboxed_api/util:runfiles",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:globals",
"@com_google_absl//absl/log:initialize",
],
)

View File

@ -21,13 +21,16 @@ add_dependencies(sandbox2_zpipe_sandbox
sandbox2::zpipe
)
target_link_libraries(sandbox2_zpipe_sandbox PRIVATE
absl::flags
absl::flags_parse
absl::log
absl::log_globals
absl::log_initialize
sandbox2::bpf_helper
sandbox2::comms
sapi::logging
sapi::runfiles
sandbox2::sandbox2
sapi::base
sapi::flags
)
# sandboxed_api/sandbox2/examples/zlib:zpipe

View File

@ -26,8 +26,11 @@
#include <utility>
#include <vector>
#include <glog/logging.h>
#include "sandboxed_api/util/flag.h"
#include "absl/flags/flag.h"
#include "absl/flags/parse.h"
#include "absl/log/globals.h"
#include "absl/log/initialize.h"
#include "absl/log/log.h"
#include "sandboxed_api/sandbox2/comms.h"
#include "sandboxed_api/sandbox2/executor.h"
#include "sandboxed_api/sandbox2/limits.h"
@ -36,13 +39,10 @@
#include "sandboxed_api/sandbox2/result.h"
#include "sandboxed_api/sandbox2/sandbox2.h"
#include "sandboxed_api/sandbox2/util/bpf_helper.h"
#include "sandboxed_api/util/logging.h"
#include "sandboxed_api/util/runfiles.h"
using std::string;
ABSL_FLAG(string, input, "", "Input file");
ABSL_FLAG(string, output, "", "Output file");
ABSL_FLAG(std::string, input, "", "Input file");
ABSL_FLAG(std::string, output, "", "Output file");
ABSL_FLAG(bool, decompress, false, "Decompress instead of compress.");
namespace {
@ -72,8 +72,9 @@ std::unique_ptr<sandbox2::Policy> GetPolicy() {
} // namespace
int main(int argc, char* argv[]) {
gflags::ParseCommandLineFlags(&argc, &argv, true);
sapi::InitLogging(argv[0]);
absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo);
absl::ParseCommandLine(argc, argv);
absl::InitializeLog();
if (absl::GetFlag(FLAGS_input).empty()) {
LOG(ERROR) << "Parameter --input required.";

Some files were not shown because too many files have changed in this diff Show More