sandboxed-api/oss-internship-2020/libarchive
2020-10-01 19:01:50 +00:00
..
examples Added unit tests. Cleaned up the code and added comments. Added README 2020-10-01 00:15:33 +00:00
patches renamed main project folder 2020-09-28 15:35:51 +00:00
test Added unit tests. Cleaned up the code and added comments. Added README 2020-10-01 00:15:33 +00:00
.clang-format renamed main project folder 2020-09-28 15:35:51 +00:00
.gitignore Added test helper class 2020-09-29 19:27:40 +00:00
CMakeLists.txt Added FetchContent command to cmake so that patches are applied automatically to libarchive clone 2020-10-01 19:01:50 +00:00
functions_to_sandbox.txt renamed main project folder 2020-09-28 15:35:51 +00:00
README.md Added unit tests. Cleaned up the code and added comments. Added README 2020-10-01 00:15:33 +00:00

libarchive Sandboxed API

Sandboxed version of the libarchive minitar example using Sandboxed API.

Build

First, run git submodule update --init --recursive to update submodules. After this, run the following commands:

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

TODO

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 (create and extract) and also 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 archived.