1# libarchive Sandboxed API 2 3Sandboxed version of the [libarchive](https://www.libarchive.org/) minitar [example](https://github.com/libarchive/libarchive/blob/master/examples/minitar/minitar.c) using [Sandboxed API](https://github.com/google/sandboxed-api). 4 5## Build 6 7``` 8mkdir -p build && cd build 9cmake .. -G Ninja 10cmake --build . 11``` 12 13The example binary file can be found at **build/examples/sapi_minitar** and the unit tests at **build/test/sapi_minitar_test**. 14 15## Patches 16 17The 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. 18 19## Examples 20 21In this project, the minitar example is sandboxed. 22The code is found in the **examples** directory and is structured as follows: 23- **sapi_minitar_main.cc** - ***main*** function of the minitar tool. This is mostly similar to the original example. 24- **sapi_minitar.h** and **sapi_minitar.cc** - The two main functions (***CreateArchive*** and ***ExtractArchive***) and other helper functions. 25- **sandbox.h** - Custom security policies, depending on the whether the user creates or extracts an archive. 26 27On top of that, unit tests can be found in the **test/minitar_test.cc** file. 28 29## Usage 30 31The unit tests can be executed with `./build/test/sapi_minitar_test`. 32 33The **sapi_minitar** command line tool can be used in the same way as the original example. It is also similar to the [tar](https://man7.org/linux/man-pages/man1/tar.1.html) command, only with fewer options: 34 35`./build/examples/sapi_minitar -[options] [-f file] [files]` 36 37The available options are: 38- *c* - Create archive. 39- *x* - Extract archive. 40- *t* - Extract archive but only print entries. 41- *p* - Preserve. 42- *v* - Verbose. 43- *j* or *y* - Compress with BZIP2. 44- *Z* - Default compression. 45- *z* - Compress with GZIP. 46 47If no compression method is chosen (in the case of archive creation) the files will only be stored. 48 49