Crate tar
A library for reading and writing TAR archives
This library provides utilities necessary to manage TAR archives abstracted over a reader or writer. Great strides are taken to ensure that an archive is never required to be fully resident in memory, and all objects provide largely a streaming interface to read bytes from.
Security
When unpacking archives (Archive::unpack, Entry::unpack_in), a
best-effort is made to prevent writing files outside the destination
directory: paths containing .. are rejected, and symlink targets within
the archive are validated before use.
Concurrent mutation of the destination tree is outside the threat model.
If another process modifies the destination (for example, by atomically
swapping a symlink) while extraction is in progress, this crate may follow
a path outside the intended destination. Preventing such TOCTOU races
requires OS primitives (e.g. openat/O_PATH used throughout) that this
crate does not use. When extracting untrusted archives in an environment
where the destination may be concurrently modified, use the cap-std
crate and/or OS-level sandboxing.
Structs
- Archive A top-level representation of an archive file.
- Builder A structure for building archives
- Entries An iterator over the entries of an archive.
- Entry A read-only view into an entry of an archive.
- EntryWriter A writer for a single entry in a tar archive.
- GnuExtSparseHeader Representation of the entry found to represent extended GNU sparse files.
- GnuHeader Representation of the header of an entry in an archive
- GnuSparseHeader Description of the header of a sparse entry.
- Header Representation of the header of an entry in an archive
- OldHeader Representation of the header of an entry in an archive
- PaxExtension A key/value pair corresponding to a pax extension.
- PaxExtensions An iterator over the pax extensions in an archive entry.
- UstarHeader Representation of the header of an entry in an archive
Enums
- EntryType Indicate the type of content described by a header.
- HeaderMode Declares the information that should be included when filling a Header from filesystem metadata.
- Unpacked When unpacking items the unpacked thing is returned to allow custom additional handling by users. Today the File is returned, in future the enum may be extended with kinds for links, directories etc.
Constants
-
DETERMINISTIC_TIMESTAMP
A deterministic, arbitrary, non-zero timestamp that use used as
mtimeof headers whenHeaderMode::Deterministicis used.