sandboxed-api/oss-internship-2020/libarchive
Christian Blichmann 51799f99ae Introduce a transitional logging utility library
Instead of calling `google::InitGoogleLogging()` directly, introduce an
indirection via a new utility library. After this change, Sandboxed API
should consistently use `sapi::InitLogging()` everywhere.

For now, `sapi::InitLogging()` simply calls its glog equivalent. However,
this enables us to migrate away from the gflags dependency and use Abseil
flags. Once a follow-up change lands, `sapi::InitLogging()` will instead
initialize the google logging library with flags defined from Aseil.

Later still, once Abseil releases logging, we can then drop the glog
dependency entirely.

PiperOrigin-RevId: 445363592
Change-Id: Ia23a7dc88b8ffe65a422ea4d5233bba7bdd1303a
2022-04-29 02:14:06 -07:00
..
examples Introduce a transitional logging utility library 2022-04-29 02:14:06 -07:00
ld_preload_example #Cleanup: Consistently use char* argv[] instead of char** 2022-04-27 00:43:51 -07:00
patches renamed main project folder 2020-09-28 15:35:51 +00:00
test Change license link to HTTPS URL 2022-01-28 01:39:09 -08:00
.gitignore Modified sandbox to limit ioctl. Use .value() instead of manually checking .ok(). 2020-10-02 15:52:29 +00:00
CMakeLists.txt Change license link to HTTPS URL 2022-01-28 01:39:09 -08:00
functions_to_sandbox.txt renamed main project folder 2020-09-28 15:35:51 +00:00
README.md added empty line at the end of files (was removed by clang-format) 2020-10-07 14:36:24 +00:00

libarchive Sandboxed API

Sandboxed version of the libarchive minitar example using Sandboxed API.

Build

mkdir -p build && cd build
cmake .. -G Ninja
cmake --build .

The example binary file can be found at build/examples/sapi_minitar and the unit tests at build/test/sapi_minitar_test.

Patches

The original libarchive code required patching since one of the custom types produced errors with libclang Python byndings. The patches are applied automatically during the build step and they do not modify the functionality of the library. The repository is also fetched automatically.

Examples

In this project, the minitar example is sandboxed. The code is found in the examples directory and is structured as follows:

  • sapi_minitar_main.cc - main function of the minitar tool. This is mostly similar to the original example.
  • sapi_minitar.h and sapi_minitar.cc - The two main functions (CreateArchive and ExtractArchive) and other helper functions.
  • sandbox.h - Custom security policies, depending on the whether the user creates or extracts an archive.

On top of that, unit tests can be found in the test/minitar_test.cc file.

Usage

The unit tests can be executed with ./build/test/sapi_minitar_test.

The sapi_minitar command line tool can be used in the same way as the original example. It is also similar to the tar command, only with fewer options:

./build/examples/sapi_minitar -[options] [-f file] [files]

The available options are:

  • c - Create archive.
  • x - Extract archive.
  • t - Extract archive but only print entries.
  • p - Preserve.
  • v - Verbose.
  • j or y - Compress with BZIP2.
  • Z - Default compression.
  • z - Compress with GZIP.

If no compression method is chosen (in the case of archive creation) the files will only be stored.